summaryrefslogtreecommitdiff
path: root/src/video_core
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/engines/shader_bytecode.h2
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.cpp3
-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
-rw-r--r--src/video_core/texture_cache/surface_params.cpp1
-rw-r--r--src/video_core/texture_cache/texture_cache.h3
7 files changed, 20 insertions, 14 deletions
diff --git a/src/video_core/engines/shader_bytecode.h b/src/video_core/engines/shader_bytecode.h
index 5e9cfba22..7231597d4 100644
--- a/src/video_core/engines/shader_bytecode.h
+++ b/src/video_core/engines/shader_bytecode.h
@@ -1507,7 +1507,7 @@ union Instruction {
1507 1507
1508 TextureType GetTextureType() const { 1508 TextureType GetTextureType() const {
1509 // The TLDS instruction has a weird encoding for the texture type. 1509 // The TLDS instruction has a weird encoding for the texture type.
1510 if (texture_info >= 0 && texture_info <= 1) { 1510 if (texture_info <= 1) {
1511 return TextureType::Texture1D; 1511 return TextureType::Texture1D;
1512 } 1512 }
1513 if (texture_info == 2 || texture_info == 8 || texture_info == 12 || 1513 if (texture_info == 2 || texture_info == 8 || texture_info == 12 ||
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
index b1804e9ea..9495f48a2 100644
--- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
@@ -835,7 +835,8 @@ private:
835 835
836 void DeclareConstantBuffers() { 836 void DeclareConstantBuffers() {
837 u32 binding = device.GetBaseBindings(stage).uniform_buffer; 837 u32 binding = device.GetBaseBindings(stage).uniform_buffer;
838 for (const auto& [index, cbuf] : ir.GetConstantBuffers()) { 838 for (const auto& buffers : ir.GetConstantBuffers()) {
839 const auto index = buffers.first;
839 code.AddLine("layout (std140, binding = {}) uniform {} {{", binding++, 840 code.AddLine("layout (std140, binding = {}) uniform {} {{", binding++,
840 GetConstBufferBlock(index)); 841 GetConstBufferBlock(index));
841 code.AddLine(" uvec4 {}[{}];", GetConstBuffer(index), MAX_CONSTBUFFER_ELEMENTS); 842 code.AddLine(" uvec4 {}[{}];", GetConstBuffer(index), MAX_CONSTBUFFER_ELEMENTS);
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 }
diff --git a/src/video_core/texture_cache/surface_params.cpp b/src/video_core/texture_cache/surface_params.cpp
index 6f3ef45be..0de499946 100644
--- a/src/video_core/texture_cache/surface_params.cpp
+++ b/src/video_core/texture_cache/surface_params.cpp
@@ -167,7 +167,6 @@ SurfaceParams SurfaceParams::CreateForImage(const FormatLookupTable& lookup_tabl
167 167
168SurfaceParams SurfaceParams::CreateForDepthBuffer(Core::System& system) { 168SurfaceParams SurfaceParams::CreateForDepthBuffer(Core::System& system) {
169 const auto& regs = system.GPU().Maxwell3D().regs; 169 const auto& regs = system.GPU().Maxwell3D().regs;
170 regs.zeta_width, regs.zeta_height, regs.zeta.format, regs.zeta.memory_layout.type;
171 SurfaceParams params; 170 SurfaceParams params;
172 params.is_tiled = regs.zeta.memory_layout.type == 171 params.is_tiled = regs.zeta.memory_layout.type ==
173 Tegra::Engines::Maxwell3D::Regs::InvMemoryLayout::BlockLinear; 172 Tegra::Engines::Maxwell3D::Regs::InvMemoryLayout::BlockLinear;
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h
index 4edd4313b..47881d527 100644
--- a/src/video_core/texture_cache/texture_cache.h
+++ b/src/video_core/texture_cache/texture_cache.h
@@ -647,7 +647,8 @@ private:
647 break; 647 break;
648 } 648 }
649 const u32 offset = static_cast<u32>(surface->GetCpuAddr() - cpu_addr); 649 const u32 offset = static_cast<u32>(surface->GetCpuAddr() - cpu_addr);
650 const auto [x, y, z] = params.GetBlockOffsetXYZ(offset); 650 const auto offsets = params.GetBlockOffsetXYZ(offset);
651 const auto z = std::get<2>(offsets);
651 modified |= surface->IsModified(); 652 modified |= surface->IsModified();
652 const CopyParams copy_params(0, 0, 0, 0, 0, z, 0, 0, params.width, params.height, 653 const CopyParams copy_params(0, 0, 0, 0, 0, z, 0, 0, params.width, params.height,
653 1); 654 1);