#include "ir_builder.h"
#include "main/macros.h"
#include "glsl_parser_extras.h"
+#include "main/mtypes.h"
using namespace ir_builder;
public lower_buffer_access::lower_buffer_access {
public:
lower_ubo_reference_visitor(struct gl_linked_shader *shader,
- bool clamp_block_indices)
+ bool clamp_block_indices,
+ bool use_std430_as_default)
: shader(shader), clamp_block_indices(clamp_block_indices),
struct_field(NULL), variable(NULL)
{
+ this->use_std430_as_default = use_std430_as_default;
}
void handle_rvalue(ir_rvalue **rvalue);
ir_rvalue **offset,
unsigned *const_offset,
bool *row_major,
- int *matrix_columns,
+ const glsl_type **matrix_type,
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,
unsigned *const_offset,
bool *row_major,
- int *matrix_columns,
+ const glsl_type **matrix_type,
enum glsl_interface_packing packing)
{
/* Determine the name of the interface block */
this->struct_field = NULL;
setup_buffer_access(mem_ctx, deref, offset, const_offset, row_major,
- matrix_columns, &this->struct_field, packing);
+ matrix_type, &this->struct_field, packing);
}
void
ir_rvalue *offset = NULL;
unsigned const_offset;
bool row_major;
- int matrix_columns;
- enum glsl_interface_packing packing = var->get_interface_type_packing();
+ const glsl_type *matrix_type;
+
+ enum glsl_interface_packing packing =
+ var->get_interface_type()->
+ get_internal_ifc_packing(use_std430_as_default);
this->buffer_access_type =
var->is_in_shader_storage_block() ?
*/
setup_for_load_or_store(mem_ctx, var, deref,
&offset, &const_offset,
- &row_major, &matrix_columns,
+ &row_major, &matrix_type,
packing);
assert(offset);
deref = new(mem_ctx) ir_dereference_variable(load_var);
emit_access(mem_ctx, false, deref, load_offset, const_offset,
- row_major, matrix_columns, packing, 0);
+ row_major, matrix_type, packing, 0);
*rvalue = deref;
progress = true;
ir_rvalue *offset = NULL;
unsigned const_offset;
bool row_major;
- int matrix_columns;
- enum glsl_interface_packing packing = var->get_interface_type_packing();
+ const glsl_type *matrix_type;
+
+ enum glsl_interface_packing packing =
+ var->get_interface_type()->
+ get_internal_ifc_packing(use_std430_as_default);
this->buffer_access_type = ssbo_store_access;
this->variable = var;
*/
setup_for_load_or_store(mem_ctx, var, deref,
&offset, &const_offset,
- &row_major, &matrix_columns,
+ &row_major, &matrix_type,
packing);
assert(offset);
deref = new(mem_ctx) ir_dereference_variable(write_var);
emit_access(mem_ctx, true, deref, write_offset, const_offset,
- row_major, matrix_columns, packing, write_mask);
+ row_major, matrix_type, packing, write_mask);
}
ir_visitor_status
return;
}
- for (unsigned i = 0; i < ir->get_num_operands(); i++) {
+ for (unsigned i = 0; i < ir->num_operands; i++) {
if (ir->operands[i]->ir_type != ir_type_expression)
continue;
ir_expression *expr = (ir_expression *) ir->operands[i];
ir_rvalue *base_offset = NULL;
unsigned const_offset;
bool row_major;
- int matrix_columns;
- enum glsl_interface_packing packing = var->get_interface_type_packing();
- int unsized_array_stride = calculate_unsized_array_stride(deref, packing);
+ const glsl_type *matrix_type;
+
+ enum glsl_interface_packing packing =
+ var->get_interface_type()->
+ get_internal_ifc_packing(use_std430_as_default);
+ int unsized_array_stride =
+ calculate_unsized_array_stride(deref, packing);
this->buffer_access_type = ssbo_unsized_array_length_access;
this->variable = var;
*/
setup_for_load_or_store(mem_ctx, var, deref,
&base_offset, &const_offset,
- &row_major, &matrix_columns,
+ &row_major, &matrix_type,
packing);
/* array.length() =
* max((buffer_object_size - offset_of_array) / stride_of_array, 0)
ir_rvalue *offset = NULL;
unsigned const_offset;
bool row_major;
- int matrix_columns;
- enum glsl_interface_packing packing = var->get_interface_type_packing();
+ const glsl_type *matrix_type;
+
+ enum glsl_interface_packing packing =
+ var->get_interface_type()->
+ get_internal_ifc_packing(use_std430_as_default);
this->buffer_access_type = ssbo_atomic_access;
this->variable = var;
setup_for_load_or_store(mem_ctx, var, deref,
&offset, &const_offset,
- &row_major, &matrix_columns,
+ &row_major, &matrix_type,
packing);
assert(offset);
assert(!row_major);
- assert(matrix_columns == 1);
+ assert(matrix_type == NULL);
ir_rvalue *deref_offset =
add(offset, new(mem_ctx) ir_constant(const_offset));
} /* unnamed namespace */
void
-lower_ubo_reference(struct gl_linked_shader *shader, bool clamp_block_indices)
+lower_ubo_reference(struct gl_linked_shader *shader,
+ bool clamp_block_indices, bool use_std430_as_default)
{
- lower_ubo_reference_visitor v(shader, clamp_block_indices);
+ lower_ubo_reference_visitor v(shader, clamp_block_indices,
+ use_std430_as_default);
/* Loop over the instructions lowering references, because we take
* a deref of a UBO array using a UBO dereference as the index will