Merge pull request #74708 from BastiaanOlij/fix_rd_texture

Merge duplicate rd_texture functions
This commit is contained in:
Rémi Verschelde 2023-03-10 22:48:19 +01:00
commit 0333b4a266
No known key found for this signature in database
GPG key ID: C3336907360768E1
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();
}

View file

@ -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<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);

View file

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

View file

@ -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;
}

View file

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

View file

@ -213,7 +213,7 @@ public:
FUNC1(texture_debug_usage, List<TextureInfo> *)
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 */

View file

@ -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;

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_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);

View file

@ -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 */