diff options
author | bunnei <bunneidev@gmail.com> | 2018-06-26 16:25:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-26 16:25:56 +0200 |
commit | 36dedae842b3bc094f52e46f0e8edc028edeec25 (patch) | |
tree | 79886fcda14b4db11b65e2c2dff338c4e9c2689c /src/video_core/renderer_opengl/gl_shader_decompiler.cpp | |
parent | Merge pull request #589 from mailwl/fix-crash (diff) | |
parent | Rasterizer: Use UBOs instead of SSBOs for uploading const buffers. (diff) | |
download | yuzu-36dedae842b3bc094f52e46f0e8edc028edeec25.tar yuzu-36dedae842b3bc094f52e46f0e8edc028edeec25.tar.gz yuzu-36dedae842b3bc094f52e46f0e8edc028edeec25.tar.bz2 yuzu-36dedae842b3bc094f52e46f0e8edc028edeec25.tar.lz yuzu-36dedae842b3bc094f52e46f0e8edc028edeec25.tar.xz yuzu-36dedae842b3bc094f52e46f0e8edc028edeec25.tar.zst yuzu-36dedae842b3bc094f52e46f0e8edc028edeec25.zip |
Diffstat (limited to 'src/video_core/renderer_opengl/gl_shader_decompiler.cpp')
-rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index 65fed77ef..cd7569e2f 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp @@ -9,6 +9,7 @@ #include "common/assert.h" #include "common/common_types.h" #include "video_core/engines/shader_bytecode.h" +#include "video_core/renderer_opengl/gl_rasterizer.h" #include "video_core/renderer_opengl/gl_shader_decompiler.h" namespace GLShader { @@ -397,7 +398,8 @@ public: /// Generates code representing a uniform (C buffer) register, interpreted as the input type. std::string GetUniform(u64 index, u64 offset, GLSLRegister::Type type) { declr_const_buffers[index].MarkAsUsed(index, offset, stage); - std::string value = 'c' + std::to_string(index) + '[' + std::to_string(offset) + ']'; + std::string value = 'c' + std::to_string(index) + '[' + std::to_string(offset / 4) + "][" + + std::to_string(offset % 4) + ']'; if (type == GLSLRegister::Type::Float) { return value; @@ -411,8 +413,12 @@ public: std::string GetUniformIndirect(u64 index, s64 offset, const Register& index_reg, GLSLRegister::Type type) { declr_const_buffers[index].MarkAsUsedIndirect(index, stage); - std::string value = 'c' + std::to_string(index) + "[(floatBitsToInt(" + - GetRegister(index_reg, 0) + ") + " + std::to_string(offset) + ") / 4]"; + + std::string final_offset = "((floatBitsToInt(" + GetRegister(index_reg, 0) + ") + " + + std::to_string(offset) + ") / 4)"; + + std::string value = + 'c' + std::to_string(index) + '[' + final_offset + " / 4][" + final_offset + " % 4]"; if (type == GLSLRegister::Type::Float) { return value; @@ -454,9 +460,10 @@ public: unsigned const_buffer_layout = 0; for (const auto& entry : GetConstBuffersDeclarations()) { - declarations.AddLine("layout(std430) buffer " + entry.GetName()); + declarations.AddLine("layout(std140) uniform " + entry.GetName()); declarations.AddLine('{'); - declarations.AddLine(" float c" + std::to_string(entry.GetIndex()) + "[];"); + declarations.AddLine(" vec4 c" + std::to_string(entry.GetIndex()) + + "[MAX_CONSTBUFFER_ELEMENTS];"); declarations.AddLine("};"); declarations.AddNewLine(); ++const_buffer_layout; @@ -1713,7 +1720,10 @@ private: }; // namespace Decompiler std::string GetCommonDeclarations() { - return "bool exec_shader();"; + std::string declarations = "bool exec_shader();\n"; + declarations += "#define MAX_CONSTBUFFER_ELEMENTS " + + std::to_string(RasterizerOpenGL::MaxConstbufferSize / (sizeof(GLvec4))); + return declarations; } boost::optional<ProgramResult> DecompileProgram(const ProgramCode& program_code, u32 main_offset, |