summaryrefslogtreecommitdiffstats
path: root/servers/rendering/renderer_rd/storage_rd/material_storage.h
diff options
context:
space:
mode:
authorDario <dariosamo@gmail.com>2023-09-05 11:41:57 -0300
committerDario <dariosamo@gmail.com>2023-09-06 11:24:19 -0300
commit9b91750fb1cecea72fbd8ee155d3ad22754917c1 (patch)
tree52b9dc20c06a838a143c3617e01337d701ce8a63 /servers/rendering/renderer_rd/storage_rd/material_storage.h
parent8449592d92eaeef990f5502b419d491ee3eeb7a6 (diff)
downloadredot-engine-9b91750fb1cecea72fbd8ee155d3ad22754917c1.tar.gz
Fix mipmap bias behavior by refactoring how samplers are created by Material Storage.
Introduces a new structure to store samplers created with certain parameters instead of storing a 'custom' set of samplers. Allows viewports to correctly configure the mipmap bias and use it when rendering the scene.
Diffstat (limited to 'servers/rendering/renderer_rd/storage_rd/material_storage.h')
-rw-r--r--servers/rendering/renderer_rd/storage_rd/material_storage.h34
1 files changed, 23 insertions, 11 deletions
diff --git a/servers/rendering/renderer_rd/storage_rd/material_storage.h b/servers/rendering/renderer_rd/storage_rd/material_storage.h
index ae97f43a3c..403fd286b4 100644
--- a/servers/rendering/renderer_rd/storage_rd/material_storage.h
+++ b/servers/rendering/renderer_rd/storage_rd/material_storage.h
@@ -105,13 +105,27 @@ public:
Vector<RID> texture_cache;
};
+ struct Samplers {
+ RID rids[RS::CANVAS_ITEM_TEXTURE_FILTER_MAX][RS::CANVAS_ITEM_TEXTURE_REPEAT_MAX];
+ float mipmap_bias = 0.0f;
+ bool use_nearest_mipmap_filter = false;
+ int anisotropic_filtering_level = 2;
+
+ _FORCE_INLINE_ RID get_sampler(RS::CanvasItemTextureFilter p_filter, RS::CanvasItemTextureRepeat p_repeat) const {
+ return rids[p_filter][p_repeat];
+ }
+
+ Vector<RD::Uniform> get_uniforms(int p_first_index) const;
+ bool is_valid() const;
+ bool is_null() const;
+ };
+
private:
static MaterialStorage *singleton;
/* Samplers */
- RID default_rd_samplers[RS::CANVAS_ITEM_TEXTURE_FILTER_MAX][RS::CANVAS_ITEM_TEXTURE_REPEAT_MAX];
- RID custom_rd_samplers[RS::CANVAS_ITEM_TEXTURE_FILTER_MAX][RS::CANVAS_ITEM_TEXTURE_REPEAT_MAX];
+ Samplers default_samplers;
/* Buffers */
@@ -335,18 +349,16 @@ public:
/* Samplers */
+ Samplers samplers_rd_allocate(float p_mipmap_bias = 0.0f) const;
+ void samplers_rd_free(Samplers &p_samplers) const;
+
_FORCE_INLINE_ RID sampler_rd_get_default(RS::CanvasItemTextureFilter p_filter, RS::CanvasItemTextureRepeat p_repeat) {
- return default_rd_samplers[p_filter][p_repeat];
+ return default_samplers.get_sampler(p_filter, p_repeat);
}
- _FORCE_INLINE_ RID sampler_rd_get_custom(RS::CanvasItemTextureFilter p_filter, RS::CanvasItemTextureRepeat p_repeat) {
- return custom_rd_samplers[p_filter][p_repeat];
- }
-
- void sampler_rd_configure_custom(float mipmap_bias);
- Vector<RD::Uniform> get_default_sampler_uniforms(int first_index);
-
- // void sampler_rd_set_default(float p_mipmap_bias);
+ _FORCE_INLINE_ const Samplers &samplers_rd_get_default() const {
+ return default_samplers;
+ }
/* Buffers */