summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Will <[email protected]>2018-01-05 15:33:31 +0100
committerJuan A. Suarez Romero <[email protected]>2018-01-12 21:38:10 +0100
commit2416223f1d7b6d23a3f4f6df4f9726bd12eab200 (patch)
tree52c2767a991449f048d1743b17ff5827b5d4a3d3
parent9a7ffd93c28e4e36fa02d4d707f55815c2e8c074 (diff)
glsl: Respect std430 layout in lower_buffer_access
Respect the std430 rules for determining offset and size of struct members when using a std430 buffer. std140 rules lead to wrong buffer offsets in that case. Fixes my test case attached in Bugzilla. No piglit changes. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104492 Reviewed-by: Timothy Arceri <[email protected]> (cherry picked from commit 7e025def6d7d3d6bf94facd6ec6d956f40cbb31e)
-rw-r--r--src/compiler/glsl/lower_buffer_access.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/compiler/glsl/lower_buffer_access.cpp b/src/compiler/glsl/lower_buffer_access.cpp
index caffaf9bfb2..7679c03d6c7 100644
--- a/src/compiler/glsl/lower_buffer_access.cpp
+++ b/src/compiler/glsl/lower_buffer_access.cpp
@@ -72,16 +72,22 @@ lower_buffer_access::emit_access(void *mem_ctx,
new(mem_ctx) ir_dereference_record(deref->clone(mem_ctx, NULL),
field->name);
- field_offset =
- glsl_align(field_offset,
- field->type->std140_base_alignment(row_major));
+ unsigned field_align;
+ if (packing == GLSL_INTERFACE_PACKING_STD430)
+ field_align = field->type->std430_base_alignment(row_major);
+ else
+ field_align = field->type->std140_base_alignment(row_major);
+ field_offset = glsl_align(field_offset, field_align);
emit_access(mem_ctx, is_write, field_deref, base_offset,
deref_offset + field_offset,
row_major, 1, packing,
writemask_for_size(field_deref->type->vector_elements));
- field_offset += field->type->std140_size(row_major);
+ if (packing == GLSL_INTERFACE_PACKING_STD430)
+ field_offset += field->type->std430_size(row_major);
+ else
+ field_offset += field->type->std140_size(row_major);
}
return;
}