From 27010a2f566477717fce22fb84e4cf73f0dcef19 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Wed, 25 Jun 2014 19:32:34 -0700 Subject: [PATCH] Add a 'flush' command to graphics subsystem ...I'm actually concerned that I went a bit overkill trying to prevent backwards compatibility issues with this abstraction design, because this is a large number of files that have to be modified just to add a single graphics subsystem export. Someone's going to strangle me, and when you know that someone might strangle you, that means that you did something wrong. We'll have to look in to simplifying this in the future without killing backward compatibility safety. --- libobs-d3d11/d3d11-subsystem.cpp | 5 +++++ libobs-opengl/gl-subsystem.c | 5 +++++ libobs/graphics/device-exports.h | 1 + libobs/graphics/graphics-imports.c | 1 + libobs/graphics/graphics-internal.h | 1 + libobs/graphics/graphics.c | 8 ++++++++ libobs/graphics/graphics.h | 1 + 7 files changed, 22 insertions(+) diff --git a/libobs-d3d11/d3d11-subsystem.cpp b/libobs-d3d11/d3d11-subsystem.cpp index d22f4e178..4090a3126 100644 --- a/libobs-d3d11/d3d11-subsystem.cpp +++ b/libobs-d3d11/d3d11-subsystem.cpp @@ -1204,6 +1204,11 @@ void device_present(device_t device) device->curSwapChain->swap->Present(0, 0); } +void device_flush(device_t device) +{ + device->context->Flush(); +} + void device_setcullmode(device_t device, enum gs_cull_mode mode) { if (mode == device->rasterState.cullMode) diff --git a/libobs-opengl/gl-subsystem.c b/libobs-opengl/gl-subsystem.c index 6793a19d3..dea69bc4f 100644 --- a/libobs-opengl/gl-subsystem.c +++ b/libobs-opengl/gl-subsystem.c @@ -972,6 +972,11 @@ void device_clear(device_t device, uint32_t clear_flags, UNUSED_PARAMETER(device); } +void device_flush(device_t device) +{ + glFlush(); +} + void device_setcullmode(device_t device, enum gs_cull_mode mode) { if (device->cur_cull_mode == mode) diff --git a/libobs/graphics/device-exports.h b/libobs/graphics/device-exports.h index 76c8b4282..917a63159 100644 --- a/libobs/graphics/device-exports.h +++ b/libobs/graphics/device-exports.h @@ -94,6 +94,7 @@ EXPORT void device_load_swapchain(device_t device, swapchain_t swapchain); EXPORT void device_clear(device_t device, uint32_t clear_flags, struct vec4 *color, float depth, uint8_t stencil); EXPORT void device_present(device_t device); +EXPORT void device_flush(device_t device); EXPORT void device_setcullmode(device_t device, enum gs_cull_mode mode); EXPORT enum gs_cull_mode device_getcullmode(device_t device); EXPORT void device_enable_blending(device_t device, bool enable); diff --git a/libobs/graphics/graphics-imports.c b/libobs/graphics/graphics-imports.c index 50d82292c..165ca42eb 100644 --- a/libobs/graphics/graphics-imports.c +++ b/libobs/graphics/graphics-imports.c @@ -83,6 +83,7 @@ bool load_graphics_imports(struct gs_exports *exports, void *module, GRAPHICS_IMPORT(device_endscene); GRAPHICS_IMPORT(device_clear); GRAPHICS_IMPORT(device_present); + GRAPHICS_IMPORT(device_flush); GRAPHICS_IMPORT(device_setcullmode); GRAPHICS_IMPORT(device_getcullmode); GRAPHICS_IMPORT(device_enable_blending); diff --git a/libobs/graphics/graphics-internal.h b/libobs/graphics/graphics-internal.h index 8b19470b7..aa98e5ad8 100644 --- a/libobs/graphics/graphics-internal.h +++ b/libobs/graphics/graphics-internal.h @@ -100,6 +100,7 @@ struct gs_exports { void (*device_clear)(device_t device, uint32_t clear_flags, struct vec4 *color, float depth, uint8_t stencil); void (*device_present)(device_t device); + void (*device_flush)(device_t device); void (*device_setcullmode)(device_t device, enum gs_cull_mode mode); enum gs_cull_mode (*device_getcullmode)(device_t device); void (*device_enable_blending)(device_t device, bool enable); diff --git a/libobs/graphics/graphics.c b/libobs/graphics/graphics.c index 8018b80df..09a1039ba 100644 --- a/libobs/graphics/graphics.c +++ b/libobs/graphics/graphics.c @@ -1309,6 +1309,14 @@ void gs_present(void) graphics->exports.device_present(graphics->device); } +void gs_flush(void) +{ + graphics_t graphics = thread_graphics; + if (!graphics) return; + + graphics->exports.device_flush(graphics->device); +} + void gs_setcullmode(enum gs_cull_mode mode) { graphics_t graphics = thread_graphics; diff --git a/libobs/graphics/graphics.h b/libobs/graphics/graphics.h index e3338bc41..0710c8bea 100644 --- a/libobs/graphics/graphics.h +++ b/libobs/graphics/graphics.h @@ -594,6 +594,7 @@ EXPORT void gs_load_swapchain(swapchain_t swapchain); EXPORT void gs_clear(uint32_t clear_flags, struct vec4 *color, float depth, uint8_t stencil); EXPORT void gs_present(void); +EXPORT void gs_flush(void); EXPORT void gs_setcullmode(enum gs_cull_mode mode); EXPORT enum gs_cull_mode gs_getcullmode(void);