mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-02-14 03:13:03 +00:00
wip
This commit is contained in:
@@ -8,18 +8,21 @@ using namespace IW3;
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr const char* ASSET_TYPE_NAMES[ASSET_TYPE_COUNT]{
|
||||
constexpr const char* ASSET_TYPE_NAMES[]{
|
||||
"xmodelpieces", "physpreset", "xanim", "xmodel", "material", "techniqueset", "image", "sound", "soundcurve", "loadedsound",
|
||||
"clipmap_unused", "clipmap", "comworld", "gameworldsp", "gameworldmp", "mapents", "gfxworld", "lightdef", "uimap", "font",
|
||||
"menulist", "menu", "localize", "weapon", "snddriverglobals", "fx", "impactfx", "aitype", "mptype", "character",
|
||||
"xmodelalias", "rawfile", "stringtable",
|
||||
};
|
||||
static_assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
|
||||
|
||||
constexpr const char* SUB_ASSET_TYPE_NAMES[SUB_ASSET_TYPE_COUNT]{
|
||||
constexpr const char* SUB_ASSET_TYPE_NAMES[]{
|
||||
"technique",
|
||||
"vertexdecl",
|
||||
"vertexshader",
|
||||
"pixelshader",
|
||||
};
|
||||
static_assert(std::extent_v<decltype(SUB_ASSET_TYPE_NAMES)> == SUB_ASSET_TYPE_COUNT);
|
||||
} // namespace
|
||||
|
||||
namespace IW3
|
||||
|
||||
@@ -53,6 +53,7 @@ namespace IW3
|
||||
enum SubAssetType
|
||||
{
|
||||
SUB_ASSET_TYPE_TECHNIQUE,
|
||||
SUB_ASSET_TYPE_VERTEX_DECL,
|
||||
SUB_ASSET_TYPE_VERTEX_SHADER,
|
||||
SUB_ASSET_TYPE_PIXEL_SHADER,
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ using namespace IW4;
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr const char* ASSET_TYPE_NAMES[ASSET_TYPE_COUNT]{
|
||||
constexpr const char* ASSET_TYPE_NAMES[]{
|
||||
"physpreset", "physcollmap", "xanim", "xmodelsurfs", "xmodel",
|
||||
"material", "pixelshader", "vertexshader", "vertexdecl", "techniqueset",
|
||||
"image", "sound", "soundcurve", "loadedsound", "clipmap_unused",
|
||||
@@ -19,10 +19,12 @@ namespace
|
||||
"xmodelalias", "rawfile", "stringtable", "leaderboard", "structureddatadef",
|
||||
"tracer", "vehicle", "addonmapents",
|
||||
};
|
||||
static_assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
|
||||
|
||||
constexpr const char* SUB_ASSET_TYPE_NAMES[SUB_ASSET_TYPE_COUNT]{
|
||||
constexpr const char* SUB_ASSET_TYPE_NAMES[]{
|
||||
"technique",
|
||||
};
|
||||
static_assert(std::extent_v<decltype(SUB_ASSET_TYPE_NAMES)> == SUB_ASSET_TYPE_COUNT);
|
||||
} // namespace
|
||||
|
||||
namespace IW4
|
||||
|
||||
@@ -8,7 +8,7 @@ using namespace IW5;
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr const char* ASSET_TYPE_NAMES[ASSET_TYPE_COUNT]{
|
||||
constexpr const char* ASSET_TYPE_NAMES[]{
|
||||
"physpreset",
|
||||
"physcollmap",
|
||||
"xanim",
|
||||
@@ -56,10 +56,12 @@ namespace
|
||||
"vehicle",
|
||||
"addonmapents",
|
||||
};
|
||||
static_assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
|
||||
|
||||
constexpr const char* SUB_ASSET_TYPE_NAMES[SUB_ASSET_TYPE_COUNT]{
|
||||
constexpr const char* SUB_ASSET_TYPE_NAMES[]{
|
||||
"technique",
|
||||
};
|
||||
static_assert(std::extent_v<decltype(SUB_ASSET_TYPE_NAMES)> == SUB_ASSET_TYPE_COUNT);
|
||||
} // namespace
|
||||
|
||||
namespace IW5
|
||||
|
||||
@@ -8,7 +8,7 @@ using namespace T5;
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr const char* ASSET_TYPE_NAMES[ASSET_TYPE_COUNT]{
|
||||
constexpr const char* ASSET_TYPE_NAMES[]{
|
||||
"xmodelpieces", "physpreset", "physconstraints", "destructibledef", "xanim", "xmodel", "material",
|
||||
"techniqueset", "image", "soundbank", "soundpatch", "clipmap_unused", "clipmap", "comworld",
|
||||
"gameworldsp", "gameworldmp", "mapents", "gfxworld", "gfxlightdef", "uimap", "font",
|
||||
@@ -17,12 +17,15 @@ namespace
|
||||
"xmodelalias", "rawfile", "stringtable", "packindex", "xglobals", "ddl", "glasses",
|
||||
"emblemset",
|
||||
};
|
||||
static_assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
|
||||
|
||||
constexpr const char* SUB_ASSET_TYPE_NAMES[SUB_ASSET_TYPE_COUNT]{
|
||||
constexpr const char* SUB_ASSET_TYPE_NAMES[]{
|
||||
"technique",
|
||||
"vertexdecl",
|
||||
"vertexshader",
|
||||
"pixelshader",
|
||||
};
|
||||
static_assert(std::extent_v<decltype(SUB_ASSET_TYPE_NAMES)> == SUB_ASSET_TYPE_COUNT);
|
||||
} // namespace
|
||||
|
||||
namespace T5
|
||||
|
||||
@@ -62,7 +62,8 @@ namespace T5
|
||||
|
||||
enum SubAssetType
|
||||
{
|
||||
SUB_ASSET_TYPE_TECHNIQUE = ASSET_TYPE_COUNT,
|
||||
SUB_ASSET_TYPE_TECHNIQUE,
|
||||
SUB_ASSET_TYPE_VERTEX_DECL,
|
||||
SUB_ASSET_TYPE_VERTEX_SHADER,
|
||||
SUB_ASSET_TYPE_PIXEL_SHADER,
|
||||
|
||||
|
||||
@@ -1465,11 +1465,15 @@ namespace T5
|
||||
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,
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ using namespace T6;
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr const char* ASSET_TYPE_NAMES[ASSET_TYPE_COUNT]{
|
||||
constexpr const char* ASSET_TYPE_NAMES[]{
|
||||
"xmodelpieces",
|
||||
"physpreset",
|
||||
"physconstraints",
|
||||
@@ -70,12 +70,15 @@ namespace
|
||||
"footstepfxtable",
|
||||
"zbarrier",
|
||||
};
|
||||
static_assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
|
||||
|
||||
constexpr const char* SUB_ASSET_TYPE_NAMES[SUB_ASSET_TYPE_COUNT]{
|
||||
constexpr const char* SUB_ASSET_TYPE_NAMES[]{
|
||||
"technique",
|
||||
"vertexdecl",
|
||||
"vertexshader",
|
||||
"pixelshader",
|
||||
};
|
||||
static_assert(std::extent_v<decltype(SUB_ASSET_TYPE_NAMES)> == SUB_ASSET_TYPE_COUNT);
|
||||
} // namespace
|
||||
|
||||
namespace T6
|
||||
|
||||
@@ -83,6 +83,7 @@ namespace T6
|
||||
enum SubAssetType
|
||||
{
|
||||
SUB_ASSET_TYPE_TECHNIQUE,
|
||||
SUB_ASSET_TYPE_VERTEX_DECL,
|
||||
SUB_ASSET_TYPE_VERTEX_SHADER,
|
||||
SUB_ASSET_TYPE_PIXEL_SHADER,
|
||||
|
||||
@@ -288,8 +289,9 @@ namespace T6
|
||||
using AssetZBarrier = Asset<ASSET_TYPE_ZBARRIER, ZBarrierDef>;
|
||||
|
||||
using SubAssetTechnique = SubAsset<SUB_ASSET_TYPE_TECHNIQUE, MaterialTechnique>;
|
||||
using SubAssetVertexShader = SubAsset<SUB_ASSET_TYPE_VERTEX_SHADER, MaterialTechnique>;
|
||||
using SubAssetPixelShader = SubAsset<SUB_ASSET_TYPE_PIXEL_SHADER, MaterialTechnique>;
|
||||
using SubAssetVertexDecl = SubAsset<SUB_ASSET_TYPE_VERTEX_DECL, MaterialVertexDeclaration>;
|
||||
using SubAssetVertexShader = SubAsset<SUB_ASSET_TYPE_VERTEX_SHADER, MaterialVertexShader>;
|
||||
using SubAssetPixelShader = SubAsset<SUB_ASSET_TYPE_PIXEL_SHADER, MaterialPixelShader>;
|
||||
} // namespace T6
|
||||
|
||||
DEFINE_ASSET_NAME_ACCESSOR(T6::AssetPhysPreset, name);
|
||||
|
||||
@@ -3001,6 +3001,15 @@ namespace T6
|
||||
VERTEX_SHADER_MODEL_UNLIT,
|
||||
};
|
||||
|
||||
enum CustomSamplers
|
||||
{
|
||||
CUSTOM_SAMPLER_REFLECTION_PROBE = 0,
|
||||
CUSTOM_SAMPLER_LIGHTMAP_PRIMARY,
|
||||
CUSTOM_SAMPLER_LIGHTMAP_SECONDARY,
|
||||
|
||||
CUSTOM_SAMPLER_COUNT
|
||||
};
|
||||
|
||||
enum MaterialType : unsigned char
|
||||
{
|
||||
MTL_TYPE_DEFAULT = 0x0,
|
||||
@@ -3035,6 +3044,20 @@ namespace T6
|
||||
MaterialShaderArgument* args;
|
||||
};
|
||||
|
||||
enum TechniqueFlags
|
||||
{
|
||||
TECHNIQUE_FLAG_1 = 0x1,
|
||||
TECHNIQUE_FLAG_2 = 0x2,
|
||||
TECHNIQUE_FLAG_4 = 0x4,
|
||||
TECHNIQUE_FLAG_8 = 0x8,
|
||||
TECHNIQUE_FLAG_10 = 0x10,
|
||||
TECHNIQUE_FLAG_20 = 0x20,
|
||||
TECHNIQUE_FLAG_40 = 0x40,
|
||||
TECHNIQUE_FLAG_80 = 0x80,
|
||||
TECHNIQUE_FLAG_100 = 0x100,
|
||||
TECHNIQUE_FLAG_200 = 0x200,
|
||||
};
|
||||
|
||||
struct MaterialTechnique
|
||||
{
|
||||
const char* name;
|
||||
@@ -3043,14 +3066,6 @@ namespace T6
|
||||
MaterialPass passArray[1];
|
||||
};
|
||||
|
||||
/* struct __cppobj ID3D11View : ID3D11DeviceChild
|
||||
{
|
||||
};*/
|
||||
|
||||
/* struct __cppobj ID3D11ShaderResourceView : ID3D11View
|
||||
{
|
||||
};*/
|
||||
|
||||
struct type_align32(4) GfxImageLoadDef
|
||||
{
|
||||
char levelCount;
|
||||
@@ -3719,14 +3734,6 @@ namespace T6
|
||||
GfxImage* secondary;
|
||||
};
|
||||
|
||||
/* struct __cppobj ID3D11Resource : ID3D11DeviceChild
|
||||
{
|
||||
};*/
|
||||
|
||||
/* struct __cppobj ID3D11Buffer : ID3D11Resource
|
||||
{
|
||||
};*/
|
||||
|
||||
struct type_align(4) GfxLightGridEntry
|
||||
{
|
||||
uint16_t colorsIndex;
|
||||
@@ -5793,8 +5800,8 @@ namespace T6
|
||||
|
||||
struct MaterialStreamRouting
|
||||
{
|
||||
char source;
|
||||
char dest;
|
||||
unsigned char source;
|
||||
unsigned char dest;
|
||||
};
|
||||
|
||||
struct MaterialVertexStreamRouting
|
||||
@@ -5805,7 +5812,7 @@ namespace T6
|
||||
|
||||
struct MaterialVertexDeclaration
|
||||
{
|
||||
char streamCount;
|
||||
unsigned char streamCount;
|
||||
bool hasOptionalSource;
|
||||
bool isLoaded;
|
||||
MaterialVertexStreamRouting routing;
|
||||
@@ -6177,14 +6184,19 @@ namespace T6
|
||||
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,
|
||||
MLT_ARG_COUNT = 0x8,
|
||||
|
||||
MLT_ARG_COUNT,
|
||||
};
|
||||
|
||||
struct MaterialShaderArgument
|
||||
@@ -6895,10 +6907,6 @@ namespace T6
|
||||
vec3_t halfLengths;
|
||||
};
|
||||
|
||||
/* struct __cppobj ID3D11InputLayout : ID3D11DeviceChild
|
||||
{
|
||||
};*/
|
||||
|
||||
struct GfxLightRegionAxis
|
||||
{
|
||||
vec3_t dir;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -277,6 +277,11 @@ namespace T5
|
||||
};
|
||||
static_assert(std::extent_v<decltype(streamRoutingDestinations)> == STREAM_DST_COUNT);
|
||||
|
||||
static inline techset::CommonStreamRoutingInfos commonRoutingInfos(streamRoutingSources,
|
||||
std::extent_v<decltype(streamRoutingSources)>,
|
||||
streamRoutingDestinations,
|
||||
std::extent_v<decltype(streamRoutingDestinations)>);
|
||||
|
||||
static techset::CommonCodeConstSourceInfo commonCodeConstSources[]{
|
||||
{
|
||||
.value = CONST_SRC_CODE_LIGHT_POSITION,
|
||||
@@ -1734,6 +1739,26 @@ namespace T5
|
||||
},
|
||||
};
|
||||
|
||||
// See MaterialShaderArgumentType
|
||||
static inline techset::CommonShaderArgumentType commonArgumentTypes[]{
|
||||
{.m_shader_type = techset::CommonTechniqueShaderType::VERTEX, .m_value_type = techset::CommonShaderValueType::MATERIAL_CONST },
|
||||
{.m_shader_type = techset::CommonTechniqueShaderType::VERTEX, .m_value_type = techset::CommonShaderValueType::LITERAL_CONST },
|
||||
{.m_shader_type = techset::CommonTechniqueShaderType::PIXEL, .m_value_type = techset::CommonShaderValueType::MATERIAL_SAMPLER},
|
||||
{.m_shader_type = techset::CommonTechniqueShaderType::VERTEX, .m_value_type = techset::CommonShaderValueType::CODE_CONST },
|
||||
{.m_shader_type = techset::CommonTechniqueShaderType::PIXEL, .m_value_type = techset::CommonShaderValueType::CODE_SAMPLER },
|
||||
{.m_shader_type = techset::CommonTechniqueShaderType::PIXEL, .m_value_type = techset::CommonShaderValueType::CODE_CONST },
|
||||
{.m_shader_type = techset::CommonTechniqueShaderType::PIXEL, .m_value_type = techset::CommonShaderValueType::MATERIAL_CONST },
|
||||
{.m_shader_type = techset::CommonTechniqueShaderType::PIXEL, .m_value_type = techset::CommonShaderValueType::LITERAL_CONST },
|
||||
};
|
||||
static_assert(std::extent_v<decltype(commonArgumentTypes)> == MLT_ARG_COUNT);
|
||||
|
||||
static inline techset::CommonCodeSourceInfos commonCodeSourceInfos(commonCodeConstSources,
|
||||
std::extent_v<decltype(commonCodeConstSources)>,
|
||||
commonCodeSamplerSources,
|
||||
std::extent_v<decltype(commonCodeSamplerSources)>,
|
||||
commonArgumentTypes,
|
||||
std::extent_v<decltype(commonArgumentTypes)>);
|
||||
|
||||
inline MaterialTypeInfo g_materialTypeInfo[]{
|
||||
{"", "" },
|
||||
{"m/", "m_" },
|
||||
|
||||
@@ -190,6 +190,11 @@ namespace T6
|
||||
};
|
||||
static_assert(std::extent_v<decltype(streamRoutingDestinations)> == STREAM_DST_COUNT);
|
||||
|
||||
static inline techset::CommonStreamRoutingInfos commonRoutingInfos(streamRoutingSources,
|
||||
std::extent_v<decltype(streamRoutingSources)>,
|
||||
streamRoutingDestinations,
|
||||
std::extent_v<decltype(streamRoutingDestinations)>);
|
||||
|
||||
static inline techset::CommonCodeConstSourceInfo commonCodeConstSources[]{
|
||||
{
|
||||
.value = CONST_SRC_CODE_LIGHT_POSITION,
|
||||
@@ -214,6 +219,7 @@ namespace T6
|
||||
.accessor = "lightSpotFactors",
|
||||
.arrayCount = 0,
|
||||
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
|
||||
.techFlags = TECHNIQUE_FLAG_10,
|
||||
},
|
||||
{
|
||||
.value = CONST_SRC_CODE_LIGHT_ATTENUATION,
|
||||
@@ -544,6 +550,7 @@ namespace T6
|
||||
.accessor = "particleCloudVelWorld",
|
||||
.arrayCount = 0,
|
||||
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
|
||||
.techFlags = TECHNIQUE_FLAG_100,
|
||||
},
|
||||
{
|
||||
.value = CONST_SRC_CODE_DEPTH_FROM_CLIP,
|
||||
@@ -1538,11 +1545,13 @@ namespace T6
|
||||
.value = TEXTURE_SRC_CODE_LIGHTMAP_PRIMARY,
|
||||
.accessor = "lightmapSamplerPrimary",
|
||||
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::CUSTOM,
|
||||
.customSamplerIndex = CUSTOM_SAMPLER_LIGHTMAP_PRIMARY,
|
||||
},
|
||||
{
|
||||
.value = TEXTURE_SRC_CODE_LIGHTMAP_SECONDARY,
|
||||
.accessor = "lightmapSamplerSecondary",
|
||||
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::CUSTOM,
|
||||
.customSamplerIndex = CUSTOM_SAMPLER_LIGHTMAP_SECONDARY,
|
||||
},
|
||||
{
|
||||
.value = TEXTURE_SRC_CODE_SHADOWMAP_SUN,
|
||||
@@ -1563,11 +1572,13 @@ namespace T6
|
||||
.value = TEXTURE_SRC_CODE_RESOLVED_POST_SUN,
|
||||
.accessor = "resolvedPostSun",
|
||||
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
|
||||
.techFlags = TECHNIQUE_FLAG_1,
|
||||
},
|
||||
{
|
||||
.value = TEXTURE_SRC_CODE_RESOLVED_SCENE,
|
||||
.accessor = "resolvedScene",
|
||||
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
|
||||
.techFlags = TECHNIQUE_FLAG_2,
|
||||
},
|
||||
{
|
||||
.value = TEXTURE_SRC_CODE_POST_EFFECT_SRC,
|
||||
@@ -1608,16 +1619,19 @@ namespace T6
|
||||
.value = TEXTURE_SRC_CODE_FLOATZ,
|
||||
.accessor = "floatZSampler",
|
||||
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
|
||||
.techFlags = TECHNIQUE_FLAG_40,
|
||||
},
|
||||
{
|
||||
.value = TEXTURE_SRC_CODE_PROCESSED_FLOATZ,
|
||||
.accessor = "processedFloatZSampler",
|
||||
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
|
||||
.techFlags = TECHNIQUE_FLAG_40,
|
||||
},
|
||||
{
|
||||
.value = TEXTURE_SRC_CODE_RAW_FLOATZ,
|
||||
.accessor = "rawFloatZSampler",
|
||||
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
|
||||
.techFlags = TECHNIQUE_FLAG_40,
|
||||
},
|
||||
{
|
||||
.value = TEXTURE_SRC_CODE_STENCIL,
|
||||
@@ -1648,6 +1662,7 @@ namespace T6
|
||||
.value = TEXTURE_SRC_CODE_REFLECTION_PROBE,
|
||||
.accessor = "reflectionProbeSampler",
|
||||
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::CUSTOM,
|
||||
.customSamplerIndex = CUSTOM_SAMPLER_REFLECTION_PROBE,
|
||||
},
|
||||
{
|
||||
.value = TEXTURE_SRC_CODE_FEATHER_FLOAT_Z,
|
||||
@@ -1791,6 +1806,26 @@ namespace T6
|
||||
},
|
||||
};
|
||||
|
||||
// See MaterialShaderArgumentType
|
||||
static inline techset::CommonShaderArgumentType commonArgumentTypes[]{
|
||||
{.m_shader_type = techset::CommonTechniqueShaderType::VERTEX, .m_value_type = techset::CommonShaderValueType::MATERIAL_CONST },
|
||||
{.m_shader_type = techset::CommonTechniqueShaderType::VERTEX, .m_value_type = techset::CommonShaderValueType::LITERAL_CONST },
|
||||
{.m_shader_type = techset::CommonTechniqueShaderType::PIXEL, .m_value_type = techset::CommonShaderValueType::MATERIAL_SAMPLER},
|
||||
{.m_shader_type = techset::CommonTechniqueShaderType::VERTEX, .m_value_type = techset::CommonShaderValueType::CODE_CONST },
|
||||
{.m_shader_type = techset::CommonTechniqueShaderType::PIXEL, .m_value_type = techset::CommonShaderValueType::CODE_SAMPLER },
|
||||
{.m_shader_type = techset::CommonTechniqueShaderType::PIXEL, .m_value_type = techset::CommonShaderValueType::CODE_CONST },
|
||||
{.m_shader_type = techset::CommonTechniqueShaderType::PIXEL, .m_value_type = techset::CommonShaderValueType::MATERIAL_CONST },
|
||||
{.m_shader_type = techset::CommonTechniqueShaderType::PIXEL, .m_value_type = techset::CommonShaderValueType::LITERAL_CONST },
|
||||
};
|
||||
static_assert(std::extent_v<decltype(commonArgumentTypes)> == MLT_ARG_COUNT);
|
||||
|
||||
static inline techset::CommonCodeSourceInfos commonCodeSourceInfos(commonCodeConstSources,
|
||||
std::extent_v<decltype(commonCodeConstSources)>,
|
||||
commonCodeSamplerSources,
|
||||
std::extent_v<decltype(commonCodeSamplerSources)>,
|
||||
commonArgumentTypes,
|
||||
std::extent_v<decltype(commonArgumentTypes)>);
|
||||
|
||||
static inline MaterialTypeInfo g_materialTypeInfo[]{
|
||||
{"", "" },
|
||||
{"m/", "m_" },
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
#include "CommonTechnique.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
namespace techset
|
||||
{
|
||||
CommonCodeSourceInfos::CommonCodeSourceInfos(const CommonCodeConstSourceInfo* codeConstSourceInfos,
|
||||
const size_t codeConstCount,
|
||||
const CommonCodeSamplerSourceInfo* codeSamplerSourceInfos,
|
||||
const size_t codeSamplerCount)
|
||||
const size_t codeSamplerCount,
|
||||
const CommonShaderArgumentType* argumentTypes,
|
||||
const size_t argumentTypeCount)
|
||||
: m_code_const_source_infos(codeConstCount),
|
||||
m_code_sampler_source_infos(codeSamplerCount)
|
||||
m_code_sampler_source_infos(codeSamplerCount),
|
||||
m_argument_types(argumentTypeCount)
|
||||
{
|
||||
std::copy(codeConstSourceInfos, &codeConstSourceInfos[codeConstCount], m_code_const_source_infos.data());
|
||||
std::ranges::sort(m_code_const_source_infos,
|
||||
@@ -24,6 +28,18 @@ namespace techset
|
||||
{
|
||||
return a.value < b.value;
|
||||
});
|
||||
|
||||
std::copy(argumentTypes, &argumentTypes[argumentTypeCount], m_argument_types.data());
|
||||
|
||||
for (const auto& codeConstInfo : m_code_const_source_infos)
|
||||
{
|
||||
m_code_const_lookup.emplace(codeConstInfo.accessor, codeConstInfo.value);
|
||||
}
|
||||
|
||||
for (const auto& codeSamplerInfo : m_code_sampler_source_infos)
|
||||
{
|
||||
m_code_sampler_lookup.emplace(codeSamplerInfo.accessor, codeSamplerInfo.value);
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<CommonCodeConstSourceInfo> CommonCodeSourceInfos::GetInfoForCodeConstSource(const CommonCodeConstSource codeConstSource) const
|
||||
@@ -55,6 +71,33 @@ namespace techset
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<CommonCodeConstSource> CommonCodeSourceInfos::GetCodeConstSourceForAccessor(const std::string& accessor) const
|
||||
{
|
||||
const auto foundEntry = m_code_const_lookup.find(accessor);
|
||||
if (foundEntry == m_code_const_lookup.end())
|
||||
return std::nullopt;
|
||||
|
||||
return foundEntry->second;
|
||||
}
|
||||
|
||||
std::optional<CommonCodeSamplerSource> CommonCodeSourceInfos::GetCodeSamplerSourceForAccessor(const std::string& accessor) const
|
||||
{
|
||||
const auto foundEntry = m_code_sampler_lookup.find(accessor);
|
||||
if (foundEntry == m_code_sampler_lookup.end())
|
||||
return std::nullopt;
|
||||
|
||||
return foundEntry->second;
|
||||
}
|
||||
|
||||
std::optional<size_t> CommonCodeSourceInfos::GetArgumentTypeNumericValue(const CommonShaderArgumentType& argumentType) const
|
||||
{
|
||||
const auto foundValue = std::ranges::find(m_argument_types, argumentType);
|
||||
if (foundValue == m_argument_types.end())
|
||||
return std::nullopt;
|
||||
|
||||
return static_cast<size_t>(foundValue - m_argument_types.begin());
|
||||
}
|
||||
|
||||
CommonStreamRoutingInfos::CommonStreamRoutingInfos(const CommonStreamRoutingSourceInfo* sourceInfos,
|
||||
const size_t sourceCount,
|
||||
const CommonStreamRoutingDestinationInfo* destinationNames,
|
||||
@@ -64,6 +107,18 @@ namespace techset
|
||||
{
|
||||
std::copy(sourceInfos, &sourceInfos[sourceCount], m_sources.data());
|
||||
std::copy(destinationNames, &destinationNames[destinationCount], m_destinations.data());
|
||||
|
||||
for (size_t i = 0; i < sourceCount; i++)
|
||||
{
|
||||
m_source_name_lookup[sourceInfos[i].name] = static_cast<CommonStreamSource>(i);
|
||||
m_source_abbreviation_lookup[sourceInfos[i].abbreviation] = static_cast<CommonStreamSource>(i);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < destinationCount; i++)
|
||||
{
|
||||
m_destination_name_lookup[destinationNames[i].name] = static_cast<CommonStreamDestination>(i);
|
||||
m_destination_abbreviation_lookup[destinationNames[i].abbreviation] = static_cast<CommonStreamDestination>(i);
|
||||
}
|
||||
}
|
||||
|
||||
const char* CommonStreamRoutingInfos::GetSourceName(const CommonStreamSource source) const
|
||||
@@ -105,4 +160,144 @@ namespace techset
|
||||
|
||||
return m_destinations[destination].abbreviation;
|
||||
}
|
||||
|
||||
std::optional<CommonStreamSource> CommonStreamRoutingInfos::GetSourceByName(const std::string& name) const
|
||||
{
|
||||
const auto foundSource = m_source_name_lookup.find(name);
|
||||
if (foundSource != m_source_name_lookup.end())
|
||||
return foundSource->second;
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<CommonStreamSource> CommonStreamRoutingInfos::GetSourceByAbbreviation(const std::string& abbreviation) const
|
||||
{
|
||||
const auto foundSource = m_source_abbreviation_lookup.find(abbreviation);
|
||||
if (foundSource != m_source_abbreviation_lookup.end())
|
||||
return foundSource->second;
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<CommonStreamDestination> CommonStreamRoutingInfos::GetDestinationByName(const std::string& name) const
|
||||
{
|
||||
const auto foundDestination = m_destination_name_lookup.find(name);
|
||||
if (foundDestination != m_destination_name_lookup.end())
|
||||
return foundDestination->second;
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<CommonStreamDestination> CommonStreamRoutingInfos::GetDestinationByAbbreviation(const std::string& abbreviation) const
|
||||
{
|
||||
const auto foundDestination = m_destination_abbreviation_lookup.find(abbreviation);
|
||||
if (foundDestination != m_destination_abbreviation_lookup.end())
|
||||
return foundDestination->second;
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
CommonShaderArg::CommonShaderArg(const CommonShaderArgumentType type, const CommonShaderArgDestination& destination, const CommonShaderArgValue& value)
|
||||
: m_type(type),
|
||||
m_destination(destination),
|
||||
m_value(value)
|
||||
{
|
||||
}
|
||||
|
||||
CommonCodeSourceUpdateFrequency CommonShaderArg::GetFrequency(const CommonCodeSourceInfos& infos) const
|
||||
{
|
||||
switch (m_type.m_value_type)
|
||||
{
|
||||
case CommonShaderValueType::CODE_CONST:
|
||||
{
|
||||
const auto info = infos.GetInfoForCodeConstSource(m_value.code_const_source);
|
||||
assert(info);
|
||||
return info->updateFrequency;
|
||||
}
|
||||
|
||||
case CommonShaderValueType::CODE_SAMPLER:
|
||||
{
|
||||
const auto info = infos.GetInfoForCodeSamplerSource(m_value.code_sampler_source);
|
||||
assert(info);
|
||||
return info->updateFrequency;
|
||||
}
|
||||
|
||||
case CommonShaderValueType::MATERIAL_CONST:
|
||||
case CommonShaderValueType::LITERAL_CONST:
|
||||
case CommonShaderValueType::MATERIAL_SAMPLER:
|
||||
return CommonCodeSourceUpdateFrequency::RARELY;
|
||||
|
||||
default:
|
||||
assert(false);
|
||||
return CommonCodeSourceUpdateFrequency::RARELY;
|
||||
}
|
||||
}
|
||||
|
||||
CommonStreamRouting::CommonStreamRouting(const CommonStreamSource source, const CommonStreamDestination destination)
|
||||
: m_source(source),
|
||||
m_destination(destination)
|
||||
{
|
||||
}
|
||||
|
||||
CommonVertexDeclaration::CommonVertexDeclaration(std::vector<CommonStreamRouting> routing)
|
||||
: m_routing(std::move(routing))
|
||||
{
|
||||
}
|
||||
|
||||
void CommonVertexDeclaration::SortRoutingEntries()
|
||||
{
|
||||
std::ranges::sort(m_routing,
|
||||
[](const CommonStreamRouting& r1, const CommonStreamRouting& r2)
|
||||
{
|
||||
return r1.m_source < r2.m_source;
|
||||
});
|
||||
}
|
||||
|
||||
CommonTechniqueShader::CommonTechniqueShader()
|
||||
: m_type(CommonTechniqueShaderType::VERTEX)
|
||||
{
|
||||
}
|
||||
|
||||
CommonTechniqueShader::CommonTechniqueShader(const CommonTechniqueShaderType type, std::string name)
|
||||
: m_type(type),
|
||||
m_name(std::move(name))
|
||||
{
|
||||
}
|
||||
|
||||
CommonPass::CommonPass(const uint32_t samplerFlags,
|
||||
std::string stateMap,
|
||||
CommonTechniqueShader vertexShader,
|
||||
CommonTechniqueShader pixelShader,
|
||||
CommonVertexDeclaration vertexDeclaration)
|
||||
: m_sampler_flags(samplerFlags),
|
||||
m_state_map(std::move(stateMap)),
|
||||
m_vertex_shader(std::move(vertexShader)),
|
||||
m_pixel_shader(std::move(pixelShader)),
|
||||
m_vertex_declaration(std::move(vertexDeclaration))
|
||||
{
|
||||
}
|
||||
|
||||
CommonPass::FrequencyCounts_t CommonPass::GetFrequencyCounts(const CommonCodeSourceInfos& infos) const
|
||||
{
|
||||
FrequencyCounts_t result;
|
||||
for (auto& count : result)
|
||||
count = 0;
|
||||
|
||||
for (auto& arg : m_args)
|
||||
result[std::to_underlying(arg.GetFrequency(infos))]++;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
CommonTechnique::CommonTechnique(std::string name)
|
||||
: m_name(std::move(name)),
|
||||
m_flags(0)
|
||||
{
|
||||
}
|
||||
|
||||
CommonTechnique::CommonTechnique(std::string name, const uint64_t flags)
|
||||
: m_name(std::move(name)),
|
||||
m_flags(flags)
|
||||
{
|
||||
}
|
||||
} // namespace techset
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace techset
|
||||
@@ -27,12 +28,35 @@ namespace techset
|
||||
const char* abbreviation;
|
||||
};
|
||||
|
||||
enum class CommonTechniqueShaderType : std::uint8_t
|
||||
{
|
||||
VERTEX,
|
||||
PIXEL
|
||||
};
|
||||
|
||||
enum class CommonShaderValueType : std::uint8_t
|
||||
{
|
||||
// Value is set to a float4 value in the pass
|
||||
LITERAL_CONST,
|
||||
// Value is set to a float4 value in the material
|
||||
MATERIAL_CONST,
|
||||
// Value is set to a float4 value calculated in code
|
||||
CODE_CONST,
|
||||
// Value is set to a sampler from the material
|
||||
MATERIAL_SAMPLER,
|
||||
// Value is set to a sampler generated in code
|
||||
CODE_SAMPLER
|
||||
};
|
||||
|
||||
enum class CommonCodeSourceUpdateFrequency : std::uint8_t
|
||||
{
|
||||
PER_PRIM,
|
||||
PER_OBJECT,
|
||||
RARELY,
|
||||
CUSTOM,
|
||||
IGNORE,
|
||||
|
||||
COUNT
|
||||
};
|
||||
|
||||
struct CommonCodeConstSourceInfo
|
||||
@@ -41,6 +65,7 @@ namespace techset
|
||||
const char* accessor;
|
||||
std::uint8_t arrayCount;
|
||||
CommonCodeSourceUpdateFrequency updateFrequency;
|
||||
std::optional<unsigned> techFlags;
|
||||
};
|
||||
|
||||
struct CommonCodeSamplerSourceInfo
|
||||
@@ -48,6 +73,24 @@ namespace techset
|
||||
CommonCodeSamplerSource value;
|
||||
const char* accessor;
|
||||
CommonCodeSourceUpdateFrequency updateFrequency;
|
||||
std::optional<unsigned> techFlags;
|
||||
std::optional<unsigned> customSamplerIndex;
|
||||
};
|
||||
|
||||
struct CommonShaderArgumentType
|
||||
{
|
||||
friend bool operator==(const CommonShaderArgumentType& lhs, const CommonShaderArgumentType& rhs)
|
||||
{
|
||||
return lhs.m_shader_type == rhs.m_shader_type && lhs.m_value_type == rhs.m_value_type;
|
||||
}
|
||||
|
||||
friend bool operator!=(const CommonShaderArgumentType& lhs, const CommonShaderArgumentType& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
CommonTechniqueShaderType m_shader_type;
|
||||
CommonShaderValueType m_value_type;
|
||||
};
|
||||
|
||||
class CommonCodeSourceInfos
|
||||
@@ -56,14 +99,26 @@ namespace techset
|
||||
CommonCodeSourceInfos(const CommonCodeConstSourceInfo* codeConstSourceInfos,
|
||||
size_t codeConstCount,
|
||||
const CommonCodeSamplerSourceInfo* codeSamplerSourceInfos,
|
||||
size_t codeSamplerCount);
|
||||
size_t codeSamplerCount,
|
||||
const CommonShaderArgumentType* argumentTypes,
|
||||
size_t argumentTypeCount);
|
||||
|
||||
[[nodiscard]] std::optional<CommonCodeConstSourceInfo> GetInfoForCodeConstSource(CommonCodeConstSource codeConstSource) const;
|
||||
[[nodiscard]] std::optional<CommonCodeSamplerSourceInfo> GetInfoForCodeSamplerSource(CommonCodeSamplerSource codeSamplerSource) const;
|
||||
|
||||
[[nodiscard]] std::optional<CommonCodeConstSource> GetCodeConstSourceForAccessor(const std::string& accessor) const;
|
||||
[[nodiscard]] std::optional<CommonCodeSamplerSource> GetCodeSamplerSourceForAccessor(const std::string& accessor) const;
|
||||
|
||||
[[nodiscard]] std::optional<size_t> GetArgumentTypeNumericValue(const CommonShaderArgumentType& argumentType) const;
|
||||
|
||||
private:
|
||||
std::vector<CommonCodeConstSourceInfo> m_code_const_source_infos;
|
||||
std::vector<CommonCodeSamplerSourceInfo> m_code_sampler_source_infos;
|
||||
|
||||
std::unordered_map<std::string, CommonCodeConstSource> m_code_const_lookup;
|
||||
std::unordered_map<std::string, CommonCodeSamplerSource> m_code_sampler_lookup;
|
||||
|
||||
std::vector<CommonShaderArgumentType> m_argument_types;
|
||||
};
|
||||
|
||||
class CommonStreamRoutingInfos
|
||||
@@ -79,10 +134,18 @@ namespace techset
|
||||
[[nodiscard]] bool IsSourceOptional(CommonStreamSource source) const;
|
||||
[[nodiscard]] const char* GetDestinationName(CommonStreamDestination destination) const;
|
||||
[[nodiscard]] const char* GetDestinationAbbreviation(CommonStreamDestination destination) const;
|
||||
[[nodiscard]] std::optional<CommonStreamSource> GetSourceByName(const std::string& name) const;
|
||||
[[nodiscard]] std::optional<CommonStreamSource> GetSourceByAbbreviation(const std::string& abbreviation) const;
|
||||
[[nodiscard]] std::optional<CommonStreamDestination> GetDestinationByName(const std::string& name) const;
|
||||
[[nodiscard]] std::optional<CommonStreamDestination> GetDestinationByAbbreviation(const std::string& abbreviation) const;
|
||||
|
||||
private:
|
||||
std::vector<CommonStreamRoutingSourceInfo> m_sources;
|
||||
std::vector<CommonStreamRoutingDestinationInfo> m_destinations;
|
||||
std::unordered_map<std::string, CommonStreamSource> m_source_name_lookup;
|
||||
std::unordered_map<std::string, CommonStreamDestination> m_destination_name_lookup;
|
||||
std::unordered_map<std::string, CommonStreamSource> m_source_abbreviation_lookup;
|
||||
std::unordered_map<std::string, CommonStreamDestination> m_destination_abbreviation_lookup;
|
||||
};
|
||||
|
||||
union CommonShaderArgValue
|
||||
@@ -115,31 +178,26 @@ namespace techset
|
||||
CommonShaderArgDestinationDx11 dx11;
|
||||
};
|
||||
|
||||
enum class CommonShaderArgType : std::uint8_t
|
||||
{
|
||||
// Value is set to a float4 value in the pass
|
||||
LITERAL_CONST,
|
||||
// Value is set to a float4 value in the material
|
||||
MATERIAL_CONST,
|
||||
// Value is set to a float4 value calculated in code
|
||||
CODE_CONST,
|
||||
// Value is set to a sampler from the material
|
||||
MATERIAL_SAMPLER,
|
||||
// Value is set to a sampler generated in code
|
||||
CODE_SAMPLER
|
||||
};
|
||||
|
||||
class CommonShaderArg
|
||||
{
|
||||
public:
|
||||
CommonShaderArgType m_type;
|
||||
CommonShaderArg() = default;
|
||||
CommonShaderArg(CommonShaderArgumentType type, const CommonShaderArgDestination& destination, const CommonShaderArgValue& value);
|
||||
|
||||
[[nodiscard]] CommonCodeSourceUpdateFrequency GetFrequency(const CommonCodeSourceInfos& infos) const;
|
||||
|
||||
CommonShaderArgumentType m_type;
|
||||
CommonShaderArgDestination m_destination;
|
||||
CommonShaderArgValue m_value;
|
||||
std::optional<CommonCodeSourceUpdateFrequency> m_bin;
|
||||
};
|
||||
|
||||
class CommonStreamRouting
|
||||
{
|
||||
public:
|
||||
CommonStreamRouting() = default;
|
||||
CommonStreamRouting(CommonStreamSource source, CommonStreamDestination destination);
|
||||
|
||||
CommonStreamSource m_source;
|
||||
CommonStreamDestination m_destination;
|
||||
};
|
||||
@@ -147,39 +205,69 @@ namespace techset
|
||||
class CommonVertexDeclaration
|
||||
{
|
||||
public:
|
||||
CommonVertexDeclaration() = default;
|
||||
explicit CommonVertexDeclaration(std::vector<CommonStreamRouting> routing);
|
||||
|
||||
void SortRoutingEntries();
|
||||
|
||||
std::vector<CommonStreamRouting> m_routing;
|
||||
};
|
||||
|
||||
class CommonTechniqueShaderBin
|
||||
{
|
||||
public:
|
||||
const void* m_shader_bin;
|
||||
size_t m_shader_bin_size;
|
||||
};
|
||||
|
||||
class CommonTechniqueShader
|
||||
{
|
||||
public:
|
||||
CommonTechniqueShader();
|
||||
CommonTechniqueShader(CommonTechniqueShaderType type, std::string name);
|
||||
|
||||
CommonTechniqueShaderType m_type;
|
||||
std::string m_name;
|
||||
const void* m_shader_bin;
|
||||
size_t m_shader_bin_size;
|
||||
std::optional<CommonTechniqueShaderBin> m_bin;
|
||||
};
|
||||
|
||||
class CommonPass
|
||||
{
|
||||
public:
|
||||
using FrequencyCounts_t = std::array<size_t, std::to_underlying(CommonCodeSourceUpdateFrequency::COUNT)>;
|
||||
|
||||
CommonPass() = default;
|
||||
CommonPass(uint32_t samplerFlags,
|
||||
std::string stateMap,
|
||||
CommonTechniqueShader vertexShader,
|
||||
CommonTechniqueShader pixelShader,
|
||||
CommonVertexDeclaration vertexDeclaration);
|
||||
|
||||
[[nodiscard]] FrequencyCounts_t GetFrequencyCounts(const CommonCodeSourceInfos& infos) const;
|
||||
|
||||
uint32_t m_sampler_flags;
|
||||
std::string m_state_map;
|
||||
CommonTechniqueShader m_vertex_shader;
|
||||
CommonTechniqueShader m_pixel_shader;
|
||||
CommonVertexDeclaration m_vertex_declaration;
|
||||
std::vector<CommonShaderArg> m_args;
|
||||
};
|
||||
|
||||
class CommonTechnique
|
||||
{
|
||||
public:
|
||||
CommonTechnique() = default;
|
||||
explicit CommonTechnique(std::string name);
|
||||
CommonTechnique(std::string name, uint64_t flags);
|
||||
|
||||
std::string m_name;
|
||||
uint64_t m_flags;
|
||||
std::vector<CommonPass> m_passes;
|
||||
};
|
||||
|
||||
enum class DxVersion : std::uint8_t
|
||||
{
|
||||
DX9,
|
||||
DX11
|
||||
};
|
||||
|
||||
class CommonPass
|
||||
{
|
||||
public:
|
||||
uint32_t m_sampler_flags;
|
||||
DxVersion m_dx_version;
|
||||
CommonTechniqueShader m_vertex_shader;
|
||||
CommonTechniqueShader m_pixel_shader;
|
||||
CommonVertexDeclaration m_vertex_declaration;
|
||||
};
|
||||
|
||||
class CommonTechnique
|
||||
{
|
||||
public:
|
||||
std::string m_name;
|
||||
uint64_t m_flags;
|
||||
std::vector<CommonPass> m_passes;
|
||||
};
|
||||
} // namespace techset
|
||||
|
||||
67
src/ObjCommon/Techset/CommonVertexDeclCreator.cpp
Normal file
67
src/ObjCommon/Techset/CommonVertexDeclCreator.cpp
Normal file
@@ -0,0 +1,67 @@
|
||||
#include "CommonVertexDeclCreator.h"
|
||||
|
||||
#include "Utils/Logging/Log.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace
|
||||
{
|
||||
bool NextAbbreviation(const std::string& assetName, std::string& abbreviation, size_t& offset)
|
||||
{
|
||||
if (offset >= assetName.size())
|
||||
return false;
|
||||
|
||||
if (offset + 1 < assetName.size() && isdigit(assetName[offset + 1]))
|
||||
{
|
||||
abbreviation = std::string(assetName, offset, 2);
|
||||
offset += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
abbreviation = std::string(assetName, offset, 1);
|
||||
offset += 1;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace techset
|
||||
{
|
||||
std::optional<CommonVertexDeclaration> CreateVertexDeclFromName(const std::string& name, const CommonStreamRoutingInfos& routingInfos)
|
||||
{
|
||||
CommonVertexDeclaration result;
|
||||
size_t currentOffset = 0u;
|
||||
|
||||
std::string sourceAbbreviation;
|
||||
while (NextAbbreviation(name, sourceAbbreviation, currentOffset))
|
||||
{
|
||||
std::string destinationAbbreviation;
|
||||
if (!NextAbbreviation(name, destinationAbbreviation, currentOffset))
|
||||
{
|
||||
con::error("Failed to detect vertex decl destination abbreviation: {}", name);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
const auto maybeSource = routingInfos.GetSourceByAbbreviation(sourceAbbreviation);
|
||||
if (!maybeSource)
|
||||
{
|
||||
con::error("Unknown vertex decl source abbreviation: {}", sourceAbbreviation);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
const auto maybeDestination = routingInfos.GetDestinationByAbbreviation(sourceAbbreviation);
|
||||
if (!maybeDestination)
|
||||
{
|
||||
con::error("Unknown vertex decl destination abbreviation: {}", destinationAbbreviation);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
result.m_routing.emplace_back(*maybeSource, *maybeDestination);
|
||||
}
|
||||
|
||||
result.SortRoutingEntries();
|
||||
|
||||
return result;
|
||||
}
|
||||
} // namespace techset
|
||||
11
src/ObjCommon/Techset/CommonVertexDeclCreator.h
Normal file
11
src/ObjCommon/Techset/CommonVertexDeclCreator.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "CommonTechnique.h"
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
namespace techset
|
||||
{
|
||||
std::optional<CommonVertexDeclaration> CreateVertexDeclFromName(const std::string& name, const CommonStreamRoutingInfos& routingInfos);
|
||||
}
|
||||
@@ -9,11 +9,8 @@
|
||||
#include "Gdt/AbstractGdtEntryReader.h"
|
||||
#include "Gdt/IGdtQueryable.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
#include "Techset/CommonTechsetCache.h"
|
||||
#include "Techset/StateMap/StateMapFromTechniqueExtractor.h"
|
||||
#include "Techset/StateMap/StateMapHandler.h"
|
||||
#include "Techset/TechniqueFileReader.h"
|
||||
#include "Techset/TechniqueStateMapCache.h"
|
||||
#include "Techset/StateMap/TechniqueStateMapCache.h"
|
||||
#include "Techset/TechsetCommon.h"
|
||||
#include "Utils/Logging/Log.h"
|
||||
|
||||
@@ -28,6 +25,7 @@ using namespace IW4;
|
||||
|
||||
namespace
|
||||
{
|
||||
/*
|
||||
class SkipMaterialException final : public std::exception
|
||||
{
|
||||
};
|
||||
@@ -1328,6 +1326,7 @@ namespace
|
||||
|
||||
std::unique_ptr<techset::ICreatorIW4> m_techset_creator;
|
||||
};
|
||||
*/
|
||||
|
||||
class MaterialLoader final : public AssetCreator<AssetMaterial>
|
||||
{
|
||||
@@ -1341,6 +1340,8 @@ namespace
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
|
||||
{
|
||||
return AssetCreationResult::NoAction();
|
||||
/*
|
||||
const auto* entry = m_gdt.GetGdtEntryByGdfAndName(ObjConstants::GDF_FILENAME_MATERIAL, assetName);
|
||||
if (!entry)
|
||||
return AssetCreationResult::NoAction();
|
||||
@@ -1367,6 +1368,7 @@ namespace
|
||||
}
|
||||
|
||||
return AssetCreationResult::Failure();
|
||||
*/
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -6,11 +6,9 @@
|
||||
#include "Game/IW4/Techset/TechsetConstantsIW4.h"
|
||||
#include "Shader/D3D9ShaderAnalyser.h"
|
||||
#include "Shader/ShaderCommon.h"
|
||||
#include "Techset/CommonTechsetCache.h"
|
||||
#include "Techset/CommonTechsetLoader.h"
|
||||
#include "Techset/StateMap/StateMapReader.h"
|
||||
#include "Techset/TechniqueFileReader.h"
|
||||
#include "Techset/TechniqueStateMapCache.h"
|
||||
#include "Techset/StateMap/TechniqueStateMapCache.h"
|
||||
#include "Techset/TechsetCommon.h"
|
||||
#include "Utils/Alignment.h"
|
||||
#include "Utils/Logging/Log.h"
|
||||
@@ -32,6 +30,7 @@ using namespace std::string_literals;
|
||||
|
||||
namespace
|
||||
{
|
||||
/*
|
||||
class LoadedTechnique
|
||||
{
|
||||
public:
|
||||
@@ -407,7 +406,7 @@ namespace
|
||||
|
||||
if (arg1.m_arg.type == MTL_ARG_MATERIAL_VERTEX_CONST || arg1.m_arg.type == MTL_ARG_MATERIAL_PIXEL_CONST
|
||||
|| arg1.m_arg.type == MTL_ARG_MATERIAL_PIXEL_SAMPLER)
|
||||
return arg1.m_arg.u.codeSampler < arg2.m_arg.u.codeSampler;
|
||||
return arg1.m_arg.u.nameHash < arg2.m_arg.u.nameHash;
|
||||
|
||||
return arg1.m_arg.dest < arg2.m_arg.dest;
|
||||
});
|
||||
@@ -1263,7 +1262,7 @@ namespace
|
||||
TechniqueZoneLoadingState& m_zone_state;
|
||||
techset::ICreatorIW4* m_techset_creator;
|
||||
};
|
||||
|
||||
*/
|
||||
class TechsetLoader final : public techset::ICreatorIW4
|
||||
{
|
||||
public:
|
||||
@@ -1275,15 +1274,18 @@ namespace
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
|
||||
{
|
||||
return AssetCreationResult::NoAction();
|
||||
/*
|
||||
bool failure = false;
|
||||
const auto* techsetDefinition = LoadTechsetDefinition(assetName, context, failure);
|
||||
if (!techsetDefinition)
|
||||
return failure ? AssetCreationResult::Failure() : AssetCreationResult::NoAction();
|
||||
|
||||
return CreateTechsetFromDefinition(assetName, *techsetDefinition, context);
|
||||
*/
|
||||
}
|
||||
|
||||
private:
|
||||
/*
|
||||
AssetCreationResult CreateTechsetFromDefinition(const std::string& assetName, const CommonTechset& definition, AssetCreationContext& context)
|
||||
{
|
||||
auto* techset = m_memory.Alloc<MaterialTechniqueSet>();
|
||||
@@ -1311,9 +1313,11 @@ namespace
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
||||
}
|
||||
*/
|
||||
|
||||
CommonTechset* LoadTechsetDefinition(const std::string& assetName, AssetCreationContext& context, bool& failure) override
|
||||
{
|
||||
/*
|
||||
failure = false;
|
||||
auto& definitionCache = context.GetZoneAssetCreationState<CommonTechsetCache>();
|
||||
auto* cachedTechsetDefinition = definitionCache.GetCachedTechsetDefinition(assetName);
|
||||
@@ -1334,10 +1338,13 @@ namespace
|
||||
definitionCache.AddCommonTechsetToCache(assetName, std::move(techsetDefinition));
|
||||
|
||||
return techsetDefinitionPtr;
|
||||
*/
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const state_map::StateMapDefinition* LoadStateMapDefinition(const std::string& stateMapName, AssetCreationContext& context) override
|
||||
{
|
||||
/*
|
||||
auto& stateMapCache = context.GetZoneAssetCreationState<TechniqueStateMapCache>();
|
||||
auto* cachedStateMap = stateMapCache.GetCachedStateMap(stateMapName);
|
||||
if (cachedStateMap)
|
||||
@@ -1358,6 +1365,8 @@ namespace
|
||||
stateMapCache.AddStateMapToCache(std::move(stateMapDefinition));
|
||||
|
||||
return stateMapDefinitionPtr;
|
||||
*/
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
#include "Image/ImageIPakPostProcessor.h"
|
||||
#include "Image/ImageIwdPostProcessor.h"
|
||||
#include "KeyValuePairs/KeyValuePairsCompilerT6.h"
|
||||
#include "Techset/TechniqueCompilerT6.h"
|
||||
#include "Techset/TechsetCompilerT6.h"
|
||||
#include "Techset/VertexDeclCompilerT6.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -22,6 +24,9 @@ namespace
|
||||
|
||||
collection.AddAssetCreator(key_value_pairs::CreateCompilerT6(memory, zone, zoneDefinition.m_zone_definition, zoneStates));
|
||||
collection.AddAssetCreator(techset::CreateCompilerT6(memory, searchPath));
|
||||
|
||||
collection.AddSubAssetCreator(techset::CreateTechniqueCompilerT6(memory, searchPath));
|
||||
collection.AddSubAssetCreator(techset::CreateVertexDeclCompilerT6(memory));
|
||||
}
|
||||
|
||||
void ConfigurePostProcessors(AssetCreatorCollection& collection,
|
||||
|
||||
223
src/ObjCompiling/Game/T6/Techset/TechniqueCompilerT6.cpp
Normal file
223
src/ObjCompiling/Game/T6/Techset/TechniqueCompilerT6.cpp
Normal file
@@ -0,0 +1,223 @@
|
||||
#include "TechniqueCompilerT6.h"
|
||||
|
||||
#include "Game/T6/T6.h"
|
||||
#include "Game/T6/Techset/TechsetConstantsT6.h"
|
||||
#include "Techset/CommonShaderArgCreator.h"
|
||||
#include "Techset/CommonTechniqueLoader.h"
|
||||
#include "Utils/StringUtils.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
|
||||
using namespace T6;
|
||||
|
||||
namespace
|
||||
{
|
||||
void UpdateTechniqueFlags(MaterialTechnique& technique, const techset::CommonTechnique& commonTechnique)
|
||||
{
|
||||
std::string lowerTechniqueName(commonTechnique.m_name);
|
||||
utils::MakeStringLowerCase(lowerTechniqueName);
|
||||
|
||||
// Not a particularly cool way to do this but...
|
||||
// the game actually does this :shrug:
|
||||
if (lowerTechniqueName == "zprepass" || lowerTechniqueName.starts_with("pimp_technique_zprepass_")
|
||||
|| lowerTechniqueName.starts_with("pimp_technique_layer_zprepass_") || lowerTechniqueName.starts_with("pimp_technique_buildshadowmap_"))
|
||||
{
|
||||
technique.flags |= TECHNIQUE_FLAG_4;
|
||||
}
|
||||
}
|
||||
|
||||
void ConvertMaterialArgs(MaterialPass& pass, const techset::CommonPass& commonPass, MemoryManager& memory)
|
||||
{
|
||||
pass.args = memory.Alloc<MaterialShaderArgument>(commonPass.m_args.size());
|
||||
|
||||
size_t perObjArgCount = 0u;
|
||||
size_t perPrimArgCount = 0u;
|
||||
size_t stableArgCount = 0u;
|
||||
size_t argIndex = 0u;
|
||||
|
||||
const auto frequencyCount = commonPass.GetFrequencyCounts(commonCodeSourceInfos);
|
||||
|
||||
for (const auto& arg : commonPass.m_args)
|
||||
{
|
||||
UpdateTechniqueFlagsForArgument(technique.flags, arg);
|
||||
switch (arg.m_update_frequency)
|
||||
{
|
||||
case MTL_UPDATE_PER_PRIM:
|
||||
perPrimArgCount++;
|
||||
break;
|
||||
case MTL_UPDATE_PER_OBJECT:
|
||||
perObjArgCount++;
|
||||
break;
|
||||
case MTL_UPDATE_RARELY:
|
||||
stableArgCount++;
|
||||
break;
|
||||
case MTL_UPDATE_CUSTOM:
|
||||
{
|
||||
assert(arg.m_arg.type == MTL_ARG_CODE_PIXEL_SAMPLER);
|
||||
if (arg.m_arg.type == MTL_ARG_CODE_PIXEL_SAMPLER)
|
||||
{
|
||||
const auto customSampler = std::ranges::find(g_customSamplerSrc, arg.m_arg.u.codeSampler);
|
||||
assert(customSampler != std::end(g_customSamplerSrc));
|
||||
if (customSampler != std::end(g_customSamplerSrc))
|
||||
{
|
||||
const auto customSamplerIndex = customSampler - std::begin(g_customSamplerSrc);
|
||||
out.customSamplerFlags |= 1 << customSamplerIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
continue;
|
||||
default:
|
||||
assert(false);
|
||||
continue;
|
||||
}
|
||||
|
||||
out.args[argIndex++] = arg.m_arg;
|
||||
}
|
||||
|
||||
pass.perObjArgCount = static_cast<unsigned char>(frequencyCount[std::to_underlying(techset::CommonCodeSourceUpdateFrequency::PER_OBJECT)]);
|
||||
pass.perPrimArgCount = static_cast<unsigned char>(frequencyCount[std::to_underlying(techset::CommonCodeSourceUpdateFrequency::PER_PRIM)]);
|
||||
pass.stableArgCount = static_cast<unsigned char>(frequencyCount[std::to_underlying(techset::CommonCodeSourceUpdateFrequency::RARELY)]);
|
||||
}
|
||||
|
||||
void ConvertVertexDecl(MaterialPass& pass, const techset::CommonVertexDeclaration& commonDecl, AssetCreationContext& context)
|
||||
{
|
||||
std::ostringstream nameStream;
|
||||
for (const auto& entry : commonDecl.m_routing)
|
||||
{
|
||||
nameStream << commonRoutingInfos.GetSourceAbbreviation(entry.m_source);
|
||||
nameStream << commonRoutingInfos.GetDestinationAbbreviation(entry.m_destination);
|
||||
}
|
||||
|
||||
const std::string declName(nameStream.str());
|
||||
auto* vertexDeclAsset = context.LoadSubAsset<SubAssetVertexDecl>(declName);
|
||||
assert(vertexDeclAsset);
|
||||
pass.vertexDecl = vertexDeclAsset ? vertexDeclAsset->Asset() : nullptr;
|
||||
}
|
||||
|
||||
void ConvertMaterialPass(MaterialPass& pass, const techset::CommonPass& commonPass, AssetCreationContext& context, MemoryManager& memory)
|
||||
{
|
||||
ConvertVertexDecl(pass, commonPass.m_vertex_declaration, context);
|
||||
|
||||
if (!commonPass.m_vertex_shader.m_name.empty())
|
||||
{
|
||||
auto* vertexShaderAsset = context.LoadSubAsset<SubAssetVertexShader>(commonPass.m_vertex_shader.m_name);
|
||||
assert(vertexShaderAsset);
|
||||
pass.vertexShader = vertexShaderAsset ? vertexShaderAsset->Asset() : nullptr;
|
||||
}
|
||||
|
||||
if (!commonPass.m_pixel_shader.m_name.empty())
|
||||
{
|
||||
auto* pixelShaderAsset = context.LoadSubAsset<SubAssetPixelShader>(commonPass.m_pixel_shader.m_name);
|
||||
assert(pixelShaderAsset);
|
||||
pass.pixelShader = pixelShaderAsset ? pixelShaderAsset->Asset() : nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
MaterialTechnique* ConvertTechnique(const techset::CommonTechnique& commonTechnique, AssetCreationContext& context, MemoryManager& memory)
|
||||
{
|
||||
const auto additionalPassCount = std::max(commonTechnique.m_passes.size(), 1u) - 1u;
|
||||
auto* technique = static_cast<MaterialTechnique*>(memory.AllocRaw(sizeof(MaterialTechnique) + additionalPassCount * sizeof(MaterialPass)));
|
||||
|
||||
const auto passCount = static_cast<decltype(MaterialTechnique::passCount)>(commonTechnique.m_passes.size());
|
||||
|
||||
technique->name = memory.Dup(commonTechnique.m_name.c_str());
|
||||
|
||||
// Take common flags and apply further logic
|
||||
technique->flags = static_cast<decltype(MaterialTechnique::flags)>(commonTechnique.m_flags);
|
||||
UpdateTechniqueFlags(*technique, commonTechnique);
|
||||
|
||||
technique->passCount = passCount;
|
||||
|
||||
for (auto passIndex = 0u; passIndex < passCount; passIndex++)
|
||||
ConvertMaterialPass(technique->passArray[passIndex], commonTechnique.m_passes[passIndex], context, memory);
|
||||
|
||||
return technique;
|
||||
}
|
||||
|
||||
class TechniqueShaderLoaderT6 final : public techset::ITechniqueShaderLoader
|
||||
{
|
||||
public:
|
||||
explicit TechniqueShaderLoaderT6(AssetCreationContext& context)
|
||||
: m_context(context)
|
||||
{
|
||||
}
|
||||
|
||||
std::optional<techset::CommonTechniqueShaderBin> LoadVertexShader(const std::string& name) override
|
||||
{
|
||||
auto* shaderAsset = m_context.LoadSubAsset<SubAssetVertexShader>(name);
|
||||
if (!shaderAsset)
|
||||
return std::nullopt;
|
||||
|
||||
const auto* shader = shaderAsset->Asset();
|
||||
assert(shader->prog.loadDef.program && shader->prog.loadDef.programSize > 0);
|
||||
if (!shader->prog.loadDef.program || shader->prog.loadDef.programSize == 0)
|
||||
return std::nullopt;
|
||||
|
||||
return techset::CommonTechniqueShaderBin{
|
||||
.m_shader_bin = shader->prog.loadDef.program,
|
||||
.m_shader_bin_size = shader->prog.loadDef.programSize,
|
||||
};
|
||||
}
|
||||
|
||||
std::optional<techset::CommonTechniqueShaderBin> LoadPixelShader(const std::string& name) override
|
||||
{
|
||||
auto* shaderAsset = m_context.LoadSubAsset<SubAssetPixelShader>(name);
|
||||
if (!shaderAsset)
|
||||
return std::nullopt;
|
||||
|
||||
const auto* shader = shaderAsset->Asset();
|
||||
assert(shader->prog.loadDef.program && shader->prog.loadDef.programSize > 0);
|
||||
if (!shader->prog.loadDef.program || shader->prog.loadDef.programSize == 0)
|
||||
return std::nullopt;
|
||||
|
||||
return techset::CommonTechniqueShaderBin{
|
||||
.m_shader_bin = shader->prog.loadDef.program,
|
||||
.m_shader_bin_size = shader->prog.loadDef.programSize,
|
||||
};
|
||||
}
|
||||
|
||||
private:
|
||||
AssetCreationContext& m_context;
|
||||
};
|
||||
|
||||
class TechniqueCompilerT6 final : public SubAssetCreator<SubAssetTechnique>
|
||||
{
|
||||
public:
|
||||
TechniqueCompilerT6(MemoryManager& memory, ISearchPath& searchPath)
|
||||
: m_memory(memory),
|
||||
m_search_path(searchPath)
|
||||
{
|
||||
}
|
||||
|
||||
AssetCreationResult CreateSubAsset(const std::string& subAssetName, AssetCreationContext& context) override
|
||||
{
|
||||
bool failure = false;
|
||||
TechniqueShaderLoaderT6 shaderLoader(context);
|
||||
const auto commonShaderArgCreator = techset::CommonShaderArgCreator::CreateDx11(shaderLoader, context);
|
||||
|
||||
const auto commonTechnique =
|
||||
techset::LoadCommonTechnique(subAssetName, commonCodeSourceInfos, commonRoutingInfos, *commonShaderArgCreator, m_search_path, failure);
|
||||
|
||||
if (!commonTechnique)
|
||||
return failure ? AssetCreationResult::Failure() : AssetCreationResult::NoAction();
|
||||
|
||||
auto* convertedTechnique = ConvertTechnique(*commonTechnique, context, m_memory);
|
||||
assert(convertedTechnique);
|
||||
|
||||
return AssetCreationResult::Success(context.AddSubAsset(AssetRegistration<SubAssetTechnique>(subAssetName, convertedTechnique)));
|
||||
}
|
||||
|
||||
private:
|
||||
MemoryManager& m_memory;
|
||||
ISearchPath& m_search_path;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace techset
|
||||
{
|
||||
std::unique_ptr<ISubAssetCreator> CreateTechniqueCompilerT6(MemoryManager& memory, ISearchPath& searchPath)
|
||||
{
|
||||
return std::make_unique<TechniqueCompilerT6>(memory, searchPath);
|
||||
}
|
||||
} // namespace techset
|
||||
12
src/ObjCompiling/Game/T6/Techset/TechniqueCompilerT6.h
Normal file
12
src/ObjCompiling/Game/T6/Techset/TechniqueCompilerT6.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "Asset/IAssetCreator.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace techset
|
||||
{
|
||||
std::unique_ptr<ISubAssetCreator> CreateTechniqueCompilerT6(MemoryManager& memory, ISearchPath& searchPath);
|
||||
}
|
||||
@@ -70,6 +70,19 @@ namespace
|
||||
|
||||
auto* techset = ConvertTechniqueSet(*commonTechset, m_memory);
|
||||
|
||||
for (auto techniqueIndex = 0u; techniqueIndex < std::extent_v<decltype(MaterialTechniqueSet::techniques)>; techniqueIndex++)
|
||||
{
|
||||
const auto& techniqueName = commonTechset->m_technique_names[techniqueIndex];
|
||||
if (techniqueName.empty())
|
||||
continue;
|
||||
|
||||
auto* technique = context.LoadSubAsset<SubAssetTechnique>(techniqueName);
|
||||
if (!technique)
|
||||
return AssetCreationResult::Failure();
|
||||
|
||||
techset->techniques[techniqueIndex] = technique->Asset();
|
||||
}
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset(AssetRegistration<AssetTechniqueSet>(assetName, techset)));
|
||||
}
|
||||
|
||||
|
||||
57
src/ObjCompiling/Game/T6/Techset/VertexDeclCompilerT6.cpp
Normal file
57
src/ObjCompiling/Game/T6/Techset/VertexDeclCompilerT6.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
#include "VertexDeclCompilerT6.h"
|
||||
|
||||
#include "Game/T6/T6.h"
|
||||
#include "Game/T6/Techset/TechsetConstantsT6.h"
|
||||
#include "Techset/CommonVertexDeclCreator.h"
|
||||
#include "Utils/Logging/Log.h"
|
||||
|
||||
using namespace T6;
|
||||
|
||||
namespace
|
||||
{
|
||||
class VertexDeclCompilerT6 final : public SubAssetCreator<SubAssetVertexDecl>
|
||||
{
|
||||
public:
|
||||
explicit VertexDeclCompilerT6(MemoryManager& memory)
|
||||
: m_memory(memory)
|
||||
{
|
||||
}
|
||||
|
||||
AssetCreationResult CreateSubAsset(const std::string& subAssetName, AssetCreationContext& context) override
|
||||
{
|
||||
const auto commonVertexDecl = techset::CreateVertexDeclFromName(subAssetName, commonRoutingInfos);
|
||||
if (!commonVertexDecl)
|
||||
return AssetCreationResult::Failure();
|
||||
|
||||
if (commonVertexDecl->m_routing.size() > std::extent_v<decltype(MaterialVertexStreamRouting::data)>)
|
||||
{
|
||||
con::error("Vertex declaration can only have up to {} routing entries", std::extent_v<decltype(MaterialVertexStreamRouting::data)>);
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
|
||||
auto* vertexDecl = m_memory.Alloc<MaterialVertexDeclaration>();
|
||||
|
||||
for (const auto& commonRoutingEntry : commonVertexDecl->m_routing)
|
||||
{
|
||||
vertexDecl->routing.data[vertexDecl->streamCount].source = commonRoutingEntry.m_source;
|
||||
vertexDecl->routing.data[vertexDecl->streamCount].dest = commonRoutingEntry.m_destination;
|
||||
vertexDecl->hasOptionalSource = vertexDecl->hasOptionalSource || commonRoutingEntry.m_source >= STREAM_SRC_OPTIONAL_BEGIN;
|
||||
|
||||
vertexDecl->streamCount++;
|
||||
}
|
||||
|
||||
return AssetCreationResult::Success(context.AddSubAsset(AssetRegistration<SubAssetVertexDecl>(subAssetName, vertexDecl)));
|
||||
}
|
||||
|
||||
private:
|
||||
MemoryManager& m_memory;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace techset
|
||||
{
|
||||
std::unique_ptr<ISubAssetCreator> CreateVertexDeclCompilerT6(MemoryManager& memory)
|
||||
{
|
||||
return std::make_unique<VertexDeclCompilerT6>(memory);
|
||||
}
|
||||
} // namespace techset
|
||||
11
src/ObjCompiling/Game/T6/Techset/VertexDeclCompilerT6.h
Normal file
11
src/ObjCompiling/Game/T6/Techset/VertexDeclCompilerT6.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "Asset/IAssetCreator.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace techset
|
||||
{
|
||||
std::unique_ptr<ISubAssetCreator> CreateVertexDeclCompilerT6(MemoryManager& memory);
|
||||
}
|
||||
164
src/ObjCompiling/Techset/CommonShaderArgCreator.cpp
Normal file
164
src/ObjCompiling/Techset/CommonShaderArgCreator.cpp
Normal file
@@ -0,0 +1,164 @@
|
||||
#include "CommonShaderArgCreator.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
namespace
|
||||
{
|
||||
class BaseCommonShaderArgCreator : public techset::CommonShaderArgCreator
|
||||
{
|
||||
public:
|
||||
explicit BaseCommonShaderArgCreator(techset::ITechniqueShaderLoader& shaderLoader, techset::CommonCodeSourceInfos& commonCodeSourceInfos)
|
||||
: m_shader_loader(shaderLoader),
|
||||
m_common_code_source_infos(commonCodeSourceInfos),
|
||||
m_shader_type(techset::CommonTechniqueShaderType::VERTEX),
|
||||
m_bin{}
|
||||
{
|
||||
}
|
||||
|
||||
result::Expected<NoResult, std::string> EnterShader(const techset::CommonTechniqueShaderType shaderType, const std::string& name) override
|
||||
{
|
||||
m_shader_type = shaderType;
|
||||
|
||||
std::optional<techset::CommonTechniqueShaderBin> maybeShader;
|
||||
if (shaderType == techset::CommonTechniqueShaderType::VERTEX)
|
||||
{
|
||||
maybeShader = m_shader_loader.LoadVertexShader(name);
|
||||
}
|
||||
else if (shaderType == techset::CommonTechniqueShaderType::PIXEL)
|
||||
{
|
||||
maybeShader = m_shader_loader.LoadPixelShader(name);
|
||||
}
|
||||
|
||||
if (!maybeShader)
|
||||
return result::Unexpected<std::string>("Failed to load shader");
|
||||
|
||||
m_bin = *maybeShader;
|
||||
|
||||
return NoResult{};
|
||||
}
|
||||
|
||||
void LeaveShader() override
|
||||
{
|
||||
m_bin = {};
|
||||
}
|
||||
|
||||
result::Expected<NoResult, std::string> AcceptShaderConstantArgument(const techset::CommonShaderArgCreatorDestination& destination,
|
||||
techset::CommonCodeConstSource codeConstSource) override
|
||||
{
|
||||
return result::Unexpected<std::string>("Not implemented");
|
||||
}
|
||||
|
||||
result::Expected<NoResult, std::string> AcceptShaderSamplerArgument(const techset::CommonShaderArgCreatorDestination& destination,
|
||||
techset::CommonCodeSamplerSource codeSamplerSource) override
|
||||
{
|
||||
return result::Unexpected<std::string>("Not implemented");
|
||||
}
|
||||
|
||||
result::Expected<NoResult, std::string> AcceptShaderLiteralArgument(const techset::CommonShaderArgCreatorDestination& destination,
|
||||
const std::array<float, 4>& literalValue) override
|
||||
{
|
||||
return result::Unexpected<std::string>("Not implemented");
|
||||
}
|
||||
|
||||
result::Expected<NoResult, std::string> AcceptShaderMaterialArgument(const techset::CommonShaderArgCreatorDestination& destination,
|
||||
unsigned nameHash) override
|
||||
{
|
||||
return result::Unexpected<std::string>("Not implemented");
|
||||
}
|
||||
|
||||
result::Expected<NoResult, std::string> AcceptShaderMaterialArgument(const techset::CommonShaderArgCreatorDestination& destination,
|
||||
const std::string& nameValue) override
|
||||
{
|
||||
return result::Unexpected<std::string>("Not implemented");
|
||||
}
|
||||
|
||||
result::Expected<std::vector<techset::CommonShaderArg>, std::string> FinalizeArgs() override
|
||||
{
|
||||
// TODO: Auto create remaining args
|
||||
|
||||
std::ranges::sort(m_args,
|
||||
[this](const techset::CommonShaderArg& arg0, const techset::CommonShaderArg& arg1) -> bool
|
||||
{
|
||||
const auto updateFreq0 = arg0.GetFrequency(m_common_code_source_infos);
|
||||
const auto updateFreq1 = arg1.GetFrequency(m_common_code_source_infos);
|
||||
if (updateFreq0 != updateFreq1)
|
||||
return updateFreq0 < updateFreq1;
|
||||
|
||||
const auto typeNumeric0 = m_common_code_source_infos.GetArgumentTypeNumericValue(arg0.m_type);
|
||||
const auto typeNumeric1 = m_common_code_source_infos.GetArgumentTypeNumericValue(arg1.m_type);
|
||||
assert(typeNumeric0);
|
||||
assert(typeNumeric1);
|
||||
if (*typeNumeric0 != *typeNumeric1)
|
||||
return *typeNumeric0 < *typeNumeric1;
|
||||
|
||||
if (arg0.m_type.m_value_type == techset::CommonShaderValueType::MATERIAL_CONST
|
||||
|| arg0.m_type.m_value_type == techset::CommonShaderValueType::MATERIAL_SAMPLER)
|
||||
{
|
||||
return arg0.m_value.name_hash < arg1.m_value.name_hash;
|
||||
}
|
||||
|
||||
return CompareArgumentDestinations(arg0.m_destination, arg1.m_destination);
|
||||
});
|
||||
|
||||
return m_args;
|
||||
}
|
||||
|
||||
protected:
|
||||
[[nodiscard]] virtual size_t CompareArgumentDestinations(const techset::CommonShaderArgDestination& dest0,
|
||||
const techset::CommonShaderArgDestination& dest1) const = 0;
|
||||
|
||||
techset::ITechniqueShaderLoader& m_shader_loader;
|
||||
techset::CommonCodeSourceInfos& m_common_code_source_infos;
|
||||
|
||||
techset::CommonTechniqueShaderType m_shader_type;
|
||||
techset::CommonTechniqueShaderBin m_bin;
|
||||
|
||||
std::vector<techset::CommonShaderArg> m_args;
|
||||
};
|
||||
|
||||
class CommonShaderArgCreatorDx11 final : public BaseCommonShaderArgCreator
|
||||
{
|
||||
public:
|
||||
explicit CommonShaderArgCreatorDx11(techset::ITechniqueShaderLoader& shaderLoader, techset::CommonCodeSourceInfos& commonCodeSourceInfos)
|
||||
: BaseCommonShaderArgCreator(shaderLoader, commonCodeSourceInfos)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
[[nodiscard]] size_t CompareArgumentDestinations(const techset::CommonShaderArgDestination& dest0,
|
||||
const techset::CommonShaderArgDestination& dest1) const override
|
||||
{
|
||||
if (dest0.dx11.m_buffer != dest1.dx11.m_buffer)
|
||||
return dest0.dx11.m_buffer < dest1.dx11.m_buffer;
|
||||
|
||||
return dest0.dx11.m_location < dest1.dx11.m_location;
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace techset
|
||||
{
|
||||
CommonShaderArgCreatorDestination::CommonShaderArgCreatorDestination(std::string argumentName)
|
||||
: m_argument_name(std::move(argumentName))
|
||||
{
|
||||
}
|
||||
|
||||
CommonShaderArgCreatorDestination::CommonShaderArgCreatorDestination(std::string argumentName, const unsigned argumentIndex)
|
||||
: m_argument_name(std::move(argumentName)),
|
||||
m_argument_index(argumentIndex)
|
||||
{
|
||||
}
|
||||
|
||||
std::unique_ptr<CommonShaderArgCreator> CommonShaderArgCreator::CreateDx9(ITechniqueShaderLoader& shaderLoader, AssetCreationContext& context)
|
||||
{
|
||||
// TODO
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<CommonShaderArgCreator>
|
||||
CommonShaderArgCreator::CreateDx11(ITechniqueShaderLoader& shaderLoader, AssetCreationContext& context, CommonCodeSourceInfos& commonCodeSourceInfos)
|
||||
{
|
||||
return std::make_unique<CommonShaderArgCreatorDx11>(shaderLoader, commonCodeSourceInfos);
|
||||
}
|
||||
} // namespace techset
|
||||
61
src/ObjCompiling/Techset/CommonShaderArgCreator.h
Normal file
61
src/ObjCompiling/Techset/CommonShaderArgCreator.h
Normal file
@@ -0,0 +1,61 @@
|
||||
#pragma once
|
||||
|
||||
#include "Asset/AssetCreationContext.h"
|
||||
#include "Techset/CommonTechnique.h"
|
||||
#include "Utils/Result.h"
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
namespace techset
|
||||
{
|
||||
class ITechniqueShaderLoader
|
||||
{
|
||||
public:
|
||||
ITechniqueShaderLoader() = default;
|
||||
virtual ~ITechniqueShaderLoader() = default;
|
||||
|
||||
virtual std::optional<CommonTechniqueShaderBin> LoadVertexShader(const std::string& name) = 0;
|
||||
virtual std::optional<CommonTechniqueShaderBin> LoadPixelShader(const std::string& name) = 0;
|
||||
};
|
||||
|
||||
class CommonShaderArgCreatorDestination
|
||||
{
|
||||
public:
|
||||
std::string m_argument_name;
|
||||
std::optional<unsigned> m_argument_index;
|
||||
|
||||
CommonShaderArgCreatorDestination() = default;
|
||||
explicit CommonShaderArgCreatorDestination(std::string argumentName);
|
||||
CommonShaderArgCreatorDestination(std::string argumentName, unsigned argumentIndex);
|
||||
};
|
||||
|
||||
class CommonShaderArgCreator
|
||||
{
|
||||
public:
|
||||
CommonShaderArgCreator() = default;
|
||||
virtual ~CommonShaderArgCreator() = default;
|
||||
|
||||
virtual result::Expected<NoResult, std::string> EnterShader(CommonTechniqueShaderType shaderType, const std::string& name) = 0;
|
||||
virtual void LeaveShader() = 0;
|
||||
|
||||
virtual result::Expected<NoResult, std::string> AcceptShaderConstantArgument(const CommonShaderArgCreatorDestination& destination,
|
||||
CommonCodeConstSource codeConstSource) = 0;
|
||||
virtual result::Expected<NoResult, std::string> AcceptShaderSamplerArgument(const CommonShaderArgCreatorDestination& destination,
|
||||
CommonCodeSamplerSource codeSamplerSource) = 0;
|
||||
virtual result::Expected<NoResult, std::string> AcceptShaderLiteralArgument(const CommonShaderArgCreatorDestination& destination,
|
||||
const std::array<float, 4>& literalValue) = 0;
|
||||
virtual result::Expected<NoResult, std::string> AcceptShaderMaterialArgument(const CommonShaderArgCreatorDestination& destination,
|
||||
unsigned nameHash) = 0;
|
||||
virtual result::Expected<NoResult, std::string> AcceptShaderMaterialArgument(const CommonShaderArgCreatorDestination& destination,
|
||||
const std::string& nameValue) = 0;
|
||||
|
||||
virtual result::Expected<std::vector<CommonShaderArg>, std::string> FinalizeArgs() = 0;
|
||||
|
||||
static std::unique_ptr<CommonShaderArgCreator> CreateDx9(ITechniqueShaderLoader& shaderLoader, AssetCreationContext& context);
|
||||
static std::unique_ptr<CommonShaderArgCreator>
|
||||
CreateDx11(ITechniqueShaderLoader& shaderLoader, AssetCreationContext& context, CommonCodeSourceInfos& commonCodeSourceInfos);
|
||||
};
|
||||
} // namespace techset
|
||||
@@ -1 +1,47 @@
|
||||
#include "CommonTechniqueLoader.h"
|
||||
|
||||
#include "Parsing/Impl/CommentRemovingStreamProxy.h"
|
||||
#include "Parsing/Impl/ParserSingleInputStream.h"
|
||||
#include "Parsing/Simple/SimpleLexer.h"
|
||||
#include "Parsing/TechniqueFileParser.h"
|
||||
#include "Techset/TechsetCommon.h"
|
||||
#include "Utils/Logging/Log.h"
|
||||
|
||||
namespace techset
|
||||
{
|
||||
std::unique_ptr<CommonTechnique> LoadCommonTechnique(const std::string& techniqueName,
|
||||
const CommonCodeSourceInfos& codeSourceInfos,
|
||||
const CommonStreamRoutingInfos& routingInfos,
|
||||
CommonShaderArgCreator& commonShaderArgCreator,
|
||||
ISearchPath& searchPath,
|
||||
bool& failure)
|
||||
{
|
||||
failure = false;
|
||||
|
||||
const auto fileName = GetFileNameForTechniqueName(techniqueName);
|
||||
const auto techniqueFile = searchPath.Open(fileName);
|
||||
if (!techniqueFile.IsOpen())
|
||||
return nullptr;
|
||||
|
||||
SimpleLexer::Config lexerConfig;
|
||||
lexerConfig.m_emit_new_line_tokens = false;
|
||||
lexerConfig.m_read_strings = true;
|
||||
lexerConfig.m_string_escape_sequences = false;
|
||||
lexerConfig.m_read_integer_numbers = true;
|
||||
lexerConfig.m_read_floating_point_numbers = true;
|
||||
|
||||
const auto baseStream = std::make_unique<ParserSingleInputStream>(*techniqueFile.m_stream, fileName);
|
||||
const auto commentProxy = std::make_unique<CommentRemovingStreamProxy>(baseStream.get());
|
||||
const auto lexer = std::make_unique<SimpleLexer>(commentProxy.get(), std::move(lexerConfig));
|
||||
|
||||
const auto parser = std::make_unique<TechniqueParser>(*lexer, techniqueName, codeSourceInfos, routingInfos, commonShaderArgCreator);
|
||||
|
||||
const auto success = parser->Parse();
|
||||
if (success)
|
||||
return parser->GetParsingResult();
|
||||
|
||||
failure = true;
|
||||
con::error("Parsing technique file \"{}\" failed!", fileName);
|
||||
return nullptr;
|
||||
}
|
||||
} // namespace techset
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "Asset/AssetCreationContext.h"
|
||||
#include "CommonShaderArgCreator.h"
|
||||
#include "Techset/CommonTechnique.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace techset
|
||||
{
|
||||
std::unique_ptr<CommonTechnique>
|
||||
LoadCommonTechnique(const AssetCreationContext& context, const CommonCodeSourceInfos& codeSourceInfos, const CommonStreamRoutingInfos& routingInfos);
|
||||
std::unique_ptr<CommonTechnique> LoadCommonTechnique(const std::string& techniqueName,
|
||||
const CommonCodeSourceInfos& codeSourceInfos,
|
||||
const CommonStreamRoutingInfos& routingInfos,
|
||||
CommonShaderArgCreator& commonShaderArgCreator,
|
||||
ISearchPath& searchPath,
|
||||
bool& failure);
|
||||
} // namespace techset
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
#include "CommonTechsetCache.h"
|
||||
|
||||
using namespace techset;
|
||||
|
||||
CommonTechset* CommonTechsetCache::GetCachedTechsetDefinition(const std::string& techsetName) const
|
||||
{
|
||||
const auto foundTechset = m_cache.find(techsetName);
|
||||
|
||||
if (foundTechset != m_cache.end())
|
||||
return foundTechset->second.get();
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CommonTechsetCache::AddCommonTechsetToCache(std::string name, std::unique_ptr<CommonTechset> definition)
|
||||
{
|
||||
m_cache.emplace(std::make_pair(std::move(name), std::move(definition)));
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Asset/IZoneAssetCreationState.h"
|
||||
#include "Techset/CommonTechset.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace techset
|
||||
{
|
||||
class CommonTechsetCache final : public IZoneAssetCreationState
|
||||
{
|
||||
public:
|
||||
[[nodiscard]] CommonTechset* GetCachedTechsetDefinition(const std::string& techsetName) const;
|
||||
void AddCommonTechsetToCache(std::string name, std::unique_ptr<CommonTechset> definition);
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, std::unique_ptr<CommonTechset>> m_cache;
|
||||
};
|
||||
} // namespace techset
|
||||
@@ -9,7 +9,6 @@
|
||||
#include "Utils/Logging/Log.h"
|
||||
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
|
||||
@@ -23,10 +23,8 @@ namespace techset
|
||||
protected:
|
||||
void ProcessMatch(TechniqueParserState* state, SequenceResult<SimpleParserValue>& result) const override
|
||||
{
|
||||
assert(state->m_in_pass == false);
|
||||
state->m_in_pass = true;
|
||||
|
||||
state->m_acceptor->AcceptNextPass();
|
||||
assert(!state->m_current_pass);
|
||||
state->m_current_pass = CommonPass();
|
||||
}
|
||||
};
|
||||
} // namespace techset
|
||||
|
||||
@@ -26,20 +26,18 @@ namespace techset
|
||||
protected:
|
||||
void ProcessMatch(TechniqueParserState* state, SequenceResult<SimpleParserValue>& result) const override
|
||||
{
|
||||
assert(state->m_in_pass == true);
|
||||
assert(state->m_current_pass);
|
||||
assert(state->m_technique);
|
||||
|
||||
std::string errorMessage;
|
||||
if (!state->m_acceptor->AcceptEndPass(errorMessage))
|
||||
throw ParsingException(result.NextCapture(CAPTURE_FIRST_TOKEN).GetPos(), errorMessage);
|
||||
|
||||
state->m_in_pass = false;
|
||||
state->m_current_pass->m_vertex_declaration.SortRoutingEntries();
|
||||
state->m_technique->m_passes.emplace_back(std::move(*state->m_current_pass));
|
||||
state->m_current_pass = std::nullopt;
|
||||
}
|
||||
};
|
||||
|
||||
class SequenceStateMap final : public TechniqueParser::sequence_t
|
||||
{
|
||||
static constexpr auto CAPTURE_START = 1;
|
||||
static constexpr auto CAPTURE_STATE_MAP_NAME = 2;
|
||||
static constexpr auto CAPTURE_STATE_MAP_NAME = 1;
|
||||
|
||||
public:
|
||||
SequenceStateMap()
|
||||
@@ -47,7 +45,7 @@ namespace techset
|
||||
const SimpleMatcherFactory create(this);
|
||||
|
||||
AddMatchers({
|
||||
create.Keyword("stateMap").Capture(CAPTURE_START),
|
||||
create.Keyword("stateMap"),
|
||||
create.String().Capture(CAPTURE_STATE_MAP_NAME),
|
||||
create.Char(';'),
|
||||
});
|
||||
@@ -56,13 +54,9 @@ namespace techset
|
||||
protected:
|
||||
void ProcessMatch(TechniqueParserState* state, SequenceResult<SimpleParserValue>& result) const override
|
||||
{
|
||||
const auto& firstToken = result.NextCapture(CAPTURE_START);
|
||||
assert(state->m_current_pass);
|
||||
|
||||
std::string errorMessage;
|
||||
const auto acceptorResult = state->m_acceptor->AcceptStateMap(result.NextCapture(CAPTURE_STATE_MAP_NAME).StringValue(), errorMessage);
|
||||
|
||||
if (!acceptorResult)
|
||||
throw ParsingException(firstToken.GetPos(), std::move(errorMessage));
|
||||
state->m_current_pass->m_state_map = result.NextCapture(CAPTURE_STATE_MAP_NAME).StringValue();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -71,7 +65,7 @@ namespace techset
|
||||
static constexpr auto TAG_VERTEX_SHADER = 1;
|
||||
static constexpr auto TAG_PIXEL_SHADER = 2;
|
||||
|
||||
static constexpr auto CAPTURE_START = 1;
|
||||
static constexpr auto CAPTURE_FIRST_TOKEN = 1;
|
||||
static constexpr auto CAPTURE_VERSION = 2;
|
||||
static constexpr auto CAPTURE_VERSION_MAJOR = 3;
|
||||
static constexpr auto CAPTURE_VERSION_MINOR = 4;
|
||||
@@ -88,7 +82,7 @@ namespace techset
|
||||
create.Keyword("vertexShader").Tag(TAG_VERTEX_SHADER),
|
||||
create.Keyword("pixelShader").Tag(TAG_PIXEL_SHADER),
|
||||
})
|
||||
.Capture(CAPTURE_START),
|
||||
.Capture(CAPTURE_FIRST_TOKEN),
|
||||
create.Or({
|
||||
create.And({
|
||||
create.Integer().Capture(CAPTURE_VERSION_MAJOR),
|
||||
@@ -106,31 +100,23 @@ namespace techset
|
||||
protected:
|
||||
void ProcessMatch(TechniqueParserState* state, SequenceResult<SimpleParserValue>& result) const override
|
||||
{
|
||||
const auto& firstToken = result.NextCapture(CAPTURE_START);
|
||||
|
||||
// Don't care about shader version since it's stated in the shader bin anyway
|
||||
|
||||
const auto& shaderNameToken = result.NextCapture(CAPTURE_SHADER_NAME);
|
||||
|
||||
bool acceptorResult;
|
||||
std::string errorMessage;
|
||||
const auto shaderTag = result.NextTag();
|
||||
assert(shaderTag == TAG_VERTEX_SHADER || shaderTag == TAG_PIXEL_SHADER);
|
||||
|
||||
if (shaderTag == TAG_VERTEX_SHADER)
|
||||
{
|
||||
acceptorResult = state->m_acceptor->AcceptVertexShader(shaderNameToken.StringValue(), errorMessage);
|
||||
state->m_current_shader = ShaderSelector::VERTEX_SHADER;
|
||||
}
|
||||
state->m_current_shader_type = CommonTechniqueShaderType::VERTEX;
|
||||
else
|
||||
{
|
||||
acceptorResult = state->m_acceptor->AcceptPixelShader(shaderNameToken.StringValue(), errorMessage);
|
||||
state->m_current_shader = ShaderSelector::PIXEL_SHADER;
|
||||
}
|
||||
state->m_current_shader_type = CommonTechniqueShaderType::PIXEL;
|
||||
|
||||
state->m_in_shader = true;
|
||||
state->m_current_shader = CommonTechniqueShader(state->m_current_shader_type, shaderNameToken.StringValue());
|
||||
|
||||
if (!acceptorResult)
|
||||
throw ParsingException(firstToken.GetPos(), std::move(errorMessage));
|
||||
auto enterResult = state->m_shader_arg_creator.EnterShader(state->m_current_shader->m_type, state->m_current_shader->m_name);
|
||||
if (!enterResult.has_value())
|
||||
throw ParsingException(result.NextCapture(CAPTURE_FIRST_TOKEN).GetPos(), enterResult.error());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -191,13 +177,23 @@ namespace techset
|
||||
protected:
|
||||
void ProcessMatch(TechniqueParserState* state, SequenceResult<SimpleParserValue>& result) const override
|
||||
{
|
||||
const auto& firstToken = result.NextCapture(CAPTURE_FIRST_TOKEN);
|
||||
const std::string destinationString = CreateRoutingString(result, CAPTURE_STREAM_DESTINATION_NAME, CAPTURE_STREAM_DESTINATION_INDEX);
|
||||
const std::string sourceString = CreateRoutingString(result, CAPTURE_STREAM_SOURCE_NAME, CAPTURE_STREAM_SOURCE_INDEX);
|
||||
assert(state->m_current_pass);
|
||||
|
||||
std::string errorMessage;
|
||||
if (!state->m_acceptor->AcceptVertexStreamRouting(destinationString, sourceString, errorMessage))
|
||||
throw ParsingException(firstToken.GetPos(), std::move(errorMessage));
|
||||
const auto& firstToken = result.NextCapture(CAPTURE_FIRST_TOKEN);
|
||||
|
||||
const std::string destinationString = CreateRoutingString(result, CAPTURE_STREAM_DESTINATION_NAME, CAPTURE_STREAM_DESTINATION_INDEX);
|
||||
const auto maybeDestination = state->m_routing_infos.GetDestinationByName(destinationString);
|
||||
|
||||
if (!maybeDestination.has_value())
|
||||
throw ParsingException(firstToken.GetPos(), "Unknown routing destination");
|
||||
|
||||
const std::string sourceString = CreateRoutingString(result, CAPTURE_STREAM_SOURCE_NAME, CAPTURE_STREAM_SOURCE_INDEX);
|
||||
const auto maybeSource = state->m_routing_infos.GetSourceByName(sourceString);
|
||||
|
||||
if (!maybeSource.has_value())
|
||||
throw ParsingException(firstToken.GetPos(), "Unknown routing source");
|
||||
|
||||
state->m_current_pass->m_vertex_declaration.m_routing.emplace_back(*maybeSource, *maybeDestination);
|
||||
}
|
||||
};
|
||||
} // namespace techset
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "TechniqueShaderScopeSequences.h"
|
||||
|
||||
#include "Parsing/Simple/Matcher/SimpleMatcherFactory.h"
|
||||
#include "Techset/CommonShaderArgCreator.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
@@ -10,21 +11,35 @@ namespace techset
|
||||
{
|
||||
class SequenceEndShader final : public TechniqueParser::sequence_t
|
||||
{
|
||||
static constexpr auto CAPTURE_FIRST_TOKEN = 1;
|
||||
|
||||
public:
|
||||
SequenceEndShader()
|
||||
{
|
||||
const SimpleMatcherFactory create(this);
|
||||
|
||||
AddMatchers({
|
||||
create.Char('}'),
|
||||
create.Char('}').Capture(CAPTURE_FIRST_TOKEN),
|
||||
});
|
||||
}
|
||||
|
||||
protected:
|
||||
void ProcessMatch(TechniqueParserState* state, SequenceResult<SimpleParserValue>& result) const override
|
||||
{
|
||||
assert(state->m_in_shader == true);
|
||||
state->m_in_shader = false;
|
||||
assert(state->m_current_pass);
|
||||
assert(state->m_current_shader);
|
||||
|
||||
if (state->m_current_shader_type == CommonTechniqueShaderType::VERTEX)
|
||||
state->m_current_pass->m_vertex_shader = std::move(*state->m_current_shader);
|
||||
else
|
||||
state->m_current_pass->m_pixel_shader = std::move(*state->m_current_shader);
|
||||
|
||||
state->m_current_shader = std::nullopt;
|
||||
auto finalizationResult = state->m_shader_arg_creator.FinalizeArgs();
|
||||
if (!finalizationResult.has_value())
|
||||
throw ParsingException(result.NextCapture(CAPTURE_FIRST_TOKEN).GetPos(), finalizationResult.error());
|
||||
|
||||
state->m_shader_arg_creator.LeaveShader();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -134,40 +149,120 @@ namespace techset
|
||||
});
|
||||
}
|
||||
|
||||
static void ProcessCodeArgument(const TechniqueParserState* state, SequenceResult<SimpleParserValue>& result, ShaderArgument arg, const bool isSampler)
|
||||
protected:
|
||||
void ProcessMatch(TechniqueParserState* state, SequenceResult<SimpleParserValue>& result) const override
|
||||
{
|
||||
std::vector<std::string> accessors;
|
||||
while (result.HasNextCapture(CAPTURE_CODE_ACCESSOR))
|
||||
accessors.emplace_back(result.NextCapture(CAPTURE_CODE_ACCESSOR).IdentifierValue());
|
||||
assert(state->m_current_shader);
|
||||
|
||||
const auto& shaderArgumentNameToken = result.NextCapture(CAPTURE_SHADER_ARGUMENT);
|
||||
|
||||
CommonShaderArgCreatorDestination destination;
|
||||
if (result.HasNextCapture(CAPTURE_SHADER_INDEX))
|
||||
{
|
||||
const auto& shaderArgumentIndexToken = result.NextCapture(CAPTURE_SHADER_INDEX);
|
||||
if (shaderArgumentIndexToken.IntegerValue() < 0)
|
||||
throw ParsingException(shaderArgumentIndexToken.GetPos(), "Index cannot be negative");
|
||||
const auto index = static_cast<unsigned>(shaderArgumentIndexToken.IntegerValue());
|
||||
destination = CommonShaderArgCreatorDestination(shaderArgumentNameToken.IdentifierValue(), index);
|
||||
}
|
||||
else
|
||||
destination = CommonShaderArgCreatorDestination(shaderArgumentNameToken.IdentifierValue());
|
||||
|
||||
const auto typeTag = result.NextTag();
|
||||
assert(typeTag == TAG_CONSTANT || typeTag == TAG_SAMPLER || typeTag == TAG_LITERAL || typeTag == TAG_MATERIAL);
|
||||
|
||||
if (typeTag == TAG_CONSTANT || typeTag == TAG_SAMPLER)
|
||||
{
|
||||
ProcessCodeArgument(state, result, destination, typeTag == TAG_SAMPLER);
|
||||
}
|
||||
else if (typeTag == TAG_LITERAL)
|
||||
{
|
||||
ProcessLiteralArgument(state, result, destination);
|
||||
}
|
||||
else
|
||||
{
|
||||
ProcessMaterialArgument(state, result, destination);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
static void ProcessCodeArgument(const TechniqueParserState* state,
|
||||
SequenceResult<SimpleParserValue>& result,
|
||||
const CommonShaderArgCreatorDestination& destination,
|
||||
const bool isSampler)
|
||||
{
|
||||
const auto accessor = GetAccessorValue(result);
|
||||
|
||||
CommonShaderArgValue argValue;
|
||||
if (isSampler)
|
||||
{
|
||||
const auto maybeSamplerSource = state->m_code_source_infos.GetCodeSamplerSourceForAccessor(accessor);
|
||||
if (!maybeSamplerSource.has_value())
|
||||
throw ParsingException(result.NextCapture(CAPTURE_FIRST_TOKEN).GetPos(), "Unknown code sampler");
|
||||
|
||||
argValue.code_const_source = *maybeSamplerSource;
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto maybeConstSource = state->m_code_source_infos.GetCodeSamplerSourceForAccessor(accessor);
|
||||
if (!maybeConstSource.has_value())
|
||||
throw ParsingException(result.NextCapture(CAPTURE_FIRST_TOKEN).GetPos(), "Unknown code constant");
|
||||
|
||||
argValue.code_const_source = *maybeConstSource;
|
||||
}
|
||||
|
||||
ShaderArgumentCodeSource source;
|
||||
if (result.HasNextCapture(CAPTURE_CODE_INDEX))
|
||||
{
|
||||
if (isSampler)
|
||||
throw ParsingException(result.NextCapture(CAPTURE_FIRST_TOKEN).GetPos(), "Code sampler is not an array");
|
||||
|
||||
const auto& codeIndexToken = result.NextCapture(CAPTURE_CODE_INDEX);
|
||||
if (codeIndexToken.IntegerValue() < 0)
|
||||
const auto indexIntValue = codeIndexToken.IntegerValue();
|
||||
if (indexIntValue < 0)
|
||||
throw ParsingException(codeIndexToken.GetPos(), "Index cannot be negative");
|
||||
source = ShaderArgumentCodeSource(std::move(accessors), static_cast<size_t>(codeIndexToken.IntegerValue()));
|
||||
}
|
||||
else
|
||||
source = ShaderArgumentCodeSource(std::move(accessors));
|
||||
|
||||
std::string errorMessage;
|
||||
if (!isSampler)
|
||||
const auto indexValue = static_cast<size_t>(indexIntValue);
|
||||
|
||||
size_t codeArraySize = state->m_code_source_infos.GetInfoForCodeConstSource(argValue.code_const_source)->arrayCount;
|
||||
|
||||
if (codeArraySize == 0)
|
||||
throw ParsingException(result.NextCapture(CAPTURE_FIRST_TOKEN).GetPos(), "Code constant is not an array");
|
||||
if (codeArraySize <= indexValue)
|
||||
{
|
||||
if (!state->m_acceptor->AcceptShaderConstantArgument(state->m_current_shader, std::move(arg), std::move(source), errorMessage))
|
||||
throw ParsingException(result.NextCapture(CAPTURE_FIRST_TOKEN).GetPos(), std::move(errorMessage));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!state->m_acceptor->AcceptShaderSamplerArgument(state->m_current_shader, std::move(arg), std::move(source), errorMessage))
|
||||
throw ParsingException(result.NextCapture(CAPTURE_FIRST_TOKEN).GetPos(), std::move(errorMessage));
|
||||
}
|
||||
throw ParsingException(result.NextCapture(CAPTURE_FIRST_TOKEN).GetPos(),
|
||||
std::format("Array overflow: Code array has size {}", codeArraySize));
|
||||
}
|
||||
|
||||
static void ProcessLiteralArgument(const TechniqueParserState* state, SequenceResult<SimpleParserValue>& result, ShaderArgument arg)
|
||||
argValue.code_const_source += static_cast<CommonCodeConstSource>(indexValue);
|
||||
}
|
||||
|
||||
result::Expected<NoResult, std::string> shaderCreatorResult(NoResult{});
|
||||
if (isSampler)
|
||||
shaderCreatorResult = state->m_shader_arg_creator.AcceptShaderSamplerArgument(destination, argValue.code_sampler_source);
|
||||
else
|
||||
shaderCreatorResult = state->m_shader_arg_creator.AcceptShaderConstantArgument(destination, argValue.code_const_source);
|
||||
|
||||
if (!shaderCreatorResult.has_value())
|
||||
throw ParsingException(result.NextCapture(CAPTURE_FIRST_TOKEN).GetPos(), std::move(shaderCreatorResult.error()));
|
||||
}
|
||||
|
||||
static std::string GetAccessorValue(SequenceResult<SimpleParserValue>& result)
|
||||
{
|
||||
float value[4];
|
||||
for (float& i : value)
|
||||
std::ostringstream accessorStream;
|
||||
|
||||
accessorStream << result.NextCapture(CAPTURE_CODE_ACCESSOR).IdentifierValue();
|
||||
while (result.HasNextCapture(CAPTURE_CODE_ACCESSOR))
|
||||
accessorStream << '.' << result.NextCapture(CAPTURE_CODE_ACCESSOR).IdentifierValue();
|
||||
|
||||
return accessorStream.str();
|
||||
}
|
||||
|
||||
static void ProcessLiteralArgument(const TechniqueParserState* state,
|
||||
SequenceResult<SimpleParserValue>& result,
|
||||
const CommonShaderArgCreatorDestination& destination)
|
||||
{
|
||||
std::array<float, 4> argValue;
|
||||
for (float& i : argValue)
|
||||
{
|
||||
const auto& literalValueToken = result.NextCapture(CAPTURE_LITERAL_VALUE);
|
||||
|
||||
@@ -177,56 +272,30 @@ namespace techset
|
||||
i = static_cast<float>(literalValueToken.IntegerValue());
|
||||
}
|
||||
|
||||
const ShaderArgumentLiteralSource source(value);
|
||||
std::string errorMessage;
|
||||
if (!state->m_acceptor->AcceptShaderLiteralArgument(state->m_current_shader, std::move(arg), source, errorMessage))
|
||||
throw ParsingException(result.NextCapture(CAPTURE_FIRST_TOKEN).GetPos(), std::move(errorMessage));
|
||||
auto shaderCreatorResult = state->m_shader_arg_creator.AcceptShaderLiteralArgument(destination, argValue);
|
||||
|
||||
if (!shaderCreatorResult.has_value())
|
||||
throw ParsingException(result.NextCapture(CAPTURE_FIRST_TOKEN).GetPos(), std::move(shaderCreatorResult.error()));
|
||||
}
|
||||
|
||||
static void ProcessMaterialArgument(const TechniqueParserState* state, SequenceResult<SimpleParserValue>& result, ShaderArgument arg)
|
||||
static void ProcessMaterialArgument(const TechniqueParserState* state,
|
||||
SequenceResult<SimpleParserValue>& result,
|
||||
const CommonShaderArgCreatorDestination& destination)
|
||||
{
|
||||
std::string errorMessage;
|
||||
result::Expected<NoResult, std::string> shaderCreatorResult(NoResult{});
|
||||
if (result.HasNextCapture(CAPTURE_MATERIAL_HASH))
|
||||
{
|
||||
ShaderArgumentMaterialSource source(static_cast<size_t>(result.NextCapture(CAPTURE_MATERIAL_HASH).IntegerValue()));
|
||||
if (!state->m_acceptor->AcceptShaderMaterialArgument(state->m_current_shader, std::move(arg), std::move(source), errorMessage))
|
||||
throw ParsingException(result.NextCapture(CAPTURE_FIRST_TOKEN).GetPos(), std::move(errorMessage));
|
||||
shaderCreatorResult = state->m_shader_arg_creator.AcceptShaderMaterialArgument(
|
||||
destination, static_cast<unsigned>(result.NextCapture(CAPTURE_MATERIAL_HASH).IntegerValue()));
|
||||
}
|
||||
else
|
||||
{
|
||||
ShaderArgumentMaterialSource source(result.NextCapture(CAPTURE_MATERIAL_NAME).IdentifierValue());
|
||||
if (!state->m_acceptor->AcceptShaderMaterialArgument(state->m_current_shader, std::move(arg), std::move(source), errorMessage))
|
||||
throw ParsingException(result.NextCapture(CAPTURE_FIRST_TOKEN).GetPos(), std::move(errorMessage));
|
||||
}
|
||||
const auto stringValue = result.NextCapture(CAPTURE_MATERIAL_NAME).IdentifierValue();
|
||||
shaderCreatorResult = state->m_shader_arg_creator.AcceptShaderMaterialArgument(destination, stringValue);
|
||||
}
|
||||
|
||||
protected:
|
||||
void ProcessMatch(TechniqueParserState* state, SequenceResult<SimpleParserValue>& result) const override
|
||||
{
|
||||
assert(state->m_in_shader == true);
|
||||
|
||||
const auto& shaderArgumentNameToken = result.NextCapture(CAPTURE_SHADER_ARGUMENT);
|
||||
|
||||
ShaderArgument arg;
|
||||
if (result.HasNextCapture(CAPTURE_SHADER_INDEX))
|
||||
{
|
||||
const auto& shaderArgumentIndexToken = result.NextCapture(CAPTURE_SHADER_INDEX);
|
||||
if (shaderArgumentIndexToken.IntegerValue() < 0)
|
||||
throw ParsingException(shaderArgumentIndexToken.GetPos(), "Index cannot be negative");
|
||||
const auto index = static_cast<unsigned>(shaderArgumentIndexToken.IntegerValue());
|
||||
arg = ShaderArgument(shaderArgumentNameToken.IdentifierValue(), index);
|
||||
}
|
||||
else
|
||||
arg = ShaderArgument(shaderArgumentNameToken.IdentifierValue());
|
||||
|
||||
const auto typeTag = result.NextTag();
|
||||
assert(typeTag == TAG_CONSTANT || typeTag == TAG_SAMPLER || typeTag == TAG_LITERAL || typeTag == TAG_MATERIAL);
|
||||
if (typeTag == TAG_CONSTANT || typeTag == TAG_SAMPLER)
|
||||
ProcessCodeArgument(state, result, std::move(arg), typeTag == TAG_SAMPLER);
|
||||
else if (typeTag == TAG_LITERAL)
|
||||
ProcessLiteralArgument(state, result, std::move(arg));
|
||||
else
|
||||
ProcessMaterialArgument(state, result, std::move(arg));
|
||||
if (!shaderCreatorResult.has_value())
|
||||
throw ParsingException(result.NextCapture(CAPTURE_FIRST_TOKEN).GetPos(), std::move(shaderCreatorResult.error()));
|
||||
}
|
||||
};
|
||||
} // namespace techset
|
||||
|
||||
@@ -4,20 +4,30 @@
|
||||
#include "Sequence/TechniquePassScopeSequences.h"
|
||||
#include "Sequence/TechniqueShaderScopeSequences.h"
|
||||
|
||||
using namespace techset;
|
||||
|
||||
TechniqueParser::TechniqueParser(SimpleLexer* lexer, ITechniqueDefinitionAcceptor* acceptor)
|
||||
: AbstractParser(lexer, std::make_unique<TechniqueParserState>(acceptor))
|
||||
namespace techset
|
||||
{
|
||||
}
|
||||
TechniqueParser::TechniqueParser(SimpleLexer& lexer,
|
||||
std::string techniqueName,
|
||||
const CommonCodeSourceInfos& codeSourceInfos,
|
||||
const CommonStreamRoutingInfos& routingInfos,
|
||||
CommonShaderArgCreator& shaderArgCreator)
|
||||
: AbstractParser(&lexer, std::make_unique<TechniqueParserState>(std::move(techniqueName), codeSourceInfos, routingInfos, shaderArgCreator))
|
||||
{
|
||||
}
|
||||
|
||||
const std::vector<TechniqueParser::sequence_t*>& TechniqueParser::GetTestsForState()
|
||||
{
|
||||
if (m_state->m_in_shader)
|
||||
std::unique_ptr<CommonTechnique> TechniqueParser::GetParsingResult() const
|
||||
{
|
||||
return std::move(m_state->m_technique);
|
||||
}
|
||||
|
||||
const std::vector<TechniqueParser::sequence_t*>& TechniqueParser::GetTestsForState()
|
||||
{
|
||||
if (m_state->m_current_shader.has_value())
|
||||
return TechniqueShaderScopeSequences::GetSequences();
|
||||
|
||||
if (m_state->m_in_pass)
|
||||
if (m_state->m_current_pass.has_value())
|
||||
return TechniquePassScopeSequences::GetSequences();
|
||||
|
||||
return TechniqueNoScopeSequences::GetSequences();
|
||||
}
|
||||
}
|
||||
} // namespace techset
|
||||
|
||||
@@ -4,15 +4,21 @@
|
||||
#include "Parsing/Simple/SimpleLexer.h"
|
||||
#include "Parsing/Simple/SimpleParserValue.h"
|
||||
#include "TechniqueFileParserState.h"
|
||||
#include "Techset/CommonTechnique.h"
|
||||
|
||||
namespace techset
|
||||
{
|
||||
class TechniqueParser final : public AbstractParser<SimpleParserValue, TechniqueParserState>
|
||||
{
|
||||
public:
|
||||
TechniqueParser(SimpleLexer& lexer,
|
||||
std::string techniqueName,
|
||||
const CommonCodeSourceInfos& codeSourceInfos,
|
||||
const CommonStreamRoutingInfos& routingInfos,
|
||||
CommonShaderArgCreator& shaderArgCreator);
|
||||
[[nodiscard]] std::unique_ptr<CommonTechnique> GetParsingResult() const;
|
||||
|
||||
protected:
|
||||
const std::vector<sequence_t*>& GetTestsForState() override;
|
||||
|
||||
public:
|
||||
TechniqueParser(SimpleLexer* lexer, ITechniqueDefinitionAcceptor* acceptor);
|
||||
};
|
||||
} // namespace techset
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
#include "TechniqueFileParserState.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
using namespace techset;
|
||||
|
||||
TechniqueParserState::TechniqueParserState(ITechniqueDefinitionAcceptor* acceptor)
|
||||
: m_acceptor(acceptor),
|
||||
m_in_pass(false),
|
||||
m_in_shader(false),
|
||||
m_current_shader(ShaderSelector::VERTEX_SHADER)
|
||||
namespace techset
|
||||
{
|
||||
assert(acceptor);
|
||||
}
|
||||
TechniqueParserState::TechniqueParserState(std::string techniqueName,
|
||||
const CommonCodeSourceInfos& codeSourceInfos,
|
||||
const CommonStreamRoutingInfos& routingInfos,
|
||||
CommonShaderArgCreator& shaderArgCreator)
|
||||
: m_technique(std::make_unique<CommonTechnique>(std::move(techniqueName))),
|
||||
m_code_source_infos(codeSourceInfos),
|
||||
m_routing_infos(routingInfos),
|
||||
m_shader_arg_creator(shaderArgCreator),
|
||||
m_current_shader_type(CommonTechniqueShaderType::VERTEX)
|
||||
{
|
||||
}
|
||||
} // namespace techset
|
||||
|
||||
@@ -1,18 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include "Techset/TechniqueDefinitionAcceptor.h"
|
||||
#include "Techset/CommonShaderArgCreator.h"
|
||||
#include "Techset/CommonTechnique.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace techset
|
||||
{
|
||||
class TechniqueParserState
|
||||
{
|
||||
public:
|
||||
explicit TechniqueParserState(ITechniqueDefinitionAcceptor* acceptor);
|
||||
TechniqueParserState(std::string techniqueName,
|
||||
const CommonCodeSourceInfos& codeSourceInfos,
|
||||
const CommonStreamRoutingInfos& routingInfos,
|
||||
CommonShaderArgCreator& shaderArgCreator);
|
||||
|
||||
ITechniqueDefinitionAcceptor* const m_acceptor;
|
||||
std::unique_ptr<CommonTechnique> m_technique;
|
||||
|
||||
bool m_in_pass;
|
||||
bool m_in_shader;
|
||||
ShaderSelector m_current_shader;
|
||||
const CommonCodeSourceInfos& m_code_source_infos;
|
||||
const CommonStreamRoutingInfos& m_routing_infos;
|
||||
CommonShaderArgCreator& m_shader_arg_creator;
|
||||
|
||||
std::optional<CommonPass> m_current_pass;
|
||||
std::optional<CommonTechniqueShader> m_current_shader;
|
||||
CommonTechniqueShaderType m_current_shader_type;
|
||||
};
|
||||
} // namespace techset
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
#include "StateMapFromTechniqueExtractor.h"
|
||||
|
||||
using namespace state_map;
|
||||
|
||||
std::string StateMapFromTechniqueExtractor::RetrieveStateMap()
|
||||
{
|
||||
return std::move(m_state_map);
|
||||
}
|
||||
|
||||
void StateMapFromTechniqueExtractor::AcceptNextPass() {}
|
||||
|
||||
bool StateMapFromTechniqueExtractor::AcceptEndPass(std::string& errorMessage)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StateMapFromTechniqueExtractor::AcceptStateMap(const std::string& stateMapName, std::string& errorMessage)
|
||||
{
|
||||
m_state_map = stateMapName;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StateMapFromTechniqueExtractor::AcceptVertexShader(const std::string& vertexShaderName, std::string& errorMessage)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StateMapFromTechniqueExtractor::AcceptPixelShader(const std::string& pixelShaderName, std::string& errorMessage)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StateMapFromTechniqueExtractor::AcceptShaderConstantArgument(techset::ShaderSelector shader,
|
||||
techset::ShaderArgument shaderArgument,
|
||||
techset::ShaderArgumentCodeSource source,
|
||||
std::string& errorMessage)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StateMapFromTechniqueExtractor::AcceptShaderSamplerArgument(techset::ShaderSelector shader,
|
||||
techset::ShaderArgument shaderArgument,
|
||||
techset::ShaderArgumentCodeSource source,
|
||||
std::string& errorMessage)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StateMapFromTechniqueExtractor::AcceptShaderLiteralArgument(techset::ShaderSelector shader,
|
||||
techset::ShaderArgument shaderArgument,
|
||||
techset::ShaderArgumentLiteralSource source,
|
||||
std::string& errorMessage)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StateMapFromTechniqueExtractor::AcceptShaderMaterialArgument(techset::ShaderSelector shader,
|
||||
techset::ShaderArgument shaderArgument,
|
||||
techset::ShaderArgumentMaterialSource source,
|
||||
std::string& errorMessage)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StateMapFromTechniqueExtractor::AcceptVertexStreamRouting(const std::string& destination, const std::string& source, std::string& errorMessage)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Techset/TechniqueDefinitionAcceptor.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace state_map
|
||||
{
|
||||
class StateMapFromTechniqueExtractor final : public techset::ITechniqueDefinitionAcceptor
|
||||
{
|
||||
public:
|
||||
std::string RetrieveStateMap();
|
||||
|
||||
void AcceptNextPass() override;
|
||||
bool AcceptEndPass(std::string& errorMessage) override;
|
||||
bool AcceptStateMap(const std::string& stateMapName, std::string& errorMessage) override;
|
||||
bool AcceptVertexShader(const std::string& vertexShaderName, std::string& errorMessage) override;
|
||||
bool AcceptPixelShader(const std::string& pixelShaderName, std::string& errorMessage) override;
|
||||
bool AcceptShaderConstantArgument(techset::ShaderSelector shader,
|
||||
techset::ShaderArgument shaderArgument,
|
||||
techset::ShaderArgumentCodeSource source,
|
||||
std::string& errorMessage) override;
|
||||
bool AcceptShaderSamplerArgument(techset::ShaderSelector shader,
|
||||
techset::ShaderArgument shaderArgument,
|
||||
techset::ShaderArgumentCodeSource source,
|
||||
std::string& errorMessage) override;
|
||||
bool AcceptShaderLiteralArgument(techset::ShaderSelector shader,
|
||||
techset::ShaderArgument shaderArgument,
|
||||
techset::ShaderArgumentLiteralSource source,
|
||||
std::string& errorMessage) override;
|
||||
bool AcceptShaderMaterialArgument(techset::ShaderSelector shader,
|
||||
techset::ShaderArgument shaderArgument,
|
||||
techset::ShaderArgumentMaterialSource source,
|
||||
std::string& errorMessage) override;
|
||||
bool AcceptVertexStreamRouting(const std::string& destination, const std::string& source, std::string& errorMessage) override;
|
||||
|
||||
private:
|
||||
std::string m_state_map;
|
||||
};
|
||||
} // namespace state_map
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "Parsing/StateMapParserState.h"
|
||||
#include "StateMapDefinition.h"
|
||||
#include "Techset/StateMap/StateMapLayout.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@@ -22,7 +21,7 @@ namespace state_map
|
||||
public:
|
||||
StateMapReader(std::istream& stream, std::string fileName, std::string stateMapName, const StateMapLayout& layout);
|
||||
|
||||
_NODISCARD bool IsValidEndState(const StateMapParserState* state) const;
|
||||
_NODISCARD std::unique_ptr<StateMapDefinition> ReadStateMapDefinition() const;
|
||||
[[nodiscard]] bool IsValidEndState(const StateMapParserState* state) const;
|
||||
[[nodiscard]] std::unique_ptr<StateMapDefinition> ReadStateMapDefinition() const;
|
||||
};
|
||||
} // namespace state_map
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Asset/IZoneAssetCreationState.h"
|
||||
#include "StateMap/StateMapDefinition.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "Techset/StateMap/StateMapDefinition.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@@ -13,10 +12,10 @@ namespace techset
|
||||
class TechniqueStateMapCache final : public IZoneAssetCreationState
|
||||
{
|
||||
public:
|
||||
_NODISCARD const state_map::StateMapDefinition* GetCachedStateMap(const std::string& name) const;
|
||||
[[nodiscard]] const state_map::StateMapDefinition* GetCachedStateMap(const std::string& name) const;
|
||||
void AddStateMapToCache(std::unique_ptr<state_map::StateMapDefinition> stateMap);
|
||||
|
||||
_NODISCARD const state_map::StateMapDefinition* GetStateMapForTechnique(const std::string& techniqueName) const;
|
||||
[[nodiscard]] const state_map::StateMapDefinition* GetStateMapForTechnique(const std::string& techniqueName) const;
|
||||
void SetTechniqueUsesStateMap(std::string techniqueName, const state_map::StateMapDefinition* stateMap);
|
||||
|
||||
private:
|
||||
@@ -1,116 +0,0 @@
|
||||
#include "TechniqueDefinitionAcceptor.h"
|
||||
|
||||
using namespace techset;
|
||||
|
||||
ShaderArgument::ShaderArgument()
|
||||
: m_argument_index_specified(false),
|
||||
m_argument_index(0u)
|
||||
{
|
||||
}
|
||||
|
||||
ShaderArgument::ShaderArgument(std::string argumentName)
|
||||
: m_argument_name(std::move(argumentName)),
|
||||
m_argument_index_specified(false),
|
||||
m_argument_index(0u)
|
||||
{
|
||||
}
|
||||
|
||||
ShaderArgument::ShaderArgument(std::string argumentName, const unsigned argumentIndex)
|
||||
: m_argument_name(std::move(argumentName)),
|
||||
m_argument_index_specified(true),
|
||||
m_argument_index(argumentIndex)
|
||||
{
|
||||
}
|
||||
|
||||
ShaderArgumentCodeSource::ShaderArgumentCodeSource()
|
||||
: m_index_accessor_specified(false),
|
||||
m_index_accessor(0u)
|
||||
{
|
||||
}
|
||||
|
||||
ShaderArgumentCodeSource::ShaderArgumentCodeSource(std::vector<std::string> accessors)
|
||||
: m_accessors(std::move(accessors)),
|
||||
m_index_accessor_specified(false),
|
||||
m_index_accessor(0u)
|
||||
{
|
||||
}
|
||||
|
||||
ShaderArgumentCodeSource::ShaderArgumentCodeSource(std::vector<std::string> accessors, const unsigned indexAccessor)
|
||||
: m_accessors(std::move(accessors)),
|
||||
m_index_accessor_specified(true),
|
||||
m_index_accessor(indexAccessor)
|
||||
{
|
||||
}
|
||||
|
||||
ShaderArgumentLiteralSource::ShaderArgumentLiteralSource()
|
||||
: m_value{}
|
||||
{
|
||||
}
|
||||
|
||||
ShaderArgumentLiteralSource::ShaderArgumentLiteralSource(const float v0, const float v1, const float v2, const float v3)
|
||||
: m_value{v0, v1, v2, v3}
|
||||
{
|
||||
}
|
||||
|
||||
ShaderArgumentLiteralSource::ShaderArgumentLiteralSource(float value[4])
|
||||
: m_value{value[0], value[1], value[2], value[3]}
|
||||
{
|
||||
}
|
||||
|
||||
namespace techset
|
||||
{
|
||||
bool operator<(const ShaderArgumentLiteralSource& lhs, const ShaderArgumentLiteralSource& rhs)
|
||||
{
|
||||
if (lhs.m_value[0] < rhs.m_value[0])
|
||||
return true;
|
||||
if (lhs.m_value[0] > rhs.m_value[0])
|
||||
return false;
|
||||
if (lhs.m_value[1] < rhs.m_value[1])
|
||||
return true;
|
||||
if (lhs.m_value[1] > rhs.m_value[1])
|
||||
return false;
|
||||
if (lhs.m_value[2] < rhs.m_value[2])
|
||||
return true;
|
||||
if (lhs.m_value[2] > rhs.m_value[2])
|
||||
return false;
|
||||
if (lhs.m_value[3] < rhs.m_value[3])
|
||||
return true;
|
||||
if (lhs.m_value[3] > rhs.m_value[3])
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator<=(const ShaderArgumentLiteralSource& lhs, const ShaderArgumentLiteralSource& rhs)
|
||||
{
|
||||
return !(rhs < lhs);
|
||||
}
|
||||
|
||||
bool operator>(const ShaderArgumentLiteralSource& lhs, const ShaderArgumentLiteralSource& rhs)
|
||||
{
|
||||
return rhs < lhs;
|
||||
}
|
||||
|
||||
bool operator>=(const ShaderArgumentLiteralSource& lhs, const ShaderArgumentLiteralSource& rhs)
|
||||
{
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
} // namespace techset
|
||||
|
||||
ShaderArgumentMaterialSource::ShaderArgumentMaterialSource()
|
||||
: m_is_hash(false),
|
||||
m_hash(0u)
|
||||
{
|
||||
}
|
||||
|
||||
ShaderArgumentMaterialSource::ShaderArgumentMaterialSource(const unsigned hash)
|
||||
: m_is_hash(true),
|
||||
m_hash(hash)
|
||||
{
|
||||
}
|
||||
|
||||
ShaderArgumentMaterialSource::ShaderArgumentMaterialSource(std::string name)
|
||||
: m_is_hash(false),
|
||||
m_hash(0u),
|
||||
m_name(std::move(name))
|
||||
{
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace techset
|
||||
{
|
||||
enum class ShaderSelector
|
||||
{
|
||||
VERTEX_SHADER,
|
||||
PIXEL_SHADER
|
||||
};
|
||||
|
||||
class ShaderArgument
|
||||
{
|
||||
public:
|
||||
std::string m_argument_name;
|
||||
bool m_argument_index_specified;
|
||||
unsigned m_argument_index;
|
||||
|
||||
ShaderArgument();
|
||||
explicit ShaderArgument(std::string argumentName);
|
||||
ShaderArgument(std::string argumentName, unsigned argumentIndex);
|
||||
};
|
||||
|
||||
class ShaderArgumentCodeSource
|
||||
{
|
||||
public:
|
||||
std::vector<std::string> m_accessors;
|
||||
bool m_index_accessor_specified;
|
||||
unsigned m_index_accessor;
|
||||
|
||||
ShaderArgumentCodeSource();
|
||||
explicit ShaderArgumentCodeSource(std::vector<std::string> accessors);
|
||||
ShaderArgumentCodeSource(std::vector<std::string> accessors, unsigned indexAccessor);
|
||||
};
|
||||
|
||||
class ShaderArgumentLiteralSource
|
||||
{
|
||||
public:
|
||||
float m_value[4];
|
||||
|
||||
ShaderArgumentLiteralSource();
|
||||
ShaderArgumentLiteralSource(float v0, float v1, float v2, float v3);
|
||||
explicit ShaderArgumentLiteralSource(float value[4]);
|
||||
|
||||
friend bool operator<(const ShaderArgumentLiteralSource& lhs, const ShaderArgumentLiteralSource& rhs);
|
||||
friend bool operator<=(const ShaderArgumentLiteralSource& lhs, const ShaderArgumentLiteralSource& rhs);
|
||||
friend bool operator>(const ShaderArgumentLiteralSource& lhs, const ShaderArgumentLiteralSource& rhs);
|
||||
friend bool operator>=(const ShaderArgumentLiteralSource& lhs, const ShaderArgumentLiteralSource& rhs);
|
||||
};
|
||||
|
||||
class ShaderArgumentMaterialSource
|
||||
{
|
||||
public:
|
||||
ShaderArgumentMaterialSource();
|
||||
explicit ShaderArgumentMaterialSource(unsigned hash);
|
||||
explicit ShaderArgumentMaterialSource(std::string name);
|
||||
|
||||
bool m_is_hash;
|
||||
unsigned m_hash;
|
||||
std::string m_name;
|
||||
};
|
||||
|
||||
class ITechniqueDefinitionAcceptor
|
||||
{
|
||||
protected:
|
||||
ITechniqueDefinitionAcceptor() = default;
|
||||
|
||||
public:
|
||||
virtual ~ITechniqueDefinitionAcceptor() = default;
|
||||
ITechniqueDefinitionAcceptor(const ITechniqueDefinitionAcceptor& other) = default;
|
||||
ITechniqueDefinitionAcceptor(ITechniqueDefinitionAcceptor&& other) noexcept = default;
|
||||
ITechniqueDefinitionAcceptor& operator=(const ITechniqueDefinitionAcceptor& other) = default;
|
||||
ITechniqueDefinitionAcceptor& operator=(ITechniqueDefinitionAcceptor&& other) noexcept = default;
|
||||
|
||||
virtual void AcceptNextPass() = 0;
|
||||
virtual bool AcceptEndPass(std::string& errorMessage) = 0;
|
||||
|
||||
virtual bool AcceptStateMap(const std::string& stateMapName, std::string& errorMessage) = 0;
|
||||
|
||||
virtual bool AcceptVertexShader(const std::string& vertexShaderName, std::string& errorMessage) = 0;
|
||||
virtual bool AcceptPixelShader(const std::string& pixelShaderName, std::string& errorMessage) = 0;
|
||||
|
||||
virtual bool
|
||||
AcceptShaderConstantArgument(ShaderSelector shader, ShaderArgument shaderArgument, ShaderArgumentCodeSource source, std::string& errorMessage) = 0;
|
||||
virtual bool
|
||||
AcceptShaderSamplerArgument(ShaderSelector shader, ShaderArgument shaderArgument, ShaderArgumentCodeSource source, std::string& errorMessage) = 0;
|
||||
virtual bool AcceptShaderLiteralArgument(ShaderSelector shader,
|
||||
ShaderArgument shaderArgument,
|
||||
ShaderArgumentLiteralSource source,
|
||||
std::string& errorMessage) = 0;
|
||||
virtual bool AcceptShaderMaterialArgument(ShaderSelector shader,
|
||||
ShaderArgument shaderArgument,
|
||||
ShaderArgumentMaterialSource source,
|
||||
std::string& errorMessage) = 0;
|
||||
|
||||
virtual bool AcceptVertexStreamRouting(const std::string& destination, const std::string& source, std::string& errorMessage) = 0;
|
||||
};
|
||||
} // namespace techset
|
||||
@@ -1,39 +0,0 @@
|
||||
#include "TechniqueFileReader.h"
|
||||
|
||||
#include "Parsing/Impl/CommentRemovingStreamProxy.h"
|
||||
#include "Parsing/Impl/ParserSingleInputStream.h"
|
||||
#include "Parsing/Simple/SimpleLexer.h"
|
||||
#include "Techset/Parsing/TechniqueFileParser.h"
|
||||
#include "Utils/Logging/Log.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace techset;
|
||||
|
||||
TechniqueFileReader::TechniqueFileReader(std::istream& stream, std::string fileName, ITechniqueDefinitionAcceptor* acceptor)
|
||||
: m_file_name(std::move(fileName)),
|
||||
m_acceptor(acceptor)
|
||||
{
|
||||
m_base_stream = std::make_unique<ParserSingleInputStream>(stream, m_file_name);
|
||||
m_comment_proxy = std::make_unique<CommentRemovingStreamProxy>(m_base_stream.get());
|
||||
}
|
||||
|
||||
bool TechniqueFileReader::ReadTechniqueDefinition() const
|
||||
{
|
||||
SimpleLexer::Config lexerConfig;
|
||||
lexerConfig.m_emit_new_line_tokens = false;
|
||||
lexerConfig.m_read_strings = true;
|
||||
lexerConfig.m_string_escape_sequences = false;
|
||||
lexerConfig.m_read_integer_numbers = true;
|
||||
lexerConfig.m_read_floating_point_numbers = true;
|
||||
const auto lexer = std::make_unique<SimpleLexer>(m_comment_proxy.get(), std::move(lexerConfig));
|
||||
|
||||
const auto parser = std::make_unique<TechniqueParser>(lexer.get(), m_acceptor);
|
||||
|
||||
const auto success = parser->Parse();
|
||||
if (success)
|
||||
return true;
|
||||
|
||||
con::error("Parsing technique file \"{}\" failed!", m_file_name);
|
||||
return false;
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Parsing/IParserLineStream.h"
|
||||
#include "TechniqueDefinitionAcceptor.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace techset
|
||||
{
|
||||
class TechniqueFileReader
|
||||
{
|
||||
public:
|
||||
TechniqueFileReader(std::istream& stream, std::string fileName, ITechniqueDefinitionAcceptor* acceptor);
|
||||
|
||||
[[nodiscard]] bool ReadTechniqueDefinition() const;
|
||||
|
||||
private:
|
||||
std::string m_file_name;
|
||||
ITechniqueDefinitionAcceptor* m_acceptor;
|
||||
std::unique_ptr<IParserLineStream> m_base_stream;
|
||||
std::unique_ptr<IParserLineStream> m_comment_proxy;
|
||||
};
|
||||
} // namespace techset
|
||||
@@ -67,11 +67,15 @@ AssetCreationContext::AssetCreationContext(Zone& zone, const AssetCreatorCollect
|
||||
: ZoneAssetCreationStateContainer(zone),
|
||||
m_zone(zone),
|
||||
m_forced_asset_pools(std::make_unique<ZoneAssetPools>(zone, zone.m_priority)),
|
||||
m_sub_asset_pools(IGame::GetGameById(zone.m_game_id)->GetSubAssetTypeCount()),
|
||||
m_creators(creators),
|
||||
m_ignored_asset_lookup(ignoredAssetLookup),
|
||||
m_forced_load_depth(0u)
|
||||
{
|
||||
const auto subAssetTypeCount = IGame::GetGameById(zone.m_game_id)->GetSubAssetTypeCount();
|
||||
m_sub_asset_pools.resize(subAssetTypeCount);
|
||||
|
||||
for (asset_type_t subAssetType = 0; subAssetType < subAssetTypeCount; subAssetType++)
|
||||
m_sub_asset_pools[subAssetType] = std::make_unique<AssetPool>();
|
||||
}
|
||||
|
||||
XAssetInfoGeneric* AssetCreationContext::AddAssetGeneric(GenericAssetRegistration registration) const
|
||||
|
||||
@@ -67,106 +67,79 @@ namespace
|
||||
for (auto streamIndex = 0u; streamIndex < streamCount; streamIndex++)
|
||||
{
|
||||
const auto& routing = vertexDecl->routing.data[streamIndex];
|
||||
commonRouting.emplace_back(techset::CommonStreamRouting{
|
||||
.m_source = static_cast<techset::CommonStreamSource>(routing.source),
|
||||
.m_destination = static_cast<techset::CommonStreamDestination>(routing.dest),
|
||||
});
|
||||
commonRouting.emplace_back(static_cast<techset::CommonStreamSource>(routing.source),
|
||||
static_cast<techset::CommonStreamDestination>(routing.dest));
|
||||
}
|
||||
}
|
||||
|
||||
return techset::CommonVertexDeclaration{
|
||||
.m_routing = std::move(commonRouting),
|
||||
};
|
||||
return techset::CommonVertexDeclaration(std::move(commonRouting));
|
||||
}
|
||||
|
||||
techset::CommonShaderArg ConvertToCommonArg(const MaterialShaderArgument& arg)
|
||||
{
|
||||
const techset::CommonShaderArgDestination destination{.dx9 = {.m_destination_register = arg.dest}};
|
||||
|
||||
switch (arg.type)
|
||||
{
|
||||
case MTL_ARG_CODE_VERTEX_CONST:
|
||||
case MTL_ARG_CODE_PIXEL_CONST:
|
||||
return techset::CommonShaderArg{
|
||||
.m_type = techset::CommonShaderArgType::CODE_CONST,
|
||||
.m_destination = {.dx9 =
|
||||
{
|
||||
.m_destination_register = arg.dest,
|
||||
}},
|
||||
.m_value = {
|
||||
const techset::CommonShaderArgValue value{
|
||||
.code_const_source = static_cast<techset::CommonCodeConstSource>(arg.u.codeConst.index),
|
||||
}
|
||||
};
|
||||
|
||||
return techset::CommonShaderArg(commonArgumentTypes[arg.type], destination, value);
|
||||
}
|
||||
|
||||
case MTL_ARG_MATERIAL_VERTEX_CONST:
|
||||
case MTL_ARG_MATERIAL_PIXEL_CONST:
|
||||
return techset::CommonShaderArg{
|
||||
.m_type = techset::CommonShaderArgType::MATERIAL_CONST,
|
||||
.m_destination = {.dx9 =
|
||||
{
|
||||
.m_destination_register = arg.dest,
|
||||
}},
|
||||
.m_value = {
|
||||
const techset::CommonShaderArgValue value{
|
||||
.name_hash = arg.u.nameHash,
|
||||
}
|
||||
};
|
||||
|
||||
return techset::CommonShaderArg(commonArgumentTypes[arg.type], destination, value);
|
||||
}
|
||||
|
||||
case MTL_ARG_CODE_PIXEL_SAMPLER:
|
||||
return techset::CommonShaderArg{
|
||||
.m_type = techset::CommonShaderArgType::CODE_SAMPLER,
|
||||
.m_destination = {.dx9 =
|
||||
{
|
||||
.m_destination_register = arg.dest,
|
||||
}},
|
||||
.m_value = {
|
||||
const techset::CommonShaderArgValue value{
|
||||
.code_sampler_source = static_cast<techset::CommonCodeSamplerSource>(arg.u.codeSampler),
|
||||
}
|
||||
};
|
||||
|
||||
case MTL_ARG_MATERIAL_PIXEL_SAMPLER:
|
||||
return techset::CommonShaderArg{
|
||||
.m_type = techset::CommonShaderArgType::MATERIAL_SAMPLER,
|
||||
.m_destination = {.dx9 =
|
||||
{
|
||||
.m_destination_register = arg.dest,
|
||||
}},
|
||||
.m_value = {
|
||||
.name_hash = arg.u.nameHash,
|
||||
return techset::CommonShaderArg(commonArgumentTypes[arg.type], destination, value);
|
||||
}
|
||||
|
||||
case MTL_ARG_MATERIAL_PIXEL_SAMPLER:
|
||||
{
|
||||
const techset::CommonShaderArgValue value{
|
||||
.name_hash = arg.u.nameHash,
|
||||
};
|
||||
|
||||
return techset::CommonShaderArg(commonArgumentTypes[arg.type], destination, value);
|
||||
}
|
||||
|
||||
default:
|
||||
case MTL_ARG_LITERAL_VERTEX_CONST:
|
||||
case MTL_ARG_LITERAL_PIXEL_CONST:
|
||||
{
|
||||
techset::CommonShaderArgValue value{};
|
||||
if (arg.u.literalConst)
|
||||
{
|
||||
return techset::CommonShaderArg{
|
||||
.m_type = techset::CommonShaderArgType::LITERAL_CONST,
|
||||
.m_destination = {.dx9 =
|
||||
{
|
||||
.m_destination_register = arg.dest,
|
||||
}},
|
||||
.m_value = {
|
||||
.literal_value =
|
||||
{
|
||||
value.literal_value = {
|
||||
(*arg.u.literalConst)[0],
|
||||
(*arg.u.literalConst)[1],
|
||||
(*arg.u.literalConst)[2],
|
||||
(*arg.u.literalConst)[3],
|
||||
}, }
|
||||
};
|
||||
}
|
||||
|
||||
return techset::CommonShaderArg{
|
||||
.m_type = techset::CommonShaderArgType::LITERAL_CONST,
|
||||
.m_destination = {.dx9 =
|
||||
{
|
||||
.m_destination_register = arg.dest,
|
||||
}},
|
||||
.m_value = {},
|
||||
};
|
||||
return techset::CommonShaderArg(commonArgumentTypes[arg.type], destination, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
techset::CommonTechniqueShader ConvertToCommonShader(const MaterialPass& pass, const MaterialVertexShader* vertexShader)
|
||||
techset::CommonTechniqueShader ConvertToCommonShader(const MaterialVertexShader* vertexShader)
|
||||
{
|
||||
techset::CommonTechniqueShader result{};
|
||||
if (!vertexShader)
|
||||
@@ -177,34 +150,16 @@ namespace
|
||||
|
||||
if (vertexShader->prog.loadDef.program)
|
||||
{
|
||||
result.m_shader_bin = vertexShader->prog.loadDef.program;
|
||||
result.m_shader_bin_size = vertexShader->prog.loadDef.programSize * sizeof(uint32_t);
|
||||
}
|
||||
|
||||
if (pass.args)
|
||||
{
|
||||
const size_t totalArgCount = pass.perPrimArgCount + pass.perObjArgCount + pass.stableArgCount;
|
||||
for (auto argIndex = 0uz; argIndex < totalArgCount; argIndex++)
|
||||
{
|
||||
const auto& arg = pass.args[argIndex];
|
||||
|
||||
switch (arg.type)
|
||||
{
|
||||
case MTL_ARG_CODE_VERTEX_CONST:
|
||||
case MTL_ARG_MATERIAL_VERTEX_CONST:
|
||||
case MTL_ARG_LITERAL_VERTEX_CONST:
|
||||
result.m_args.emplace_back(ConvertToCommonArg(arg));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
result.m_bin = techset::CommonTechniqueShaderBin{
|
||||
.m_shader_bin = vertexShader->prog.loadDef.program,
|
||||
.m_shader_bin_size = vertexShader->prog.loadDef.programSize * sizeof(uint32_t),
|
||||
};
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
techset::CommonTechniqueShader ConvertToCommonShader(const MaterialPass& pass, const MaterialPixelShader* pixelShader)
|
||||
techset::CommonTechniqueShader ConvertToCommonShader(const MaterialPixelShader* pixelShader)
|
||||
{
|
||||
techset::CommonTechniqueShader result{};
|
||||
if (!pixelShader)
|
||||
@@ -215,30 +170,10 @@ namespace
|
||||
|
||||
if (pixelShader->prog.loadDef.program)
|
||||
{
|
||||
result.m_shader_bin = pixelShader->prog.loadDef.program;
|
||||
result.m_shader_bin_size = pixelShader->prog.loadDef.programSize * sizeof(uint32_t);
|
||||
}
|
||||
|
||||
if (pass.args)
|
||||
{
|
||||
const size_t totalArgCount = pass.perPrimArgCount + pass.perObjArgCount + pass.stableArgCount;
|
||||
for (auto argIndex = 0uz; argIndex < totalArgCount; argIndex++)
|
||||
{
|
||||
const auto& arg = pass.args[argIndex];
|
||||
|
||||
switch (arg.type)
|
||||
{
|
||||
case MTL_ARG_CODE_PIXEL_CONST:
|
||||
case MTL_ARG_CODE_PIXEL_SAMPLER:
|
||||
case MTL_ARG_MATERIAL_PIXEL_CONST:
|
||||
case MTL_ARG_MATERIAL_PIXEL_SAMPLER:
|
||||
case MTL_ARG_LITERAL_PIXEL_CONST:
|
||||
result.m_args.emplace_back(ConvertToCommonArg(arg));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
result.m_bin = techset::CommonTechniqueShaderBin{
|
||||
.m_shader_bin = pixelShader->prog.loadDef.program,
|
||||
.m_shader_bin_size = pixelShader->prog.loadDef.programSize * sizeof(uint32_t),
|
||||
};
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -246,37 +181,34 @@ namespace
|
||||
|
||||
techset::CommonTechnique ConvertToCommonTechnique(const MaterialTechnique& technique)
|
||||
{
|
||||
std::vector<techset::CommonPass> passes;
|
||||
techset::CommonTechnique commonTechnique(technique.name ? technique.name : std::string(), technique.flags);
|
||||
|
||||
for (auto passIndex = 0u; passIndex < technique.passCount; passIndex++)
|
||||
{
|
||||
const auto& pass = technique.passArray[passIndex];
|
||||
techset::CommonPass commonPass(pass.customSamplerFlags,
|
||||
// No clue what the actual state map was
|
||||
"passthrough",
|
||||
ConvertToCommonShader(pass.vertexShader),
|
||||
ConvertToCommonShader(pass.pixelShader),
|
||||
ConvertToCommonVertexDeclaration(pass.vertexDecl));
|
||||
|
||||
passes.emplace_back(techset::CommonPass{
|
||||
.m_sampler_flags = pass.customSamplerFlags,
|
||||
.m_dx_version = techset::DxVersion::DX9,
|
||||
.m_vertex_shader = ConvertToCommonShader(pass, pass.vertexShader),
|
||||
.m_pixel_shader = ConvertToCommonShader(pass, pass.pixelShader),
|
||||
.m_vertex_declaration = ConvertToCommonVertexDeclaration(pass.vertexDecl),
|
||||
});
|
||||
if (pass.args)
|
||||
{
|
||||
const size_t totalArgCount = pass.perPrimArgCount + pass.perObjArgCount + pass.stableArgCount;
|
||||
commonPass.m_args.reserve(totalArgCount);
|
||||
for (auto argIndex = 0uz; argIndex < totalArgCount; argIndex++)
|
||||
commonPass.m_args.emplace_back(ConvertToCommonArg(pass.args[argIndex]));
|
||||
}
|
||||
|
||||
return techset::CommonTechnique{
|
||||
.m_name = technique.name ? technique.name : std::string(),
|
||||
.m_flags = technique.flags,
|
||||
.m_passes = std::move(passes),
|
||||
};
|
||||
commonTechnique.m_passes.emplace_back(std::move(commonPass));
|
||||
}
|
||||
|
||||
return commonTechnique;
|
||||
}
|
||||
|
||||
void DumpTechniques(AssetDumpingContext& context, const MaterialTechniqueSet& techset)
|
||||
{
|
||||
static techset::CommonCodeSourceInfos codeSourceInfos(commonCodeConstSources,
|
||||
std::extent_v<decltype(commonCodeConstSources)>,
|
||||
commonCodeSamplerSources,
|
||||
std::extent_v<decltype(commonCodeSamplerSources)>);
|
||||
static techset::CommonStreamRoutingInfos routingInfos(
|
||||
streamRoutingSources, std::extent_v<decltype(streamRoutingSources)>, streamRoutingDestinations, std::extent_v<decltype(streamRoutingDestinations)>);
|
||||
|
||||
auto* techniqueState = context.GetZoneAssetDumperState<techset::TechniqueDumpingZoneState>();
|
||||
const auto* materialConstantState = context.GetZoneAssetDumperState<MaterialConstantZoneState>();
|
||||
for (const auto* technique : techset.techniques)
|
||||
@@ -285,7 +217,8 @@ namespace
|
||||
{
|
||||
const auto commonTechnique = ConvertToCommonTechnique(*technique);
|
||||
|
||||
techset::DumpCommonTechnique(context, commonTechnique, codeSourceInfos, routingInfos, *materialConstantState);
|
||||
techset::DumpCommonTechnique(
|
||||
context, commonTechnique, techset::DxVersion::DX9, commonCodeSourceInfos, commonRoutingInfos, *materialConstantState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
#include "Techset/ShaderDumpingZoneState.h"
|
||||
#include "Techset/TechniqueDumpingZoneState.h"
|
||||
|
||||
#include <unordered_set>
|
||||
|
||||
using namespace T6;
|
||||
|
||||
namespace
|
||||
@@ -66,16 +64,12 @@ namespace
|
||||
for (auto streamIndex = 0u; streamIndex < streamCount; streamIndex++)
|
||||
{
|
||||
const auto& routing = vertexDecl->routing.data[streamIndex];
|
||||
commonRouting.emplace_back(techset::CommonStreamRouting{
|
||||
.m_source = static_cast<techset::CommonStreamSource>(routing.source),
|
||||
.m_destination = static_cast<techset::CommonStreamDestination>(routing.dest),
|
||||
});
|
||||
commonRouting.emplace_back(static_cast<techset::CommonStreamSource>(routing.source),
|
||||
static_cast<techset::CommonStreamDestination>(routing.dest));
|
||||
}
|
||||
}
|
||||
|
||||
return techset::CommonVertexDeclaration{
|
||||
.m_routing = std::move(commonRouting),
|
||||
};
|
||||
return techset::CommonVertexDeclaration(std::move(commonRouting));
|
||||
}
|
||||
|
||||
techset::CommonShaderArg ConvertToCommonArg(const MaterialShaderArgument& arg)
|
||||
@@ -84,100 +78,99 @@ namespace
|
||||
{
|
||||
case MTL_ARG_CODE_VERTEX_CONST:
|
||||
case MTL_ARG_CODE_PIXEL_CONST:
|
||||
return techset::CommonShaderArg{
|
||||
.m_type = techset::CommonShaderArgType::CODE_CONST,
|
||||
.m_destination = {.dx11 =
|
||||
{
|
||||
const techset::CommonShaderArgValue value{
|
||||
.code_const_source = static_cast<techset::CommonCodeConstSource>(arg.u.codeConst.index),
|
||||
};
|
||||
const techset::CommonShaderArgDestination destination = {
|
||||
.dx11 = {
|
||||
.m_location = arg.location.offset,
|
||||
.m_size = arg.size,
|
||||
.m_buffer = arg.buffer,
|
||||
}},
|
||||
.m_value = {
|
||||
.code_const_source = static_cast<techset::CommonCodeConstSource>(arg.u.codeConst.index),
|
||||
}
|
||||
};
|
||||
|
||||
return techset::CommonShaderArg(commonArgumentTypes[arg.type], destination, value);
|
||||
}
|
||||
|
||||
case MTL_ARG_MATERIAL_VERTEX_CONST:
|
||||
case MTL_ARG_MATERIAL_PIXEL_CONST:
|
||||
return techset::CommonShaderArg{
|
||||
.m_type = techset::CommonShaderArgType::MATERIAL_CONST,
|
||||
.m_destination = {.dx11 =
|
||||
{
|
||||
const techset::CommonShaderArgValue value{
|
||||
.name_hash = arg.u.nameHash,
|
||||
};
|
||||
const techset::CommonShaderArgDestination destination = {
|
||||
.dx11 = {
|
||||
.m_location = arg.location.offset,
|
||||
.m_size = arg.size,
|
||||
.m_buffer = arg.buffer,
|
||||
}},
|
||||
.m_value = {
|
||||
.name_hash = arg.u.nameHash,
|
||||
}
|
||||
};
|
||||
|
||||
return techset::CommonShaderArg(commonArgumentTypes[arg.type], destination, value);
|
||||
}
|
||||
|
||||
case MTL_ARG_CODE_PIXEL_SAMPLER:
|
||||
return techset::CommonShaderArg{
|
||||
.m_type = techset::CommonShaderArgType::CODE_SAMPLER,
|
||||
.m_destination = {.dx11 =
|
||||
{
|
||||
const techset::CommonShaderArgValue value{
|
||||
.code_sampler_source = static_cast<techset::CommonCodeSamplerSource>(arg.u.codeSampler),
|
||||
};
|
||||
const techset::CommonShaderArgDestination destination = {
|
||||
.dx11 = {
|
||||
.m_location = arg.location.samplerIndex,
|
||||
.m_size = arg.size,
|
||||
.m_buffer = arg.buffer,
|
||||
}},
|
||||
.m_value = {
|
||||
.code_sampler_source = static_cast<techset::CommonCodeSamplerSource>(arg.u.codeSampler),
|
||||
}
|
||||
};
|
||||
|
||||
return techset::CommonShaderArg(commonArgumentTypes[arg.type], destination, value);
|
||||
}
|
||||
|
||||
case MTL_ARG_MATERIAL_PIXEL_SAMPLER:
|
||||
return techset::CommonShaderArg{
|
||||
.m_type = techset::CommonShaderArgType::MATERIAL_SAMPLER,
|
||||
.m_destination = {.dx11 =
|
||||
{
|
||||
const techset::CommonShaderArgValue value{
|
||||
.name_hash = arg.u.nameHash,
|
||||
};
|
||||
const techset::CommonShaderArgDestination destination = {
|
||||
.dx11 = {
|
||||
.m_location = arg.location.samplerIndex,
|
||||
.m_size = arg.size,
|
||||
.m_buffer = arg.buffer,
|
||||
}},
|
||||
.m_value = {
|
||||
.name_hash = arg.u.nameHash,
|
||||
}
|
||||
};
|
||||
|
||||
return techset::CommonShaderArg(commonArgumentTypes[arg.type], destination, value);
|
||||
}
|
||||
|
||||
default:
|
||||
case MTL_ARG_LITERAL_VERTEX_CONST:
|
||||
case MTL_ARG_LITERAL_PIXEL_CONST:
|
||||
{
|
||||
techset::CommonShaderArgValue value{};
|
||||
if (arg.u.literalConst)
|
||||
{
|
||||
return techset::CommonShaderArg{
|
||||
.m_type = techset::CommonShaderArgType::LITERAL_CONST,
|
||||
.m_destination = {.dx11 =
|
||||
{
|
||||
.m_location = arg.location.offset,
|
||||
.m_size = arg.size,
|
||||
.m_buffer = arg.buffer,
|
||||
}},
|
||||
.m_value = {
|
||||
.literal_value =
|
||||
{
|
||||
value.literal_value = {
|
||||
(*arg.u.literalConst)[0],
|
||||
(*arg.u.literalConst)[1],
|
||||
(*arg.u.literalConst)[2],
|
||||
(*arg.u.literalConst)[3],
|
||||
}, }
|
||||
};
|
||||
}
|
||||
|
||||
return techset::CommonShaderArg{
|
||||
.m_type = techset::CommonShaderArgType::LITERAL_CONST,
|
||||
.m_destination = {.dx11 =
|
||||
{
|
||||
const techset::CommonShaderArgDestination destination = {
|
||||
.dx11 = {
|
||||
.m_location = arg.location.offset,
|
||||
.m_size = arg.size,
|
||||
.m_buffer = arg.buffer,
|
||||
}},
|
||||
.m_value = {},
|
||||
}
|
||||
};
|
||||
|
||||
return techset::CommonShaderArg(commonArgumentTypes[arg.type], destination, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
techset::CommonTechniqueShader ConvertToCommonShader(const MaterialPass& pass, const MaterialVertexShader* vertexShader)
|
||||
techset::CommonTechniqueShader ConvertToCommonShader(const MaterialVertexShader* vertexShader)
|
||||
{
|
||||
techset::CommonTechniqueShader result{};
|
||||
if (!vertexShader)
|
||||
@@ -188,34 +181,16 @@ namespace
|
||||
|
||||
if (vertexShader->prog.loadDef.program)
|
||||
{
|
||||
result.m_shader_bin = vertexShader->prog.loadDef.program;
|
||||
result.m_shader_bin_size = vertexShader->prog.loadDef.programSize;
|
||||
}
|
||||
|
||||
if (pass.args)
|
||||
{
|
||||
const size_t totalArgCount = pass.perPrimArgCount + pass.perObjArgCount + pass.stableArgCount;
|
||||
for (auto argIndex = 0uz; argIndex < totalArgCount; argIndex++)
|
||||
{
|
||||
const auto& arg = pass.args[argIndex];
|
||||
|
||||
switch (arg.type)
|
||||
{
|
||||
case MTL_ARG_CODE_VERTEX_CONST:
|
||||
case MTL_ARG_MATERIAL_VERTEX_CONST:
|
||||
case MTL_ARG_LITERAL_VERTEX_CONST:
|
||||
result.m_args.emplace_back(ConvertToCommonArg(arg));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
result.m_bin = techset::CommonTechniqueShaderBin{
|
||||
.m_shader_bin = vertexShader->prog.loadDef.program,
|
||||
.m_shader_bin_size = vertexShader->prog.loadDef.programSize,
|
||||
};
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
techset::CommonTechniqueShader ConvertToCommonShader(const MaterialPass& pass, const MaterialPixelShader* pixelShader)
|
||||
techset::CommonTechniqueShader ConvertToCommonShader(const MaterialPixelShader* pixelShader)
|
||||
{
|
||||
techset::CommonTechniqueShader result{};
|
||||
if (!pixelShader)
|
||||
@@ -226,30 +201,10 @@ namespace
|
||||
|
||||
if (pixelShader->prog.loadDef.program)
|
||||
{
|
||||
result.m_shader_bin = pixelShader->prog.loadDef.program;
|
||||
result.m_shader_bin_size = pixelShader->prog.loadDef.programSize;
|
||||
}
|
||||
|
||||
if (pass.args)
|
||||
{
|
||||
const size_t totalArgCount = pass.perPrimArgCount + pass.perObjArgCount + pass.stableArgCount;
|
||||
for (auto argIndex = 0uz; argIndex < totalArgCount; argIndex++)
|
||||
{
|
||||
const auto& arg = pass.args[argIndex];
|
||||
|
||||
switch (arg.type)
|
||||
{
|
||||
case MTL_ARG_CODE_PIXEL_CONST:
|
||||
case MTL_ARG_CODE_PIXEL_SAMPLER:
|
||||
case MTL_ARG_MATERIAL_PIXEL_CONST:
|
||||
case MTL_ARG_MATERIAL_PIXEL_SAMPLER:
|
||||
case MTL_ARG_LITERAL_PIXEL_CONST:
|
||||
result.m_args.emplace_back(ConvertToCommonArg(arg));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
result.m_bin = techset::CommonTechniqueShaderBin{
|
||||
.m_shader_bin = pixelShader->prog.loadDef.program,
|
||||
.m_shader_bin_size = pixelShader->prog.loadDef.programSize,
|
||||
};
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -257,37 +212,34 @@ namespace
|
||||
|
||||
techset::CommonTechnique ConvertToCommonTechnique(const MaterialTechnique& technique)
|
||||
{
|
||||
std::vector<techset::CommonPass> passes;
|
||||
techset::CommonTechnique commonTechnique(technique.name ? technique.name : std::string(), technique.flags);
|
||||
|
||||
for (auto passIndex = 0u; passIndex < technique.passCount; passIndex++)
|
||||
{
|
||||
const auto& pass = technique.passArray[passIndex];
|
||||
techset::CommonPass commonPass(pass.customSamplerFlags,
|
||||
// No clue what the actual state map was
|
||||
"passthrough",
|
||||
ConvertToCommonShader(pass.vertexShader),
|
||||
ConvertToCommonShader(pass.pixelShader),
|
||||
ConvertToCommonVertexDeclaration(pass.vertexDecl));
|
||||
|
||||
passes.emplace_back(techset::CommonPass{
|
||||
.m_sampler_flags = pass.customSamplerFlags,
|
||||
.m_dx_version = techset::DxVersion::DX11,
|
||||
.m_vertex_shader = ConvertToCommonShader(pass, pass.vertexShader),
|
||||
.m_pixel_shader = ConvertToCommonShader(pass, pass.pixelShader),
|
||||
.m_vertex_declaration = ConvertToCommonVertexDeclaration(pass.vertexDecl),
|
||||
});
|
||||
if (pass.args)
|
||||
{
|
||||
const size_t totalArgCount = pass.perPrimArgCount + pass.perObjArgCount + pass.stableArgCount;
|
||||
commonPass.m_args.reserve(totalArgCount);
|
||||
for (auto argIndex = 0uz; argIndex < totalArgCount; argIndex++)
|
||||
commonPass.m_args.emplace_back(ConvertToCommonArg(pass.args[argIndex]));
|
||||
}
|
||||
|
||||
return techset::CommonTechnique{
|
||||
.m_name = technique.name ? technique.name : std::string(),
|
||||
.m_flags = technique.flags,
|
||||
.m_passes = std::move(passes),
|
||||
};
|
||||
commonTechnique.m_passes.emplace_back(std::move(commonPass));
|
||||
}
|
||||
|
||||
return commonTechnique;
|
||||
}
|
||||
|
||||
void DumpTechniques(AssetDumpingContext& context, const MaterialTechniqueSet& techset)
|
||||
{
|
||||
static techset::CommonCodeSourceInfos codeSourceInfos(commonCodeConstSources,
|
||||
std::extent_v<decltype(commonCodeConstSources)>,
|
||||
commonCodeSamplerSources,
|
||||
std::extent_v<decltype(commonCodeSamplerSources)>);
|
||||
static techset::CommonStreamRoutingInfos routingInfos(
|
||||
streamRoutingSources, std::extent_v<decltype(streamRoutingSources)>, streamRoutingDestinations, std::extent_v<decltype(streamRoutingDestinations)>);
|
||||
|
||||
auto* techniqueState = context.GetZoneAssetDumperState<techset::TechniqueDumpingZoneState>();
|
||||
const auto* materialConstantState = context.GetZoneAssetDumperState<MaterialConstantZoneState>();
|
||||
for (const auto* technique : techset.techniques)
|
||||
@@ -296,7 +248,8 @@ namespace
|
||||
{
|
||||
const auto commonTechnique = ConvertToCommonTechnique(*technique);
|
||||
|
||||
techset::DumpCommonTechnique(context, commonTechnique, codeSourceInfos, routingInfos, *materialConstantState);
|
||||
techset::DumpCommonTechnique(
|
||||
context, commonTechnique, techset::DxVersion::DX11, commonCodeSourceInfos, commonRoutingInfos, *materialConstantState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,10 +23,12 @@ namespace
|
||||
{
|
||||
public:
|
||||
TechniqueFileWriter(std::ostream& stream,
|
||||
const DxVersion dxVersion,
|
||||
const CommonCodeSourceInfos& codeSourceInfos,
|
||||
const CommonStreamRoutingInfos& routingInfos,
|
||||
const AbstractMaterialConstantZoneState& constantZoneState)
|
||||
: AbstractTextDumper(stream),
|
||||
m_dx_version(dxVersion),
|
||||
m_code_source_infos(codeSourceInfos),
|
||||
m_routing_infos(routingInfos),
|
||||
m_constant_zone_state(constantZoneState)
|
||||
@@ -73,8 +75,8 @@ namespace
|
||||
#endif
|
||||
|
||||
DumpStateMap();
|
||||
DumpShader(technique, pass.m_vertex_shader, TechniqueShaderType::VERTEX_SHADER, pass.m_dx_version);
|
||||
DumpShader(technique, pass.m_pixel_shader, TechniqueShaderType::PIXEL_SHADER, pass.m_dx_version);
|
||||
DumpShader(technique, pass.m_vertex_shader, TechniqueShaderType::VERTEX_SHADER, m_dx_version);
|
||||
DumpShader(technique, pass.m_pixel_shader, TechniqueShaderType::PIXEL_SHADER, m_dx_version);
|
||||
DumpVertexDecl(pass.m_vertex_declaration);
|
||||
|
||||
DecIndent();
|
||||
@@ -91,7 +93,7 @@ namespace
|
||||
|
||||
void DumpShader(const CommonTechnique& technique, const CommonTechniqueShader& shader, const TechniqueShaderType shaderType, const DxVersion dxVersion)
|
||||
{
|
||||
if (!shader.m_shader_bin)
|
||||
if (!shader.m_bin || !shader.m_bin->m_shader_bin)
|
||||
{
|
||||
if (!shader.m_name.empty())
|
||||
{
|
||||
@@ -105,7 +107,7 @@ namespace
|
||||
unsigned versionMajor, versionMinor;
|
||||
if (dxVersion == DxVersion::DX9)
|
||||
{
|
||||
const auto shaderInfo = d3d9::ShaderAnalyser::GetShaderInfo(shader.m_shader_bin, shader.m_shader_bin_size);
|
||||
const auto shaderInfo = d3d9::ShaderAnalyser::GetShaderInfo(shader.m_bin->m_shader_bin, shader.m_bin->m_shader_bin_size);
|
||||
assert(shaderInfo);
|
||||
if (!shaderInfo)
|
||||
return;
|
||||
@@ -121,7 +123,7 @@ namespace
|
||||
else
|
||||
{
|
||||
assert(dxVersion == DxVersion::DX11);
|
||||
const auto shaderInfo = d3d11::ShaderAnalyser::GetShaderInfo(shader.m_shader_bin, shader.m_shader_bin_size);
|
||||
const auto shaderInfo = d3d11::ShaderAnalyser::GetShaderInfo(shader.m_bin->m_shader_bin, shader.m_bin->m_shader_bin_size);
|
||||
assert(shaderInfo);
|
||||
if (!shaderInfo)
|
||||
return;
|
||||
@@ -385,6 +387,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
DxVersion m_dx_version;
|
||||
const CommonCodeSourceInfos& m_code_source_infos;
|
||||
const CommonStreamRoutingInfos& m_routing_infos;
|
||||
const AbstractMaterialConstantZoneState& m_constant_zone_state;
|
||||
@@ -395,6 +398,7 @@ namespace techset
|
||||
{
|
||||
void DumpCommonTechnique(const AssetDumpingContext& context,
|
||||
const CommonTechnique& technique,
|
||||
const DxVersion dxVersion,
|
||||
const CommonCodeSourceInfos& codeSourceInfos,
|
||||
const CommonStreamRoutingInfos& routingInfos,
|
||||
const AbstractMaterialConstantZoneState& constantZoneState)
|
||||
@@ -402,7 +406,7 @@ namespace techset
|
||||
const auto techniqueFile = context.OpenAssetFile(GetFileNameForTechniqueName(technique.m_name));
|
||||
if (techniqueFile)
|
||||
{
|
||||
TechniqueFileWriter writer(*techniqueFile, codeSourceInfos, routingInfos, constantZoneState);
|
||||
TechniqueFileWriter writer(*techniqueFile, dxVersion, codeSourceInfos, routingInfos, constantZoneState);
|
||||
writer.DumpTechnique(technique);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace techset
|
||||
{
|
||||
void DumpCommonTechnique(const AssetDumpingContext& context,
|
||||
const CommonTechnique& technique,
|
||||
DxVersion dxVersion,
|
||||
const CommonCodeSourceInfos& codeSourceInfos,
|
||||
const CommonStreamRoutingInfos& routingInfos,
|
||||
const AbstractMaterialConstantZoneState& constantZoneState);
|
||||
|
||||
Reference in New Issue
Block a user