summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/zink/zink_context.c
diff options
context:
space:
mode:
authorErik Faye-Lund <[email protected]>2019-06-19 19:14:06 +0200
committerErik Faye-Lund <[email protected]>2019-10-28 08:51:45 +0000
commita872f4636924db0198684be46cb48df9d2863916 (patch)
tree9f622a9226866fe29465493c5988f2c8a7051b8f /src/gallium/drivers/zink/zink_context.c
parent5f216373700f6c05cdb31ab52ccef4cf8b6ddf34 (diff)
zink: cache render-passes
Acked-by: Jordan Justen <[email protected]>
Diffstat (limited to 'src/gallium/drivers/zink/zink_context.c')
-rw-r--r--src/gallium/drivers/zink/zink_context.c37
1 files changed, 33 insertions, 4 deletions
diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index beefba1f755..f35017a60d9 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -443,6 +443,7 @@ zink_set_clip_state(struct pipe_context *pctx,
static struct zink_render_pass *
get_render_pass(struct zink_context *ctx)
{
+ struct zink_screen *screen = zink_screen(ctx->base.screen);
const struct pipe_framebuffer_state *fb = &ctx->fb_state;
struct zink_render_pass_state state;
@@ -458,8 +459,17 @@ get_render_pass(struct zink_context *ctx)
}
state.have_zsbuf = fb->zsbuf != NULL;
- // TODO: cache instead!
- return zink_create_render_pass(zink_screen(ctx->base.screen), &state);
+ struct hash_entry *entry = _mesa_hash_table_search(ctx->render_pass_cache,
+ &state);
+ if (!entry) {
+ struct zink_render_pass *rp;
+ rp = zink_create_render_pass(screen, &state);
+ entry = _mesa_hash_table_insert(ctx->render_pass_cache, &state, rp);
+ if (!entry)
+ return NULL;
+ }
+
+ return entry->data;
}
static struct zink_framebuffer *
@@ -471,7 +481,6 @@ get_framebuffer(struct zink_context *ctx)
struct zink_framebuffer *ret = zink_create_framebuffer(screen,
&ctx->fb_state,
rp);
- zink_render_pass_reference(screen, &rp, NULL);
return ret;
}
@@ -794,6 +803,18 @@ equals_gfx_program(const void *a, const void *b)
return memcmp(a, b, sizeof(struct zink_shader *) * (PIPE_SHADER_TYPES - 1)) == 0;
}
+static uint32_t
+hash_render_pass_state(const void *key)
+{
+ return _mesa_hash_data(key, sizeof(struct zink_render_pass_state));
+}
+
+static bool
+equals_render_pass_state(const void *a, const void *b)
+{
+ return memcmp(a, b, sizeof(struct zink_render_pass_state)) == 0;
+}
+
static struct zink_gfx_program *
get_gfx_program(struct zink_context *ctx)
{
@@ -1311,10 +1332,18 @@ zink_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
vkGetDeviceQueue(screen->dev, screen->gfx_queue, 0, &ctx->queue);
- ctx->program_cache = _mesa_hash_table_create(NULL, hash_gfx_program, equals_gfx_program);
+ ctx->program_cache = _mesa_hash_table_create(NULL,
+ hash_gfx_program,
+ equals_gfx_program);
if (!ctx->program_cache)
goto fail;
+ ctx->render_pass_cache = _mesa_hash_table_create(NULL,
+ hash_render_pass_state,
+ equals_render_pass_state);
+ if (!ctx->render_pass_cache)
+ goto fail;
+
ctx->dirty = ZINK_DIRTY_PROGRAM;
/* start the first batch */