Repository navigation
Description
Unit
The technique and pass loop of libobs/graphics/effect.c.h, with the parameter upload, into rust/obs-graphics as obs_graphics::effect_passes. Slice 2 of effect.c, after #2409 (the parameter values, #2411, merged).
- The exported functions:
gs_effect_loop,gs_technique_begin,gs_technique_end,gs_technique_begin_pass,gs_technique_begin_pass_by_name,gs_technique_end_pass,gs_effect_update_params. - The static helpers:
upload_shader_params(the next sampler, then the value or the default, only the changed ones on an update),upload_parameters(vertex then pixel shader, thenchangedcleared),reset_params,clear_tex_params(texture parameters set to NULL at the end of a pass).
Every draw in OBS runs this loop (while (gs_effect_loop(effect, "Draw"))), once per pass.
These stay C: gs_effect_destroy and gs_effect_actually_destroy (the effect's lifecycle through the header-inline effect_free, not on the hot path).
Phase and position
obs-graphics, next to effect_lookups, effect_parser_lifecycle and effect_params.
Seam
- Structs:
struct gs_effect,gs_effect_technique,gs_effect_passandgs_effect_paramare mirrored inffi::effect_lookups. New:struct pass_shaderparam(eparam,sparam) for thevertshader_params/pixelshader_paramsarrays. - Device: a
Devicetrait, as intexture_render, forgs_load_vertexshader,gs_load_pixelshader,gs_shader_set_val,gs_shader_set_next_sampler,gs_shader_get_param_info,gs_shader_set_textureandgs_get_effect. The shim implements it with the C functions. graphics->cur_effect:gs_technique_begin/_endwrite it through the effect's graphics subsystem (tech->effect->graphics), not the thread's.struct graphics_subsystemdoes not cross: a hidden C setter inobs-graphics-adapter.c.hdoes the write.- Logging: the two
LOG_WARNINGlines ofgs_effect_loop("An effect is already active", "Technique '%s' not found.") go through the adapter with the C's literal formats and the name as the argument, aseffect_paramsdoes for its errors. - Values:
cur_val/default_valstay the C darrays;gs_technique_endemptiescur_val(da_resize(.., 0)) througheffect_params::DarrayStore.
Characterized behaviour to keep
gs_effect_loopbegins the technique on the first call, ends the previous pass on each later call, and begins passloop_pass++; when there is no next pass it ends the technique and resetsloopingandloop_pass.- A missing technique or an active effect (
gs_get_effect()) logs a warning and returns false without changing state. gs_technique_begin_pass_by_namereturns true when the name matches, whatevergs_technique_begin_passreturns.gs_technique_endloads NULL shaders, clearscur_techniqueandcur_effect, empties every parameter'scur_val, clearschangedand dropsnext_sampler.- The upload sets the next sampler before it checks
changed; with no value it copies the default intocur_val(da_copy) and uploads that; with neither it skips the parameter.
All of these are pinned by test_effect_pass_loop, done locally on top of #2411 and passing on libobs and libobs-c-reference.
Existing tests
- Every render test runs the loop through the real libobs (
test_color_correction_16f,test_scroll_filter_wide_source,test_sprite_flip_render,test_scene_rotated_scale_filter,test_effect_set_default_null, ...). They are the Tier 2. - No test pins the call sequence. New:
test_effect_pass_loopcompiles the moved C into itself with recording stubs for the device functions andgs_get_effect(no graphics context; every platform), on hand-built effects: one and two passes, a missing technique, an active effect,changed_onlyupdates, defaults, next samplers, texture clearing, begin_pass_by_name, the end-of-technique reset.
Plan
One PR, in this order:
- Extraction commit, behaviour-neutral: the loop and upload move to
libobs/graphics/effect-passes.c.h(same group for now);effect.c.hkeeps the destroy functions. - Characterization commit:
test_effect_pass_loopagainst the C (libobs,libobs-c-reference). - RED: the safe core in
obs-graphics(effect_passes) on aDevicetrait, withtodo!(); Tier 1 tests on a recording device (the cmocka cases 1:1, plus properties), failing. - GREEN: the core, the 7 exported shims, the hidden
cur_effectsetter, the file inlibobs.ported-graphics, Tier 3 (the C oracle and the shim against the same recording stubs: the same call sequence and the same effect state),port_comparisonfor a one- and a two-pass loop with 4 parameters. - Tier 2: the render tests with Rust off and on. Exported symbols unchanged.
After this slice, effect.c.h keeps only gs_effect_destroy and gs_effect_actually_destroy.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
vpacher commentedon Oct 25, 2026
Claiming: #2421
Plan as in the description: one PR (extraction, characterization, RED, GREEN with Tier 3 and
port_comparison, Tier 2). The work is done locally on top of #2411; the PR follows after the checks on the rebased head.vpacher commentedon Oct 25, 2026
Progress: #2422 is open with the whole plan (extraction, characterization, RED, GREEN, Tier 3). Tier 2 7/7 on the hybrid and the C reference, Tier 1/3 45/45 on Linux (three runs), mutation check 16/17 (the survivor is equivalent).
obs-graphics: Write cur_effect through the obs-graphics adapter
graphics: Drop the blank line left at the end of graphics-internal.h
obs-graphics: Port the effect technique and pass loop (obs-rust#2421) (…