summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorDaniel Rakos <daniel.rakos@rastergrid.com>2019-05-08 17:20:42 +0200
committerDaniel Rakos <daniel.rakos@rastergrid.com>2019-05-08 17:22:40 +0200
commite34eb5c26caf4a0a68f8c84f0e02893e4be2eeb6 (patch)
tree645fcd489c569b4aeb3f4be5074ab646598c7852 /drivers
parent0239d8bd9fa03965439aac2482d18746f807bd00 (diff)
Fix texture resource reload bug
If a non-imported texture resource file (e.g. DDS) gets updated the editor doesn't reload it. The cause of the problem is two-fold: First, the code of ImageTexture assumes that textures are always imported from an image, but that's not the case for e.g. DDS. This change thus adds code to issue a resource reload in case an image reload is not possible (which is the case for non-imported texture resources). Second, the code is filled with bogus calls to Image::get_image_data_size() to determine the mipmap offset when that should be done using Image::get_image_mipmap_offset(). Previous code literally passed the integer mip level value to Image::get_image_data_size() where that actually expects a boolean. Thus this part of the change might actually solve some other issues as well. To be pedantic, the texture_get_data() funciton of the rasterizer drivers is still quite a mess, as it only ever returns the whole mipchain when GLES_OVER_GL is set (practically only on desktop builds) but this change does not attempt to resolve that.
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gles2/rasterizer_storage_gles2.cpp5
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.cpp5
2 files changed, 2 insertions, 8 deletions
diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp
index 13fdd1db73..3f78588940 100644
--- a/drivers/gles2/rasterizer_storage_gles2.cpp
+++ b/drivers/gles2/rasterizer_storage_gles2.cpp
@@ -774,10 +774,7 @@ Ref<Image> RasterizerStorageGLES2::texture_get_data(RID p_texture, int p_layer)
for (int i = 0; i < texture->mipmaps; i++) {
- int ofs = 0;
- if (i > 0) {
- ofs = Image::get_image_data_size(texture->alloc_width, texture->alloc_height, real_format, i - 1);
- }
+ int ofs = Image::get_image_mipmap_offset(texture->alloc_width, texture->alloc_height, real_format, i);
if (texture->compressed) {
glPixelStorei(GL_PACK_ALIGNMENT, 4);
diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp
index 95d4bec611..661be28e6b 100644
--- a/drivers/gles3/rasterizer_storage_gles3.cpp
+++ b/drivers/gles3/rasterizer_storage_gles3.cpp
@@ -1210,10 +1210,7 @@ Ref<Image> RasterizerStorageGLES3::texture_get_data(RID p_texture, int p_layer)
for (int i = 0; i < texture->mipmaps; i++) {
- int ofs = 0;
- if (i > 0) {
- ofs = Image::get_image_data_size(texture->alloc_width, texture->alloc_height, real_format, i - 1);
- }
+ int ofs = Image::get_image_mipmap_offset(texture->alloc_width, texture->alloc_height, real_format, i);
if (texture->compressed) {