From: Gert Wollny Date: Tue, 21 Jul 2020 09:57:52 +0000 (+0200) Subject: r600/sfn: handle querying SSBO size X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3e3068a76a6b7890a421a5537befd673349c98eb;p=mesa.git r600/sfn: handle querying SSBO size Signed-off-by: Gert Wollny Part-of: --- diff --git a/src/gallium/drivers/r600/sfn/sfn_emitssboinstruction.cpp b/src/gallium/drivers/r600/sfn/sfn_emitssboinstruction.cpp index a65a187521a..f5200405f7a 100644 --- a/src/gallium/drivers/r600/sfn/sfn_emitssboinstruction.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_emitssboinstruction.cpp @@ -98,6 +98,8 @@ bool EmitSSBOInstruction::do_emit(nir_instr* instr) return emit_image_load(intr); case nir_intrinsic_image_size: return emit_image_size(intr); + case nir_intrinsic_get_buffer_size: + return emit_buffer_size(intr); default: return false; } @@ -586,6 +588,32 @@ bool EmitSSBOInstruction::emit_image_size(const nir_intrinsic_instr *intrin) return true; } +bool EmitSSBOInstruction::emit_buffer_size(const nir_intrinsic_instr *intr) +{ + std::array dst_elms; + + + for (uint16_t i = 0; i < 4; ++i) { + dst_elms[i] = from_nir(intr->dest, (i < intr->dest.ssa.num_components) ? i : 7); + } + + GPRVector dst(dst_elms); + GPRVector src(0,{4,4,4,4}); + + auto const_offset = nir_src_as_const_value(intr->src[0]); + auto dyn_offset = PValue(); + int res_id = R600_IMAGE_REAL_RESOURCE_OFFSET; + if (const_offset) + res_id += const_offset[0].u32; + else + assert(0 && "dynamic buffer offset not supported in buffer_size"); + + emit_instruction(new FetchInstruction(dst, PValue(new GPRValue(0, 7)), + res_id, bim_none)); + + return true; +} + GPRVector EmitSSBOInstruction::make_dest(const nir_intrinsic_instr* ir) { GPRVector::Values v; diff --git a/src/gallium/drivers/r600/sfn/sfn_emitssboinstruction.h b/src/gallium/drivers/r600/sfn/sfn_emitssboinstruction.h index 5064845d530..4c742d0658d 100644 --- a/src/gallium/drivers/r600/sfn/sfn_emitssboinstruction.h +++ b/src/gallium/drivers/r600/sfn/sfn_emitssboinstruction.h @@ -32,6 +32,7 @@ private: bool emit_image_load(const nir_intrinsic_instr *intrin); bool emit_image_store(const nir_intrinsic_instr *intrin); bool emit_ssbo_atomic_op(const nir_intrinsic_instr *intrin); + bool emit_buffer_size(const nir_intrinsic_instr *intrin); bool fetch_return_value(const nir_intrinsic_instr *intrin);