mirror of
https://github.com/hedge-dev/XenosRecomp.git
synced 2026-04-28 04:51:36 +00:00
Cleanup
Signed-off-by: Isaac Marovitz <isaacryu@icloud.com>
This commit is contained in:
parent
f328cbbec8
commit
6153094d1f
2 changed files with 29 additions and 45 deletions
|
|
@ -161,6 +161,30 @@ float2 getWeights2D(uint resourceDescriptorIndex, uint samplerDescriptorIndex, f
|
|||
|
||||
#endif
|
||||
|
||||
#ifdef __air__
|
||||
#define selectWrapper(a, b, c) select(c, b, a)
|
||||
#else
|
||||
#define selectWrapper(a, b, c) select(a, b, c)
|
||||
#endif
|
||||
|
||||
#ifdef __air__
|
||||
#define frac(X) fract(X)
|
||||
|
||||
template<typename T>
|
||||
void clip(T a)
|
||||
{
|
||||
if (a < 0.0) {
|
||||
discard_fragment();
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void rcp(T a)
|
||||
{
|
||||
return 1.0 / a;
|
||||
}
|
||||
#endif
|
||||
|
||||
float w0(float a)
|
||||
{
|
||||
return (1.0f / 6.0f) * (a * (a * (-a + 3.0f) - 3.0f) + 1.0f);
|
||||
|
|
|
|||
|
|
@ -556,38 +556,22 @@ void ShaderRecompiler::recompile(const AluInstruction& instr)
|
|||
{
|
||||
case AluVectorOpcode::KillEq:
|
||||
indent();
|
||||
#ifdef XENOS_RECOMP_AIR
|
||||
println("if (any({} == {})) discard_fragment();", op(VECTOR_0), op(VECTOR_1));
|
||||
#else
|
||||
println("clip(any({} == {}) ? -1 : 1);", op(VECTOR_0), op(VECTOR_1));
|
||||
#endif
|
||||
break;
|
||||
|
||||
case AluVectorOpcode::KillGt:
|
||||
indent();
|
||||
#ifdef XENOS_RECOMP_AIR
|
||||
println("if (any({} > {})) discard_fragment();", op(VECTOR_0), op(VECTOR_1));
|
||||
#else
|
||||
println("clip(any({} > {}) ? -1 : 1);", op(VECTOR_0), op(VECTOR_1));
|
||||
#endif
|
||||
break;
|
||||
|
||||
case AluVectorOpcode::KillGe:
|
||||
indent();
|
||||
#ifdef XENOS_RECOMP_AIR
|
||||
println("if (any({} >= {})) discard_fragment();", op(VECTOR_0), op(VECTOR_1));
|
||||
#else
|
||||
println("clip(any({} >= {}) ? -1 : 1);", op(VECTOR_0), op(VECTOR_1));
|
||||
#endif
|
||||
break;
|
||||
|
||||
case AluVectorOpcode::KillNe:
|
||||
indent();
|
||||
#ifdef XENOS_RECOMP_AIR
|
||||
println("if (any({} != {})) discard_fragment();", op(VECTOR_0), op(VECTOR_1));
|
||||
#else
|
||||
println("clip(any({} != {}) ? -1 : 1);", op(VECTOR_0), op(VECTOR_1));
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -743,11 +727,7 @@ void ShaderRecompiler::recompile(const AluInstruction& instr)
|
|||
break;
|
||||
|
||||
case AluVectorOpcode::Frc:
|
||||
#ifdef XENOS_RECOMP_AIR
|
||||
print("fract({})", op(VECTOR_0));
|
||||
#else
|
||||
print("frac({})", op(VECTOR_0));
|
||||
#endif
|
||||
break;
|
||||
|
||||
case AluVectorOpcode::Trunc:
|
||||
|
|
@ -763,15 +743,15 @@ void ShaderRecompiler::recompile(const AluInstruction& instr)
|
|||
break;
|
||||
|
||||
case AluVectorOpcode::CndEq:
|
||||
print("select({} == 0.0, {}, {})", op(VECTOR_0), op(VECTOR_1), op(VECTOR_2));
|
||||
print("selectWrapper({} == 0.0, {}, {})", op(VECTOR_0), op(VECTOR_1), op(VECTOR_2));
|
||||
break;
|
||||
|
||||
case AluVectorOpcode::CndGe:
|
||||
print("select({} >= 0.0, {}, {})", op(VECTOR_0), op(VECTOR_1), op(VECTOR_2));
|
||||
print("selectWrapper({} >= 0.0, {}, {})", op(VECTOR_0), op(VECTOR_1), op(VECTOR_2));
|
||||
break;
|
||||
|
||||
case AluVectorOpcode::CndGt:
|
||||
print("select({} > 0.0, {}, {})", op(VECTOR_0), op(VECTOR_1), op(VECTOR_2));
|
||||
print("selectWrapper({} > 0.0, {}, {})", op(VECTOR_0), op(VECTOR_1), op(VECTOR_2));
|
||||
break;
|
||||
|
||||
case AluVectorOpcode::Dp4:
|
||||
|
|
@ -815,11 +795,7 @@ void ShaderRecompiler::recompile(const AluInstruction& instr)
|
|||
break;
|
||||
|
||||
case AluVectorOpcode::Dst:
|
||||
#ifdef XENOS_RECOMP_AIR
|
||||
print("distance({}, {})", op(VECTOR_0), op(VECTOR_1));
|
||||
#else
|
||||
print("dst({}, {})", op(VECTOR_0), op(VECTOR_1));
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -925,11 +901,7 @@ void ShaderRecompiler::recompile(const AluInstruction& instr)
|
|||
break;
|
||||
|
||||
case AluScalarOpcode::Frcs:
|
||||
#ifdef XENOS_RECOMP_AIR
|
||||
print("fract({})", op(SCALAR_0));
|
||||
#else
|
||||
print("frac({})", op(SCALAR_0));
|
||||
#endif
|
||||
break;
|
||||
|
||||
case AluScalarOpcode::Truncs:
|
||||
|
|
@ -952,11 +924,7 @@ void ShaderRecompiler::recompile(const AluInstruction& instr)
|
|||
case AluScalarOpcode::Rcpc:
|
||||
case AluScalarOpcode::Rcpf:
|
||||
case AluScalarOpcode::Rcp:
|
||||
#ifdef XENOS_RECOMP_AIR
|
||||
print("clamp((1.0 / {}), FLT_MIN, FLT_MAX)", op(SCALAR_0));
|
||||
#else
|
||||
print("clamp(rcp({}), FLT_MIN, FLT_MAX)", op(SCALAR_0));
|
||||
#endif
|
||||
break;
|
||||
|
||||
case AluScalarOpcode::Rsqc:
|
||||
|
|
@ -1112,11 +1080,7 @@ void ShaderRecompiler::recompile(const AluInstruction& instr)
|
|||
if (instr.scalarOpcode >= AluScalarOpcode::KillsEq && instr.scalarOpcode <= AluScalarOpcode::KillsOne)
|
||||
{
|
||||
indent();
|
||||
#ifdef XENOS_RECOMP_AIR
|
||||
out += "if (ps != 0.0) discard_fragment();\n";
|
||||
#else
|
||||
out += "clip(ps != 0.0 ? -1 : 1);\n";
|
||||
#endif
|
||||
}
|
||||
|
||||
if (closeIfBracket)
|
||||
|
|
@ -1190,7 +1154,7 @@ void ShaderRecompiler::recompile(const uint8_t* shaderData, const std::string_vi
|
|||
{
|
||||
uint32_t tailCount = (isPixelShader ? 224 : 256) - constantInfo->registerIndex;
|
||||
|
||||
println("#define {}(INDEX) select((INDEX) < {}, vk::RawBufferLoad<float4>(g_PushConstants.{}ShaderConstants + ({} + min(INDEX, {})) * 16, 0x10), 0.0)",
|
||||
println("#define {}(INDEX) selectWrapper((INDEX) < {}, vk::RawBufferLoad<float4>(g_PushConstants.{}ShaderConstants + ({} + min(INDEX, {})) * 16, 0x10), 0.0)",
|
||||
constantName, tailCount, shaderName, constantInfo->registerIndex.get(), tailCount - 1);
|
||||
}
|
||||
else
|
||||
|
|
@ -1247,7 +1211,7 @@ void ShaderRecompiler::recompile(const uint8_t* shaderData, const std::string_vi
|
|||
if (constantInfo->registerCount > 1)
|
||||
{
|
||||
uint32_t tailCount = (isPixelShader ? 224 : 256) - constantInfo->registerIndex;
|
||||
println("#define {0}(INDEX) select((INDEX) < {1}, {0}[min(INDEX, {2})], 0.0)", constantName, tailCount, tailCount - 1);
|
||||
println("#define {0}(INDEX) selectWrapper((INDEX) < {1}, {0}[min(INDEX, {2})], 0.0)", constantName, tailCount, tailCount - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1848,11 +1812,7 @@ void ShaderRecompiler::recompile(const uint8_t* shaderData, const std::string_vi
|
|||
|
||||
indent();
|
||||
|
||||
#ifdef XENOS_RECOMP_AIR
|
||||
out += "\tif ((oC0.w - g_AlphaThreshold) < 0.0) discard_fragment();\n";
|
||||
#else
|
||||
out += "\tclip(oC0.w - g_AlphaThreshold);\n";
|
||||
#endif
|
||||
|
||||
indent();
|
||||
out += "}";
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue