diff options
author | Timothy Arceri <[email protected]> | 2015-12-29 21:02:56 +1100 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2015-12-30 11:52:05 +1100 |
commit | 0d4cd045c8a74efd7d43ceb841bde43cc6eee65d (patch) | |
tree | 2f6ce86c230a934484b49b744d56aed59ac9bec8 /src/glsl | |
parent | 2c1a215409e6d5b3bc95854e17da2412a978e0c9 (diff) |
glsl: tidy up struct with a single member
There used to be more members but they now share other fields
in order to keep memory use low.
Also making the naming more generic will allow us to reuse the
field for explicit byte offsets within blocks for
ARB_enhanced_layouts.
Reviewed-by: Edward O'Callaghan <[email protected]>
Diffstat (limited to 'src/glsl')
-rw-r--r-- | src/glsl/ast_to_hir.cpp | 2 | ||||
-rw-r--r-- | src/glsl/ir.cpp | 2 | ||||
-rw-r--r-- | src/glsl/ir.h | 4 | ||||
-rw-r--r-- | src/glsl/link_atomics.cpp | 16 | ||||
-rw-r--r-- | src/glsl/linker.cpp | 2 | ||||
-rw-r--r-- | src/glsl/nir/glsl_to_nir.cpp | 2 | ||||
-rw-r--r-- | src/glsl/nir/nir.h | 4 | ||||
-rw-r--r-- | src/glsl/nir/nir_lower_atomics.c | 2 |
8 files changed, 15 insertions, 19 deletions
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index e1baadaf65f..dbf05ac9999 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -3105,7 +3105,7 @@ apply_layout_qualifier_to_variable(const struct ast_type_qualifier *qual, _mesa_glsl_error(loc, state, "misaligned atomic counter offset"); - var->data.atomic.offset = *offset; + var->data.offset = *offset; *offset += var->type->atomic_size(); } else { diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index 70227070ca7..d82bccd5d2f 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -1674,7 +1674,7 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name, this->data.mode = mode; this->data.interpolation = INTERP_QUALIFIER_NONE; this->data.max_array_access = 0; - this->data.atomic.offset = 0; + this->data.offset = 0; this->data.precision = GLSL_PRECISION_NONE; this->data.image_read_only = false; this->data.image_write_only = false; diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 159f94d9edd..c56c95994b8 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -871,9 +871,7 @@ public: /** * Location an atomic counter is stored at. */ - struct { - unsigned offset; - } atomic; + unsigned offset; /** * Highest element accessed with a constant expression array index diff --git a/src/glsl/link_atomics.cpp b/src/glsl/link_atomics.cpp index 3aa52dbd18a..277d4737ab7 100644 --- a/src/glsl/link_atomics.cpp +++ b/src/glsl/link_atomics.cpp @@ -83,16 +83,16 @@ namespace { const active_atomic_counter *const first = (active_atomic_counter *) a; const active_atomic_counter *const second = (active_atomic_counter *) b; - return int(first->var->data.atomic.offset) - int(second->var->data.atomic.offset); + return int(first->var->data.offset) - int(second->var->data.offset); } bool check_atomic_counters_overlap(const ir_variable *x, const ir_variable *y) { - return ((x->data.atomic.offset >= y->data.atomic.offset && - x->data.atomic.offset < y->data.atomic.offset + y->type->atomic_size()) || - (y->data.atomic.offset >= x->data.atomic.offset && - y->data.atomic.offset < x->data.atomic.offset + x->type->atomic_size())); + return ((x->data.offset >= y->data.offset && + x->data.offset < y->data.offset + y->type->atomic_size()) || + (y->data.offset >= x->data.offset && + y->data.offset < x->data.offset + x->type->atomic_size())); } void @@ -158,7 +158,7 @@ namespace { ir_variable *var = node->as_variable(); if (var && var->type->contains_atomic()) { - int offset = var->data.atomic.offset; + int offset = var->data.offset; unsigned uniform_loc = var->data.location; process_atomic_variable(var->type, prog, &uniform_loc, var, buffers, num_buffers, &offset, i); @@ -185,7 +185,7 @@ namespace { linker_error(prog, "Atomic counter %s declared at offset %d " "which is already in use.", buffers[i].counters[j].var->name, - buffers[i].counters[j].var->data.atomic.offset); + buffers[i].counters[j].var->data.offset); } } } @@ -237,7 +237,7 @@ link_assign_atomic_counter_resources(struct gl_context *ctx, var->data.binding = i; storage->atomic_buffer_index = i; - storage->offset = var->data.atomic.offset; + storage->offset = var->data.offset; storage->array_stride = (var->type->is_array() ? var->type->without_array()->atomic_size() : 0); if (!var->type->is_matrix()) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index c7e69765335..a6e81b41f3c 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1014,7 +1014,7 @@ cross_validate_globals(struct gl_shader_program *prog, } if (var->type->contains_atomic() && - var->data.atomic.offset != existing->data.atomic.offset) { + var->data.offset != existing->data.offset) { linker_error(prog, "offset specifications for %s " "`%s' have differing values\n", mode_string(var), var->name); diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp index 0d1d0f4e282..12efb4419b2 100644 --- a/src/glsl/nir/glsl_to_nir.cpp +++ b/src/glsl/nir/glsl_to_nir.cpp @@ -389,7 +389,7 @@ nir_visitor::visit(ir_variable *ir) var->data.index = ir->data.index; var->data.binding = ir->data.binding; - var->data.atomic.offset = ir->data.atomic.offset; + var->data.offset = ir->data.offset; var->data.image.read_only = ir->data.image_read_only; var->data.image.write_only = ir->data.image_write_only; var->data.image.coherent = ir->data.image_coherent; diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h index 562c5c5cc8c..a8972ac6ad5 100644 --- a/src/glsl/nir/nir.h +++ b/src/glsl/nir/nir.h @@ -291,9 +291,7 @@ typedef struct { /** * Location an atomic counter is stored at. */ - struct { - unsigned offset; - } atomic; + unsigned offset; /** * ARB_shader_image_load_store qualifiers. diff --git a/src/glsl/nir/nir_lower_atomics.c b/src/glsl/nir/nir_lower_atomics.c index 259c154149b..1aa78e18a85 100644 --- a/src/glsl/nir/nir_lower_atomics.c +++ b/src/glsl/nir/nir_lower_atomics.c @@ -74,7 +74,7 @@ lower_instr(nir_intrinsic_instr *instr, state->shader_program->UniformStorage[uniform_loc].opaque[state->shader->stage].index; nir_load_const_instr *offset_const = nir_load_const_instr_create(mem_ctx, 1); - offset_const->value.u[0] = instr->variables[0]->var->data.atomic.offset; + offset_const->value.u[0] = instr->variables[0]->var->data.offset; nir_instr_insert_before(&instr->instr, &offset_const->instr); |