nir: deref only for OpTypePointer

Fixes dEQP-VK.binding_model.buffer_device_address.* and
dEQP-VK.ssbo.phys.layout* Vulkan CTS tests.

v2: set val->type->stride in the section below (Jason)

v3: restore val->type->type to original place (Jason)

Fixes: d0ba326f23 ("nir/spirv: support physical pointers")
CC: Karol Herbst <kherbst@redhat.com>
CC: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:
Juan A. Suarez Romero 2019-03-20 19:20:27 +00:00
parent 04189565a0
commit efcf9c9f9f
1 changed files with 14 additions and 8 deletions

View File

@ -1319,7 +1319,6 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode,
* declaration.
*/
val = vtn_untyped_value(b, w[1]);
struct vtn_type *deref_type = vtn_untyped_value(b, w[3])->type;
SpvStorageClass storage_class = w[2];
@ -1348,19 +1347,13 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode,
break;
case SpvStorageClassWorkgroup:
val->type->type = b->options->shared_ptr_type;
if (b->physical_ptrs)
val->type->stride = align(glsl_get_cl_size(deref_type->type), glsl_get_cl_alignment(deref_type->type));
break;
case SpvStorageClassCrossWorkgroup:
val->type->type = b->options->global_ptr_type;
if (b->physical_ptrs)
val->type->stride = align(glsl_get_cl_size(deref_type->type), glsl_get_cl_alignment(deref_type->type));
break;
case SpvStorageClassFunction:
if (b->physical_ptrs) {
if (b->physical_ptrs)
val->type->type = b->options->temp_ptr_type;
val->type->stride = align(glsl_get_cl_size(deref_type->type), glsl_get_cl_alignment(deref_type->type));
}
break;
default:
/* In this case, no variable pointers are allowed so all deref
@ -1386,6 +1379,19 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode,
vtn_foreach_decoration(b, val, array_stride_decoration_cb, NULL);
if (b->physical_ptrs) {
switch (storage_class) {
case SpvStorageClassFunction:
case SpvStorageClassWorkgroup:
case SpvStorageClassCrossWorkgroup:
val->type->stride = align(glsl_get_cl_size(val->type->deref->type),
glsl_get_cl_alignment(val->type->deref->type));
break;
default:
break;
}
}
if (storage_class == SpvStorageClassWorkgroup &&
b->options->lower_workgroup_access_to_offsets) {
uint32_t size, align;