r600/sfn: Fix filling FS output gaps
authorGert Wollny <gert.wollny@collabora.com>
Fri, 30 Jun 2023 10:53:01 +0000 (12:53 +0200)
committerMarge Bot <emma+marge@anholt.net>
Fri, 30 Jun 2023 11:12:12 +0000 (11:12 +0000)
in `a << b` with gcc 13 the shift count c is masked by the
bit count, and a value larger than 32 will result in shifts
by (c & 0x1f), which will add empty instructions if all
color outputs are written and this will eventually
result in an OOM error.

Fixes: 201b46e487d3aecda005973b0b46a514184eec4b
   r600/sfn: on R600/R700 write a dummy pixel output if there is a gap

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23945>

src/gallium/drivers/r600/sfn/sfn_shader_fs.cpp

index 4345015..f0804c2 100644 (file)
@@ -595,7 +595,7 @@ FragmentShader::do_finalize()
       unsigned i = 0;
       unsigned mask = m_color_export_mask;
 
-      while (mask & (1u << (4 * i))) {
+      while (i < m_max_color_exports && (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);