diff --git a/src/gallium/drivers/zink/zink_program.c b/src/gallium/drivers/zink/zink_program.c index b0c3b50568c..b154a29beee 100644 --- a/src/gallium/drivers/zink/zink_program.c +++ b/src/gallium/drivers/zink/zink_program.c @@ -1525,6 +1525,17 @@ zink_create_cached_shader_state(struct pipe_context *pctx, const struct pipe_sha return util_live_shader_cache_get(pctx, &screen->shaders, shader, &cache_hit); } +void +zink_create_pipeline_lib(struct zink_screen *screen, struct zink_gfx_program *prog, struct zink_gfx_pipeline_state *state, enum pipe_prim_type mode) +{ + struct zink_gfx_library_key *gkey = rzalloc(prog, struct zink_gfx_library_key); + gkey->hw_rast_state = state->rast_state; + memcpy(gkey->modules, state->modules, sizeof(gkey->modules)); + bool line = u_reduced_prim(mode) == PIPE_PRIM_LINES; + gkey->pipeline = zink_create_gfx_pipeline_library(screen, prog, (struct zink_rasterizer_hw_state*)state, line); + _mesa_set_add(&prog->libs[get_primtype_idx(mode)], gkey); +} + void zink_program_init(struct zink_context *ctx) { diff --git a/src/gallium/drivers/zink/zink_program.h b/src/gallium/drivers/zink/zink_program.h index 790b44fa7f0..a785c302212 100644 --- a/src/gallium/drivers/zink/zink_program.h +++ b/src/gallium/drivers/zink/zink_program.h @@ -28,7 +28,7 @@ #ifdef __cplusplus extern "C" { #endif - +#include "util/u_prim.h" struct gfx_pipeline_cache_entry { struct zink_gfx_pipeline_state state; @@ -123,10 +123,29 @@ zink_gfx_program_update(struct zink_context *ctx); void zink_gfx_program_update_optimal(struct zink_context *ctx); + +void +zink_create_pipeline_lib(struct zink_screen *screen, struct zink_gfx_program *prog, struct zink_gfx_pipeline_state *state, enum pipe_prim_type mode); uint32_t hash_gfx_output(const void *key); uint32_t hash_gfx_input(const void *key); uint32_t hash_gfx_input_dynamic(const void *key); + +static inline unsigned +get_primtype_idx(enum pipe_prim_type mode) +{ + if (mode == PIPE_PRIM_PATCHES) + return 3; + switch (u_reduced_prim(mode)) { + case PIPE_PRIM_POINTS: + return 0; + case PIPE_PRIM_LINES: + return 1; + default: + return 2; + } +} + struct zink_gfx_program * zink_create_gfx_program(struct zink_context *ctx, struct zink_shader **stages, diff --git a/src/gallium/drivers/zink/zink_program_state.hpp b/src/gallium/drivers/zink/zink_program_state.hpp index 52054128774..3dbb74e1bed 100644 --- a/src/gallium/drivers/zink/zink_program_state.hpp +++ b/src/gallium/drivers/zink/zink_program_state.hpp @@ -28,7 +28,6 @@ #include "zink_pipeline.h" #include "zink_program.h" #include "zink_screen.h" -#include "util/u_prim.h" template @@ -44,32 +43,6 @@ hash_gfx_pipeline_state(const void *key) return XXH32(&state->dyn_state1, sizeof(state->dyn_state1), hash); } -static unsigned -get_primtype_idx(enum pipe_prim_type mode) -{ - if (mode == PIPE_PRIM_PATCHES) - return 3; - switch (u_reduced_prim(mode)) { - case PIPE_PRIM_POINTS: - return 0; - case PIPE_PRIM_LINES: - return 1; - default: - return 2; - } -} - -static void -create_pipeline_lib(struct zink_screen *screen, struct zink_gfx_program *prog, struct zink_gfx_pipeline_state *state, enum pipe_prim_type mode) -{ - struct zink_gfx_library_key *gkey = rzalloc(prog, struct zink_gfx_library_key); - gkey->hw_rast_state = state->rast_state; - memcpy(gkey->modules, state->modules, sizeof(gkey->modules)); - bool line = u_reduced_prim(mode) == PIPE_PRIM_LINES; - gkey->pipeline = zink_create_gfx_pipeline_library(screen, prog, (struct zink_rasterizer_hw_state*)state, line); - _mesa_set_add(&prog->libs[get_primtype_idx(mode)], gkey); -} - template static unsigned get_pipeline_idx(enum pipe_prim_type mode, VkPrimitiveTopology vkmode) @@ -240,7 +213,7 @@ zink_get_gfx_pipeline(struct zink_context *ctx, /* TODO: this will eventually be pre-populated by async shader compile */ //struct set_entry *he = _mesa_set_search(&prog->libs[idx], &ctx->gfx_pipeline_state.gkey); if (!he && (zink_debug & ZINK_DEBUG_GPL)) { - create_pipeline_lib(screen, prog, &ctx->gfx_pipeline_state, mode); + zink_create_pipeline_lib(screen, prog, &ctx->gfx_pipeline_state, mode); he = _mesa_set_search(&prog->libs[idx], &ctx->gfx_pipeline_state.gkey); assert(he); }