struct ir3_cp_ctx {
struct ir3 *shader;
struct ir3_shader_variant *so;
- unsigned immediate_idx;
};
/* is it a type preserving mov, with ok 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;
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);
}
}
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);
*/
uint32_t off[IR3_MAX_SHADER_IMAGES];
} image_dims;
+
+ unsigned immediate_idx;
+ unsigned immediates_count;
+ unsigned immediates_size;
+ struct {
+ uint32_t val[4];
+ } *immediates;
};
/**
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
*/
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)
{
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:
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);
}
}