Commit f0ebc56c authored by Boris Brezillon's avatar Boris Brezillon
Browse files

spirv: Propagate packed information to glsl_type



We need to parse the CPacked decoration early enough to apply it when
calculating field offsets and creating the struct type.
Signed-off-by: Boris Brezillon's avatarBoris Brezillon <boris.brezillon@collabora.com>
parent f7dd66dd
......@@ -930,6 +930,15 @@ struct_member_matrix_stride_cb(struct vtn_builder *b,
ctx->fields[member].type = ctx->type->members[member]->type;
}
static void
struct_packed_decoration_cb(struct vtn_builder *b,
struct vtn_value *val, int member,
const struct vtn_decoration *dec, void *void_ctx)
{
if (dec->decoration == SpvDecorationCPacked)
val->type->packed = true;
}
static void
struct_block_decoration_cb(struct vtn_builder *b,
struct vtn_value *val, int member,
......@@ -1028,11 +1037,11 @@ type_decoration_cb(struct vtn_builder *b,
break;
case SpvDecorationCPacked:
vtn_assert(type->base_type == vtn_base_type_struct);
vtn_assert(type->packed);
if (b->shader->info.stage != MESA_SHADER_KERNEL)
vtn_warn("Decoration only allowed for CL-style kernels: %s",
spirv_decoration_to_string(dec->decoration));
else
type->packed = true;
break;
case SpvDecorationSaturatedConversion:
......@@ -1254,10 +1263,14 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode,
};
}
vtn_foreach_decoration(b, val, struct_packed_decoration_cb, NULL);
if (b->shader->info.stage == MESA_SHADER_KERNEL) {
unsigned offset = 0;
for (unsigned i = 0; i < num_fields; i++) {
offset = align(offset, glsl_get_cl_alignment(fields[i].type));
offset = align(offset,
val->type->packed ?
1 : glsl_get_cl_alignment(fields[i].type));
fields[i].offset = offset;
offset += glsl_get_cl_size(fields[i].type);
}
......@@ -1285,7 +1298,8 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode,
name ? name : "block");
} else {
val->type->type = glsl_struct_type(fields, num_fields,
name ? name : "struct", false);
name ? name : "struct",
val->type->packed);
}
break;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment