Jelajahi Sumber

libobs: Add function to check fast clear capability

Ryan Foster 2 tahun lalu
induk
melakukan
e5d5df879c

+ 5 - 0
libobs-d3d11/d3d11-subsystem.cpp

@@ -3593,3 +3593,8 @@ uint32_t gs_get_adapter_count(void)
 
 	return count;
 }
+
+extern "C" EXPORT bool device_can_adapter_fast_clear(gs_device_t *device)
+{
+	return device->fastClearSupported;
+}

+ 1 - 0
libobs/graphics/graphics-imports.c

@@ -221,6 +221,7 @@ bool load_graphics_imports(struct gs_exports *exports, void *module,
 	GRAPHICS_IMPORT_OPTIONAL(gs_duplicator_get_color_space);
 	GRAPHICS_IMPORT_OPTIONAL(gs_duplicator_get_sdr_white_level);
 	GRAPHICS_IMPORT_OPTIONAL(gs_get_adapter_count);
+	GRAPHICS_IMPORT_OPTIONAL(device_can_adapter_fast_clear);
 	GRAPHICS_IMPORT_OPTIONAL(device_texture_create_gdi);
 	GRAPHICS_IMPORT_OPTIONAL(gs_texture_get_dc);
 	GRAPHICS_IMPORT_OPTIONAL(gs_texture_release_dc);

+ 1 - 0
libobs/graphics/graphics-internal.h

@@ -312,6 +312,7 @@ struct gs_exports {
 	float (*gs_duplicator_get_sdr_white_level)(gs_duplicator_t *duplicator);
 
 	uint32_t (*gs_get_adapter_count)(void);
+	bool (*device_can_adapter_fast_clear)(gs_device_t *device);
 
 	gs_texture_t *(*device_texture_create_gdi)(gs_device_t *device,
 						   uint32_t width,

+ 11 - 0
libobs/graphics/graphics.c

@@ -3040,6 +3040,17 @@ uint32_t gs_get_adapter_count(void)
 	return thread_graphics->exports.gs_get_adapter_count();
 }
 
+bool gs_can_adapter_fast_clear(void)
+{
+	if (!gs_valid("gs_can_adapter_fast_clear"))
+		return false;
+	if (!thread_graphics->exports.device_can_adapter_fast_clear)
+		return false;
+
+	return thread_graphics->exports.device_can_adapter_fast_clear(
+		thread_graphics->device);
+}
+
 gs_texture_t *gs_duplicator_get_texture(gs_duplicator_t *duplicator)
 {
 	if (!gs_valid_p("gs_duplicator_get_texture", duplicator))

+ 1 - 0
libobs/graphics/graphics.h

@@ -924,6 +924,7 @@ gs_duplicator_get_color_space(gs_duplicator_t *duplicator);
 EXPORT float gs_duplicator_get_sdr_white_level(gs_duplicator_t *duplicator);
 
 EXPORT uint32_t gs_get_adapter_count(void);
+EXPORT bool gs_can_adapter_fast_clear(void);
 
 /** creates a windows GDI-lockable texture */
 EXPORT gs_texture_t *gs_texture_create_gdi(uint32_t width, uint32_t height);