From 7c530e06661d760eb6366724d109468423363072 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Tue, 7 Jan 2020 17:45:12 -0400 Subject: Shader_IR: Propagate bindless index into the GL compiler. --- src/video_core/shader/track.cpp | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'src/video_core/shader/track.cpp') diff --git a/src/video_core/shader/track.cpp b/src/video_core/shader/track.cpp index 69a677394..d449b625e 100644 --- a/src/video_core/shader/track.cpp +++ b/src/video_core/shader/track.cpp @@ -61,8 +61,19 @@ std::optional> DecoupleIndirectRead(const OperationNode& o return std::nullopt; } +bool AmendNodeCv(std::size_t amend_index, Node node) { + if (const auto operation = std::get_if(&*node)) { + operation->SetAmendIndex(amend_index); + return true; + } else if (const auto conditional = std::get_if(&*node)) { + conditional->SetAmendIndex(amend_index); + return true; + } + return false; +} + std::tuple ShaderIR::TrackSampler(Node tracked, const NodeBlock& code, - s64 cursor) const { + s64 cursor) { if (const auto cbuf = std::get_if(&*tracked)) { // Constant buffer found, test if it's an immediate const auto offset = cbuf->GetOffset(); @@ -84,9 +95,21 @@ std::tuple ShaderIR::TrackSampler(Node tracked, const NodeBl } auto [gpr, base_offset] = *pair; const auto offset_inm = std::get_if(&*base_offset); + auto gpu_driver = locker.AccessGuestDriverProfile(); + if (gpu_driver == nullptr) { + return {}; + } + const u32 bindless_cv = NewCustomVariable(); + const Node op = Operation(OperationCode::UDiv, NO_PRECISE, gpr, + Immediate(gpu_driver->GetTextureHandlerSize())); + + const Node cv_node = GetCustomVariable(bindless_cv); + Node amend_op = Operation(OperationCode::Assign, cv_node, std::move(op)); + const std::size_t amend_index = DeclareAmend(amend_op); + AmendNodeCv(amend_index, code[cursor]); // TODO Implement Bindless Index custom variable - auto track = - MakeTrackSampler(cbuf->GetIndex(), offset_inm->GetValue(), 0); + auto track = MakeTrackSampler(cbuf->GetIndex(), + offset_inm->GetValue(), bindless_cv); return {tracked, track}; } return {}; -- cgit v1.2.3