}
}
+static unsigned
+user_consts_cmdstream_size(struct ir3_shader_variant *v)
+{
+ struct ir3_ubo_analysis_state *ubo_state = &v->shader->ubo_state;
+
+ if (unlikely(!ubo_state->cmdstream_size)) {
+ unsigned packets, size;
+
+ /* pre-calculate size required for userconst stateobj: */
+ ir3_user_consts_size(ubo_state, &packets, &size);
+
+ /* also account for UBO addresses: */
+ packets += 1;
+ size += 2 * v->shader->num_ubos;
+
+ unsigned sizedwords = (4 * packets) + size;
+ ubo_state->cmdstream_size = sizedwords * 4;
+ }
+
+ return ubo_state->cmdstream_size;
+}
+
static void
emit_user_consts(struct fd6_emit *emit)
{
PIPE_SHADER_VERTEX, PIPE_SHADER_TESS_CTRL, PIPE_SHADER_TESS_EVAL,
PIPE_SHADER_GEOMETRY, PIPE_SHADER_FRAGMENT,
};
- const struct ir3_shader_variant *variants[] = {
+ struct ir3_shader_variant *variants[] = {
emit->vs, emit->hs, emit->ds, emit->gs, emit->fs,
};
struct fd_context *ctx = emit->ctx;
for (unsigned i = 0; i < ARRAY_SIZE(types); i++) {
if (!variants[i])
continue;
- sz += variants[i]->shader->ubo_state.cmdstream_size;
+ sz += user_consts_cmdstream_size(variants[i]);
}
struct fd_ringbuffer *constobj = fd_submit_new_ringbuffer(
ir3_emit_immediates(screen, v, ring);
}
-void
-fd6_user_consts_size(struct ir3_ubo_analysis_state *state,
- unsigned *packets, unsigned *size)
-{
- ir3_user_consts_size(state, packets, size);
-}
-
void
fd6_emit_link_map(struct fd_screen *screen,
const struct ir3_shader_variant *producer,
struct fd_context *ctx, const struct pipe_grid_info *info);
void fd6_emit_immediates(struct fd_screen *screen, const struct ir3_shader_variant *v,
struct fd_ringbuffer *ring);
-void fd6_user_consts_size(struct ir3_ubo_analysis_state *state,
- unsigned *packets, unsigned *size);
void fd6_emit_link_map(struct fd_screen *screen,
const struct ir3_shader_variant *producer,
const struct ir3_shader_variant *v, struct fd_ringbuffer *ring);
static void *
fd6_shader_state_create(struct pipe_context *pctx, const struct pipe_shader_state *cso)
{
- struct ir3_shader *shader = ir3_shader_state_create(pctx, cso);
- unsigned packets, size;
-
- /* pre-calculate size required for userconst stateobj: */
- fd6_user_consts_size(&shader->ubo_state, &packets, &size);
-
- /* also account for UBO addresses: */
- packets += 1;
- size += 2 * shader->num_ubos;
-
- unsigned sizedwords = (4 * packets) + size;
- shader->ubo_state.cmdstream_size = sizedwords * 4;
-
- return shader;
+ return ir3_shader_state_create(pctx, cso);
}
static void