ir_call *ssbo_store(ir_rvalue *deref, ir_rvalue *offset,
unsigned write_mask);
+ enum {
+ ubo_load_access,
+ ssbo_load_access,
+ ssbo_store_access,
+ ssbo_unsized_array_length_access,
+ ssbo_atomic_access,
+ } buffer_access_type;
+
void emit_access(bool is_write, ir_dereference *deref,
ir_variable *base_offset, unsigned int deref_offset,
bool row_major, int matrix_columns,
struct gl_uniform_buffer_variable *ubo_var;
ir_rvalue *uniform_block;
bool progress;
- bool is_shader_storage;
};
/**
deref, &nonconst_block_index);
/* Locate the block by interface name */
- this->is_shader_storage = var->is_in_shader_storage_block();
unsigned num_blocks;
struct gl_uniform_block **blocks;
- if (this->is_shader_storage) {
+ if (this->buffer_access_type != ubo_load_access) {
num_blocks = shader->NumShaderStorageBlocks;
blocks = shader->ShaderStorageBlocks;
} else {
int matrix_columns;
unsigned packing = var->get_interface_type()->interface_packing;
+ this->buffer_access_type =
+ var->is_in_shader_storage_block() ?
+ ssbo_load_access : ubo_load_access;
+
/* Compute the offset to the start if the dereference as well as other
* information we need to configure the write
*/
if (is_write)
base_ir->insert_after(ssbo_store(deref, offset, write_mask));
else {
- if (!this->is_shader_storage) {
+ if (this->buffer_access_type == ubo_load_access) {
base_ir->insert_before(assign(deref->clone(mem_ctx, NULL),
ubo_load(deref->type, offset)));
} else {
base_ir->insert_after(ssbo_store(swizzle(deref, i, 1), chan_offset, 1));
} else {
- if (!this->is_shader_storage) {
+ if (this->buffer_access_type == ubo_load_access) {
base_ir->insert_before(assign(deref->clone(mem_ctx, NULL),
ubo_load(deref_type, chan_offset),
(1U << i)));
int matrix_columns;
unsigned packing = var->get_interface_type()->interface_packing;
+ this->buffer_access_type = ssbo_store_access;
+
/* Compute the offset to the start if the dereference as well as other
* information we need to configure the write
*/
unsigned packing = var->get_interface_type()->interface_packing;
int unsized_array_stride = calculate_unsized_array_stride(deref, packing);
+ this->buffer_access_type = ssbo_unsized_array_length_access;
+
/* Compute the offset to the start if the dereference as well as other
* information we need to calculate the length.
*/
int matrix_columns;
unsigned packing = var->get_interface_type()->interface_packing;
+ this->buffer_access_type = ssbo_atomic_access;
+
setup_for_load_or_store(var, deref,
&offset, &const_offset,
&row_major, &matrix_columns,