Skip to content

Exempt user bitmaps from texture detail culling#7617

Merged
Goober5000 merged 2 commits into
scp-fs2open:masterfrom
Goober5000:fix/texture_upload
Jul 19, 2026
Merged

Exempt user bitmaps from texture detail culling#7617
Goober5000 merged 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 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

@JohnAFernandez JohnAFernandez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to my limited graphics understanding

Goober5000 and others added 2 commits July 19, 2026 00:12
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 force-pushed the fix/texture_upload branch from 01a7c3c to 35312d3 Compare July 19, 2026 04:12
@Goober5000
Goober5000 merged commit 69c6ce3 into scp-fs2open:master Jul 19, 2026
18 checks passed
@Goober5000
Goober5000 deleted the fix/texture_upload branch July 19, 2026 05:47
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.

2 participants