diff options
| author | 2020-06-04 23:02:55 -0300 | |
|---|---|---|
| committer | 2020-06-04 23:02:55 -0300 | |
| commit | e1438f8e913293dd70fb4ee7818312c3f6d64d77 (patch) | |
| tree | c1278bc61b0177cd0a8f2661b9c0c59a9ed41bb5 /src/video_core/shader/track.cpp | |
| parent | Merge pull request #4006 from ReinUsesLisp/squash-ubos (diff) | |
| download | yuzu-e1438f8e913293dd70fb4ee7818312c3f6d64d77.tar.gz yuzu-e1438f8e913293dd70fb4ee7818312c3f6d64d77.tar.xz yuzu-e1438f8e913293dd70fb4ee7818312c3f6d64d77.zip | |
shader/track: Move bindless tracking to a separate function
Diffstat (limited to 'src/video_core/shader/track.cpp')
| -rw-r--r-- | src/video_core/shader/track.cpp | 54 |
1 files changed, 31 insertions, 23 deletions
diff --git a/src/video_core/shader/track.cpp b/src/video_core/shader/track.cpp index eb97bfd41..435f4facb 100644 --- a/src/video_core/shader/track.cpp +++ b/src/video_core/shader/track.cpp | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | namespace VideoCommon::Shader { | 14 | namespace VideoCommon::Shader { |
| 15 | 15 | ||
| 16 | namespace { | 16 | namespace { |
| 17 | |||
| 17 | std::pair<Node, s64> FindOperation(const NodeBlock& code, s64 cursor, | 18 | std::pair<Node, s64> FindOperation(const NodeBlock& code, s64 cursor, |
| 18 | OperationCode operation_code) { | 19 | OperationCode operation_code) { |
| 19 | for (; cursor >= 0; --cursor) { | 20 | for (; cursor >= 0; --cursor) { |
| @@ -72,40 +73,27 @@ bool AmendNodeCv(std::size_t amend_index, Node node) { | |||
| 72 | 73 | ||
| 73 | } // Anonymous namespace | 74 | } // Anonymous namespace |
| 74 | 75 | ||
| 75 | std::tuple<Node, TrackSampler> ShaderIR::TrackBindlessSampler(Node tracked, const NodeBlock& code, | 76 | std::pair<Node, TrackSampler> ShaderIR::TrackBindlessSampler(Node tracked, const NodeBlock& code, |
| 76 | s64 cursor) { | 77 | s64 cursor) { |
| 77 | if (const auto cbuf = std::get_if<CbufNode>(&*tracked)) { | 78 | if (const auto cbuf = std::get_if<CbufNode>(&*tracked)) { |
| 79 | const u32 cbuf_index = cbuf->GetIndex(); | ||
| 80 | |||
| 78 | // Constant buffer found, test if it's an immediate | 81 | // Constant buffer found, test if it's an immediate |
| 79 | const auto& offset = cbuf->GetOffset(); | 82 | const auto& offset = cbuf->GetOffset(); |
| 80 | if (const auto immediate = std::get_if<ImmediateNode>(&*offset)) { | 83 | if (const auto immediate = std::get_if<ImmediateNode>(&*offset)) { |
| 81 | auto track = | 84 | auto track = MakeTrackSampler<BindlessSamplerNode>(cbuf_index, immediate->GetValue()); |
| 82 | MakeTrackSampler<BindlessSamplerNode>(cbuf->GetIndex(), immediate->GetValue()); | ||
| 83 | return {tracked, track}; | 85 | return {tracked, track}; |
| 84 | } | 86 | } |
| 85 | if (const auto operation = std::get_if<OperationNode>(&*offset)) { | 87 | if (const auto operation = std::get_if<OperationNode>(&*offset)) { |
| 86 | const u32 bound_buffer = registry.GetBoundBuffer(); | 88 | const u32 bound_buffer = registry.GetBoundBuffer(); |
| 87 | if (bound_buffer != cbuf->GetIndex()) { | 89 | if (bound_buffer != cbuf_index) { |
| 88 | return {}; | 90 | return {}; |
| 89 | } | 91 | } |
| 90 | const auto pair = DecoupleIndirectRead(*operation); | 92 | if (const std::optional pair = DecoupleIndirectRead(*operation)) { |
| 91 | if (!pair) { | 93 | auto [gpr, base_offset] = *pair; |
| 92 | return {}; | 94 | return HandleBindlessIndirectRead(*cbuf, *operation, gpr, base_offset, tracked, |
| 95 | code, cursor); | ||
| 93 | } | 96 | } |
| 94 | auto [gpr, base_offset] = *pair; | ||
| 95 | const auto offset_inm = std::get_if<ImmediateNode>(&*base_offset); | ||
| 96 | const auto& gpu_driver = registry.AccessGuestDriverProfile(); | ||
| 97 | const u32 bindless_cv = NewCustomVariable(); | ||
| 98 | Node op = | ||
| 99 | Operation(OperationCode::UDiv, gpr, Immediate(gpu_driver.GetTextureHandlerSize())); | ||
| 100 | |||
| 101 | const Node cv_node = GetCustomVariable(bindless_cv); | ||
| 102 | Node amend_op = Operation(OperationCode::Assign, cv_node, std::move(op)); | ||
| 103 | const std::size_t amend_index = DeclareAmend(std::move(amend_op)); | ||
| 104 | AmendNodeCv(amend_index, code[cursor]); | ||
| 105 | // TODO Implement Bindless Index custom variable | ||
| 106 | auto track = MakeTrackSampler<ArraySamplerNode>(cbuf->GetIndex(), | ||
| 107 | offset_inm->GetValue(), bindless_cv); | ||
| 108 | return {tracked, track}; | ||
| 109 | } | 97 | } |
| 110 | return {}; | 98 | return {}; |
| 111 | } | 99 | } |
| @@ -139,6 +127,26 @@ std::tuple<Node, TrackSampler> ShaderIR::TrackBindlessSampler(Node tracked, cons | |||
| 139 | return {}; | 127 | return {}; |
| 140 | } | 128 | } |
| 141 | 129 | ||
| 130 | std::pair<Node, TrackSampler> ShaderIR::HandleBindlessIndirectRead( | ||
| 131 | const CbufNode& cbuf, const OperationNode& operation, Node gpr, Node base_offset, Node tracked, | ||
| 132 | const NodeBlock& code, s64 cursor) { | ||
| 133 | const auto offset_imm = std::get<ImmediateNode>(*base_offset); | ||
| 134 | const auto& gpu_driver = registry.AccessGuestDriverProfile(); | ||
| 135 | const u32 bindless_cv = NewCustomVariable(); | ||
| 136 | const u32 texture_handler_size = gpu_driver.GetTextureHandlerSize(); | ||
| 137 | Node op = Operation(OperationCode::UDiv, gpr, Immediate(texture_handler_size)); | ||
| 138 | |||
| 139 | Node cv_node = GetCustomVariable(bindless_cv); | ||
| 140 | Node amend_op = Operation(OperationCode::Assign, std::move(cv_node), std::move(op)); | ||
| 141 | const std::size_t amend_index = DeclareAmend(std::move(amend_op)); | ||
| 142 | AmendNodeCv(amend_index, code[cursor]); | ||
| 143 | |||
| 144 | // TODO: Implement bindless index custom variable | ||
| 145 | auto track = | ||
| 146 | MakeTrackSampler<ArraySamplerNode>(cbuf.GetIndex(), offset_imm.GetValue(), bindless_cv); | ||
| 147 | return {tracked, track}; | ||
| 148 | } | ||
| 149 | |||
| 142 | std::tuple<Node, u32, u32> ShaderIR::TrackCbuf(Node tracked, const NodeBlock& code, | 150 | std::tuple<Node, u32, u32> ShaderIR::TrackCbuf(Node tracked, const NodeBlock& code, |
| 143 | s64 cursor) const { | 151 | s64 cursor) const { |
| 144 | if (const auto cbuf = std::get_if<CbufNode>(&*tracked)) { | 152 | if (const auto cbuf = std::get_if<CbufNode>(&*tracked)) { |