From 864e8f55cf48bc6c8ad95c35cbe9217449936662 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Thu, 20 Dec 2018 22:42:47 -0300 Subject: shader_ir: Add constant buffer getters --- src/video_core/shader/shader_ir.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/video_core/shader/shader_ir.cpp') diff --git a/src/video_core/shader/shader_ir.cpp b/src/video_core/shader/shader_ir.cpp index ff4e462f2..3bc9f72f5 100644 --- a/src/video_core/shader/shader_ir.cpp +++ b/src/video_core/shader/shader_ir.cpp @@ -54,6 +54,27 @@ Node ShaderIR::GetImmediate32(Instruction instr) { return Immediate(instr.alu.GetImm20_32()); } +Node ShaderIR::GetConstBuffer(u64 index_, u64 offset_) { + const auto index = static_cast(index_); + const auto offset = static_cast(offset_); + + const auto [entry, is_new] = used_cbufs.try_emplace(index); + entry->second.MarkAsUsed(offset); + + return StoreNode(CbufNode(index, Immediate(offset))); +} + +Node ShaderIR::GetConstBufferIndirect(u64 index_, u64 offset_, Node node) { + const auto index = static_cast(index_); + const auto offset = static_cast(offset_); + + const auto [entry, is_new] = used_cbufs.try_emplace(index); + entry->second.MarkAsUsedIndirect(); + + const Node final_offset = Operation(OperationCode::UAdd, NO_PRECISE, node, Immediate(offset)); + return StoreNode(CbufNode(index, final_offset)); +} + Node ShaderIR::GetPredicate(u64 pred_, bool negated) { const auto pred = static_cast(pred_); if (pred != Pred::UnusedIndex && pred != Pred::NeverExecute) { -- cgit v1.2.3