aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHyunjun Ko <[email protected]>2018-08-30 11:58:53 +0900
committerRob Clark <[email protected]>2018-09-05 13:38:43 -0400
commitb4da2f6667e8fcdd4f8fdd45f3859e036a3b855c (patch)
treeb721e609b9ed1d47ac64a3a6faf8891587b81426
parentc3d9f29b78136c949ff2c98886aea8803f62b34e (diff)
freedreno/ir3: make immediates array dynamic
Since most shaders wouldn't need that large array of immediates, making the array dynamic could save unnecessary spaces. In addition, sometimes we can potentially have a much larger array of immediates to be lowered, which might be more than 64. Signed-off-by: Rob Clark <[email protected]>
-rw-r--r--src/gallium/drivers/freedreno/ir3/ir3_cp.c7
-rw-r--r--src/gallium/drivers/freedreno/ir3/ir3_shader.c2
-rw-r--r--src/gallium/drivers/freedreno/ir3/ir3_shader.h3
3 files changed, 11 insertions, 1 deletions
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_cp.c b/src/gallium/drivers/freedreno/ir3/ir3_cp.c
index 0ee8ea2e0ea..ea92f6b8577 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_cp.c
+++ b/src/gallium/drivers/freedreno/ir3/ir3_cp.c
@@ -286,6 +286,13 @@ lower_immed(struct ir3_cp_ctx *ctx, struct ir3_register *reg, unsigned new_flags
new_flags &= ~IR3_REG_FNEG;
}
+ /* Reallocate for 4 more elements whenever it's necessary */
+ if (ctx->immediate_idx == ctx->so->immediates_size * 4) {
+ ctx->so->immediates_size += 4;
+ ctx->so->immediates = realloc (ctx->so->immediates,
+ ctx->so->immediates_size * sizeof (ctx->so->immediates[0]));
+ }
+
for (i = 0; i < ctx->immediate_idx; i++) {
swiz = i % 4;
idx = i / 4;
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_shader.c b/src/gallium/drivers/freedreno/ir3/ir3_shader.c
index 7bb4263b177..125bf3b983e 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_shader.c
+++ b/src/gallium/drivers/freedreno/ir3/ir3_shader.c
@@ -54,6 +54,8 @@ delete_variant(struct ir3_shader_variant *v)
ir3_destroy(v->ir);
if (v->bo)
fd_bo_del(v->bo);
+ if (v->immediates)
+ free(v->immediates);
free(v);
}
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_shader.h b/src/gallium/drivers/freedreno/ir3/ir3_shader.h
index 288e9fa4e70..456701be7db 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_shader.h
+++ b/src/gallium/drivers/freedreno/ir3/ir3_shader.h
@@ -325,9 +325,10 @@ struct ir3_shader_variant {
} constbase;
unsigned immediates_count;
+ unsigned immediates_size;
struct {
uint32_t val[4];
- } immediates[64];
+ } *immediates;
/* for astc srgb workaround, the number/base of additional
* alpha tex states we need, and index of original tex states