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

View File

@ -35,6 +35,12 @@ namespace IW4
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)
{
if (pass.vertexShader == nullptr)
@ -48,7 +54,22 @@ namespace IW4
m_stream << "{\n";
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();
Indent();
@ -68,7 +89,24 @@ namespace IW4
m_stream << "{\n";
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();
Indent();