summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2018-08-08 02:07:44 -0400
committerGravatar bunnei2018-08-08 02:10:25 -0400
commit57982df105a6d149cc82292541184e6ceabc288c (patch)
treecafcaec08c7f7f7308f0856a03f1c8310a0a6740 /src
parentMerge pull request #964 from Hexagon12/lower-logs (diff)
downloadyuzu-57982df105a6d149cc82292541184e6ceabc288c.tar.gz
yuzu-57982df105a6d149cc82292541184e6ceabc288c.tar.xz
yuzu-57982df105a6d149cc82292541184e6ceabc288c.zip
maxwell_3d: Use correct const buffer size and check bounds.
- Fixes mem corruption with Super Mario Odyssey and Pokkén Tournament DX.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/engines/maxwell_3d.cpp2
-rw-r--r--src/video_core/engines/maxwell_3d.h2
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp5
-rw-r--r--src/video_core/renderer_opengl/gl_state.h6
4 files changed, 12 insertions, 3 deletions
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp
index 5c0ae8009..ed22a2090 100644
--- a/src/video_core/engines/maxwell_3d.cpp
+++ b/src/video_core/engines/maxwell_3d.cpp
@@ -238,6 +238,8 @@ void Maxwell3D::ProcessCBBind(Regs::ShaderStage stage) {
238 238
239 auto& buffer = shader.const_buffers[bind_data.index]; 239 auto& buffer = shader.const_buffers[bind_data.index];
240 240
241 ASSERT(bind_data.index < Regs::MaxConstBuffers);
242
241 buffer.enabled = bind_data.valid.Value() != 0; 243 buffer.enabled = bind_data.valid.Value() != 0;
242 buffer.index = bind_data.index; 244 buffer.index = bind_data.index;
243 buffer.address = regs.const_buffer.BufferAddress(); 245 buffer.address = regs.const_buffer.BufferAddress();
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h
index 4d0ff96a5..0506ac8fe 100644
--- a/src/video_core/engines/maxwell_3d.h
+++ b/src/video_core/engines/maxwell_3d.h
@@ -44,7 +44,7 @@ public:
44 static constexpr size_t MaxShaderProgram = 6; 44 static constexpr size_t MaxShaderProgram = 6;
45 static constexpr size_t MaxShaderStage = 5; 45 static constexpr size_t MaxShaderStage = 5;
46 // Maximum number of const buffers per shader stage. 46 // Maximum number of const buffers per shader stage.
47 static constexpr size_t MaxConstBuffers = 16; 47 static constexpr size_t MaxConstBuffers = 18;
48 48
49 enum class QueryMode : u32 { 49 enum class QueryMode : u32 {
50 Write = 0, 50 Write = 0,
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index c2a931469..601a1084b 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -659,7 +659,10 @@ u32 RasterizerOpenGL::SetupConstBuffers(Maxwell::ShaderStage stage, GLuint progr
659 auto& buffer_draw_state = 659 auto& buffer_draw_state =
660 state.draw.const_buffers[static_cast<size_t>(stage)][used_buffer.GetIndex()]; 660 state.draw.const_buffers[static_cast<size_t>(stage)][used_buffer.GetIndex()];
661 661
662 ASSERT_MSG(buffer.enabled, "Attempted to upload disabled constbuffer"); 662 if (!buffer.enabled) {
663 continue;
664 }
665
663 buffer_draw_state.enabled = true; 666 buffer_draw_state.enabled = true;
664 buffer_draw_state.bindpoint = current_bindpoint + bindpoint; 667 buffer_draw_state.bindpoint = current_bindpoint + bindpoint;
665 668
diff --git a/src/video_core/renderer_opengl/gl_state.h b/src/video_core/renderer_opengl/gl_state.h
index 24b1d956b..5c7b636e4 100644
--- a/src/video_core/renderer_opengl/gl_state.h
+++ b/src/video_core/renderer_opengl/gl_state.h
@@ -7,6 +7,10 @@
7#include <array> 7#include <array>
8#include <glad/glad.h> 8#include <glad/glad.h>
9 9
10#include "video_core/engines/maxwell_3d.h"
11
12using Regs = Tegra::Engines::Maxwell3D::Regs;
13
10namespace TextureUnits { 14namespace TextureUnits {
11 15
12struct TextureUnit { 16struct TextureUnit {
@@ -120,7 +124,7 @@ public:
120 GLuint bindpoint; 124 GLuint bindpoint;
121 GLuint ssbo; 125 GLuint ssbo;
122 }; 126 };
123 std::array<std::array<ConstBufferConfig, 16>, 5> const_buffers{}; 127 std::array<std::array<ConstBufferConfig, Regs::MaxConstBuffers>, 5> const_buffers;
124 } draw; 128 } draw;
125 129
126 struct { 130 struct {