diff options
author | Fernando Sahmkow <fsahmkow27@gmail.com> | 2020-01-07 22:45:12 +0100 |
---|---|---|
committer | FernandoS27 <fsahmkow27@gmail.com> | 2020-01-24 21:44:47 +0100 |
commit | 7c530e06661d760eb6366724d109468423363072 (patch) | |
tree | 529a0bdfb0aa41773468be8966d9f5c8738e6e3d /src/video_core/shader/track.cpp | |
parent | Shader_IR: Implement Injectable Custom Variables to the IR. (diff) | |
download | yuzu-7c530e06661d760eb6366724d109468423363072.tar yuzu-7c530e06661d760eb6366724d109468423363072.tar.gz yuzu-7c530e06661d760eb6366724d109468423363072.tar.bz2 yuzu-7c530e06661d760eb6366724d109468423363072.tar.lz yuzu-7c530e06661d760eb6366724d109468423363072.tar.xz yuzu-7c530e06661d760eb6366724d109468423363072.tar.zst yuzu-7c530e06661d760eb6366724d109468423363072.zip |
Diffstat (limited to 'src/video_core/shader/track.cpp')
-rw-r--r-- | src/video_core/shader/track.cpp | 29 |
1 files changed, 26 insertions, 3 deletions
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<std::pair<Node, Node>> DecoupleIndirectRead(const OperationNode& o return std::nullopt; } +bool AmendNodeCv(std::size_t amend_index, Node node) { + if (const auto operation = std::get_if<OperationNode>(&*node)) { + operation->SetAmendIndex(amend_index); + return true; + } else if (const auto conditional = std::get_if<ConditionalNode>(&*node)) { + conditional->SetAmendIndex(amend_index); + return true; + } + return false; +} + std::tuple<Node, TrackSampler> ShaderIR::TrackSampler(Node tracked, const NodeBlock& code, - s64 cursor) const { + s64 cursor) { if (const auto cbuf = std::get_if<CbufNode>(&*tracked)) { // Constant buffer found, test if it's an immediate const auto offset = cbuf->GetOffset(); @@ -84,9 +95,21 @@ std::tuple<Node, TrackSampler> ShaderIR::TrackSampler(Node tracked, const NodeBl } auto [gpr, base_offset] = *pair; const auto offset_inm = std::get_if<ImmediateNode>(&*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<ArraySamplerNode>(cbuf->GetIndex(), offset_inm->GetValue(), 0); + auto track = MakeTrackSampler<ArraySamplerNode>(cbuf->GetIndex(), + offset_inm->GetValue(), bindless_cv); return {tracked, track}; } return {}; |