zink: use helper function to handle uvec/bvec types
bit_size of 1 means we use a bool type here, 32 means uint, so we can just handle that automatically for all relevant cases ref shaders@glsl-vs-continue-in-switch-in-do-while Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5911>
This commit is contained in:

committed by
Marge Bot

parent
7015d2c249
commit
6587f41e11
@@ -632,6 +632,17 @@ emit_uniform(struct ntv_context *ctx, struct nir_variable *var)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
static SpvId
|
||||||
get_src_ssa(struct ntv_context *ctx, const nir_ssa_def *ssa)
|
get_src_ssa(struct ntv_context *ctx, const nir_ssa_def *ssa)
|
||||||
{
|
{
|
||||||
@@ -656,7 +667,7 @@ get_src_reg(struct ntv_context *ctx, const nir_reg_src *reg)
|
|||||||
assert(!reg->base_offset);
|
assert(!reg->base_offset);
|
||||||
|
|
||||||
SpvId var = get_var_from_reg(ctx, reg->reg);
|
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);
|
return spirv_builder_emit_load(&ctx->builder, type, var);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1503,19 +1514,17 @@ emit_load_const(struct ntv_context *ctx, nir_load_const_instr *load_const)
|
|||||||
SpvId constant;
|
SpvId constant;
|
||||||
if (num_components > 1) {
|
if (num_components > 1) {
|
||||||
SpvId components[num_components];
|
SpvId components[num_components];
|
||||||
SpvId type;
|
SpvId type = get_vec_from_bit_size(ctx, bit_size, num_components);
|
||||||
if (bit_size == 1) {
|
if (bit_size == 1) {
|
||||||
for (int i = 0; i < num_components; i++)
|
for (int i = 0; i < num_components; i++)
|
||||||
components[i] = spirv_builder_const_bool(&ctx->builder,
|
components[i] = spirv_builder_const_bool(&ctx->builder,
|
||||||
load_const->value[i].b);
|
load_const->value[i].b);
|
||||||
|
|
||||||
type = get_bvec_type(ctx, num_components);
|
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < num_components; i++)
|
for (int i = 0; i < num_components; i++)
|
||||||
components[i] = emit_uint_const(ctx, bit_size,
|
components[i] = emit_uint_const(ctx, bit_size,
|
||||||
load_const->value[i].u32);
|
load_const->value[i].u32);
|
||||||
|
|
||||||
type = get_uvec_type(ctx, bit_size, num_components);
|
|
||||||
}
|
}
|
||||||
constant = spirv_builder_const_composite(&ctx->builder, type,
|
constant = spirv_builder_const_composite(&ctx->builder, type,
|
||||||
components, num_components);
|
components, num_components);
|
||||||
@@ -2302,7 +2311,7 @@ nir_to_spirv(struct nir_shader *s, const struct pipe_stream_output_info *so_info
|
|||||||
/* emit a block only for the variable declarations */
|
/* emit a block only for the variable declarations */
|
||||||
start_block(&ctx, spirv_builder_new_id(&ctx.builder));
|
start_block(&ctx, spirv_builder_new_id(&ctx.builder));
|
||||||
foreach_list_typed(nir_register, reg, node, &entry->registers) {
|
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,
|
SpvId pointer_type = spirv_builder_type_pointer(&ctx.builder,
|
||||||
SpvStorageClassFunction,
|
SpvStorageClassFunction,
|
||||||
type);
|
type);
|
||||||
|
Reference in New Issue
Block a user