summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJason Ekstrand <jason@jlekstrand.net>2017-10-19 11:04:07 -0700
committerChad Versace <chadversary@chromium.org>2017-11-30 23:37:08 +0000
commited61e74c4d94f0bcec10a43fdf56427db053cab9 (patch)
treef3c19e7ce2f33e5e94c58dbdf545a2354babbe29 /src
parent8142ac25cc2104830ee976e2d256c32e2c7a9210 (diff)
FROMLIST: spirv: Refactor the base case of offset_pointer_dereference
This makes us key off of !offset instead of !block_index. It also puts the guts inside a switch statement so that we can handle more than just UBOs and SSBOs. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Archived-At: https://lists.freedesktop.org/archives/mesa-dev/2017-October/173533.html (am from https://patchwork.freedesktop.org/patch/183824) Needed for SPIR-V VariablePointers capability. BUG=b:68708929 TEST=No regressions on Eve in `cts-tradefed run cts -m CtsDeqpTestCases`. Change-Id: I5ec31e019875613ac192383b264bb08e0318ca60 Reviewed-on: https://chromium-review.googlesource.com/799674 Tested-by: Chad Versace <chadversary@chromium.org> Reviewed-by: Kristian H. Kristensen <hoegsberg@chromium.org> Commit-Queue: Kristian H. Kristensen <hoegsberg@chromium.org>
Diffstat (limited to 'src')
-rw-r--r--src/compiler/spirv/vtn_variables.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c
index a406adfb2be..a92ac44eade 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -161,24 +161,32 @@ vtn_ssa_offset_pointer_dereference(struct vtn_builder *b,
idx++;
}
- if (!block_index) {
+ if (!offset) {
+ /* This is the first access chain so we don't have a block index */
+ assert(!block_index);
+
assert(base->var);
- if (glsl_type_is_array(type->type)) {
- /* We need at least one element in the chain */
- assert(deref_chain->length >= 1);
+ switch (base->mode) {
+ case vtn_variable_mode_ubo:
+ case vtn_variable_mode_ssbo:
+ if (glsl_type_is_array(type->type)) {
+ /* We need at least one element in the chain */
+ assert(deref_chain->length >= 1);
+
+ nir_ssa_def *desc_arr_idx =
+ vtn_access_link_as_ssa(b, deref_chain->link[0], 1);
+ block_index = vtn_variable_resource_index(b, base->var, desc_arr_idx);
+ type = type->array_element;
+ idx++;
+ } else {
+ block_index = vtn_variable_resource_index(b, base->var, NULL);
+ }
+ offset = nir_imm_int(&b->nb, 0);
+ break;
- nir_ssa_def *desc_arr_idx =
- vtn_access_link_as_ssa(b, deref_chain->link[0], 1);
- block_index = vtn_variable_resource_index(b, base->var, desc_arr_idx);
- type = type->array_element;
- idx++;
- } else {
- block_index = vtn_variable_resource_index(b, base->var, NULL);
+ default:
+ unreachable("Invalid offset pointer mode");
}
-
- /* This is the first access chain so we also need an offset */
- assert(!offset);
- offset = nir_imm_int(&b->nb, 0);
}
assert(offset);