Mesa (main): intel/compiler: Call inst->resize_sources before setting the sources

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Mar 29 20:44:46 UTC 2022


Module: Mesa
Branch: main
Commit: 1967fd3b1018c8c609b388f4dc49afc641f501c5
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=1967fd3b1018c8c609b388f4dc49afc641f501c5

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Tue Mar 29 02:42:41 2022 -0700

intel/compiler: Call inst->resize_sources before setting the sources

You should probably resize the sources array before accessing entries
that might be out of bounds.  inst->resize_sources() always allocates
enough space for at least 3 sources, so this is really only an issue
when there are 4+ sources.

Fixes: a920979d4f3 ("intel/fs: Use split sends for surface writes on gen9+")
Fixes: 4f86a70599a ("intel/fs: Lower DW untyped r/w messages to LSC when available")
Fixes: d372abe3973 ("intel/fs: Add surface OWORD BLOCK opcodes")
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Rohan Garg <rohan.garg at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15632>

---

 src/intel/compiler/brw_fs.cpp | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp
index 683ad73fc40..507aca8c0af 100644
--- a/src/intel/compiler/brw_fs.cpp
+++ b/src/intel/compiler/brw_fs.cpp
@@ -5813,11 +5813,11 @@ lower_surface_logical_send(const fs_builder &bld, fs_inst *inst)
    inst->sfid = sfid;
    setup_surface_descriptors(bld, inst, desc, surface, surface_handle);
 
+   inst->resize_sources(4);
+
    /* Finally, the payload */
    inst->src[2] = payload;
    inst->src[3] = payload2;
-
-   inst->resize_sources(4);
 }
 
 static enum lsc_opcode
@@ -6040,11 +6040,11 @@ lower_lsc_surface_logical_send(const fs_builder &bld, fs_inst *inst)
    inst->send_has_side_effects = has_side_effects;
    inst->send_is_volatile = !has_side_effects;
 
+   inst->resize_sources(4);
+
    /* Finally, the payload */
    inst->src[2] = payload;
    inst->src[3] = payload2;
-
-   inst->resize_sources(4);
 }
 
 static void
@@ -6110,10 +6110,10 @@ lower_surface_block_logical_send(const fs_builder &bld, fs_inst *inst)
                                                     arg.ud, write);
    setup_surface_descriptors(bld, inst, desc, surface, surface_handle);
 
+   inst->resize_sources(4);
+
    inst->src[2] = header;
    inst->src[3] = data;
-
-   inst->resize_sources(4);
 }
 
 static fs_reg



More information about the mesa-commit mailing list