Shader_ir: Address feedback
This commit is contained in:
parent
3c09d9abe6
commit
e6eae4b815
6 changed files with 24 additions and 65 deletions
|
@ -2271,7 +2271,11 @@ private:
|
|||
ShaderWriter code;
|
||||
};
|
||||
|
||||
const std::string flow_var = "flow_var_";
|
||||
static constexpr std::string_view flow_var = "flow_var_";
|
||||
|
||||
std::string GetFlowVariable(u32 i) {
|
||||
return fmt::format("{}{}", flow_var, i);
|
||||
}
|
||||
|
||||
class ExprDecompiler {
|
||||
public:
|
||||
|
@ -2326,7 +2330,7 @@ public:
|
|||
}
|
||||
|
||||
void operator()(VideoCommon::Shader::ExprVar& expr) {
|
||||
inner += flow_var + std::to_string(expr.var_index);
|
||||
inner += GetFlowVariable(expr.var_index);
|
||||
}
|
||||
|
||||
void operator()(VideoCommon::Shader::ExprBoolean& expr) {
|
||||
|
@ -2391,7 +2395,7 @@ public:
|
|||
void operator()(VideoCommon::Shader::ASTVarSet& ast) {
|
||||
ExprDecompiler expr_parser{decomp};
|
||||
std::visit(expr_parser, *ast.condition);
|
||||
decomp.code.AddLine("{}{} = {};", flow_var, ast.index, expr_parser.GetResult());
|
||||
decomp.code.AddLine("{} = {};", GetFlowVariable(ast.index), expr_parser.GetResult());
|
||||
}
|
||||
|
||||
void operator()(VideoCommon::Shader::ASTLabel& ast) {
|
||||
|
@ -2462,7 +2466,7 @@ private:
|
|||
void GLSLDecompiler::DecompileAST() {
|
||||
const u32 num_flow_variables = ir.GetASTNumVariables();
|
||||
for (u32 i = 0; i < num_flow_variables; i++) {
|
||||
code.AddLine("bool {}{} = false;", flow_var, i);
|
||||
code.AddLine("bool {} = false;", GetFlowVariable(i));
|
||||
}
|
||||
ASTDecompiler decompiler{*this};
|
||||
VideoCommon::Shader::ASTNode program = ir.GetASTProgram();
|
||||
|
|
|
@ -19,6 +19,8 @@ using VideoCommon::Shader::ShaderIR;
|
|||
static constexpr u32 PROGRAM_OFFSET = 10;
|
||||
static constexpr u32 COMPUTE_OFFSET = 0;
|
||||
|
||||
static constexpr CompilerSettings settings{CompileDepth::NoFlowStack, true};
|
||||
|
||||
ProgramResult GenerateVertexShader(const Device& device, const ShaderSetup& setup) {
|
||||
const std::string id = fmt::format("{:016x}", setup.program.unique_identifier);
|
||||
|
||||
|
@ -33,9 +35,6 @@ layout (std140, binding = EMULATION_UBO_BINDING) uniform vs_config {
|
|||
|
||||
)";
|
||||
|
||||
CompilerSettings settings;
|
||||
settings.depth = CompileDepth::NoFlowStack;
|
||||
|
||||
const ShaderIR program_ir(setup.program.code, PROGRAM_OFFSET, setup.program.size_a, settings);
|
||||
const auto stage = setup.IsDualProgram() ? ProgramType::VertexA : ProgramType::VertexB;
|
||||
ProgramResult program = Decompile(device, program_ir, stage, "vertex");
|
||||
|
@ -86,9 +85,6 @@ layout (std140, binding = EMULATION_UBO_BINDING) uniform gs_config {
|
|||
|
||||
)";
|
||||
|
||||
CompilerSettings settings;
|
||||
settings.depth = CompileDepth::NoFlowStack;
|
||||
|
||||
const ShaderIR program_ir(setup.program.code, PROGRAM_OFFSET, setup.program.size_a, settings);
|
||||
ProgramResult program = Decompile(device, program_ir, ProgramType::Geometry, "geometry");
|
||||
out += program.first;
|
||||
|
@ -123,8 +119,6 @@ layout (std140, binding = EMULATION_UBO_BINDING) uniform fs_config {
|
|||
};
|
||||
|
||||
)";
|
||||
CompilerSettings settings;
|
||||
settings.depth = CompileDepth::NoFlowStack;
|
||||
|
||||
const ShaderIR program_ir(setup.program.code, PROGRAM_OFFSET, setup.program.size_a, settings);
|
||||
ProgramResult program = Decompile(device, program_ir, ProgramType::Fragment, "fragment");
|
||||
|
@ -145,9 +139,6 @@ ProgramResult GenerateComputeShader(const Device& device, const ShaderSetup& set
|
|||
std::string out = "// Shader Unique Id: CS" + id + "\n\n";
|
||||
out += GetCommonDeclarations();
|
||||
|
||||
CompilerSettings settings;
|
||||
settings.depth = CompileDepth::NoFlowStack;
|
||||
|
||||
const ShaderIR program_ir(setup.program.code, COMPUTE_OFFSET, setup.program.size_a, settings);
|
||||
ProgramResult program = Decompile(device, program_ir, ProgramType::Compute, "compute");
|
||||
out += program.first;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue