}
}
+static SpvId
+get_vec_from_bit_size(struct ntv_context *ctx, uint32_t bit_size, uint32_t num_components)
+{
+ if (bit_size == 1)
+ return get_bvec_type(ctx, num_components);
+ if (bit_size == 32)
+ return get_uvec_type(ctx, bit_size, num_components);
+ unreachable("unhandled register bit size");
+ return 0;
+}
+
static SpvId
get_src_ssa(struct ntv_context *ctx, const nir_ssa_def *ssa)
{
assert(!reg->base_offset);
SpvId var = get_var_from_reg(ctx, reg->reg);
- SpvId type = get_uvec_type(ctx, reg->reg->bit_size, reg->reg->num_components);
+ SpvId type = get_vec_from_bit_size(ctx, reg->reg->bit_size, reg->reg->num_components);
return spirv_builder_emit_load(&ctx->builder, type, var);
}
SpvId constant;
if (num_components > 1) {
SpvId components[num_components];
- SpvId type;
+ SpvId type = get_vec_from_bit_size(ctx, bit_size, num_components);
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);
- 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);
/* emit a block only for the variable declarations */
start_block(&ctx, spirv_builder_new_id(&ctx.builder));
foreach_list_typed(nir_register, reg, node, &entry->registers) {
- SpvId type = get_uvec_type(&ctx, reg->bit_size, reg->num_components);
+ SpvId type = get_vec_from_bit_size(&ctx, reg->bit_size, reg->num_components);
SpvId pointer_type = spirv_builder_type_pointer(&ctx.builder,
SpvStorageClassFunction,
type);