From 84e77da244e1523286cb9dfb596e42510da35b78 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 15 Sep 2020 10:54:05 -0700 Subject: [PATCH] intel/fs: Fix sampler message headers on Gen11+ when using scratch Icelake's sampler message header introduces a field in m0.3 bit 0 which controls whether the sampler state pointer should be relative to bindless sampler state base address or dynamic state base address. g0.3 bit 0 is part of the per-thread scratch space field. On older hardware, we were able to copy that along because the sampler ignored bits 4:0. Now, however, we need to mask them out. Fixes various textureGatherOffsets piglit tests when forcing the FS to run with 2048 bytes of per-thread scratch space (which is a per-thread scratch space encoding of 1, meaning bit 0 will be set). Cc: mesa-stable Reviewed-by: Jason Ekstrand Part-of: (cherry picked from commit 31290f98061acc237ba0f5d9c8c4c38ad6075c70) --- .pick_status.json | 2 +- src/intel/compiler/brw_fs.cpp | 27 ++++++++++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index a3ba8d3507d..be048a3880d 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -229,7 +229,7 @@ "description": "intel/fs: Fix sampler message headers on Gen11+ when using scratch", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "master_sha": null, "because_sha": null }, diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp index 6a77c3afd58..1122b1d6b73 100644 --- a/src/intel/compiler/brw_fs.cpp +++ b/src/intel/compiler/brw_fs.cpp @@ -5015,21 +5015,38 @@ lower_sampler_logical_send_gen7(const fs_builder &bld, fs_inst *inst, opcode op, */ ubld1.MOV(component(header, 3), sampler_handle); } else if (is_high_sampler(devinfo, sampler)) { + fs_reg sampler_state_ptr = + retype(brw_vec1_grf(0, 3), BRW_REGISTER_TYPE_UD); + + /* Gen11+ sampler message headers include bits in 4:0 which conflict + * with the ones included in g0.3 bits 4:0. Mask them out. + */ + if (devinfo->gen >= 11) { + sampler_state_ptr = ubld1.vgrf(BRW_REGISTER_TYPE_UD); + ubld1.AND(sampler_state_ptr, + retype(brw_vec1_grf(0, 3), BRW_REGISTER_TYPE_UD), + brw_imm_ud(INTEL_MASK(31, 5))); + } + if (sampler.file == BRW_IMMEDIATE_VALUE) { assert(sampler.ud >= 16); const int sampler_state_size = 16; /* 16 bytes */ - ubld1.ADD(component(header, 3), - retype(brw_vec1_grf(0, 3), BRW_REGISTER_TYPE_UD), + ubld1.ADD(component(header, 3), sampler_state_ptr, brw_imm_ud(16 * (sampler.ud / 16) * sampler_state_size)); } else { fs_reg tmp = ubld1.vgrf(BRW_REGISTER_TYPE_UD); ubld1.AND(tmp, sampler, brw_imm_ud(0x0f0)); ubld1.SHL(tmp, tmp, brw_imm_ud(4)); - ubld1.ADD(component(header, 3), - retype(brw_vec1_grf(0, 3), BRW_REGISTER_TYPE_UD), - tmp); + ubld1.ADD(component(header, 3), sampler_state_ptr, tmp); } + } else if (devinfo->gen >= 11) { + /* Gen11+ sampler message headers include bits in 4:0 which conflict + * with the ones included in g0.3 bits 4:0. Mask them out. + */ + ubld1.AND(component(header, 3), + retype(brw_vec1_grf(0, 3), BRW_REGISTER_TYPE_UD), + brw_imm_ud(INTEL_MASK(31, 5))); } }