Repository navigation
Description
Unit
The parameter values of libobs/graphics/effect.c.h (433 lines), into rust/obs-graphics as obs_graphics::effect_params. Slice 1 of effect.c; it follows the effect lookups (#1822, #1843) and the effect-parser lifecycle (#1644) in the same crate.
The 17 public functions that set and read a parameter's value, all EXPORT:
- the setters:
gs_effect_set_bool,_float,_int,_matrix4,_vec2,_vec3,_vec4,_color,_texture,_texture_srgb,_val,_default, andgs_effect_set_next_sampler; - the getters:
gs_effect_get_val,gs_effect_get_val_size,gs_effect_get_default_val,gs_effect_get_default_val_size; - the shared core,
effect_setval_inline(resizecur_valwhen the size changes, copy and setchangedonly when the bytes differ) and the two getter copies (at most the stored size).
Every filter and scene item sets its effect parameters on every frame, so the setters are on the hot path.
These stay C in this slice: everything that touches the graphics device or the pass state: gs_effect_loop, gs_technique_begin / _end, gs_technique_begin_pass / _by_name / _end_pass, gs_effect_update_params and the upload (upload_shader_params, clear_tex_params, reset_params), and gs_effect_destroy. They are slice 2.
Phase and position
Phase 5/6 graphics (obs-graphics), next to effect_lookups and effect_parser_lifecycle.
Seam
- Structs:
struct gs_effect_paramis already mirrored#[repr(C)]inobs-graphics::ffi::effect_lookups, with layout tests (obs-graphics: Port effect name and index lookups #1843). This slice reuses it:cur_valanddefault_val(DARRAY(uint8_t)),changed,next_sampler,type. No new layout crosses; no public header changes. - Memory:
cur_valis resized in place throughobs_util::ffi::darray(bmem, aseffect_freefrees it withda_free);gs_effect_get_valandgs_effect_get_default_valreturnbzallocmemory, which the caller frees withbfree, so the shim allocates through obs-util's bmem. - Logging: the four
LOG_ERRORlines ("effect_setval_inline: invalid param" / "invalid data", "gs_effect_get_val: invalid param", "gs_effect_get_default_val: invalid param", "gs_effect_set_next_sampler: invalid param") go through the existing log helper the graphics shims use (image_file), with the same text. vec4_from_bgra(gs_effect_set_color) is a header inline ingraphics/vec4.h, not in the Rustvec4port yet; the slice ports it as a helper with its own parity case.- No device: none of these functions calls into the graphics subsystem, so no
Devicetrait is needed in this slice.
Characterized behaviour to keep (from reading; to pin with tests)
gs_effect_set_defaulton a parameter without a default passes the NULLdefault_val.arrayon, so it logs "invalid data" and keeps the current value (partly covered bytest_effect_set_default_null, libobs/graphics: gs_effect_set_default dereferences a NULL param #2210).gs_effect_set_vec3stores 12 bytes (sizeof(float) * 3), notsizeof(struct vec3)(16 with the SSE lane);gs_effect_set_vec4and_matrix4store the whole struct.gs_effect_set_boolstores anint(4 bytes).- Setting the same bytes again does not set
changed; a different size always does (even with a common prefix). gs_effect_set_next_sampleronly takes effect on aGS_SHADER_PARAM_TEXTUREparameter and is silent otherwise.- The getters return NULL for a size of 0 and copy at most the stored size.
Existing tests
test_effect_set_default_null(libobs/graphics: gs_effect_set_default dereferences a NULL param #2210) runs the real setters with graphics up (Xvfb on Linux): a NULL parameter, the default put back, a parameter without a default.- Many render tests set effect parameters through the real libobs (
test_color_correction_16f,test_scroll_filter_wide_source,test_sprite_flip_render,test_scene_rotated_scale_filter, ...). They are the Tier 2 for this slice. - No test pins the value rules above. New cases go into a new
test_effect_param_valueson a hand-builtstruct gs_effect_param(no graphics context needed): each setter's size and bytes,changedon same / different bytes and on a size change, the getters (NULL at 0, copy limits, freed withbfree),set_defaultwith and without a default,next_sampleron texture and non-texture parameters, NULL parameter and NULL data (one log line each).
Plan
One PR, in this order:
- Characterization commit:
test_effect_param_valuesagainst the C (libobsandlibobs-c-reference). - Extraction commit, behaviour-neutral: the parameter value functions move to
libobs/graphics/effect-params.c.h(same unity group for now). The unchanged tests pass. - RED: the safe core in
obs-graphics(effect_params) withtodo!(), Tier 1 tests (the cmocka cases 1:1, plus properties), failing. - GREEN: the core and the
#[no_mangle]shims for the 17 exported functions, the file moved to alibobs.ported-effect-paramsgroup, Tier 3 proptest against the C oracle (the extracted file),port_comparisonnumbers forgs_effect_set_float,_vec4,_matrix4and_texture(same value and changed value). - Tier 2:
test_effect_set_default_nulland the render tests above with Rust off and on. Exported symbols unchanged.
Next slice
Slice 2: the technique and pass loop with the parameter upload. It calls the graphics device (gs_load_vertexshader, gs_shader_set_val, gs_shader_set_next_sampler, gs_shader_get_param_info, gs_shader_set_texture), so it needs a Device trait as in texture_render, and a hidden C accessor for graphics->cur_effect (the graphics_subsystem layout does not cross). Filed when this one closes.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
vpacher commentedon Oct 25, 2026
Claiming: #2409
Plan as in the description: one PR (characterization, extraction, RED, GREEN with Tier 3 and
port_comparison, Tier 2). Progress notes here as the steps land.vpacher commentedon Oct 25, 2026
Progress: #2411 is open with the whole plan (characterization, extraction, RED, GREEN, Tier 3). Tier 2 6/6 on the hybrid and the C reference (the four render tests plus
test_effect_param_valuesandtest_effect_set_default_null), Tier 1/3 32/32 on Linux, mutation check 17/19 (the two survivors are equivalent). Slice 2 (the technique and pass loop with the upload) gets its own issue when this one closes.test: Characterize the effect parameter values
libobs: Move the effect parameter values into graphics/effect-params.c
obs-graphics: Add Tier 1 tests for the effect parameter values port
obs-graphics: Port the effect parameter values
obs-graphics: Check the effect parameter values port against the C
obs-graphics: Port the effect parameter values (obs-rust#2409) (obs-r…