zink: fix invalid Offset set for variables which do not need an offset

Offset decoration in spirv is unsigned and it does not have a notion of an invalid offset.
Unlike NIR which set -1 for invlaid offset. This translates to invalid spirv being produced.
Instead, just don't emit an Offset decoration.

Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18910>
(cherry picked from commit b87c08b3bf)
This commit is contained in:
SoroushIMG
2022-07-19 13:25:02 +01:00
committed by Dylan Baker
parent 40d73e5c7f
commit 07734660ad
2 changed files with 6 additions and 3 deletions

View File

@@ -175,7 +175,7 @@
"description": "zink: fix invalid Offset set for variables which do not need an offset",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null
},

View File

@@ -445,8 +445,11 @@ get_glsl_type(struct ntv_context *ctx, const struct glsl_type *type)
types[i] = get_glsl_type(ctx, glsl_get_struct_field(type, i));
ret = spirv_builder_type_struct(&ctx->builder, types,
glsl_get_length(type));
for (unsigned i = 0; i < glsl_get_length(type); i++)
spirv_builder_emit_member_offset(&ctx->builder, ret, i, glsl_get_struct_field_offset(type, i));
for (unsigned i = 0; i < glsl_get_length(type); i++) {
int32_t offset = glsl_get_struct_field_offset(type, i);
if (offset >= 0)
spirv_builder_emit_member_offset(&ctx->builder, ret, i, offset);
}
} else
unreachable("Unhandled GLSL type");