Module: Mesa Branch: main Commit: c26e0e50708f5b9326920c71c8c97aabe7c86fd7 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c26e0e50708f5b9326920c71c8c97aabe7c86fd7
Author: Samuel Pitoiset <[email protected]> Date: Thu Sep 8 13:59:18 2022 +0200 radv: fix hw remapping of MRT holes with color attachments without export If a color attachment is used in a render pass but not exported by the FS, cb_shader_mask would be non-zero for this MRT. Though, to make sure the hw remapping of SPI_SHADER_COL_FORMAT<->CB_SHADER_MASK works as expected, we should also clear the unused color attachment in CB_SHADER_MASK. Otherwise, the hw will remap to the wrong MRT. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7221 Fixes: 8fcb4aa0ebd ("radv: compact MRTs to save PS export memory space") Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Bas Nieuwenhuizen <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18491> --- src/amd/vulkan/radv_pipeline.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c index c344dd43ebf..831a4691d36 100644 --- a/src/amd/vulkan/radv_pipeline.c +++ b/src/amd/vulkan/radv_pipeline.c @@ -6096,6 +6096,13 @@ radv_graphics_pipeline_init(struct radv_graphics_pipeline *pipeline, struct radv blend.spi_shader_col_format = V_028714_SPI_SHADER_32_R; } + /* In presense of MRT holes (ie. the FS exports MRT1 but not MRT0), the compiler will remap them, + * so that only MRT0 is exported and the driver will compact SPI_SHADER_COL_FORMAT to match what + * the FS actually exports. Though, to make sure the hw remapping works as expected, we should + * also clear color attachments without exports in CB_SHADER_MASK. + */ + blend.cb_shader_mask &= ps->info.ps.colors_written; + pipeline->col_format = blend.spi_shader_col_format; pipeline->cb_target_mask = blend.cb_target_mask;
