mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-15 19:28:43 +12:00
d3d12: Factorize common use functions among frag and vertex decompiler
This commit is contained in:
parent
e38bf8d51f
commit
1837f40ed4
6 changed files with 93 additions and 115 deletions
|
@ -1,7 +1,7 @@
|
|||
#include "stdafx.h"
|
||||
#if defined(DX12_SUPPORT)
|
||||
#include "D3D12FragmentProgramDecompiler.h"
|
||||
|
||||
#include "D3D12CommonDecompiler.h"
|
||||
#include "Utilities/Log.h"
|
||||
#include "Emu/Memory/Memory.h"
|
||||
#include "Emu/System.h"
|
||||
|
@ -14,50 +14,12 @@ D3D12FragmentDecompiler::D3D12FragmentDecompiler(u32 addr, u32& size, u32 ctrl)
|
|||
|
||||
std::string D3D12FragmentDecompiler::getFloatTypeName(size_t elementCount)
|
||||
{
|
||||
switch (elementCount)
|
||||
{
|
||||
default:
|
||||
abort();
|
||||
case 1:
|
||||
return "float";
|
||||
case 2:
|
||||
return "float2";
|
||||
case 3:
|
||||
return "float3";
|
||||
case 4:
|
||||
return "float4";
|
||||
}
|
||||
return getFloatTypeNameImp(elementCount);
|
||||
}
|
||||
|
||||
std::string D3D12FragmentDecompiler::getFunction(enum class FUNCTION f)
|
||||
{
|
||||
switch (f)
|
||||
{
|
||||
default:
|
||||
abort();
|
||||
case FUNCTION::FUNCTION_DP2:
|
||||
return "dot($0.xy, $1.xy).xxxx";
|
||||
case FUNCTION::FUNCTION_DP2A:
|
||||
return "(dot($0.xy, $1.xy) + $2.x).xxxx";
|
||||
case FUNCTION::FUNCTION_DP3:
|
||||
return "dot($0.xyz, $1.xyz).xxxx";
|
||||
case FUNCTION::FUNCTION_DP4:
|
||||
return "dot($0, $1).xxxx";
|
||||
case FUNCTION::FUNCTION_DPH:
|
||||
return "dot(float4($0.xyz, 1.0), $1).xxxx";
|
||||
case FUNCTION::FUNCTION_SFL:
|
||||
return "float4(0., 0., 0., 0.)";
|
||||
case FUNCTION::FUNCTION_STR:
|
||||
return "float4(1., 1., 1., 1.)";
|
||||
case FUNCTION::FUNCTION_FRACT:
|
||||
return "frac($0)";
|
||||
case FUNCTION::FUNCTION_TEXTURE_SAMPLE:
|
||||
return "$t.Sample($tsampler, $0.xy)";
|
||||
case FUNCTION::FUNCTION_DFDX:
|
||||
return "ddx($0)";
|
||||
case FUNCTION::FUNCTION_DFDY:
|
||||
return "ddy($0)";
|
||||
}
|
||||
return getFunctionImp(f);
|
||||
}
|
||||
|
||||
std::string D3D12FragmentDecompiler::saturate(const std::string & code)
|
||||
|
@ -67,23 +29,7 @@ std::string D3D12FragmentDecompiler::saturate(const std::string & code)
|
|||
|
||||
std::string D3D12FragmentDecompiler::compareFunction(COMPARE f, const std::string &Op0, const std::string &Op1)
|
||||
{
|
||||
switch (f)
|
||||
{
|
||||
default:
|
||||
abort();
|
||||
case COMPARE::FUNCTION_SEQ:
|
||||
return "(" + Op0 + " == " + Op1 + ")";
|
||||
case COMPARE::FUNCTION_SGE:
|
||||
return "(" + Op0 + " >= " + Op1 +")";
|
||||
case COMPARE::FUNCTION_SGT:
|
||||
return "(" + Op0 + " > " + Op1 + ")";
|
||||
case COMPARE::FUNCTION_SLE:
|
||||
return "(" + Op0 + " <= " + Op1 + ")";
|
||||
case COMPARE::FUNCTION_SLT:
|
||||
return "(" + Op0 + " < " + Op1 + ")";
|
||||
case COMPARE::FUNCTION_SNE:
|
||||
return "(" + Op0 + " != " + Op1 + ")";
|
||||
}
|
||||
return compareFunctionImp(f, Op0, Op1);
|
||||
}
|
||||
|
||||
void D3D12FragmentDecompiler::insertHeader(std::stringstream & OS)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue