TODO IW4 Shader arg dumping

This commit is contained in:
Jan 2022-03-23 18:22:23 +01:00
parent b0ed7e9544
commit 5f44d95770
2 changed files with 52 additions and 9 deletions

View File

@ -920,8 +920,8 @@ namespace IW4
struct MaterialArgumentCodeConst struct MaterialArgumentCodeConst
{ {
uint16_t index; uint16_t index;
char firstRow; unsigned char firstRow;
char rowCount; unsigned char rowCount;
}; };
union MaterialArgumentDef union MaterialArgumentDef
@ -937,14 +937,19 @@ namespace IW4
MTL_ARG_MATERIAL_VERTEX_CONST = 0x0, MTL_ARG_MATERIAL_VERTEX_CONST = 0x0,
MTL_ARG_LITERAL_VERTEX_CONST = 0x1, MTL_ARG_LITERAL_VERTEX_CONST = 0x1,
MTL_ARG_MATERIAL_PIXEL_SAMPLER = 0x2, MTL_ARG_MATERIAL_PIXEL_SAMPLER = 0x2,
MTL_ARG_CODE_PRIM_BEGIN = 0x3, MTL_ARG_CODE_PRIM_BEGIN = 0x3,
MTL_ARG_CODE_VERTEX_CONST = 0x3, MTL_ARG_CODE_VERTEX_CONST = 0x3,
MTL_ARG_CODE_PIXEL_SAMPLER = 0x4, MTL_ARG_CODE_PIXEL_SAMPLER = 0x4,
MTL_ARG_CODE_PIXEL_CONST = 0x5, MTL_ARG_CODE_PIXEL_CONST = 0x5,
MTL_ARG_CODE_PRIM_END = 0x6, MTL_ARG_CODE_PRIM_END = 0x6,
MTL_ARG_MATERIAL_PIXEL_CONST = 0x6, MTL_ARG_MATERIAL_PIXEL_CONST = 0x6,
MTL_ARG_LITERAL_PIXEL_CONST = 0x7, MTL_ARG_LITERAL_PIXEL_CONST = 0x7,
MTL_ARG_COUNT = 0x8,
MTL_ARG_COUNT
}; };
struct MaterialShaderArgument struct MaterialShaderArgument
@ -959,10 +964,10 @@ namespace IW4
MaterialVertexDeclaration* vertexDecl; MaterialVertexDeclaration* vertexDecl;
MaterialVertexShader* vertexShader; MaterialVertexShader* vertexShader;
MaterialPixelShader* pixelShader; MaterialPixelShader* pixelShader;
char perPrimArgCount; unsigned char perPrimArgCount;
char perObjArgCount; unsigned char perObjArgCount;
char stableArgCount; unsigned char stableArgCount;
char customSamplerFlags; unsigned char customSamplerFlags;
MaterialShaderArgument* args; MaterialShaderArgument* args;
}; };

View File

@ -35,6 +35,12 @@ namespace IW4
m_stream << "stateMap \"\"; // TODO\n"; m_stream << "stateMap \"\"; // TODO\n";
} }
void DumpShaderArg(const MaterialShaderArgument& arg)
{
Indent();
m_stream << "// Some arg dest:" << arg.dest << " type: " << arg.type << "\n";
}
void DumpVertexShader(const MaterialPass& pass) void DumpVertexShader(const MaterialPass& pass)
{ {
if (pass.vertexShader == nullptr) if (pass.vertexShader == nullptr)
@ -48,7 +54,22 @@ namespace IW4
m_stream << "{\n"; m_stream << "{\n";
IncIndent(); IncIndent();
// TODO: Dump vertex shader args if (pass.args)
{
const auto totalArgCount = static_cast<size_t>(pass.perPrimArgCount)
+ static_cast<size_t>(pass.perObjArgCount)
+ static_cast<size_t>(pass.stableArgCount);
for (auto i = 0u; i < totalArgCount; i++)
{
const auto& arg = pass.args[i];
if (arg.type == MTL_ARG_MATERIAL_VERTEX_CONST
|| arg.type == MTL_ARG_LITERAL_VERTEX_CONST
|| arg.type == MTL_ARG_CODE_VERTEX_CONST)
{
DumpShaderArg(arg);
}
}
}
DecIndent(); DecIndent();
Indent(); Indent();
@ -68,7 +89,24 @@ namespace IW4
m_stream << "{\n"; m_stream << "{\n";
IncIndent(); IncIndent();
// TODO: Dump pixel shader args if (pass.args)
{
const auto totalArgCount = static_cast<size_t>(pass.perPrimArgCount)
+ static_cast<size_t>(pass.perObjArgCount)
+ static_cast<size_t>(pass.stableArgCount);
for (auto i = 0u; i < totalArgCount; i++)
{
const auto& arg = pass.args[i];
if (arg.type == MTL_ARG_MATERIAL_PIXEL_SAMPLER
|| arg.type == MTL_ARG_CODE_PIXEL_SAMPLER
|| arg.type == MTL_ARG_CODE_PIXEL_CONST
|| arg.type == MTL_ARG_MATERIAL_PIXEL_CONST
|| arg.type == MTL_ARG_LITERAL_PIXEL_CONST)
{
DumpShaderArg(arg);
}
}
}
DecIndent(); DecIndent();
Indent(); Indent();