Repository navigation
libobs: Move the effect parser params to own file - #3615
Merged
Merged
Conversation
The effect parser's parameter value assignments have no C test of
their own: the effect tests load whole effects through a device.
test_effect_parser_params calls ep_init(), ep_parse() and ep_free()
on fixed effect texts and pins, written out and compared whole, the
params kept (flags, array count and every byte of the default value),
the functions after them, every error and warning with its row,
column and level, and the allocations still held after ep_free().
78 texts: each value form (int, float, bool, string, texture path,
negative values with and without a space, the { } and type( ) forms of
the vectors and the 3x3, 4x4 and 2x2 matrices), malformed values (not
a number, a bool other than true or false, an invalid type, a bad row
or column count, too few or too many values, a missing ',' or end, a
vector without '{', a missing ';'), array counts (valid, 0, negative,
not a number, unterminated) and text cut short at each step. Odd but
real results are marked "characterized, not endorsed": among them, a
bad bool or an invalid type does not skip to the ';', so the next
statement starts at the bad token and reports it again.
ep_parse() and ep_free() are hidden in libobs, so the test compiles
the original effect parser C into itself and links libobs for the
rest, as test_effect_parser_passes does. Every text is parsed behind
a first line of "{}", whose error keeps ep_parse() from calling
ep_compile(), which needs a device. No display and no graphics
context: it runs on every platform. It passes, none skipped, against
the C, hybrid and C reference libobs, and built with ASan and UBSan
it has no report.
Refs #3610.
Behaviour-neutral extraction before the Rust port. The effect parser's parameter value assignments move, as written, into the new libobs/graphics/effect-parser-params.c.h: - ep_parse_param_array(); - ep_parse_param_assign_texture(), _string(), _intfloat() and _bool(), and ep_parse_param_assign_intfloat_array(); - ep_parse_param_assignment_val(); - ep_parse_param_assign(). The annotations and ep_parse_param(), still in effect-parser.c, call ep_parse_param_array() and ep_parse_param_assign(), so those two lose their static (and inline) and are declared in a new internal graphics/effect-parser-params.h, a private adapter and not a new public API; its declaration replaces effect-parser.c's forward one. The value helpers stay static in the new file. Nothing else changes: the callers call them on the same tokens, in the same places. The new file has its own live group, libobs.effect-parser-params (in the graphics module), with a precompiled header of its declarations, the parameter type decisions and util/platform.h, so the C oracle can compile it alone and the port can move its include into a ported group. No Rust: the hybrid libobs compiles the C too. The C, hybrid and C reference builds export the same 1767 symbols as master, the two moved functions local (t) in each. The tests that compile the effect parser C into themselves compile the new file beside it. Refs #3610. Co-authored-by: Lain <[email protected]>
The effect parser's annotations and parameter declaration have no C test of their own either. test_effect_parser_params gains two groups of texts and now also writes out each param's annotations (type, name and default bytes, in the order they were pushed): - 22 annotation lists: well-formed ones with each value form, empty lists, stray ';', repeated names, a list after an array count and before a value, entries with no name, a ':' mapping, an entry that ends at '>', a failed value, no ';' after a value, a bad type or name, a nested list, an invalid type, no ';' after the list, a list after the value and two lists; - 8 texts cut short at each step of an entry. Odd but real results are marked "characterized, not endorsed": among them, a ':' mapping or a failed value ends the list where it is, so the param is dropped and the parser goes on from inside the list, and a nested list ends the outer one at its '>', so the outer list's last entry is read as a param of its own. It passes, none skipped, against the C, hybrid and C reference libobs, and built with ASan and UBSan it has no report. Refs #3611.
Behaviour-neutral extraction before the Rust port. The effect parser's annotations and parameter declaration move, as written, into libobs/graphics/effect-parser-params.c.h, ahead of the value assignments as in effect-parser.c: - ep_parse_param_annotation_var(); - ep_parse_annotations() and ep_parse_param_annotations(), which keep their int return type; - the commented-out ep_parse_param_property() stub and ep_parse_param(). ep_parse_other() calls ep_parse_param(), so it loses its static and is declared in graphics/effect-parser-params.h beside the two value helpers, which stay declared so the value parser can be ported before the declaration that calls it. The annotation helpers stay static. Nothing else changes: ep_parse_other() calls it on the same token, with the same type and name. Without its static the signature fits on one line, which is the only change clang-format makes to the moved code. effect-parser.c now reaches the file only through ep_parse_param(). The C, hybrid and C reference builds export the same 1767 symbols as master, ep_parse_param, ep_parse_param_array and ep_parse_param_assign local (t) in each. Refs #3611. Co-authored-by: Lain <[email protected]>
This was referenced Nov 4, 2026
7 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #3610
Refs #3611
What and why
First step of porting the effect parser's parameters to
obs-graphics: a characterization test and a behaviour-neutral extraction, C only, for two batched units, the parameter value assignments (#3610) and the annotations and parameter declaration (#3611). The Rust port of the moved file follows in its own PR on both issues. Same shape as the effect parser's passes and techniques (#3599).test: Characterize the effect parser param values(rust: Port the effect parser's parameter value assignments #3610): a newtest_effect_parser_params(cmocka) callsep_init(),ep_parse()andep_free()on 78 fixed effect texts and pins, written out and compared whole, the params kept (flags, array count and every byte of the default value), the functions after them, every error and warning with its row, column and level, and the allocations still held afterep_free(). It covers each value form (int, float, bool, string, texture path, negative values with and without a space, the{ }andtype( )forms of the vectors and of the 3x3, 4x4 and 2x2 matrices), malformed values (not a number, a bool other thantrueorfalse, an invalid type, a bad row or column count, too few or too many values, a missing,or end, a vector without{, a missing;), array counts (valid, 0, negative, not a number, unterminated) and text cut short at each step.ep_parse()andep_free()are hidden in libobs, so the test compiles the original effect parser C into itself and links libobs for the rest; each text is parsed behind a first line of{}, whose error keepsep_parse()from callingep_compile()(which needs a device). No display and no graphics context, so it runs on every platform.libobs: Move the effect param values to own file(rust: Port the effect parser's parameter value assignments #3610):ep_parse_param_array(),ep_parse_param_assign_texture(),_string(),_intfloat(),_bool(),ep_parse_param_assign_intfloat_array(),ep_parse_param_assignment_val()andep_parse_param_assign()move, as written, fromlibobs/graphics/effect-parser.c.hinto the newlibobs/graphics/effect-parser-params.c.h. The annotations andep_parse_param()still callep_parse_param_array()andep_parse_param_assign(), so those two lose theirstaticand are declared in a new internalgraphics/effect-parser-params.h(a private adapter, not a new public API;effect-parser.hstays as it is), which replaces the forward declaration; the value helpers staystatic. The file has its own live unity group,libobs.effect-parser-params(graphics module), with a precompiled header of its declarations, the parameter type decisions andutil/platform.h, so the port can later move its include into a ported group.docs/rust-port/naming.mdlists it underobs-graphics.test_effect_parser_blocks,test_effect_parser_passesand their_rustvariants, which compileeffect-parser.c.hinto themselves, compile the moved file beside it.test: Characterize the effect parser annotations(rust: Port the effect parser's annotations and parameter declaration #3611): the same test gains 30 texts and writes out each param's annotations: well-formed lists with each value form, empty lists, stray;, repeated names, a list after an array count and before a value, entries with no name, a:mapping, an entry that ends at>, a failed value, no;after a value, a bad type or name, a nested list, an invalid type, no;after the list, a list after the value, two lists, and text cut short at each step of an entry.libobs: Move the effect param declaration to file(rust: Port the effect parser's annotations and parameter declaration #3611):ep_parse_param_annotation_var(),ep_parse_annotations()andep_parse_param_annotations()(which keep theirintreturn type), the commented-outep_parse_param_property()stub andep_parse_param()move, as written, into the same file, ineffect-parser.c's order (annotations first, then the values, then the declaration).ep_parse_other()callsep_parse_param(), so it loses itsstaticand is declared ineffect-parser-params.h; the two value helpers stay declared so the value parser can be ported before the declaration that calls it, and the annotation helpers staystatic. Without itsstaticthe signature fits on one line, the only change clang-format makes to the moved code.effect-parser.cnow reaches the file only throughep_parse_param().Odd but real results are marked "characterized, not endorsed" in the test. Among them: a bool other than
trueorfalse, or an invalid type, does not skip to the;, so the next statement starts at the bad token and reports it again; no;after a value drops the param with no error; a:mapping or a failed value in an annotation ends the list where it is, so the param is dropped and the parser goes on from inside the list; a nested annotation list ends the outer one at its>. No leak and no undefined behaviour showed: built with ASan and UBSan (gcc and clang) the test has no report, so the port has no intentional difference so far.Moved code: Lain Bailey's (upstream obs-studio), credited on the move commits. No upstream issue.
Move harness (scratch, not committed): the whole effect parser C, built once from master's files and once from the moved ones, each with a driver that writes out every param (flags, array count, default bytes, annotations recursively), function, struct, technique, error and the live allocations after
ep_free(), run on the same 199,997 generated effect texts (seed declarations with 1/64 to 29/64 of their tokens dropped, replaced or joined by others, a quarter cut short, and token soups; three generated texts that reach the function parser, a later unit, are left out): identical logs (1,153,060 lines, 40,337 params kept, 28,946 with a default value, 3,010 with annotations, 712,726 errors) in 8 builds of each side (GCC and Clang, -O0 and -O2, with and without ASan and UBSan without recovery), for the tree after each move. Sixteen planted mutants of the moved code all differ.RED → GREEN
test_effect_parser_paramspasses 7/7 on the C build, the hybridlibobsandlibobs-c-reference, none skipped. It and the effect and shader tests (test_effect_int_bool_defaults,test_effect_lookups,test_effect_number_defaults,test_effect_param_numbers_steps,test_effect_param_types_steps,test_effect_param_values,test_effect_parser_blocks,test_effect_parser_lifecycle,test_effect_parser_passes,test_effect_pass_loop,test_effect_set_default_null,test_shader_number_defaults,test_shader_param_names,test_shader_param_values_steps,test_shader_parser_blocks,test_shader_sampler_convert) pass 17/17 on the C build and 21/21 (with the four_rustvariants) on the hybridlibobsand onlibobs-c-reference, none skipped. The C, hybrid and C reference builds export the same 1767 symbols as master;ep_parse_param,ep_parse_param_arrayandep_parse_param_assignare local (t) in each. The workspace tests, formatting, clippy and the Windows clippy on all targets pass, and./unittestpassed (6504 and 912 Rust tests; Tier 2 720/720 againstlibobs-c-referenceand 720/720 against the hybridlibobs). The local gate could not stamp this head here (its Dylint step has no driver for the pinned nightly on this machine), so PR CI runs the full suite. Runs were on 046aa14; the move harness ran on the same commits before their rebase onto the passes port, which changed none of the C it compiles but one precompiled header include, the same on both sides.Checklist
master(or the description starts with a Stacked: note)docs/features.mdis added or updated (not applicable: no user-visible change)-W..., ratchets): built with scripting ON (PR CI builds no OBS app: rungh workflow run ci.yml --ref <branch>for the full builds) and cross-checked with clang and MSVC (not applicable: no warning or flag change)