mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 13:00:09 +01:00
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 <eocallaghan@alterapraxis.com>
This commit is contained in:
parent
2c1a215409
commit
0d4cd045c8
8 changed files with 15 additions and 19 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue