From 069f3869ac3a140898224c8c37d5b3b6349361a4 Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Sun, 14 Aug 2022 18:17:08 +0200 Subject: [PATCH] r600/sfn: Fix color outputs when color0 writes all Fixes: 33765aa92aa5c150873fc210e9d6c1fe22cf8646 r600/sfn: Enable NIR for pre RG hardware Signed-off-by: Gert Wollny Part-of: --- .../drivers/r600/sfn/sfn_shader_fs.cpp | 29 +++++++------------ src/gallium/drivers/r600/sfn/sfn_shader_fs.h | 2 +- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/gallium/drivers/r600/sfn/sfn_shader_fs.cpp b/src/gallium/drivers/r600/sfn/sfn_shader_fs.cpp index 18c1422cc99..794c08d837b 100644 --- a/src/gallium/drivers/r600/sfn/sfn_shader_fs.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_shader_fs.cpp @@ -112,23 +112,11 @@ bool FragmentShader::store_output(nir_intrinsic_instr *intr) { auto location = nir_intrinsic_io_semantics(intr).location; - if (location == FRAG_RESULT_COLOR) { - if (!m_dual_source_blend) { + if (location == FRAG_RESULT_COLOR && !m_dual_source_blend) { m_fs_write_all = true; - } - - return emit_export_pixel(*intr, m_dual_source_blend ? 1 : m_max_color_exports); } - if ((location >= FRAG_RESULT_DATA0 && - location <= FRAG_RESULT_DATA7) || - location == FRAG_RESULT_DEPTH || - location == FRAG_RESULT_STENCIL || - location == FRAG_RESULT_SAMPLE_MASK) - return emit_export_pixel(*intr, 1); - - sfn_log << SfnLog::err << "r600-NIR: Unimplemented store_output for " << location << ")\n"; - return false; + return emit_export_pixel(*intr); } unsigned @@ -471,7 +459,7 @@ bool FragmentShader::scan_input(nir_intrinsic_instr *intr, int index_src_id) } } -bool FragmentShader::emit_export_pixel(nir_intrinsic_instr& intr, int num_outputs) +bool FragmentShader::emit_export_pixel(nir_intrinsic_instr& intr) { RegisterVec4::Swizzle swizzle; auto semantics = nir_intrinsic_io_semantics(&intr); @@ -503,7 +491,11 @@ bool FragmentShader::emit_export_pixel(nir_intrinsic_instr& intr, int num_output ShaderOutput output(driver_location, TGSI_SEMANTIC_COLOR, write_mask); add_output(output); - for (int k = 0 ; k < num_outputs; ++k) { + unsigned color_outputs = m_fs_write_all && chip_class() >= ISA_CC_EVERGREEN ? + m_max_color_exports : 1; + + + for (unsigned k = 0; k < color_outputs; ++k) { unsigned location = (m_dual_source_blend && (semantics.location == FRAG_RESULT_COLOR) ? semantics.dual_source_blend_index : driver_location) + k - m_depth_exports; @@ -514,7 +506,7 @@ bool FragmentShader::emit_export_pixel(nir_intrinsic_instr& intr, int num_output sfn_log << SfnLog::io << "Pixel output loc:" << location << " dl:" << driver_location << " skipped because we have only " << m_max_color_exports << " CBs\n"; - continue; + return true; ; } m_last_pixel_export = new ExportInstr(ExportInstr::pixel, location, value); @@ -536,8 +528,7 @@ bool FragmentShader::emit_export_pixel(nir_intrinsic_instr& intr, int num_output m_color_export_mask |= mask; emit_instruction(m_last_pixel_export); - - }; + } } else if (semantics.location == FRAG_RESULT_DEPTH || semantics.location == FRAG_RESULT_STENCIL || semantics.location == FRAG_RESULT_SAMPLE_MASK) { diff --git a/src/gallium/drivers/r600/sfn/sfn_shader_fs.h b/src/gallium/drivers/r600/sfn/sfn_shader_fs.h index 2028b2b43df..a6b492da25f 100644 --- a/src/gallium/drivers/r600/sfn/sfn_shader_fs.h +++ b/src/gallium/drivers/r600/sfn/sfn_shader_fs.h @@ -60,7 +60,7 @@ private: bool scan_input(nir_intrinsic_instr *instr, int index_src_id); - bool emit_export_pixel(nir_intrinsic_instr& intr, int num_outputs); + bool emit_export_pixel(nir_intrinsic_instr& intr); bool emit_load_sample_mask_in(nir_intrinsic_instr* instr); bool emit_load_helper_invocation(nir_intrinsic_instr* instr); bool emit_load_sample_pos(nir_intrinsic_instr* instr);