diff options
author | clayjohn <claynjohn@gmail.com> | 2023-06-07 15:44:11 -0700 |
---|---|---|
committer | clayjohn <claynjohn@gmail.com> | 2023-06-07 15:44:11 -0700 |
commit | 05142b62289e90ae0dba62e60f2768512c21e7c4 (patch) | |
tree | da66fe3da515c4c48bc98062d9e2398f93804af8 /drivers/gles3/storage/texture_storage.cpp | |
parent | 72b59325cf7beba7e6e9170cf6023a079fd58672 (diff) | |
download | redot-engine-05142b62289e90ae0dba62e60f2768512c21e7c4.tar.gz |
Properly update array textures when using the OpenGL backend to avoid crash
Diffstat (limited to 'drivers/gles3/storage/texture_storage.cpp')
-rw-r--r-- | drivers/gles3/storage/texture_storage.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/gles3/storage/texture_storage.cpp b/drivers/gles3/storage/texture_storage.cpp index 14c2b3166f..c4fef89cfd 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 Vector<R texture.format = image->get_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<Image>(), 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<Image> &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]); } |