mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-30 20:24:24 +01:00
gl_shader_decompiler: Add identifier to decompiled code
This commit is contained in:
parent
e612242977
commit
b1061afed9
@ -186,8 +186,10 @@ std::shared_ptr<Registry> MakeRegistry(const ShaderDiskCacheEntry& entry) {
|
|||||||
std::shared_ptr<OGLProgram> BuildShader(const Device& device, ShaderType shader_type,
|
std::shared_ptr<OGLProgram> BuildShader(const Device& device, ShaderType shader_type,
|
||||||
u64 unique_identifier, const ShaderIR& ir,
|
u64 unique_identifier, const ShaderIR& ir,
|
||||||
const Registry& registry, bool hint_retrievable = false) {
|
const Registry& registry, bool hint_retrievable = false) {
|
||||||
LOG_INFO(Render_OpenGL, "{}", MakeShaderID(unique_identifier, shader_type));
|
const std::string shader_id = MakeShaderID(unique_identifier, shader_type);
|
||||||
const std::string glsl = DecompileShader(device, ir, registry, shader_type);
|
LOG_INFO(Render_OpenGL, "{}", shader_id);
|
||||||
|
|
||||||
|
const std::string glsl = DecompileShader(device, ir, registry, shader_type, shader_id);
|
||||||
OGLShader shader;
|
OGLShader shader;
|
||||||
shader.Create(glsl.c_str(), GetGLShaderType(shader_type));
|
shader.Create(glsl.c_str(), GetGLShaderType(shader_type));
|
||||||
|
|
||||||
|
@ -393,9 +393,9 @@ std::string FlowStackTopName(MetaStackClass stack) {
|
|||||||
class GLSLDecompiler final {
|
class GLSLDecompiler final {
|
||||||
public:
|
public:
|
||||||
explicit GLSLDecompiler(const Device& device, const ShaderIR& ir, const Registry& registry,
|
explicit GLSLDecompiler(const Device& device, const ShaderIR& ir, const Registry& registry,
|
||||||
ShaderType stage, std::string_view suffix)
|
ShaderType stage, std::string_view identifier, std::string_view suffix)
|
||||||
: device{device}, ir{ir}, registry{registry}, stage{stage}, suffix{suffix},
|
: device{device}, ir{ir}, registry{registry}, stage{stage},
|
||||||
header{ir.GetHeader()} {}
|
identifier{identifier}, suffix{suffix}, header{ir.GetHeader()} {}
|
||||||
|
|
||||||
void Decompile() {
|
void Decompile() {
|
||||||
DeclareHeader();
|
DeclareHeader();
|
||||||
@ -478,6 +478,9 @@ private:
|
|||||||
void DecompileAST();
|
void DecompileAST();
|
||||||
|
|
||||||
void DeclareHeader() {
|
void DeclareHeader() {
|
||||||
|
if (!identifier.empty()) {
|
||||||
|
code.AddLine("// {}", identifier);
|
||||||
|
}
|
||||||
code.AddLine("#version 430 core");
|
code.AddLine("#version 430 core");
|
||||||
code.AddLine("#extension GL_ARB_separate_shader_objects : enable");
|
code.AddLine("#extension GL_ARB_separate_shader_objects : enable");
|
||||||
if (device.HasShaderBallot()) {
|
if (device.HasShaderBallot()) {
|
||||||
@ -2477,6 +2480,7 @@ private:
|
|||||||
const ShaderIR& ir;
|
const ShaderIR& ir;
|
||||||
const Registry& registry;
|
const Registry& registry;
|
||||||
const ShaderType stage;
|
const ShaderType stage;
|
||||||
|
const std::string_view identifier;
|
||||||
const std::string_view suffix;
|
const std::string_view suffix;
|
||||||
const Header header;
|
const Header header;
|
||||||
|
|
||||||
@ -2698,8 +2702,9 @@ ShaderEntries MakeEntries(const VideoCommon::Shader::ShaderIR& ir) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string DecompileShader(const Device& device, const ShaderIR& ir, const Registry& registry,
|
std::string DecompileShader(const Device& device, const ShaderIR& ir, const Registry& registry,
|
||||||
ShaderType stage, std::string_view suffix) {
|
ShaderType stage, std::string_view identifier,
|
||||||
GLSLDecompiler decompiler(device, ir, registry, stage, suffix);
|
std::string_view suffix) {
|
||||||
|
GLSLDecompiler decompiler(device, ir, registry, stage, identifier, suffix);
|
||||||
decompiler.Decompile();
|
decompiler.Decompile();
|
||||||
return decompiler.GetResult();
|
return decompiler.GetResult();
|
||||||
}
|
}
|
||||||
|
@ -78,6 +78,7 @@ ShaderEntries MakeEntries(const VideoCommon::Shader::ShaderIR& ir);
|
|||||||
|
|
||||||
std::string DecompileShader(const Device& device, const VideoCommon::Shader::ShaderIR& ir,
|
std::string DecompileShader(const Device& device, const VideoCommon::Shader::ShaderIR& ir,
|
||||||
const VideoCommon::Shader::Registry& registry,
|
const VideoCommon::Shader::Registry& registry,
|
||||||
Tegra::Engines::ShaderType stage, std::string_view suffix = {});
|
Tegra::Engines::ShaderType stage, std::string_view identifier,
|
||||||
|
std::string_view suffix = {});
|
||||||
|
|
||||||
} // namespace OpenGL
|
} // namespace OpenGL
|
||||||
|
Loading…
Reference in New Issue
Block a user