glsl: use enum glsl_interface_packing in more places. (v2)
Although the glsl_types.h stores this in a bitfield, we should hide that from everyone else. Hide the cast in an accessor method and use the enum everywhere. This makes things a bit nicer in gdb, and improves type safety. v2: fix a few pieces of interface I missed that caused some piglit regressions. Signed-off-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
This commit is contained in:
parent
ff2e569153
commit
78659ade40
|
@ -537,6 +537,10 @@ public:
|
|||
return this->interface_type;
|
||||
}
|
||||
|
||||
enum glsl_interface_packing get_interface_type_packing() const
|
||||
{
|
||||
return this->interface_type->get_interface_packing();
|
||||
}
|
||||
/**
|
||||
* Get the max_ifc_array_access pointer
|
||||
*
|
||||
|
|
|
@ -167,8 +167,7 @@ link_uniform_block_active_visitor::visit(ir_variable *var)
|
|||
* also considered active, even if no member of the block is
|
||||
* referenced."
|
||||
*/
|
||||
if (var->get_interface_type()->interface_packing ==
|
||||
GLSL_INTERFACE_PACKING_PACKED)
|
||||
if (var->get_interface_type_packing() == GLSL_INTERFACE_PACKING_PACKED)
|
||||
return visit_continue;
|
||||
|
||||
/* Process the block. Bail if there was an error.
|
||||
|
@ -258,8 +257,7 @@ link_uniform_block_active_visitor::visit_enter(ir_dereference_array *ir)
|
|||
* std140 layout qualifier, all its instances have been already marked
|
||||
* as used in link_uniform_block_active_visitor::visit(ir_variable *).
|
||||
*/
|
||||
if (var->get_interface_type()->interface_packing ==
|
||||
GLSL_INTERFACE_PACKING_PACKED) {
|
||||
if (var->get_interface_type_packing() == GLSL_INTERFACE_PACKING_PACKED) {
|
||||
b->var = var;
|
||||
process_arrays(this->mem_ctx, ir, b);
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ private:
|
|||
}
|
||||
|
||||
virtual void enter_record(const glsl_type *type, const char *,
|
||||
bool row_major, const unsigned packing) {
|
||||
bool row_major, const enum glsl_interface_packing packing) {
|
||||
assert(type->is_record());
|
||||
if (packing == GLSL_INTERFACE_PACKING_STD430)
|
||||
this->offset = glsl_align(
|
||||
|
@ -81,7 +81,7 @@ private:
|
|||
}
|
||||
|
||||
virtual void leave_record(const glsl_type *type, const char *,
|
||||
bool row_major, const unsigned packing) {
|
||||
bool row_major, const enum glsl_interface_packing packing) {
|
||||
assert(type->is_record());
|
||||
|
||||
/* If this is the last field of a structure, apply rule #9. The
|
||||
|
@ -106,7 +106,7 @@ private:
|
|||
|
||||
virtual void visit_field(const glsl_type *type, const char *name,
|
||||
bool row_major, const glsl_type *,
|
||||
const unsigned packing,
|
||||
const enum glsl_interface_packing packing,
|
||||
bool last_field)
|
||||
{
|
||||
assert(this->index < this->num_variables);
|
||||
|
|
|
@ -65,7 +65,7 @@ program_resource_visitor::process(const glsl_type *type, const char *name)
|
|||
|
||||
unsigned record_array_count = 1;
|
||||
char *name_copy = ralloc_strdup(NULL, name);
|
||||
unsigned packing = type->interface_packing;
|
||||
enum glsl_interface_packing packing = type->get_interface_packing();
|
||||
|
||||
recursion(type, &name_copy, strlen(name), false, NULL, packing, false,
|
||||
record_array_count, NULL);
|
||||
|
@ -79,9 +79,9 @@ program_resource_visitor::process(ir_variable *var)
|
|||
const bool row_major =
|
||||
var->data.matrix_layout == GLSL_MATRIX_LAYOUT_ROW_MAJOR;
|
||||
|
||||
const unsigned packing = var->get_interface_type() ?
|
||||
var->get_interface_type()->interface_packing :
|
||||
var->type->interface_packing;
|
||||
const enum glsl_interface_packing packing = var->get_interface_type() ?
|
||||
var->get_interface_type_packing() :
|
||||
var->type->get_interface_packing();
|
||||
|
||||
const glsl_type *t =
|
||||
var->data.from_named_ifc_block ? var->get_interface_type() : var->type;
|
||||
|
@ -116,7 +116,7 @@ void
|
|||
program_resource_visitor::recursion(const glsl_type *t, char **name,
|
||||
size_t name_length, bool row_major,
|
||||
const glsl_type *record_type,
|
||||
const unsigned packing,
|
||||
const enum glsl_interface_packing packing,
|
||||
bool last_field,
|
||||
unsigned record_array_count,
|
||||
const glsl_struct_field *named_ifc_member)
|
||||
|
@ -228,7 +228,7 @@ void
|
|||
program_resource_visitor::visit_field(const glsl_type *type, const char *name,
|
||||
bool row_major,
|
||||
const glsl_type *,
|
||||
const unsigned,
|
||||
const enum glsl_interface_packing,
|
||||
bool /* last_field */)
|
||||
{
|
||||
visit_field(type, name, row_major);
|
||||
|
@ -243,13 +243,13 @@ program_resource_visitor::visit_field(const glsl_struct_field *field)
|
|||
|
||||
void
|
||||
program_resource_visitor::enter_record(const glsl_type *, const char *, bool,
|
||||
const unsigned)
|
||||
const enum glsl_interface_packing)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
program_resource_visitor::leave_record(const glsl_type *, const char *, bool,
|
||||
const unsigned)
|
||||
const enum glsl_interface_packing)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -660,7 +660,7 @@ private:
|
|||
}
|
||||
|
||||
virtual void enter_record(const glsl_type *type, const char *,
|
||||
bool row_major, const unsigned packing) {
|
||||
bool row_major, const enum glsl_interface_packing packing) {
|
||||
assert(type->is_record());
|
||||
if (this->buffer_block_index == -1)
|
||||
return;
|
||||
|
@ -673,7 +673,7 @@ private:
|
|||
}
|
||||
|
||||
virtual void leave_record(const glsl_type *type, const char *,
|
||||
bool row_major, const unsigned packing) {
|
||||
bool row_major, const enum glsl_interface_packing packing) {
|
||||
assert(type->is_record());
|
||||
if (this->buffer_block_index == -1)
|
||||
return;
|
||||
|
@ -687,7 +687,7 @@ private:
|
|||
|
||||
virtual void visit_field(const glsl_type *type, const char *name,
|
||||
bool row_major, const glsl_type * /* record_type */,
|
||||
const unsigned packing,
|
||||
const enum glsl_interface_packing packing,
|
||||
bool /* last_field */)
|
||||
{
|
||||
assert(!type->without_array()->is_record());
|
||||
|
|
|
@ -156,7 +156,7 @@ protected:
|
|||
*/
|
||||
virtual void visit_field(const glsl_type *type, const char *name,
|
||||
bool row_major, const glsl_type *record_type,
|
||||
const unsigned packing,
|
||||
const enum glsl_interface_packing packing,
|
||||
bool last_field);
|
||||
|
||||
/**
|
||||
|
@ -180,10 +180,10 @@ protected:
|
|||
virtual void visit_field(const glsl_struct_field *field);
|
||||
|
||||
virtual void enter_record(const glsl_type *type, const char *name,
|
||||
bool row_major, const unsigned packing);
|
||||
bool row_major, const enum glsl_interface_packing packing);
|
||||
|
||||
virtual void leave_record(const glsl_type *type, const char *name,
|
||||
bool row_major, const unsigned packing);
|
||||
bool row_major, const enum glsl_interface_packing packing);
|
||||
|
||||
virtual void set_buffer_offset(unsigned offset);
|
||||
|
||||
|
@ -199,7 +199,7 @@ private:
|
|||
*/
|
||||
void recursion(const glsl_type *t, char **name, size_t name_length,
|
||||
bool row_major, const glsl_type *record_type,
|
||||
const unsigned packing,
|
||||
const enum glsl_interface_packing packing,
|
||||
bool last_field, unsigned record_array_count,
|
||||
const glsl_struct_field *named_ifc_member);
|
||||
};
|
||||
|
|
|
@ -328,7 +328,7 @@ lower_buffer_access::setup_buffer_access(void *mem_ctx,
|
|||
bool *row_major,
|
||||
int *matrix_columns,
|
||||
const glsl_struct_field **struct_field,
|
||||
unsigned packing)
|
||||
enum glsl_interface_packing packing)
|
||||
{
|
||||
*offset = new(mem_ctx) ir_constant(0u);
|
||||
*row_major = is_dereferenced_thing_row_major(deref);
|
||||
|
|
|
@ -58,7 +58,7 @@ public:
|
|||
ir_rvalue **offset, unsigned *const_offset,
|
||||
bool *row_major, int *matrix_columns,
|
||||
const glsl_struct_field **struct_field,
|
||||
unsigned packing);
|
||||
enum glsl_interface_packing packing);
|
||||
};
|
||||
|
||||
} /* namespace lower_buffer_access */
|
||||
|
|
|
@ -138,7 +138,7 @@ lower_shared_reference_visitor::handle_rvalue(ir_rvalue **rvalue)
|
|||
bool row_major;
|
||||
int matrix_columns;
|
||||
assert(var->get_interface_type() == NULL);
|
||||
const unsigned packing = GLSL_INTERFACE_PACKING_STD430;
|
||||
const enum glsl_interface_packing packing = GLSL_INTERFACE_PACKING_STD430;
|
||||
|
||||
setup_buffer_access(mem_ctx, var, deref,
|
||||
&offset, &const_offset,
|
||||
|
@ -206,7 +206,7 @@ lower_shared_reference_visitor::handle_assignment(ir_assignment *ir)
|
|||
bool row_major;
|
||||
int matrix_columns;
|
||||
assert(var->get_interface_type() == NULL);
|
||||
const unsigned packing = GLSL_INTERFACE_PACKING_STD430;
|
||||
const enum glsl_interface_packing packing = GLSL_INTERFACE_PACKING_STD430;
|
||||
|
||||
setup_buffer_access(mem_ctx, var, deref,
|
||||
&offset, &const_offset,
|
||||
|
@ -365,7 +365,7 @@ lower_shared_reference_visitor::lower_shared_atomic_intrinsic(ir_call *ir)
|
|||
bool row_major;
|
||||
int matrix_columns;
|
||||
assert(var->get_interface_type() == NULL);
|
||||
const unsigned packing = GLSL_INTERFACE_PACKING_STD430;
|
||||
const enum glsl_interface_packing packing = GLSL_INTERFACE_PACKING_STD430;
|
||||
buffer_access_type = shared_atomic_access;
|
||||
|
||||
setup_buffer_access(mem_ctx, var, deref,
|
||||
|
|
|
@ -61,7 +61,7 @@ public:
|
|||
unsigned *const_offset,
|
||||
bool *row_major,
|
||||
int *matrix_columns,
|
||||
unsigned packing);
|
||||
enum glsl_interface_packing packing);
|
||||
uint32_t ssbo_access_params();
|
||||
ir_expression *ubo_load(void *mem_ctx, const struct glsl_type *type,
|
||||
ir_rvalue *offset);
|
||||
|
@ -99,7 +99,7 @@ public:
|
|||
ir_expression *emit_ssbo_get_buffer_size(void *mem_ctx);
|
||||
|
||||
unsigned calculate_unsized_array_stride(ir_dereference *deref,
|
||||
unsigned packing);
|
||||
enum glsl_interface_packing packing);
|
||||
|
||||
ir_call *lower_ssbo_atomic_intrinsic(ir_call *ir);
|
||||
ir_call *check_for_ssbo_atomic_intrinsic(ir_call *ir);
|
||||
|
@ -273,7 +273,7 @@ lower_ubo_reference_visitor::setup_for_load_or_store(void *mem_ctx,
|
|||
unsigned *const_offset,
|
||||
bool *row_major,
|
||||
int *matrix_columns,
|
||||
unsigned packing)
|
||||
enum glsl_interface_packing packing)
|
||||
{
|
||||
/* Determine the name of the interface block */
|
||||
ir_rvalue *nonconst_block_index;
|
||||
|
@ -344,7 +344,7 @@ lower_ubo_reference_visitor::handle_rvalue(ir_rvalue **rvalue)
|
|||
unsigned const_offset;
|
||||
bool row_major;
|
||||
int matrix_columns;
|
||||
unsigned packing = var->get_interface_type()->interface_packing;
|
||||
enum glsl_interface_packing packing = var->get_interface_type_packing();
|
||||
|
||||
this->buffer_access_type =
|
||||
var->is_in_shader_storage_block() ?
|
||||
|
@ -557,7 +557,7 @@ lower_ubo_reference_visitor::write_to_memory(void *mem_ctx,
|
|||
unsigned const_offset;
|
||||
bool row_major;
|
||||
int matrix_columns;
|
||||
unsigned packing = var->get_interface_type()->interface_packing;
|
||||
enum glsl_interface_packing packing = var->get_interface_type_packing();
|
||||
|
||||
this->buffer_access_type = ssbo_store_access;
|
||||
this->variable = var;
|
||||
|
@ -666,7 +666,7 @@ lower_ubo_reference_visitor::emit_ssbo_get_buffer_size(void *mem_ctx)
|
|||
|
||||
unsigned
|
||||
lower_ubo_reference_visitor::calculate_unsized_array_stride(ir_dereference *deref,
|
||||
unsigned packing)
|
||||
enum glsl_interface_packing packing)
|
||||
{
|
||||
unsigned array_stride = 0;
|
||||
|
||||
|
@ -736,7 +736,7 @@ lower_ubo_reference_visitor::process_ssbo_unsized_array_length(ir_rvalue **rvalu
|
|||
unsigned const_offset;
|
||||
bool row_major;
|
||||
int matrix_columns;
|
||||
unsigned packing = var->get_interface_type()->interface_packing;
|
||||
enum glsl_interface_packing packing = var->get_interface_type_packing();
|
||||
int unsized_array_stride = calculate_unsized_array_stride(deref, packing);
|
||||
|
||||
this->buffer_access_type = ssbo_unsized_array_length_access;
|
||||
|
@ -970,7 +970,7 @@ lower_ubo_reference_visitor::lower_ssbo_atomic_intrinsic(ir_call *ir)
|
|||
unsigned const_offset;
|
||||
bool row_major;
|
||||
int matrix_columns;
|
||||
unsigned packing = var->get_interface_type()->interface_packing;
|
||||
enum glsl_interface_packing packing = var->get_interface_type_packing();
|
||||
|
||||
this->buffer_access_type = ssbo_atomic_access;
|
||||
this->variable = var;
|
||||
|
|
|
@ -144,7 +144,7 @@ do_dead_code(exec_list *instructions, bool uniform_locations_assigned)
|
|||
* layouts, do not eliminate it.
|
||||
*/
|
||||
if (entry->var->is_in_buffer_block()) {
|
||||
if (entry->var->get_interface_type()->interface_packing !=
|
||||
if (entry->var->get_interface_type_packing() !=
|
||||
GLSL_INTERFACE_PACKING_PACKED)
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -745,6 +745,14 @@ struct glsl_type {
|
|||
*/
|
||||
bool record_compare(const glsl_type *b, bool match_locations = true) const;
|
||||
|
||||
/**
|
||||
* Get the type interface packing.
|
||||
*/
|
||||
enum glsl_interface_packing get_interface_packing() const
|
||||
{
|
||||
return (enum glsl_interface_packing)interface_packing;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
static mtx_t mutex;
|
||||
|
|
Loading…
Reference in New Issue