gallium/u_threaded: allow drivers to change tc_call_set_vertex_buffers function

Move the execute function pointers to struct threaded_context, so that
drivers can change it. Also move struct tc_vertex_buffers into the header
file, so that drivers can implement their own function.

This allows drivers to inline pipe_context::set_vertex_buffers for TC.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27492>
This commit is contained in:
Marek Olšák
2024-02-05 02:47:58 -05:00
committed by Marge Bot
parent b66ee99bc2
commit b23f52b7e4
2 changed files with 24 additions and 23 deletions

View File

@@ -54,13 +54,6 @@
#define TC_SENTINEL 0x5ca1ab1e
enum tc_call_id {
#define CALL(name) TC_CALL_##name,
#include "u_threaded_context_calls.h"
#undef CALL
TC_NUM_CALLS,
};
#if TC_DEBUG >= 3 || defined(TC_TRACE)
static const char *tc_call_names[] = {
#define CALL(name) #name,
@@ -75,10 +68,6 @@ static const char *tc_call_names[] = {
# define TC_TRACE_SCOPE(call_id)
#endif
typedef uint16_t (*tc_execute)(struct pipe_context *pipe, void *call);
static const tc_execute execute_func[TC_NUM_CALLS];
static void
tc_buffer_subdata(struct pipe_context *_pipe,
struct pipe_resource *resource,
@@ -448,6 +437,8 @@ batch_execute(struct tc_batch *batch, struct pipe_context *pipe, uint64_t *last,
* begin incrementing renderpass info on the first set_framebuffer_state call
*/
bool first = !batch->first_set_fb;
const tc_execute *execute_func = batch->tc->execute_func;
for (uint64_t *iter = batch->slots; iter != last;) {
struct tc_call_base *call = (struct tc_call_base *)iter;
@@ -2151,12 +2142,6 @@ tc_set_shader_buffers(struct pipe_context *_pipe,
tc->shader_buffers_writeable_mask[shader] |= writable_bitmask << start;
}
struct tc_vertex_buffers {
struct tc_call_base base;
uint8_t count;
struct pipe_vertex_buffer slot[0]; /* more will be allocated if needed */
};
static uint16_t
tc_call_set_vertex_buffers(struct pipe_context *pipe, void *call)
{
@@ -5156,12 +5141,6 @@ tc_destroy(struct pipe_context *_pipe)
FREE(tc);
}
static const tc_execute execute_func[TC_NUM_CALLS] = {
#define CALL(name) tc_call_##name,
#include "u_threaded_context_calls.h"
#undef CALL
};
void tc_driver_internal_flush_notify(struct threaded_context *tc)
{
/* Allow drivers to call this function even for internal contexts that
@@ -5419,6 +5398,10 @@ threaded_context_create(struct pipe_context *pipe,
CTX_INIT(get_intel_perf_query_data);
#undef CTX_INIT
#define CALL(name) tc->execute_func[TC_CALL_##name] = tc_call_##name;
#include "u_threaded_context_calls.h"
#undef CALL
if (out)
*out = tc;

View File

@@ -273,6 +273,13 @@ struct tc_unflushed_batch_token;
*/
#define TC_MAX_SUBDATA_BYTES 320
enum tc_call_id {
#define CALL(name) TC_CALL_##name,
#include "u_threaded_context_calls.h"
#undef CALL
TC_NUM_CALLS,
};
enum tc_binding_type {
TC_BINDING_VERTEX_BUFFER,
TC_BINDING_STREAMOUT_BUFFER,
@@ -302,6 +309,8 @@ enum tc_binding_type {
TC_BINDING_IMAGE_CS,
};
typedef uint16_t (*tc_execute)(struct pipe_context *pipe, void *call);
typedef void (*tc_replace_buffer_storage_func)(struct pipe_context *ctx,
struct pipe_resource *dst,
struct pipe_resource *src,
@@ -558,6 +567,12 @@ struct threaded_context_options {
void (*fs_parse)(void *state, struct tc_renderpass_info *info);
};
struct tc_vertex_buffers {
struct tc_call_base base;
uint8_t count;
struct pipe_vertex_buffer slot[0]; /* more will be allocated if needed */
};
struct threaded_context {
struct pipe_context base;
struct pipe_context *pipe;
@@ -652,6 +667,9 @@ struct threaded_context {
struct tc_renderpass_info *renderpass_info_recording;
/* accessed by driver thread */
struct tc_renderpass_info *renderpass_info;
/* Callbacks that call pipe_context functions. */
tc_execute execute_func[TC_NUM_CALLS];
};