summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2020-02-29 16:30:20 -0300
committerGravatar ReinUsesLisp2020-03-09 18:40:53 -0300
commitb1061afed90db36c6b6d6cc19c6a4495bcef4fec (patch)
tree089d9cbd623f57b8708db56b233d7c74f7ea4aec /src
parentgl_shader_decompiler: Roll back to GLSL core 430 (diff)
downloadyuzu-b1061afed90db36c6b6d6cc19c6a4495bcef4fec.tar.gz
yuzu-b1061afed90db36c6b6d6cc19c6a4495bcef4fec.tar.xz
yuzu-b1061afed90db36c6b6d6cc19c6a4495bcef4fec.zip
gl_shader_decompiler: Add identifier to decompiled code
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_shader_cache.cpp6
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.cpp15
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.h3
3 files changed, 16 insertions, 8 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp
index 593897787..e3d31c3eb 100644
--- a/src/video_core/renderer_opengl/gl_shader_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp
@@ -186,8 +186,10 @@ std::shared_ptr<Registry> MakeRegistry(const ShaderDiskCacheEntry& entry) {
186std::shared_ptr<OGLProgram> BuildShader(const Device& device, ShaderType shader_type, 186std::shared_ptr<OGLProgram> BuildShader(const Device& device, ShaderType shader_type,
187 u64 unique_identifier, const ShaderIR& ir, 187 u64 unique_identifier, const ShaderIR& ir,
188 const Registry& registry, bool hint_retrievable = false) { 188 const Registry& registry, bool hint_retrievable = false) {
189 LOG_INFO(Render_OpenGL, "{}", MakeShaderID(unique_identifier, shader_type)); 189 const std::string shader_id = MakeShaderID(unique_identifier, shader_type);
190 const std::string glsl = DecompileShader(device, ir, registry, shader_type); 190 LOG_INFO(Render_OpenGL, "{}", shader_id);
191
192 const std::string glsl = DecompileShader(device, ir, registry, shader_type, shader_id);
191 OGLShader shader; 193 OGLShader shader;
192 shader.Create(glsl.c_str(), GetGLShaderType(shader_type)); 194 shader.Create(glsl.c_str(), GetGLShaderType(shader_type));
193 195
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
index 0adb51629..cb89daba1 100644
--- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
@@ -393,9 +393,9 @@ std::string FlowStackTopName(MetaStackClass stack) {
393class GLSLDecompiler final { 393class GLSLDecompiler final {
394public: 394public:
395 explicit GLSLDecompiler(const Device& device, const ShaderIR& ir, const Registry& registry, 395 explicit GLSLDecompiler(const Device& device, const ShaderIR& ir, const Registry& registry,
396 ShaderType stage, std::string_view suffix) 396 ShaderType stage, std::string_view identifier, std::string_view suffix)
397 : device{device}, ir{ir}, registry{registry}, stage{stage}, suffix{suffix}, 397 : device{device}, ir{ir}, registry{registry}, stage{stage},
398 header{ir.GetHeader()} {} 398 identifier{identifier}, suffix{suffix}, header{ir.GetHeader()} {}
399 399
400 void Decompile() { 400 void Decompile() {
401 DeclareHeader(); 401 DeclareHeader();
@@ -478,6 +478,9 @@ private:
478 void DecompileAST(); 478 void DecompileAST();
479 479
480 void DeclareHeader() { 480 void DeclareHeader() {
481 if (!identifier.empty()) {
482 code.AddLine("// {}", identifier);
483 }
481 code.AddLine("#version 430 core"); 484 code.AddLine("#version 430 core");
482 code.AddLine("#extension GL_ARB_separate_shader_objects : enable"); 485 code.AddLine("#extension GL_ARB_separate_shader_objects : enable");
483 if (device.HasShaderBallot()) { 486 if (device.HasShaderBallot()) {
@@ -2477,6 +2480,7 @@ private:
2477 const ShaderIR& ir; 2480 const ShaderIR& ir;
2478 const Registry& registry; 2481 const Registry& registry;
2479 const ShaderType stage; 2482 const ShaderType stage;
2483 const std::string_view identifier;
2480 const std::string_view suffix; 2484 const std::string_view suffix;
2481 const Header header; 2485 const Header header;
2482 2486
@@ -2698,8 +2702,9 @@ ShaderEntries MakeEntries(const VideoCommon::Shader::ShaderIR& ir) {
2698} 2702}
2699 2703
2700std::string DecompileShader(const Device& device, const ShaderIR& ir, const Registry& registry, 2704std::string DecompileShader(const Device& device, const ShaderIR& ir, const Registry& registry,
2701 ShaderType stage, std::string_view suffix) { 2705 ShaderType stage, std::string_view identifier,
2702 GLSLDecompiler decompiler(device, ir, registry, stage, suffix); 2706 std::string_view suffix) {
2707 GLSLDecompiler decompiler(device, ir, registry, stage, identifier, suffix);
2703 decompiler.Decompile(); 2708 decompiler.Decompile();
2704 return decompiler.GetResult(); 2709 return decompiler.GetResult();
2705} 2710}
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.h b/src/video_core/renderer_opengl/gl_shader_decompiler.h
index 68b68ee77..e7dbd810c 100644
--- a/src/video_core/renderer_opengl/gl_shader_decompiler.h
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.h
@@ -78,6 +78,7 @@ ShaderEntries MakeEntries(const VideoCommon::Shader::ShaderIR& ir);
78 78
79std::string DecompileShader(const Device& device, const VideoCommon::Shader::ShaderIR& ir, 79std::string DecompileShader(const Device& device, const VideoCommon::Shader::ShaderIR& ir,
80 const VideoCommon::Shader::Registry& registry, 80 const VideoCommon::Shader::Registry& registry,
81 Tegra::Engines::ShaderType stage, std::string_view suffix = {}); 81 Tegra::Engines::ShaderType stage, std::string_view identifier,
82 std::string_view suffix = {});
82 83
83} // namespace OpenGL 84} // namespace OpenGL