From b10655300841bf4fe295ad076747548936d5383c Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 11 Mar 2024 09:20:07 -0400 Subject: [PATCH] zink: add even more strict checks for separate shader usage this blocks e.g., shader object usage with sample shading which cannot be used with current vk spec cc: mesa-stable Part-of: (cherry picked from commit 485b4d9abedfd747bc324d5b3858e5df3b38eec2) --- .pick_status.json | 2 +- src/gallium/drivers/zink/zink_program.c | 9 ++++++--- src/gallium/drivers/zink/zink_program.h | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 6c6ba5c3727..e5ba3fa11aa 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -524,7 +524,7 @@ "description": "zink: add even more strict checks for separate shader usage", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/gallium/drivers/zink/zink_program.c b/src/gallium/drivers/zink/zink_program.c index 34588801186..bec57ca2b74 100644 --- a/src/gallium/drivers/zink/zink_program.c +++ b/src/gallium/drivers/zink/zink_program.c @@ -727,12 +727,14 @@ zink_gfx_program_update_optimal(struct zink_context *ctx) prog = (struct zink_gfx_program*)entry->data; if (prog->is_separable) { /* shader variants can't be handled by separable programs: sync and compile */ - if (!ZINK_SHADER_KEY_OPTIMAL_IS_DEFAULT(ctx->gfx_pipeline_state.optimal_key)) + if (!ZINK_SHADER_KEY_OPTIMAL_IS_DEFAULT(ctx->gfx_pipeline_state.optimal_key) || + (prog->base.uses_shobj ? !zink_can_use_shader_objects(ctx) : !zink_can_use_pipeline_libs(ctx))) util_queue_fence_wait(&prog->base.cache_fence); /* If the optimized linked pipeline is done compiling, swap it into place. */ if (util_queue_fence_is_signalled(&prog->base.cache_fence) && /* but only if needed for ZINK_DEBUG=noopt */ - (!(zink_debug & ZINK_DEBUG_NOOPT) || !ZINK_SHADER_KEY_OPTIMAL_IS_DEFAULT(ctx->gfx_pipeline_state.optimal_key))) { + (!(zink_debug & ZINK_DEBUG_NOOPT) || !ZINK_SHADER_KEY_OPTIMAL_IS_DEFAULT(ctx->gfx_pipeline_state.optimal_key) || + (prog->base.uses_shobj ? !zink_can_use_shader_objects(ctx) : !zink_can_use_pipeline_libs(ctx)))) { prog = replace_separable_prog(screen, entry, prog); } } @@ -757,7 +759,8 @@ zink_gfx_program_update_optimal(struct zink_context *ctx) /* remove old hash */ ctx->gfx_pipeline_state.optimal_key = zink_sanitize_optimal_key(ctx->gfx_stages, ctx->gfx_pipeline_state.shader_keys_optimal.key.val); ctx->gfx_pipeline_state.final_hash ^= ctx->curr_program->last_variant_hash; - if (ctx->curr_program->is_separable && !ZINK_SHADER_KEY_OPTIMAL_IS_DEFAULT(ctx->gfx_pipeline_state.optimal_key)) { + if (ctx->curr_program->is_separable && !ZINK_SHADER_KEY_OPTIMAL_IS_DEFAULT(ctx->gfx_pipeline_state.optimal_key) && + (ctx->curr_program->base.uses_shobj ? !zink_can_use_shader_objects(ctx) : !zink_can_use_pipeline_libs(ctx))) { struct zink_gfx_program *prog = ctx->curr_program; util_queue_fence_wait(&prog->base.cache_fence); diff --git a/src/gallium/drivers/zink/zink_program.h b/src/gallium/drivers/zink/zink_program.h index 432dcb0a9e4..c5ecf99d8b3 100644 --- a/src/gallium/drivers/zink/zink_program.h +++ b/src/gallium/drivers/zink/zink_program.h @@ -418,6 +418,21 @@ zink_can_use_pipeline_libs(const struct zink_context *ctx) !ctx->is_generated_gs_bound; } +/* stricter requirements */ +ALWAYS_INLINE static bool +zink_can_use_shader_objects(const struct zink_context *ctx) +{ + return + /* TODO: if there's ever a dynamic render extension with input attachments */ + !ctx->gfx_pipeline_state.render_pass && + ZINK_SHADER_KEY_OPTIMAL_IS_DEFAULT(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 && + !ctx->gfx_pipeline_state.force_persample_interp && + !ctx->gfx_pipeline_state.min_samples && + !ctx->is_generated_gs_bound; +} + bool zink_set_rasterizer_discard(struct zink_context *ctx, bool disable); void