summaryrefslogtreecommitdiffstats
path: root/src/freedreno
diff options
context:
space:
mode:
authorRob Clark <[email protected]>2019-05-06 16:02:19 -0700
committerRob Clark <[email protected]>2019-05-07 07:26:00 -0700
commit9403184ddd002f11f30a0eab0f98f9545810b513 (patch)
tree4d18f9fad89e49dacb67a77fa975d8937321d218 /src/freedreno
parent23e7a34466c448c4c7c9a2c2e4d200dedf2584f7 (diff)
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 <[email protected]>
Diffstat (limited to 'src/freedreno')
-rw-r--r--src/freedreno/ir3/ir3_cp.c24
-rw-r--r--src/freedreno/ir3/ir3_shader.c14
-rw-r--r--src/freedreno/ir3/ir3_shader.h13
-rw-r--r--src/freedreno/vulkan/tu_shader.c4
4 files changed, 27 insertions, 28 deletions
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)