From 4e0ca477d868c8cbb62cbe4d030fd0a2f739e3b6 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Wed, 30 Oct 2019 15:37:42 +0100 Subject: [PATCH] zink/spirv: support loading bool constants Seems I missed this before; let's add support for this. --- .../drivers/zink/nir_to_spirv/nir_to_spirv.c | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c index b72c731dd85..47d93efc910 100644 --- a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c +++ b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c @@ -1058,18 +1058,34 @@ emit_load_const(struct ntv_context *ctx, nir_load_const_instr *load_const) SpvId constant; if (num_components > 1) { SpvId components[num_components]; - for (int i = 0; i < num_components; i++) - components[i] = emit_uint_const(ctx, bit_size, - load_const->value[i].u32); + SpvId type; + if (bit_size == 1) { + for (int i = 0; i < num_components; i++) + components[i] = spirv_builder_const_bool(&ctx->builder, + load_const->value[i].b); - SpvId type = get_uvec_type(ctx, bit_size, num_components); + type = get_bvec_type(ctx, num_components); + } else { + for (int i = 0; i < num_components; i++) + components[i] = emit_uint_const(ctx, bit_size, + load_const->value[i].u32); + + type = get_uvec_type(ctx, bit_size, num_components); + } constant = spirv_builder_const_composite(&ctx->builder, type, components, num_components); } else { assert(num_components == 1); - constant = emit_uint_const(ctx, bit_size, load_const->value[0].u32); + if (bit_size == 1) + constant = spirv_builder_const_bool(&ctx->builder, + load_const->value[0].b); + else + constant = emit_uint_const(ctx, bit_size, load_const->value[0].u32); } + if (bit_size == 1) + constant = bvec_to_uvec(ctx, constant, num_components); + store_ssa_def_uint(ctx, &load_const->def, constant); } -- 2.30.2