summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2021-01-21 19:44:05 -0300
committerGravatar ReinUsesLisp2021-01-21 19:47:41 -0300
commit436457b6e780ee21fc4d69f1ffc652e39c320f2c (patch)
tree36c100001f9444b90f68292aaccdcb2a16e06b64 /src
parentMerge pull request #5755 from FearlessTobi/port-5344 (diff)
downloadyuzu-436457b6e780ee21fc4d69f1ffc652e39c320f2c.tar.gz
yuzu-436457b6e780ee21fc4d69f1ffc652e39c320f2c.tar.xz
yuzu-436457b6e780ee21fc4d69f1ffc652e39c320f2c.zip
gl_shader_decompiler: Fix constant buffer size calculation
The divide logic was wrong and can cause an uniform buffer size overflow.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
index 2e1fa252d..c35b71b6b 100644
--- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
@@ -14,6 +14,7 @@
14#include "common/alignment.h" 14#include "common/alignment.h"
15#include "common/assert.h" 15#include "common/assert.h"
16#include "common/common_types.h" 16#include "common/common_types.h"
17#include "common/div_ceil.h"
17#include "common/logging/log.h" 18#include "common/logging/log.h"
18#include "video_core/engines/maxwell_3d.h" 19#include "video_core/engines/maxwell_3d.h"
19#include "video_core/engines/shader_type.h" 20#include "video_core/engines/shader_type.h"
@@ -877,7 +878,7 @@ private:
877 878
878 u32 binding = device.GetBaseBindings(stage).uniform_buffer; 879 u32 binding = device.GetBaseBindings(stage).uniform_buffer;
879 for (const auto& [index, info] : ir.GetConstantBuffers()) { 880 for (const auto& [index, info] : ir.GetConstantBuffers()) {
880 const u32 num_elements = Common::AlignUp(info.GetSize(), 4) / 4; 881 const u32 num_elements = Common::DivCeil(info.GetSize(), 4 * sizeof(u32));
881 const u32 size = info.IsIndirect() ? MAX_CONSTBUFFER_ELEMENTS : num_elements; 882 const u32 size = info.IsIndirect() ? MAX_CONSTBUFFER_ELEMENTS : num_elements;
882 code.AddLine("layout (std140, binding = {}) uniform {} {{", binding++, 883 code.AddLine("layout (std140, binding = {}) uniform {} {{", binding++,
883 GetConstBufferBlock(index)); 884 GetConstBufferBlock(index));