Repository navigation
libobs: Extract the raster and blend setters - #4818
Merged
Merged
Conversation
Pin seven public graphics state exports (gs_set_cull_mode, gs_get_cull_mode, gs_enable_color, gs_enable_blending, gs_blend_function, gs_blend_function_separate and gs_blend_op) through a recording backend, before they move out of graphics.c.h. No graphics module or GPU is needed. Outside a graphics context (never entered, and after leaving one) each call dispatches nothing, leaves the blend state alone and writes its own gs_valid debug line, and gs_get_cull_mode returns GS_NEITHER. Inside one, each call reaches its own device export once with the current device and its arguments unchanged, undeclared enum values included; gs_get_cull_mode returns the export's answer. The blend setters store the new state before the device is told, gs_blend_function sets the colour and alpha factors alike, and gs_blend_op forwards the stored operation. What they store is what gs_blend_state_push saves and gs_blend_state_pop restores. The test is defined in test-graph.json, so the Cargo-native validator runs it too, in the default core suite like the frame and present characterization. Refs #4812.
Move gs_enable_blending, gs_blend_function, gs_blend_function_separate and gs_blend_op verbatim from graphics.c.h into state-blend-setters.c.h, and gs_set_cull_mode, gs_get_cull_mode and gs_enable_color into raster-state-entrypoints.c.h, each in its original order, so each file can be ported as a whole. Both files sort after graphics.c.h in the graphics unity group, where thread_graphics and the static gs_valid are defined, as present-entrypoints.c.h did. The stencil calls between them stay in graphics.c.h. The Rust blend pop and reset keep calling the blend setters through their C symbols. No signature, header or behaviour change. The exported symbol sets stay identical on the plain C build, hybrid libobs and libobs-c-reference, with all seven still exported. Refs #4812. Local-Gate: v1 tree=96ab1b92f4bffce5b57a323950af5f743440b550 secs=3047 lanes=lint:run,dylint:run,rust-test:run,cross:run,tier2-linux:run,macos-native:n/a,windows-native:n/a,client-checks:run,client-swift:n/a,client-lint:run,client-test:run,client-test-x86_64-unknown-linux-gnu:run,client-test-aarch64-unknown-linux-gnu:n/a,client-test-x86_64-pc-windows-msvc:n/a,client-test-aarch64-pc-windows-msvc:n/a,client-test-x86_64-apple-darwin:n/a,client-test-aarch64-apple-darwin:n/a Ci-Attestation: {"at":1794548695,"gate":"rust/all/fmt","host":"linux-x86_64","key":"828448f7722d8172cc7e04cd8708dba28c8bbae14bf38bd62d427a3979e8803a","lane":"lint","parents":["d31a92ad2fce2bf934a04579e0e03d7bd2589e35"],"secs":59,"stamp":"21d6793b647bfdb4929ff8714dc3eaa7","tree":"96ab1b92f4bffce5b57a323950af5f743440b550","v":1,"via":"run"} Ci-Attestation: {"at":1794548695,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"828448f7722d8172cc7e04cd8708dba28c8bbae14bf38bd62d427a3979e8803a","lane":"lint","parents":["d31a92ad2fce2bf934a04579e0e03d7bd2589e35"],"secs":59,"stamp":"f223b5eb3b2f999f3aa4a2696c1d7d96","tree":"96ab1b92f4bffce5b57a323950af5f743440b550","v":1,"via":"run"} Ci-Attestation: {"at":1794548695,"gate":"rust/x86_64-unknown-linux-gnu/dylint","host":"linux-x86_64","key":"dee6f7c12117f5eb874c202cc4145078d199000c52db8b882890c43d0fc90028","lane":"dylint","parents":["d31a92ad2fce2bf934a04579e0e03d7bd2589e35"],"secs":0,"stamp":"a2f7ecd98e49ae4fe4243418cfaa25b6","tree":"96ab1b92f4bffce5b57a323950af5f743440b550","v":1,"via":"run"} Ci-Attestation: {"at":1794548695,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"b44411cbb7a4a3c46972508af4576200cc93d69d4b3f877c52227fddd055b6f3","lane":"rust-test","parents":["d31a92ad2fce2bf934a04579e0e03d7bd2589e35"],"secs":376,"stamp":"e4773e9633b99602193d8b7f74d8f29d","tree":"96ab1b92f4bffce5b57a323950af5f743440b550","v":1,"via":"run"} Ci-Attestation: {"at":1794548695,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"0a0b9f726a80f3a4389fe7229c2bc0e7cacbc8a4b32896037d234bf40eccf24c","lane":"cross","parents":["d31a92ad2fce2bf934a04579e0e03d7bd2589e35"],"secs":245,"stamp":"4e7e9bcab5d544cf8719dc04dfb8d05d","tree":"96ab1b92f4bffce5b57a323950af5f743440b550","v":1,"via":"run"} Ci-Attestation: {"at":1794548695,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"0a0b9f726a80f3a4389fe7229c2bc0e7cacbc8a4b32896037d234bf40eccf24c","lane":"cross","parents":["d31a92ad2fce2bf934a04579e0e03d7bd2589e35"],"secs":245,"stamp":"cd510be107df0c0e73e359085f5eb1ec","tree":"96ab1b92f4bffce5b57a323950af5f743440b550","v":1,"via":"run"} Ci-Attestation: {"at":1794548695,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"0a0b9f726a80f3a4389fe7229c2bc0e7cacbc8a4b32896037d234bf40eccf24c","lane":"cross","parents":["d31a92ad2fce2bf934a04579e0e03d7bd2589e35"],"secs":245,"stamp":"152991ae6db48a056b70a4910fe37ee9","tree":"96ab1b92f4bffce5b57a323950af5f743440b550","v":1,"via":"run"} Ci-Attestation: {"at":1794548695,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"0a0b9f726a80f3a4389fe7229c2bc0e7cacbc8a4b32896037d234bf40eccf24c","lane":"cross","parents":["d31a92ad2fce2bf934a04579e0e03d7bd2589e35"],"secs":245,"stamp":"07f2db33d32b4940ed8a87209d7ba48f","tree":"96ab1b92f4bffce5b57a323950af5f743440b550","v":1,"via":"run"} Ci-Attestation: {"at":1794548695,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"b05adf22c53d0b0aacb294d165547768ae0e3fd145a039a29d70ebc19351d07f","lane":"tier2-linux","parents":["d31a92ad2fce2bf934a04579e0e03d7bd2589e35"],"secs":3046,"stamp":"c17caf60ab4bd637b280263d177e7992","tree":"96ab1b92f4bffce5b57a323950af5f743440b550","v":1,"via":"run"} Ci-Attestation: {"at":1794548695,"gate":"python/all/self-test","host":"linux-x86_64","key":"c53c5ddb531ae0caf0a6b412b17764eeee64357e2d988f7cf3e42aa9669d6f89","lane":"client-checks","parents":["d31a92ad2fce2bf934a04579e0e03d7bd2589e35"],"secs":63,"stamp":"6a64b24936ae576834b98d8c60960354","tree":"96ab1b92f4bffce5b57a323950af5f743440b550","v":1,"via":"run"} Ci-Attestation: {"at":1794548695,"gate":"general/all/client-lint","host":"linux-x86_64","key":"f6164116c8f83c8d9056e4f45e86f5b4086814a4da814742a6ba850d21b247fa","lane":"client-lint","parents":["d31a92ad2fce2bf934a04579e0e03d7bd2589e35"],"secs":88,"stamp":"2566726a1a9ff535c5b0d0da398244b4","tree":"96ab1b92f4bffce5b57a323950af5f743440b550","v":1,"via":"run"} Ci-Attestation: {"at":1794548695,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"f6164116c8f83c8d9056e4f45e86f5b4086814a4da814742a6ba850d21b247fa","lane":"client-lint","parents":["d31a92ad2fce2bf934a04579e0e03d7bd2589e35"],"secs":88,"stamp":"71882819bd8d91b9c03b112f85974596","tree":"96ab1b92f4bffce5b57a323950af5f743440b550","v":1,"via":"run"} Ci-Attestation: {"at":1794548695,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"f6164116c8f83c8d9056e4f45e86f5b4086814a4da814742a6ba850d21b247fa","lane":"client-lint","parents":["d31a92ad2fce2bf934a04579e0e03d7bd2589e35"],"secs":88,"stamp":"40ce76391262f5df18d4bf5156390b32","tree":"96ab1b92f4bffce5b57a323950af5f743440b550","v":1,"via":"run"} Ci-Attestation: {"at":1794548695,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"f6164116c8f83c8d9056e4f45e86f5b4086814a4da814742a6ba850d21b247fa","lane":"client-lint","parents":["d31a92ad2fce2bf934a04579e0e03d7bd2589e35"],"secs":88,"stamp":"8e2d067d9ec79b850399a92cbfaf0138","tree":"96ab1b92f4bffce5b57a323950af5f743440b550","v":1,"via":"run"} Ci-Attestation: {"at":1794548695,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"f6164116c8f83c8d9056e4f45e86f5b4086814a4da814742a6ba850d21b247fa","lane":"client-lint","parents":["d31a92ad2fce2bf934a04579e0e03d7bd2589e35"],"secs":88,"stamp":"d12d1e1eae177a9e1714f879ce0c4587","tree":"96ab1b92f4bffce5b57a323950af5f743440b550","v":1,"via":"run"} Ci-Attestation: {"at":1794548695,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"f6164116c8f83c8d9056e4f45e86f5b4086814a4da814742a6ba850d21b247fa","lane":"client-lint","parents":["d31a92ad2fce2bf934a04579e0e03d7bd2589e35"],"secs":88,"stamp":"6890cd127cee1fbd9921adf88fd56ff2","tree":"96ab1b92f4bffce5b57a323950af5f743440b550","v":1,"via":"run"} Ci-Attestation: {"at":1794548695,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"f6164116c8f83c8d9056e4f45e86f5b4086814a4da814742a6ba850d21b247fa","lane":"client-lint","parents":["d31a92ad2fce2bf934a04579e0e03d7bd2589e35"],"secs":88,"stamp":"14132bfa86ab09c7cfd190ce1a850248","tree":"96ab1b92f4bffce5b57a323950af5f743440b550","v":1,"via":"run"} Ci-Attestation: {"at":1794548695,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"f6164116c8f83c8d9056e4f45e86f5b4086814a4da814742a6ba850d21b247fa","lane":"client-lint","parents":["d31a92ad2fce2bf934a04579e0e03d7bd2589e35"],"secs":88,"stamp":"4f6c763a58db354d528826279b14ce0e","tree":"96ab1b92f4bffce5b57a323950af5f743440b550","v":1,"via":"run"} Ci-Attestation: {"at":1794548695,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"f6164116c8f83c8d9056e4f45e86f5b4086814a4da814742a6ba850d21b247fa","lane":"client-lint","parents":["d31a92ad2fce2bf934a04579e0e03d7bd2589e35"],"secs":88,"stamp":"ba90ecdd54a0950c4a208607341bc672","tree":"96ab1b92f4bffce5b57a323950af5f743440b550","v":1,"via":"run"} Ci-Attestation: {"at":1794548695,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"f6164116c8f83c8d9056e4f45e86f5b4086814a4da814742a6ba850d21b247fa","lane":"client-lint","parents":["d31a92ad2fce2bf934a04579e0e03d7bd2589e35"],"secs":88,"stamp":"237ca1a882aeb2e8792ee71ed6db3e3d","tree":"96ab1b92f4bffce5b57a323950af5f743440b550","v":1,"via":"run"} Ci-Attestation: {"at":1794548695,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"f6164116c8f83c8d9056e4f45e86f5b4086814a4da814742a6ba850d21b247fa","lane":"client-lint","parents":["d31a92ad2fce2bf934a04579e0e03d7bd2589e35"],"secs":88,"stamp":"110ae0a8ef3ee068eea1beb05480b03e","tree":"96ab1b92f4bffce5b57a323950af5f743440b550","v":1,"via":"run"} Ci-Attestation: {"at":1794548695,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"f6164116c8f83c8d9056e4f45e86f5b4086814a4da814742a6ba850d21b247fa","lane":"client-lint","parents":["d31a92ad2fce2bf934a04579e0e03d7bd2589e35"],"secs":88,"stamp":"aeafc46b88f09768a422eb90c2027bb1","tree":"96ab1b92f4bffce5b57a323950af5f743440b550","v":1,"via":"run"} Ci-Attestation: {"at":1794548695,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"f6164116c8f83c8d9056e4f45e86f5b4086814a4da814742a6ba850d21b247fa","lane":"client-lint","parents":["d31a92ad2fce2bf934a04579e0e03d7bd2589e35"],"secs":88,"stamp":"802fa01056e42a79ce24f234e5b5090d","tree":"96ab1b92f4bffce5b57a323950af5f743440b550","v":1,"via":"run"} Ci-Attestation: {"at":1794548695,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"54a501d14919185ef5b7ce47c5ffcc7b27697fdcfeb279a44785c31803e2cf03","lane":"client-test-x86_64-unknown-linux-gnu","parents":["d31a92ad2fce2bf934a04579e0e03d7bd2589e35"],"secs":326,"stamp":"ec813fd0706c12c862c195a0aa1e0d39","tree":"96ab1b92f4bffce5b57a323950af5f743440b550","v":1,"via":"run"}
Collaborator
Author
|
Handed off to the coordinator |
This was referenced Nov 13, 2026
6 of 7 tasks
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.
Fixes #4812
What and why
The behaviour-neutral prerequisite for porting seven graphics state entry points to
obs-graphics(testing-policy.md, "Extracting a function before porting it"): the cull mode getter and setter, the colour write mask, and the four blend setters that the blend push, pop and reset port (#4296) left in C. Each new file can then be swapped to Rust as a whole.test: Characterize the raster and blend setters): a new GPU-free cmocka test,test/cmocka/test_raster_state_entrypoints.c, calls the real public exports through a recording backend, the waytest_present_entrypointsdoes. It is defined intest/cmocka/build/test-graph.json(defaultcoresuite: it needs no graphics module), so CMake and the Cargo-native validator both build and run it. It pins:gs_get_cull_modereturnsGS_NEITHEReven when the backend would answer otherwise, and each call writes its owngs_validdebug line;gs_get_cull_modereturns the export's answer each time, nothing cached;gs_blend_functionsets the colour and alpha factors alike;gs_blend_opforwards the stored operation;gs_blend_state_pushsaves andgs_blend_state_poprestores, a singlegs_blend_functionpair included.libobs: Extract the raster and blend setters):gs_enable_blending,gs_blend_function,gs_blend_function_separateandgs_blend_opmove verbatim fromlibobs/graphics/graphics.c.h(lines 1333-1342 and 1374-1412) intolibobs/graphics/state-blend-setters.c.h, andgs_set_cull_mode,gs_get_cull_modeandgs_enable_color(lines 1313-1331 and 1364-1372) intolibobs/graphics/raster-state-entrypoints.c.h, each in its original order. Both includelibobs-graphics.pch.hlikepresent-entrypoints.c.hdid, and sort aftergraphics.c.hinlibobs.graphics+.h.c, wherethread_graphicsand the staticgs_validare defined. No Rust, and no signature, header or behaviour change. The Rust blend pop and reset keep calling the blend setters through their C symbols.The four stencil calls between them (
gs_enable_stencil_test,gs_enable_stencil_write,gs_stencil_function,gs_stencil_op) stay ingraphics.c.h: their extraction is #4418's.RED → GREEN
test_raster_state_entrypointspasses (3/3) on the plain C build, hybridlibobsandlibobs-c-reference, on the characterization commit and after the move.test_pulse_default_followand the two vivid camera tests, which need hardware or a sound server). Two fail on all three builds, the plain C one included, because they need a running sound server:test_v4l2_vcam_audioandtest_v4l2_vmic_libpulse. The third on plain C (test_enum_modules) and on the C reference (test_find_modules) passed alone on all three builds (load).T).gs_get_cull_modereturningGS_BACKwithout a context,gs_blend_function's alpha source taken from the destination,gs_blend_optelling the device before storing,gs_enable_blendingnot storing, green and blue swapped ings_enable_color, the wrong name ings_blend_function_separate's debug line, the cull mode's back and front swapped, andgs_blend_function_separate's alpha destination taken from the alpha source. Planted in the real files, the same 8 also failtest_raster_state_entrypoints.--lane lint,--lane dylint,--lane cross,--test-diff(8444 passed, 6 skipped) and the Windows MSVC all-targets clippy all pass. The full local gate (lint, dylint, rust-test, cross, Tier 2 in the Linux container) passed and stamped the pushed head.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)