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: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28017>
This commit is contained in:
Mike Blumenkrantz 2024-03-11 09:20:07 -04:00 committed by Marge Bot
parent 5910ce4b86
commit 485b4d9abe
2 changed files with 21 additions and 3 deletions

View file

@ -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);

View file

@ -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