summaryrefslogtreecommitdiff
path: root/src/video_core/shader
diff options
context:
space:
mode:
authorGravatar bunnei2020-04-16 21:12:33 -0400
committerGravatar GitHub2020-04-16 21:12:33 -0400
commit79c1269f0fd25e8aaf090cd1f4640a52237a3fd3 (patch)
treecef3d04b0e14887bbcb6b021d42e2420ae1588a4 /src/video_core/shader
parentMerge pull request #3600 from ReinUsesLisp/no-pointer-buf-cache (diff)
parentCMakeLists: Specify -Wextra on linux builds (diff)
downloadyuzu-79c1269f0fd25e8aaf090cd1f4640a52237a3fd3.tar.gz
yuzu-79c1269f0fd25e8aaf090cd1f4640a52237a3fd3.tar.xz
yuzu-79c1269f0fd25e8aaf090cd1f4640a52237a3fd3.zip
Merge pull request #3673 from lioncash/extra
CMakeLists: Specify -Wextra on linux builds
Diffstat (limited to 'src/video_core/shader')
-rw-r--r--src/video_core/shader/decode/image.cpp11
-rw-r--r--src/video_core/shader/shader_ir.cpp7
-rw-r--r--src/video_core/shader/track.cpp7
3 files changed, 15 insertions, 10 deletions
diff --git a/src/video_core/shader/decode/image.cpp b/src/video_core/shader/decode/image.cpp
index 0dd7a1196..85ee9aa5e 100644
--- a/src/video_core/shader/decode/image.cpp
+++ b/src/video_core/shader/decode/image.cpp
@@ -352,8 +352,10 @@ u32 ShaderIR::DecodeImage(NodeBlock& bb, u32 pc) {
352 registry.ObtainBoundSampler(static_cast<u32>(instr.image.index.Value())); 352 registry.ObtainBoundSampler(static_cast<u32>(instr.image.index.Value()));
353 } else { 353 } else {
354 const Node image_register = GetRegister(instr.gpr39); 354 const Node image_register = GetRegister(instr.gpr39);
355 const auto [base_image, buffer, offset] = TrackCbuf( 355 const auto result = TrackCbuf(image_register, global_code,
356 image_register, global_code, static_cast<s64>(global_code.size())); 356 static_cast<s64>(global_code.size()));
357 const auto buffer = std::get<1>(result);
358 const auto offset = std::get<2>(result);
357 descriptor = registry.ObtainBindlessSampler(buffer, offset); 359 descriptor = registry.ObtainBindlessSampler(buffer, offset);
358 } 360 }
359 if (!descriptor) { 361 if (!descriptor) {
@@ -497,9 +499,12 @@ Image& ShaderIR::GetImage(Tegra::Shader::Image image, Tegra::Shader::ImageType t
497 499
498Image& ShaderIR::GetBindlessImage(Tegra::Shader::Register reg, Tegra::Shader::ImageType type) { 500Image& ShaderIR::GetBindlessImage(Tegra::Shader::Register reg, Tegra::Shader::ImageType type) {
499 const Node image_register = GetRegister(reg); 501 const Node image_register = GetRegister(reg);
500 const auto [base_image, buffer, offset] = 502 const auto result =
501 TrackCbuf(image_register, global_code, static_cast<s64>(global_code.size())); 503 TrackCbuf(image_register, global_code, static_cast<s64>(global_code.size()));
502 504
505 const auto buffer = std::get<1>(result);
506 const auto offset = std::get<2>(result);
507
503 const auto it = 508 const auto it =
504 std::find_if(std::begin(used_images), std::end(used_images), 509 std::find_if(std::begin(used_images), std::end(used_images),
505 [buffer = buffer, offset = offset](const Image& entry) { 510 [buffer = buffer, offset = offset](const Image& entry) {
diff --git a/src/video_core/shader/shader_ir.cpp b/src/video_core/shader/shader_ir.cpp
index 8852c8a1b..822674926 100644
--- a/src/video_core/shader/shader_ir.cpp
+++ b/src/video_core/shader/shader_ir.cpp
@@ -56,8 +56,7 @@ Node ShaderIR::GetConstBuffer(u64 index_, u64 offset_) {
56 const auto index = static_cast<u32>(index_); 56 const auto index = static_cast<u32>(index_);
57 const auto offset = static_cast<u32>(offset_); 57 const auto offset = static_cast<u32>(offset_);
58 58
59 const auto [entry, is_new] = used_cbufs.try_emplace(index); 59 used_cbufs.try_emplace(index).first->second.MarkAsUsed(offset);
60 entry->second.MarkAsUsed(offset);
61 60
62 return MakeNode<CbufNode>(index, Immediate(offset)); 61 return MakeNode<CbufNode>(index, Immediate(offset));
63} 62}
@@ -66,8 +65,7 @@ Node ShaderIR::GetConstBufferIndirect(u64 index_, u64 offset_, Node node) {
66 const auto index = static_cast<u32>(index_); 65 const auto index = static_cast<u32>(index_);
67 const auto offset = static_cast<u32>(offset_); 66 const auto offset = static_cast<u32>(offset_);
68 67
69 const auto [entry, is_new] = used_cbufs.try_emplace(index); 68 used_cbufs.try_emplace(index).first->second.MarkAsUsedIndirect();
70 entry->second.MarkAsUsedIndirect();
71 69
72 Node final_offset = [&] { 70 Node final_offset = [&] {
73 // Attempt to inline constant buffer without a variable offset. This is done to allow 71 // Attempt to inline constant buffer without a variable offset. This is done to allow
@@ -166,6 +164,7 @@ Node ShaderIR::ConvertIntegerSize(Node value, Register::Size size, bool is_signe
166 std::move(value), Immediate(16)); 164 std::move(value), Immediate(16));
167 value = SignedOperation(OperationCode::IArithmeticShiftRight, is_signed, NO_PRECISE, 165 value = SignedOperation(OperationCode::IArithmeticShiftRight, is_signed, NO_PRECISE,
168 std::move(value), Immediate(16)); 166 std::move(value), Immediate(16));
167 return value;
169 case Register::Size::Word: 168 case Register::Size::Word:
170 // Default - do nothing 169 // Default - do nothing
171 return value; 170 return value;
diff --git a/src/video_core/shader/track.cpp b/src/video_core/shader/track.cpp
index 10739b37d..224943ad9 100644
--- a/src/video_core/shader/track.cpp
+++ b/src/video_core/shader/track.cpp
@@ -27,8 +27,9 @@ std::pair<Node, s64> FindOperation(const NodeBlock& code, s64 cursor,
27 27
28 if (const auto conditional = std::get_if<ConditionalNode>(&*node)) { 28 if (const auto conditional = std::get_if<ConditionalNode>(&*node)) {
29 const auto& conditional_code = conditional->GetCode(); 29 const auto& conditional_code = conditional->GetCode();
30 auto [found, internal_cursor] = FindOperation( 30 auto result = FindOperation(
31 conditional_code, static_cast<s64>(conditional_code.size() - 1), operation_code); 31 conditional_code, static_cast<s64>(conditional_code.size() - 1), operation_code);
32 auto& found = result.first;
32 if (found) { 33 if (found) {
33 return {std::move(found), cursor}; 34 return {std::move(found), cursor};
34 } 35 }
@@ -186,8 +187,8 @@ std::tuple<Node, u32, u32> ShaderIR::TrackCbuf(Node tracked, const NodeBlock& co
186std::optional<u32> ShaderIR::TrackImmediate(Node tracked, const NodeBlock& code, s64 cursor) const { 187std::optional<u32> ShaderIR::TrackImmediate(Node tracked, const NodeBlock& code, s64 cursor) const {
187 // Reduce the cursor in one to avoid infinite loops when the instruction sets the same register 188 // Reduce the cursor in one to avoid infinite loops when the instruction sets the same register
188 // that it uses as operand 189 // that it uses as operand
189 const auto [found, found_cursor] = 190 const auto result = TrackRegister(&std::get<GprNode>(*tracked), code, cursor - 1);
190 TrackRegister(&std::get<GprNode>(*tracked), code, cursor - 1); 191 const auto& found = result.first;
191 if (!found) { 192 if (!found) {
192 return {}; 193 return {};
193 } 194 }