Repository navigation
Description
Unit
libobs/graphics/effect.c.h, the name and index lookups, into rust/obs-graphics. They move to libobs/graphics/effect-lookups.c.h. About 110 lines. They walk arrays on a gs_effect the caller already built. They do not call the graphics device.
gs_effect_get_techniquegs_effect_get_current_techniquegs_effect_get_num_paramsgs_effect_get_param_by_idxgs_effect_get_param_by_namegs_param_get_num_annotationsgs_param_get_annotation_by_idxgs_param_get_annotation_by_namegs_technique_get_pass_by_idxgs_technique_get_pass_by_namegs_effect_get_viewproj_matrixgs_effect_get_world_matrixgs_effect_get_param_info
These stay in effect.c.h: gs_effect_destroy, gs_effect_loop, technique begin and end, begin_pass and end_pass, parameter upload, and the setters. They call the device (gs_get_effect, cur_effect, shader load).
Phase and position
Phase 6 (#444). Graphics math is already in obs-graphics (Phase 5). Shader parameter names are ported (#839). The effect-parser lifecycle is already its own C file. This slice is next: a pure walk of the effect arrays, and it does not share a file with an open port. The rest of effect.c.h waits until the device side has a seam.
Dependencies and existing tests
The functions take the public typedefs in graphics.h (gs_effect_t, gs_technique_t, gs_epass_t, gs_eparam_t, gs_effect_param_info). The structs are complete in graphics/effect.h. A test can fill them with effect_init, effect_param_init and effect_technique_init and never start a GPU.
No cmocka test covers these lookups. The characterization lands first, with the move, and links OBS::libobs. The symbols are EXPORT, so the test calls them through libobs and will see the later swap. It does not compile the .c.h into itself.
Name walks are a first-match strcmp. A missing name returns NULL. A null effect returns NULL, or 0 from gs_effect_get_num_params. A null param returns 0 annotations and NULL annotation pointers, and gs_effect_get_param_info returns without writing info. A null technique returns NULL passes.
Index checks, as the C is today:
gs_effect_get_param_by_idxreturns NULL when the index is greater than or equal toparams.num.gs_param_get_annotation_by_idxandgs_technique_get_pass_by_idxreturn NULL only when the index is greater than the count. An index equal to the count returns one past the array. The test compares that pointer and does not dereference it.
gs_effect_get_current_technique returns the stored pointer even when that technique is not in the techniques array. View-proj and world are the stored pointers.
Plan
- Characterization PR, opening with the claim. Move the functions verbatim into
libobs/graphics/effect-lookups.c.h, include it fromlibobs/build/libobs.graphics+.h.c, and addtest/cmocka/test_effect_lookups.c. No Rust, no public header change, no behavior change.Refsthis issue. - Port PR after that merges. RED, then GREEN, in
obs-graphics. Tier 1 ports the cmocka cases. Tier 2 runs the same test with Rust off and on. Tier 3 compares the lookups to the moved C. Tier 4 does not apply. The Rust tests join the existingobs-tests-graphicsbinary.
Notes
The one-past return on an annotation index or a pass index equal to the count is characterized, not endorsed. This plan does not change it. A fix, if one is wanted, should land before the port so the port copies the fixed C.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
nathan-v commentedon Oct 22, 2026
Claiming: graphics/effect-lookups.c
effect.c.hintographics/effect-lookups.c.h(same graphics unity group, no behavior change) and add a cmocka test that links libobs. The test pins first-match names, null inputs, and the index checks as they are: a param index uses>=and returns null at the count, while an annotation index and a pass index use>, so an index equal to the count returns one past the array. That one-past return is characterized, not endorsed. No Rust.obs-graphics, with a layout check and a differential against the moved C. The cmocka test stays unchanged.First PR today.
nathan-v commentedon Oct 22, 2026
Characterization PR: #1823 (draft).
test_effect_lookupspassed 5/5 before the move and 5/5 after, on macOS arm64, Rust off. The Rust port is still the second step.libobs: Characterize effect name and index lookups (obs-rust#1823)
nathan-v commentedon Oct 22, 2026
The Rust port is up as a draft: #1843
RED is 056a97b. The five lookup tests panic in todo!(). GREEN is next on the same branch.
test: Port effect lookup cases against stubs
obs-graphics: Port effect name and index lookups
obs-graphics: Port effect name and index lookups (obs-rust#1843)