From ad3a445f9606fcc40a9c493e9f6365e4e521cab1 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 18 Sep 2025 07:22:25 -0400 Subject: [PATCH] zink: various cleanups for mesh+multiview Part-of: --- src/gallium/drivers/zink/zink_pipeline.c | 3 ++- src/gallium/drivers/zink/zink_program.c | 8 ++++++-- src/gallium/drivers/zink/zink_program.h | 5 ++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/zink/zink_pipeline.c b/src/gallium/drivers/zink/zink_pipeline.c index ce943a47e88..b0b78726656 100644 --- a/src/gallium/drivers/zink/zink_pipeline.c +++ b/src/gallium/drivers/zink/zink_pipeline.c @@ -221,7 +221,8 @@ zink_create_gfx_pipeline(struct zink_screen *screen, dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_STENCIL_OP; dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE; dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_FRONT_FACE; - dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY; + if (!is_mesh) + dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY; dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_CULL_MODE; if (state->sample_locations_enabled) dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT; diff --git a/src/gallium/drivers/zink/zink_program.c b/src/gallium/drivers/zink/zink_program.c index 316f36e1071..53dd1ffb0af 100644 --- a/src/gallium/drivers/zink/zink_program.c +++ b/src/gallium/drivers/zink/zink_program.c @@ -933,10 +933,12 @@ optimized_compile_job(void *data, void *gdata, int thread_index) struct zink_gfx_pipeline_cache_entry *pc_entry = data; struct zink_screen *screen = gdata; VkPipeline pipeline; + bool is_mesh = !!pc_entry->prog->shaders[MESA_SHADER_MESH]; + VkPrimitiveTopology vkmode = is_mesh ? VK_PRIMITIVE_TOPOLOGY_MAX_ENUM : zink_primitive_topology(pc_entry->state.gfx_prim_mode); if (pc_entry->gpl.gkey) pipeline = zink_create_gfx_pipeline_combined(screen, pc_entry->prog, pc_entry->gpl.ikey->pipeline, &pc_entry->gpl.gkey->pipeline, 1, pc_entry->gpl.okey->pipeline, true, false); else - pipeline = zink_create_gfx_pipeline(screen, pc_entry->prog, pc_entry->prog->objs, &pc_entry->state, pc_entry->state.element_state->binding_map, zink_primitive_topology(pc_entry->state.gfx_prim_mode), true); + pipeline = zink_create_gfx_pipeline(screen, pc_entry->prog, pc_entry->prog->objs, &pc_entry->state, pc_entry->state.element_state->binding_map, vkmode, true); if (pipeline) { pc_entry->gpl.unoptimized_pipeline = pc_entry->pipeline; pc_entry->pipeline = pipeline; @@ -948,13 +950,15 @@ optimized_shobj_compile_job(void *data, void *gdata, int thread_index) { struct zink_gfx_pipeline_cache_entry *pc_entry = data; struct zink_screen *screen = gdata; + bool is_mesh = !!pc_entry->prog->shaders[MESA_SHADER_MESH]; + VkPrimitiveTopology vkmode = is_mesh ? VK_PRIMITIVE_TOPOLOGY_MAX_ENUM : zink_primitive_topology(pc_entry->state.gfx_prim_mode); struct zink_shader_object objs[MESA_SHADER_MESH_STAGES]; for (unsigned i = 0; i < MESA_SHADER_MESH_STAGES; i++) { objs[i].mod = VK_NULL_HANDLE; objs[i].spirv = pc_entry->shobjs[i].spirv; } - pc_entry->pipeline = zink_create_gfx_pipeline(screen, pc_entry->prog, objs, &pc_entry->state, NULL, zink_primitive_topology(pc_entry->state.gfx_prim_mode), true); + pc_entry->pipeline = zink_create_gfx_pipeline(screen, pc_entry->prog, objs, &pc_entry->state, NULL, vkmode, true); /* no unoptimized_pipeline dance */ } diff --git a/src/gallium/drivers/zink/zink_program.h b/src/gallium/drivers/zink/zink_program.h index 654e127fe2c..4d1bcc2430c 100644 --- a/src/gallium/drivers/zink/zink_program.h +++ b/src/gallium/drivers/zink/zink_program.h @@ -445,7 +445,8 @@ zink_can_use_pipeline_libs_mesh(const struct zink_context *ctx) !ctx->gfx_stages[MESA_SHADER_FRAGMENT]->info.fs.uses_sample_shading && !zink_get_fs_base_key(ctx)->fbfetch_ms && !ctx->gfx_pipeline_state.force_persample_interp && - !ctx->gfx_pipeline_state.min_samples; + !ctx->gfx_pipeline_state.min_samples && + !ctx->fb_state.viewmask; } /* stricter requirements */ @@ -456,6 +457,8 @@ zink_can_use_shader_objects_mesh(const struct zink_context *ctx) ZINK_SHADER_KEY_OPTIMAL_IS_DEFAULT_MESH(ctx->gfx_pipeline_state.optimal_key) && /* TODO: is sample shading even possible to handle with GPL? */ !ctx->gfx_stages[MESA_SHADER_FRAGMENT]->info.fs.uses_sample_shading && + /* TODO: maybe someday shader objects + viewmask */ + !ctx->gfx_stages[MESA_SHADER_MESH]->info.view_mask && !ctx->gfx_pipeline_state.force_persample_interp && !ctx->gfx_pipeline_state.min_samples; }