diff options
author | clayjohn <claynjohn@gmail.com> | 2023-06-26 10:45:24 -0700 |
---|---|---|
committer | clayjohn <claynjohn@gmail.com> | 2023-06-26 10:45:24 -0700 |
commit | 7c37a32897712649fdbeb7b1a37f0957b2fb9fa3 (patch) | |
tree | e73d63984fda1e53be6d1b34e5c0addfbcd21bff /drivers/gles3/storage/texture_storage.cpp | |
parent | 030c1a950e8cee19e72104b4fb79caba17a2d678 (diff) | |
download | redot-engine-7c37a32897712649fdbeb7b1a37f0957b2fb9fa3.tar.gz |
Use a filter with mipmaps when initializing textures with mipmaps in GL Compatibility renderer
This works around a driver bug in some older devices and should be harmless on any spec-compliant device
Diffstat (limited to 'drivers/gles3/storage/texture_storage.cpp')
-rw-r--r-- | drivers/gles3/storage/texture_storage.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/gles3/storage/texture_storage.cpp b/drivers/gles3/storage/texture_storage.cpp index 8a57476a73..305be68706 100644 --- a/drivers/gles3/storage/texture_storage.cpp +++ b/drivers/gles3/storage/texture_storage.cpp @@ -1249,10 +1249,6 @@ void TextureStorage::_texture_set_data(RID p_texture, const Ref<Image> &p_image, glActiveTexture(GL_TEXTURE0); glBindTexture(texture->target, texture->tex_id); - // set filtering and repeat state to default - texture->gl_set_filter(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST); - texture->gl_set_repeat(RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); - #ifndef WEB_ENABLED switch (texture->format) { #ifdef GLES_OVER_GL @@ -1294,6 +1290,15 @@ void TextureStorage::_texture_set_data(RID p_texture, const Ref<Image> &p_image, int mipmaps = img->has_mipmaps() ? img->get_mipmap_count() + 1 : 1; + // Set filtering and repeat state to default. + if (mipmaps > 1) { + texture->gl_set_filter(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS); + } else { + texture->gl_set_filter(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST); + } + + texture->gl_set_repeat(RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); + int w = img->get_width(); int h = img->get_height(); |