Skip to content

Exempt user bitmaps from texture detail culling#7617

Open
Goober5000 wants to merge 2 commits into
scp-fs2open:masterfrom
Goober5000:fix/texture_upload
Open

Exempt user bitmaps from texture detail culling#7617
Goober5000 wants to merge 2 commits into
scp-fs2open:masterfrom
Goober5000:fix/texture_upload

Conversation

@Goober5000

Copy link
Copy Markdown
Contributor

At texture detail below maximum, opengl_create_texture() culls texture
dimensions on upload, but user bitmaps are streaming surfaces
(streamed animations, video) whose frames are updated through
gr_update_texture() with the bitmap's own dimensions. Once culled, the
glTexSubImage3D update exceeds the texture's actual size, so OpenGL
rejects it with GL_INVALID_VALUE and the animation silently freezes on
its first, downsampled frame. Culling them also saves nothing, since
full-size frame data is streamed every frame regardless.

Also assert in gr_opengl_update_texture() that the update dimensions
match the texture, so any future mismatch of this kind is caught in
debug builds instead of failing silently.

And add a check for texture bind results in gr_opengl_tcache_set().

Goober5000 and others added 2 commits July 18, 2026 01:27
At texture detail below maximum, opengl_create_texture() culls texture
dimensions on upload, but user bitmaps are streaming surfaces
(streamed animations, video) whose frames are updated through
gr_update_texture() with the bitmap's own dimensions.  Once culled, the
glTexSubImage3D update exceeds the texture's actual size, so OpenGL
rejects it with GL_INVALID_VALUE and the animation silently freezes on
its first, downsampled frame.  Culling them also saves nothing, since
full-size frame data is streamed every frame regardless.

Also assert in gr_opengl_update_texture() that the update dimensions
match the texture, so any future mismatch of this kind is caught in
debug builds instead of failing silently.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
gr_opengl_tcache_set() leaves the previous binding active when it
fails, so the glTexParameteri calls that follow would modify the filter
state of an unrelated texture.  Only set the parameter when the volume
texture actually bound.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Goober5000 Goober5000 added fix A fix for bugs, not-a-bugs, and/or regressions. graphics A feature or issue related to graphics (2d and 3d) labels Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix A fix for bugs, not-a-bugs, and/or regressions. graphics A feature or issue related to graphics (2d and 3d)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant