From 4f8a548af1b6041738e7ed90ea29ca45415eac3b Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 6 Feb 2023 14:15:34 -0500 Subject: [PATCH] zink: allow multiple gpl libraries in zink_create_gfx_pipeline_combined() Part-of: --- src/gallium/drivers/zink/zink_pipeline.c | 11 ++++++++--- src/gallium/drivers/zink/zink_pipeline.h | 3 +-- src/gallium/drivers/zink/zink_program.c | 2 +- src/gallium/drivers/zink/zink_program_state.hpp | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/zink/zink_pipeline.c b/src/gallium/drivers/zink/zink_pipeline.c index 23c69008f13..7a38bd102f3 100644 --- a/src/gallium/drivers/zink/zink_pipeline.c +++ b/src/gallium/drivers/zink/zink_pipeline.c @@ -771,16 +771,21 @@ zink_create_gfx_pipeline_library(struct zink_screen *screen, struct zink_gfx_pro } VkPipeline -zink_create_gfx_pipeline_combined(struct zink_screen *screen, struct zink_gfx_program *prog, VkPipeline input, VkPipeline library, VkPipeline output, bool optimized) +zink_create_gfx_pipeline_combined(struct zink_screen *screen, struct zink_gfx_program *prog, VkPipeline input, VkPipeline *library, unsigned libcount, VkPipeline output, bool optimized) { - VkPipeline libraries[] = {input, library, output}; + VkPipeline libraries[4]; + libraries[0] = input; + libraries[2] = libraries[3] = output; + for (unsigned i = 0; i < libcount; i++) + libraries[1 + i] = library[i]; VkPipelineLibraryCreateInfoKHR libstate = {0}; libstate.sType = VK_STRUCTURE_TYPE_PIPELINE_LIBRARY_CREATE_INFO_KHR; - libstate.libraryCount = 3; + libstate.libraryCount = 2 + libcount; libstate.pLibraries = libraries; VkGraphicsPipelineCreateInfo pci = {0}; pci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; + pci.layout = prog->base.layout; if (optimized) pci.flags = VK_PIPELINE_CREATE_LINK_TIME_OPTIMIZATION_BIT_EXT; else diff --git a/src/gallium/drivers/zink/zink_pipeline.h b/src/gallium/drivers/zink/zink_pipeline.h index 7c0f1ea29e6..5ef36b56c2e 100644 --- a/src/gallium/drivers/zink/zink_pipeline.h +++ b/src/gallium/drivers/zink/zink_pipeline.h @@ -53,8 +53,7 @@ zink_create_gfx_pipeline_library(struct zink_screen *screen, struct zink_gfx_pro VkPipeline zink_create_gfx_pipeline_output(struct zink_screen *screen, struct zink_gfx_pipeline_state *state); VkPipeline -zink_create_gfx_pipeline_combined(struct zink_screen *screen, struct zink_gfx_program *prog, VkPipeline input, VkPipeline library, VkPipeline output, bool optimized); - +zink_create_gfx_pipeline_combined(struct zink_screen *screen, struct zink_gfx_program *prog, VkPipeline input, VkPipeline *library, unsigned libcount, VkPipeline output, bool optimized); #ifdef __cplusplus } #endif diff --git a/src/gallium/drivers/zink/zink_program.c b/src/gallium/drivers/zink/zink_program.c index 4f7d8d767b1..02ec650145b 100644 --- a/src/gallium/drivers/zink/zink_program.c +++ b/src/gallium/drivers/zink/zink_program.c @@ -715,7 +715,7 @@ optimized_compile_job(void *data, void *gdata, int thread_index) struct zink_screen *screen = gdata; VkPipeline pipeline; if (pc_entry->gkey) - pipeline = zink_create_gfx_pipeline_combined(screen, pc_entry->prog, pc_entry->ikey->pipeline, pc_entry->gkey->pipeline, pc_entry->okey->pipeline, true); + pipeline = zink_create_gfx_pipeline_combined(screen, pc_entry->prog, pc_entry->ikey->pipeline, &pc_entry->gkey->pipeline, 1, pc_entry->okey->pipeline, true); else pipeline = zink_create_gfx_pipeline(screen, pc_entry->prog, &pc_entry->state, pc_entry->state.element_state->binding_map, zink_primitive_topology(pc_entry->state.gfx_prim_mode), true); if (pipeline) { diff --git a/src/gallium/drivers/zink/zink_program_state.hpp b/src/gallium/drivers/zink/zink_program_state.hpp index b83d227a4a2..308320a7b54 100644 --- a/src/gallium/drivers/zink/zink_program_state.hpp +++ b/src/gallium/drivers/zink/zink_program_state.hpp @@ -270,7 +270,7 @@ zink_get_gfx_pipeline(struct zink_context *ctx, pc_entry->gkey = gkey; pc_entry->okey = okey; /* create the non-optimized pipeline first using fast-linking to avoid stuttering */ - pipeline = zink_create_gfx_pipeline_combined(screen, prog, ikey->pipeline, gkey->pipeline, okey->pipeline, false); + pipeline = zink_create_gfx_pipeline_combined(screen, prog, ikey->pipeline, &gkey->pipeline, 1, okey->pipeline, false); } else { /* optimize by default only when expecting precompiles in order to reduce stuttering */ pipeline = zink_create_gfx_pipeline(screen, prog, state, state->element_state->binding_map, vkmode, !HAVE_LIB);