summaryrefslogtreecommitdiff
path: root/src/video_core/shader/track.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core/shader/track.cpp')
-rw-r--r--src/video_core/shader/track.cpp29
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
61 return std::nullopt; 61 return std::nullopt;
62} 62}
63 63
64bool AmendNodeCv(std::size_t amend_index, Node node) {
65 if (const auto operation = std::get_if<OperationNode>(&*node)) {
66 operation->SetAmendIndex(amend_index);
67 return true;
68 } else if (const auto conditional = std::get_if<ConditionalNode>(&*node)) {
69 conditional->SetAmendIndex(amend_index);
70 return true;
71 }
72 return false;
73}
74
64std::tuple<Node, TrackSampler> ShaderIR::TrackSampler(Node tracked, const NodeBlock& code, 75std::tuple<Node, TrackSampler> ShaderIR::TrackSampler(Node tracked, const NodeBlock& code,
65 s64 cursor) const { 76 s64 cursor) {
66 if (const auto cbuf = std::get_if<CbufNode>(&*tracked)) { 77 if (const auto cbuf = std::get_if<CbufNode>(&*tracked)) {
67 // Constant buffer found, test if it's an immediate 78 // Constant buffer found, test if it's an immediate
68 const auto offset = cbuf->GetOffset(); 79 const auto offset = cbuf->GetOffset();
@@ -84,9 +95,21 @@ std::tuple<Node, TrackSampler> ShaderIR::TrackSampler(Node tracked, const NodeBl
84 } 95 }
85 auto [gpr, base_offset] = *pair; 96 auto [gpr, base_offset] = *pair;
86 const auto offset_inm = std::get_if<ImmediateNode>(&*base_offset); 97 const auto offset_inm = std::get_if<ImmediateNode>(&*base_offset);
98 auto gpu_driver = locker.AccessGuestDriverProfile();
99 if (gpu_driver == nullptr) {
100 return {};
101 }
102 const u32 bindless_cv = NewCustomVariable();
103 const Node op = Operation(OperationCode::UDiv, NO_PRECISE, gpr,
104 Immediate(gpu_driver->GetTextureHandlerSize()));
105
106 const Node cv_node = GetCustomVariable(bindless_cv);
107 Node amend_op = Operation(OperationCode::Assign, cv_node, std::move(op));
108 const std::size_t amend_index = DeclareAmend(amend_op);
109 AmendNodeCv(amend_index, code[cursor]);
87 // TODO Implement Bindless Index custom variable 110 // TODO Implement Bindless Index custom variable
88 auto track = 111 auto track = MakeTrackSampler<ArraySamplerNode>(cbuf->GetIndex(),
89 MakeTrackSampler<ArraySamplerNode>(cbuf->GetIndex(), offset_inm->GetValue(), 0); 112 offset_inm->GetValue(), bindless_cv);
90 return {tracked, track}; 113 return {tracked, track};
91 } 114 }
92 return {}; 115 return {};