Skip to content

rust: Port the shader-parser name lookups (get_shader_param_type, get_sample_filter, get_address_mode) to obs-graphics #839

Closed

Description

@zackees

Unit

The three exported string-to-enum lookups at the top of libobs/graphics/shader-parser.c (shader-parser.h): get_shader_param_type, get_sample_filter, get_address_mode. Target crate: obs-graphics.

Phase and position

Phase 6, tracker #444 ("the effect/shader parser"), first slice. The rest of shader-parser.c fills struct shader_parser, which libobs-opengl and libobs-d3d11 read directly, so its layout is public contract and it gets its own scoping issue. effect-parser.c compiles through the graphics device inside ep_parse and is later still.

Dependencies and existing tests

astrcmpi/astrcmp_n (dstr, ported). No cmocka test covers these functions. Steps, per the testing policy's partial-file rule:

  1. Behavior-neutral PR: move the three functions verbatim into libobs/graphics/shader-param-names.c (added to libobs/CMakeLists.txt).
  2. Characterization PR: test/cmocka/test_shader_param_names.c.
  3. RED, then GREEN; ENABLE_RUST_LIBOBS=ON drops the new file.

Notes

Quirks to pin as characterized: any type that starts with texture is a texture (astrcmp_n(type, "texture", 7)); Anisotropy/Point/Linear match case-insensitively but the MIN_MAG_* filter names only exactly; an unknown filter is GS_FILTER_LINEAR; the address-mode fallback is whatever the C returns past Border. A NULL argument crashes in C (strcmp(NULL)); the port returns the fallback (intentional difference).

Activity

  1. added
    enhancement
    port
    on Oct 15, 2026
  2. zackees commented on Oct 15, 2026

    @zackees
    MemberAuthor

    Claiming: shader-parser name lookups

    1. Extraction PR (behavior-neutral): graphics/shader-param-names.c.
    2. Characterization PR: test_shader_param_names.
    3. RED, then GREEN in obs-graphics.

    First PR today.

  3. added
    claimed
    on Oct 15, 2026
  4. zackees commented on Oct 15, 2026

    @zackees
    MemberAuthor

    Done: #840 moved the three lookups into graphics/shader-param-names.c, #843 characterized them (C only), and #844 ported them to obs-graphics (Tier 1 1:1; Tier 3 against the original with the C dstr.c on every known name in every case plus random names and bytes; Tier 2 249/249 OFF and ON; ENABLE_RUST_LIBOBS=ON drops the C file).

    Intentional difference: a null name gives the fallback where C calls strcmp(NULL); get_address_mode(NULL) is CLAMP in both.

    Left on #444's parser item: the rest of shader-parser.c (struct shader_parser is read directly by the GL/D3D11 backends, so its layout is contract) and effect-parser.c (ep_parse compiles through the graphics device); both need their own scoping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    claimedenhancementport

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions