From e45f8434e328123dcadf2adacec88ca5b032b1cc Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Tue, 20 Apr 2021 21:46:53 +0300 Subject: [PATCH] spirv: fixup pointer_to/from_ssa with acceleration structures Signed-off-by: Lionel Landwerlin Fixes: ed907e5d84cba4 ("spirv: Add support for OpTypeAccelerationStructureKHR") Reviewed-by: Jason Ekstrand Part-of: (cherry picked from commit 0bb29c07a4fd262db891005897b0662720ddbccf) --- .pick_status.json | 2 +- src/compiler/spirv/vtn_variables.c | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 8ad51510d99..0dce17196ae 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -427,7 +427,7 @@ "description": "spirv: fixup pointer_to/from_ssa with acceleration structures", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "master_sha": null, "because_sha": "ed907e5d84cba4632320bad4dfc35462ca0dd927" }, diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c index b98cc767664..4df95baaa9e 100644 --- a/src/compiler/spirv/vtn_variables.c +++ b/src/compiler/spirv/vtn_variables.c @@ -1590,9 +1590,10 @@ vtn_mode_to_address_format(struct vtn_builder *b, enum vtn_variable_mode mode) nir_ssa_def * vtn_pointer_to_ssa(struct vtn_builder *b, struct vtn_pointer *ptr) { - if (vtn_pointer_is_external_block(b, ptr) && - vtn_type_contains_block(b, ptr->type) && - ptr->mode != vtn_variable_mode_phys_ssbo) { + if ((vtn_pointer_is_external_block(b, ptr) && + vtn_type_contains_block(b, ptr->type) && + ptr->mode != vtn_variable_mode_phys_ssbo) || + ptr->mode == vtn_variable_mode_accel_struct) { /* In this case, we're looking for a block index and not an actual * deref. * @@ -1641,11 +1642,13 @@ vtn_pointer_from_ssa(struct vtn_builder *b, nir_ssa_def *ssa, const struct glsl_type *deref_type = vtn_type_get_nir_type(b, ptr_type->deref, ptr->mode); - if (!vtn_pointer_is_external_block(b, ptr)) { + if (!vtn_pointer_is_external_block(b, ptr) && + ptr->mode != vtn_variable_mode_accel_struct) { ptr->deref = nir_build_deref_cast(&b->nb, ssa, nir_mode, deref_type, ptr_type->stride); - } else if (vtn_type_contains_block(b, ptr->type) && - ptr->mode != vtn_variable_mode_phys_ssbo) { + } else if ((vtn_type_contains_block(b, ptr->type) && + ptr->mode != vtn_variable_mode_phys_ssbo) || + ptr->mode == vtn_variable_mode_accel_struct) { /* This is a pointer to somewhere in an array of blocks, not a * pointer to somewhere inside the block. Set the block index * instead of making a cast.