zink: remove screen info stuff from draw templates

we can initialize templates that we never need to evaluate again at
runtime, cutting the overhead for all tempaltes

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11964>
This commit is contained in:
Mike Blumenkrantz 2021-05-14 19:53:24 -04:00 committed by Marge Bot
parent 9bafcde42f
commit 59e69e8ec5
4 changed files with 23 additions and 22 deletions

View File

@ -3409,14 +3409,13 @@ zink_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
if (!ctx)
goto fail;
ctx->have_timelines = screen->info.have_KHR_timeline_semaphore;
ctx->dynamic_state = screen->info.have_EXT_extended_dynamic_state;
ctx->pipeline_changed[0] = ctx->pipeline_changed[1] = true;
ctx->gfx_pipeline_state.dirty = true;
ctx->compute_pipeline_state.dirty = true;
ctx->fb_changed = ctx->rp_changed = true;
zink_init_draw_functions(ctx);
zink_init_draw_functions(ctx, screen);
zink_init_grid_functions(ctx);
ctx->base.screen = pscreen;
@ -3579,7 +3578,6 @@ zink_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
if (tc && (struct zink_context*)tc != ctx) {
tc->bytes_mapped_limit = screen->total_mem / 4;
ctx->base.set_context_param = zink_set_context_param;
ctx->multidraw = screen->info.have_EXT_multi_draw;
}
return (struct pipe_context*)tc;

View File

@ -162,9 +162,7 @@ struct zink_context {
struct slab_child_pool transfer_pool_unsync;
struct blitter_context *blitter;
zink_multidraw multidraw : 1;
zink_dynamic_state dynamic_state : 1;
pipe_draw_vbo_func draw_vbo[2][2][2]; //multidraw, dynamic state, batch changed
pipe_draw_vbo_func draw_vbo[2]; //batch changed
pipe_launch_grid_func launch_grid[2]; //batch changed
struct pipe_device_reset_callback reset;
@ -387,7 +385,7 @@ zink_pipeline_flags_from_pipe_stage(enum pipe_shader_type pstage)
}
void
zink_init_draw_functions(struct zink_context *ctx);
zink_init_draw_functions(struct zink_context *ctx, struct zink_screen *screen);
void
zink_init_grid_functions(struct zink_context *ctx);

View File

@ -804,32 +804,33 @@ zink_launch_grid(struct pipe_context *pctx, const struct pipe_grid_info *info)
template <zink_multidraw HAS_MULTIDRAW, zink_dynamic_state HAS_DYNAMIC_STATE, bool BATCH_CHANGED>
static void
init_batch_changed_functions(struct zink_context *ctx)
init_batch_changed_functions(struct zink_context *ctx, pipe_draw_vbo_func draw_vbo_array[2][2][2])
{
ctx->draw_vbo[HAS_MULTIDRAW][HAS_DYNAMIC_STATE][BATCH_CHANGED] = zink_draw_vbo<HAS_MULTIDRAW, HAS_DYNAMIC_STATE, BATCH_CHANGED>;
draw_vbo_array[HAS_MULTIDRAW][HAS_DYNAMIC_STATE][BATCH_CHANGED] =
zink_draw_vbo<HAS_MULTIDRAW, HAS_DYNAMIC_STATE, BATCH_CHANGED>;
}
template <zink_multidraw HAS_MULTIDRAW, zink_dynamic_state HAS_DYNAMIC_STATE>
static void
init_dynamic_state_functions(struct zink_context *ctx)
init_dynamic_state_functions(struct zink_context *ctx, pipe_draw_vbo_func draw_vbo_array[2][2][2])
{
init_batch_changed_functions<HAS_MULTIDRAW, HAS_DYNAMIC_STATE, false>(ctx);
init_batch_changed_functions<HAS_MULTIDRAW, HAS_DYNAMIC_STATE, true>(ctx);
init_batch_changed_functions<HAS_MULTIDRAW, HAS_DYNAMIC_STATE, false>(ctx, draw_vbo_array);
init_batch_changed_functions<HAS_MULTIDRAW, HAS_DYNAMIC_STATE, true>(ctx, draw_vbo_array);
}
template <zink_multidraw HAS_MULTIDRAW>
static void
init_multidraw_functions(struct zink_context *ctx)
init_multidraw_functions(struct zink_context *ctx, pipe_draw_vbo_func draw_vbo_array[2][2][2])
{
init_dynamic_state_functions<HAS_MULTIDRAW, ZINK_NO_DYNAMIC_STATE>(ctx);
init_dynamic_state_functions<HAS_MULTIDRAW, ZINK_DYNAMIC_STATE>(ctx);
init_dynamic_state_functions<HAS_MULTIDRAW, ZINK_NO_DYNAMIC_STATE>(ctx, draw_vbo_array);
init_dynamic_state_functions<HAS_MULTIDRAW, ZINK_DYNAMIC_STATE>(ctx, draw_vbo_array);
}
static void
init_all_draw_functions(struct zink_context *ctx)
init_all_draw_functions(struct zink_context *ctx, pipe_draw_vbo_func draw_vbo_array[2][2][2])
{
init_multidraw_functions<ZINK_NO_MULTIDRAW>(ctx);
init_multidraw_functions<ZINK_MULTIDRAW>(ctx);
init_multidraw_functions<ZINK_NO_MULTIDRAW>(ctx, draw_vbo_array);
init_multidraw_functions<ZINK_MULTIDRAW>(ctx, draw_vbo_array);
}
template <bool BATCH_CHANGED>
@ -865,9 +866,14 @@ zink_invalid_launch_grid(struct pipe_context *pctx, const struct pipe_grid_info
extern "C"
void
zink_init_draw_functions(struct zink_context *ctx)
zink_init_draw_functions(struct zink_context *ctx, struct zink_screen *screen)
{
init_all_draw_functions(ctx);
pipe_draw_vbo_func draw_vbo_array[2][2][2]; //multidraw, dynamic state, batch changed
init_all_draw_functions(ctx, draw_vbo_array);
memcpy(ctx->draw_vbo, &draw_vbo_array[screen->info.have_EXT_multi_draw]
[screen->info.have_EXT_extended_dynamic_state],
sizeof(ctx->draw_vbo));
/* Bind a fake draw_vbo, so that draw_vbo isn't NULL, which would skip
* initialization of callbacks in upper layers (such as u_threaded_context).
*/

View File

@ -5,8 +5,7 @@
static inline void
zink_select_draw_vbo(struct zink_context *ctx)
{
ctx->base.draw_vbo = ctx->draw_vbo[ctx->multidraw][ctx->dynamic_state]
[ctx->pipeline_changed[0]];
ctx->base.draw_vbo = ctx->draw_vbo[ctx->pipeline_changed[0]];
assert(ctx->base.draw_vbo);
}