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

Alejandro PiƱeiro apinheiro at igalia.com
Mon Oct 22 12:24:27 UTC 2018


>From ARB_gl_spirv spec:
   "Mapping of layouts

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

   "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 37a801037b9..28f4716b40e 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -734,7 +734,7 @@ struct_member_decoration_cb(struct vtn_builder *b,
       ctx->type->builtin_block = true;
       break;
    case SpvDecorationOffset:
-      ctx->type->offsets[member] = dec->literals[0];
+      ctx->type->offsets[member] = ctx->fields[member].offset = dec->literals[0];
       break;
    case SpvDecorationMatrixStride:
       /* Handled as a second pass */
-- 
2.14.1



More information about the mesa-dev mailing list