freedreno/ir3: Stop pushing immediates once we've filled the constbuf.
authorEric Anholt <eric@anholt.net>
Mon, 1 Jun 2020 18:32:04 +0000 (11:32 -0700)
committerEric Anholt <eric@anholt.net>
Fri, 5 Jun 2020 20:36:29 +0000 (13:36 -0700)
If we filled the constbuf up with UBOs, we may need to avoid generating
more immediate push constants.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5273>

src/freedreno/ir3/ir3_cp.c

index ca80b7a8bc2b9e2dd041497c210f14f46c64ca15..052c8a539ac5ed3d6ba7507f1a8644eb8b04de4d 100644 (file)
@@ -383,7 +383,14 @@ lower_immed(struct ir3_cp_ctx *ctx, struct ir3_instruction *instr, unsigned n,
        }
 
        if (i == const_state->immediate_idx) {
-               /* need to generate a new immediate: */
+               struct ir3_compiler *compiler = instr->block->shader->compiler;
+               /* Add on a new immediate to be pushed, if we have space left in the
+                * constbuf.
+                */
+               if (const_state->offsets.immediate + const_state->immediate_idx / 4 >=
+                               compiler->max_const)
+                       return false;
+
                swiz = i % 4;
                idx  = i / 4;