if (ir3_kernel->info.numwg != INVALID_REG) {
assert((ir3_kernel->info.numwg & 0x3) == 0);
int idx = ir3_kernel->info.numwg >> 2;
- const_state->immediates[idx].val[0] = grid[0];
- const_state->immediates[idx].val[1] = grid[1];
- const_state->immediates[idx].val[2] = grid[2];
+ const_state->immediates[idx * 4 + 0] = grid[0];
+ const_state->immediates[idx * 4 + 1] = grid[1];
+ const_state->immediates[idx * 4 + 2] = grid[2];
}
/* truncate size to avoid writing constants that shader
size *= 4;
if (size > 0) {
- emit_const(ring, base, size, const_state->immediates[0].val);
+ emit_const(ring, base, size, const_state->immediates);
}
}
if (!ir3_valid_flags(instr, n, new_flags))
return false;
- unsigned swiz, idx, i;
-
reg = ir3_reg_clone(ctx->shader, reg);
/* Half constant registers seems to handle only 32-bit values
new_flags &= ~IR3_REG_FNEG;
}
- /* Reallocate for 4 more elements whenever it's necessary */
+ /* Reallocate for 4 more elements whenever it's necessary. Note that ir3
+ * printing relies on having groups of 4 dwords, so we fill the unused
+ * slots with a dummy value.
+ */
struct ir3_const_state *const_state = ir3_const_state(ctx->so);
- if (const_state->immediates_count == const_state->immediates_size * 4) {
+ if (const_state->immediates_count == const_state->immediates_size) {
const_state->immediates = rerzalloc(const_state,
const_state->immediates,
__typeof__(const_state->immediates[0]),
const_state->immediates_size + 4);
const_state->immediates_size += 4;
- for (int i = const_state->immediates_count; i < const_state->immediates_size * 4; i++)
- const_state->immediates[i / 4].val[i % 4] = 0xd0d0d0d0;
+ for (int i = const_state->immediates_count; i < const_state->immediates_size; i++)
+ const_state->immediates[i] = 0xd0d0d0d0;
}
+ int i;
for (i = 0; i < const_state->immediates_count; i++) {
- swiz = i % 4;
- idx = i / 4;
-
- if (const_state->immediates[idx].val[swiz] == reg->uim_val) {
+ if (const_state->immediates[i] == reg->uim_val)
break;
- }
}
if (i == const_state->immediates_count) {
ir3_max_const(ctx->so))
return false;
- swiz = i % 4;
- idx = i / 4;
-
- const_state->immediates[idx].val[swiz] = reg->uim_val;
+ const_state->immediates[i] = reg->uim_val;
const_state->immediates_count++;
}
struct ir3_const_state *const_state = ir3_const_state(variant);
assert((reg & 0x7) == 0);
int idx = reg >> (1 + 2); /* low bit is half vs full, next two bits are swiz */
- if (const_state->immediates_count == const_state->immediates_size * 4) {
+ if (const_state->immediates_count == const_state->immediates_size) {
const_state->immediates = rerzalloc(const_state,
const_state->immediates,
__typeof__(const_state->immediates[0]),
const_state->immediates_size + 4);
const_state->immediates_size += 4;
}
- const_state->immediates[idx].val[0] = c0;
- const_state->immediates[idx].val[1] = c1;
- const_state->immediates[idx].val[2] = c2;
- const_state->immediates[idx].val[3] = c3;
+ const_state->immediates[idx * 4 + 0] = c0;
+ const_state->immediates[idx * 4 + 1] = c1;
+ const_state->immediates[idx * 4 + 2] = c2;
+ const_state->immediates[idx * 4 + 3] = c3;
const_state->immediates_count++;
}
for (i = 0; i < DIV_ROUND_UP(const_state->immediates_count, 4); i++) {
fprintf(out, "@const(c%d.x)\t", const_state->offsets.immediate + i);
fprintf(out, "0x%08x, 0x%08x, 0x%08x, 0x%08x\n",
- const_state->immediates[i].val[0],
- const_state->immediates[i].val[1],
- const_state->immediates[i].val[2],
- const_state->immediates[i].val[3]);
+ const_state->immediates[i * 4 + 0],
+ const_state->immediates[i * 4 + 1],
+ const_state->immediates[i * 4 + 2],
+ const_state->immediates[i * 4 + 3]);
}
disasm_a3xx(bin, so->info.sizedwords, 0, out, ir->compiler->gpu_id);
unsigned immediates_count;
unsigned immediates_size;
- struct {
- uint32_t val[4];
- } *immediates;
+ uint32_t *immediates;
/* State of ubo access lowered to push consts: */
struct ir3_ubo_analysis_state ubo_state;
tu_cs_emit(cs, CP_LOAD_STATE6_1_EXT_SRC_ADDR(0));
tu_cs_emit(cs, CP_LOAD_STATE6_2_EXT_SRC_ADDR_HI(0));
- for (unsigned i = 0; i < size; i++) {
- tu_cs_emit(cs, const_state->immediates[i].val[0]);
- tu_cs_emit(cs, const_state->immediates[i].val[1]);
- tu_cs_emit(cs, const_state->immediates[i].val[2]);
- tu_cs_emit(cs, const_state->immediates[i].val[3]);
- }
+ tu_cs_emit_array(cs, const_state->immediates, size * 4);
}
static void
size *= 4;
if (size > 0)
- emit_const(ring, v, base, 0, size, const_state->immediates[0].val, NULL);
+ emit_const(ring, v, base, 0, size, const_state->immediates, NULL);
}
static inline void