From 69e7b066d28c14878eb312815ca1bd906c0fd167 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Wed, 18 Nov 2026 15:36:38 -0800 Subject: [PATCH 1/3] test: mirror sampler-state lifecycle against Rust stubs (Refs #5149) --- rust/obs-graphics/src/lib.rs | 1 + .../src/samplerstate_lifecycle.rs | 50 +++++++ rust/obs-graphics/tests/render/main.rs | 1 + .../tests/render/samplerstate_lifecycle.rs | 141 ++++++++++++++++++ 4 files changed, 193 insertions(+) create mode 100644 rust/obs-graphics/src/samplerstate_lifecycle.rs create mode 100644 rust/obs-graphics/tests/render/samplerstate_lifecycle.rs diff --git a/rust/obs-graphics/src/lib.rs b/rust/obs-graphics/src/lib.rs index 8011a2333d..3d8c9a2a42 100644 --- a/rust/obs-graphics/src/lib.rs +++ b/rust/obs-graphics/src/lib.rs @@ -90,6 +90,7 @@ pub mod quat; pub mod raster_entrypoints; pub mod render_target_setters; mod round; +pub mod samplerstate_lifecycle; pub mod shader_file; pub mod shader_param_introspection; pub mod shader_param_names; diff --git a/rust/obs-graphics/src/samplerstate_lifecycle.rs b/rust/obs-graphics/src/samplerstate_lifecycle.rs new file mode 100644 index 0000000000..37b8d345c3 --- /dev/null +++ b/rust/obs-graphics/src/samplerstate_lifecycle.rs @@ -0,0 +1,50 @@ +//! Sampler lifecycle decisions; objects remain opaque and backend-owned. +use std::ffi::CStr; + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum Entry { + Create, + Destroy, +} +impl Entry { + pub const fn name(self) -> &'static str { + match self { + Self::Create => "gs_samplerstate_create", + Self::Destroy => "gs_samplerstate_destroy", + } + } + pub const fn c_name(self) -> &'static CStr { + match self { + Self::Create => c"gs_samplerstate_create", + Self::Destroy => c"gs_samplerstate_destroy", + } + } +} +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum Rejection { + Context, + Info, +} +impl Rejection { + pub const fn message(self) -> &'static CStr { + match self { + Self::Context => c"called while not in a graphics context", + Self::Info => c"Null 'info' parameter", + } + } +} +/// Dispatch methods are reached only after the Rust context/argument guards. +pub trait Host { + type Info: Copy; + type Sampler: Copy; + fn has_context(&self) -> bool; + fn debug(&mut self, entry: Entry, reason: Rejection); + fn create(&mut self, info: Self::Info) -> Option; + fn destroy(&mut self, sampler: Self::Sampler); +} +pub fn create(_host: &mut H, _info: Option) -> Option { + todo!() +} +pub fn destroy(_host: &mut H, _sampler: Option) { + todo!() +} diff --git a/rust/obs-graphics/tests/render/main.rs b/rust/obs-graphics/tests/render/main.rs index 08dfce64a3..c029947c56 100644 --- a/rust/obs-graphics/tests/render/main.rs +++ b/rust/obs-graphics/tests/render/main.rs @@ -57,6 +57,7 @@ mod raster_entrypoints; mod raster_entrypoints_parity; mod render_target_setters; mod render_target_setters_parity; +mod samplerstate_lifecycle; mod sprite; mod sprite_parity; mod state_stacks; diff --git a/rust/obs-graphics/tests/render/samplerstate_lifecycle.rs b/rust/obs-graphics/tests/render/samplerstate_lifecycle.rs new file mode 100644 index 0000000000..82517bb060 --- /dev/null +++ b/rust/obs-graphics/tests/render/samplerstate_lifecycle.rs @@ -0,0 +1,141 @@ +//! Tier 1: all four unchanged test_samplerstate_lifecycle C characterizations. +use obs_graphics::samplerstate_lifecycle::{self as core, Entry, Host, Rejection}; + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +struct Settings([i64; 6]); +#[derive(Default)] +struct Fixture<'a> { + context: bool, + callbacks: bool, + expected_info: Option<&'a Settings>, + expected_sampler: usize, + result: Option, + calls: [usize; 2], + logs: Vec<(i32, String)>, + events: String, +} +impl<'a> Host for Fixture<'a> { + type Info = &'a Settings; + type Sampler = usize; + fn has_context(&self) -> bool { + self.context + } + fn debug(&mut self, entry: Entry, reason: Rejection) { + self.logs.push(( + 400, + format!("{}: {}", entry.name(), reason.message().to_str().unwrap()), + )); + self.events.push('L'); + } + fn create(&mut self, info: &'a Settings) -> Option { + assert!(self.context && self.callbacks); + assert!(std::ptr::eq(info, self.expected_info.unwrap())); + self.calls[0] += 1; + self.events.push('C'); + self.result + } + fn destroy(&mut self, sampler: usize) { + assert!(self.context && self.callbacks); + assert_eq!(sampler, self.expected_sampler); + self.calls[1] += 1; + self.events.push('D'); + } +} +fn diagnostic(f: &Fixture<'_>, count: usize, message: &str) { + assert_eq!(f.logs.len(), count); + assert_eq!(f.logs.last(), Some(&(400, message.to_owned()))); + assert_eq!(f.calls, [0, 0]); +} +#[test] +fn test_samplerstate_lifecycle_no_context() { + let info = Settings([0; 6]); + let mut f = Fixture { + callbacks: true, + ..Fixture::default() + }; + for i in 0..2 { + assert_eq!(core::create(&mut f, Some(&info)), None); + diagnostic( + &f, + 4 * i + 1, + "gs_samplerstate_create: called while not in a graphics context", + ); + assert_eq!(core::create(&mut f, None), None); + diagnostic( + &f, + 4 * i + 2, + "gs_samplerstate_create: called while not in a graphics context", + ); + core::destroy(&mut f, Some(1)); + diagnostic( + &f, + 4 * i + 3, + "gs_samplerstate_destroy: called while not in a graphics context", + ); + core::destroy(&mut f, None); + diagnostic( + &f, + 4 * i + 4, + "gs_samplerstate_destroy: called while not in a graphics context", + ); + f.callbacks = false; + } + assert_eq!(f.events, "LLLLLLLL"); +} +#[test] +fn test_samplerstate_lifecycle_null_arguments_in_context() { + let mut f = Fixture { + context: true, + callbacks: true, + ..Fixture::default() + }; + for i in 0..2 { + assert_eq!(core::create(&mut f, None), None); + diagnostic(&f, i + 1, "gs_samplerstate_create: Null 'info' parameter"); + core::destroy(&mut f, None); + diagnostic(&f, i + 1, "gs_samplerstate_create: Null 'info' parameter"); + f.callbacks = false; + } + assert_eq!(f.events, "LL"); +} +#[test] +fn test_samplerstate_lifecycle_creation_forwards_info_and_result() { + let infos = [ + Settings([0, 2, 0, 1, i64::from(i32::MIN), 0]), + Settings([8, 3, 4, 2, i64::from(i32::MAX), i64::from(u32::MAX)]), + ]; + let before = infos; + let mut f = Fixture { + context: true, + callbacks: true, + ..Fixture::default() + }; + for i in 0..3 { + f.expected_info = Some(&infos[i % 2]); + f.result = (i < 2).then_some(i + 1); + let expected = f.result; + assert_eq!(core::create(&mut f, Some(&infos[i % 2])), expected); + assert_eq!(f.calls, [i + 1, 0]); + assert!(f.logs.is_empty()); + assert_eq!(infos, before); + } + assert_eq!(f.events, "CCC"); +} +#[test] +fn test_samplerstate_lifecycle_destruction_forwards_handles_in_order() { + let mut f = Fixture { + context: true, + callbacks: true, + ..Fixture::default() + }; + for i in 0..3 { + f.expected_sampler = i % 2 + 1; + let sampler = f.expected_sampler; + core::destroy(&mut f, Some(sampler)); + assert_eq!(f.calls, [0, i + 1]); + core::destroy(&mut f, None); + assert_eq!(f.calls, [0, i + 1]); + assert!(f.logs.is_empty()); + } + assert_eq!(f.events, "DDD"); +} From f1c48417621917027e3d9a37a6b9c08609a46b97 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Wed, 18 Nov 2026 15:43:08 -0800 Subject: [PATCH 2/3] graphics: swap sampler-state lifecycle to safe Rust (Refs #5149) --- libobs/build/libobs.graphics+.h.c | 2 +- ...orted-graphics-samplerstate-lifecycle+.h.c | 4 + .../graphics-samplerstate-lifecycle.json | 5 + .../obs-graphics-samplerstate_lifecycle.txt | 2 + ...graphics-samplerstate-lifecycle-fields.c.h | 23 ++ .../graphics-samplerstate-lifecycle.c.h | 28 ++- rust/README.md | 1 + rust/obs-build/tests/native.rs | 2 + ...mplerstate_lifecycle_swap_is_registered.rs | 34 +++ .../legacy/graphics-samplerstate-lifecycle.c | 30 +++ ...raphics-samplerstate-lifecycle-fields.list | 1 + .../graphics-samplerstate-lifecycle.list | 1 + .../oracle/samplerstate_lifecycle.c | 165 +++++++++++++ rust/obs-graphics/src/ffi/mod.rs | 1 + .../src/ffi/samplerstate_lifecycle.rs | 56 +++++ .../src/samplerstate_lifecycle.rs | 24 +- rust/obs-graphics/tests/render/main.rs | 1 + .../tests/render/samplerstate_lifecycle.rs | 4 +- .../render/samplerstate_lifecycle_parity.rs | 219 ++++++++++++++++++ ...hics-samplerstate-lifecycle-link-support.c | 2 + ..._samplerstate_lifecycle_link_support.cmake | 22 ++ 21 files changed, 615 insertions(+), 12 deletions(-) create mode 100644 libobs/build/libobs.ported-graphics-samplerstate-lifecycle+.h.c create mode 100644 libobs/build/ported-source-sets/graphics-samplerstate-lifecycle.json create mode 100644 libobs/cmake/rust-exports.d/obs-graphics-samplerstate_lifecycle.txt create mode 100644 libobs/graphics/graphics-samplerstate-lifecycle-fields.c.h create mode 100644 rust/obs-build/tests/native/registration/canonical_graphics_samplerstate_lifecycle_swap_is_registered.rs create mode 100644 rust/obs-c-oracle/legacy/graphics-samplerstate-lifecycle.c create mode 100644 rust/obs-c-oracle/oracle.d/graphics-samplerstate-lifecycle-fields.list create mode 100644 rust/obs-c-oracle/oracle.d/graphics-samplerstate-lifecycle.list create mode 100644 rust/obs-c-oracle/oracle/samplerstate_lifecycle.c create mode 100644 rust/obs-graphics/src/ffi/samplerstate_lifecycle.rs create mode 100644 rust/obs-graphics/tests/render/samplerstate_lifecycle_parity.rs create mode 100644 test/cmocka/graphics-samplerstate-lifecycle-link-support.c create mode 100644 test/cmocka/tests.d/graphics_samplerstate_lifecycle_link_support.cmake diff --git a/libobs/build/libobs.graphics+.h.c b/libobs/build/libobs.graphics+.h.c index 9e18a56843..16706300d2 100644 --- a/libobs/build/libobs.graphics+.h.c +++ b/libobs/build/libobs.graphics+.h.c @@ -10,7 +10,7 @@ #include "libobs/graphics/graphics-imports.c.h" #include "libobs/graphics/graphics-indexbuffer-maintenance-fields.c.h" #include "libobs/graphics/graphics-render-target-setters-fields.c.h" -#include "libobs/graphics/graphics-samplerstate-lifecycle.c.h" +#include "libobs/graphics/graphics-samplerstate-lifecycle-fields.c.h" #include "libobs/graphics/graphics-shader-params-adapter.c.h" #include "libobs/graphics/graphics-target-size-fields.c.h" #include "libobs/graphics/graphics-texture-copy-fields.c.h" diff --git a/libobs/build/libobs.ported-graphics-samplerstate-lifecycle+.h.c b/libobs/build/libobs.ported-graphics-samplerstate-lifecycle+.h.c new file mode 100644 index 0000000000..0471ca1fb5 --- /dev/null +++ b/libobs/build/libobs.ported-graphics-samplerstate-lifecycle+.h.c @@ -0,0 +1,4 @@ +/* Unity group (BUILD.md): original sampler lifecycle for the C reference. */ +#include "libobs/build/libobs-graphics.pch.h" + +#include "libobs/graphics/graphics-samplerstate-lifecycle.c.h" diff --git a/libobs/build/ported-source-sets/graphics-samplerstate-lifecycle.json b/libobs/build/ported-source-sets/graphics-samplerstate-lifecycle.json new file mode 100644 index 0000000000..17075e65d3 --- /dev/null +++ b/libobs/build/ported-source-sets/graphics-samplerstate-lifecycle.json @@ -0,0 +1,5 @@ +{ + "LIBOBS_PORTED_SOURCES": [ + "build/libobs.ported-graphics-samplerstate-lifecycle+.h.c" + ] +} diff --git a/libobs/cmake/rust-exports.d/obs-graphics-samplerstate_lifecycle.txt b/libobs/cmake/rust-exports.d/obs-graphics-samplerstate_lifecycle.txt new file mode 100644 index 0000000000..659ca844f0 --- /dev/null +++ b/libobs/cmake/rust-exports.d/obs-graphics-samplerstate_lifecycle.txt @@ -0,0 +1,2 @@ +gs_samplerstate_create +gs_samplerstate_destroy diff --git a/libobs/graphics/graphics-samplerstate-lifecycle-fields.c.h b/libobs/graphics/graphics-samplerstate-lifecycle-fields.c.h new file mode 100644 index 0000000000..fa37f1727d --- /dev/null +++ b/libobs/graphics/graphics-samplerstate-lifecycle-fields.c.h @@ -0,0 +1,23 @@ +#include "libobs/build/libobs-graphics.pch.h" + +/* Native layout and vtable dispatch only; Rust guards context before access. */ +graphics_t *obs_graphics_samplerstate_context(void); +graphics_t *obs_graphics_samplerstate_context(void) +{ + return gs_get_context(); +} +void obs_graphics_samplerstate_debug(const char *function, const char *reason); +void obs_graphics_samplerstate_debug(const char *function, const char *reason) +{ + blog(LOG_DEBUG, "%s: %s", function, reason); +} +gs_samplerstate_t *obs_graphics_samplerstate_create(graphics_t *graphics, const struct gs_sampler_info *info); +gs_samplerstate_t *obs_graphics_samplerstate_create(graphics_t *graphics, const struct gs_sampler_info *info) +{ + return graphics->exports.device_samplerstate_create(graphics->device, info); +} +void obs_graphics_samplerstate_destroy(graphics_t *graphics, gs_samplerstate_t *samplerstate); +void obs_graphics_samplerstate_destroy(graphics_t *graphics, gs_samplerstate_t *samplerstate) +{ + graphics->exports.gs_samplerstate_destroy(samplerstate); +} diff --git a/libobs/graphics/graphics-samplerstate-lifecycle.c.h b/libobs/graphics/graphics-samplerstate-lifecycle.c.h index 674ab424c4..b6e9d25e75 100644 --- a/libobs/graphics/graphics-samplerstate-lifecycle.c.h +++ b/libobs/graphics/graphics-samplerstate-lifecycle.c.h @@ -1,10 +1,25 @@ #include "libobs/build/libobs-graphics.pch.h" -/* Private dependencies defined in graphics.c.h, later in the unity group. */ -static THREAD_LOCAL graphics_t *thread_graphics; -static inline bool gs_valid(const char *f); -static inline bool gs_obj_valid(const void *obj, const char *f, const char *name); - +/* Reference-only original bodies over the C-owned TLS context getter. */ +#define thread_graphics gs_get_context() +static inline bool samplerstate_ref_valid(const char *f) +{ + if (!thread_graphics) { + blog(LOG_DEBUG, "%s: called while not in a graphics context", f); + return false; + } + return true; +} +static inline bool samplerstate_ref_obj_valid(const void *obj, const char *f, const char *name) +{ + if (!obj) { + blog(LOG_DEBUG, "%s: Null '%s' parameter", f, name); + return false; + } + return true; +} +#define gs_valid samplerstate_ref_valid +#define gs_obj_valid samplerstate_ref_obj_valid #define gs_valid_p(func, param1) (gs_valid(func) && gs_obj_valid(param1, func, #param1)) gs_samplerstate_t *gs_samplerstate_create(const struct gs_sampler_info *info) @@ -28,3 +43,6 @@ void gs_samplerstate_destroy(gs_samplerstate_t *samplerstate) } #undef gs_valid_p +#undef gs_obj_valid +#undef gs_valid +#undef thread_graphics diff --git a/rust/README.md b/rust/README.md index d51a138336..809113aadc 100644 --- a/rust/README.md +++ b/rust/README.md @@ -153,6 +153,7 @@ and compares their exported symbols. `OBS_LIBOBS_BACKEND=C` is temporary rollbac | `libobs/graphics/graphics-device-queries.c.h` | `obs-graphics::device_queries` | Swapped in hybrid `libobs` (Refs #5070; prerequisite #5068). Safe Rust checks context before private C field/dispatch adapters, distinguishes missing context from backend -1/zero, and preserves the optional adapter-count callback fallback and exact diagnostics. Original bodies remain reference-only and in a verbatim legacy oracle. Tier 1 mirrors unchanged `test_graphics_device_queries`; Tier 3 compares signed/unsigned boundaries and bounded random queries through the real adapters in the existing graphics binary. | | `libobs/graphics/graphics-indexbuffer-maintenance.c.h` | `obs-graphics::indexbuffer_maintenance` | Swapped in hybrid `libobs` (#5049; prerequisite #5046, Refs #5039). The four maintenance entry points preserve context-before-pointer guards, silent NULL destroy in context, direct-data rejection order, exact diagnostics, pointer identity and full `size_t` forwarding. Safe Rust owns validation; private C adapters own layout and dispatch. Original C remains in a reference-only group and a verbatim legacy oracle copy. Tier 1 mirrors unchanged `test_graphics_indexbuffer_maintenance`; Tier 3 compares boundary matrices and bounded random inputs through the Rust ABI in the existing Graphics category binary. No intentional differences; Tier 4 does not apply. | | `libobs/graphics/graphics-render-target-setters.c.h` | `obs-graphics::render_target_setters` | Swapped in hybrid `libobs` (#5076; prerequisite #5058 / #5048). Safe Rust guards the context before private C layout/dispatch adapters; both nullable target/depth handles and every cube face value reach the backend unchanged. Exact diagnostics, device/pointer identity and single dispatch are preserved. Original C remains reference-only and in a verbatim legacy oracle. Tier 1 mirrors unchanged `test_graphics_render_target_setters`; Tier 3 compares boundary matrices and bounded random sequences through the Rust ABI in the existing Graphics category binary. No intentional differences; Tier 4 does not apply. | +| `libobs/graphics/graphics-samplerstate-lifecycle.c.h` | `obs-graphics::samplerstate_lifecycle` | Swapped in hybrid `libobs` (Refs #5149; prerequisite #5128/#5148). Safe Rust preserves context-before-argument validation, exact LOG_DEBUG diagnostics, silent NULL destruction in context, settings/opaque-handle identity and backend failure returns. Private C adapters retain TLS, native layouts and exact device-vtable dispatch; sampler objects stay backend-owned without wrapper allocation or tracking. Tier 1 mirrors all four unchanged C characterization cases; Tier 3 compares the original C and real Rust ABI/adapters over boundary and bounded random sequences in the Graphics category. No intentional differences; Tier 4 does not apply. | | `libobs/graphics/graphics-target-size.c.h` | `obs-graphics::target_size` | Swapped in hybrid `libobs` (Refs #5100; prerequisite #5087/#5107). Safe Rust checks context before private C layout/dispatch adapters, preserves zero scalar defaults and untouched outputs without context, and forwards nullable/aliased outputs unchanged. Exact LOG_DEBUG messages, device/output identities and single matching callbacks agree with the reference-only C and verbatim legacy oracle. Tier 1 mirrors unchanged `test_graphics_target_size`; Tier 3 covers boundary and bounded random queries in the existing Graphics category binary. No intentional differences; Tier 4 does not apply. | | `libobs/graphics/graphics-texture-copy.c.h` | `obs-graphics::texture_copy` | Swapped in hybrid `libobs` (Refs #5062; prerequisite #5074/#5059). Safe Rust preserves context-before-pointer validation, whole-copy destination-then-source guards and region-copy destination-only validation, including NULL sources, aliasing and all six unchanged offsets/extents. Private C adapters own layout and backend dispatch. Exact LOG_DEBUG messages, device and texture identity match the reference-only original C and verbatim Tier 3 legacy oracle. Tier 1 mirrors unchanged `test_graphics_texture_copy`; Tier 3 compares boundary matrices and bounded random inputs through the real ABI and adapters in the existing Graphics category binary. No intentional differences; Tier 4 does not apply. | | `libobs/graphics/graphics-viewport.c.h` | `obs-graphics::viewport` | Full-target viewport, pixel-space projection and optional maximum-texture capability policy (#4429). Context validation and backend dispatch remain C; callback zero overrides API fallbacks. Unchanged public-API C characterization, safe-core tests and exact original-C differential traces. No intentional differences. | diff --git a/rust/obs-build/tests/native.rs b/rust/obs-build/tests/native.rs index 04b19d847a..5ec0aebc9e 100644 --- a/rust/obs-build/tests/native.rs +++ b/rust/obs-build/tests/native.rs @@ -11,6 +11,8 @@ mod canonical_graphics_device_queries_swap_is_registered; mod canonical_graphics_indexbuffer_maintenance_swap_is_registered; #[path = "native/registration/canonical_graphics_render_target_setters_swap_is_registered.rs"] mod canonical_graphics_render_target_setters_swap_is_registered; +#[path = "native/registration/canonical_graphics_samplerstate_lifecycle_swap_is_registered.rs"] +mod canonical_graphics_samplerstate_lifecycle_swap_is_registered; #[path = "native/registration/canonical_graphics_target_size_swap_is_registered.rs"] mod canonical_graphics_target_size_swap_is_registered; #[path = "native/registration/canonical_graphics_texture_copy_swap_is_registered.rs"] diff --git a/rust/obs-build/tests/native/registration/canonical_graphics_samplerstate_lifecycle_swap_is_registered.rs b/rust/obs-build/tests/native/registration/canonical_graphics_samplerstate_lifecycle_swap_is_registered.rs new file mode 100644 index 0000000000..e4510a0124 --- /dev/null +++ b/rust/obs-build/tests/native/registration/canonical_graphics_samplerstate_lifecycle_swap_is_registered.rs @@ -0,0 +1,34 @@ +use super::*; + +#[test] +fn canonical_graphics_samplerstate_lifecycle_swap_is_registered() { + use obs_build::validation::graph::{Graph, Source}; + let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../.."); + let mut graph = Graph::load(&root.join("test/cmocka/build/test-graph.json")).unwrap(); + let name = "test_samplerstate_lifecycle"; + graph.targets.retain(|key, _| key == name); + graph.tests.retain(|key, _| key == name); + for os in ["OS_LINUX", "OS_MACOS", "OS_WINDOWS"] { + let selected = graph.select(&[(os.into(), true)].into()).unwrap(); + assert!( + matches!(selected.targets[name].sources.as_slice(), [Source::Path(path)] + if path == "test/cmocka/test_samplerstate_lifecycle.c") + ); + assert_eq!(selected.tests[name].target, name); + } + let ported = fs::read_to_string( + root.join("libobs/build/ported-source-sets/graphics-samplerstate-lifecycle.json"), + ) + .unwrap(); + assert!(ported.contains("build/libobs.ported-graphics-samplerstate-lifecycle+.h.c")); + let group = fs::read_to_string( + root.join("libobs/build/libobs.ported-graphics-samplerstate-lifecycle+.h.c"), + ) + .unwrap(); + assert!(group.contains("#include \"libobs/graphics/graphics-samplerstate-lifecycle.c.h\"")); + let hybrid = fs::read_to_string(root.join("libobs/build/libobs.graphics+.h.c")).unwrap(); + assert!(!hybrid.contains("#include \"libobs/graphics/graphics-samplerstate-lifecycle.c.h\"")); + assert!( + hybrid.contains("#include \"libobs/graphics/graphics-samplerstate-lifecycle-fields.c.h\"") + ); +} diff --git a/rust/obs-c-oracle/legacy/graphics-samplerstate-lifecycle.c b/rust/obs-c-oracle/legacy/graphics-samplerstate-lifecycle.c new file mode 100644 index 0000000000..674ab424c4 --- /dev/null +++ b/rust/obs-c-oracle/legacy/graphics-samplerstate-lifecycle.c @@ -0,0 +1,30 @@ +#include "libobs/build/libobs-graphics.pch.h" + +/* Private dependencies defined in graphics.c.h, later in the unity group. */ +static THREAD_LOCAL graphics_t *thread_graphics; +static inline bool gs_valid(const char *f); +static inline bool gs_obj_valid(const void *obj, const char *f, const char *name); + +#define gs_valid_p(func, param1) (gs_valid(func) && gs_obj_valid(param1, func, #param1)) + +gs_samplerstate_t *gs_samplerstate_create(const struct gs_sampler_info *info) +{ + graphics_t *graphics = thread_graphics; + + if (!gs_valid_p("gs_samplerstate_create", info)) + return NULL; + + return graphics->exports.device_samplerstate_create(graphics->device, info); +} + +void gs_samplerstate_destroy(gs_samplerstate_t *samplerstate) +{ + if (!gs_valid("gs_samplerstate_destroy")) + return; + if (!samplerstate) + return; + + thread_graphics->exports.gs_samplerstate_destroy(samplerstate); +} + +#undef gs_valid_p diff --git a/rust/obs-c-oracle/oracle.d/graphics-samplerstate-lifecycle-fields.list b/rust/obs-c-oracle/oracle.d/graphics-samplerstate-lifecycle-fields.list new file mode 100644 index 0000000000..ff89f92887 --- /dev/null +++ b/rust/obs-c-oracle/oracle.d/graphics-samplerstate-lifecycle-fields.list @@ -0,0 +1 @@ +graphics-samplerstate-lifecycle-fields.inc|libobs/graphics/graphics-samplerstate-lifecycle-fields.c.h|auto diff --git a/rust/obs-c-oracle/oracle.d/graphics-samplerstate-lifecycle.list b/rust/obs-c-oracle/oracle.d/graphics-samplerstate-lifecycle.list new file mode 100644 index 0000000000..9affcd66ea --- /dev/null +++ b/rust/obs-c-oracle/oracle.d/graphics-samplerstate-lifecycle.list @@ -0,0 +1 @@ +graphics-samplerstate-lifecycle.inc|rust/obs-c-oracle/legacy/graphics-samplerstate-lifecycle.c|auto diff --git a/rust/obs-c-oracle/oracle/samplerstate_lifecycle.c b/rust/obs-c-oracle/oracle/samplerstate_lifecycle.c new file mode 100644 index 0000000000..1779f509bd --- /dev/null +++ b/rust/obs-c-oracle/oracle/samplerstate_lifecycle.c @@ -0,0 +1,165 @@ +/* Original C and real adapter over a thread-local recording backend. */ +#include +#include +#include +#include +#define gs_samplerstate_create oracle_gs_samplerstate_create +#define gs_samplerstate_destroy oracle_gs_samplerstate_destroy +#include "graphics/graphics-internal.h" +#include "util/base.h" + +gs_samplerstate_t *oracle_gs_samplerstate_create(const struct gs_sampler_info *info); +void oracle_gs_samplerstate_destroy(gs_samplerstate_t *samplerstate); +static THREAD_LOCAL struct graphics_subsystem sl_graphics; +static THREAD_LOCAL int sl_device, sl_tokens[2]; +static THREAD_LOCAL struct gs_sampler_info sl_infos[2], sl_before[2]; +static THREAD_LOCAL const struct gs_sampler_info *sl_expected_info; +static THREAD_LOCAL gs_samplerstate_t *sl_result, *sl_expected_sampler; +static THREAD_LOCAL unsigned sl_calls[2], sl_logs, sl_event_count; +static THREAD_LOCAL int sl_level; +static THREAD_LOCAL char sl_log[160], sl_events[128]; +static void sl_record(char event) +{ + assert(sl_event_count + 1 < sizeof(sl_events)); + sl_events[sl_event_count++] = event; + sl_events[sl_event_count] = '\0'; +} +#ifdef __GNUC__ +__attribute__((format(printf, 2, 3))) +#endif +static void sl_blog(int level, const char *format, ...) +{ + va_list args; + va_start(args, format); + sl_logs++; + sl_level = level; + vsnprintf(sl_log, sizeof(sl_log), format, args); + va_end(args); + sl_record('L'); +} +#define blog sl_blog +#include "graphics-samplerstate-lifecycle.inc" +/* Original validators from graphics.c.h, verbatim. */ +static inline bool gs_valid(const char *f) +{ + if (!thread_graphics) { + blog(LOG_DEBUG, "%s: called while not in a graphics context", f); + return false; + } + + return true; +} +static inline bool gs_obj_valid(const void *obj, const char *f, const char *name) +{ + if (!obj) { + blog(LOG_DEBUG, "%s: Null '%s' parameter", f, name); + return false; + } + + return true; +} +static graphics_t *sl_context(void) +{ + return thread_graphics; +} +#define gs_get_context sl_context +#include "graphics-samplerstate-lifecycle-fields.inc" +#undef gs_get_context +#undef blog + +static gs_samplerstate_t *sl_create(gs_device_t *device, const struct gs_sampler_info *info) +{ + assert(thread_graphics == &sl_graphics); + assert(device == (gs_device_t *)&sl_device); + assert(info == sl_expected_info); + sl_calls[0]++; + sl_record('C'); + return sl_result; +} +static void sl_destroy(gs_samplerstate_t *sampler) +{ + assert(thread_graphics == &sl_graphics); + assert(sampler == sl_expected_sampler); + sl_calls[1]++; + sl_record('D'); +} +void oracle_samplerstate_reset(void); +void oracle_samplerstate_reset(void) +{ + memset(&sl_graphics, 0, sizeof(sl_graphics)); + sl_graphics.device = (gs_device_t *)&sl_device; + memset(sl_infos, 0, sizeof(sl_infos)); + memset(sl_before, 0, sizeof(sl_before)); + memset(sl_calls, 0, sizeof(sl_calls)); + sl_logs = sl_event_count = 0; + sl_level = 0; + sl_log[0] = sl_events[0] = '\0'; + thread_graphics = NULL; +} +const struct gs_sampler_info *oracle_samplerstate_info(unsigned slot, unsigned filter, unsigned u, unsigned v, + unsigned w, int anisotropy, uint32_t border); +const struct gs_sampler_info *oracle_samplerstate_info(unsigned slot, unsigned filter, unsigned u, unsigned v, + unsigned w, int anisotropy, uint32_t border) +{ + assert(slot < 2 && filter <= GS_FILTER_MIN_MAG_LINEAR_MIP_POINT); + assert(u <= GS_ADDRESS_MIRRORONCE && v <= GS_ADDRESS_MIRRORONCE && w <= GS_ADDRESS_MIRRORONCE); + sl_infos[slot] = (struct gs_sampler_info){(enum gs_sample_filter)filter, + (enum gs_address_mode)u, + (enum gs_address_mode)v, + (enum gs_address_mode)w, + anisotropy, + border}; + memcpy(&sl_before[slot], &sl_infos[slot], sizeof(sl_infos[slot])); + return &sl_infos[slot]; +} +gs_samplerstate_t *oracle_samplerstate_token(unsigned slot); +gs_samplerstate_t *oracle_samplerstate_token(unsigned slot) +{ + assert(slot < 2); + return (gs_samplerstate_t *)&sl_tokens[slot]; +} +void oracle_samplerstate_configure(bool context, unsigned callbacks, const struct gs_sampler_info *info, + gs_samplerstate_t *result, gs_samplerstate_t *sampler); +void oracle_samplerstate_configure(bool context, unsigned callbacks, const struct gs_sampler_info *info, + gs_samplerstate_t *result, gs_samplerstate_t *sampler) +{ + thread_graphics = context ? &sl_graphics : NULL; + sl_graphics.exports.device_samplerstate_create = (callbacks & 1) ? sl_create : NULL; + sl_graphics.exports.gs_samplerstate_destroy = (callbacks & 2) ? sl_destroy : NULL; + sl_expected_info = info; + sl_result = result; + sl_expected_sampler = sampler; +} +unsigned oracle_samplerstate_calls(unsigned index); +unsigned oracle_samplerstate_calls(unsigned index) +{ + assert(index < 2); + return sl_calls[index]; +} +unsigned oracle_samplerstate_logs(void); +unsigned oracle_samplerstate_logs(void) +{ + return sl_logs; +} +int oracle_samplerstate_level(void); +int oracle_samplerstate_level(void) +{ + return sl_level; +} +const char *oracle_samplerstate_log(void); +const char *oracle_samplerstate_log(void) +{ + return sl_log; +} +const char *oracle_samplerstate_events(void); +const char *oracle_samplerstate_events(void) +{ + return sl_events; +} +bool oracle_samplerstate_unchanged(void); +bool oracle_samplerstate_unchanged(void) +{ + return memcmp(sl_infos, sl_before, sizeof(sl_infos)) == 0; +} +#undef gs_samplerstate_create +#undef gs_samplerstate_destroy diff --git a/rust/obs-graphics/src/ffi/mod.rs b/rust/obs-graphics/src/ffi/mod.rs index 5e62a1db39..b505f4b116 100644 --- a/rust/obs-graphics/src/ffi/mod.rs +++ b/rust/obs-graphics/src/ffi/mod.rs @@ -44,6 +44,7 @@ pub mod present_entrypoints; pub mod quat; pub mod raster_entrypoints; pub mod render_target_setters; +pub mod samplerstate_lifecycle; pub mod shader_file; pub mod shader_param_introspection; pub mod shader_param_names; diff --git a/rust/obs-graphics/src/ffi/samplerstate_lifecycle.rs b/rust/obs-graphics/src/ffi/samplerstate_lifecycle.rs new file mode 100644 index 0000000000..1e1677e462 --- /dev/null +++ b/rust/obs-graphics/src/ffi/samplerstate_lifecycle.rs @@ -0,0 +1,56 @@ +//! Thin lifecycle ABI; C owns graphics layouts, TLS and device objects. +use crate::samplerstate_lifecycle::{self as core, Entry, Host, Rejection}; +use std::ffi::{c_char, c_void}; +use std::ptr; + +unsafe extern "C" { + fn obs_graphics_samplerstate_context() -> *mut c_void; + fn obs_graphics_samplerstate_debug(function: *const c_char, reason: *const c_char); + fn obs_graphics_samplerstate_create(context: *mut c_void, info: *const c_void) -> *mut c_void; + fn obs_graphics_samplerstate_destroy(context: *mut c_void, sampler: *mut c_void); +} +struct Context(*mut c_void); +fn current() -> Context { + // SAFETY: reads the calling thread's opaque context without dereferencing it. + Context(unsafe { obs_graphics_samplerstate_context() }) +} +impl Host for Context { + type Info = *const c_void; + type Sampler = *mut c_void; + fn has_context(&self) -> bool { + !self.0.is_null() + } + fn debug(&mut self, entry: Entry, reason: Rejection) { + // SAFETY: both strings are static and NUL-terminated. + unsafe { + obs_graphics_samplerstate_debug(entry.c_name().as_ptr(), reason.message().as_ptr()) + } + } + fn create(&mut self, info: *const c_void) -> Option<*mut c_void> { + // SAFETY: the safe core checked context and info before C field access. + // The caller supplies backend-compatible settings, forwarded unchanged. + let result = unsafe { obs_graphics_samplerstate_create(self.0, info) }; + (!result.is_null()).then_some(result) + } + fn destroy(&mut self, sampler: *mut c_void) { + // SAFETY: the safe core checked context and sampler before field access. + // Ownership and validity remain the backend/caller's contract. + unsafe { obs_graphics_samplerstate_destroy(self.0, sampler) } + } +} +/// Forward settings to the current device without copying or allocating. +/// # Safety +/// A live context must provide the required backend callback. Non-NULL info +/// must satisfy that backend's contract; the returned sampler remains backend-owned. +#[unsafe(no_mangle)] +pub unsafe extern "C" fn gs_samplerstate_create(info: *const c_void) -> *mut c_void { + core::create(&mut current(), (!info.is_null()).then_some(info)).unwrap_or(ptr::null_mut()) +} +/// Forward a sampler to the current backend without wrapper-side tracking. +/// # Safety +/// A live context must provide the required callback. A non-NULL sampler must +/// satisfy the backend's destruction contract. +#[unsafe(no_mangle)] +pub unsafe extern "C" fn gs_samplerstate_destroy(sampler: *mut c_void) { + core::destroy(&mut current(), (!sampler.is_null()).then_some(sampler)); +} diff --git a/rust/obs-graphics/src/samplerstate_lifecycle.rs b/rust/obs-graphics/src/samplerstate_lifecycle.rs index 37b8d345c3..cef2dcdd33 100644 --- a/rust/obs-graphics/src/samplerstate_lifecycle.rs +++ b/rust/obs-graphics/src/samplerstate_lifecycle.rs @@ -42,9 +42,25 @@ pub trait Host { fn create(&mut self, info: Self::Info) -> Option; fn destroy(&mut self, sampler: Self::Sampler); } -pub fn create(_host: &mut H, _info: Option) -> Option { - todo!() +pub fn create(host: &mut H, info: Option) -> Option { + if !host.has_context() { + host.debug(Entry::Create, Rejection::Context); + return None; + } + match info { + Some(info) => host.create(info), + None => { + host.debug(Entry::Create, Rejection::Info); + None + } + } } -pub fn destroy(_host: &mut H, _sampler: Option) { - todo!() +pub fn destroy(host: &mut H, sampler: Option) { + if !host.has_context() { + host.debug(Entry::Destroy, Rejection::Context); + return; + } + if let Some(sampler) = sampler { + host.destroy(sampler); + } } diff --git a/rust/obs-graphics/tests/render/main.rs b/rust/obs-graphics/tests/render/main.rs index c029947c56..98542a647a 100644 --- a/rust/obs-graphics/tests/render/main.rs +++ b/rust/obs-graphics/tests/render/main.rs @@ -58,6 +58,7 @@ mod raster_entrypoints_parity; mod render_target_setters; mod render_target_setters_parity; mod samplerstate_lifecycle; +mod samplerstate_lifecycle_parity; mod sprite; mod sprite_parity; mod state_stacks; diff --git a/rust/obs-graphics/tests/render/samplerstate_lifecycle.rs b/rust/obs-graphics/tests/render/samplerstate_lifecycle.rs index 82517bb060..5434ebafa3 100644 --- a/rust/obs-graphics/tests/render/samplerstate_lifecycle.rs +++ b/rust/obs-graphics/tests/render/samplerstate_lifecycle.rs @@ -101,8 +101,8 @@ fn test_samplerstate_lifecycle_null_arguments_in_context() { #[test] fn test_samplerstate_lifecycle_creation_forwards_info_and_result() { let infos = [ - Settings([0, 2, 0, 1, i64::from(i32::MIN), 0]), - Settings([8, 3, 4, 2, i64::from(i32::MAX), i64::from(u32::MAX)]), + Settings([0, 0, 1, 2, i64::from(i32::MIN), 0]), + Settings([2, 3, 4, 0, i64::from(i32::MAX), i64::from(u32::MAX)]), ]; let before = infos; let mut f = Fixture { diff --git a/rust/obs-graphics/tests/render/samplerstate_lifecycle_parity.rs b/rust/obs-graphics/tests/render/samplerstate_lifecycle_parity.rs new file mode 100644 index 0000000000..95e434da95 --- /dev/null +++ b/rust/obs-graphics/tests/render/samplerstate_lifecycle_parity.rs @@ -0,0 +1,219 @@ +//! Tier 3: original C vs production Rust ABI and real adapters. No differences. +//! Missing callbacks are generated only when validation prevents their use; +//! calling an absent required callback is undefined in the original C. +use obs_c_oracle as _; +use obs_graphics::ffi::samplerstate_lifecycle as rust; +use proptest::prelude::*; +use std::ffi::{CStr, c_char, c_void}; +use std::ptr; + +unsafe extern "C" { + fn oracle_gs_samplerstate_create(info: *const c_void) -> *mut c_void; + fn oracle_gs_samplerstate_destroy(sampler: *mut c_void); + fn oracle_samplerstate_reset(); + fn oracle_samplerstate_info( + slot: u32, + filter: u32, + u: u32, + v: u32, + w: u32, + anisotropy: i32, + border: u32, + ) -> *const c_void; + fn oracle_samplerstate_token(slot: u32) -> *mut c_void; + fn oracle_samplerstate_configure( + context: bool, + callbacks: u32, + info: *const c_void, + result: *mut c_void, + sampler: *mut c_void, + ); + fn oracle_samplerstate_calls(index: u32) -> u32; + fn oracle_samplerstate_logs() -> u32; + fn oracle_samplerstate_level() -> i32; + fn oracle_samplerstate_log() -> *const c_char; + fn oracle_samplerstate_events() -> *const c_char; + fn oracle_samplerstate_unchanged() -> bool; +} +#[derive(Clone, Debug)] +struct Step { + context: bool, + callbacks: u32, + destroy: bool, + info: Option, + sampler: Option, + result: Option, + settings: (u32, u32, u32, u32, i32, u32), +} +#[derive(Debug, PartialEq, Eq)] +struct Observed { + result: Option, + calls: [u32; 2], + logs: u32, + level: i32, + message: Vec, + events: Vec, + unchanged: bool, +} +fn run(ported: bool, steps: &[Step]) -> Vec { + // SAFETY: all recording state and adapters use fixture-local TLS. Settings, + // device and opaque token pointers remain live; no callback frees a token. + // Required callbacks are installed for every reachable dispatch. C owns + // the settings layout; Rust forwards only pointers returned by the fixture. + unsafe { + oracle_samplerstate_reset(); + let tokens = [oracle_samplerstate_token(0), oracle_samplerstate_token(1)]; + steps + .iter() + .map(|s| { + let (f, u, v, w, a, b) = s.settings; + let info = s.info.map_or(ptr::null(), |i| { + oracle_samplerstate_info(i, f, u, v, w, a, b) + }); + let sampler = s.sampler.map_or(ptr::null_mut(), |i| tokens[i as usize]); + let result = s.result.map_or(ptr::null_mut(), |i| tokens[i as usize]); + let required = if s.context { + if s.destroy { + u32::from(s.sampler.is_some()) * 2 + } else { + u32::from(s.info.is_some()) + } + } else { + 0 + }; + oracle_samplerstate_configure( + s.context, + s.callbacks | required, + info, + result, + sampler, + ); + let returned = match (ported, s.destroy) { + (true, false) => rust::gs_samplerstate_create(info), + (false, false) => oracle_gs_samplerstate_create(info), + (true, true) => { + rust::gs_samplerstate_destroy(sampler); + ptr::null_mut() + } + (false, true) => { + oracle_gs_samplerstate_destroy(sampler); + ptr::null_mut() + } + }; + let result = if returned.is_null() { + None + } else { + Some( + u32::try_from( + tokens + .iter() + .position(|&p| p == returned) + .expect("original handle identity"), + ) + .unwrap(), + ) + }; + Observed { + result, + calls: [oracle_samplerstate_calls(0), oracle_samplerstate_calls(1)], + logs: oracle_samplerstate_logs(), + level: oracle_samplerstate_level(), + message: CStr::from_ptr(oracle_samplerstate_log()) + .to_bytes() + .to_vec(), + events: CStr::from_ptr(oracle_samplerstate_events()) + .to_bytes() + .to_vec(), + unchanged: oracle_samplerstate_unchanged(), + } + }) + .collect() + } +} +fn compare(steps: &[Step]) { + let original = run(false, steps); + let ported = run(true, steps); + assert_eq!(ported, original, "{steps:?}"); + let mut calls = [0, 0]; + let mut logs = 0; + let mut message = Vec::new(); + let mut events = Vec::new(); + for (s, observed) in steps.iter().zip(ported) { + let mut result = None; + let diagnostic = if !s.context { + Some(format!( + "gs_samplerstate_{}: called while not in a graphics context", + if s.destroy { "destroy" } else { "create" } + )) + } else if !s.destroy && s.info.is_none() { + Some("gs_samplerstate_create: Null 'info' parameter".into()) + } else { + None + }; + if let Some(diagnostic) = diagnostic { + logs += 1; + message = diagnostic.into_bytes(); + events.push(b'L'); + } else if !s.destroy { + calls[0] += 1; + events.push(b'C'); + result = s.result; + } else if s.sampler.is_some() { + calls[1] += 1; + events.push(b'D'); + } + assert_eq!( + observed, + Observed { + result, + calls, + logs, + level: if logs == 0 { 0 } else { 400 }, + message: message.clone(), + events: events.clone(), + unchanged: true + } + ); + } +} +#[test] +fn characterized_sequences_match_c() { + for context in [false, true] { + for callbacks in 0..4 { + let mut steps = Vec::new(); + for i in 0..3 { + for (destroy, info, sampler) in [ + (false, Some(i % 2), None), + (false, None, None), + (true, None, Some(i % 2)), + (true, None, None), + ] { + steps.push(Step { + context, + callbacks, + destroy, + info, + sampler, + result: if i < 2 { Some(i) } else { None }, + settings: if i % 2 == 0 { + (0, 0, 1, 2, i32::MIN, 0) + } else { + (2, 3, 4, 0, i32::MAX, u32::MAX) + }, + }); + } + } + compare(&steps); + } + } +} +proptest! { + #![proptest_config(ProptestConfig { cases: obs_c_oracle::parity::cases(128), failure_persistence: None, ..ProptestConfig::default() })] + #[test] + fn random_sequences_match_c(steps in prop::collection::vec( + (any::(),0u32..4,any::(),prop::option::of(0u32..2),prop::option::of(0u32..2),prop::option::of(0u32..2), + (0u32..9,0u32..5,0u32..5,0u32..5,any::(),any::())),1..=16)) { + let steps: Vec<_> = steps.into_iter().map(|(context,callbacks,destroy,info,sampler,result,settings)| Step {context,callbacks,destroy,info,sampler,result,settings}).collect(); + compare(&steps); + } +} diff --git a/test/cmocka/graphics-samplerstate-lifecycle-link-support.c b/test/cmocka/graphics-samplerstate-lifecycle-link-support.c new file mode 100644 index 0000000000..2d46c4fef5 --- /dev/null +++ b/test/cmocka/graphics-samplerstate-lifecycle-link-support.c @@ -0,0 +1,2 @@ +/* Real private adapter for standalone consumers of libobs_rust-static. */ +#include "libobs/graphics/graphics-samplerstate-lifecycle-fields.c.h" diff --git a/test/cmocka/tests.d/graphics_samplerstate_lifecycle_link_support.cmake b/test/cmocka/tests.d/graphics_samplerstate_lifecycle_link_support.cmake new file mode 100644 index 0000000000..e4b63d4c89 --- /dev/null +++ b/test/cmocka/tests.d/graphics_samplerstate_lifecycle_link_support.cmake @@ -0,0 +1,22 @@ +# Keep the real private adapter available to standalone Rust-static tests. +function(_graphics_samplerstate_lifecycle_link_support) + get_directory_property(_targets BUILDSYSTEM_TARGETS) + foreach(_target IN LISTS _targets) + get_target_property(_links ${_target} LINK_LIBRARIES) + if(_target MATCHES "^test_" AND "libobs_rust-static" IN_LIST _links) + if(NOT TARGET obs-graphics-samplerstate-lifecycle-link-support) + add_library(obs-graphics-samplerstate-lifecycle-link-support STATIC graphics-samplerstate-lifecycle-link-support.c) + target_include_directories( + obs-graphics-samplerstate-lifecycle-link-support + PRIVATE "${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/libobs" + ) + target_link_libraries( + obs-graphics-samplerstate-lifecycle-link-support + PRIVATE SIMDe::SIMDe Uthash::Uthash "$<$:OBS::w32-pthreads>" + ) + endif() + target_link_libraries(${_target} PRIVATE obs-graphics-samplerstate-lifecycle-link-support) + endif() + endforeach() +endfunction() +cmake_language(DEFER CALL _graphics_samplerstate_lifecycle_link_support) From da40526f12cf99dd3c5b71e6578b2e416a1fd2b1 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Wed, 18 Nov 2026 15:58:27 -0800 Subject: [PATCH 3/3] style: format sampler lifecycle link support (Refs #5149) Ci-Attestation: {"at":1795046856,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["f1c48417621917027e3d9a37a6b9c08609a46b97"],"secs":121,"stamp":"d247439b8ed910f8e6c9f24a6299ca2d","tree":"313297da473b6297e42dc1fe66377f30f5867013","v":1,"via":"run"} Ci-Attestation: {"at":1795046856,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["f1c48417621917027e3d9a37a6b9c08609a46b97"],"secs":121,"stamp":"0d219066239e9eeb088c62ae93a55e60","tree":"313297da473b6297e42dc1fe66377f30f5867013","v":1,"via":"run"} Ci-Attestation: {"at":1795046856,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["f1c48417621917027e3d9a37a6b9c08609a46b97"],"secs":121,"stamp":"80b49d57777994b86a7a62c3527412cc","tree":"313297da473b6297e42dc1fe66377f30f5867013","v":1,"via":"run"} Ci-Attestation: {"at":1795046856,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["f1c48417621917027e3d9a37a6b9c08609a46b97"],"secs":121,"stamp":"8d65bc32bdc82f982bdbedf8f7263f01","tree":"313297da473b6297e42dc1fe66377f30f5867013","v":1,"via":"run"} Ci-Attestation: {"at":1795046733,"gate":"general/all/client-lint","host":"linux-x86_64","key":"ad1dcd741d5434b667e0689bd45ca7fe622e9af2720c4cfdbbbaf5bbe84cae30","lane":"client-lint","parents":["f1c48417621917027e3d9a37a6b9c08609a46b97"],"secs":397,"stamp":"c473ef75e5da7ecf0a699efd285e19a9","tree":"313297da473b6297e42dc1fe66377f30f5867013","v":1,"via":"run"} Ci-Attestation: {"at":1795046856,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["f1c48417621917027e3d9a37a6b9c08609a46b97"],"secs":121,"stamp":"75c2383ce13096a07ffe0d92959418de","tree":"313297da473b6297e42dc1fe66377f30f5867013","v":1,"via":"run"} Ci-Attestation: {"at":1795046734,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"ad1dcd741d5434b667e0689bd45ca7fe622e9af2720c4cfdbbbaf5bbe84cae30","lane":"client-lint","parents":["f1c48417621917027e3d9a37a6b9c08609a46b97"],"secs":397,"stamp":"fef7e09df0456b1760c66a97eca0d481","tree":"313297da473b6297e42dc1fe66377f30f5867013","v":1,"via":"run"} Ci-Attestation: {"at":1795046734,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"ad1dcd741d5434b667e0689bd45ca7fe622e9af2720c4cfdbbbaf5bbe84cae30","lane":"client-lint","parents":["f1c48417621917027e3d9a37a6b9c08609a46b97"],"secs":397,"stamp":"7797a0d5119443f73a3da8c63c463de0","tree":"313297da473b6297e42dc1fe66377f30f5867013","v":1,"via":"run"} Ci-Attestation: {"at":1795046733,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"ad1dcd741d5434b667e0689bd45ca7fe622e9af2720c4cfdbbbaf5bbe84cae30","lane":"client-lint","parents":["f1c48417621917027e3d9a37a6b9c08609a46b97"],"secs":397,"stamp":"374f86bb63815bd6b083b725641f6db5","tree":"313297da473b6297e42dc1fe66377f30f5867013","v":1,"via":"run"} Ci-Attestation: {"at":1795046733,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"ad1dcd741d5434b667e0689bd45ca7fe622e9af2720c4cfdbbbaf5bbe84cae30","lane":"client-lint","parents":["f1c48417621917027e3d9a37a6b9c08609a46b97"],"secs":397,"stamp":"265aef823c826d7013cf31c157c74dcf","tree":"313297da473b6297e42dc1fe66377f30f5867013","v":1,"via":"run"} Ci-Attestation: {"at":1795046733,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"ad1dcd741d5434b667e0689bd45ca7fe622e9af2720c4cfdbbbaf5bbe84cae30","lane":"client-lint","parents":["f1c48417621917027e3d9a37a6b9c08609a46b97"],"secs":397,"stamp":"a76ad6314afef6670853f2204e3e5591","tree":"313297da473b6297e42dc1fe66377f30f5867013","v":1,"via":"run"} Ci-Attestation: {"at":1795046733,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"ad1dcd741d5434b667e0689bd45ca7fe622e9af2720c4cfdbbbaf5bbe84cae30","lane":"client-lint","parents":["f1c48417621917027e3d9a37a6b9c08609a46b97"],"secs":397,"stamp":"ae1be01d9ea7a4b74055e83aae29fc9c","tree":"313297da473b6297e42dc1fe66377f30f5867013","v":1,"via":"run"} Ci-Attestation: {"at":1795046733,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"ad1dcd741d5434b667e0689bd45ca7fe622e9af2720c4cfdbbbaf5bbe84cae30","lane":"client-lint","parents":["f1c48417621917027e3d9a37a6b9c08609a46b97"],"secs":397,"stamp":"fcca1552dfedeacf9b6a5313853208b1","tree":"313297da473b6297e42dc1fe66377f30f5867013","v":1,"via":"run"} Ci-Attestation: {"at":1795046734,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"ad1dcd741d5434b667e0689bd45ca7fe622e9af2720c4cfdbbbaf5bbe84cae30","lane":"client-lint","parents":["f1c48417621917027e3d9a37a6b9c08609a46b97"],"secs":397,"stamp":"1fa52d452125b5bc922d4c79c30e241f","tree":"313297da473b6297e42dc1fe66377f30f5867013","v":1,"via":"run"} Ci-Attestation: {"at":1795046733,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"ad1dcd741d5434b667e0689bd45ca7fe622e9af2720c4cfdbbbaf5bbe84cae30","lane":"client-lint","parents":["f1c48417621917027e3d9a37a6b9c08609a46b97"],"secs":397,"stamp":"37db4011745b16d3fa43c660351a1359","tree":"313297da473b6297e42dc1fe66377f30f5867013","v":1,"via":"run"} Ci-Attestation: {"at":1795046733,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"ad1dcd741d5434b667e0689bd45ca7fe622e9af2720c4cfdbbbaf5bbe84cae30","lane":"client-lint","parents":["f1c48417621917027e3d9a37a6b9c08609a46b97"],"secs":397,"stamp":"7ce67c9acef94c8437e15f98043e5c60","tree":"313297da473b6297e42dc1fe66377f30f5867013","v":1,"via":"run"} Ci-Attestation: {"at":1795046733,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"ad1dcd741d5434b667e0689bd45ca7fe622e9af2720c4cfdbbbaf5bbe84cae30","lane":"client-lint","parents":["f1c48417621917027e3d9a37a6b9c08609a46b97"],"secs":397,"stamp":"5186d9373dd05976187795ff0c46f1c4","tree":"313297da473b6297e42dc1fe66377f30f5867013","v":1,"via":"run"} Ci-Attestation: {"at":1795046733,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"ad1dcd741d5434b667e0689bd45ca7fe622e9af2720c4cfdbbbaf5bbe84cae30","lane":"client-lint","parents":["f1c48417621917027e3d9a37a6b9c08609a46b97"],"secs":397,"stamp":"a155e4f83520444eb3ac6bab4d0ba064","tree":"313297da473b6297e42dc1fe66377f30f5867013","v":1,"via":"run"} Ci-Attestation: {"at":1795047359,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"2092fee471980e3cd09e0572bfd536d1b594c65767d6b227134966d48146ce20","lane":"client-test-x86_64-unknown-linux-gnu","parents":["f1c48417621917027e3d9a37a6b9c08609a46b97"],"secs":502,"stamp":"0d174f2e84525c857936e638f31fe9b2","tree":"313297da473b6297e42dc1fe66377f30f5867013","v":1,"via":"run"} Client-Checks: {"checks":{"base":"a62bfe717d5d9610a5136ca211273e66a1ae1f84","coverage":"all-tracked-applicable-files","diff":["libobs/build/libobs.graphics+.h.c","libobs/build/libobs.ported-graphics-samplerstate-lifecycle+.h.c","libobs/build/ported-source-sets/graphics-samplerstate-lifecycle.json","libobs/cmake/rust-exports.d/obs-graphics-samplerstate_lifecycle.txt","libobs/graphics/graphics-samplerstate-lifecycle-fields.c.h","libobs/graphics/graphics-samplerstate-lifecycle.c.h","rust/README.md","rust/obs-build/tests/native.rs","rust/obs-build/tests/native/registration/canonical_graphics_samplerstate_lifecycle_swap_is_registered.rs","rust/obs-c-oracle/legacy/graphics-samplerstate-lifecycle.c","rust/obs-c-oracle/oracle.d/graphics-samplerstate-lifecycle-fields.list","rust/obs-c-oracle/oracle.d/graphics-samplerstate-lifecycle.list","rust/obs-c-oracle/oracle/samplerstate_lifecycle.c","rust/obs-graphics/src/ffi/mod.rs","rust/obs-graphics/src/ffi/samplerstate_lifecycle.rs","rust/obs-graphics/src/lib.rs","rust/obs-graphics/src/samplerstate_lifecycle.rs","rust/obs-graphics/tests/render/main.rs","rust/obs-graphics/tests/render/samplerstate_lifecycle.rs","rust/obs-graphics/tests/render/samplerstate_lifecycle_parity.rs","test/cmocka/graphics-samplerstate-lifecycle-link-support.c","test/cmocka/tests.d/graphics_samplerstate_lifecycle_link_support.cmake"],"head":"4f0ed04f13377f1373c6313167f25dd77b45dc75","tools":{"orchestrator-python":"3.13.15 (main, Aug 14 2026, 15:34:59) [Clang 22.1.3 ]","schema-dependencies":"3.13.15 (main, Aug 14 2026, 15:34:59) [Clang 22.1.3 ]\n{'jsonschema': '4.26.0', 'json_source_map': '1.0.5'}","uv":"uv 0.13.5 (x86_64-unknown-linux-gnu)","xmllint":"xmllint: using libxml version 21504\n compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 DTDValid HTML C14N Catalog XPath XPointer XInclude Iconv ISO8859X Regexps Automata RelaxNG Schemas Modules Debug"},"tracked-digest":"77062ab89dbcd9a7a0913ffc97988a85a5b7bbc3febbceb06dc682abf4143288","tree":"313297da473b6297e42dc1fe66377f30f5867013"}} --- .../graphics_samplerstate_lifecycle_link_support.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/cmocka/tests.d/graphics_samplerstate_lifecycle_link_support.cmake b/test/cmocka/tests.d/graphics_samplerstate_lifecycle_link_support.cmake index e4b63d4c89..0d99b6599e 100644 --- a/test/cmocka/tests.d/graphics_samplerstate_lifecycle_link_support.cmake +++ b/test/cmocka/tests.d/graphics_samplerstate_lifecycle_link_support.cmake @@ -5,7 +5,11 @@ function(_graphics_samplerstate_lifecycle_link_support) get_target_property(_links ${_target} LINK_LIBRARIES) if(_target MATCHES "^test_" AND "libobs_rust-static" IN_LIST _links) if(NOT TARGET obs-graphics-samplerstate-lifecycle-link-support) - add_library(obs-graphics-samplerstate-lifecycle-link-support STATIC graphics-samplerstate-lifecycle-link-support.c) + add_library( + obs-graphics-samplerstate-lifecycle-link-support + STATIC + graphics-samplerstate-lifecycle-link-support.c + ) target_include_directories( obs-graphics-samplerstate-lifecycle-link-support PRIVATE "${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/libobs"