struct ir3_shader *shader = rzalloc_size(NULL, sizeof(*shader));
shader->compiler = c;
shader->type = MESA_SHADER_COMPUTE;
+ shader->const_state = rzalloc_size(shader, sizeof(*shader->const_state));
mtx_init(&shader->variants_lock, mtx_plain);
struct ir3_shader_variant *v = rzalloc_size(shader, sizeof(*v));
/* Reallocate for 4 more elements whenever it's necessary */
struct ir3_const_state *const_state = ir3_const_state(ctx->so);
if (const_state->immediate_idx == const_state->immediates_size * 4) {
+ const_state->immediates = rerzalloc(const_state,
+ const_state->immediates,
+ __typeof__(const_state->immediates[0]),
+ const_state->immediates_size,
+ 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 (int i = const_state->immediate_idx; i < const_state->immediates_size * 4; i++)
const_state->immediates[i / 4].val[i % 4] = 0xd0d0d0d0;
* const_state layout setup. This should be done after ubo range
* analysis.
*/
- ir3_setup_const_state(shader, s, &shader->const_state);
+ ir3_setup_const_state(shader, s, shader->const_state);
}
void
bool
ir3_nir_analyze_ubo_ranges(nir_shader *nir, struct ir3_shader *shader)
{
- struct ir3_ubo_analysis_state *state = &shader->const_state.ubo_state;
+ struct ir3_const_state *const_state = shader->const_state;
+ struct ir3_ubo_analysis_state *state = &const_state->ubo_state;
memset(state, 0, sizeof(*state));
for (int i = 0; i < IR3_MAX_UBO_PUSH_RANGES; i++) {
assert((reg & 0x7) == 0);
int idx = reg >> (1 + 2); /* low bit is half vs full, next two bits are swiz */
if (const_state->immediate_idx == const_state->immediates_size * 4) {
+ const_state->immediates = rerzalloc(const_state,
+ const_state->immediates,
+ __typeof__(const_state->immediates[0]),
+ const_state->immediates_size,
+ 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]));
}
const_state->immediates[idx].val[0] = c0;
const_state->immediates[idx].val[1] = c1;
void
ir3_shader_destroy(struct ir3_shader *shader)
{
- free(shader->const_state.immediates);
ralloc_free(shader->nir);
mtx_destroy(&shader->variants_lock);
ralloc_free(shader);
if (stream_output)
memcpy(&shader->stream_output, stream_output, sizeof(shader->stream_output));
shader->num_reserved_user_consts = reserved_user_consts;
+ shader->const_state = rzalloc_size(shader, sizeof(*shader->const_state));
if (nir->info.stage == MESA_SHADER_GEOMETRY)
NIR_PASS_V(nir, ir3_nir_lower_gs);
struct ir3_compiler *compiler;
- struct ir3_const_state const_state;
+ struct ir3_const_state *const_state;
unsigned num_reserved_user_consts;
struct nir_shader *nir;
static inline struct ir3_const_state *
ir3_const_state(const struct ir3_shader_variant *v)
{
- return &v->shader->const_state;
+ return v->shader->const_state;
}
void * ir3_shader_assemble(struct ir3_shader_variant *v);
r3d_common(struct tu_cmd_buffer *cmd, struct tu_cs *cs, bool blit, uint32_t num_rts,
bool layered_clear)
{
- struct ir3_shader dummy_shader = {};
+ struct ir3_const_state dummy_const_state = {};
+ struct ir3_shader dummy_shader = {
+ .const_state = &dummy_const_state,
+ };
struct ir3_shader_variant vs = {
.type = MESA_SHADER_VERTEX,