anv: add dirty tracking of fs_msaa_flags in runtime
At the moment this is useless as the pipeline already holds the same value. But in the next changes we'll stop building this value on the pipeline to allow for more dynamic states. Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Ivan Briano <ivan.briano@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27803>
This commit is contained in:
committed by
Marge Bot
parent
25b57a6a75
commit
11b348a1c5
@@ -704,13 +704,6 @@ void anv_CmdBindPipeline(
|
||||
}
|
||||
}
|
||||
|
||||
if ((new_pipeline->fs_msaa_flags & INTEL_MSAA_FLAG_ENABLE_DYNAMIC) &&
|
||||
push->gfx.fs_msaa_flags != new_pipeline->fs_msaa_flags) {
|
||||
push->gfx.fs_msaa_flags = new_pipeline->fs_msaa_flags;
|
||||
cmd_buffer->state.push_constants_dirty |= VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
state->push_constants_data_dirty = true;
|
||||
}
|
||||
|
||||
anv_cmd_buffer_flush_pipeline_state(cmd_buffer, old_pipeline, new_pipeline);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -3157,6 +3157,7 @@ enum anv_cmd_dirty_bits {
|
||||
ANV_CMD_DIRTY_XFB_ENABLE = 1 << 4,
|
||||
ANV_CMD_DIRTY_RESTART_INDEX = 1 << 5,
|
||||
ANV_CMD_DIRTY_OCCLUSION_QUERY_ACTIVE = 1 << 6,
|
||||
ANV_CMD_DIRTY_FS_MSAA_FLAGS = 1 << 7,
|
||||
};
|
||||
typedef enum anv_cmd_dirty_bits anv_cmd_dirty_mask_t;
|
||||
|
||||
@@ -3672,6 +3673,12 @@ struct anv_cmd_graphics_state {
|
||||
struct vk_vertex_input_state vertex_input;
|
||||
struct vk_sample_locations_state sample_locations;
|
||||
|
||||
/* Dynamic msaa flags, this value can be different from
|
||||
* anv_push_constants::gfx::fs_msaa_flags, as the push constant value only
|
||||
* needs to be updated for fragment shaders dynamically checking the value.
|
||||
*/
|
||||
enum intel_msaa_flags fs_msaa_flags;
|
||||
|
||||
bool object_preemption;
|
||||
bool has_uint_rt;
|
||||
|
||||
|
||||
@@ -520,6 +520,63 @@ genX(cmd_buffer_flush_gfx_runtime_state)(struct anv_cmd_buffer *cmd_buffer)
|
||||
unreachable("Invalid provoking vertex mode"); \
|
||||
} \
|
||||
|
||||
UNUSED bool fs_msaa_changed = false;
|
||||
if ((gfx->dirty & ANV_CMD_DIRTY_PIPELINE) ||
|
||||
BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_MS_ALPHA_TO_COVERAGE_ENABLE) ||
|
||||
BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_MS_RASTERIZATION_SAMPLES) ||
|
||||
BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_FSR)) {
|
||||
enum intel_msaa_flags fs_msaa_flags = 0;
|
||||
|
||||
if (wm_prog_data) {
|
||||
/* If we have any dynamic bits here, we might need to update the
|
||||
* value in the push constant for the shader.
|
||||
*/
|
||||
if (wm_prog_data->coarse_pixel_dispatch == BRW_SOMETIMES ||
|
||||
wm_prog_data->persample_dispatch == BRW_SOMETIMES ||
|
||||
wm_prog_data->alpha_to_coverage == BRW_SOMETIMES) {
|
||||
fs_msaa_flags = INTEL_MSAA_FLAG_ENABLE_DYNAMIC;
|
||||
|
||||
if (dyn->ms.rasterization_samples > 1) {
|
||||
fs_msaa_flags |= INTEL_MSAA_FLAG_MULTISAMPLE_FBO;
|
||||
|
||||
if (wm_prog_data->sample_shading) {
|
||||
assert(wm_prog_data->persample_dispatch != BRW_NEVER);
|
||||
fs_msaa_flags |= INTEL_MSAA_FLAG_PERSAMPLE_DISPATCH;
|
||||
}
|
||||
if ((pipeline->sample_shading_enable &&
|
||||
(pipeline->min_sample_shading * dyn->ms.rasterization_samples) > 1) ||
|
||||
wm_prog_data->sample_shading) {
|
||||
fs_msaa_flags |= INTEL_MSAA_FLAG_PERSAMPLE_DISPATCH |
|
||||
INTEL_MSAA_FLAG_PERSAMPLE_INTERP;
|
||||
}
|
||||
}
|
||||
|
||||
if (wm_prog_data->coarse_pixel_dispatch == BRW_SOMETIMES &&
|
||||
!(fs_msaa_flags & INTEL_MSAA_FLAG_PERSAMPLE_DISPATCH)) {
|
||||
fs_msaa_flags |= INTEL_MSAA_FLAG_COARSE_PI_MSG |
|
||||
INTEL_MSAA_FLAG_COARSE_RT_WRITES;
|
||||
}
|
||||
|
||||
if (wm_prog_data->alpha_to_coverage == BRW_SOMETIMES &&
|
||||
dyn->ms.alpha_to_coverage_enable)
|
||||
fs_msaa_flags |= INTEL_MSAA_FLAG_ALPHA_TO_COVERAGE;
|
||||
|
||||
/* Check the last push constant value and update */
|
||||
|
||||
if (gfx->base.push_constants.gfx.fs_msaa_flags != fs_msaa_flags) {
|
||||
gfx->base.push_constants.gfx.fs_msaa_flags = fs_msaa_flags;
|
||||
cmd_buffer->state.push_constants_dirty |= VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
gfx->base.push_constants_data_dirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fs_msaa_flags != gfx->fs_msaa_flags) {
|
||||
gfx->fs_msaa_flags = fs_msaa_flags;
|
||||
gfx->dirty |= ANV_CMD_DIRTY_FS_MSAA_FLAGS;
|
||||
}
|
||||
}
|
||||
|
||||
if ((gfx->dirty & (ANV_CMD_DIRTY_PIPELINE |
|
||||
ANV_CMD_DIRTY_XFB_ENABLE |
|
||||
ANV_CMD_DIRTY_OCCLUSION_QUERY_ACTIVE)) ||
|
||||
@@ -600,10 +657,11 @@ genX(cmd_buffer_flush_gfx_runtime_state)(struct anv_cmd_buffer *cmd_buffer)
|
||||
|
||||
#if GFX_VER >= 11
|
||||
if (cmd_buffer->device->vk.enabled_extensions.KHR_fragment_shading_rate &&
|
||||
(gfx->dirty & ANV_CMD_DIRTY_PIPELINE ||
|
||||
((gfx->dirty & ANV_CMD_DIRTY_PIPELINE) ||
|
||||
(gfx->dirty & ANV_CMD_DIRTY_FS_MSAA_FLAGS) ||
|
||||
BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_FSR))) {
|
||||
const bool cps_enable = wm_prog_data &&
|
||||
brw_wm_prog_data_is_coarse(wm_prog_data, pipeline->fs_msaa_flags);
|
||||
brw_wm_prog_data_is_coarse(wm_prog_data, gfx->fs_msaa_flags);
|
||||
#if GFX_VER == 11
|
||||
SET(CPS, cps.CoarsePixelShadingMode,
|
||||
cps_enable ? CPS_MODE_CONSTANT : CPS_MODE_NONE);
|
||||
|
||||
Reference in New Issue
Block a user