Repository navigation
obs-graphics: Port graphics/texture-render.c.h to Rust - #1861
Merged
Merged
Conversation
Records every device call gs_texrender_* makes through graphics.c on a fake device in a hand-built graphics_t, so the test needs no GPU and runs against the C build, the C reference and hybrid libobs. Refs obs-rust#1860
Tier 1 mirror of test_texture_render.c through a safe core whose bodies are todo!(). Refs obs-rust#1860
gs_texrender_* now live in obs-graphics. The safe core drives a Device trait in the C call order; the shim implements it with the public gs_* functions, which stay C in graphics.c.h. The texrender is a bmalloc block, so bnum_allocs counts it as before. texture-render.c.h moves to the ported graphics group, so hybrid libobs no longer compiles it and the C reference still does. Cargo tests have no graphics context: the oracle crate supplies a recording stand-in for the gs_* functions the shim calls. Refs obs-rust#1860
The original texture-render.c.h is built as oracle_gs_texrender_*. Both sides run the same operation sequences on the recording gs_* stand-in, and the test compares the full call log with arguments, every return value and bnum_allocs after each step. Refs obs-rust#1860
Adds the rust/README.md row and two port_comparison pairs: a begin, end and reset frame on a sized texrender, and create, size and destroy. The oracle's gs_* stand-in stops recording for them, so they time the state machine and its graphics calls. Fixes obs-rust#1860
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 #1860
What and why
Unit 5 of #1846. The eight
gs_texrender_*functions fromlibobs/graphics/texture-render.c.hnow live in obs-graphics. The file moves fromlibobs.graphics+.h.ctolibobs.ported-graphics+.h.c. Hybrid libobs no longer compiles it, and the C reference still does. Public headers and the exported symbols do not change.The file reads no private layout. Its struct is private to the file, and callers only hold the pointer. It calls only public
graphics.hfunctions. The safe core drives aDevicetrait in the C call order. The shim implements the trait with thosegs_*functions, which stay C ingraphics.c.h. That is the patternobs-missing-filesuses forobs_source_get_name: libobs links the real functions, and cargo tests get a stand-in. Here the stand-in is in the oracle crate (oracle/texture_render_device.c), because every test binary that links obs-graphics also links the oracle. The texrender is abmallocblock, sobnum_allocscounts it as before.No intentional differences. Characterized, not endorsed, and kept:
uint32_tsize cast toint.gs_texrender_get_format(NULL)is not checked, as in the C.Tests:
test/cmocka/test_texture_render.c, 13 cases. No GPU or display: the fixture builds agraphics_twith a recording fake device in its exports and enters it withgs_enter_context. It calls the exportedgs_texrender_*, so it runs the C or the Rust, whichever libobs is loaded.obs-tests-graphics(render::texture_render). They run through the safe core with a fake that does what graphics.c does, and the expected strings are the C test's strings.render::texture_render_paritycompares the shim with the original file, which is built asoracle_gs_texrender_*. Both sides call the same recordinggs_*stand-in, which logs every call with its arguments, null destroys and matrix calls included. Seven fixed sequences cover the cmocka cases' situations, and 512 proptest sequences of up to 48 operations cover the rest. The test compares the whole log, every return value, the returned device handles andbnum_allocsafter each step. It runs in its own child process, because the stand-in and the allocation counter are process-wide.matrix_popandprojection_popin end failed it. Storing the size only after a successful create failed it. Dropping the saved color space failed it. With the fixed sequences disabled, the proptest alone also caught the size change.port_comparison(soldr cargo bench -p obs-c-oracle --bench port_comparison -- texture_render), medians. The stand-in does not record during the benches:These came from a shared build host with a load average of 25 to 31, pinned to one CPU, and they do not settle which side is faster: the order changes from run to run and the confidence intervals overlap. They should be rerun on a quiet machine before anyone reads them as a regression or a gain.
RED → GREEN
c47b8350e37a77763444f5ea4b8d5b2a079b886e. The 13render::texture_rendertests panic intodo!()(not yet implemented), 0 passed, 13 failed.e833989708d9119998e77697d1aea0f94c7e9a3e.obs-tests-graphicspasses 245/245 at GREEN, including the 13 texrender cases, and 246/246 at the head with the parity test (c2ccca498). Theobs-media-ioharness passes 237/237, and every workspace test binary builds and links on the host, for Windows MSVC and for macOS arm64 (the local gate cross lane).test_texture_renderpasses 13/13 against the C build (OBS_LIBOBS_BACKEND=C), againstlibobs-c-referenceand against hybrid libobs. Each run loaded the intendedlibobs.so. All threelibobs.soexport the same 1766 symbols. Hybrid libobs compileslibobs.graphics+.h.cand notlibobs.ported-graphics+.h.c. The C reference compiles both.Full ctest on the hybrid tree (private Xvfb,
dbus-run-session): against hybrid libobs 382/382. Againstlibobs-c-reference, 381/382:test_deinterlace_2x_field_orderfailed while the host was at a load average of about 30, then passed 2/2 alone against each library. A run before the last rebase had the same pattern:test_pulse_monitor_devicefailed against the C reference while another pulse test ran on the host, then passed alone. Neither test touches texrender. The only skips areopen_crashes_without_obs_core(by design while obs core is up) andtest_hex_float_values_ignore_comma_locale(no comma-decimal locale installed on the host), the same on both. Local gatelintandcrosslanes pass.Checklist
master(or the description starts with a Stacked: note)eec7df67a, REDc47b8350e, GREENe83398970.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. None. The oracle wrapper turns off-Wsign-conversionaround the unchanged original, which passes itsuint32_tsize togs_set_viewport'sintparameters.