summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaio Marcelo de Oliveira Filho <[email protected]>2019-05-01 15:57:40 -0700
committerCaio Marcelo de Oliveira Filho <[email protected]>2019-05-20 10:53:38 -0700
commit7e5723d6d7631604116b3cef4ab571200e1820d4 (patch)
tree5a403386403816099a42d1411698f61a6bb9fb36
parent83550b7dc437f496eea090b938d3ba599c0db016 (diff)
spirv: Generate proper NULL pointer values
Use the storage class address format information to pick the right constant values for a NULL pointer. v2: Don't add a deref_cast to the values. (Jason) v3: Update to use vtn_storage_class_to_mode() and vtn_mode_to_address_format() explicitly. (Jason) Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Bas Nieuwenhuizen <[email protected]>
-rw-r--r--src/compiler/spirv/spirv_to_nir.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index 720999b9286..743f8ba8fb9 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -1532,15 +1532,23 @@ vtn_null_constant(struct vtn_builder *b, struct vtn_type *type)
/* Nothing to do here. It's already initialized to zero */
break;
- case vtn_base_type_pointer:
+ case vtn_base_type_pointer: {
+ enum vtn_variable_mode mode = vtn_storage_class_to_mode(
+ b, type->storage_class, type->deref, NULL);
+ nir_address_format addr_format = vtn_mode_to_address_format(b, mode);
+
+ const nir_const_value *null_value = nir_address_format_null_value(addr_format);
+ memcpy(c->values[0], null_value,
+ sizeof(nir_const_value) * nir_address_format_num_components(addr_format));
+ break;
+ }
+
case vtn_base_type_void:
case vtn_base_type_image:
case vtn_base_type_sampler:
case vtn_base_type_sampled_image:
case vtn_base_type_function:
- /* For pointers and other things, we have to return something but it
- * doesn't matter what.
- */
+ /* For those we have to return something but it doesn't matter what. */
break;
case vtn_base_type_matrix: