From: Rob Clark Date: Mon, 6 May 2019 23:02:19 +0000 (-0700) Subject: freedreno/ir3: move immediates to const_state X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9403184ddd002f11f30a0eab0f98f9545810b513;p=mesa.git freedreno/ir3: move immediates to const_state They are really part of the constant state, and it will moving things from ir3_shader_variant to ir3_shader if we combine them. Signed-off-by: Rob Clark --- diff --git a/src/freedreno/ir3/ir3_cp.c b/src/freedreno/ir3/ir3_cp.c index 983c5fa61f2..5d46b19d6e5 100644 --- a/src/freedreno/ir3/ir3_cp.c +++ b/src/freedreno/ir3/ir3_cp.c @@ -37,7 +37,6 @@ struct ir3_cp_ctx { struct ir3 *shader; struct ir3_shader_variant *so; - unsigned immediate_idx; }; /* is it a type preserving mov, with ok flags? */ @@ -299,32 +298,31 @@ lower_immed(struct ir3_cp_ctx *ctx, struct ir3_register *reg, unsigned new_flags } /* 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])); + struct ir3_const_state *const_state = &ctx->so->const_state; + if (const_state->immediate_idx == const_state->immediates_size * 4) { + const_state->immediates_size += 4; + const_state->immediates = realloc (const_state->immediates, + const_state->immediates_size * sizeof(const_state->immediates[0])); } - for (i = 0; i < ctx->immediate_idx; i++) { + for (i = 0; i < const_state->immediate_idx; i++) { swiz = i % 4; idx = i / 4; - if (ctx->so->immediates[idx].val[swiz] == reg->uim_val) { + if (const_state->immediates[idx].val[swiz] == reg->uim_val) { break; } } - if (i == ctx->immediate_idx) { + if (i == const_state->immediate_idx) { /* need to generate a new immediate: */ swiz = i % 4; idx = i / 4; - ctx->so->immediates[idx].val[swiz] = reg->uim_val; - ctx->so->immediates_count = idx + 1; - ctx->immediate_idx++; + const_state->immediates[idx].val[swiz] = reg->uim_val; + const_state->immediates_count = idx + 1; + const_state->immediate_idx++; } - struct ir3_const_state *const_state = &ctx->so->const_state; - new_flags &= ~IR3_REG_IMMED; new_flags |= IR3_REG_CONST; reg->flags = new_flags; diff --git a/src/freedreno/ir3/ir3_shader.c b/src/freedreno/ir3/ir3_shader.c index 63cad3ee414..29f7fa05f0c 100644 --- a/src/freedreno/ir3/ir3_shader.c +++ b/src/freedreno/ir3/ir3_shader.c @@ -47,8 +47,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); + if (v->const_state.immediates) + free(v->const_state.immediates); free(v); } @@ -351,13 +351,13 @@ ir3_shader_disasm(struct ir3_shader_variant *so, uint32_t *bin, FILE *out) } struct ir3_const_state *const_state = &so->const_state; - for (i = 0; i < so->immediates_count; i++) { + for (i = 0; i < const_state->immediates_count; i++) { fprintf(out, "@const(c%d.x)\t", const_state->offsets.immediate + i); fprintf(out, "0x%08x, 0x%08x, 0x%08x, 0x%08x\n", - so->immediates[i].val[0], - so->immediates[i].val[1], - so->immediates[i].val[2], - so->immediates[i].val[3]); + const_state->immediates[i].val[0], + const_state->immediates[i].val[1], + const_state->immediates[i].val[2], + const_state->immediates[i].val[3]); } disasm_a3xx(bin, so->info.sizedwords, 0, out, ir->compiler->gpu_id); diff --git a/src/freedreno/ir3/ir3_shader.h b/src/freedreno/ir3/ir3_shader.h index 448f6052194..a4386d7762d 100644 --- a/src/freedreno/ir3/ir3_shader.h +++ b/src/freedreno/ir3/ir3_shader.h @@ -148,6 +148,13 @@ struct ir3_const_state { */ uint32_t off[IR3_MAX_SHADER_IMAGES]; } image_dims; + + unsigned immediate_idx; + unsigned immediates_count; + unsigned immediates_size; + struct { + uint32_t val[4]; + } *immediates; }; /** @@ -490,12 +497,6 @@ struct ir3_shader_variant { bool per_samp; - unsigned immediates_count; - unsigned immediates_size; - struct { - uint32_t val[4]; - } *immediates; - /* for astc srgb workaround, the number/base of additional * alpha tex states we need, and index of original tex states */ diff --git a/src/freedreno/vulkan/tu_shader.c b/src/freedreno/vulkan/tu_shader.c index c2fdff9953e..62f8f91c7f3 100644 --- a/src/freedreno/vulkan/tu_shader.c +++ b/src/freedreno/vulkan/tu_shader.c @@ -196,8 +196,8 @@ tu_shader_destroy(struct tu_device *dev, for (uint32_t i = 0; i < 1 + shader->has_binning_pass; i++) { if (shader->variants[i].ir) ir3_destroy(shader->variants[i].ir); - if (shader->variants[i].immediates) - free(shader->variants[i].immediates); + if (shader->variants[i].const_state.immediates) + free(shader->variants[i].const_state.immediates); } if (shader->binary) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_gallium.c b/src/gallium/drivers/freedreno/ir3/ir3_gallium.c index 3bb29daf9b8..08a7c90aab3 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_gallium.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_gallium.c @@ -388,7 +388,7 @@ emit_immediates(struct fd_context *ctx, const struct ir3_shader_variant *v, { const struct ir3_const_state *const_state = &v->const_state; uint32_t base = const_state->offsets.immediate; - int size = v->immediates_count; + int size = const_state->immediates_count; /* truncate size to avoid writing constants that shader * does not use: @@ -402,7 +402,7 @@ emit_immediates(struct fd_context *ctx, const struct ir3_shader_variant *v, if (size > 0) { ring_wfi(ctx->batch, ring); ctx->emit_const(ring, v->type, base, - 0, size, v->immediates[0].val, NULL); + 0, size, const_state->immediates[0].val, NULL); } }