mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 04:58:05 +02:00
zink: destroy gfx program when a shader is freed
there's no sense in having these objects sitting around when they can never be used again requires adding a zink_context* pointer to each program in order to prune the hash table entry Reviewed-by: Antonio Caggiano <antonio.caggiano@collabora.com> Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5887>
This commit is contained in:
parent
9e9c8e2f79
commit
7116decfce
6 changed files with 17 additions and 15 deletions
|
|
@ -309,11 +309,14 @@ zink_compile_nir(struct zink_screen *screen, struct nir_shader *nir,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
zink_shader_free(struct zink_screen *screen, struct zink_shader *shader)
|
zink_shader_free(struct zink_context *ctx, struct zink_shader *shader)
|
||||||
{
|
{
|
||||||
|
struct zink_screen *screen = zink_screen(ctx->base.screen);
|
||||||
vkDestroyShaderModule(screen->dev, shader->shader_module, NULL);
|
vkDestroyShaderModule(screen->dev, shader->shader_module, NULL);
|
||||||
set_foreach(shader->programs, entry) {
|
set_foreach(shader->programs, entry) {
|
||||||
zink_gfx_program_remove_shader((void*)entry->key, shader);
|
struct zink_gfx_program *prog = (void*)entry->key;
|
||||||
|
_mesa_hash_table_remove_key(ctx->program_cache, prog->stages);
|
||||||
|
zink_destroy_gfx_program(screen, prog);
|
||||||
}
|
}
|
||||||
_mesa_set_destroy(shader->programs, NULL);
|
_mesa_set_destroy(shader->programs, NULL);
|
||||||
FREE(shader);
|
FREE(shader);
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
|
|
||||||
struct pipe_screen;
|
struct pipe_screen;
|
||||||
|
struct zink_context;
|
||||||
struct zink_screen;
|
struct zink_screen;
|
||||||
struct zink_gfx_program;
|
struct zink_gfx_program;
|
||||||
|
|
||||||
|
|
@ -71,6 +72,6 @@ zink_compile_nir(struct zink_screen *screen, struct nir_shader *nir,
|
||||||
const struct pipe_stream_output_info *so_info);
|
const struct pipe_stream_output_info *so_info);
|
||||||
|
|
||||||
void
|
void
|
||||||
zink_shader_free(struct zink_screen *screen, struct zink_shader *shader);
|
zink_shader_free(struct zink_context *ctx, struct zink_shader *shader);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -323,7 +323,7 @@ static void
|
||||||
zink_delete_vs_state(struct pipe_context *pctx,
|
zink_delete_vs_state(struct pipe_context *pctx,
|
||||||
void *cso)
|
void *cso)
|
||||||
{
|
{
|
||||||
zink_shader_free(zink_screen(pctx->screen), cso);
|
zink_shader_free(zink_context(pctx), cso);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
|
|
@ -350,7 +350,7 @@ static void
|
||||||
zink_delete_fs_state(struct pipe_context *pctx,
|
zink_delete_fs_state(struct pipe_context *pctx,
|
||||||
void *cso)
|
void *cso)
|
||||||
{
|
{
|
||||||
zink_shader_free(zink_screen(pctx->screen), cso);
|
zink_shader_free(zink_context(pctx), cso);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
||||||
|
|
@ -164,8 +164,7 @@ get_gfx_program(struct zink_context *ctx)
|
||||||
ctx->gfx_stages);
|
ctx->gfx_stages);
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
struct zink_gfx_program *prog;
|
struct zink_gfx_program *prog;
|
||||||
prog = zink_create_gfx_program(zink_screen(ctx->base.screen),
|
prog = zink_create_gfx_program(ctx, ctx->gfx_stages);
|
||||||
ctx->gfx_stages);
|
|
||||||
entry = _mesa_hash_table_insert(ctx->program_cache, prog->stages, prog);
|
entry = _mesa_hash_table_insert(ctx->program_cache, prog->stages, prog);
|
||||||
if (!entry)
|
if (!entry)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
||||||
|
|
@ -109,9 +109,10 @@ equals_gfx_pipeline_state(const void *a, const void *b)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct zink_gfx_program *
|
struct zink_gfx_program *
|
||||||
zink_create_gfx_program(struct zink_screen *screen,
|
zink_create_gfx_program(struct zink_context *ctx,
|
||||||
struct zink_shader *stages[PIPE_SHADER_TYPES - 1])
|
struct zink_shader *stages[PIPE_SHADER_TYPES - 1])
|
||||||
{
|
{
|
||||||
|
struct zink_screen *screen = zink_screen(ctx->base.screen);
|
||||||
struct zink_gfx_program *prog = CALLOC_STRUCT(zink_gfx_program);
|
struct zink_gfx_program *prog = CALLOC_STRUCT(zink_gfx_program);
|
||||||
if (!prog)
|
if (!prog)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
@ -152,8 +153,8 @@ fail:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
zink_gfx_program_remove_shader(struct zink_gfx_program *prog, struct zink_shader *shader)
|
gfx_program_remove_shader(struct zink_gfx_program *prog, struct zink_shader *shader)
|
||||||
{
|
{
|
||||||
enum pipe_shader_type p_stage = pipe_shader_type_from_mesa(shader->info.stage);
|
enum pipe_shader_type p_stage = pipe_shader_type_from_mesa(shader->info.stage);
|
||||||
|
|
||||||
|
|
@ -174,7 +175,7 @@ zink_destroy_gfx_program(struct zink_screen *screen,
|
||||||
|
|
||||||
for (int i = 0; i < PIPE_SHADER_TYPES - 1; ++i) {
|
for (int i = 0; i < PIPE_SHADER_TYPES - 1; ++i) {
|
||||||
if (prog->stages[i])
|
if (prog->stages[i])
|
||||||
zink_gfx_program_remove_shader(prog, prog->stages[i]);
|
gfx_program_remove_shader(prog, prog->stages[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* unref all used render-passes */
|
/* unref all used render-passes */
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include "pipe/p_state.h"
|
#include "pipe/p_state.h"
|
||||||
|
|
||||||
|
struct zink_context;
|
||||||
struct zink_screen;
|
struct zink_screen;
|
||||||
struct zink_shader;
|
struct zink_shader;
|
||||||
struct zink_gfx_pipeline_state;
|
struct zink_gfx_pipeline_state;
|
||||||
|
|
@ -45,7 +46,7 @@ struct zink_gfx_program {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct zink_gfx_program *
|
struct zink_gfx_program *
|
||||||
zink_create_gfx_program(struct zink_screen *screen,
|
zink_create_gfx_program(struct zink_context *ctx,
|
||||||
struct zink_shader *stages[PIPE_SHADER_TYPES - 1]);
|
struct zink_shader *stages[PIPE_SHADER_TYPES - 1]);
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -58,7 +59,4 @@ zink_get_gfx_pipeline(struct zink_screen *screen,
|
||||||
struct zink_gfx_pipeline_state *state,
|
struct zink_gfx_pipeline_state *state,
|
||||||
enum pipe_prim_type mode);
|
enum pipe_prim_type mode);
|
||||||
|
|
||||||
void
|
|
||||||
zink_gfx_program_remove_shader(struct zink_gfx_program *prog, struct zink_shader *shader);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue