diff --git a/drivers/gles3/storage/texture_storage.cpp b/drivers/gles3/storage/texture_storage.cpp index 14bbe635a4f..bdcd9fe4849 100644 --- a/drivers/gles3/storage/texture_storage.cpp +++ b/drivers/gles3/storage/texture_storage.cpp @@ -1099,7 +1099,11 @@ Ref TextureStorage::texture_2d_get(RID p_texture) const { ERR_FAIL_COND_V(data.is_empty(), Ref()); image = Image::create_from_data(texture->alloc_width, texture->alloc_height, texture->mipmaps > 1, texture->real_format, data); - ERR_FAIL_COND_V(image->is_empty(), Ref()); + if (image->is_empty()) { + const String &path_str = texture->path.is_empty() ? "with no path" : vformat("with path '%s'", texture->path); + ERR_FAIL_V_MSG(Ref(), vformat("Texture %s has no data.", path_str)); + } + if (texture->format != texture->real_format) { image->convert(texture->format); } @@ -1155,7 +1159,10 @@ Ref TextureStorage::texture_2d_get(RID p_texture) const { ERR_FAIL_COND_V(data.is_empty(), Ref()); image = Image::create_from_data(texture->alloc_width, texture->alloc_height, false, Image::FORMAT_RGBA8, data); - ERR_FAIL_COND_V(image->is_empty(), Ref()); + if (image->is_empty()) { + const String &path_str = texture->path.is_empty() ? "with no path" : vformat("with path '%s'", texture->path); + ERR_FAIL_V_MSG(Ref(), vformat("Texture %s has no data.", path_str)); + } if (texture->format != Image::FORMAT_RGBA8) { image->convert(texture->format); @@ -1227,7 +1234,10 @@ Ref TextureStorage::texture_2d_layer_get(RID p_texture, int p_layer) cons ERR_FAIL_COND_V(data.is_empty(), Ref()); Ref image = Image::create_from_data(texture->width, texture->height, false, Image::FORMAT_RGBA8, data); - ERR_FAIL_COND_V(image->is_empty(), Ref()); + if (image->is_empty()) { + const String &path_str = texture->path.is_empty() ? "with no path" : vformat("with path '%s'", texture->path); + ERR_FAIL_V_MSG(Ref(), vformat("Texture %s has no data.", path_str)); + } if (texture->format != Image::FORMAT_RGBA8) { image->convert(texture->format); diff --git a/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp b/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp index 697d9490158..d664f26d340 100644 --- a/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp @@ -1446,7 +1446,11 @@ Ref TextureStorage::texture_2d_get(RID p_texture) const { image = Image::create_from_data(tex->width, tex->height, tex->mipmaps > 1, tex->validated_format, data); } - ERR_FAIL_COND_V(image->is_empty(), Ref()); + if (image->is_empty()) { + const String &path_str = tex->path.is_empty() ? "with no path" : vformat("with path '%s'", tex->path); + ERR_FAIL_V_MSG(Ref(), vformat("Texture %s has no data.", path_str)); + } + if (tex->format != tex->validated_format) { image->convert(tex->format); } @@ -1467,7 +1471,10 @@ Ref TextureStorage::texture_2d_layer_get(RID p_texture, int p_layer) cons Vector data = RD::get_singleton()->texture_get_data(tex->rd_texture, p_layer); ERR_FAIL_COND_V(data.is_empty(), Ref()); Ref image = Image::create_from_data(tex->width, tex->height, tex->mipmaps > 1, tex->validated_format, data); - ERR_FAIL_COND_V(image->is_empty(), Ref()); + if (image->is_empty()) { + const String &path_str = tex->path.is_empty() ? "with no path" : vformat("with path '%s'", tex->path); + ERR_FAIL_V_MSG(Ref(), vformat("Texture %s has no data.", path_str)); + } if (tex->format != tex->validated_format) { image->convert(tex->format); } @@ -1494,6 +1501,10 @@ Vector> TextureStorage::texture_3d_get(RID p_texture) const { Ref img = Image::create_from_data(bs.size.width, bs.size.height, false, tex->validated_format, sub_region); ERR_FAIL_COND_V(img->is_empty(), Vector>()); + if (img->is_empty()) { + const String &path_str = tex->path.is_empty() ? "with no path" : vformat("with path '%s'", tex->path); + ERR_FAIL_V_MSG(Vector>(), vformat("Texture %s has no data.", path_str)); + } if (tex->format != tex->validated_format) { img->convert(tex->format); }