Merge duplicate rd_texture functions

This commit is contained in:
Bastiaan Olij 2023-03-10 20:41:55 +11:00
parent c1128e911c
commit 70dca9ff55
9 changed files with 16 additions and 22 deletions

View File

@ -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(); return RID();
} }

View File

@ -535,7 +535,7 @@ public:
virtual Size2 texture_size_with_proxy(RID p_proxy) override; 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<Image> &p_image, int p_layer = 0); void texture_set_data(RID p_texture, const Ref<Image> &p_image, int p_layer = 0);
void texture_set_data_partial(RID p_texture, const Ref<Image> &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); void texture_set_data_partial(RID p_texture, const Ref<Image> &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);

View File

@ -127,7 +127,7 @@ public:
virtual Size2 texture_size_with_proxy(RID p_proxy) override { return Size2(); }; 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 */ /* DECAL API */
virtual RID decal_allocate() override { return RID(); } virtual RID decal_allocate() override { return RID(); }

View File

@ -1429,9 +1429,15 @@ Size2 TextureStorage::texture_size_with_proxy(RID p_proxy) {
return texture_2d_get_size(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); 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; return (p_srgb && tex->rd_texture_srgb.is_valid()) ? tex->rd_texture_srgb : tex->rd_texture;
} }

View File

@ -498,7 +498,7 @@ public:
virtual Size2 texture_size_with_proxy(RID p_proxy) override; 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 //internal usage
_FORCE_INLINE_ TextureType texture_get_type(RID p_texture) { _FORCE_INLINE_ TextureType texture_get_type(RID p_texture) {
@ -519,18 +519,6 @@ public:
return tex->layers; 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) { _FORCE_INLINE_ Size2i texture_2d_get_size(RID p_texture) {
if (p_texture.is_null()) { if (p_texture.is_null()) {
return Size2i(); return Size2i();

View File

@ -213,7 +213,7 @@ public:
FUNC1(texture_debug_usage, List<TextureInfo> *) FUNC1(texture_debug_usage, List<TextureInfo> *)
FUNC2(texture_set_force_redraw_if_visible, RID, bool) 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 */ /* SHADER API */

View File

@ -100,7 +100,7 @@ public:
virtual Size2 texture_size_with_proxy(RID p_proxy) = 0; 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 */ /* Decal API */
virtual RID decal_allocate() = 0; virtual RID decal_allocate() = 0;

View File

@ -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_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_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_2D_ARRAY);
BIND_ENUM_CONSTANT(TEXTURE_LAYERED_CUBEMAP); BIND_ENUM_CONSTANT(TEXTURE_LAYERED_CUBEMAP);

View File

@ -156,7 +156,7 @@ public:
virtual void texture_set_force_redraw_if_visible(RID p_texture, bool p_enable) = 0; 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 */ /* SHADER API */