Repository navigation
obs-graphics: Port graphics/image-file.c.h - #1911
Merged
Merged
Conversation
10 tasks done
test_image_file loads GIF and PNG fixtures (data/image-file.py writes them) through the exported gs_image_file_ex_* on a hand-built graphics_t with a fake device, as test_texture_render does: fields after load, failing paths and their log lines, bnum_allocs, the texture created, tick timing across frames and loop counts, frame updates and alpha modes. No GPU. Refs #1907
Tier 1 mirror of test_image_file.c through a safe core whose bodies are todo!(): ImageFileEx (struct gs_image_file_ex over a Host trait's handles) and the timing, premultiply and format helpers. All 14 cases fail. Refs #1907
gs_image_file_ex_* now live in obs-graphics. The safe core drives libnsgif, the file read, the allocator, gs_create_texture_file_data3 and the gs_texture_* calls through a Host trait in the C order; the shim implements it with the real functions, which stay C. struct gs_image_file_ex keeps its layout; the internal block and every buffer are bmalloc blocks, so bnum_allocs counts them as before. image-file.c.h moves to the ported graphics group, so hybrid libobs no longer compiles it and the C reference still does. test_effect_parser_lifecycle_rust links the production Rust staticlib directly; its obs-graphics object now calls libnsgif, which libobs does not export, so that executable compiles the vendored libnsgif group too. Refs #1907
The original image-file.c.h is built as oracle_gs_image_file_ex_*, and the oracle crate builds the vendored libnsgif both sides call. The recording gs_* stand-in also stands in for gs_create_texture_file_data3 and gs_texture_set_image, hashes the pixels it is given and logs libobs log lines. A proptest over tick/update/texture-init sequences on every fixture and alpha mode compares that log, every return value, every public field and bnum_allocs after each step. Layout test for struct gs_image_file_ex. Refs #1907
Adds the rust/README.md row and two port_comparison pairs on the animated fixture: a tick plus texture update, and load, texture init and free. Fixes #1907
…y name Tier 2 ON: null_file_test memcmps the image against zero after init and free, padding included; the shim now zeroes the whole struct where the C memsets it. Windows: test_effect_parser_lifecycle_rust links the staticlib next to obs.lib; calling bmalloc/bfree/os_fopen/os_ftelli64 through obs-util's Rust paths pulled obs-util objects that clash with obs.lib (LNK2005), so the shim declares them extern like the other libobs functions it calls. Refs #1907
test_effect_parser_lifecycle_rust links the staticlib next to obs.lib. The obs-graphics objects it pulls for ep_free now also hold image-file, whose Vec/format!/expect reached the Rust allocator, std and from there obs-util objects that clash with obs.lib on Windows (LNK2005). Log lines are built in a stack buffer and the impossible branches return instead of panicking. Checked on the x86_64-pc-windows-msvc staticlib: the members the test pulls reach neither core, std nor obs-util. Refs #1907
… C adapters test_effect_parser_lifecycle_rust links the Rust staticlib next to libobs. On Windows, once ep_free pulls an obs-graphics object, link.exe resolves that object's bmalloc/bfree from the same staticlib, which drags in obs-util and clashes with libobs's exports (LNK2005, LNK2019). Adding image-file moved gs_texrender_* and gs_image_file_ex_* into the CGU that ep_free pulls. obs-graphics now names no obs-util symbol: it calls private C adapters in libobs/graphics/obs-graphics-adapter.c.h (the graphics unity group; the test compiles its own copy, and the oracle copies it verbatim), so the closure from ep_free stays inside obs-graphics.
zackees
force-pushed
the
port/image-file
branch
from
October 23, 2026 09:03
dcaede1 to
137d52c
Compare
zackees
marked this pull request as ready for review
October 23, 2026 09:35
5 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 #1907
Refs #1846 (unit 6)
Ports
libobs/graphics/image-file.c.h(gs_image_file_ex_*) toobs-graphics.Commits
test: Characterize gs_image_file_ex before its port:test/cmocka/test_image_file.c(10 cases) with GIF/PNG fixtures intest/cmocka/data/(written byimage-file.py, uv + Pillow). Fake device on a hand-builtgraphics_t, astest_texture_render. Ran locally in Tier 2 against the C build: passes.obs-graphics: Port the image-file cases against stubs: Tier 1 mirror inobs-tests-graphics(tests/render/image_file.rs) againsttodo!()bodies. Result:test result: FAILED. 0 passed; 14 failed(each panics atnot yet implemented).obs-graphics: Port graphics/image-file.c.h: safe core over aHosttrait (libnsgif, file read, bmalloc,gs_create_texture_file_data3,gs_texture_*, log) +#[no_mangle]shim;ImageFileEx<GsHost>isstruct gs_image_file_ex. File moves tolibobs.ported-graphics+.h.c; export fragmentobs-graphics-image_file.txt.test_effect_parser_lifecycle_rustlinks the Rust staticlib directly; its obs-graphics object now references libnsgif, which libobs.so does not export, so that executable also compileslibobs.nsgif+.h.c(cmake only; the C test is unchanged).obs-graphics: Compare image-file with the original C: original built asoracle_gs_image_file_ex_*; oracle crate builds libnsgif; recording stand-in extended withgs_create_texture_file_data3,gs_texture_set_image, pixel hashes and log capture. Proptest (512 cases + every file × alpha-mode walk) compares call/log stream, return values, every public field andbnum_allocsper step. Layout test forstruct gs_image_file_ex.Mutation check: changing the zero-delay frame time to 100 ms + 1 ns made
image_file_matches_original_cfail (first diff at the frame-1 tick).port_comparisonbench.Results (local)
soldr cargo test -p obs-graphics --test obs-tests-graphics: 262 passed../lint: clean.native_test_graph_replaces: passes (test is in tests.d only, liketest_texture_render; no count change).rust/tools/linux-validate/run.sh: build OK, libobs exported symbols C vs Rust IDENTICAL (1766),test_image_filepasses; the run stopped ontest_async_delay_audio(timing failure under local load, unrelated), so the ON pass was not completed locally — PR CI decides.Intentional differences
None. Characterized, not endorsed (kept): failed/oversized
.gifdoes not fall back to FFmpeg and leaks its nsgif object; init leavesmem_usage/alpha_mode/space0; only frame 0 gets the init alpha mode; infinite-loop GIFs never countcur_loop; a tick back to the same frame returns false; 0 delay = 100 ms.Performance (port_comparison, local, noisy)
image_file/tick_update: Rust 50.1 ns, C 47.2 nsimage_file/load_free: Rust 11.3 µs, C 10.1 µs (file read + nsgif dominated)Follow-up commits (CI fixes)
memsetdoes. Tier 2null_filecompares the bytes.Vec,format!orexpect.test_effect_parser_lifecycle_rustlinks the Rust staticlib next to libobs. On Windows,link.exeresolvedbmalloc/bfreefor the obs-graphics object thatep_freepulls from the staticlib itself, which dragged in obs-util and caused LNK2005/LNK2019. obs-graphics (image-file and the existing texture-render) now names no obs-util symbol. It calls the private adapters inlibobs/graphics/obs-graphics-adapter.c.hinstead: graphics unity group, compiled by that test, copied verbatim into the oracle. I checked this on a localx86_64-pc-windows-msvcrelease staticlib: the symbol closure fromep_freestays inside obs-graphics.