From 05142b62289e90ae0dba62e60f2768512c21e7c4 Mon Sep 17 00:00:00 2001 From: clayjohn Date: Wed, 7 Jun 2023 15:44:11 -0700 Subject: [PATCH] Properly update array textures when using the OpenGL backend to avoid crash --- drivers/gles3/storage/texture_storage.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gles3/storage/texture_storage.cpp b/drivers/gles3/storage/texture_storage.cpp index 14c2b3166f8..c4fef89cfd2 100644 --- a/drivers/gles3/storage/texture_storage.cpp +++ b/drivers/gles3/storage/texture_storage.cpp @@ -789,14 +789,14 @@ void TextureStorage::texture_2d_layered_initialize(RID p_texture, const Vectorget_format(); texture.type = Texture::TYPE_LAYERED; texture.layered_type = p_layered_type; - texture.target = GL_TEXTURE_2D_ARRAY; + texture.target = p_layered_type == RS::TEXTURE_LAYERED_CUBEMAP ? GL_TEXTURE_CUBE_MAP : GL_TEXTURE_2D_ARRAY; texture.layers = p_layers.size(); _get_gl_image_and_format(Ref(), texture.format, texture.real_format, texture.gl_format_cache, texture.gl_internal_format_cache, texture.gl_type_cache, texture.compressed, false); texture.active = true; glGenTextures(1, &texture.tex_id); texture_owner.initialize_rid(p_texture, texture); for (int i = 0; i < p_layers.size(); i++) { - _texture_set_data(p_texture, p_layers[i], 1, i == 0); + _texture_set_data(p_texture, p_layers[i], i, i == 0); } } @@ -1310,7 +1310,7 @@ void TextureStorage::_texture_set_data(RID p_texture, const Ref &p_image, if (initialize) { glTexImage3D(GL_TEXTURE_2D_ARRAY, i, internal_format, w, h, texture->layers, 0, format, type, nullptr); } - glTexSubImage3D(GL_TEXTURE_2D_ARRAY, i, 0, 0, p_layer, w, h, 0, format, type, &read[ofs]); + glTexSubImage3D(GL_TEXTURE_2D_ARRAY, i, 0, 0, p_layer, w, h, 1, format, type, &read[ofs]); } else { glTexImage2D(blit_target, i, internal_format, w, h, 0, format, type, &read[ofs]); }