Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2022-09-01 15:46:17 +0300
committerClément Foucault <foucault.clem@gmail.com>2022-09-02 20:37:15 +0300
commite48a6fcc6397e5a964f2096d937ac189f07ce999 (patch)
tree37f98d5dab5c869b7248fc65a35edfc1b618b531 /source/blender/draw/intern/draw_shader_shared.h
parent356460f5cf659ef071daa1267ab368b733b4133e (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/draw_shader_shared.h')
-rw-r--r--source/blender/draw/intern/draw_shader_shared.h24
1 files changed, 22 insertions, 2 deletions
diff --git a/source/blender/draw/intern/draw_shader_shared.h b/source/blender/draw/intern/draw_shader_shared.h
index 00d54311548..d43bfe6b159 100644
--- a/source/blender/draw/intern/draw_shader_shared.h
+++ b/source/blender/draw/intern/draw_shader_shared.h
@@ -13,6 +13,7 @@ typedef struct ObjectInfos ObjectInfos;
typedef struct ObjectBounds ObjectBounds;
typedef struct VolumeInfos VolumeInfos;
typedef struct CurvesInfos CurvesInfos;
+typedef struct ObjectAttribute ObjectAttribute;
typedef struct DrawCommand DrawCommand;
typedef struct DispatchCommand DispatchCommand;
typedef struct DRWDebugPrintBuffer DRWDebugPrintBuffer;
@@ -22,6 +23,8 @@ typedef struct DRWDebugDrawBuffer DRWDebugDrawBuffer;
# ifdef __cplusplus
/* C++ only forward declarations. */
struct Object;
+struct ID;
+struct GPUUniformAttr;
namespace blender::draw {
@@ -130,9 +133,9 @@ struct ObjectInfos {
#else
/** Uploaded as center + size. Converted to mul+bias to local coord. */
float3 orco_add;
- float _pad0;
+ uint object_attrs_offset;
float3 orco_mul;
- float _pad1;
+ uint object_attrs_len;
float4 color;
uint index;
@@ -193,6 +196,23 @@ struct CurvesInfos {
};
BLI_STATIC_ASSERT_ALIGN(CurvesInfos, 16)
+#pragma pack(push, 4)
+struct ObjectAttribute {
+ /* Workaround the padding cost from alignment requirements.
+ * (see GL spec : 7.6.2.2 Standard Uniform Block Layout) */
+ float data_x, data_y, data_z, data_w;
+ uint hash_code;
+
+#if !defined(GPU_SHADER) && defined(__cplusplus)
+ bool sync(const blender::draw::ObjectRef &ref, const GPUUniformAttr &attr);
+ bool id_property_lookup(ID *id, const char *name);
+#endif
+};
+#pragma pack(pop)
+/** \note we only align to 4 bytes and fetch data manually so make sure
+ * C++ compiler gives us the same size. */
+BLI_STATIC_ASSERT_ALIGN(ObjectAttribute, 20)
+
/** \} */
/* -------------------------------------------------------------------- */