Repository navigation
perf(libobs-opengl): update a dynamic texture in place on unmap (#3191) - #3382
Merged
Merged
Conversation
zackees
enabled auto-merge
November 1, 2026 07:21
This was referenced Nov 1, 2026
This was referenced Nov 1, 2026
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.
Refs #3191
RED (guard and measurement) c7aa78b: a new cmocka test,
test_gl_dynamic_texture, runs the reallibobs-openglmodule under xvfb (Mesa software GL on Linux; skips without a display), astest_ffmpeg_mux_unwritable_pathalready does. That covers the real-GL harness the /investigate note asked for. For 15 frames at 1080p and at 4K it maps aGS_DYNAMICBGRA texture, writes a frame-specific pattern, unmaps it, reads it back through a stage surface and requires the exact bytes. It prints the median time of map, write and unmap. It passes on master; it is the guard that the in-place update is bit-exact.GREEN 8b8e4ad:
gs_texture_unmapuploads from the pixel buffer withglTexSubImage2Dinstead ofglTexImage2D. The texture's storage is already specified at creation (upload_texture_2d→gl_init_face), so re-specifying level 0 on every frame only invites the driver to reallocate. Format, type and unpack alignment are unchanged, and the test reads back the same bytes.Measured, honestly a null result on software GL (median ms per map, write and unmap; each line is a separate container run):
llvmpipe shows no difference beyond its ±25% run-to-run noise. It apparently reuses storage when
glTexImage2Drepeats the same size, so the reallocation the issue describes doesn't happen there. The win, if any, is on real GPU drivers (apitrace or Nsight on hardware), which I can't run here. HenceRefs, notFixes: the hardware numbers the issue asks for are still open.Dropped from the plan: orphaning the pixel buffer with
glBufferData(NULL)before each map. On llvmpipe it was slower (5.52 / 21.08 ms in one run), probably a fresh allocation per map, and it can do the same on other drivers. It should come back only with hardware traces that show the map stall.Tiers: libobs-opengl C only. Tier 2: the new test. Tiers 1, 3 and 4 do not apply.
./lintpasses.