Skip to content

rust: port shader sampler conversion to obs-graphics - #1750

Merged
zackees merged 2 commits into
obs-rust:masterfrom
nathan-v:port/shader-sampler-convert
Oct 22, 2026
Merged

zackees merged 2 commits into
obs-rust:masterfrom
nathan-v:port/shader-sampler-convert

Conversation

@nathan-v

@nathan-v nathan-v commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1716. C-only characterization prerequisite #1718 is merged.

Replace shader_sampler_convert with a safe Rust conversion core and a narrow C ABI adapter. Preserve all six output fields, reset defaults, case-insensitive lookups, duplicate precedence, and native strtol behavior (long width, locale, overflow and errno). The original C implementation remains available to the C reference and differential oracle.

RED and GREEN

  • RED: b41d4f601 adds six characterization mirrors against a failing stub. The original pushed RED 63e33e486 failed the six expected stub tests in PR CI; Tier 2 OFF/ON and formatting passed.
  • GREEN: d053ac72c implements the conversion and ABI shim, adds real-header layout checks and exact C output/errno parity, including numeric edges, null state/address inputs, duplicate states and 512 randomized sequences. Inputs invoking undefined behavior in the C original are excluded.
  • Mutation evidence: changing the default anisotropy from 1 to 2 fails the fixed and randomized differential tests; the mutation was restored.

Validation

  • Native macOS workspace tests: 2,031 passed, one ignored, plus doctests. Workspace Clippy with warnings denied and repository Dylints passed. After the final test-only input constraint, all ten sampler tests and graphics Clippy passed again.
  • 56 focused policy checks passed, including build groups, registration, naming, platform boundaries and test binary budget.
  • Linux Docker: both libraries built and exported the same 1,766 symbols. The local build needed an additional frontend API include path for two unchanged screenshot tests; this is a command-line environment workaround, not a source change.
  • Full Linux C-reference suite completed: two unrelated scene failures (drag_into_filled_group, private_copy_keeps_group_state), four PulseAudio hardware skips. See completed Linux results below.
  • Local x86 Linux Rust compiler crashes under emulation, including with a newer QEMU; native macOS Windows cross-check also lacks windows.h. Native ARM Linux gate checks identified the limits recorded below.

No existing C tests or public headers are changed. No user-visible behavior or protocol change; Tier 4 and a feature-ledger entry do not apply. Final-head PR CI is fully green; marked ready for review after completion.

Completed Linux local results

Rust-enabled OFF/ON harness comparison: ON completed with zero failures across 360 registered tests, four PulseAudio hardware skips. OFF completed with the two scene-group failures above; both corresponding tests pass in ON. Linux lint's repository Python/policy checks and rustfmt completed; workspace Rust compilation on native ARM stops in unchanged dstr-libc.c.h because ARM's unsigned wchar_t triggers -Werror=sign-conversion. The Rust-test lane reaches the same existing oracle failure. The cross lane was attempted and stops because this local image lacks llvm-lib. An emulated x86 compiler was also attempted and crashes before compiling source. Native macOS workspace Clippy, Dylints and tests passed as recorded above. These are local coverage limits, not a local-gate attestation; full PR CI remains mandatory.

Final hosted CI

Run 39820421514 completed successfully for exact GREEN head d053ac72c3708f278e76b36660aec6dbc2e859df: formatting, Fast Gate, Linux Tier 2 build and OFF/ON tests, macOS/Windows Rust tests, macOS/Windows Tier 2, Windows/macOS cross-lint, and CI Gate all passed. Marked ready only after all selected checks completed successfully.

@nathan-v

Copy link
Copy Markdown
Contributor Author

Characterization #1718 passed all CI after the requested rebase (eebb004, run 39737568724), was marked ready only after CI Gate passed, and has now merged.

Remote RED 63e33e4 completed CI run 39738851100: the six intended sampler mirrors fail at todo!, while Linux Tier 2 build and both C-reference/hybrid test jobs pass. That is expected RED evidence.

The Rust branch has been rebased onto master d71d985. Local commits are now RED b41d4f6 and GREEN d80b8a262. GREEN is NOT pushed. It adds the read-only safe core, native strtol boundary, ABI shim/export and production swap, real-C oracle/layout/errno parity, randomized cases and defined null-state/address-value coverage. Existing C tests/public headers are unchanged. No intended behavior differences.

Exact local GREEN validation:

  • Full native workspace tests and doctests passed, including all 224 graphics tests.
  • rustfmt, workspace Clippy with warnings denied, and Dylint passed.
  • 56 focused policy tests passed.
  • A wrong-default mutation fails fixed and randomized differential tests; it was restored before committing.

Linux validation is incomplete, not green: initial local lint found/fixed oracle module ordering; container scratch/path failures were corrected. x86 compiler probes crash under both installed and newer user-mode emulation. Native Linux OFF/ON build was started, but the shared 3.8 GB Podman VM became unresponsive to Docker API and SSH during compilation. Attempts to stop only my containers have not reliably completed. The native macOS cross attempt also cannot find the Windows SDK headers. No local attestation is claimed.

Per the maintainer’s requirement, GREEN remains local while Linux/cross checks are unresolved, and this Rust PR remains draft. Restarting the shared Podman VM would interrupt existing whera application containers, so restart authorization has been requested rather than doing that implicitly. No shared VM restart, unrelated source fix or GREEN push has occurred.

@nathan-v

nathan-v commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor Author

The complete local Linux build succeeded; C-reference and hybrid exports match (1,766 symbols). The OFF/ON tests are running. A local-only -I/ro/frontend/api C++ search-path flag was needed for two unchanged WebSocket screenshot tests; no repository source/test was modified for that environment workaround. C compiler caching is disabled locally after the earlier cache failures.

Local GREEN is now d053ac7 (the amendment only documents/excludes undefined signed-char lookup inputs from randomized C-oracle tests). All ten focused sampler tests and graphics Clippy pass. Numeric/ignored-value parity still includes arbitrary non-NUL bytes. GREEN remains unpushed until the local checks complete; this PR remains draft.

@nathan-v
nathan-v force-pushed the port/shader-sampler-convert branch from 63e33e4 to d053ac7 Compare October 22, 2026 17:11
@nathan-v
nathan-v marked this pull request as ready for review October 22, 2026 17:34
@nathan-v
nathan-v requested a review from zackees as a code owner October 22, 2026 17:34
@zackees
zackees added this pull request to the merge queue Oct 22, 2026
Merged via the queue into obs-rust:master with commit 72612aa Oct 22, 2026
32 checks passed
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.

rust: Port graphics/shader-sampler-convert.c to obs-graphics

2 participants