GLES3: Don't call glTexParameter*
for invalid filter and repeat modes
#79685
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.
This fixes #79315. That issue was caused by
TextureStorage::_clear_render_target
callingTexture::gl_set_filter
andTexture::gl_set_repeat
with the value*_MAX
. Thegl_set_filter
andgl_set_repeat
functions weren't designed to be called with the values (which appear to be used to force the next calls to makeglTexParameter*
calls), which results in whatever happens to be the currently bound OpenGL texture to be assigned unexpected parameters. This PR updatesTexture::gl_set_filter
andTexture::gl_set_repeat
so that they only make calls toglTexParameter*
whenp_filter
/p_repeat
is a valid value.I also made some small changes to these functions that shouldn't affect functionality, but figured would be nice to cleanup while I'm here. I removed the (IMO) unhelpful comments and updated how
max_lod
is assigned to be more consistent with the other local variables ingl_set_filter
. I also changed the default values ofTexture::state_filter
andTexture::state_repeat
to better represent their uninitialized state. This shouldn't have an effect on the engine, as these values get initialized inTextureStorage::_texture_set_data
either way.The only part of this I'm not sure about is the handling of
*_DEFAULT
as the argument. From what I can tell, they should never be used with these functions, so I didn't add a specific case for them, and chose to handle them the same a*_MAX
(or any invalid enum value). If this needs to be changed, let me know what behavior you would want these to have, and I can update this PR.This PR targets the master branch, but it should be safe to cherry-pick for a 4.1.X release. This PR may interact with #79568 and may require a rebase if that gets merged first.