From 6d863fda2d5866d732117b8573ca4c163d2ea3cf Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Mon, 14 Apr 2025 15:42:59 +0300 Subject: [PATCH] anv/brw: move sample_shading_enable to wm_prog_data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The vulkan runtime doesn´t store this parameter in the dynamic state (since it's not a dynamic state). Just capture it at compile time and leave on the wm_prog_data. Signed-off-by: Lionel Landwerlin Reviewed-by: Tapani Pälli Part-of: --- src/intel/compiler/brw_compile_fs.cpp | 1 + src/intel/compiler/brw_compiler.h | 10 ++++++++-- src/intel/vulkan/anv_cmd_buffer.c | 1 - src/intel/vulkan/anv_pipeline.c | 4 +--- src/intel/vulkan/anv_private.h | 2 -- src/intel/vulkan/genX_gfx_state.c | 2 +- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/intel/compiler/brw_compile_fs.cpp b/src/intel/compiler/brw_compile_fs.cpp index 0f4f508287b..910d073e3b5 100644 --- a/src/intel/compiler/brw_compile_fs.cpp +++ b/src/intel/compiler/brw_compile_fs.cpp @@ -960,6 +960,7 @@ brw_nir_populate_wm_prog_data(nir_shader *shader, prog_data->sample_shading = shader->info.fs.uses_sample_shading || shader->info.outputs_read; + prog_data->api_sample_shading = key->api_sample_shading; prog_data->min_sample_shading = key->min_sample_shading; assert(key->multisample_fbo != INTEL_NEVER || diff --git a/src/intel/compiler/brw_compiler.h b/src/intel/compiler/brw_compiler.h index f4adffee351..db7347dd0bf 100644 --- a/src/intel/compiler/brw_compiler.h +++ b/src/intel/compiler/brw_compiler.h @@ -397,8 +397,7 @@ struct brw_wm_prog_key { bool ignore_sample_mask_out:1; bool coarse_pixel:1; bool null_push_constant_tbimr_workaround:1; - - uint64_t padding:1; + bool api_sample_shading:1; }; static inline bool @@ -758,6 +757,13 @@ struct brw_wm_prog_data { */ bool sample_shading; + /** True if the API wants sample shading + * + * Not used by the compiler, but useful for restore from the cache. The + * driver is expected to write the value it wants. + */ + bool api_sample_shading; + /** Min sample shading value * * Not used by the compiler, but useful for restore from the cache. The diff --git a/src/intel/vulkan/anv_cmd_buffer.c b/src/intel/vulkan/anv_cmd_buffer.c index fae5b5f0044..e3b188d6838 100644 --- a/src/intel/vulkan/anv_cmd_buffer.c +++ b/src/intel/vulkan/anv_cmd_buffer.c @@ -767,7 +767,6 @@ void anv_CmdBindPipeline( cmd_buffer->state.gfx.vs_source_hash = new_pipeline->vs_source_hash; cmd_buffer->state.gfx.fs_source_hash = new_pipeline->fs_source_hash; - cmd_buffer->state.gfx.sample_shading_enable = new_pipeline->sample_shading_enable; cmd_buffer->state.gfx.instance_multiplier = new_pipeline->instance_multiplier; cmd_buffer->state.gfx.primitive_id_index = new_pipeline->primitive_id_index; cmd_buffer->state.gfx.first_vue_slot = new_pipeline->first_vue_slot; diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c index d9d17dbc989..9c3235f1146 100644 --- a/src/intel/vulkan/anv_pipeline.c +++ b/src/intel/vulkan/anv_pipeline.c @@ -564,6 +564,7 @@ populate_wm_prog_key(struct anv_pipeline_stage *stage, key->mesh_input = is_mesh; + key->api_sample_shading = ms ? ms->sample_shading_enable : false; key->min_sample_shading = ms ? ms->min_sample_shading : 1.0f; /* Vulkan doesn't support fixed-function alpha test */ @@ -2920,9 +2921,6 @@ anv_graphics_pipeline_emit(struct anv_graphics_pipeline *pipeline, /* TODO(mesh): Mesh vs. Multiview with Instancing. */ } - if (pipeline->base.shaders[MESA_SHADER_FRAGMENT] && state->ms) - pipeline->sample_shading_enable = state->ms->sample_shading_enable; - /* Mark all color output as unused by default */ memset(pipeline->color_output_mapping, ANV_COLOR_OUTPUT_UNUSED, diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 8ae6e5b71a9..3214a5f6fc8 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -4122,7 +4122,6 @@ struct anv_cmd_graphics_state { bool kill_pixel; bool uses_xfb; - bool sample_shading_enable; uint32_t primitive_id_index; uint32_t first_vue_slot; @@ -5094,7 +5093,6 @@ struct anv_graphics_pipeline { bool kill_pixel; bool uses_xfb; - bool sample_shading_enable; /* Number of VERTEX_ELEMENT_STATE input elements used by the shader */ uint32_t vs_input_elements; diff --git a/src/intel/vulkan/genX_gfx_state.c b/src/intel/vulkan/genX_gfx_state.c index 83753371c99..b6ae000fff9 100644 --- a/src/intel/vulkan/genX_gfx_state.c +++ b/src/intel/vulkan/genX_gfx_state.c @@ -842,7 +842,7 @@ update_fs_msaa_flags(struct anv_gfx_dynamic_state *hw_state, intel_fs_msaa_flags((struct intel_fs_params) { .shader_sample_shading = wm_prog_data->sample_shading, .shader_min_sample_shading = wm_prog_data->min_sample_shading, - .state_sample_shading = gfx->sample_shading_enable, + .state_sample_shading = wm_prog_data->api_sample_shading, .rasterization_samples = dyn->ms.rasterization_samples, .coarse_pixel = !vk_fragment_shading_rate_is_disabled(&dyn->fsr), .alpha_to_coverage = dyn->ms.alpha_to_coverage_enable,