ShaderIR: interpret kill as a return abort in non fragment shaders.
This commit is contained in:
@@ -1193,7 +1193,11 @@ void ARBDecompiler::VisitAST(const ASTNode& node) {
|
||||
ResetTemporaries();
|
||||
}
|
||||
if (ast_return->kills) {
|
||||
AddLine("KIL TR;");
|
||||
if (stage == ShaderType::Fragment) {
|
||||
AddLine("KIL TR;");
|
||||
} else {
|
||||
AddLine("RET;");
|
||||
}
|
||||
} else {
|
||||
Exit();
|
||||
}
|
||||
@@ -2082,6 +2086,10 @@ std::string ARBDecompiler::Exit(Operation) {
|
||||
}
|
||||
|
||||
std::string ARBDecompiler::Discard(Operation) {
|
||||
if (stage != ShaderType::Fragment) {
|
||||
AddLine("RET;");
|
||||
return {};
|
||||
}
|
||||
AddLine("KIL TR;");
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -2305,7 +2305,11 @@ private:
|
||||
// about unexecuted instructions that may follow this.
|
||||
code.AddLine("if (true) {{");
|
||||
++code.scope;
|
||||
code.AddLine("discard;");
|
||||
if (stage != ShaderType::Fragment) {
|
||||
code.AddLine("return;");
|
||||
} else {
|
||||
code.AddLine("discard;");
|
||||
}
|
||||
--code.scope;
|
||||
code.AddLine("}}");
|
||||
return {};
|
||||
@@ -2932,7 +2936,11 @@ public:
|
||||
decomp.code.scope++;
|
||||
}
|
||||
if (ast.kills) {
|
||||
decomp.code.AddLine("discard;");
|
||||
if (decomp.stage != ShaderType::Fragment) {
|
||||
decomp.code.AddLine("return;");
|
||||
} else {
|
||||
decomp.code.AddLine("discard;");
|
||||
}
|
||||
} else {
|
||||
if (decomp.context_func->IsMain()) {
|
||||
decomp.PreExit();
|
||||
|
||||
@@ -591,6 +591,14 @@ private:
|
||||
DeclareOutputVertex();
|
||||
}
|
||||
|
||||
void SafeKill() {
|
||||
if (stage != ShaderType::Fragment) {
|
||||
OpReturn();
|
||||
return;
|
||||
}
|
||||
OpKill();
|
||||
}
|
||||
|
||||
void DeclareFragment() {
|
||||
if (stage != ShaderType::Fragment) {
|
||||
return;
|
||||
@@ -2126,7 +2134,7 @@ private:
|
||||
|
||||
OpBranchConditional(condition, true_label, discard_label);
|
||||
AddLabel(discard_label);
|
||||
OpKill();
|
||||
SafeKill();
|
||||
AddLabel(true_label);
|
||||
}
|
||||
|
||||
@@ -2196,12 +2204,12 @@ private:
|
||||
Expression Discard(Operation operation) {
|
||||
inside_branch = true;
|
||||
if (conditional_branch_set) {
|
||||
OpKill();
|
||||
SafeKill();
|
||||
} else {
|
||||
const Id dummy = OpLabel();
|
||||
OpBranch(dummy);
|
||||
AddLabel(dummy);
|
||||
OpKill();
|
||||
SafeKill();
|
||||
AddLabel();
|
||||
}
|
||||
return {};
|
||||
@@ -3053,7 +3061,7 @@ public:
|
||||
decomp.OpBranchConditional(condition, then_label, endif_label);
|
||||
decomp.AddLabel(then_label);
|
||||
if (ast.kills) {
|
||||
decomp.OpKill();
|
||||
decomp.SafeKill();
|
||||
} else {
|
||||
if (decomp.context_func->IsMain()) {
|
||||
decomp.PreExit();
|
||||
@@ -3066,7 +3074,7 @@ public:
|
||||
decomp.OpBranch(next_block);
|
||||
decomp.AddLabel(next_block);
|
||||
if (ast.kills) {
|
||||
decomp.OpKill();
|
||||
decomp.SafeKill();
|
||||
} else {
|
||||
if (decomp.context_func->IsMain()) {
|
||||
decomp.PreExit();
|
||||
|
||||
Reference in New Issue
Block a user