From 201b46e487d3aecda005973b0b46a514184eec4b Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Mon, 19 Jun 2023 08:53:49 +0200 Subject: [PATCH] r600/sfn: on R600/R700 write a dummy pixel output if there is a gap Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9223 Fixes: 98d65120cb66cf8ca9f9928b107d93af24c83776 r600/sfn: Fix FS out handling Part-of: --- .../drivers/r600/sfn/sfn_shader_fs.cpp | 23 +++++++++++++++++++ src/gallium/drivers/r600/sfn/sfn_shader_fs.h | 1 + 2 files changed, 24 insertions(+) diff --git a/src/gallium/drivers/r600/sfn/sfn_shader_fs.cpp b/src/gallium/drivers/r600/sfn/sfn_shader_fs.cpp index fad58e27f14..95f886e2886 100644 --- a/src/gallium/drivers/r600/sfn/sfn_shader_fs.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_shader_fs.cpp @@ -540,6 +540,8 @@ FragmentShader::emit_export_pixel(nir_intrinsic_instr& intr) m_fs_write_all = false; unsigned mask = (0xfu << (location * 4)); + m_color_export_written_mask |= (1 << location); + /* If the i-th target format is set, all previous target formats must * be non-zero to avoid hangs. - from radeonsi, seems to apply to eg as well. /*/ @@ -589,6 +591,27 @@ FragmentShader::emit_load_sample_pos(nir_intrinsic_instr *instr) void FragmentShader::do_finalize() { + /* On pre-evergreen not emtting something to all color exports that + * are enabled might lead to a hang. + * see: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9223 + */ + if (chip_class() < ISA_CC_EVERGREEN) { + unsigned i = 0; + unsigned mask = m_color_export_mask; + + while (mask & (1u << (4 * i))) { + if (!(m_color_export_written_mask & (1u << i))) { + RegisterVec4 value(0, false, {7, 7, 7, 7}); + m_last_pixel_export = new ExportInstr(ExportInstr::pixel, i, value); + emit_instruction(m_last_pixel_export); + m_num_color_exports++; + if (m_export_highest < i) + m_export_highest = i; + } + ++i; + } + } + if (!m_last_pixel_export) { RegisterVec4 value(0, false, {7, 7, 7, 7}); m_last_pixel_export = new ExportInstr(ExportInstr::pixel, 0, value); diff --git a/src/gallium/drivers/r600/sfn/sfn_shader_fs.h b/src/gallium/drivers/r600/sfn/sfn_shader_fs.h index 277a14ea590..faf62fc6526 100644 --- a/src/gallium/drivers/r600/sfn/sfn_shader_fs.h +++ b/src/gallium/drivers/r600/sfn/sfn_shader_fs.h @@ -76,6 +76,7 @@ private: unsigned m_num_color_exports; unsigned m_color_export_mask; ExportInstr *m_last_pixel_export; + unsigned m_color_export_written_mask{0}; std::bitset m_interpolators_used; RegisterVec4 m_pos_input;