From 337641cfcc952c01d0555791a7a5465abc867e0a Mon Sep 17 00:00:00 2001 From: Caio Oliveira Date: Sun, 25 Feb 2024 09:30:54 -0800 Subject: [PATCH] intel/compiler: Fix SIMD lowering when instruction needs a larger SIMD When lower_simd_width() encounters an instruction that needs a larger SIMD, for example SHADER_OPCODE_TXS_LOGICAL in Gfx4 needs at least SIMD16. In this case the builder needs to be at least as large as max_width, otherwise the group() setup will assert. Turns out this did not assert before "by accident", since it was relying on the default fs_visitor builder that had a dispatch width of 64, a bogus placeholder value, expected not to be used. However, when we changed the code to remove that builder (and the bogus value), we created a new builder in the pass shader dispatch_width -- which work fine except in the case where we want to "lower" the SIMD above the shader dispatch width. The fix is to also consider the already calculated max_width when creating the builder. Fixes: 5b8ec015f27 ("intel/compiler: Don't use fs_visitor::bld in remaining places") Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10338 Reviewed-by: Ian Romanick Part-of: --- src/intel/compiler/brw_fs_lower_simd_width.cpp | 3 ++- src/intel/compiler/elk/elk_fs.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/intel/compiler/brw_fs_lower_simd_width.cpp b/src/intel/compiler/brw_fs_lower_simd_width.cpp index 56ec355ba3b..97b26dea55f 100644 --- a/src/intel/compiler/brw_fs_lower_simd_width.cpp +++ b/src/intel/compiler/brw_fs_lower_simd_width.cpp @@ -637,7 +637,8 @@ brw_fs_lower_simd_width(fs_visitor &s) */ const unsigned max_width = MAX2(inst->exec_size, lower_width); - const fs_builder bld = fs_builder(&s).at_end(); + const fs_builder bld = + fs_builder(&s, MAX2(max_width, s.dispatch_width)).at_end(); const fs_builder ibld = bld.at(block, inst) .exec_all(inst->force_writemask_all) .group(max_width, inst->group / max_width); diff --git a/src/intel/compiler/elk/elk_fs.cpp b/src/intel/compiler/elk/elk_fs.cpp index 85b226fe22f..05ec8ba7d2e 100644 --- a/src/intel/compiler/elk/elk_fs.cpp +++ b/src/intel/compiler/elk/elk_fs.cpp @@ -5329,7 +5329,8 @@ elk_fs_visitor::lower_simd_width() */ const unsigned max_width = MAX2(inst->exec_size, lower_width); - const fs_builder bld = fs_builder(this).at_end(); + const fs_builder bld = + fs_builder(this, MAX2(max_width, dispatch_width)).at_end(); const fs_builder ibld = bld.at(block, inst) .exec_all(inst->force_writemask_all) .group(max_width, inst->group / max_width);