diff options
author | bunnei <bunneidev@gmail.com> | 2018-04-15 09:32:12 +0200 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2018-04-15 17:50:10 +0200 |
commit | 73d9c494ea6ae0a8076f679506ff07e2fe014826 (patch) | |
tree | f283b7d9b9014488dabd45e97f5687c2d67e842d /src/video_core/renderer_opengl/gl_shader_gen.cpp | |
parent | Merge pull request #328 from Subv/constbuffers (diff) | |
download | yuzu-73d9c494ea6ae0a8076f679506ff07e2fe014826.tar yuzu-73d9c494ea6ae0a8076f679506ff07e2fe014826.tar.gz yuzu-73d9c494ea6ae0a8076f679506ff07e2fe014826.tar.bz2 yuzu-73d9c494ea6ae0a8076f679506ff07e2fe014826.tar.lz yuzu-73d9c494ea6ae0a8076f679506ff07e2fe014826.tar.xz yuzu-73d9c494ea6ae0a8076f679506ff07e2fe014826.tar.zst yuzu-73d9c494ea6ae0a8076f679506ff07e2fe014826.zip |
Diffstat (limited to 'src/video_core/renderer_opengl/gl_shader_gen.cpp')
-rw-r--r-- | src/video_core/renderer_opengl/gl_shader_gen.cpp | 54 |
1 files changed, 48 insertions, 6 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_gen.cpp b/src/video_core/renderer_opengl/gl_shader_gen.cpp index 524c2cfb5..aeea1c805 100644 --- a/src/video_core/renderer_opengl/gl_shader_gen.cpp +++ b/src/video_core/renderer_opengl/gl_shader_gen.cpp @@ -3,18 +3,60 @@ // Refer to the license.txt file included. #include "common/assert.h" +#include "video_core/engines/maxwell_3d.h" +#include "video_core/renderer_opengl/gl_shader_decompiler.h" #include "video_core/renderer_opengl/gl_shader_gen.h" namespace GLShader { -std::string GenerateVertexShader(const ShaderSetup& setup, const MaxwellVSConfig& config) { - UNREACHABLE(); - return {}; +using Tegra::Engines::Maxwell3D; + +static constexpr u32 PROGRAM_OFFSET{10}; + +ProgramResult GenerateVertexShader(const ShaderSetup& setup, const MaxwellVSConfig& config) { + std::string out = "#version 430 core\n"; + out += "#extension GL_ARB_separate_shader_objects : enable\n\n"; + out += Decompiler::GetCommonDeclarations(); + + ProgramResult program = Decompiler::DecompileProgram(setup.program_code, PROGRAM_OFFSET, + Maxwell3D::Regs::ShaderStage::Vertex) + .get_value_or({}); + out += R"( + +out gl_PerVertex { + vec4 gl_Position; +}; + +void main() { + exec_shader(); +} + +)"; + out += program.first; + return {out, program.second}; +} + +ProgramResult GenerateFragmentShader(const ShaderSetup& setup, const MaxwellFSConfig& config) { + std::string out = "#version 430 core\n"; + out += "#extension GL_ARB_separate_shader_objects : enable\n\n"; + out += Decompiler::GetCommonDeclarations(); + + ProgramResult program = Decompiler::DecompileProgram(setup.program_code, PROGRAM_OFFSET, + Maxwell3D::Regs::ShaderStage::Fragment) + .get_value_or({}); + out += R"( + +out vec4 color; + +uniform sampler2D tex[32]; + +void main() { + exec_shader(); } -std::string GenerateFragmentShader(const ShaderSetup& setup, const MaxwellFSConfig& config) { - UNREACHABLE(); - return {}; +)"; + out += program.first; + return {out, program.second}; } } // namespace GLShader |