From 01fc9a06bd1d09dd3b8477533e2d31d282f5431d Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Tue, 27 Dec 2022 15:57:53 +0200 Subject: [PATCH] intel/fs: enable get_buffer_size on bindless heap Signed-off-by: Lionel Landwerlin Reviewed-by: Kenneth Graunke Part-of: --- src/intel/compiler/brw_eu_defines.h | 2 ++ src/intel/compiler/brw_fs_nir.cpp | 7 ++++--- src/intel/compiler/brw_lower_logical_sends.cpp | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/intel/compiler/brw_eu_defines.h b/src/intel/compiler/brw_eu_defines.h index 0cfe546e97f..1f75ac7405a 100644 --- a/src/intel/compiler/brw_eu_defines.h +++ b/src/intel/compiler/brw_eu_defines.h @@ -916,6 +916,8 @@ enum pull_varying_constant_srcs { enum get_buffer_size_srcs { /** Surface binding table index */ GET_BUFFER_SIZE_SRC_SURFACE, + /** Surface bindless handle */ + GET_BUFFER_SIZE_SRC_SURFACE_HANDLE, /** LOD */ GET_BUFFER_SIZE_SRC_LOD, diff --git a/src/intel/compiler/brw_fs_nir.cpp b/src/intel/compiler/brw_fs_nir.cpp index 2a76a9abae9..5d3e814c451 100644 --- a/src/intel/compiler/brw_fs_nir.cpp +++ b/src/intel/compiler/brw_fs_nir.cpp @@ -5037,8 +5037,6 @@ fs_visitor::nir_emit_intrinsic(const fs_builder &bld, nir_intrinsic_instr *instr case nir_intrinsic_get_ssbo_size: { assert(nir_src_num_components(instr->src[0]) == 1); - unsigned ssbo_index = nir_src_is_const(instr->src[0]) ? - nir_src_as_uint(instr->src[0]) : 0; /* A resinfo's sampler message is used to get the buffer size. The * SIMD8's writeback message consists of four registers and SIMD16's @@ -5056,7 +5054,10 @@ fs_visitor::nir_emit_intrinsic(const fs_builder &bld, nir_intrinsic_instr *instr ubld.MOV(src_payload, brw_imm_d(0)); fs_reg srcs[GET_BUFFER_SIZE_SRCS]; - srcs[GET_BUFFER_SIZE_SRC_SURFACE] = brw_imm_ud(ssbo_index); + srcs[get_nir_src_bindless(instr->src[0]) ? + GET_BUFFER_SIZE_SRC_SURFACE_HANDLE : + GET_BUFFER_SIZE_SRC_SURFACE] = + get_nir_buffer_intrinsic_index(bld, instr); srcs[GET_BUFFER_SIZE_SRC_LOD] = src_payload; fs_inst *inst = ubld.emit(SHADER_OPCODE_GET_BUFFER_SIZE, ret_payload, srcs, GET_BUFFER_SIZE_SRCS); diff --git a/src/intel/compiler/brw_lower_logical_sends.cpp b/src/intel/compiler/brw_lower_logical_sends.cpp index 78bc0bc9905..4bd7612a741 100644 --- a/src/intel/compiler/brw_lower_logical_sends.cpp +++ b/src/intel/compiler/brw_lower_logical_sends.cpp @@ -2742,6 +2742,7 @@ lower_get_buffer_size(const fs_builder &bld, fs_inst *inst) assert(inst->exec_size == 8); fs_reg surface = inst->src[GET_BUFFER_SIZE_SRC_SURFACE]; + fs_reg surface_handle = inst->src[GET_BUFFER_SIZE_SRC_SURFACE_HANDLE]; fs_reg lod = inst->src[GET_BUFFER_SIZE_SRC_LOD]; inst->opcode = SHADER_OPCODE_SEND; @@ -2763,7 +2764,7 @@ lower_get_buffer_size(const fs_builder &bld, fs_inst *inst) inst->dst = retype(inst->dst, BRW_REGISTER_TYPE_UW); inst->sfid = BRW_SFID_SAMPLER; - setup_surface_descriptors(bld, inst, desc, surface, fs_reg() /* surface_handle */); + setup_surface_descriptors(bld, inst, desc, surface, surface_handle); } bool