gl_shader_gen: Fixup code formatting
This commit is contained in:
parent
af5d7e2c49
commit
df74ff3c8b
|
@ -1531,7 +1531,7 @@ std::string GetCommonDeclarations() {
|
||||||
"}\n\n"
|
"}\n\n"
|
||||||
"vec2 toHalf2(float value) {\n"
|
"vec2 toHalf2(float value) {\n"
|
||||||
" return unpackHalf2x16(ftou(value));\n"
|
" return unpackHalf2x16(ftou(value));\n"
|
||||||
"}\n\n";
|
"}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
ProgramResult Decompile(const ShaderIR& ir, Maxwell::ShaderStage stage, const std::string& suffix) {
|
ProgramResult Decompile(const ShaderIR& ir, Maxwell::ShaderStage stage, const std::string& suffix) {
|
||||||
|
|
|
@ -21,8 +21,8 @@ ProgramResult GenerateVertexShader(const ShaderSetup& setup) {
|
||||||
const std::string id = fmt::format("{:016x}", setup.program.unique_identifier);
|
const std::string id = fmt::format("{:016x}", setup.program.unique_identifier);
|
||||||
|
|
||||||
std::string out = "#version 430 core\n";
|
std::string out = "#version 430 core\n";
|
||||||
out += "// Shader Unique Id: VS" + id + '\n';
|
out += "#extension GL_ARB_separate_shader_objects : enable\n\n";
|
||||||
out += "#extension GL_ARB_separate_shader_objects : enable\n";
|
out += "// Shader Unique Id: VS" + id + "\n\n";
|
||||||
out += GetCommonDeclarations();
|
out += GetCommonDeclarations();
|
||||||
|
|
||||||
out += R"(
|
out += R"(
|
||||||
|
@ -33,6 +33,7 @@ layout(std140) uniform vs_config {
|
||||||
uvec4 config_pack; // instance_id, flip_stage, y_direction, padding
|
uvec4 config_pack; // instance_id, flip_stage, y_direction, padding
|
||||||
uvec4 alpha_test;
|
uvec4 alpha_test;
|
||||||
};
|
};
|
||||||
|
|
||||||
)";
|
)";
|
||||||
ShaderIR program_ir(setup.program.code, PROGRAM_OFFSET);
|
ShaderIR program_ir(setup.program.code, PROGRAM_OFFSET);
|
||||||
ProgramResult program = Decompile(program_ir, Maxwell3D::Regs::ShaderStage::Vertex, "vertex");
|
ProgramResult program = Decompile(program_ir, Maxwell3D::Regs::ShaderStage::Vertex, "vertex");
|
||||||
|
@ -80,11 +81,12 @@ ProgramResult GenerateGeometryShader(const ShaderSetup& setup) {
|
||||||
// Version is intentionally skipped in shader generation, it's added by the lazy compilation.
|
// Version is intentionally skipped in shader generation, it's added by the lazy compilation.
|
||||||
const std::string id = fmt::format("{:016x}", setup.program.unique_identifier);
|
const std::string id = fmt::format("{:016x}", setup.program.unique_identifier);
|
||||||
|
|
||||||
std::string out = "// Shader Unique Id: GS" + id + '\n';
|
std::string out = "#extension GL_ARB_separate_shader_objects : enable\n\n";
|
||||||
out += "#extension GL_ARB_separate_shader_objects : enable\n";
|
out += "// Shader Unique Id: GS" + id + "\n\n";
|
||||||
out += GetCommonDeclarations();
|
out += GetCommonDeclarations();
|
||||||
|
|
||||||
out += R"(layout (location = 0) in vec4 gs_position[];
|
out += R"(
|
||||||
|
layout (location = 0) in vec4 gs_position[];
|
||||||
layout (location = 0) out vec4 position;
|
layout (location = 0) out vec4 position;
|
||||||
|
|
||||||
layout (std140) uniform gs_config {
|
layout (std140) uniform gs_config {
|
||||||
|
@ -92,8 +94,8 @@ layout (std140) uniform gs_config {
|
||||||
uvec4 config_pack; // instance_id, flip_stage, y_direction, padding
|
uvec4 config_pack; // instance_id, flip_stage, y_direction, padding
|
||||||
uvec4 alpha_test;
|
uvec4 alpha_test;
|
||||||
};
|
};
|
||||||
)";
|
|
||||||
|
|
||||||
|
)";
|
||||||
ShaderIR program_ir(setup.program.code, PROGRAM_OFFSET);
|
ShaderIR program_ir(setup.program.code, PROGRAM_OFFSET);
|
||||||
ProgramResult program =
|
ProgramResult program =
|
||||||
Decompile(program_ir, Maxwell3D::Regs::ShaderStage::Geometry, "geometry");
|
Decompile(program_ir, Maxwell3D::Regs::ShaderStage::Geometry, "geometry");
|
||||||
|
@ -111,8 +113,8 @@ ProgramResult GenerateFragmentShader(const ShaderSetup& setup) {
|
||||||
const std::string id = fmt::format("{:016x}", setup.program.unique_identifier);
|
const std::string id = fmt::format("{:016x}", setup.program.unique_identifier);
|
||||||
|
|
||||||
std::string out = "#version 430 core\n";
|
std::string out = "#version 430 core\n";
|
||||||
out += "// Shader Unique Id: FS" + id + '\n';
|
out += "#extension GL_ARB_separate_shader_objects : enable\n\n";
|
||||||
out += "#extension GL_ARB_separate_shader_objects : enable\n";
|
out += "// Shader Unique Id: FS" + id + "\n\n";
|
||||||
out += GetCommonDeclarations();
|
out += GetCommonDeclarations();
|
||||||
|
|
||||||
out += R"(
|
out += R"(
|
||||||
|
@ -155,8 +157,9 @@ bool AlphaFunc(in float value) {
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
})";
|
}
|
||||||
|
|
||||||
|
)";
|
||||||
ShaderIR program_ir(setup.program.code, PROGRAM_OFFSET);
|
ShaderIR program_ir(setup.program.code, PROGRAM_OFFSET);
|
||||||
ProgramResult program =
|
ProgramResult program =
|
||||||
Decompile(program_ir, Maxwell3D::Regs::ShaderStage::Fragment, "fragment");
|
Decompile(program_ir, Maxwell3D::Regs::ShaderStage::Fragment, "fragment");
|
||||||
|
@ -171,4 +174,5 @@ void main() {
|
||||||
)";
|
)";
|
||||||
return {out, program.second};
|
return {out, program.second};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace OpenGL::GLShader
|
} // namespace OpenGL::GLShader
|
Reference in New Issue