From 70dca9ff55f08f0392f486e0e69e610c074692dc Mon Sep 17 00:00:00 2001 From: Bastiaan Olij Date: Fri, 10 Mar 2023 20:41:55 +1100 Subject: [PATCH] Merge duplicate rd_texture functions --- drivers/gles3/storage/texture_storage.cpp | 2 +- drivers/gles3/storage/texture_storage.h | 2 +- servers/rendering/dummy/storage/texture_storage.h | 2 +- .../renderer_rd/storage_rd/texture_storage.cpp | 10 ++++++++-- .../renderer_rd/storage_rd/texture_storage.h | 14 +------------- servers/rendering/rendering_server_default.h | 2 +- servers/rendering/storage/texture_storage.h | 2 +- servers/rendering_server.cpp | 2 +- servers/rendering_server.h | 2 +- 9 files changed, 16 insertions(+), 22 deletions(-) diff --git a/drivers/gles3/storage/texture_storage.cpp b/drivers/gles3/storage/texture_storage.cpp index dae722186cc..b4dea0dfe26 100644 --- a/drivers/gles3/storage/texture_storage.cpp +++ b/drivers/gles3/storage/texture_storage.cpp @@ -1136,7 +1136,7 @@ Size2 TextureStorage::texture_size_with_proxy(RID p_texture) { } } -RID TextureStorage::texture_get_rd_texture_rid(RID p_texture, bool p_srgb) const { +RID TextureStorage::texture_get_rd_texture(RID p_texture, bool p_srgb) const { return RID(); } diff --git a/drivers/gles3/storage/texture_storage.h b/drivers/gles3/storage/texture_storage.h index fedda6b260a..c7029046483 100644 --- a/drivers/gles3/storage/texture_storage.h +++ b/drivers/gles3/storage/texture_storage.h @@ -535,7 +535,7 @@ public: virtual Size2 texture_size_with_proxy(RID p_proxy) override; - virtual RID texture_get_rd_texture_rid(RID p_texture, bool p_srgb = false) const override; + virtual RID texture_get_rd_texture(RID p_texture, bool p_srgb = false) const override; void texture_set_data(RID p_texture, const Ref &p_image, int p_layer = 0); void texture_set_data_partial(RID p_texture, const Ref &p_image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int p_dst_mip, int p_layer = 0); diff --git a/servers/rendering/dummy/storage/texture_storage.h b/servers/rendering/dummy/storage/texture_storage.h index 67661ce8210..e880cacc029 100644 --- a/servers/rendering/dummy/storage/texture_storage.h +++ b/servers/rendering/dummy/storage/texture_storage.h @@ -127,7 +127,7 @@ public: virtual Size2 texture_size_with_proxy(RID p_proxy) override { return Size2(); }; - virtual RID texture_get_rd_texture_rid(RID p_texture, bool p_srgb = false) const override { return RID(); }; + virtual RID texture_get_rd_texture(RID p_texture, bool p_srgb = false) const override { return RID(); }; /* DECAL API */ virtual RID decal_allocate() override { return RID(); } diff --git a/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp b/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp index 1aab52d1c3b..8808d63a829 100644 --- a/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp @@ -1429,9 +1429,15 @@ Size2 TextureStorage::texture_size_with_proxy(RID p_proxy) { return texture_2d_get_size(p_proxy); } -RID TextureStorage::texture_get_rd_texture_rid(RID p_texture, bool p_srgb) const { +RID TextureStorage::texture_get_rd_texture(RID p_texture, bool p_srgb) const { + if (p_texture.is_null()) { + return RID(); + } + Texture *tex = texture_owner.get_or_null(p_texture); - ERR_FAIL_COND_V(!tex, RID()); + if (!tex) { + return RID(); + } return (p_srgb && tex->rd_texture_srgb.is_valid()) ? tex->rd_texture_srgb : tex->rd_texture; } diff --git a/servers/rendering/renderer_rd/storage_rd/texture_storage.h b/servers/rendering/renderer_rd/storage_rd/texture_storage.h index f710de11000..3e4ac3b8332 100644 --- a/servers/rendering/renderer_rd/storage_rd/texture_storage.h +++ b/servers/rendering/renderer_rd/storage_rd/texture_storage.h @@ -498,7 +498,7 @@ public: virtual Size2 texture_size_with_proxy(RID p_proxy) override; - virtual RID texture_get_rd_texture_rid(RID p_texture, bool p_srgb = false) const override; + virtual RID texture_get_rd_texture(RID p_texture, bool p_srgb = false) const override; //internal usage _FORCE_INLINE_ TextureType texture_get_type(RID p_texture) { @@ -519,18 +519,6 @@ public: return tex->layers; } - _FORCE_INLINE_ RID texture_get_rd_texture(RID p_texture, bool p_srgb = false) { - if (p_texture.is_null()) { - return RID(); - } - RendererRD::TextureStorage::Texture *tex = texture_owner.get_or_null(p_texture); - - if (!tex) { - return RID(); - } - return (p_srgb && tex->rd_texture_srgb.is_valid()) ? tex->rd_texture_srgb : tex->rd_texture; - } - _FORCE_INLINE_ Size2i texture_2d_get_size(RID p_texture) { if (p_texture.is_null()) { return Size2i(); diff --git a/servers/rendering/rendering_server_default.h b/servers/rendering/rendering_server_default.h index a3bdf7d1468..249e5c2d9df 100644 --- a/servers/rendering/rendering_server_default.h +++ b/servers/rendering/rendering_server_default.h @@ -213,7 +213,7 @@ public: FUNC1(texture_debug_usage, List *) FUNC2(texture_set_force_redraw_if_visible, RID, bool) - FUNC2RC(RID, texture_get_rd_texture_rid, RID, bool) + FUNC2RC(RID, texture_get_rd_texture, RID, bool) /* SHADER API */ diff --git a/servers/rendering/storage/texture_storage.h b/servers/rendering/storage/texture_storage.h index 227d44aa278..0a59c70526c 100644 --- a/servers/rendering/storage/texture_storage.h +++ b/servers/rendering/storage/texture_storage.h @@ -100,7 +100,7 @@ public: virtual Size2 texture_size_with_proxy(RID p_proxy) = 0; - virtual RID texture_get_rd_texture_rid(RID p_texture, bool p_srgb = false) const = 0; + virtual RID texture_get_rd_texture(RID p_texture, bool p_srgb = false) const = 0; /* Decal API */ virtual RID decal_allocate() = 0; diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp index 3d0443b494d..d88cbec13b5 100644 --- a/servers/rendering_server.cpp +++ b/servers/rendering_server.cpp @@ -1697,7 +1697,7 @@ void RenderingServer::_bind_methods() { ClassDB::bind_method(D_METHOD("texture_get_path", "texture"), &RenderingServer::texture_get_path); ClassDB::bind_method(D_METHOD("texture_set_force_redraw_if_visible", "texture", "enable"), &RenderingServer::texture_set_force_redraw_if_visible); - ClassDB::bind_method(D_METHOD("texture_get_rd_texture", "texture", "srgb"), &RenderingServer::texture_get_rd_texture_rid, DEFVAL(false)); + ClassDB::bind_method(D_METHOD("texture_get_rd_texture", "texture", "srgb"), &RenderingServer::texture_get_rd_texture, DEFVAL(false)); BIND_ENUM_CONSTANT(TEXTURE_LAYERED_2D_ARRAY); BIND_ENUM_CONSTANT(TEXTURE_LAYERED_CUBEMAP); diff --git a/servers/rendering_server.h b/servers/rendering_server.h index b53b7d2ff95..a2837444438 100644 --- a/servers/rendering_server.h +++ b/servers/rendering_server.h @@ -156,7 +156,7 @@ public: virtual void texture_set_force_redraw_if_visible(RID p_texture, bool p_enable) = 0; - virtual RID texture_get_rd_texture_rid(RID p_texture, bool p_srgb = false) const = 0; + virtual RID texture_get_rd_texture(RID p_texture, bool p_srgb = false) const = 0; /* SHADER API */