}
static void
-fd6_emit_ubos(const struct ir3_shader_variant *v,
+fd6_emit_ubos(struct fd_context *ctx, const struct ir3_shader_variant *v,
struct fd_ringbuffer *ring, struct fd_constbuf_stateobj *constbuf)
{
if (!v->shader->num_ubos)
* and UBO load indices decremented by one.
*/
struct pipe_constant_buffer *cb = &constbuf->cb[i + 1];
+
+ /* If we have user pointers (constbuf 0, aka GL uniforms), upload them
+ * to a buffer now, and save it in the constbuf so that we don't have
+ * to reupload until they get changed.
+ */
+ if (cb->user_buffer) {
+ struct pipe_context *pctx = &ctx->base;
+ u_upload_data(pctx->stream_uploader, 0,
+ cb->buffer_size,
+ 64,
+ cb->user_buffer,
+ &cb->buffer_offset, &cb->buffer);
+ cb->user_buffer = NULL;
+ }
+
if (cb->buffer) {
int size_vec4s = DIV_ROUND_UP(cb->buffer_size, 16);
OUT_RELOC(ring, fd_resource(cb->buffer)->bo,
if (!variants[i])
continue;
ir3_emit_user_consts(ctx->screen, variants[i], constobj, &ctx->constbuf[types[i]]);
- fd6_emit_ubos(variants[i], constobj, &ctx->constbuf[types[i]]);
+ fd6_emit_ubos(ctx, variants[i], constobj, &ctx->constbuf[types[i]]);
}
fd6_emit_take_group(emit, constobj, FD6_GROUP_CONST, ENABLE_ALL);
struct fd_context *ctx, const struct pipe_grid_info *info)
{
ir3_emit_cs_consts(v, ring, ctx, info);
- fd6_emit_ubos(v, ring, &ctx->constbuf[PIPE_SHADER_COMPUTE]);
+ fd6_emit_ubos(ctx, v, ring, &ctx->constbuf[PIPE_SHADER_COMPUTE]);
}
void
}
static inline void
-ir3_emit_ubos(struct fd_screen *screen, const struct ir3_shader_variant *v,
+ir3_emit_ubos(struct fd_context *ctx, const struct ir3_shader_variant *v,
struct fd_ringbuffer *ring, struct fd_constbuf_stateobj *constbuf)
{
const struct ir3_const_state *const_state = &v->shader->const_state;
for (uint32_t i = 0; i < params; i++) {
const uint32_t index = i + 1; /* UBOs start at index 1 */
struct pipe_constant_buffer *cb = &constbuf->cb[index];
- assert(!cb->user_buffer);
+
+ /* If we have user pointers (constbuf 0, aka GL uniforms), upload
+ * them to a buffer now, and save it in the constbuf so that we
+ * don't have to reupload until they get changed.
+ */
+ if (cb->user_buffer) {
+ struct pipe_context *pctx = &ctx->base;
+ u_upload_data(pctx->stream_uploader, 0,
+ cb->buffer_size,
+ 64,
+ cb->user_buffer,
+ &cb->buffer_offset, &cb->buffer);
+ cb->user_buffer = NULL;
+ }
if ((constbuf->enabled_mask & (1 << index)) && cb->buffer) {
offsets[i] = cb->buffer_offset;
ring_wfi(ctx->batch, ring);
ir3_emit_user_consts(ctx->screen, v, ring, constbuf);
- ir3_emit_ubos(ctx->screen, v, ring, constbuf);
+ ir3_emit_ubos(ctx, v, ring, constbuf);
if (shader_dirty)
ir3_emit_immediates(ctx->screen, v, ring);
}