Commit 5a571633 authored by Caio Marcelo de Oliveira Filho's avatar Caio Marcelo de Oliveira Filho
Browse files

spirv: Use nir_deref_type_null for OpConstantNull

Use for SSBOs and shared memory, which will exercise the two main
codepaths we have for I/O lowering.
parent 92e9d5e2
Pipeline #34131 passed with stages
in 7 minutes and 9 seconds
......@@ -294,6 +294,35 @@ vtn_const_ssa_value(struct vtn_builder *b, nir_constant *constant,
return val;
}
static struct vtn_ssa_value *
vtn_ssa_null_pointer(struct vtn_builder *b, struct vtn_value *val)
{
nir_variable_mode nir_mode;
bool lower_to_offsets;
if (val->type->storage_class == SpvStorageClassStorageBuffer) {
nir_mode = nir_var_mem_ssbo;
lower_to_offsets = b->options->lower_ubo_ssbo_access_to_offsets;
} else {
assert(val->type->storage_class == SpvStorageClassWorkgroup);
nir_mode = nir_var_mem_shared;
lower_to_offsets = b->options->lower_workgroup_access_to_offsets;
}
struct vtn_ssa_value *ssa = rzalloc(b, struct vtn_ssa_value);
ssa->type = val->type->type;
if (lower_to_offsets) {
ssa->def = nir_imm_int(&b->nb, -1);
} else {
nir_deref_instr *deref =
nir_build_deref_null(&b->nb, nir_mode, val->type->type);
ssa->def = &deref->dest.ssa;
}
return ssa;
}
struct vtn_ssa_value *
vtn_ssa_value(struct vtn_builder *b, uint32_t value_id)
{
......@@ -302,8 +331,15 @@ vtn_ssa_value(struct vtn_builder *b, uint32_t value_id)
case vtn_value_type_undef:
return vtn_undef_ssa_value(b, val->type->type);
case vtn_value_type_constant:
return vtn_const_ssa_value(b, val->constant, val->type->type);
case vtn_value_type_constant: {
if (val->type->base_type == vtn_base_type_pointer &&
(val->type->storage_class == SpvStorageClassStorageBuffer ||
val->type->storage_class == SpvStorageClassWorkgroup)) {
return vtn_ssa_null_pointer(b, val);
} else {
return vtn_const_ssa_value(b, val->constant, val->type->type);
}
}
case vtn_value_type_ssa:
return val->ssa;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment