Skip to content

graphics: swap shader matrix-parameter queries to safe Rust (Refs #5185) - #5194

Merged
rdoupe merged 2 commits into
masterfrom
port/5185-shader-matrix-queries
Nov 19, 2026
Merged

rdoupe merged 2 commits into
masterfrom
port/5185-shader-matrix-queries

Conversation

@rdoupe

@rdoupe rdoupe commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #5185.

Swap gs_shader_get_viewproj_matrix and gs_shader_get_world_matrix from the extraction in #5184 to obs-graphics, following the texture-copy and sampler-state swaps. The safe core checks the graphics context before the shader, with the original LOG_DEBUG messages; then private C adapters dispatch the matching backend callback with the exact shader pointer and return the borrowed parameter unchanged, NULL included. TLS, field layout and backend ownership stay in C.

The original bodies stay in a reference-only group (libobs.ported-graphics-shader-matrix-queries+.h.c) and verbatim in the Tier 3 oracle (rust/obs-c-oracle/legacy/graphics-shader-matrix-queries.c). Adds the per-port source/export/oracle registration, a native registration case, the README row and a link-support fragment that gives standalone Rust-static test consumers the real adapter. The C test test_shader_matrix_queries.c, public headers and the WebSocket plugin are unchanged. No intentional behavior differences.

RED

db341b9cd mirrors the four C cases as Tier 1 tests against todo!() stubs:

soldr cargo test -p obs-graphics --test obs-tests-graphics shader_matrix_queries
test result: FAILED. 1 passed; 4 failed
  not yet implemented: gs_shader_get_viewproj_matrix
  not yet implemented: gs_shader_get_world_matrix

GREEN

  • Tier 1: the 4 mirrored cases plus a diagnostic-name check pass.
  • Tier 3: shader_matrix_queries_parity compares the original C (with the verbatim gs_valid/gs_obj_valid) against the production Rust ABI and the real adapters over every context × callback set × shader (NULL/two tokens) × result (NULL/two tokens) combination, plus bounded random sequences: return value, callback counts, shader identity, log count/level/text and the L/V/W event order.
  • Mutants, each restored before the final run:
    • world query dispatched to the viewproj callback: killed (SIGSEGV, the world-only fixture has no viewproj callback);
    • shader checked before context: killed by the mirrored no_context case and both parity tests (Null 'shader' parameter vs called while not in a graphics context).
  • soldr cargo test -p obs-graphics --test obs-tests-graphics: 1,025 passed.
  • soldr cargo test -p obs-studio-rust --test obs-tests-app native_build::: 311 passed (new canonical_graphics_shader_matrix_queries_swap_is_registered included).
  • ./lint: ok.
  • Tier 2, run on the pre-rebase base ccda709 (the rebase onto 21667f4 only merged a neighbouring registration line in rust/obs-build/tests/native.rs; after it, native_build:: passed 315/315 and the shader-matrix Graphics tests 7/7) (OBS_CTEST_JOBS=10 uv run rust/tools/linux-validate/run.py --repeat 1 --tests 'test_shader_matrix_queries|test_graphics_'): the full suite passed 1015/1015 against libobs-c-reference (OFF) and against hybrid libobs (ON), then the repeat of the 31 selected tests passed on both; test_shader_matrix_queries passed on both builds. Exported symbols, C vs Rust: IDENTICAL (1769 symbols).

Test cost: 7 new tests in the existing Graphics binary; over 25 reduced-parity runs all finished in under 0.01 s, peak memory 3.3 MB; no own threads, no new test executable.

Tier 4 does not apply (no protocol code). Native Windows/macOS were not run locally.

🤖 Generated with Claude Code

rdoupe and others added 2 commits November 18, 2026 23:16
…ust stubs (Refs #5185)

The four cases of the unchanged test_shader_matrix_queries.c become Tier 1
tests in the Graphics category binary. They fail at the todo!() stubs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gs_shader_get_viewproj_matrix and gs_shader_get_world_matrix move from the
extraction in #5184 to obs-graphics. The safe core checks the context before
the shader, with the original LOG_DEBUG messages, then private C adapters
dispatch the matching backend callback with the exact shader pointer and
return the borrowed parameter unchanged, NULL included. TLS, field layout
and backend ownership stay in C.

The original bodies stay in a reference-only group and verbatim in the
Tier 3 oracle. Tier 3 compares every context/callback/shader/result
combination and bounded random sequences through the real ABI and adapters.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ci-Attestation: {"at":1795062026,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["db341b9cdaaaeec0f1e01907929266760322467d"],"secs":58,"stamp":"6f034aba06e4bb1f196dd75751090457","tree":"f13e24f0003f5bc2bd250d062535f48da94aad92","v":1,"via":"run"}
Ci-Attestation: {"at":1795062026,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["db341b9cdaaaeec0f1e01907929266760322467d"],"secs":58,"stamp":"56bafb1fd4e706e0863a5579d0aaf9a8","tree":"f13e24f0003f5bc2bd250d062535f48da94aad92","v":1,"via":"run"}
Ci-Attestation: {"at":1795062026,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["db341b9cdaaaeec0f1e01907929266760322467d"],"secs":58,"stamp":"20a042eecd416be598848f9e72b97410","tree":"f13e24f0003f5bc2bd250d062535f48da94aad92","v":1,"via":"run"}
Ci-Attestation: {"at":1795062026,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["db341b9cdaaaeec0f1e01907929266760322467d"],"secs":58,"stamp":"faad6c1ac8e8fd04bd924b8dc90b92fc","tree":"f13e24f0003f5bc2bd250d062535f48da94aad92","v":1,"via":"run"}
Ci-Attestation: {"at":1795061967,"gate":"general/all/client-lint","host":"linux-x86_64","key":"c882d19deb2840dad068772a82328520a4a718f53752230324ad58eff320e1f2","lane":"client-lint","parents":["db341b9cdaaaeec0f1e01907929266760322467d"],"secs":104,"stamp":"ace9141532187b65ed1247b42e516de1","tree":"f13e24f0003f5bc2bd250d062535f48da94aad92","v":1,"via":"run"}
Ci-Attestation: {"at":1795062026,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["db341b9cdaaaeec0f1e01907929266760322467d"],"secs":58,"stamp":"244155a681699b5eeb44e7dd23fadf69","tree":"f13e24f0003f5bc2bd250d062535f48da94aad92","v":1,"via":"run"}
Ci-Attestation: {"at":1795061968,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"c882d19deb2840dad068772a82328520a4a718f53752230324ad58eff320e1f2","lane":"client-lint","parents":["db341b9cdaaaeec0f1e01907929266760322467d"],"secs":104,"stamp":"3c63498b6805d6dda2f29b62e04e63c1","tree":"f13e24f0003f5bc2bd250d062535f48da94aad92","v":1,"via":"run"}
Ci-Attestation: {"at":1795061968,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"c882d19deb2840dad068772a82328520a4a718f53752230324ad58eff320e1f2","lane":"client-lint","parents":["db341b9cdaaaeec0f1e01907929266760322467d"],"secs":104,"stamp":"61816a52d954bc7cac259d4ec436a991","tree":"f13e24f0003f5bc2bd250d062535f48da94aad92","v":1,"via":"run"}
Ci-Attestation: {"at":1795061968,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"c882d19deb2840dad068772a82328520a4a718f53752230324ad58eff320e1f2","lane":"client-lint","parents":["db341b9cdaaaeec0f1e01907929266760322467d"],"secs":104,"stamp":"35a91ba414d12acb1d84cebbbb2772b5","tree":"f13e24f0003f5bc2bd250d062535f48da94aad92","v":1,"via":"run"}
Ci-Attestation: {"at":1795061968,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"c882d19deb2840dad068772a82328520a4a718f53752230324ad58eff320e1f2","lane":"client-lint","parents":["db341b9cdaaaeec0f1e01907929266760322467d"],"secs":104,"stamp":"521edee1ebfe92074e643a9df0c41bc1","tree":"f13e24f0003f5bc2bd250d062535f48da94aad92","v":1,"via":"run"}
Ci-Attestation: {"at":1795061968,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"c882d19deb2840dad068772a82328520a4a718f53752230324ad58eff320e1f2","lane":"client-lint","parents":["db341b9cdaaaeec0f1e01907929266760322467d"],"secs":104,"stamp":"da01f5eb11b9b95eb899f554f033a2aa","tree":"f13e24f0003f5bc2bd250d062535f48da94aad92","v":1,"via":"run"}
Ci-Attestation: {"at":1795061968,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"c882d19deb2840dad068772a82328520a4a718f53752230324ad58eff320e1f2","lane":"client-lint","parents":["db341b9cdaaaeec0f1e01907929266760322467d"],"secs":104,"stamp":"26863ac4c8eaba1298f1d12f88f52ace","tree":"f13e24f0003f5bc2bd250d062535f48da94aad92","v":1,"via":"run"}
Ci-Attestation: {"at":1795061968,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"c882d19deb2840dad068772a82328520a4a718f53752230324ad58eff320e1f2","lane":"client-lint","parents":["db341b9cdaaaeec0f1e01907929266760322467d"],"secs":104,"stamp":"aebcdccb41e1412b6538c6f4de4c3f4f","tree":"f13e24f0003f5bc2bd250d062535f48da94aad92","v":1,"via":"run"}
Ci-Attestation: {"at":1795061968,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"c882d19deb2840dad068772a82328520a4a718f53752230324ad58eff320e1f2","lane":"client-lint","parents":["db341b9cdaaaeec0f1e01907929266760322467d"],"secs":104,"stamp":"0f16dd780848b54e992b4f5d0b055dce","tree":"f13e24f0003f5bc2bd250d062535f48da94aad92","v":1,"via":"run"}
Ci-Attestation: {"at":1795061968,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"c882d19deb2840dad068772a82328520a4a718f53752230324ad58eff320e1f2","lane":"client-lint","parents":["db341b9cdaaaeec0f1e01907929266760322467d"],"secs":104,"stamp":"03811d7693934ad10a07f47a3086ac85","tree":"f13e24f0003f5bc2bd250d062535f48da94aad92","v":1,"via":"run"}
Ci-Attestation: {"at":1795061968,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"c882d19deb2840dad068772a82328520a4a718f53752230324ad58eff320e1f2","lane":"client-lint","parents":["db341b9cdaaaeec0f1e01907929266760322467d"],"secs":104,"stamp":"880bbd1a779f1814268d36184a9eac8a","tree":"f13e24f0003f5bc2bd250d062535f48da94aad92","v":1,"via":"run"}
Ci-Attestation: {"at":1795061967,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"c882d19deb2840dad068772a82328520a4a718f53752230324ad58eff320e1f2","lane":"client-lint","parents":["db341b9cdaaaeec0f1e01907929266760322467d"],"secs":104,"stamp":"0a423b3b8bdad13f475d5e03d9cc7408","tree":"f13e24f0003f5bc2bd250d062535f48da94aad92","v":1,"via":"run"}
Ci-Attestation: {"at":1795061967,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"c882d19deb2840dad068772a82328520a4a718f53752230324ad58eff320e1f2","lane":"client-lint","parents":["db341b9cdaaaeec0f1e01907929266760322467d"],"secs":104,"stamp":"cb4b54108136583a0d9b5724bc79249d","tree":"f13e24f0003f5bc2bd250d062535f48da94aad92","v":1,"via":"run"}
Ci-Attestation: {"at":1795062249,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"7fc96a992d50ebd3bd88bc523e8be6ff9aec6a5d7ce9f0ebf4b695e1ae70e9b8","lane":"client-test-x86_64-unknown-linux-gnu","parents":["db341b9cdaaaeec0f1e01907929266760322467d"],"secs":222,"stamp":"ab9f1680c536820338303bb28c1b994a","tree":"f13e24f0003f5bc2bd250d062535f48da94aad92","v":1,"via":"run"}

Client-Checks: {"checks":{"base":"21667f4da05037469c03778e9c504c96bd6d5c49","coverage":"all-tracked-applicable-files","diff":["libobs/build/libobs.graphics+.h.c","libobs/build/libobs.ported-graphics-shader-matrix-queries+.h.c","libobs/build/ported-source-sets/graphics-shader-matrix-queries.json","libobs/cmake/rust-exports.d/obs-graphics-shader_matrix_queries.txt","libobs/graphics/graphics-shader-matrix-queries-fields.c.h","libobs/graphics/graphics-shader-matrix-queries.c.h","rust/README.md","rust/obs-build/tests/native.rs","rust/obs-build/tests/native/registration/canonical_graphics_shader_matrix_queries_swap_is_registered.rs","rust/obs-c-oracle/legacy/graphics-shader-matrix-queries.c","rust/obs-c-oracle/oracle.d/graphics-shader-matrix-queries-fields.list","rust/obs-c-oracle/oracle.d/graphics-shader-matrix-queries.list","rust/obs-c-oracle/oracle/shader_matrix_queries.c","rust/obs-graphics/src/ffi/mod.rs","rust/obs-graphics/src/ffi/shader_matrix_queries.rs","rust/obs-graphics/src/lib.rs","rust/obs-graphics/src/shader_matrix_queries.rs","rust/obs-graphics/tests/render/main.rs","rust/obs-graphics/tests/render/shader_matrix_queries.rs","rust/obs-graphics/tests/render/shader_matrix_queries_parity.rs","test/cmocka/graphics-shader-matrix-queries-link-support.c","test/cmocka/tests.d/graphics_shader_matrix_queries_link_support.cmake"],"head":"bc54b46e92d788eaf66ac2550ce7f04a3700bb4c","tools":{"orchestrator-python":"3.13.16 (main, Oct 14 2026, 01:04:01) [Clang 23.1.3 ]","schema-dependencies":"3.13.16 (main, Oct 14 2026, 01:04:01) [Clang 23.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-GITv2.15.4\n   compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 DTDValid HTML C14N Catalog XPath XPointer XInclude Iconv ICU ISO8859X Regexps Automata RelaxNG Schemas Schematron Modules Debug Zlib"},"tracked-digest":"55fcbb07da9bd329a6297e2f4758ba317defae4007a57abdea08276cffc82d6c","tree":"f13e24f0003f5bc2bd250d062535f48da94aad92"}}
@rdoupe
rdoupe requested a review from zackees as a code owner November 19, 2026 04:24
@rdoupe
rdoupe enabled auto-merge November 19, 2026 04:39
@rdoupe
rdoupe added this pull request to the merge queue Nov 19, 2026
Merged via the queue into master with commit fd60fd8 Nov 19, 2026
45 checks passed
@rdoupe
rdoupe deleted the port/5185-shader-matrix-queries branch November 19, 2026 05:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant