const struct pipe_constant_buffer *cb)
{
struct threaded_context *tc = threaded_context(_pipe);
- struct pipe_resource *buffer = NULL;
- unsigned offset;
- /* This must be done before adding set_constant_buffer, because it could
- * generate e.g. transfer_unmap and flush partially-uninitialized
- * set_constant_buffer to the driver if it was done afterwards.
- */
if (cb && cb->user_buffer) {
+ struct pipe_resource *buffer = NULL;
+ unsigned offset;
+
+ /* This must be done before adding set_constant_buffer, because it could
+ * generate e.g. transfer_unmap and flush partially-uninitialized
+ * set_constant_buffer to the driver if it was done afterwards.
+ */
u_upload_data(tc->base.const_uploader, 0, cb->buffer_size, tc->ubo_alignment,
cb->user_buffer, &offset, &buffer);
u_upload_unmap(tc->base.const_uploader);
+
+ struct tc_constant_buffer *p =
+ tc_add_struct_typed_call(tc, TC_CALL_set_constant_buffer,
+ tc_constant_buffer);
+ p->shader = shader;
+ p->index = index;
+ p->cb.buffer_size = cb->buffer_size;
+ p->cb.user_buffer = NULL;
+ p->cb.buffer_offset = offset;
+ p->cb.buffer = buffer;
+ return;
}
struct tc_constant_buffer *p =
p->index = index;
if (cb) {
- if (cb->user_buffer) {
- p->cb.buffer_size = cb->buffer_size;
- p->cb.user_buffer = NULL;
- p->cb.buffer_offset = offset;
- p->cb.buffer = buffer;
- } else {
- tc_set_resource_reference(&p->cb.buffer,
- cb->buffer);
- p->cb.user_buffer = NULL;
- p->cb.buffer_offset = cb->buffer_offset;
- p->cb.buffer_size = cb->buffer_size;
- }
+ tc_set_resource_reference(&p->cb.buffer, cb->buffer);
+ p->cb.user_buffer = NULL;
+ p->cb.buffer_offset = cb->buffer_offset;
+ p->cb.buffer_size = cb->buffer_size;
} else {
memset(&p->cb, 0, sizeof(*cb));
}