zink: return current pipeline object if state hasn't changed

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10508>
This commit is contained in:
Mike Blumenkrantz
2021-01-19 11:43:03 -05:00
committed by Marge Bot
parent ce31c840b6
commit e645f71c68
2 changed files with 17 additions and 2 deletions

View File

@@ -74,6 +74,9 @@ struct zink_gfx_pipeline_state {
uint32_t vertex_buffers_enabled_mask;
uint32_t vertex_strides[PIPE_MAX_ATTRIBS];
bool have_EXT_extended_dynamic_state;
VkPipeline pipeline;
enum pipe_prim_type mode;
};
struct zink_compute_pipeline_state {
@@ -83,6 +86,8 @@ struct zink_compute_pipeline_state {
bool dirty;
bool use_local_size;
uint32_t local_size[3];
VkPipeline pipeline;
};
VkPipeline

View File

@@ -884,6 +884,9 @@ zink_get_gfx_pipeline(struct zink_context *ctx,
struct zink_gfx_pipeline_state *state,
enum pipe_prim_type mode)
{
if (!state->dirty && !state->combined_dirty && !state->vertex_state_dirty && mode == state->mode)
return state->pipeline;
struct zink_screen *screen = zink_screen(ctx->base.screen);
VkPrimitiveTopology vkmode = primitive_topology(mode);
assert(vkmode <= ARRAY_SIZE(prog->pipelines));
@@ -935,7 +938,10 @@ zink_get_gfx_pipeline(struct zink_context *ctx,
assert(entry);
}
return ((struct gfx_pipeline_cache_entry *)(entry->data))->pipeline;
struct gfx_pipeline_cache_entry *cache_entry = entry->data;
state->pipeline = cache_entry->pipeline;
state->mode = mode;
return state->pipeline;
}
VkPipeline
@@ -945,6 +951,8 @@ zink_get_compute_pipeline(struct zink_screen *screen,
{
struct hash_entry *entry = NULL;
if (!state->dirty)
return state->pipeline;
if (state->dirty) {
state->hash = hash_compute_pipeline_state(state);
state->dirty = false;
@@ -968,7 +976,9 @@ zink_get_compute_pipeline(struct zink_screen *screen,
assert(entry);
}
return ((struct compute_pipeline_cache_entry *)(entry->data))->pipeline;
struct compute_pipeline_cache_entry *cache_entry = entry->data;
state->pipeline = cache_entry->pipeline;
return state->pipeline;
}