diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-09-01 15:46:17 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-09-02 20:37:15 +0300 |
commit | e48a6fcc6397e5a964f2096d937ac189f07ce999 (patch) | |
tree | 37f98d5dab5c869b7248fc65a35edfc1b618b531 /source/blender/draw/intern/shaders | |
parent | 356460f5cf659ef071daa1267ab368b733b4133e (diff) |
DRW-Next: Add uniform attributes (object attributes) support
This replaces the direct shader uniform layout declaration by a linear
search through a global buffer.
Each instance has an attribute offset inside the global buffer and an
attribute count.
This removes any padding and tighly pack all uniform attributes inside
a single buffer.
This would also remove the limit of 8 attribute but it is kept because of
compatibility with the old system that is still used by the old draw
manager.
Diffstat (limited to 'source/blender/draw/intern/shaders')
-rw-r--r-- | source/blender/draw/intern/shaders/common_attribute_lib.glsl | 1 | ||||
-rw-r--r-- | source/blender/draw/intern/shaders/draw_object_infos_info.hh | 10 |
2 files changed, 10 insertions, 1 deletions
diff --git a/source/blender/draw/intern/shaders/common_attribute_lib.glsl b/source/blender/draw/intern/shaders/common_attribute_lib.glsl index ce5e49c7f63..6b5b6fcc846 100644 --- a/source/blender/draw/intern/shaders/common_attribute_lib.glsl +++ b/source/blender/draw/intern/shaders/common_attribute_lib.glsl @@ -25,3 +25,4 @@ float attr_load_float(sampler3D tex); float attr_load_temperature_post(float attr); vec4 attr_load_color_post(vec4 attr); +vec4 attr_load_uniform(vec4 attr, const uint attr_hash); diff --git a/source/blender/draw/intern/shaders/draw_object_infos_info.hh b/source/blender/draw/intern/shaders/draw_object_infos_info.hh index 2ec40ab76e3..31fee018fbc 100644 --- a/source/blender/draw/intern/shaders/draw_object_infos_info.hh +++ b/source/blender/draw/intern/shaders/draw_object_infos_info.hh @@ -25,4 +25,12 @@ GPU_SHADER_CREATE_INFO(draw_object_infos_new) .define("OrcoTexCoFactors", "(drw_infos[resource_id].orco_mul_bias)") .define("ObjectInfo", "(drw_infos[resource_id].infos)") .define("ObjectColor", "(drw_infos[resource_id].color)") - .storage_buf(DRW_OBJ_INFOS_SLOT, Qualifier::READ, "ObjectInfos", "drw_infos[]");
\ No newline at end of file + .storage_buf(DRW_OBJ_INFOS_SLOT, Qualifier::READ, "ObjectInfos", "drw_infos[]"); + +/** \note Requires draw_object_infos_new. */ +GPU_SHADER_CREATE_INFO(draw_object_attribute_new) + .define("OBATTR_LIB") + .define("ObjectAttributeStart", "(drw_infos[resource_id].orco_mul_bias[0].w)") + .define("ObjectAttributeLen", "(drw_infos[resource_id].orco_mul_bias[1].w)") + .storage_buf(DRW_OBJ_ATTR_SLOT, Qualifier::READ, "ObjectAttribute", "drw_attrs[]") + .additional_info("draw_object_infos_new"); |