mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-08-30 21:53:15 +00:00
refactor: streamline shader dumping
This commit is contained in:
@@ -15,8 +15,8 @@
|
||||
#include "PhysCollmap/PhysCollmapDumperIW4.h"
|
||||
#include "PhysPreset/PhysPresetInfoStringDumperIW4.h"
|
||||
#include "RawFile/RawFileDumperIW4.h"
|
||||
#include "Shader/AssetDumperPixelShader.h"
|
||||
#include "Shader/AssetDumperVertexShader.h"
|
||||
#include "Shader/PixelShaderDumperIW4.h"
|
||||
#include "Shader/VertexShaderDumperIW4.h"
|
||||
#include "Sound/LoadedSoundDumperIW4.h"
|
||||
#include "Sound/SndCurveDumperIW4.h"
|
||||
#include "StringTable/StringTableDumperIW4.h"
|
||||
@@ -47,8 +47,8 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
|
||||
#ifdef EXPERIMENTAL_MATERIAL_COMPILATION
|
||||
DUMP_ASSET_POOL(material::DecompilingGdtDumper, m_material, ASSET_TYPE_MATERIAL)
|
||||
#endif
|
||||
DUMP_ASSET_POOL(AssetDumperPixelShader, m_material_pixel_shader, ASSET_TYPE_PIXELSHADER)
|
||||
DUMP_ASSET_POOL(AssetDumperVertexShader, m_material_vertex_shader, ASSET_TYPE_VERTEXSHADER)
|
||||
DUMP_ASSET_POOL(shader::PixelShaderDumper, m_material_pixel_shader, ASSET_TYPE_PIXELSHADER)
|
||||
DUMP_ASSET_POOL(shader::VertexShaderDumper, m_material_vertex_shader, ASSET_TYPE_VERTEXSHADER)
|
||||
DUMP_ASSET_POOL(techset::Dumper, m_technique_set, ASSET_TYPE_TECHNIQUE_SET)
|
||||
DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE)
|
||||
// DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound, ASSET_TYPE_SOUND)
|
||||
|
@@ -1,26 +0,0 @@
|
||||
#include "AssetDumperPixelShader.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
bool AssetDumperPixelShader::ShouldDump(XAssetInfo<MaterialPixelShader>* asset)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
@@ -1,26 +0,0 @@
|
||||
#include "AssetDumperVertexShader.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
bool AssetDumperVertexShader::ShouldDump(XAssetInfo<MaterialVertexShader>* asset)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
26
src/ObjWriting/Game/IW4/Shader/PixelShaderDumperIW4.cpp
Normal file
26
src/ObjWriting/Game/IW4/Shader/PixelShaderDumperIW4.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include "PixelShaderDumperIW4.h"
|
||||
|
||||
#include "Shader/ShaderCommon.h"
|
||||
|
||||
using namespace IW4;
|
||||
using namespace ::shader;
|
||||
|
||||
namespace IW4::shader
|
||||
{
|
||||
bool PixelShaderDumper::ShouldDump(XAssetInfo<MaterialPixelShader>* asset)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void PixelShaderDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo<MaterialPixelShader>* asset)
|
||||
{
|
||||
const auto* pixelShader = asset->Asset();
|
||||
const auto shaderFile = context.OpenAssetFile(GetFileNameForPixelShaderAssetName(asset->m_name));
|
||||
|
||||
if (!shaderFile)
|
||||
return;
|
||||
|
||||
shaderFile->write(reinterpret_cast<const char*>(pixelShader->prog.loadDef.program),
|
||||
static_cast<std::streamsize>(pixelShader->prog.loadDef.programSize) * 4u);
|
||||
}
|
||||
} // namespace IW4::shader
|
@@ -3,12 +3,12 @@
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
|
||||
namespace IW4
|
||||
namespace IW4::shader
|
||||
{
|
||||
class AssetDumperPixelShader final : public AbstractAssetDumper<MaterialPixelShader>
|
||||
class PixelShaderDumper final : public AbstractAssetDumper<MaterialPixelShader>
|
||||
{
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<MaterialPixelShader>* asset) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<MaterialPixelShader>* asset) override;
|
||||
};
|
||||
} // namespace IW4
|
||||
} // namespace IW4::shader
|
26
src/ObjWriting/Game/IW4/Shader/VertexShaderDumperIW4.cpp
Normal file
26
src/ObjWriting/Game/IW4/Shader/VertexShaderDumperIW4.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include "VertexShaderDumperIW4.h"
|
||||
|
||||
#include "Shader/ShaderCommon.h"
|
||||
|
||||
using namespace IW4;
|
||||
using namespace ::shader;
|
||||
|
||||
namespace IW4::shader
|
||||
{
|
||||
bool VertexShaderDumper::ShouldDump(XAssetInfo<MaterialVertexShader>* asset)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void VertexShaderDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo<MaterialVertexShader>* asset)
|
||||
{
|
||||
const auto* vertexShader = asset->Asset();
|
||||
const auto shaderFile = context.OpenAssetFile(GetFileNameForVertexShaderAssetName(asset->m_name));
|
||||
|
||||
if (!shaderFile)
|
||||
return;
|
||||
|
||||
shaderFile->write(reinterpret_cast<const char*>(vertexShader->prog.loadDef.program),
|
||||
static_cast<std::streamsize>(vertexShader->prog.loadDef.programSize) * 4u);
|
||||
}
|
||||
} // namespace IW4::shader
|
@@ -3,12 +3,12 @@
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
|
||||
namespace IW4
|
||||
namespace IW4::shader
|
||||
{
|
||||
class AssetDumperVertexShader final : public AbstractAssetDumper<MaterialVertexShader>
|
||||
class VertexShaderDumper final : public AbstractAssetDumper<MaterialVertexShader>
|
||||
{
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<MaterialVertexShader>* asset) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<MaterialVertexShader>* asset) override;
|
||||
};
|
||||
} // namespace IW4
|
||||
} // namespace IW4::shader
|
Reference in New Issue
Block a user