summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2018-11-13 09:45:03 -0600
committerJason Ekstrand <[email protected]>2018-11-15 19:59:42 -0600
commitd34fd81e7668b14158d63ade844a0e260b6f9152 (patch)
tree369c2a2d80630c70bd899485e7c7df3624c7db43 /src/compiler/glsl
parentfb127f77295fb9409e089b9267fff32b5f51a0a2 (diff)
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 <[email protected]> Acked-by: Karol Herbst <[email protected]>
Diffstat (limited to 'src/compiler/glsl')
-rw-r--r--src/compiler/glsl/glsl_to_nir.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp
index 9bb0f5d4044..9f73b721e39 100644
--- a/src/compiler/glsl/glsl_to_nir.cpp
+++ b/src/compiler/glsl/glsl_to_nir.cpp
@@ -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);
/*