Skip to content

rust: Port the effect parser's passes and techniques #3598

Closed

Description

@rdoupe

Unit

libobs/graphics/effect-parser.c.h: the effect parser's passes and techniques, moved to a new hidden file and then ported to rust/obs-graphics:

  • ep_parse_pass_command_call() and ep_parse_pass_command(): one vertex_shader|vertex_program|pixel_shader|pixel_program = [compile] <call>; command, its tokens copied into the pass's vertex_program or fragment_program with a zeroed end token;
  • ep_parse_pass(): pass [name] { <commands> };
  • ep_parse_technique(): technique name { <passes> }, pushed into ep->techniques.

ep_parse() calls ep_parse_technique() after the technique keyword. It becomes a hidden (not EXPORT) function declared in a new internal graphics/effect-parser-passes.h, in a new libobs/graphics/effect-parser-passes.c.h; the pass and command helpers stay static inside it.

Phase and position

Phase 6 style (#444): a behaviour-neutral extraction, then the port. Crate obs-graphics, after the effect parser's struct and sampler-state blocks (#3550). Tracking: #4.

Dependencies and existing tests

  • No open PR touches graphics/effect-parser.*; the blocks move and port (libobs: Move the effect parser blocks to own file #3561, obs-graphics: Port the effect parser blocks #3595) have merged.
  • No C test pins what ep_parse() builds from technique blocks: the effect tests load whole effects through a device. ep_parse() is hidden in libobs, so a new test_effect_parser_passes (cmocka) compiles the original effect parser C into itself, as test_effect_parser_blocks does, and calls ep_init(), ep_parse() and ep_free() on fixed effect texts behind a first line of {}, whose error keeps ep_parse() from calling ep_compile() (which needs a device). It pins ep->techniques (names, pass names, the token strings of vertex_program and fragment_program, end token included), the error and warning list, and the allocation count after ep_free(): named and unnamed passes, both spellings, the compile warning, a missing ; before }, an unknown command, a non-pass entry, a technique without {, and text cut short at each step. No display, no graphics context.
  • PR 1: the characterization and the move, C only. PR 2: the Rust port of the moved file.

Notes

  • The functions fill the parser's struct ep_technique and struct ep_pass (bmalloc'd names and token darrays freed by ep_free()) and walk ep->cfp's tokens in place, so the port works on the C parser's token cursor and keeps every cf_adderror() where it is.
  • One expected intentional difference in the port: ep_parse_technique() returns without freeing the technique's name when the text ends right after the name, or when a technique without { has no ; after it (a leak per malformed technique, seen only in the allocation count). The characterization pins the count it sees; the port frees it, and its parity test lists the difference.
  • Threads: effects are parsed on the graphics thread; nothing here keeps state.

Activity

  1. added
    enhancement
    port
    on Nov 4, 2026
  2. rdoupe commented on Nov 4, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: #3598.

    1. Characterization: a new test_effect_parser_passes (cmocka) that compiles the original effect parser C into itself, as test_effect_parser_blocks does, and pins ep->techniques (names, pass names, the vertex_program and fragment_program tokens, end token included), every error and warning with its row and column, and the allocations still held after ep_free(), on fixed texts behind a first line of {} so ep_compile() never runs.
    2. Move: ep_parse_pass_command_call(), ep_parse_pass_command(), ep_parse_pass() and ep_parse_technique() as written into libobs/graphics/effect-parser-passes.c.h, with ep_parse_technique() declared in an internal graphics/effect-parser-passes.h and its own live unity group, as libobs: Move the effect parser blocks to own file #3561 did for the blocks. Export sets identical on the C, hybrid and C reference builds.
    3. If LeakSanitizer reports the technique name left behind on the early returns (as it did for the sampler items in libobs: Move the effect parser blocks to own file #3561), a RED test expecting leaked 0 and a C fix in the same PR, so the port has no intentional difference.
    4. PR 2: the Rust port of the moved file into obs-graphics, with its Tier 1 and Tier 3 tests.

    First PR (steps 1-3) as a draft today.

  3. added
    ready
    on Nov 4, 2026
  4. rdoupe commented on Nov 4, 2026

    @rdoupe
    CollaboratorAuthor

    Closed by the Rust port PR (#3609, merged through the merge queue as f8bc87e). It follows the characterization test and the move into libobs/graphics/effect-parser-passes.c.h (#3599), which also fixed the technique-name leak on the two early returns in the C. The effect parser's passes and techniques (ep_parse_technique, ep_parse_pass, ep_parse_pass_command and the call's loop) now run in rust/obs-graphics, with Tier 1, Tier 2 layouts and Tier 3 parity tests, and no intentional differences from the C.

    Left of this unit: nothing. The rest of the effect parser's ep_parse() pieces continue in the follow-up issues for the parameter value assignments (#3610) and the annotations and parameter declaration (#3611).

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

Metadata

Metadata

Assignees

Labels

enhancementportready

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions