From 2a9b2ed780c88df197d866019cfd2792a6567a8a Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Thu, 19 Nov 2026 05:58:10 -0800 Subject: [PATCH 1/3] test: characterize active vertex/pixel shader queries (Refs #5244) --- test/cmocka/build/test-graph.json | 22 +++ .../test_graphics_active_shader_queries.c | 168 ++++++++++++++++++ .../test_graphics_active_shader_queries.cmake | 1 + 3 files changed, 191 insertions(+) create mode 100644 test/cmocka/test_graphics_active_shader_queries.c create mode 100644 test/cmocka/tests.d/test_graphics_active_shader_queries.cmake diff --git a/test/cmocka/build/test-graph.json b/test/cmocka/build/test-graph.json index 31119292ed..9332cada0c 100644 --- a/test/cmocka/build/test-graph.json +++ b/test/cmocka/build/test-graph.json @@ -4933,6 +4933,22 @@ ], "requires": "OS_LINUX" }, + "test_graphics_active_shader_queries": { + "sources": [ + "test/cmocka/test_graphics_active_shader_queries.c" + ], + "libraries": [ + "OBS::libobs", + "OBS::native-test-cmocka", + { + "name": "OBS::w32-pthreads", + "requires": "OS_WINDOWS" + } + ], + "header_libraries": [ + "SIMDe::SIMDe" + ] + }, "test_graphics_alias_ordinary": { "sources": [ "test/cmocka/test_graphics_alias_ordinary.c" @@ -23767,6 +23783,12 @@ "test_glyph_atlas": { "target": "test_glyph_atlas" }, + "test_graphics_active_shader_queries": { + "target": "test_graphics_active_shader_queries", + "command": [ + "${target}" + ] + }, "test_graphics_alias_ordinary": { "target": "test_graphics_alias_ordinary", "command": [ diff --git a/test/cmocka/test_graphics_active_shader_queries.c b/test/cmocka/test_graphics_active_shader_queries.c new file mode 100644 index 0000000000..57aa7e3851 --- /dev/null +++ b/test/cmocka/test_graphics_active_shader_queries.c @@ -0,0 +1,168 @@ +/* Characterize borrowed active shader queries without a GPU. */ +#include +#include +#include +#include +#include +#include +#include "graphics/graphics-internal.h" +#include "util/base.h" + +static struct graphics_subsystem graphics; +static int device_tokens[2]; +static int shader_tokens[2]; +static gs_device_t *expected_device; +static gs_shader_t *vertex_result, *pixel_result; +static unsigned vertex_calls, pixel_calls, log_count; +static char message[160]; +static log_handler_t previous_handler; +static void *previous_param; + +#ifdef __GNUC__ +__attribute__((format(printf, 2, 0))) +#endif +static void capture(int level, const char *format, va_list args, void *param) +{ + (void)param; + assert_int_equal(level, LOG_DEBUG); + log_count++; + vsnprintf(message, sizeof(message), format, args); +} + +static void context(gs_device_t *device) +{ + assert_ptr_equal(device, expected_device); +} + +static gs_shader_t *vertex(const gs_device_t *device) +{ + assert_ptr_equal(gs_get_context(), &graphics); + assert_ptr_equal(device, expected_device); + vertex_calls++; + return vertex_result; +} + +static gs_shader_t *pixel(const gs_device_t *device) +{ + assert_ptr_equal(gs_get_context(), &graphics); + assert_ptr_equal(device, expected_device); + pixel_calls++; + return pixel_result; +} + +static int setup(void **state) +{ + (void)state; + assert_null(gs_get_context()); + memset(&graphics, 0, sizeof(graphics)); + vertex_calls = pixel_calls = log_count = 0; + vertex_result = pixel_result = NULL; + shader_tokens[0] = 17; + shader_tokens[1] = 29; + message[0] = '\0'; + expected_device = (gs_device_t *)&device_tokens[0]; + graphics.device = expected_device; + graphics.exports.device_enter_context = context; + graphics.exports.device_leave_context = context; + graphics.exports.device_get_vertex_shader = vertex; + graphics.exports.device_get_pixel_shader = pixel; + assert_int_equal(pthread_mutex_init(&graphics.mutex, NULL), 0); + base_get_log_handler(&previous_handler, &previous_param); + base_set_log_handler(capture, NULL); + return 0; +} + +static int teardown(void **state) +{ + (void)state; + if (gs_get_context()) + gs_leave_context(); + base_set_log_handler(previous_handler, previous_param); + assert_int_equal(pthread_mutex_destroy(&graphics.mutex), 0); + return 0; +} + +static void no_context(void **state) +{ + (void)state; + /* A NULL graphics handle never establishes a thread context. */ + gs_enter_context(NULL); + assert_string_equal(message, "gs_enter_context: Null 'graphics' parameter"); + assert_int_equal(log_count, 1); + assert_null(gs_get_context()); + for (unsigned i = 0; i < 2; i++) { + assert_null(gs_get_vertex_shader()); + assert_string_equal(message, "gs_get_vertex_shader: called while not in a graphics context"); + assert_int_equal(log_count, 2 * i + 2); + assert_null(gs_get_pixel_shader()); + assert_string_equal(message, "gs_get_pixel_shader: called while not in a graphics context"); + assert_int_equal(log_count, 2 * i + 3); + assert_int_equal(vertex_calls, 0); + assert_int_equal(pixel_calls, 0); + /* Rejection precedes reading either mandatory backend callback. */ + graphics.exports.device_get_vertex_shader = NULL; + graphics.exports.device_get_pixel_shader = NULL; + } +} + +static void callback_results_and_device_routing(void **state) +{ + (void)state; + /* Opaque tokens are borrowed identities, never real host shaders/devices. */ + for (unsigned device = 0; device < 2; device++) { + expected_device = (gs_device_t *)&device_tokens[device]; + graphics.device = expected_device; + gs_enter_context(&graphics); + for (unsigned results = 0; results < 4; results++) { + vertex_result = (results & 1) ? (gs_shader_t *)&shader_tokens[device] : NULL; + pixel_result = (results & 2) ? (gs_shader_t *)&shader_tokens[1 - device] : NULL; + unsigned calls = device * 4 + results; + assert_ptr_equal(gs_get_vertex_shader(), vertex_result); + assert_int_equal(vertex_calls, calls + 1); + assert_int_equal(pixel_calls, calls); + assert_ptr_equal(gs_get_pixel_shader(), pixel_result); + assert_int_equal(vertex_calls, calls + 1); + assert_int_equal(pixel_calls, calls + 1); + assert_int_equal(graphics.ref, 1); + assert_int_equal(shader_tokens[0], 17); + assert_int_equal(shader_tokens[1], 29); + assert_int_equal(log_count, 0); + } + gs_leave_context(); + assert_null(gs_get_context()); + } +} + +static void leaving_context_rejects_then_reentry_dispatches(void **state) +{ + (void)state; + vertex_result = (gs_shader_t *)&shader_tokens[0]; + pixel_result = (gs_shader_t *)&shader_tokens[1]; + gs_enter_context(&graphics); + assert_ptr_equal(gs_get_pixel_shader(), pixel_result); + assert_ptr_equal(gs_get_vertex_shader(), vertex_result); + gs_leave_context(); + assert_null(gs_get_vertex_shader()); + assert_string_equal(message, "gs_get_vertex_shader: called while not in a graphics context"); + assert_null(gs_get_pixel_shader()); + assert_string_equal(message, "gs_get_pixel_shader: called while not in a graphics context"); + assert_int_equal(log_count, 2); + assert_int_equal(vertex_calls, 1); + assert_int_equal(pixel_calls, 1); + gs_enter_context(&graphics); + assert_ptr_equal(gs_get_vertex_shader(), vertex_result); + assert_ptr_equal(gs_get_pixel_shader(), pixel_result); + assert_int_equal(vertex_calls, 2); + assert_int_equal(pixel_calls, 2); + assert_int_equal(log_count, 2); +} + +int main(void) +{ + const struct CMUnitTest tests[] = { + cmocka_unit_test_setup_teardown(no_context, setup, teardown), + cmocka_unit_test_setup_teardown(callback_results_and_device_routing, setup, teardown), + cmocka_unit_test_setup_teardown(leaving_context_rejects_then_reentry_dispatches, setup, teardown), + }; + return cmocka_run_group_tests(tests, NULL, NULL); +} diff --git a/test/cmocka/tests.d/test_graphics_active_shader_queries.cmake b/test/cmocka/tests.d/test_graphics_active_shader_queries.cmake new file mode 100644 index 0000000000..097d1362a9 --- /dev/null +++ b/test/cmocka/tests.d/test_graphics_active_shader_queries.cmake @@ -0,0 +1 @@ +# Both target and test are declared in ../build/test-graph.json. From 9a09edc46a5eb67f58858db4c3177108e52d84db Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Thu, 19 Nov 2026 05:59:33 -0800 Subject: [PATCH 2/3] test: require active shader query extraction seam (Refs #5244) --- test/cmocka/test_graphics_active_shader_queries.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/cmocka/test_graphics_active_shader_queries.c b/test/cmocka/test_graphics_active_shader_queries.c index 57aa7e3851..fbdb556744 100644 --- a/test/cmocka/test_graphics_active_shader_queries.c +++ b/test/cmocka/test_graphics_active_shader_queries.c @@ -8,6 +8,11 @@ #include "graphics/graphics-internal.h" #include "util/base.h" +/* This characterization lands with the extraction, before the Rust swap. */ +#if !__has_include("graphics/graphics-active-shader-queries.c.h") +#error "graphics active shader query extraction seam is missing" +#endif + static struct graphics_subsystem graphics; static int device_tokens[2]; static int shader_tokens[2]; From 8ce41f93021eb11e9a5b757a3d6c521d7f520b81 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Thu, 19 Nov 2026 06:04:35 -0800 Subject: [PATCH 3/3] graphics: extract active shader query bodies verbatim (Refs #5244) Ci-Attestation: {"at":1795098498,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["9a09edc46a5eb67f58858db4c3177108e52d84db"],"secs":129,"stamp":"731692d743b9f5d7eede48a1054e41c9","tree":"7e9f0542e0b50f6242f4871cd98d497bcddb1f39","v":1,"via":"run"} Ci-Attestation: {"at":1795098498,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["9a09edc46a5eb67f58858db4c3177108e52d84db"],"secs":129,"stamp":"b541088b22deafe9d95f4fb9a8077900","tree":"7e9f0542e0b50f6242f4871cd98d497bcddb1f39","v":1,"via":"run"} Ci-Attestation: {"at":1795098498,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["9a09edc46a5eb67f58858db4c3177108e52d84db"],"secs":129,"stamp":"ec2a8704733475dc3e587dc93b108b03","tree":"7e9f0542e0b50f6242f4871cd98d497bcddb1f39","v":1,"via":"run"} Ci-Attestation: {"at":1795098498,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["9a09edc46a5eb67f58858db4c3177108e52d84db"],"secs":129,"stamp":"3bde230c37ae4def36d2ea9b63419ae7","tree":"7e9f0542e0b50f6242f4871cd98d497bcddb1f39","v":1,"via":"run"} Ci-Attestation: {"at":1795098367,"gate":"general/all/client-lint","host":"linux-x86_64","key":"e65df71a270d327e47b9d1341b6cc4a40eec69ec2e13ea50fcfb69b7859bc5ef","lane":"client-lint","parents":["9a09edc46a5eb67f58858db4c3177108e52d84db"],"secs":254,"stamp":"66b3fa6186331464e2764dba779d1736","tree":"7e9f0542e0b50f6242f4871cd98d497bcddb1f39","v":1,"via":"run"} Ci-Attestation: {"at":1795098498,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["9a09edc46a5eb67f58858db4c3177108e52d84db"],"secs":129,"stamp":"779d0e242f099b1984fc341328d54718","tree":"7e9f0542e0b50f6242f4871cd98d497bcddb1f39","v":1,"via":"run"} Ci-Attestation: {"at":1795098368,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"e65df71a270d327e47b9d1341b6cc4a40eec69ec2e13ea50fcfb69b7859bc5ef","lane":"client-lint","parents":["9a09edc46a5eb67f58858db4c3177108e52d84db"],"secs":254,"stamp":"5b8fd4c6ac8acec1ada5f3bd1d8ab21f","tree":"7e9f0542e0b50f6242f4871cd98d497bcddb1f39","v":1,"via":"run"} Ci-Attestation: {"at":1795098368,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"e65df71a270d327e47b9d1341b6cc4a40eec69ec2e13ea50fcfb69b7859bc5ef","lane":"client-lint","parents":["9a09edc46a5eb67f58858db4c3177108e52d84db"],"secs":254,"stamp":"271410cbf9bdd75d68c01a4f14203821","tree":"7e9f0542e0b50f6242f4871cd98d497bcddb1f39","v":1,"via":"run"} Ci-Attestation: {"at":1795098368,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"e65df71a270d327e47b9d1341b6cc4a40eec69ec2e13ea50fcfb69b7859bc5ef","lane":"client-lint","parents":["9a09edc46a5eb67f58858db4c3177108e52d84db"],"secs":254,"stamp":"f355273334e33ee61ba00b4b7151c565","tree":"7e9f0542e0b50f6242f4871cd98d497bcddb1f39","v":1,"via":"run"} Ci-Attestation: {"at":1795098368,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"e65df71a270d327e47b9d1341b6cc4a40eec69ec2e13ea50fcfb69b7859bc5ef","lane":"client-lint","parents":["9a09edc46a5eb67f58858db4c3177108e52d84db"],"secs":254,"stamp":"8aad35768ebf76df483f4d654568e5a5","tree":"7e9f0542e0b50f6242f4871cd98d497bcddb1f39","v":1,"via":"run"} Ci-Attestation: {"at":1795098368,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"e65df71a270d327e47b9d1341b6cc4a40eec69ec2e13ea50fcfb69b7859bc5ef","lane":"client-lint","parents":["9a09edc46a5eb67f58858db4c3177108e52d84db"],"secs":254,"stamp":"e8845e282f6597ba211c95dc704283f7","tree":"7e9f0542e0b50f6242f4871cd98d497bcddb1f39","v":1,"via":"run"} Ci-Attestation: {"at":1795098368,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"e65df71a270d327e47b9d1341b6cc4a40eec69ec2e13ea50fcfb69b7859bc5ef","lane":"client-lint","parents":["9a09edc46a5eb67f58858db4c3177108e52d84db"],"secs":254,"stamp":"1334bb8d3a4d1998093a54bc96aca7c4","tree":"7e9f0542e0b50f6242f4871cd98d497bcddb1f39","v":1,"via":"run"} Ci-Attestation: {"at":1795098368,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"e65df71a270d327e47b9d1341b6cc4a40eec69ec2e13ea50fcfb69b7859bc5ef","lane":"client-lint","parents":["9a09edc46a5eb67f58858db4c3177108e52d84db"],"secs":254,"stamp":"bb912d4252741d5c7e7365f00e8e46c5","tree":"7e9f0542e0b50f6242f4871cd98d497bcddb1f39","v":1,"via":"run"} Ci-Attestation: {"at":1795098368,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"e65df71a270d327e47b9d1341b6cc4a40eec69ec2e13ea50fcfb69b7859bc5ef","lane":"client-lint","parents":["9a09edc46a5eb67f58858db4c3177108e52d84db"],"secs":254,"stamp":"b0566f836bb208203aa879fad1cea32a","tree":"7e9f0542e0b50f6242f4871cd98d497bcddb1f39","v":1,"via":"run"} Ci-Attestation: {"at":1795098368,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"e65df71a270d327e47b9d1341b6cc4a40eec69ec2e13ea50fcfb69b7859bc5ef","lane":"client-lint","parents":["9a09edc46a5eb67f58858db4c3177108e52d84db"],"secs":254,"stamp":"a560136cc0fb6fb3702f00da9f49356a","tree":"7e9f0542e0b50f6242f4871cd98d497bcddb1f39","v":1,"via":"run"} Ci-Attestation: {"at":1795098368,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"e65df71a270d327e47b9d1341b6cc4a40eec69ec2e13ea50fcfb69b7859bc5ef","lane":"client-lint","parents":["9a09edc46a5eb67f58858db4c3177108e52d84db"],"secs":254,"stamp":"081a8f74fad8370bcd33412919383b1f","tree":"7e9f0542e0b50f6242f4871cd98d497bcddb1f39","v":1,"via":"run"} Ci-Attestation: {"at":1795098367,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"e65df71a270d327e47b9d1341b6cc4a40eec69ec2e13ea50fcfb69b7859bc5ef","lane":"client-lint","parents":["9a09edc46a5eb67f58858db4c3177108e52d84db"],"secs":254,"stamp":"68d06beb704ac3a596c714e9e531374f","tree":"7e9f0542e0b50f6242f4871cd98d497bcddb1f39","v":1,"via":"run"} Ci-Attestation: {"at":1795098367,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"e65df71a270d327e47b9d1341b6cc4a40eec69ec2e13ea50fcfb69b7859bc5ef","lane":"client-lint","parents":["9a09edc46a5eb67f58858db4c3177108e52d84db"],"secs":254,"stamp":"0572c630979b8772faa745fbae967621","tree":"7e9f0542e0b50f6242f4871cd98d497bcddb1f39","v":1,"via":"run"} Ci-Attestation: {"at":1795099063,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"c185034e730c974d892597f73d4b049b90e673525e26431917830436dac4cb40","lane":"client-test-x86_64-unknown-linux-gnu","parents":["9a09edc46a5eb67f58858db4c3177108e52d84db"],"secs":563,"stamp":"30c5c82cf2e92b4875d08e7ce41dfc95","tree":"7e9f0542e0b50f6242f4871cd98d497bcddb1f39","v":1,"via":"run"} Client-Checks: {"checks":{"base":"046aa3962ebec052eb15d857ebb79f26602f47bf","coverage":"all-tracked-applicable-files","diff":["libobs/build/libobs.core+.h.c","libobs/build/libobs.core-hotkey-pair-register+.h.c","libobs/build/libobs.core-source+.h.c","libobs/build/libobs.graphics+.h.c","libobs/build/libobs.ported-hotkey-pair-register+.h.c","libobs/build/libobs.ported-object-id+.h.c","libobs/build/libobs.ported-source-get-weak+.h.c","libobs/build/modules.d/core.json","libobs/build/ported-source-sets/hotkey-pair-register.json","libobs/build/ported-source-sets/object-id.json","libobs/build/ported-source-sets/source-get-weak.json","libobs/build/source-sets.d/LIBOBS_SOURCES.json","libobs/cmake/rust-exports.d/obs-core-object_id.txt","libobs/cmake/rust-exports.d/obs-hotkey-pair_register.txt","libobs/cmake/rust-exports.d/obs-source-source_get_weak.txt","libobs/graphics/graphics-active-shader-queries.c.h","libobs/graphics/graphics.c.h","libobs/obs-hotkey-pair-register-fields.c.h","libobs/obs-object-id-fields.c.h","libobs/obs-source-get-weak-fields.c.h","rust/README.md","rust/obs-build/tests/native.rs","rust/obs-build/tests/native/registration/canonical_object_id_swap_is_registered.rs","rust/obs-build/tests/native/registration/canonical_source_get_weak_swap_is_registered.rs","rust/obs-c-oracle/oracle.d/hotkey_pair_register.list","rust/obs-c-oracle/oracle.d/source-get-weak.list","rust/obs-c-oracle/oracle/hotkey_pair_register.c","rust/obs-c-oracle/oracle/object_id.c","rust/obs-c-oracle/oracle/source_get_weak.c","rust/obs-core/src/ffi/mod.rs","rust/obs-core/src/ffi/object_id.rs","rust/obs-core/src/lib.rs","rust/obs-core/src/object_id.rs","rust/obs-core/tests/obs_core/main.rs","rust/obs-core/tests/obs_core/object_id.rs","rust/obs-core/tests/obs_core/object_id_parity.rs","rust/obs-hotkey/src/ffi/mod.rs","rust/obs-hotkey/src/ffi/pair_register.rs","rust/obs-hotkey/src/lib.rs","rust/obs-hotkey/src/pair_register.rs","rust/obs-hotkey/tests/hotkey/main.rs","rust/obs-hotkey/tests/hotkey/pair_register.rs","rust/obs-hotkey/tests/hotkey/pair_register_parity.rs","rust/obs-hotkey/tests/proptest-regressions/pair_register_parity.txt","rust/obs-source/src/ffi/mod.rs","rust/obs-source/src/ffi/source_get_weak.rs","rust/obs-source/src/get_weak.rs","rust/obs-source/src/lib.rs","rust/obs-source/tests/source/get_weak.rs","rust/obs-source/tests/source/get_weak_parity.rs","rust/obs-source/tests/source/main.rs","test/cmocka/build/test-graph.json","test/cmocka/test_graphics_active_shader_queries.c","test/cmocka/tests.d/test_graphics_active_shader_queries.cmake","test/cmocka/video-info-query-link-support.c"],"head":"20afde4330310e9412aa67d054bb37e1ad217a12","tools":{"orchestrator-python":"3.13.15 (main, Aug 14 2026, 15:34:59) [Clang 22.1.3 ]","schema-dependencies":"3.13.15 (main, Aug 14 2026, 15:34:59) [Clang 22.1.3 ]\n{'jsonschema': '4.26.0', 'json_source_map': '1.0.5'}","uv":"uv 0.13.5 (x86_64-unknown-linux-gnu)","xmllint":"xmllint: using libxml version 21504\n compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 DTDValid HTML C14N Catalog XPath XPointer XInclude Iconv ISO8859X Regexps Automata RelaxNG Schemas Modules Debug"},"tracked-digest":"8c7f5d191151cf56f2611bcd91181bcfd5df2c53cec7030ce7def7b7703503a7","tree":"7e9f0542e0b50f6242f4871cd98d497bcddb1f39"}} --- libobs/build/libobs.graphics+.h.c | 1 + .../graphics-active-shader-queries.c.h | 25 +++++++++++++++++++ libobs/graphics/graphics.c.h | 20 --------------- 3 files changed, 26 insertions(+), 20 deletions(-) create mode 100644 libobs/graphics/graphics-active-shader-queries.c.h diff --git a/libobs/build/libobs.graphics+.h.c b/libobs/build/libobs.graphics+.h.c index 8c40f13883..375694ad98 100644 --- a/libobs/build/libobs.graphics+.h.c +++ b/libobs/build/libobs.graphics+.h.c @@ -5,6 +5,7 @@ #include "libobs/graphics/blend-entrypoints-fields.c.h" #include "libobs/graphics/effect-parser-lifecycle-adapter.c.h" #include "libobs/graphics/effect-parser.c.h" +#include "libobs/graphics/graphics-active-shader-queries.c.h" #include "libobs/graphics/graphics-device-load-fields.c.h" #include "libobs/graphics/graphics-device-queries-fields.c.h" #include "libobs/graphics/graphics-imports.c.h" diff --git a/libobs/graphics/graphics-active-shader-queries.c.h b/libobs/graphics/graphics-active-shader-queries.c.h new file mode 100644 index 0000000000..4f38c7f1bd --- /dev/null +++ b/libobs/graphics/graphics-active-shader-queries.c.h @@ -0,0 +1,25 @@ +#include "libobs/build/libobs-graphics.pch.h" + +/* Private dependencies defined in graphics.c.h, later in the unity group. */ +static THREAD_LOCAL graphics_t *thread_graphics; +static inline bool gs_valid(const char *f); + +gs_shader_t *gs_get_vertex_shader(void) +{ + graphics_t *graphics = thread_graphics; + + if (!gs_valid("gs_get_vertex_shader")) + return NULL; + + return graphics->exports.device_get_vertex_shader(graphics->device); +} + +gs_shader_t *gs_get_pixel_shader(void) +{ + graphics_t *graphics = thread_graphics; + + if (!gs_valid("gs_get_pixel_shader")) + return NULL; + + return graphics->exports.device_get_pixel_shader(graphics->device); +} diff --git a/libobs/graphics/graphics.c.h b/libobs/graphics/graphics.c.h index 44f5408fdf..0df8907dd4 100644 --- a/libobs/graphics/graphics.c.h +++ b/libobs/graphics/graphics.c.h @@ -1026,26 +1026,6 @@ void gs_load_pixelshader(gs_shader_t *pixelshader) graphics->exports.device_load_pixelshader(graphics->device, pixelshader); } -gs_shader_t *gs_get_vertex_shader(void) -{ - graphics_t *graphics = thread_graphics; - - if (!gs_valid("gs_get_vertex_shader")) - return NULL; - - return graphics->exports.device_get_vertex_shader(graphics->device); -} - -gs_shader_t *gs_get_pixel_shader(void) -{ - graphics_t *graphics = thread_graphics; - - if (!gs_valid("gs_get_pixel_shader")) - return NULL; - - return graphics->exports.device_get_pixel_shader(graphics->device); -} - enum gs_color_space gs_get_color_space(void) { graphics_t *graphics = thread_graphics;