From ec3eb87f91c17e4777acc983bb728d8a81e91069 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 14 May 2024 10:39:19 -0400 Subject: [PATCH] zink: move some flags from driver_workarounds to separate struct Part-of: --- src/gallium/drivers/zink/zink_compiler.c | 6 +++--- src/gallium/drivers/zink/zink_context.c | 10 +++++----- src/gallium/drivers/zink/zink_program.c | 4 ++-- src/gallium/drivers/zink/zink_program.h | 2 +- src/gallium/drivers/zink/zink_screen.c | 20 ++++++++++---------- src/gallium/drivers/zink/zink_types.h | 11 +++++++---- 6 files changed, 28 insertions(+), 25 deletions(-) diff --git a/src/gallium/drivers/zink/zink_compiler.c b/src/gallium/drivers/zink/zink_compiler.c index 3e2099fbc4f..e63d88bbc68 100644 --- a/src/gallium/drivers/zink/zink_compiler.c +++ b/src/gallium/drivers/zink/zink_compiler.c @@ -1398,7 +1398,7 @@ zink_screen_init_compiler(struct zink_screen *screen) screen->nir_options.max_unroll_iterations_fp64 = 32; } - if (screen->driver_workarounds.io_opt) { + if (screen->driver_compiler_workarounds.io_opt) { screen->nir_options.io_options |= nir_io_glsl_opt_varyings; switch (zink_driverid(screen)) { @@ -2998,7 +2998,7 @@ zink_compiler_assign_io(struct zink_screen *screen, nir_shader *producer, nir_sh nir_shader_instructions_pass(consumer, rewrite_read_as_0, nir_metadata_dominance, var_in); } } - if (consumer->info.stage == MESA_SHADER_FRAGMENT && screen->driver_workarounds.needs_sanitised_layer) + if (consumer->info.stage == MESA_SHADER_FRAGMENT && screen->driver_compiler_workarounds.needs_sanitised_layer) do_fixup |= clamp_layer_output(producer, consumer, &io.reserved); } nir_shader_gather_info(producer, nir_shader_get_entrypoint(producer)); @@ -3671,7 +3671,7 @@ lower_zs_swizzle_tex_instr(nir_builder *b, nir_instr *instr, void *data) * draw-time shader recompile to do so. * * We may also need to apply shader swizzles for - * driver_workarounds.needs_zs_shader_swizzle. + * driver_compiler_workarounds.needs_zs_shader_swizzle. */ static bool lower_zs_swizzle_tex(nir_shader *nir, const void *swizzle, bool shadow_only) diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index 132b9fb7120..bf38f4f0c6e 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -634,7 +634,7 @@ get_imageview_for_binding(struct zink_context *ctx, gl_shader_stage stage, enum if (ctx->di.emulate_nonseamless[stage] & ctx->di.cubes[stage] & BITFIELD_BIT(idx)) return sampler_view->cube_array; bool needs_zs_shader_swizzle = (ctx->di.zs_swizzle[stage].mask & BITFIELD_BIT(idx)) && - zink_screen(ctx->base.screen)->driver_workarounds.needs_zs_shader_swizzle; + zink_screen(ctx->base.screen)->driver_compiler_workarounds.needs_zs_shader_swizzle; bool needs_shadow_shader_swizzle = (stage == MESA_SHADER_FRAGMENT) && ctx->gfx_stages[MESA_SHADER_FRAGMENT] && (ctx->di.zs_swizzle[MESA_SHADER_FRAGMENT].mask & ctx->gfx_stages[MESA_SHADER_FRAGMENT]->fs.legacy_shadow_mask & BITFIELD_BIT(idx)); if (sampler_view->zs_view && (needs_zs_shader_swizzle || needs_shadow_shader_swizzle)) @@ -1146,7 +1146,7 @@ zink_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *pres, * value for stencil, which also uses that view). */ if (ivci.subresourceRange.aspectMask == VK_IMAGE_ASPECT_DEPTH_BIT || - zink_screen(ctx->base.screen)->driver_workarounds.needs_zs_shader_swizzle) { + zink_screen(ctx->base.screen)->driver_compiler_workarounds.needs_zs_shader_swizzle) { VkComponentSwizzle *swizzle = (VkComponentSwizzle*)&ivci.components; for (unsigned i = 0; i < 4; i++) { if (swizzle[i] == VK_COMPONENT_SWIZZLE_ONE || @@ -2982,7 +2982,7 @@ begin_rendering(struct zink_context *ctx, bool check_msaa_expand) ALWAYS_INLINE static void update_layered_rendering_state(struct zink_context *ctx) { - if (!zink_screen(ctx->base.screen)->driver_workarounds.needs_sanitised_layer) + if (!zink_screen(ctx->base.screen)->driver_compiler_workarounds.needs_sanitised_layer) return; unsigned framebffer_is_layered = zink_framebuffer_get_num_layers(&ctx->fb_state) > 1; VKCTX(CmdPushConstants)( @@ -5263,10 +5263,10 @@ zink_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags) ctx->gfx_pipeline_state.shader_keys.key[MESA_SHADER_FRAGMENT].size = sizeof(struct zink_fs_key); /* this condition must be updated if new fields are added to zink_cs_key */ - if (screen->driver_workarounds.lower_robustImageAccess2) + if (screen->driver_compiler_workarounds.lower_robustImageAccess2) ctx->compute_pipeline_state.key.size = sizeof(struct zink_cs_key); - if (is_robust && screen->driver_workarounds.lower_robustImageAccess2) { + if (is_robust && screen->driver_compiler_workarounds.lower_robustImageAccess2) { ctx->compute_pipeline_state.key.key.cs.robust_access = true; for (gl_shader_stage pstage = MESA_SHADER_VERTEX; pstage < MESA_SHADER_FRAGMENT; pstage++) ctx->gfx_pipeline_state.shader_keys.key[pstage].key.vs_base.robust_access = true; diff --git a/src/gallium/drivers/zink/zink_program.c b/src/gallium/drivers/zink/zink_program.c index 8d211a13dbc..00534efb8da 100644 --- a/src/gallium/drivers/zink/zink_program.c +++ b/src/gallium/drivers/zink/zink_program.c @@ -860,7 +860,7 @@ update_cs_shader_module(struct zink_context *ctx, struct zink_compute_program *c struct zink_shader_module *zm = NULL; unsigned inline_size = 0, nonseamless_size = 0, zs_swizzle_size = 0; struct zink_shader_key *key = &ctx->compute_pipeline_state.key; - ASSERTED bool check_robustness = screen->driver_workarounds.lower_robustImageAccess2 && (ctx->flags & PIPE_CONTEXT_ROBUST_BUFFER_ACCESS); + ASSERTED bool check_robustness = screen->driver_compiler_workarounds.lower_robustImageAccess2 && (ctx->flags & PIPE_CONTEXT_ROBUST_BUFFER_ACCESS); assert(zink_cs_key(key)->robust_access == check_robustness); if (ctx && zs->info.num_inlinable_uniforms && @@ -2007,7 +2007,7 @@ zink_bind_fs_state(struct pipe_context *pctx, } zink_set_zs_needs_shader_swizzle_key(ctx, MESA_SHADER_FRAGMENT, false); if (shadow_mask != ctx->gfx_stages[MESA_SHADER_FRAGMENT]->fs.legacy_shadow_mask && - !zink_screen(pctx->screen)->driver_workarounds.needs_zs_shader_swizzle) + !zink_screen(pctx->screen)->driver_compiler_workarounds.needs_zs_shader_swizzle) zink_update_shadow_samplerviews(ctx, shadow_mask | ctx->gfx_stages[MESA_SHADER_FRAGMENT]->fs.legacy_shadow_mask); if (!ctx->track_renderpasses && !ctx->blitting) ctx->rp_tc_info_updated = true; diff --git a/src/gallium/drivers/zink/zink_program.h b/src/gallium/drivers/zink/zink_program.h index 2431df2a99a..65f9fa66381 100644 --- a/src/gallium/drivers/zink/zink_program.h +++ b/src/gallium/drivers/zink/zink_program.h @@ -386,7 +386,7 @@ zink_set_shader_key_base(struct zink_context *ctx, gl_shader_stage pstage) static inline void zink_set_zs_needs_shader_swizzle_key(struct zink_context *ctx, gl_shader_stage pstage, bool swizzle_update) { - if (!zink_screen(ctx->base.screen)->driver_workarounds.needs_zs_shader_swizzle) { + if (!zink_screen(ctx->base.screen)->driver_compiler_workarounds.needs_zs_shader_swizzle) { if (pstage != MESA_SHADER_FRAGMENT) return; const struct zink_fs_key_base *fs = zink_get_fs_base_key(ctx); diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c index 7ad8cc1ba2c..87361cbae37 100644 --- a/src/gallium/drivers/zink/zink_screen.c +++ b/src/gallium/drivers/zink/zink_screen.c @@ -660,7 +660,7 @@ zink_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_ROBUST_BUFFER_ACCESS_BEHAVIOR: return screen->info.feats.features.robustBufferAccess && - (screen->info.rb2_feats.robustImageAccess2 || screen->driver_workarounds.lower_robustImageAccess2); + (screen->info.rb2_feats.robustImageAccess2 || screen->driver_compiler_workarounds.lower_robustImageAccess2); case PIPE_CAP_MULTI_DRAW_INDIRECT: return screen->info.feats.features.multiDrawIndirect; @@ -2955,10 +2955,10 @@ init_driver_workarounds(struct zink_screen *screen) */ switch (zink_driverid(screen)) { case VK_DRIVER_ID_IMAGINATION_PROPRIETARY: - screen->driver_workarounds.needs_sanitised_layer = true; + screen->driver_compiler_workarounds.needs_sanitised_layer = true; break; default: - screen->driver_workarounds.needs_sanitised_layer = false; + screen->driver_compiler_workarounds.needs_sanitised_layer = false; break; } /* these drivers will produce undefined results when using swizzle 1 with combined z/s textures @@ -2967,15 +2967,15 @@ init_driver_workarounds(struct zink_screen *screen) switch (zink_driverid(screen)) { case VK_DRIVER_ID_IMAGINATION_PROPRIETARY: case VK_DRIVER_ID_IMAGINATION_OPEN_SOURCE_MESA: - screen->driver_workarounds.needs_zs_shader_swizzle = true; + screen->driver_compiler_workarounds.needs_zs_shader_swizzle = true; break; default: - screen->driver_workarounds.needs_zs_shader_swizzle = false; + screen->driver_compiler_workarounds.needs_zs_shader_swizzle = false; break; } /* When robust contexts are advertised but robustImageAccess2 is not available */ - screen->driver_workarounds.lower_robustImageAccess2 = + screen->driver_compiler_workarounds.lower_robustImageAccess2 = !screen->info.rb2_feats.robustImageAccess2 && screen->info.feats.features.robustBufferAccess && screen->info.rb_image_feats.robustImageAccess; @@ -3096,9 +3096,9 @@ init_optimal_keys(struct zink_screen *screen) !screen->driver_workarounds.no_linestipple && !screen->driver_workarounds.no_linesmooth && !screen->driver_workarounds.no_hw_gl_point && - !screen->driver_workarounds.lower_robustImageAccess2 && + !screen->driver_compiler_workarounds.lower_robustImageAccess2 && !screen->driconf.emulate_point_smooth && - !screen->driver_workarounds.needs_zs_shader_swizzle; + !screen->driver_compiler_workarounds.needs_zs_shader_swizzle; if (!screen->optimal_keys && zink_debug & ZINK_DEBUG_OPTIMAL_KEYS && !(zink_debug & ZINK_DEBUG_QUIET)) { fprintf(stderr, "The following criteria are preventing optimal_keys enablement:\n"); if (screen->need_decompose_attrs) @@ -3107,7 +3107,7 @@ init_optimal_keys(struct zink_screen *screen) fprintf(stderr, "uniform inlining must be disabled (set ZINK_INLINE_UNIFORMS=0 in your env)\n"); if (screen->driconf.emulate_point_smooth) fprintf(stderr, "smooth point emulation is enabled\n"); - if (screen->driver_workarounds.needs_zs_shader_swizzle) + if (screen->driver_compiler_workarounds.needs_zs_shader_swizzle) fprintf(stderr, "Z/S shader swizzle workaround is enabled\n"); CHECK_OR_PRINT(have_EXT_line_rasterization); CHECK_OR_PRINT(line_rast_feats.stippledBresenhamLines); @@ -3521,7 +3521,7 @@ zink_internal_create_screen(const struct pipe_screen_config *config, int64_t dev zink_screen_fence_init(&screen->base); if (zink_debug & ZINK_DEBUG_IOOPT) - screen->driver_workarounds.io_opt = true; + screen->driver_compiler_workarounds.io_opt = true; zink_screen_init_compiler(screen); if (!disk_cache_init(screen)) { if (!screen->driver_name_is_inferred) diff --git a/src/gallium/drivers/zink/zink_types.h b/src/gallium/drivers/zink/zink_types.h index 13d56c5c8bc..74e93f54c21 100644 --- a/src/gallium/drivers/zink/zink_types.h +++ b/src/gallium/drivers/zink/zink_types.h @@ -1524,6 +1524,13 @@ struct zink_screen { VkExtent2D maxSampleLocationGridSize[5]; VkPipelineLayout gfx_push_constant_layout; + struct { + /* these affect shader cache */ + bool lower_robustImageAccess2; + bool needs_zs_shader_swizzle; + bool needs_sanitised_layer; + bool io_opt; + } driver_compiler_workarounds; struct { bool broken_l4a4; /* https://gitlab.khronos.org/vulkan/vulkan/-/issues/3306 @@ -1535,15 +1542,11 @@ struct zink_screen { bool disable_optimized_compile; bool always_feedback_loop; bool always_feedback_loop_zs; - bool needs_sanitised_layer; bool track_renderpasses; bool no_linestipple; bool no_linesmooth; bool no_hw_gl_point; - bool lower_robustImageAccess2; - bool needs_zs_shader_swizzle; bool can_do_invalid_linear_modifier; - bool io_opt; bool inconsistent_interpolation; bool can_2d_view_sparse; unsigned z16_unscaled_bias;