nir: Add alignment parameters to SSBO, UBO, and shared access
This also changes spirv_to_nir and glsl_to_nir to set them. The one place that doesn't set them is shared memory access lowering in nir_lower_io. That will have to be updated before any consumers of it can effectively use these new alignments. Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com> Acked-by: Karol Herbst <kherbst@redhat.com>
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
#include "compiler/nir/nir_builder.h"
|
||||
#include "main/imports.h"
|
||||
#include "main/mtypes.h"
|
||||
#include "util/u_math.h"
|
||||
|
||||
/*
|
||||
* pass to lower GLSL IR to NIR
|
||||
@@ -603,6 +604,14 @@ nir_visitor::visit(ir_return *ir)
|
||||
nir_builder_instr_insert(&b, &instr->instr);
|
||||
}
|
||||
|
||||
static void
|
||||
intrinsic_set_std430_align(nir_intrinsic_instr *intrin, const glsl_type *type)
|
||||
{
|
||||
unsigned bit_size = type->is_boolean() ? 32 : glsl_get_bit_size(type);
|
||||
unsigned pow2_components = util_next_power_of_two(type->vector_elements);
|
||||
nir_intrinsic_set_align(intrin, (bit_size / 8) * pow2_components, 0);
|
||||
}
|
||||
|
||||
void
|
||||
nir_visitor::visit(ir_call *ir)
|
||||
{
|
||||
@@ -1006,6 +1015,7 @@ nir_visitor::visit(ir_call *ir)
|
||||
instr->src[0] = nir_src_for_ssa(nir_val);
|
||||
instr->src[1] = nir_src_for_ssa(evaluate_rvalue(block));
|
||||
instr->src[2] = nir_src_for_ssa(evaluate_rvalue(offset));
|
||||
intrinsic_set_std430_align(instr, val->type);
|
||||
nir_intrinsic_set_write_mask(instr, write_mask->value.u[0]);
|
||||
instr->num_components = val->type->vector_elements;
|
||||
|
||||
@@ -1024,6 +1034,7 @@ nir_visitor::visit(ir_call *ir)
|
||||
|
||||
const glsl_type *type = ir->return_deref->var->type;
|
||||
instr->num_components = type->vector_elements;
|
||||
intrinsic_set_std430_align(instr, type);
|
||||
|
||||
/* Setup destination register */
|
||||
unsigned bit_size = type->is_boolean() ? 32 : glsl_get_bit_size(type);
|
||||
@@ -1101,6 +1112,7 @@ nir_visitor::visit(ir_call *ir)
|
||||
|
||||
const glsl_type *type = ir->return_deref->var->type;
|
||||
instr->num_components = type->vector_elements;
|
||||
intrinsic_set_std430_align(instr, type);
|
||||
|
||||
/* Setup destination register */
|
||||
unsigned bit_size = type->is_boolean() ? 32 : glsl_get_bit_size(type);
|
||||
@@ -1131,6 +1143,7 @@ nir_visitor::visit(ir_call *ir)
|
||||
|
||||
instr->src[0] = nir_src_for_ssa(nir_val);
|
||||
instr->num_components = val->type->vector_elements;
|
||||
intrinsic_set_std430_align(instr, val->type);
|
||||
|
||||
nir_builder_instr_insert(&b, &instr->instr);
|
||||
break;
|
||||
@@ -1388,6 +1401,7 @@ nir_visitor::visit(ir_expression *ir)
|
||||
load->num_components = ir->type->vector_elements;
|
||||
load->src[0] = nir_src_for_ssa(evaluate_rvalue(ir->operands[0]));
|
||||
load->src[1] = nir_src_for_ssa(evaluate_rvalue(ir->operands[1]));
|
||||
intrinsic_set_std430_align(load, ir->type);
|
||||
add_instr(&load->instr, ir->type->vector_elements, bit_size);
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user