gallium/u_threaded: expose helpers for filling set_vertex_buffers externally

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27198>
This commit is contained in:
Marek Olšák
2024-01-04 22:15:09 -05:00
committed by Marge Bot
parent 0d2dfe49fe
commit 0ac5dc5ab5
2 changed files with 56 additions and 16 deletions
+16 -16
View File
@@ -827,22 +827,6 @@ tc_add_to_buffer_list(struct tc_buffer_list *next, struct pipe_resource *buf)
BITSET_SET(next->buffer_list, id & TC_BUFFER_ID_MASK);
}
/* Set a buffer binding and add it to the buffer list. */
static void
tc_bind_buffer(uint32_t *binding, struct tc_buffer_list *next, struct pipe_resource *buf)
{
uint32_t id = threaded_resource(buf)->buffer_id_unique;
*binding = id;
BITSET_SET(next->buffer_list, id & TC_BUFFER_ID_MASK);
}
/* Reset a buffer binding. */
static void
tc_unbind_buffer(uint32_t *binding)
{
*binding = 0;
}
/* Reset a range of buffer binding slots. */
static void
tc_unbind_buffers(uint32_t *binding, unsigned count)
@@ -2193,6 +2177,22 @@ tc_set_vertex_buffers(struct pipe_context *_pipe, unsigned count,
tc->num_vertex_buffers = count;
}
struct pipe_vertex_buffer *
tc_add_set_vertex_buffers_call(struct pipe_context *_pipe, unsigned count)
{
struct threaded_context *tc = threaded_context(_pipe);
/* We don't need to unbind trailing buffers because we never touch bindings
* after num_vertex_buffers.
*/
tc->num_vertex_buffers = count;
struct tc_vertex_buffers *p =
tc_add_slot_based_call(tc, TC_CALL_set_vertex_buffers, tc_vertex_buffers, count);
p->count = count;
return p->slot;
}
struct tc_stream_outputs {
struct tc_call_base base;
unsigned count;
@@ -710,6 +710,8 @@ threaded_context_flush(struct pipe_context *_pipe,
struct tc_draw_single *
tc_add_draw_single_call(struct pipe_context *_pipe,
struct pipe_resource *index_bo);
struct pipe_vertex_buffer *
tc_add_set_vertex_buffers_call(struct pipe_context *_pipe, unsigned count);
void
tc_draw_vbo(struct pipe_context *_pipe, const struct pipe_draw_info *info,
@@ -795,6 +797,44 @@ tc_buffer_write(struct pipe_context *pipe,
pipe->buffer_subdata(pipe, buf, PIPE_MAP_WRITE | TC_TRANSFER_MAP_NO_INVALIDATE, offset, size, data);
}
static inline struct tc_buffer_list *
tc_get_next_buffer_list(struct pipe_context *_pipe)
{
struct threaded_context *tc = threaded_context(_pipe);
return &tc->buffer_lists[tc->next_buf_list];
}
/* Set a buffer binding and add it to the buffer list. */
static inline void
tc_bind_buffer(uint32_t *binding, struct tc_buffer_list *next, struct pipe_resource *buf)
{
uint32_t id = threaded_resource(buf)->buffer_id_unique;
*binding = id;
BITSET_SET(next->buffer_list, id & TC_BUFFER_ID_MASK);
}
/* Reset a buffer binding. */
static inline void
tc_unbind_buffer(uint32_t *binding)
{
*binding = 0;
}
static inline void
tc_track_vertex_buffer(struct pipe_context *_pipe, unsigned index,
struct pipe_resource *buf,
struct tc_buffer_list *next_buffer_list)
{
struct threaded_context *tc = threaded_context(_pipe);
if (buf) {
tc_bind_buffer(&tc->vertex_buffers[index], next_buffer_list, buf);
} else {
tc_unbind_buffer(&tc->vertex_buffers[index]);
}
}
#ifdef __cplusplus
}
#endif