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-06-11 14:09:04 +0300
committerClément Foucault <foucault.clem@gmail.com>2022-06-28 19:48:39 +0300
commite127182065a073235bac4158db6b6af1f36651c5 (patch)
tree01fb5e6efceb11f5e529f171ab260e931a5c788b
parent75ad435ceb63559a1443b618045e99b6ea90883f (diff)
DRW: Curve: Fix wrong UBO alignment
This was preventing correct attribute rendering with multiple attributes. Since the `CurveInfos` struct is used for data sharing between C++ and GLSL and inside a UBO it needs to obey the `std140` alignment rules which states that arrays of scalars are padded to the size of `vec4` for each array entry.
-rw-r--r--source/blender/draw/engines/eevee/shaders/shadow_vert.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/surface_vert.glsl2
-rw-r--r--source/blender/draw/engines/eevee_next/shaders/eevee_attributes_lib.glsl2
-rw-r--r--source/blender/draw/intern/draw_curves.cc2
-rw-r--r--source/blender/draw/intern/draw_shader_shared.h6
5 files changed, 7 insertions, 7 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/shadow_vert.glsl b/source/blender/draw/engines/eevee/shaders/shadow_vert.glsl
index 2926f8c5a89..57d70334651 100644
--- a/source/blender/draw/engines/eevee/shaders/shadow_vert.glsl
+++ b/source/blender/draw/engines/eevee/shaders/shadow_vert.glsl
@@ -73,7 +73,7 @@ int g_curves_attr_id = 0;
int curves_attribute_element_id()
{
int id = hairStrandID;
- if (drw_curves.is_point_attribute[g_curves_attr_id] != 0) {
+ if (drw_curves.is_point_attribute[g_curves_attr_id][0] != 0) {
id = hair_get_base_id();
}
diff --git a/source/blender/draw/engines/eevee/shaders/surface_vert.glsl b/source/blender/draw/engines/eevee/shaders/surface_vert.glsl
index a8e95e13b12..4a3a91b8534 100644
--- a/source/blender/draw/engines/eevee/shaders/surface_vert.glsl
+++ b/source/blender/draw/engines/eevee/shaders/surface_vert.glsl
@@ -80,7 +80,7 @@ int g_curves_attr_id = 0;
int curves_attribute_element_id()
{
int id = hairStrandID;
- if (drw_curves.is_point_attribute[g_curves_attr_id] != 0) {
+ if (drw_curves.is_point_attribute[g_curves_attr_id][0] != 0) {
id = hair_get_base_id();
}
diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_attributes_lib.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_attributes_lib.glsl
index a65bb7decb6..326481a1db6 100644
--- a/source/blender/draw/engines/eevee_next/shaders/eevee_attributes_lib.glsl
+++ b/source/blender/draw/engines/eevee_next/shaders/eevee_attributes_lib.glsl
@@ -131,7 +131,7 @@ int g_curves_attr_id = 0;
int curves_attribute_element_id()
{
int id = interp.curves_strand_id;
- if (drw_curves.is_point_attribute[g_curves_attr_id] != 0) {
+ if (drw_curves.is_point_attribute[g_curves_attr_id][0] != 0) {
# ifdef COMMON_HAIR_LIB
id = hair_get_base_id();
# endif
diff --git a/source/blender/draw/intern/draw_curves.cc b/source/blender/draw/intern/draw_curves.cc
index d040b4eade3..246f7c843ba 100644
--- a/source/blender/draw/intern/draw_curves.cc
+++ b/source/blender/draw/intern/draw_curves.cc
@@ -385,7 +385,7 @@ DRWShadingGroup *DRW_shgroup_curves_create_sub(Object *object,
* attributes. */
const int index = attribute_index_in_material(gpu_material, request.attribute_name);
if (index != -1) {
- curves_infos.is_point_attribute[index] = request.domain == ATTR_DOMAIN_POINT;
+ curves_infos.is_point_attribute[index][0] = request.domain == ATTR_DOMAIN_POINT;
}
}
diff --git a/source/blender/draw/intern/draw_shader_shared.h b/source/blender/draw/intern/draw_shader_shared.h
index 94c0c53dab7..e8944442607 100644
--- a/source/blender/draw/intern/draw_shader_shared.h
+++ b/source/blender/draw/intern/draw_shader_shared.h
@@ -87,9 +87,9 @@ BLI_STATIC_ASSERT_ALIGN(VolumeInfos, 16)
struct CurvesInfos {
/* Per attribute scope, follows loading order.
- * NOTE: uint as bool in GLSL is 4 bytes. */
- uint is_point_attribute[DRW_ATTRIBUTE_PER_CURVES_MAX];
- int _pad;
+ * NOTE: uint as bool in GLSL is 4 bytes.
+ * NOTE: GLSL pad arrays of scalar to 16 bytes (std140). */
+ uint4 is_point_attribute[DRW_ATTRIBUTE_PER_CURVES_MAX];
};
BLI_STATIC_ASSERT_ALIGN(CurvesInfos, 16)