zink: Re-emit the SpvBuiltInSampleMask access chain each load.

Otherwise, the access chain you emitted last time may not dominate the
current use.

Fixes the following validation failure in
dEQP-GLES31.functional.shaders.sample_variables.sample_mask_in.bits_unique_per_sample.multisample_texture_2:

  UNASSIGNED-CoreValidation-Shader-InconsistentSpirv(ERROR / SPEC):
  msgNum: 7060244 - Validation Error: [
  UNASSIGNED-CoreValidation-Shader-InconsistentSpirv ] Object 0: handle =
  0x55cf3cea2c60, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x6bbb14 |
  SPIR-V module not valid: ID '67[%67]' defined in block '23[%23]' does
  not dominate its use in block '31[%31]'

Fixes: 8899f6a198 ("zink: fix gl_SampleMaskIn spirv generation")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20756>
(cherry picked from commit 4286633eec)
This commit is contained in:
Emma Anholt 2023-01-18 16:59:11 -08:00 committed by Dylan Baker
parent 06072d3bb5
commit e3ec2e2ea9
2 changed files with 12 additions and 10 deletions

View file

@ -913,7 +913,7 @@
"description": "zink: Re-emit the SpvBuiltInSampleMask access chain each load.",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "8899f6a19857d533d62945889c413b55cea5223c"
},

View file

@ -2779,17 +2779,19 @@ emit_load_uint_input(struct ntv_context *ctx, nir_intrinsic_instr *intr, SpvId *
SpvStorageClassInput,
var_name,
builtin);
if (builtin == SpvBuiltInSampleMask) {
SpvId zero = emit_uint_const(ctx, 32, 0);
var_type = spirv_builder_type_uint(&ctx->builder, 32);
SpvId pointer_type = spirv_builder_type_pointer(&ctx->builder,
SpvStorageClassInput,
var_type);
*var_id = spirv_builder_emit_access_chain(&ctx->builder, pointer_type, *var_id, &zero, 1);
}
}
SpvId result = spirv_builder_emit_load(&ctx->builder, var_type, *var_id);
SpvId load_var = *var_id;
if (builtin == SpvBuiltInSampleMask) {
SpvId zero = emit_uint_const(ctx, 32, 0);
var_type = spirv_builder_type_uint(&ctx->builder, 32);
SpvId pointer_type = spirv_builder_type_pointer(&ctx->builder,
SpvStorageClassInput,
var_type);
load_var = spirv_builder_emit_access_chain(&ctx->builder, pointer_type, load_var, &zero, 1);
}
SpvId result = spirv_builder_emit_load(&ctx->builder, var_type, load_var);
assert(1 == nir_dest_num_components(intr->dest));
store_dest(ctx, &intr->dest, result, nir_type_uint);
}