Module: Mesa Branch: main Commit: 9ab59574ef162393f89c36980a366eeb8ecccb64 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9ab59574ef162393f89c36980a366eeb8ecccb64
Author: Marek Olšák <[email protected]> Date: Sat Dec 31 18:59:57 2022 -0500 gallium: add typedef pipe_draw_func matching the draw_vbo signature and use it We've copied the signature too many times already. This will also be used more. It intentionally deviates from the name by not including the "_vbo" part. Reviewed-by: Pierre-Eric Pelloux-Prayer <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26619> --- src/gallium/auxiliary/cso_cache/cso_context.h | 7 +------ src/gallium/drivers/r300/r300_render_stencilref.c | 7 +------ src/gallium/drivers/radeonsi/si_gfx_cs.c | 2 +- src/gallium/drivers/radeonsi/si_pipe.h | 18 ++++++------------ src/gallium/drivers/zink/zink_draw.cpp | 12 ++++++------ src/gallium/drivers/zink/zink_types.h | 8 +------- src/gallium/include/pipe/p_context.h | 15 +++++++++------ 7 files changed, 25 insertions(+), 44 deletions(-) diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h b/src/gallium/auxiliary/cso_cache/cso_context.h index 142cddf9b51..f796310d39b 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.h +++ b/src/gallium/auxiliary/cso_cache/cso_context.h @@ -43,12 +43,7 @@ struct cso_context { struct pipe_context *pipe; /* This is equal to either pipe_context::draw_vbo or u_vbuf_draw_vbo. */ - void (*draw_vbo)(struct pipe_context *pipe, - const struct pipe_draw_info *info, - unsigned drawid_offset, - const struct pipe_draw_indirect_info *indirect, - const struct pipe_draw_start_count_bias *draws, - unsigned num_draws); + pipe_draw_func draw_vbo; }; #define CSO_NO_USER_VERTEX_BUFFERS (1 << 0) diff --git a/src/gallium/drivers/r300/r300_render_stencilref.c b/src/gallium/drivers/r300/r300_render_stencilref.c index 201fd411ca5..5bcab44c0da 100644 --- a/src/gallium/drivers/r300/r300_render_stencilref.c +++ b/src/gallium/drivers/r300/r300_render_stencilref.c @@ -34,12 +34,7 @@ #include "r300_reg.h" struct r300_stencilref_context { - void (*draw_vbo)(struct pipe_context *pipe, - const struct pipe_draw_info *info, - unsigned drawid_offset, - const struct pipe_draw_indirect_info *indirect, - const struct pipe_draw_start_count_bias *draws, - unsigned num_draws); + pipe_draw_func draw_vbo; uint32_t rs_cull_mode; uint32_t zb_stencilrefmask; diff --git a/src/gallium/drivers/radeonsi/si_gfx_cs.c b/src/gallium/drivers/radeonsi/si_gfx_cs.c index 89c337b2780..23c274d256a 100644 --- a/src/gallium/drivers/radeonsi/si_gfx_cs.c +++ b/src/gallium/drivers/radeonsi/si_gfx_cs.c @@ -304,7 +304,7 @@ void si_set_tracked_regs_to_clear_state(struct si_context *ctx) BITSET_SET_RANGE(ctx->tracked_regs.reg_saved_mask, 0, SI_NUM_TRACKED_CONTEXT_REGS - 1); } -void si_install_draw_wrapper(struct si_context *sctx, pipe_draw_vbo_func wrapper, +void si_install_draw_wrapper(struct si_context *sctx, pipe_draw_func wrapper, pipe_draw_vertex_state_func vstate_wrapper) { if (wrapper) { diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index ac96d1cbfa7..237b234978a 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -961,12 +961,6 @@ struct gfx11_reg_pair { uint32_t reg_value[2]; }; -typedef void (*pipe_draw_vbo_func)(struct pipe_context *pipe, - const struct pipe_draw_info *info, - unsigned drawid_offset, - const struct pipe_draw_indirect_info *indirect, - const struct pipe_draw_start_count_bias *draws, - unsigned num_draws); typedef void (*pipe_draw_vertex_state_func)(struct pipe_context *ctx, struct pipe_vertex_state *vstate, uint32_t partial_velem_mask, @@ -1365,10 +1359,10 @@ struct si_context { */ struct hash_table *dirty_implicit_resources; - pipe_draw_vbo_func draw_vbo[2][2][2]; + pipe_draw_func draw_vbo[2][2][2]; pipe_draw_vertex_state_func draw_vertex_state[2][2][2]; /* When b.draw_vbo is a wrapper, real_draw_vbo is the real draw_vbo function */ - pipe_draw_vbo_func real_draw_vbo; + pipe_draw_func real_draw_vbo; pipe_draw_vertex_state_func real_draw_vertex_state; void (*emit_spi_map[33])(struct si_context *sctx, unsigned index); @@ -1594,7 +1588,7 @@ void gfx6_emit_cache_flush(struct si_context *sctx, struct radeon_cmdbuf *cs); /* Replace the sctx->b.draw_vbo function with a wrapper. This can be use to implement * optimizations without affecting the normal draw_vbo functions perf. */ -void si_install_draw_wrapper(struct si_context *sctx, pipe_draw_vbo_func wrapper, +void si_install_draw_wrapper(struct si_context *sctx, pipe_draw_func wrapper, pipe_draw_vertex_state_func vstate_wrapper); /* si_gpu_load.c */ @@ -2061,9 +2055,9 @@ static inline void radeon_add_to_buffer_list(struct si_context *sctx, struct rad static inline void si_select_draw_vbo(struct si_context *sctx) { - pipe_draw_vbo_func draw_vbo = sctx->draw_vbo[!!sctx->shader.tes.cso] - [!!sctx->shader.gs.cso] - [sctx->ngg]; + pipe_draw_func draw_vbo = sctx->draw_vbo[!!sctx->shader.tes.cso] + [!!sctx->shader.gs.cso] + [sctx->ngg]; pipe_draw_vertex_state_func draw_vertex_state = sctx->draw_vertex_state[!!sctx->shader.tes.cso] [!!sctx->shader.gs.cso] diff --git a/src/gallium/drivers/zink/zink_draw.cpp b/src/gallium/drivers/zink/zink_draw.cpp index 0eee77f1d72..ac911e10d2c 100644 --- a/src/gallium/drivers/zink/zink_draw.cpp +++ b/src/gallium/drivers/zink/zink_draw.cpp @@ -1307,7 +1307,7 @@ zink_launch_grid(struct pipe_context *pctx, const struct pipe_grid_info *info) template <zink_multidraw HAS_MULTIDRAW, zink_dynamic_state DYNAMIC_STATE, bool BATCH_CHANGED> static void -init_batch_changed_functions(struct zink_context *ctx, pipe_draw_vbo_func draw_vbo_array[2][6][2], pipe_draw_vertex_state_func draw_state_array[2][6][2][2]) +init_batch_changed_functions(struct zink_context *ctx, pipe_draw_func draw_vbo_array[2][6][2], pipe_draw_vertex_state_func draw_state_array[2][6][2][2]) { draw_vbo_array[HAS_MULTIDRAW][DYNAMIC_STATE][BATCH_CHANGED] = zink_draw_vbo<HAS_MULTIDRAW, DYNAMIC_STATE, BATCH_CHANGED>; draw_state_array[HAS_MULTIDRAW][DYNAMIC_STATE][0][BATCH_CHANGED] = zink_draw_vertex_state<HAS_MULTIDRAW, DYNAMIC_STATE, POPCNT_NO, BATCH_CHANGED>; @@ -1316,7 +1316,7 @@ init_batch_changed_functions(struct zink_context *ctx, pipe_draw_vbo_func draw_v template <zink_multidraw HAS_MULTIDRAW, zink_dynamic_state DYNAMIC_STATE> static void -init_dynamic_state_functions(struct zink_context *ctx, pipe_draw_vbo_func draw_vbo_array[2][6][2], pipe_draw_vertex_state_func draw_state_array[2][6][2][2]) +init_dynamic_state_functions(struct zink_context *ctx, pipe_draw_func draw_vbo_array[2][6][2], pipe_draw_vertex_state_func draw_state_array[2][6][2][2]) { init_batch_changed_functions<HAS_MULTIDRAW, DYNAMIC_STATE, false>(ctx, draw_vbo_array, draw_state_array); init_batch_changed_functions<HAS_MULTIDRAW, DYNAMIC_STATE, true>(ctx, draw_vbo_array, draw_state_array); @@ -1324,7 +1324,7 @@ init_dynamic_state_functions(struct zink_context *ctx, pipe_draw_vbo_func draw_v template <zink_multidraw HAS_MULTIDRAW> static void -init_multidraw_functions(struct zink_context *ctx, pipe_draw_vbo_func draw_vbo_array[2][6][2], pipe_draw_vertex_state_func draw_state_array[2][6][2][2]) +init_multidraw_functions(struct zink_context *ctx, pipe_draw_func draw_vbo_array[2][6][2], pipe_draw_vertex_state_func draw_state_array[2][6][2][2]) { init_dynamic_state_functions<HAS_MULTIDRAW, ZINK_NO_DYNAMIC_STATE>(ctx, draw_vbo_array, draw_state_array); init_dynamic_state_functions<HAS_MULTIDRAW, ZINK_DYNAMIC_STATE>(ctx, draw_vbo_array, draw_state_array); @@ -1335,7 +1335,7 @@ init_multidraw_functions(struct zink_context *ctx, pipe_draw_vbo_func draw_vbo_a } static void -init_all_draw_functions(struct zink_context *ctx, pipe_draw_vbo_func draw_vbo_array[2][6][2], pipe_draw_vertex_state_func draw_state_array[2][6][2][2]) +init_all_draw_functions(struct zink_context *ctx, pipe_draw_func draw_vbo_array[2][6][2], pipe_draw_vertex_state_func draw_state_array[2][6][2][2]) { init_multidraw_functions<ZINK_NO_MULTIDRAW>(ctx, draw_vbo_array, draw_state_array); init_multidraw_functions<ZINK_MULTIDRAW>(ctx, draw_vbo_array, draw_state_array); @@ -1451,8 +1451,8 @@ extern "C" void zink_init_draw_functions(struct zink_context *ctx, struct zink_screen *screen) { - pipe_draw_vbo_func draw_vbo_array[2][6] //multidraw, zink_dynamic_state - [2]; //batch changed + pipe_draw_func draw_vbo_array[2][6] //multidraw, zink_dynamic_state + [2]; //batch changed pipe_draw_vertex_state_func draw_state_array[2][6] //multidraw, zink_dynamic_state [2][2]; //has_popcnt, batch changed zink_dynamic_state dynamic; diff --git a/src/gallium/drivers/zink/zink_types.h b/src/gallium/drivers/zink/zink_types.h index d58e61f9207..d72585437c0 100644 --- a/src/gallium/drivers/zink/zink_types.h +++ b/src/gallium/drivers/zink/zink_types.h @@ -1750,12 +1750,6 @@ struct zink_rendering_info { }; -typedef void (*pipe_draw_vbo_func)(struct pipe_context *pipe, - const struct pipe_draw_info *info, - unsigned drawid_offset, - const struct pipe_draw_indirect_info *indirect, - const struct pipe_draw_start_count_bias *draws, - unsigned num_draws); typedef void (*pipe_draw_vertex_state_func)(struct pipe_context *ctx, struct pipe_vertex_state *vstate, uint32_t partial_velem_mask, @@ -1793,7 +1787,7 @@ struct zink_context { unsigned flags; - pipe_draw_vbo_func draw_vbo[2]; //batch changed + pipe_draw_func draw_vbo[2]; //batch changed pipe_draw_vertex_state_func draw_state[2]; //batch changed pipe_launch_grid_func launch_grid[2]; //batch changed diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h index 0c8d81cdf8e..802dda5c5c8 100644 --- a/src/gallium/include/pipe/p_context.h +++ b/src/gallium/include/pipe/p_context.h @@ -85,6 +85,14 @@ struct u_log_context; struct u_upload_mgr; struct util_debug_callback; struct u_vbuf; +struct pipe_context; + +typedef void (*pipe_draw_func)(struct pipe_context *pipe, + const struct pipe_draw_info *info, + unsigned drawid_offset, + const struct pipe_draw_indirect_info *indirect, + const struct pipe_draw_start_count_bias *draws, + unsigned num_draws); /** * Gallium rendering context. Basically: @@ -149,12 +157,7 @@ struct pipe_context { * \param draws array of (start, count) pairs for direct draws * \param num_draws number of direct draws; 1 for indirect multi draws */ - void (*draw_vbo)(struct pipe_context *pipe, - const struct pipe_draw_info *info, - unsigned drawid_offset, - const struct pipe_draw_indirect_info *indirect, - const struct pipe_draw_start_count_bias *draws, - unsigned num_draws); + pipe_draw_func draw_vbo; /** * Multi draw for display lists.
