Commit 9403184d authored by Rob Clark's avatar Rob Clark 💬

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's avatarRob Clark <robdclark@chromium.org>
parent 23e7a344
......@@ -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;
......
......@@ -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);
......
......@@ -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
*/
......
......@@ -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)
......
......@@ -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);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment