Repository navigation
Closed
Labels
enhancementNew feature or requestportPort a C unit to Rust (four-tier policy)readyMeets the definition of Ready; claimable
Description
Unit
libobs/graphics/effect-parser.c.h: the effect parser's shader writer, moved to a new hidden file and then ported to rust/obs-graphics:
ep_makeshaderstring(): a pass's vertex or pixel shader call (Name(args)), written out as the HLSL-style text handed to the graphics device, with the uniform params it uses collected intoused_params;ep_write_param(),ep_write_sampler(),ep_write_var(),ep_write_struct()andep_write_func(): one declaration each, skipped when already written;ep_write_func_param_deps(),_sampler_deps(),_struct_deps()and_func_deps(): a function's dependencies, written before it (ep_write_func()andep_write_func_func_deps()call each other);ep_write_main_params()andep_write_main(): themainthat calls the named function, with the mapped params as its own;ep_reset_written(): everywrittenflag cleared after each shader;ep_getfunc(),ep_getparam()andep_getannotation()(no caller), the lookups by name only the writer uses, and thedstr_array_ttypedef.
The compile step (ep_compile_pass_shader()), which stays in effect-parser.c.h, calls ep_makeshaderstring() and uses dstr_array_t, so those two go into a new internal graphics/effect-parser-writer.h (a private adapter, not a new public API) and ep_makeshaderstring() loses its static. The writer calls ep_getstruct(), ep_getsampler(), ep_getfunc_strref() and ep_getparam_strref() through graphics/effect-parser-funcs.h, and ep_struct_mapped() (effect-parser.h).
Phase and position
Phase 6 style (#444): a behaviour-neutral extraction, then the port. Crate obs-graphics, after the effect parser's parameters (#3621). Tracking: #4.
Dependencies and existing tests
- The blocks, passes, lifecycle and parameters of the effect parser are ported (rust: Port the effect parser's struct and sampler-state blocks #3550, rust: Port the effect parser's passes and techniques #3598, rust: Port graphics/effect-parser lifecycle to obs-graphics #1644, obs-graphics: Port the effect parser params #3621); the function parser's move landed (libobs: Move the effect parser functions to file #3627).
test_effect_parser_shader_call(libobs: Free and reset after unknown shader calls #3626) covers one case, a call to an unknown function. No C test pins the text the writer builds. A newtest_effect_parser_writer(cmocka) compiles the original effect parser C into itself, astest_effect_parser_funcsdoes, parses fixed effect texts withep_parse()behind a first line of{}(soep_compile(), which needs a device, never runs), then callsep_makeshaderstring()on each pass's vertex and pixel calls and pins the shader text,used_paramsand everywrittenflag afterwards:const,uniformand array params, sampler blocks, structs with mapped and unmapped members, nested function dependencies, a mappedmain, amainwith two mapped params, and aNULL, empty and unknown call.- PR 1: the characterization and the move, C only. PR 2: the Rust port of the moved file.
Notes
ep_getfunc()andep_getparam()have generic names: the move checks the graphics groups and the ported effect groups for clashes beforeep_makeshaderstring()losesstatic(only it does; the rest staystatic).- Expected intentional difference for the port:
ep_write_main_params()writes each mapped param straight after the one before, so a function with two mapped params getsmain(float4 pos : POSITION float2 uv : TEXCOORD0), which doesn't compile. The characterization pins that as "characterized, not endorsed"; the port puts", "between them. Every shader that compiles today comes out the same. - The
empty_paramsbranch,param_strandadjusted_callinep_write_main()/ep_write_main_params()have no effect on the output; the port may drop them. - Threads: effects are parsed on the graphics thread; nothing here keeps state beyond the
writtenflags, which each call clears.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestportPort a C unit to Rust (four-tier policy)readyMeets the definition of Ready; claimable
Type
Projects
- StatusShow more project fieldsDone
Activity
rdoupe commentedon Nov 6, 2026
Claiming: #3765.
test_effect_parser_writer(cmocka) that compiles the original effect parser C into itself and pins, for each pass's vertex and pixel call, the shader textep_makeshaderstring()writes, theused_paramsit collects and everywrittenflag afterwards.dstr_array_tinto a newlibobs/graphics/effect-parser-writer.c.hin its own live unity group, withep_makeshaderstring()declared in a new privategraphics/effect-parser-writer.h. Checked with a move harness (master's and the moved C on the same texts, GCC and Clang, -O0/-O2, ASan/UBSan, planted mutants) and identical export sets on the C, hybrid and C reference builds.mainfix as its intentional difference.Draft PR for 1 and 2 expected today.
libobs: Declare the effect parser shader writer
test: Characterize the effect parser writer
libobs: Move the effect parser writer to file
libobs: Move the effect parser writer to file (obs-rust#3766)
rdoupe commentedon Nov 6, 2026
Continuing with step 3 of the claim above, now that the extraction has merged (#3766): the Rust port of
libobs/graphics/effect-parser-writer.c.hintoobs-graphics'seffect_parsermodule, batched in one PR with #3768 (main()with two mapped params and no comma), which is its one intentional difference.todo!()stubs, portingtest_effect_parser_writer's cases 1:1.ep_makeshaderstring()under its C name (hidden), writing into the caller'sstruct dstrandused_paramsand setting and clearing thewrittenflags in place; the funcs file's lookups still called through their C symbols; layout tests forstruct ep_func.obs-c-oraclewrapper of the writer and a proptest over random parsers and calls, with mutation.Draft PR today, once the RED commit exists.
obs-graphics: Test the effect parser writer
obs-graphics: Port the effect parser writer
obs-graphics: Swap in the effect parser writer
obs-graphics: Compare the effect parser writer
obs-graphics: Put commas between main()'s params
docs: Record the effect parser writer port
obs-graphics: Read the writer's parser in place
obs-graphics: Grow the writer's strings with brealloc
rdoupe commentedon Nov 6, 2026
Intentional difference of the port (PR #3769), as the testing policy asks:
main()gets", "between its mapped params (#3768). The C writes each straight after the one before it, so a function with two or more separately mapped params gotfloat4 main(float4 pos : POSITIONfloat2 uv : TEXCOORD0)and its shader failed to compile. Every shader with at most one mapped param, as every stock effect has, comes out byte for byte the same.It is listed in the core's docs (
obs_graphics::effect_parser::writer), inshader::effect_parser_writer_parity, which compares exactly those calls with the C'smain()rewritten with the commas, and in rust/README.md.test_effect_parser_writerkeeps pinning the C writer's output, so it has no_rustvariant.rdoupe commentedon Nov 7, 2026
Fixed by PR #3769 (merged through the merge queue), after the extraction in #3766: the effect parser's shader writer is now in
obs-graphics'seffect_parsermodule, withep_makeshaderstring()as the hidden C shim over it. The port's one intentional difference, commas betweenmain()'s mapped params, closed #3768.What's left: the effect parser's function parser and lookups (the port of the moved funcs file, blocked on a C change landing first) is #3623. The rest of
effect-parser.c.h(ep_parse(), theep_compile*steps andep_parse_other()) has no issue of its own yet; it sits under the Phase 6 meta issue (#444) and gets one when someone claims it.obs-graphics: Port the effect parser writer (obs-rust#3769)