summaryrefslogtreecommitdiff
path: root/src/compiler/spirv/vtn_variables.c
diff options
context:
space:
mode:
authorJason Ekstrand <jason.ekstrand@intel.com>2018-12-14 18:25:38 -0600
committerJason Ekstrand <jason@jlekstrand.net>2019-01-08 00:38:30 +0000
commit3a7c5667c83f3a3f820a28af0e428bdfd010bd28 (patch)
tree855f27573d9ffa3da48e6866d7546726fc27afe0 /src/compiler/spirv/vtn_variables.c
parentadc155a8156ee4df18c66bc44587a6880a70bdd7 (diff)
spirv: Make better use of vtn_pointer_uses_ssa_offset
The choice of whether or not we should use block_load/store isn't a choice between external and not so much as a choice between deref instructions and manually calculated offsets. In vtn_pointer_from_ssa, we guard the index+offset case behind vtn_pointer_uses_ssa_offset and then branch out from there. Reviewed-by: Alejandro PiƱeiro <apinheiro@igalia.com> Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Diffstat (limited to 'src/compiler/spirv/vtn_variables.c')
-rw-r--r--src/compiler/spirv/vtn_variables.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c
index 97d3be75ea3..4e984f03346 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -917,7 +917,7 @@ _vtn_variable_load_store(struct vtn_builder *b, bool load,
struct vtn_ssa_value *
vtn_variable_load(struct vtn_builder *b, struct vtn_pointer *src)
{
- if (vtn_pointer_is_external_block(b, src)) {
+ if (vtn_pointer_uses_ssa_offset(b, src)) {
return vtn_block_load(b, src);
} else {
struct vtn_ssa_value *val = NULL;
@@ -930,7 +930,7 @@ void
vtn_variable_store(struct vtn_builder *b, struct vtn_ssa_value *src,
struct vtn_pointer *dest)
{
- if (vtn_pointer_is_external_block(b, dest)) {
+ if (vtn_pointer_uses_ssa_offset(b, dest)) {
vtn_assert(dest->mode == vtn_variable_mode_ssbo ||
dest->mode == vtn_variable_mode_workgroup);
vtn_block_store(b, src, dest);
@@ -1625,21 +1625,19 @@ vtn_pointer_from_ssa(struct vtn_builder *b, nir_ssa_def *ssa,
ptr->type = ptr_type->deref;
ptr->ptr_type = ptr_type;
- if (ptr->mode == vtn_variable_mode_ubo ||
- ptr->mode == vtn_variable_mode_ssbo) {
- /* This pointer type needs to have actual storage */
- vtn_assert(ptr_type->type);
- vtn_assert(ssa->num_components == 2);
- ptr->block_index = nir_channel(&b->nb, ssa, 0);
- ptr->offset = nir_channel(&b->nb, ssa, 1);
- } else if ((ptr->mode == vtn_variable_mode_workgroup &&
- b->options->lower_workgroup_access_to_offsets) ||
- ptr->mode == vtn_variable_mode_push_constant) {
+ if (vtn_pointer_uses_ssa_offset(b, ptr)) {
/* This pointer type needs to have actual storage */
vtn_assert(ptr_type->type);
- vtn_assert(ssa->num_components == 1);
- ptr->block_index = NULL;
- ptr->offset = ssa;
+ if (ptr->mode == vtn_variable_mode_ubo ||
+ ptr->mode == vtn_variable_mode_ubo) {
+ vtn_assert(ssa->num_components == 2);
+ ptr->block_index = nir_channel(&b->nb, ssa, 0);
+ ptr->offset = nir_channel(&b->nb, ssa, 1);
+ } else {
+ vtn_assert(ssa->num_components == 1);
+ ptr->block_index = NULL;
+ ptr->offset = ssa;
+ }
} else {
assert(!vtn_pointer_is_external_block(b, ptr));
const struct glsl_type *deref_type = ptr_type->deref->type;