diff options
author | Erik Faye-Lund <[email protected]> | 2019-07-19 16:12:57 +0200 |
---|---|---|
committer | Erik Faye-Lund <[email protected]> | 2019-10-28 08:51:47 +0000 |
commit | 3ceba2d312d1f6f3ffcb9547fdf2b1f511a5fe6c (patch) | |
tree | 7ada94c70b13ceb35f40ec4ac51ee12514c54913 /src/gallium | |
parent | 20f6b19fdf482dab5236bbbbfa9264831085f65c (diff) |
zink/spirv: inline get_uvec_constant into emit_load_const
This is the only call-site that wants to specify unique values per
component for any of the get_*_constant functions. So let's give this
its own implementation instead, so we can ease the burden for the rest.
Acked-by: Jordan Justen <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c | 20 |
1 files changed, 17 insertions, 3 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 27356f9bf13..c46ec895625 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 @@ -1007,9 +1007,23 @@ emit_load_const(struct ntv_context *ctx, nir_load_const_instr *load_const) for (int i = 0; i < load_const->def.num_components; ++i) values[i] = load_const->value[i].u32; - SpvId constant = get_uvec_constant(ctx, load_const->def.bit_size, - load_const->def.num_components, - values); + unsigned bit_size = load_const->def.bit_size; + unsigned num_components = load_const->def.num_components; + + 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, values[i]); + + SpvId 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, values[0]); + } + store_ssa_def_uint(ctx, &load_const->def, constant); } |