Dump IW4 vertex and pixel shader binary data

This commit is contained in:
Jan 2022-03-24 17:36:12 +01:00
parent 5f44d95770
commit 935e6ac060
2 changed files with 26 additions and 0 deletions

View File

@ -1,5 +1,7 @@
#include "AssetDumperPixelShader.h" #include "AssetDumperPixelShader.h"
#include <sstream>
using namespace IW4; using namespace IW4;
bool AssetDumperPixelShader::ShouldDump(XAssetInfo<MaterialPixelShader>* asset) bool AssetDumperPixelShader::ShouldDump(XAssetInfo<MaterialPixelShader>* asset)
@ -9,4 +11,15 @@ bool AssetDumperPixelShader::ShouldDump(XAssetInfo<MaterialPixelShader>* asset)
void AssetDumperPixelShader::DumpAsset(AssetDumpingContext& context, XAssetInfo<MaterialPixelShader>* asset) void AssetDumperPixelShader::DumpAsset(AssetDumpingContext& context, XAssetInfo<MaterialPixelShader>* asset)
{ {
const auto* pixelShader = asset->Asset();
std::ostringstream ss;
ss << "shader_bin/ps_" << pixelShader->name << ".cso";
const auto shaderFile = context.OpenAssetFile(ss.str());
if (!shaderFile)
return;
shaderFile->write(reinterpret_cast<const char*>(pixelShader->prog.loadDef.program), static_cast<std::streamsize>(pixelShader->prog.loadDef.programSize) * 4u);
} }

View File

@ -1,5 +1,7 @@
#include "AssetDumperVertexShader.h" #include "AssetDumperVertexShader.h"
#include <sstream>
using namespace IW4; using namespace IW4;
bool AssetDumperVertexShader::ShouldDump(XAssetInfo<MaterialVertexShader>* asset) bool AssetDumperVertexShader::ShouldDump(XAssetInfo<MaterialVertexShader>* asset)
@ -9,4 +11,15 @@ bool AssetDumperVertexShader::ShouldDump(XAssetInfo<MaterialVertexShader>* asset
void AssetDumperVertexShader::DumpAsset(AssetDumpingContext& context, XAssetInfo<MaterialVertexShader>* asset) void AssetDumperVertexShader::DumpAsset(AssetDumpingContext& context, XAssetInfo<MaterialVertexShader>* asset)
{ {
const auto* vertexShader = asset->Asset();
std::ostringstream ss;
ss << "shader_bin/vs_" << vertexShader->name << ".cso";
const auto shaderFile = context.OpenAssetFile(ss.str());
if (!shaderFile)
return;
shaderFile->write(reinterpret_cast<const char*>(vertexShader->prog.loadDef.program), static_cast<std::streamsize>(vertexShader->prog.loadDef.programSize) * 4u);
} }