diff options
author | Erik Faye-Lund <[email protected]> | 2019-07-19 17:35:27 +0200 |
---|---|---|
committer | Erik Faye-Lund <[email protected]> | 2019-10-28 08:51:47 +0000 |
commit | a046957a79c78ecdcfe1db844bde28bf9862ccbf (patch) | |
tree | 82a242f2faa63d23a5da6f1766255be86519c21e | |
parent | b28156413f9aec9207bfa185376e92fae43138c8 (diff) |
zink/spirv: fixup b2i32
Acked-by: Jordan Justen <[email protected]>
-rw-r--r-- | src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c | 35 |
1 files changed, 33 insertions, 2 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 0f5e9d4f9f1..3e4612fe1a9 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 @@ -67,6 +67,10 @@ get_uvec_constant(struct ntv_context *ctx, unsigned bit_size, unsigned num_components, uint32_t value); static SpvId +get_ivec_constant(struct ntv_context *ctx, unsigned bit_size, + unsigned num_components, int32_t value); + +static SpvId emit_unop(struct ntv_context *ctx, SpvOp op, SpvId type, SpvId src); static SpvId @@ -111,6 +115,13 @@ emit_uint_const(struct ntv_context *ctx, int bit_size, uint32_t value) } static SpvId +emit_int_const(struct ntv_context *ctx, int bit_size, int32_t value) +{ + assert(bit_size == 32); + return spirv_builder_const_int(&ctx->builder, bit_size, value); +} + +static SpvId get_fvec_type(struct ntv_context *ctx, unsigned bit_size, unsigned num_components) { assert(bit_size == 32); // only 32-bit floats supported so far @@ -719,6 +730,26 @@ get_uvec_constant(struct ntv_context *ctx, unsigned bit_size, num_components); } +static SpvId +get_ivec_constant(struct ntv_context *ctx, unsigned bit_size, + unsigned num_components, int32_t value) +{ + assert(bit_size == 32); + + SpvId result = emit_int_const(ctx, bit_size, value); + if (num_components == 1) + return result; + + assert(num_components > 1); + SpvId components[num_components]; + for (int i = 0; i < num_components; i++) + components[i] = result; + + SpvId type = get_ivec_type(ctx, bit_size, num_components); + return spirv_builder_const_composite(&ctx->builder, type, components, + num_components); +} + static inline unsigned alu_instr_src_components(const nir_alu_instr *instr, unsigned src) { @@ -829,8 +860,8 @@ emit_alu(struct ntv_context *ctx, nir_alu_instr *alu) case nir_op_b2i32: assert(nir_op_infos[alu->op].num_inputs == 1); result = emit_select(ctx, dest_type, src[0], - get_uvec_constant(ctx, 32, num_components, 1), - get_uvec_constant(ctx, 32, num_components, 0)); + get_ivec_constant(ctx, 32, num_components, 1), + get_ivec_constant(ctx, 32, num_components, 0)); break; case nir_op_b2f32: |