summaryrefslogtreecommitdiff
path: root/src/video_core
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2019-05-27 00:51:35 -0300
committerGravatar ReinUsesLisp2019-05-27 00:51:35 -0300
commit84928e6d67a9dd2bf611f12a3f9fe8aa62af397e (patch)
tree80318dad630538345dbd7d1d11a8372b2283fd28 /src/video_core
parentMerge pull request #2516 from lioncash/label (diff)
downloadyuzu-84928e6d67a9dd2bf611f12a3f9fe8aa62af397e.tar.gz
yuzu-84928e6d67a9dd2bf611f12a3f9fe8aa62af397e.tar.xz
yuzu-84928e6d67a9dd2bf611f12a3f9fe8aa62af397e.zip
gl_shader_gen: Always declare extensions after the version declaration
This addresses a bug on geometry shaders where code was being written before all #extension declarations were done. Ref to #2523
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/renderer_opengl/gl_shader_cache.cpp3
-rw-r--r--src/video_core/renderer_opengl/gl_shader_gen.cpp9
2 files changed, 5 insertions, 7 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp
index 7ee1c99c0..d66252224 100644
--- a/src/video_core/renderer_opengl/gl_shader_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp
@@ -170,7 +170,8 @@ GLShader::ProgramResult CreateProgram(const Device& device, Maxwell::ShaderProgr
170CachedProgram SpecializeShader(const std::string& code, const GLShader::ShaderEntries& entries, 170CachedProgram SpecializeShader(const std::string& code, const GLShader::ShaderEntries& entries,
171 Maxwell::ShaderProgram program_type, BaseBindings base_bindings, 171 Maxwell::ShaderProgram program_type, BaseBindings base_bindings,
172 GLenum primitive_mode, bool hint_retrievable = false) { 172 GLenum primitive_mode, bool hint_retrievable = false) {
173 std::string source = "#version 430 core\n"; 173 std::string source = "#version 430 core\n"
174 "#extension GL_ARB_separate_shader_objects : enable\n\n";
174 source += fmt::format("#define EMULATION_UBO_BINDING {}\n", base_bindings.cbuf++); 175 source += fmt::format("#define EMULATION_UBO_BINDING {}\n", base_bindings.cbuf++);
175 176
176 for (const auto& cbuf : entries.const_buffers) { 177 for (const auto& cbuf : entries.const_buffers) {
diff --git a/src/video_core/renderer_opengl/gl_shader_gen.cpp b/src/video_core/renderer_opengl/gl_shader_gen.cpp
index 7ab0b4553..d2bb705a9 100644
--- a/src/video_core/renderer_opengl/gl_shader_gen.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_gen.cpp
@@ -19,8 +19,7 @@ static constexpr u32 PROGRAM_OFFSET{10};
19ProgramResult GenerateVertexShader(const Device& device, const ShaderSetup& setup) { 19ProgramResult GenerateVertexShader(const Device& device, const ShaderSetup& setup) {
20 const std::string id = fmt::format("{:016x}", setup.program.unique_identifier); 20 const std::string id = fmt::format("{:016x}", setup.program.unique_identifier);
21 21
22 std::string out = "#extension GL_ARB_separate_shader_objects : enable\n\n"; 22 std::string out = "// Shader Unique Id: VS" + id + "\n\n";
23 out += "// Shader Unique Id: VS" + id + "\n\n";
24 out += GetCommonDeclarations(); 23 out += GetCommonDeclarations();
25 24
26 out += R"( 25 out += R"(
@@ -82,8 +81,7 @@ void main() {
82ProgramResult GenerateGeometryShader(const Device& device, const ShaderSetup& setup) { 81ProgramResult GenerateGeometryShader(const Device& device, const ShaderSetup& setup) {
83 const std::string id = fmt::format("{:016x}", setup.program.unique_identifier); 82 const std::string id = fmt::format("{:016x}", setup.program.unique_identifier);
84 83
85 std::string out = "#extension GL_ARB_separate_shader_objects : enable\n\n"; 84 std::string out = "// Shader Unique Id: GS" + id + "\n\n";
86 out += "// Shader Unique Id: GS" + id + "\n\n";
87 out += GetCommonDeclarations(); 85 out += GetCommonDeclarations();
88 86
89 out += R"( 87 out += R"(
@@ -113,8 +111,7 @@ void main() {
113ProgramResult GenerateFragmentShader(const Device& device, const ShaderSetup& setup) { 111ProgramResult GenerateFragmentShader(const Device& device, const ShaderSetup& setup) {
114 const std::string id = fmt::format("{:016x}", setup.program.unique_identifier); 112 const std::string id = fmt::format("{:016x}", setup.program.unique_identifier);
115 113
116 std::string out = "#extension GL_ARB_separate_shader_objects : enable\n\n"; 114 std::string out = "// Shader Unique Id: FS" + id + "\n\n";
117 out += "// Shader Unique Id: FS" + id + "\n\n";
118 out += GetCommonDeclarations(); 115 out += GetCommonDeclarations();
119 116
120 out += R"( 117 out += R"(