summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2019-10-18 19:49:44 -0400
committerMarek Olšák <[email protected]>2019-10-22 14:41:23 -0400
commita0b711d8e930bd18c60b95ac4ee900c0df070140 (patch)
tree187f05ae9d1d077026329507d4ed377a90613222
parentaa8515463e525435cab7a69aae366ca99e9d3461 (diff)
nir: allow nir_lower_uniforms_to_ubo to be run repeatedly
for st/mesa Reviewed-by: Kenneth Graunke <[email protected]>
-rw-r--r--src/compiler/nir/nir_lower_uniforms_to_ubo.c5
-rw-r--r--src/compiler/shader_info.h3
2 files changed, 7 insertions, 1 deletions
diff --git a/src/compiler/nir/nir_lower_uniforms_to_ubo.c b/src/compiler/nir/nir_lower_uniforms_to_ubo.c
index 2f6b23a248f..7def01aad7e 100644
--- a/src/compiler/nir/nir_lower_uniforms_to_ubo.c
+++ b/src/compiler/nir/nir_lower_uniforms_to_ubo.c
@@ -43,7 +43,9 @@ lower_instr(nir_intrinsic_instr *instr, nir_builder *b, int multiplier)
{
b->cursor = nir_before_instr(&instr->instr);
- if (instr->intrinsic == nir_intrinsic_load_ubo) {
+ /* Increase all UBO binding points by 1. */
+ if (instr->intrinsic == nir_intrinsic_load_ubo &&
+ !b->shader->info.first_ubo_is_default_ubo) {
nir_ssa_def *old_idx = nir_ssa_for_src(b, instr->src[0], 1);
nir_ssa_def *new_idx = nir_iadd(b, old_idx, nir_imm_int(b, 1));
nir_instr_rewrite_src(&instr->instr, &instr->src[0],
@@ -99,6 +101,7 @@ nir_lower_uniforms_to_ubo(nir_shader *shader, int multiplier)
}
}
+ shader->info.first_ubo_is_default_ubo = true;
return progress;
}
diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h
index 1de583e6010..e8c875f333f 100644
--- a/src/compiler/shader_info.h
+++ b/src/compiler/shader_info.h
@@ -151,6 +151,9 @@ typedef struct shader_info {
/* The size of the gl_CullDistance[] array, if declared. */
unsigned cull_distance_array_size;
+ /* Whether the first UBO is the default uniform buffer, i.e. uniforms. */
+ bool first_ubo_is_default_ubo;
+
/* Whether or not separate shader objects were used */
bool separate_shader;