mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-07 15:31:26 +12:00
d3d12: Some work to decompiler
This commit is contained in:
parent
c465b6699a
commit
bf8a48e3bd
2 changed files with 38 additions and 18 deletions
|
@ -6,27 +6,44 @@
|
||||||
#include "Emu/Memory/Memory.h"
|
#include "Emu/Memory/Memory.h"
|
||||||
#include "Emu/System.h"
|
#include "Emu/System.h"
|
||||||
|
|
||||||
static std::string typeName[] =
|
|
||||||
{
|
|
||||||
"float",
|
|
||||||
"float2",
|
|
||||||
"float3",
|
|
||||||
"float4"
|
|
||||||
};
|
|
||||||
|
|
||||||
static std::string functionName[] =
|
|
||||||
{
|
|
||||||
"saturate",
|
|
||||||
"float4(dot($0.xy, $1.xy), dot($0.xy, $1.xy), dot($0.xy, $1.xy), dot($0.xy, $1.xy))",
|
|
||||||
"frac($0)",
|
|
||||||
};
|
|
||||||
|
|
||||||
D3D12FragmentDecompiler::D3D12FragmentDecompiler(u32 addr, u32& size, u32 ctrl) :
|
D3D12FragmentDecompiler::D3D12FragmentDecompiler(u32 addr, u32& size, u32 ctrl) :
|
||||||
FragmentProgramDecompiler(addr, size, ctrl)
|
FragmentProgramDecompiler(addr, size, 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";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string D3D12FragmentDecompiler::getFunction(enum class FUNCTION f)
|
||||||
|
{
|
||||||
|
switch (f)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
abort();
|
||||||
|
case FUNCTION::FUNCTION_SATURATE:
|
||||||
|
return "saturate";
|
||||||
|
case FUNCTION::FUNCTION_DP2:
|
||||||
|
return "dot($0.xy, $1.xy).xxxx";
|
||||||
|
case FUNCTION::FUNCTION_FRACT:
|
||||||
|
return "frac($0)";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void D3D12FragmentDecompiler::insertHeader(std::stringstream & OS)
|
void D3D12FragmentDecompiler::insertHeader(std::stringstream & OS)
|
||||||
{
|
{
|
||||||
OS << "// Header" << std::endl;
|
OS << "// Header" << std::endl;
|
||||||
|
@ -69,8 +86,8 @@ void D3D12FragmentDecompiler::insertOutputs(std::stringstream & OS)
|
||||||
|
|
||||||
for (int i = 0; i < sizeof(table) / sizeof(*table); ++i)
|
for (int i = 0; i < sizeof(table) / sizeof(*table); ++i)
|
||||||
{
|
{
|
||||||
if (m_parr.HasParam(PF_PARAM_NONE, typeName[3], table[i].second))
|
if (m_parr.HasParam(PF_PARAM_NONE, "float4", table[i].second))
|
||||||
OS << " " << typeName[3] << " " << table[i].first << " : SV_TARGET" << i << ";" << std::endl;
|
OS << " " << "float4" << " " << table[i].first << " : SV_TARGET" << i << ";" << std::endl;
|
||||||
}
|
}
|
||||||
OS << "};" << std::endl;
|
OS << "};" << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -131,7 +148,7 @@ void D3D12FragmentDecompiler::insertMainEnd(std::stringstream & OS)
|
||||||
OS << " PixelOutput Out;" << std::endl;
|
OS << " PixelOutput Out;" << std::endl;
|
||||||
for (int i = 0; i < sizeof(table) / sizeof(*table); ++i)
|
for (int i = 0; i < sizeof(table) / sizeof(*table); ++i)
|
||||||
{
|
{
|
||||||
if (m_parr.HasParam(PF_PARAM_NONE, typeName[3], table[i].second))
|
if (m_parr.HasParam(PF_PARAM_NONE, "float4", table[i].second))
|
||||||
OS << " Out." << table[i].first << " = " << table[i].second << ";" << std::endl;
|
OS << " Out." << table[i].first << " = " << table[i].second << ";" << std::endl;
|
||||||
}
|
}
|
||||||
OS << " return Out;" << std::endl;
|
OS << " return Out;" << std::endl;
|
||||||
|
|
|
@ -8,6 +8,9 @@
|
||||||
class D3D12FragmentDecompiler : public FragmentProgramDecompiler
|
class D3D12FragmentDecompiler : public FragmentProgramDecompiler
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
virtual std::string getFloatTypeName(size_t elementCount) override;
|
||||||
|
virtual std::string getFunction(enum class FUNCTION) override;
|
||||||
|
|
||||||
virtual void insertHeader(std::stringstream &OS) override;
|
virtual void insertHeader(std::stringstream &OS) override;
|
||||||
virtual void insertIntputs(std::stringstream &OS) override;
|
virtual void insertIntputs(std::stringstream &OS) override;
|
||||||
virtual void insertOutputs(std::stringstream &OS) override;
|
virtual void insertOutputs(std::stringstream &OS) override;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue