[Mesa-dev] [PATCH v2 05/28] spirv/nir: include SPIR-V explicit offset on the glsl struct type

Alejandro PiƱeiro apinheiro at igalia.com
Thu Sep 27 09:51:44 UTC 2018

>From ARB_gl_spirv spec:
   "Mapping of layouts

     std140/std430 -> explicit *Offset*, *ArrayStride*, and
                      *MatrixStride* Decoration on struct members"

   "A variable in the *Uniform* Storage Class decorated as a *Block*
    must be explicitly laid out using the *Offset*, *ArrayStride*, and
    *MatrixStride* decorations. If the variable is decorated as a
    *BufferBlock*, its offsets and strides must not contradict std430
    alignment and minimum offset requirements."

So for uniform blocks, we need the explicit offset coming from the
SPIR-V shader.
 src/compiler/spirv/spirv_to_nir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index 96224354057..15a3e8cce9a 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -716,7 +716,7 @@ struct_member_decoration_cb(struct vtn_builder *b,
       ctx->type->builtin_block = true;
    case SpvDecorationOffset:
-      ctx->type->offsets[member] = dec->literals[0];
+      ctx->type->offsets[member] = ctx->fields[member].offset = dec->literals[0];
    case SpvDecorationMatrixStride:
       /* Handled as a second pass */

More information about the mesa-dev mailing list