mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-17 01:15:30 +00:00
Common/GL/D3D12: Fix int vector ctor in vertex shader and a compare opcode.
This commit is contained in:
parent
de97d3a7aa
commit
b0f8611f49
@ -232,16 +232,15 @@ std::string VertexProgramDecompiler::GetCond()
|
||||
if (d0.cond == 0) return "false";
|
||||
if (d0.cond == (lt | gt | eq)) return "true";
|
||||
|
||||
static const char* cond_string_table[(lt | gt | eq) + 1] =
|
||||
static const COMPARE cond_string_table[(lt | gt | eq) + 1] =
|
||||
{
|
||||
"error",
|
||||
"lessThan",
|
||||
"equal",
|
||||
"lessThanEqual",
|
||||
"greaterThan",
|
||||
"notEqual",
|
||||
"greaterThanEqual",
|
||||
"error"
|
||||
COMPARE::FUNCTION_SLT, // "error"
|
||||
COMPARE::FUNCTION_SLT,
|
||||
COMPARE::FUNCTION_SEQ,
|
||||
COMPARE::FUNCTION_SLE,
|
||||
COMPARE::FUNCTION_SGT,
|
||||
COMPARE::FUNCTION_SNE,
|
||||
COMPARE::FUNCTION_SGE,
|
||||
};
|
||||
|
||||
static const char f[4] = { 'x', 'y', 'z', 'w' };
|
||||
@ -253,8 +252,7 @@ std::string VertexProgramDecompiler::GetCond()
|
||||
swizzle += f[d0.mask_w];
|
||||
|
||||
swizzle = swizzle == "xyzw" ? "" : "." + swizzle;
|
||||
|
||||
return fmt::format("any(%s(cc%d%s, vec4(0.0)%s))", cond_string_table[d0.cond], d0.cond_reg_sel_1, swizzle.c_str(), swizzle.c_str());
|
||||
return "any(" + compareFunction(cond_string_table[d0.cond], "cc" + std::to_string(d0.cond_reg_sel_1), getFloatTypeName(4) + "(0., 0., 0., 0.)" + swizzle) + ")";
|
||||
}
|
||||
|
||||
void VertexProgramDecompiler::AddCodeCond(const std::string& dst, const std::string& src)
|
||||
@ -330,7 +328,7 @@ std::string VertexProgramDecompiler::AddAddrMask()
|
||||
std::string VertexProgramDecompiler::AddAddrReg()
|
||||
{
|
||||
static const char f[] = { 'x', 'y', 'z', 'w' };
|
||||
return m_parr.AddParam(PF_PARAM_NONE, "ivec4", "a" + std::to_string(d0.addr_reg_sel_1), "ivec4(0)") + AddAddrMask();
|
||||
return m_parr.AddParam(PF_PARAM_NONE, getFloatTypeName(4), "a" + std::to_string(d0.addr_reg_sel_1), getFloatTypeName(4) + "(0, 0, 0, 0)") + AddAddrMask();
|
||||
}
|
||||
|
||||
u32 VertexProgramDecompiler::GetAddr()
|
||||
@ -659,7 +657,7 @@ std::string VertexProgramDecompiler::Decompile()
|
||||
case RSX_VEC_OPCODE_MAX: SetDSTVec("max($0, $1)"); break;
|
||||
case RSX_VEC_OPCODE_SLT: SetDSTVec(getFloatTypeName(4) + "(" + compareFunction(COMPARE::FUNCTION_SLT, "$0", "$1") + ")"); break;
|
||||
case RSX_VEC_OPCODE_SGE: SetDSTVec(getFloatTypeName(4) + "(" + compareFunction(COMPARE::FUNCTION_SGE, "$0", "$1") + ")"); break;
|
||||
case RSX_VEC_OPCODE_ARL: AddCode("$ifcond $a = ivec4($0)$am;"); break;
|
||||
case RSX_VEC_OPCODE_ARL: AddCode("$ifcond $a = " + getIntTypeName(4) + "($0)$am;"); break;
|
||||
case RSX_VEC_OPCODE_FRC: SetDSTVec(getFunction(FUNCTION::FUNCTION_FRACT)); break;
|
||||
case RSX_VEC_OPCODE_FLR: SetDSTVec("floor($0)"); break;
|
||||
case RSX_VEC_OPCODE_SEQ: SetDSTVec(getFloatTypeName(4) + "(" + compareFunction(COMPARE::FUNCTION_SEQ, "$0", "$1") + ")"); break;
|
||||
|
@ -80,6 +80,10 @@ protected:
|
||||
*/
|
||||
virtual std::string getFloatTypeName(size_t elementCount) = 0;
|
||||
|
||||
/** returns the type name of int vectors.
|
||||
*/
|
||||
virtual std::string getIntTypeName(size_t elementCount) = 0;
|
||||
|
||||
/** returns string calling function where arguments are passed via
|
||||
* $0 $1 $2 substring.
|
||||
*/
|
||||
|
@ -11,6 +11,11 @@ std::string D3D12VertexProgramDecompiler::getFloatTypeName(size_t elementCount)
|
||||
return getFloatTypeNameImp(elementCount);
|
||||
}
|
||||
|
||||
std::string D3D12VertexProgramDecompiler::getIntTypeName(size_t elementCount)
|
||||
{
|
||||
return "int4";
|
||||
}
|
||||
|
||||
std::string D3D12VertexProgramDecompiler::getFunction(enum class FUNCTION f)
|
||||
{
|
||||
return getFunctionImp(f);
|
||||
|
@ -8,6 +8,7 @@ struct D3D12VertexProgramDecompiler : public VertexProgramDecompiler
|
||||
{
|
||||
protected:
|
||||
virtual std::string getFloatTypeName(size_t elementCount) override;
|
||||
std::string getIntTypeName(size_t elementCount) override;
|
||||
virtual std::string getFunction(enum class FUNCTION) override;
|
||||
virtual std::string compareFunction(enum class COMPARE, const std::string &, const std::string &) override;
|
||||
|
||||
|
@ -10,6 +10,12 @@ std::string GLVertexDecompilerThread::getFloatTypeName(size_t elementCount)
|
||||
return getFloatTypeNameImpl(elementCount);
|
||||
}
|
||||
|
||||
std::string GLVertexDecompilerThread::getIntTypeName(size_t elementCount)
|
||||
{
|
||||
return "ivec4";
|
||||
}
|
||||
|
||||
|
||||
std::string GLVertexDecompilerThread::getFunction(FUNCTION f)
|
||||
{
|
||||
return getFunctionImpl(f);
|
||||
|
@ -9,6 +9,7 @@ struct GLVertexDecompilerThread : public VertexProgramDecompiler
|
||||
std::string &m_shader;
|
||||
protected:
|
||||
virtual std::string getFloatTypeName(size_t elementCount) override;
|
||||
std::string getIntTypeName(size_t elementCount) override;
|
||||
virtual std::string getFunction(FUNCTION) override;
|
||||
virtual std::string compareFunction(COMPARE, const std::string&, const std::string&) override;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user