2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2026-03-16 09:53:04 +00:00

Merge pull request #713 from Laupetin/feature/t5-techniques

feat: t5 techset compiling
This commit is contained in:
Jan
2026-03-15 16:06:28 +01:00
committed by GitHub
23 changed files with 258 additions and 328 deletions

View File

@@ -207,6 +207,11 @@ namespace T5
using AssetDDL = Asset<ASSET_TYPE_DDL, ddlRoot_t>; using AssetDDL = Asset<ASSET_TYPE_DDL, ddlRoot_t>;
using AssetGlasses = Asset<ASSET_TYPE_GLASSES, Glasses>; using AssetGlasses = Asset<ASSET_TYPE_GLASSES, Glasses>;
using AssetEmblemSet = Asset<ASSET_TYPE_EMBLEMSET, EmblemSet>; using AssetEmblemSet = Asset<ASSET_TYPE_EMBLEMSET, EmblemSet>;
using SubAssetTechnique = SubAsset<SUB_ASSET_TYPE_TECHNIQUE, 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 T5 } // namespace T5
DEFINE_ASSET_NAME_ACCESSOR(T5::AssetPhysPreset, name); DEFINE_ASSET_NAME_ACCESSOR(T5::AssetPhysPreset, name);

View File

@@ -1487,6 +1487,16 @@ namespace T5
MaterialArgumentDef u; MaterialArgumentDef u;
}; };
enum CustomSampler
{
CUSTOM_SAMPLER_REFLECTION_PROBE = 0x0,
CUSTOM_SAMPLER_LIGHTMAP_PRIMARY = 0x1,
CUSTOM_SAMPLER_LIGHTMAP_SECONDARY = 0x2,
CUSTOM_SAMPLER_LIGHTMAP_SECONDARYB = 0x3,
CUSTOM_SAMPLER_COUNT
};
enum MaterialType : unsigned char enum MaterialType : unsigned char
{ {
MTL_TYPE_DEFAULT = 0x0, MTL_TYPE_DEFAULT = 0x0,
@@ -1506,16 +1516,16 @@ namespace T5
enum TechniqueFlags enum TechniqueFlags
{ {
TECHNIQUE_FLAG_1 = 0x1, MTL_TECHFLAG_NEEDS_RESOLVED_POST_SUN = 0x1,
TECHNIQUE_FLAG_2 = 0x2, MTL_TECHFLAG_NEEDS_RESOLVED_SCENE = 0x2,
TECHNIQUE_FLAG_4 = 0x4, MTL_TECHFLAG_ZPREPASS = 0x4,
// Vertex decl has optional source // Vertex decl has optional source
TECHNIQUE_FLAG_8 = 0x8, MTL_TECHFLAG_DECL_HAS_OPTIONAL_SOURCE = 0x8,
TECHNIQUE_FLAG_10 = 0x10, MTL_TECHFLAG_USES_LIGHT_SPOT_FACTORS = 0x10,
TECHNIQUE_FLAG_20 = 0x20, MTL_TECHFLAG_USES_GRASS = 0x20,
TECHNIQUE_FLAG_40 = 0x40, MTL_TECHFLAG_USES_FLOATZ = 0x40,
// Any material that has statebits according to any of the following sets this: // Any material that has statebits according to any of the following sets this:
// - GFXS1_DEPTHWRITE set // - GFXS1_DEPTHWRITE set
@@ -1523,8 +1533,10 @@ namespace T5
// - Any polygon offset that is not GFXS1_POLYGON_OFFSET_0 // - Any polygon offset that is not GFXS1_POLYGON_OFFSET_0
TECHNIQUE_FLAG_80 = 0x80, TECHNIQUE_FLAG_80 = 0x80,
TECHNIQUE_FLAG_100 = 0x100, // Uses marksHitNormal
TECHNIQUE_FLAG_200 = 0x200, MTL_TECHFLAG_USES_MARKS_HIT_NORMAL = 0x100,
// Uses __characterCharredAmount or destructibleParms. Not sure how those two relate?
MTL_TECHFLAG_200 = 0x200,
}; };
struct MaterialPass struct MaterialPass

View File

@@ -2,6 +2,7 @@
#include "Game/T5/T5.h" #include "Game/T5/T5.h"
#include "Techset/CommonTechnique.h" #include "Techset/CommonTechnique.h"
#include "Techset/CommonTechset.h"
namespace T5 namespace T5
{ {
@@ -138,6 +139,7 @@ namespace T5
"impact mask", "impact mask",
}; };
static_assert(std::extent_v<decltype(techniqueTypeNames)> == TECHNIQUE_COUNT); static_assert(std::extent_v<decltype(techniqueTypeNames)> == TECHNIQUE_COUNT);
static inline techset::CommonTechniqueTypeNames commonTechniqueTypeNames(techniqueTypeNames, std::extent_v<decltype(techniqueTypeNames)>);
static techset::CommonStreamRoutingSourceInfo streamRoutingSources[]{ static techset::CommonStreamRoutingSourceInfo streamRoutingSources[]{
{ {
@@ -312,6 +314,8 @@ namespace T5
.accessor = "lightSpotFactors", .accessor = "lightSpotFactors",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
.techFlags = MTL_TECHFLAG_USES_LIGHT_SPOT_FACTORS,
.techFlagShaderType = techset::CommonTechniqueShaderType::PIXEL,
}, },
{ {
.value = CONST_SRC_CODE_LIGHT_ATTENUATION, .value = CONST_SRC_CODE_LIGHT_ATTENUATION,
@@ -726,24 +730,32 @@ namespace T5
.accessor = "grassParms", .accessor = "grassParms",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
.techFlags = MTL_TECHFLAG_USES_GRASS,
.techFlagShaderType = techset::CommonTechniqueShaderType::VERTEX,
}, },
{ {
.value = CONST_SRC_CODE_GRASS_FORCE0, .value = CONST_SRC_CODE_GRASS_FORCE0,
.accessor = "grassForce0", .accessor = "grassForce0",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
.techFlags = MTL_TECHFLAG_USES_GRASS,
.techFlagShaderType = techset::CommonTechniqueShaderType::VERTEX,
}, },
{ {
.value = CONST_SRC_CODE_GRASS_FORCE1, .value = CONST_SRC_CODE_GRASS_FORCE1,
.accessor = "grassForce1", .accessor = "grassForce1",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
.techFlags = MTL_TECHFLAG_USES_GRASS,
.techFlagShaderType = techset::CommonTechniqueShaderType::VERTEX,
}, },
{ {
.value = CONST_SRC_CODE_GRASS_WIND_FORCE0, .value = CONST_SRC_CODE_GRASS_WIND_FORCE0,
.accessor = "grassWindForce0", .accessor = "grassWindForce0",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
.techFlags = MTL_TECHFLAG_USES_GRASS,
.techFlagShaderType = techset::CommonTechniqueShaderType::VERTEX,
}, },
{ {
.value = CONST_SRC_CODE_MOTIONBLUR_DIRECTION_AND_MAGNITUDE, .value = CONST_SRC_CODE_MOTIONBLUR_DIRECTION_AND_MAGNITUDE,
@@ -834,6 +846,8 @@ namespace T5
.accessor = "destructibleParms", .accessor = "destructibleParms",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
.techFlags = MTL_TECHFLAG_200,
.techFlagShaderType = techset::CommonTechniqueShaderType::VERTEX,
}, },
{ {
.value = CONST_SRC_CODE_CLOUD_WORLD_AREA, .value = CONST_SRC_CODE_CLOUD_WORLD_AREA,
@@ -858,6 +872,8 @@ namespace T5
.accessor = "__characterCharredAmount", .accessor = "__characterCharredAmount",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
.techFlags = MTL_TECHFLAG_200,
.techFlagShaderType = techset::CommonTechniqueShaderType::VERTEX,
}, },
{ {
.value = CONST_SRC_CODE_TREECANOPY_PARMS, .value = CONST_SRC_CODE_TREECANOPY_PARMS,
@@ -870,6 +886,8 @@ namespace T5
.accessor = "marksHitNormal", .accessor = "marksHitNormal",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
.techFlags = MTL_TECHFLAG_USES_MARKS_HIT_NORMAL,
.techFlagShaderType = techset::CommonTechniqueShaderType::VERTEX,
}, },
{ {
.value = CONST_SRC_CODE_POSTFX_CONTROL0, .value = CONST_SRC_CODE_POSTFX_CONTROL0,
@@ -1332,192 +1350,224 @@ namespace T5
.accessor = "worldMatrix", .accessor = "worldMatrix",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
.transposedMatrix = CONST_SRC_CODE_TRANSPOSE_WORLD_MATRIX,
}, },
{ {
.value = CONST_SRC_CODE_INVERSE_WORLD_MATRIX, .value = CONST_SRC_CODE_INVERSE_WORLD_MATRIX,
.accessor = "inverseWorldMatrix", .accessor = "inverseWorldMatrix",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
.transposedMatrix = CONST_SRC_CODE_INVERSE_TRANSPOSE_WORLD_MATRIX,
}, },
{ {
.value = CONST_SRC_CODE_TRANSPOSE_WORLD_MATRIX, .value = CONST_SRC_CODE_TRANSPOSE_WORLD_MATRIX,
.accessor = "transposeWorldMatrix", .accessor = "transposeWorldMatrix",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
.transposedMatrix = CONST_SRC_CODE_WORLD_MATRIX,
}, },
{ {
.value = CONST_SRC_CODE_INVERSE_TRANSPOSE_WORLD_MATRIX, .value = CONST_SRC_CODE_INVERSE_TRANSPOSE_WORLD_MATRIX,
.accessor = "inverseTransposeWorldMatrix", .accessor = "inverseTransposeWorldMatrix",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
.transposedMatrix = CONST_SRC_CODE_INVERSE_WORLD_MATRIX,
}, },
{ {
.value = CONST_SRC_CODE_VIEW_MATRIX, .value = CONST_SRC_CODE_VIEW_MATRIX,
.accessor = "viewMatrix", .accessor = "viewMatrix",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
.transposedMatrix = CONST_SRC_CODE_TRANSPOSE_VIEW_MATRIX,
}, },
{ {
.value = CONST_SRC_CODE_INVERSE_VIEW_MATRIX, .value = CONST_SRC_CODE_INVERSE_VIEW_MATRIX,
.accessor = "inverseViewMatrix", .accessor = "inverseViewMatrix",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
.transposedMatrix = CONST_SRC_CODE_INVERSE_TRANSPOSE_VIEW_MATRIX,
}, },
{ {
.value = CONST_SRC_CODE_TRANSPOSE_VIEW_MATRIX, .value = CONST_SRC_CODE_TRANSPOSE_VIEW_MATRIX,
.accessor = "transposeViewMatrix", .accessor = "transposeViewMatrix",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
.transposedMatrix = CONST_SRC_CODE_VIEW_MATRIX,
}, },
{ {
.value = CONST_SRC_CODE_INVERSE_TRANSPOSE_VIEW_MATRIX, .value = CONST_SRC_CODE_INVERSE_TRANSPOSE_VIEW_MATRIX,
.accessor = "inverseTransposeViewMatrix", .accessor = "inverseTransposeViewMatrix",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
.transposedMatrix = CONST_SRC_CODE_INVERSE_VIEW_MATRIX,
}, },
{ {
.value = CONST_SRC_CODE_PROJECTION_MATRIX, .value = CONST_SRC_CODE_PROJECTION_MATRIX,
.accessor = "projectionMatrix", .accessor = "projectionMatrix",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
.transposedMatrix = CONST_SRC_CODE_TRANSPOSE_PROJECTION_MATRIX,
}, },
{ {
.value = CONST_SRC_CODE_INVERSE_PROJECTION_MATRIX, .value = CONST_SRC_CODE_INVERSE_PROJECTION_MATRIX,
.accessor = "inverseProjectionMatrix", .accessor = "inverseProjectionMatrix",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
.transposedMatrix = CONST_SRC_CODE_INVERSE_TRANSPOSE_PROJECTION_MATRIX,
}, },
{ {
.value = CONST_SRC_CODE_TRANSPOSE_PROJECTION_MATRIX, .value = CONST_SRC_CODE_TRANSPOSE_PROJECTION_MATRIX,
.accessor = "transposeProjectionMatrix", .accessor = "transposeProjectionMatrix",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
.transposedMatrix = CONST_SRC_CODE_PROJECTION_MATRIX,
}, },
{ {
.value = CONST_SRC_CODE_INVERSE_TRANSPOSE_PROJECTION_MATRIX, .value = CONST_SRC_CODE_INVERSE_TRANSPOSE_PROJECTION_MATRIX,
.accessor = "inverseTransposeProjectionMatrix", .accessor = "inverseTransposeProjectionMatrix",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
.transposedMatrix = CONST_SRC_CODE_INVERSE_PROJECTION_MATRIX,
}, },
{ {
.value = CONST_SRC_CODE_WORLD_VIEW_MATRIX, .value = CONST_SRC_CODE_WORLD_VIEW_MATRIX,
.accessor = "worldViewMatrix", .accessor = "worldViewMatrix",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
.transposedMatrix = CONST_SRC_CODE_TRANSPOSE_WORLD_VIEW_MATRIX,
}, },
{ {
.value = CONST_SRC_CODE_INVERSE_WORLD_VIEW_MATRIX, .value = CONST_SRC_CODE_INVERSE_WORLD_VIEW_MATRIX,
.accessor = "inverseWorldViewMatrix", .accessor = "inverseWorldViewMatrix",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
.transposedMatrix = CONST_SRC_CODE_INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX,
}, },
{ {
.value = CONST_SRC_CODE_TRANSPOSE_WORLD_VIEW_MATRIX, .value = CONST_SRC_CODE_TRANSPOSE_WORLD_VIEW_MATRIX,
.accessor = "transposeWorldViewMatrix", .accessor = "transposeWorldViewMatrix",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
.transposedMatrix = CONST_SRC_CODE_WORLD_VIEW_MATRIX,
}, },
{ {
.value = CONST_SRC_CODE_INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX, .value = CONST_SRC_CODE_INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX,
.accessor = "inverseTransposeWorldViewMatrix", .accessor = "inverseTransposeWorldViewMatrix",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
.transposedMatrix = CONST_SRC_CODE_INVERSE_WORLD_VIEW_MATRIX,
}, },
{ {
.value = CONST_SRC_CODE_VIEW_PROJECTION_MATRIX, .value = CONST_SRC_CODE_VIEW_PROJECTION_MATRIX,
.accessor = "viewProjectionMatrix", .accessor = "viewProjectionMatrix",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
.transposedMatrix = CONST_SRC_CODE_TRANSPOSE_VIEW_PROJECTION_MATRIX,
}, },
{ {
.value = CONST_SRC_CODE_INVERSE_VIEW_PROJECTION_MATRIX, .value = CONST_SRC_CODE_INVERSE_VIEW_PROJECTION_MATRIX,
.accessor = "inverseViewProjectionMatrix", .accessor = "inverseViewProjectionMatrix",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
.transposedMatrix = CONST_SRC_CODE_INVERSE_TRANSPOSE_VIEW_PROJECTION_MATRIX,
}, },
{ {
.value = CONST_SRC_CODE_TRANSPOSE_VIEW_PROJECTION_MATRIX, .value = CONST_SRC_CODE_TRANSPOSE_VIEW_PROJECTION_MATRIX,
.accessor = "transposeViewProjectionMatrix", .accessor = "transposeViewProjectionMatrix",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
.transposedMatrix = CONST_SRC_CODE_VIEW_PROJECTION_MATRIX,
}, },
{ {
.value = CONST_SRC_CODE_INVERSE_TRANSPOSE_VIEW_PROJECTION_MATRIX, .value = CONST_SRC_CODE_INVERSE_TRANSPOSE_VIEW_PROJECTION_MATRIX,
.accessor = "inverseTransposeViewProjectionMatrix", .accessor = "inverseTransposeViewProjectionMatrix",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
.transposedMatrix = CONST_SRC_CODE_INVERSE_VIEW_PROJECTION_MATRIX,
}, },
{ {
.value = CONST_SRC_CODE_WORLD_VIEW_PROJECTION_MATRIX, .value = CONST_SRC_CODE_WORLD_VIEW_PROJECTION_MATRIX,
.accessor = "worldViewProjectionMatrix", .accessor = "worldViewProjectionMatrix",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
.transposedMatrix = CONST_SRC_CODE_TRANSPOSE_WORLD_VIEW_PROJECTION_MATRIX,
}, },
{ {
.value = CONST_SRC_CODE_INVERSE_WORLD_VIEW_PROJECTION_MATRIX, .value = CONST_SRC_CODE_INVERSE_WORLD_VIEW_PROJECTION_MATRIX,
.accessor = "inverseWorldViewProjectionMatrix", .accessor = "inverseWorldViewProjectionMatrix",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
.transposedMatrix = CONST_SRC_CODE_INVERSE_TRANSPOSE_WORLD_VIEW_PROJECTION_MATRIX,
}, },
{ {
.value = CONST_SRC_CODE_TRANSPOSE_WORLD_VIEW_PROJECTION_MATRIX, .value = CONST_SRC_CODE_TRANSPOSE_WORLD_VIEW_PROJECTION_MATRIX,
.accessor = "transposeWorldViewProjectionMatrix", .accessor = "transposeWorldViewProjectionMatrix",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
.transposedMatrix = CONST_SRC_CODE_WORLD_VIEW_PROJECTION_MATRIX,
}, },
{ {
.value = CONST_SRC_CODE_INVERSE_TRANSPOSE_WORLD_VIEW_PROJECTION_MATRIX, .value = CONST_SRC_CODE_INVERSE_TRANSPOSE_WORLD_VIEW_PROJECTION_MATRIX,
.accessor = "inverseTransposeWorldViewProjectionMatrix", .accessor = "inverseTransposeWorldViewProjectionMatrix",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
.transposedMatrix = CONST_SRC_CODE_INVERSE_WORLD_VIEW_PROJECTION_MATRIX,
}, },
{ {
.value = CONST_SRC_CODE_SHADOW_LOOKUP_MATRIX, .value = CONST_SRC_CODE_SHADOW_LOOKUP_MATRIX,
.accessor = "shadowLookupMatrix", .accessor = "shadowLookupMatrix",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
.transposedMatrix = CONST_SRC_CODE_TRANSPOSE_SHADOW_LOOKUP_MATRIX,
}, },
{ {
.value = CONST_SRC_CODE_INVERSE_SHADOW_LOOKUP_MATRIX, .value = CONST_SRC_CODE_INVERSE_SHADOW_LOOKUP_MATRIX,
.accessor = "inverseShadowLookupMatrix", .accessor = "inverseShadowLookupMatrix",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
.transposedMatrix = CONST_SRC_CODE_INVERSE_TRANSPOSE_SHADOW_LOOKUP_MATRIX,
}, },
{ {
.value = CONST_SRC_CODE_TRANSPOSE_SHADOW_LOOKUP_MATRIX, .value = CONST_SRC_CODE_TRANSPOSE_SHADOW_LOOKUP_MATRIX,
.accessor = "transposeShadowLookupMatrix", .accessor = "transposeShadowLookupMatrix",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
.transposedMatrix = CONST_SRC_CODE_SHADOW_LOOKUP_MATRIX,
}, },
{ {
.value = CONST_SRC_CODE_INVERSE_TRANSPOSE_SHADOW_LOOKUP_MATRIX, .value = CONST_SRC_CODE_INVERSE_TRANSPOSE_SHADOW_LOOKUP_MATRIX,
.accessor = "inverseTransposeShadowLookupMatrix", .accessor = "inverseTransposeShadowLookupMatrix",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
.transposedMatrix = CONST_SRC_CODE_INVERSE_SHADOW_LOOKUP_MATRIX,
}, },
{ {
.value = CONST_SRC_CODE_WORLD_OUTDOOR_LOOKUP_MATRIX, .value = CONST_SRC_CODE_WORLD_OUTDOOR_LOOKUP_MATRIX,
.accessor = "worldOutdoorLookupMatrix", .accessor = "worldOutdoorLookupMatrix",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
.transposedMatrix = CONST_SRC_CODE_TRANSPOSE_WORLD_OUTDOOR_LOOKUP_MATRIX,
}, },
{ {
.value = CONST_SRC_CODE_INVERSE_WORLD_OUTDOOR_LOOKUP_MATRIX, .value = CONST_SRC_CODE_INVERSE_WORLD_OUTDOOR_LOOKUP_MATRIX,
.accessor = "inverseWorldOutdoorLookupMatrix", .accessor = "inverseWorldOutdoorLookupMatrix",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
.transposedMatrix = CONST_SRC_CODE_INVERSE_TRANSPOSE_WORLD_OUTDOOR_LOOKUP_MATRIX,
}, },
{ {
.value = CONST_SRC_CODE_TRANSPOSE_WORLD_OUTDOOR_LOOKUP_MATRIX, .value = CONST_SRC_CODE_TRANSPOSE_WORLD_OUTDOOR_LOOKUP_MATRIX,
.accessor = "transposeWorldOutdoorLookupMatrix", .accessor = "transposeWorldOutdoorLookupMatrix",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
.transposedMatrix = CONST_SRC_CODE_WORLD_OUTDOOR_LOOKUP_MATRIX,
}, },
{ {
.value = CONST_SRC_CODE_INVERSE_TRANSPOSE_WORLD_OUTDOOR_LOOKUP_MATRIX, .value = CONST_SRC_CODE_INVERSE_TRANSPOSE_WORLD_OUTDOOR_LOOKUP_MATRIX,
.accessor = "inverseTransposeWorldOutdoorLookupMatrix", .accessor = "inverseTransposeWorldOutdoorLookupMatrix",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
.transposedMatrix = CONST_SRC_CODE_INVERSE_WORLD_OUTDOOR_LOOKUP_MATRIX,
}, },
}; };
@@ -1546,11 +1596,13 @@ namespace T5
.value = TEXTURE_SRC_CODE_LIGHTMAP_PRIMARY, .value = TEXTURE_SRC_CODE_LIGHTMAP_PRIMARY,
.accessor = "lightmapSamplerPrimary", .accessor = "lightmapSamplerPrimary",
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::CUSTOM, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::CUSTOM,
.customSamplerIndex = CUSTOM_SAMPLER_LIGHTMAP_PRIMARY,
}, },
{ {
.value = TEXTURE_SRC_CODE_LIGHTMAP_SECONDARY, .value = TEXTURE_SRC_CODE_LIGHTMAP_SECONDARY,
.accessor = "lightmapSamplerSecondary", .accessor = "lightmapSamplerSecondary",
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::CUSTOM, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::CUSTOM,
.customSamplerIndex = CUSTOM_SAMPLER_LIGHTMAP_SECONDARY,
}, },
{ {
.value = TEXTURE_SRC_CODE_SHADOWMAP_SUN, .value = TEXTURE_SRC_CODE_SHADOWMAP_SUN,
@@ -1571,11 +1623,13 @@ namespace T5
.value = TEXTURE_SRC_CODE_RESOLVED_POST_SUN, .value = TEXTURE_SRC_CODE_RESOLVED_POST_SUN,
.accessor = "resolvedPostSun", .accessor = "resolvedPostSun",
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
.techFlags = MTL_TECHFLAG_NEEDS_RESOLVED_POST_SUN,
}, },
{ {
.value = TEXTURE_SRC_CODE_RESOLVED_SCENE, .value = TEXTURE_SRC_CODE_RESOLVED_SCENE,
.accessor = "resolvedScene", .accessor = "resolvedScene",
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
.techFlags = MTL_TECHFLAG_NEEDS_RESOLVED_SCENE,
}, },
{ {
.value = TEXTURE_SRC_CODE_POST_EFFECT_SRC, .value = TEXTURE_SRC_CODE_POST_EFFECT_SRC,
@@ -1621,16 +1675,19 @@ namespace T5
.value = TEXTURE_SRC_CODE_FLOATZ, .value = TEXTURE_SRC_CODE_FLOATZ,
.accessor = "floatZSampler", .accessor = "floatZSampler",
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
.techFlags = MTL_TECHFLAG_USES_FLOATZ,
}, },
{ {
.value = TEXTURE_SRC_CODE_PROCESSED_FLOATZ, .value = TEXTURE_SRC_CODE_PROCESSED_FLOATZ,
.accessor = "processedFloatZSampler", .accessor = "processedFloatZSampler",
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
.techFlags = MTL_TECHFLAG_USES_FLOATZ,
}, },
{ {
.value = TEXTURE_SRC_CODE_RAW_FLOATZ, .value = TEXTURE_SRC_CODE_RAW_FLOATZ,
.accessor = "rawFloatZSampler", .accessor = "rawFloatZSampler",
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
.techFlags = MTL_TECHFLAG_USES_FLOATZ,
}, },
{ {
.value = TEXTURE_SRC_CODE_CASE_TEXTURE, .value = TEXTURE_SRC_CODE_CASE_TEXTURE,
@@ -1661,6 +1718,7 @@ namespace T5
.value = TEXTURE_SRC_CODE_REFLECTION_PROBE, .value = TEXTURE_SRC_CODE_REFLECTION_PROBE,
.accessor = "reflectionProbeSampler", .accessor = "reflectionProbeSampler",
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::CUSTOM, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::CUSTOM,
.customSamplerIndex = CUSTOM_SAMPLER_REFLECTION_PROBE,
}, },
{ {
.value = TEXTURE_SRC_CODE_FEATHER_FLOAT_Z, .value = TEXTURE_SRC_CODE_FEATHER_FLOAT_Z,
@@ -1691,6 +1749,7 @@ namespace T5
.value = TEXTURE_SRC_CODE_LIGHTMAP_SECONDARYB, .value = TEXTURE_SRC_CODE_LIGHTMAP_SECONDARYB,
.accessor = "lightmapSamplerSecondaryB", .accessor = "lightmapSamplerSecondaryB",
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::CUSTOM, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::CUSTOM,
.customSamplerIndex = CUSTOM_SAMPLER_LIGHTMAP_SECONDARYB,
}, },
{ {
.value = TEXTURE_SRC_CODE_TEXTURE_0, .value = TEXTURE_SRC_CODE_TEXTURE_0,

View File

@@ -79,6 +79,7 @@ namespace techset
std::uint8_t arrayCount; std::uint8_t arrayCount;
CommonCodeSourceUpdateFrequency updateFrequency; CommonCodeSourceUpdateFrequency updateFrequency;
std::optional<unsigned> techFlags; std::optional<unsigned> techFlags;
std::optional<CommonTechniqueShaderType> techFlagShaderType;
std::optional<CommonCodeConstSource> transposedMatrix; std::optional<CommonCodeConstSource> transposedMatrix;
}; };

View File

@@ -1,6 +1,9 @@
#include "ObjCompilerT5.h" #include "ObjCompilerT5.h"
#include "Game/T5/T5.h" #include "Game/T5/T5.h"
#include "Game/T5/Techset/TechniqueCompilerT5.h"
#include "Game/T5/Techset/TechsetCompilerT5.h"
#include "Game/T5/Techset/VertexDeclCompilerT5.h"
#include "Image/ImageIwdPostProcessor.h" #include "Image/ImageIwdPostProcessor.h"
#include <memory> #include <memory>
@@ -13,7 +16,10 @@ namespace
{ {
auto& memory = zone.Memory(); auto& memory = zone.Memory();
// No compilers yet collection.AddAssetCreator(techset::CreateTechsetCompilerT5(memory, searchPath));
collection.AddSubAssetCreator(techset::CreateTechniqueCompilerT5(memory, zone, searchPath));
collection.AddSubAssetCreator(techset::CreateVertexDeclCompilerT5(memory));
} }
void ConfigurePostProcessors(AssetCreatorCollection& collection, void ConfigurePostProcessors(AssetCreatorCollection& collection,
@@ -39,5 +45,6 @@ void ObjCompiler::ConfigureCreatorCollection(AssetCreatorCollection& collection,
IOutputPath& outDir, IOutputPath& outDir,
IOutputPath& cacheDir) const IOutputPath& cacheDir) const
{ {
ConfigureCompilers(collection, zone, searchPath);
ConfigurePostProcessors(collection, zone, zoneDefinition, searchPath, zoneStates, outDir); ConfigurePostProcessors(collection, zone, zoneDefinition, searchPath, zoneStates, outDir);
} }

View File

@@ -12,6 +12,35 @@
namespace namespace
{ {
const char* ShaderTypeName(const techset::CommonTechniqueShaderType shaderType)
{
switch (shaderType)
{
case techset::CommonTechniqueShaderType::VERTEX:
return "vertex";
case techset::CommonTechniqueShaderType::PIXEL:
return "pixel";
}
return "<unknown>";
}
const char* ArgTypeName(const techset::CommonShaderValueType valueType)
{
switch (valueType)
{
case techset::CommonShaderValueType::CODE_CONST:
case techset::CommonShaderValueType::LITERAL_CONST:
case techset::CommonShaderValueType::MATERIAL_CONST:
return "constant";
case techset::CommonShaderValueType::CODE_SAMPLER:
case techset::CommonShaderValueType::MATERIAL_SAMPLER:
return "sampler";
}
return "<unknown>";
}
class BaseCommonShaderArgCreator : public techset::CommonShaderArgCreator class BaseCommonShaderArgCreator : public techset::CommonShaderArgCreator
{ {
public: public:
@@ -28,6 +57,7 @@ namespace
result::Expected<NoResult, std::string> EnterShader(const techset::CommonTechniqueShaderType shaderType, const std::string& name) override result::Expected<NoResult, std::string> EnterShader(const techset::CommonTechniqueShaderType shaderType, const std::string& name) override
{ {
m_shader_type = shaderType; m_shader_type = shaderType;
m_shader_name = name;
std::optional<techset::CommonTechniqueShaderBin> maybeShader; std::optional<techset::CommonTechniqueShaderBin> maybeShader;
if (shaderType == techset::CommonTechniqueShaderType::VERTEX) if (shaderType == techset::CommonTechniqueShaderType::VERTEX)
@@ -109,6 +139,9 @@ namespace
.m_value_type = techset::CommonShaderValueType::LITERAL_CONST, .m_value_type = techset::CommonShaderValueType::LITERAL_CONST,
}; };
if (!IsArgumentTypeSupported(argumentType))
return result::Unexpected(std::format("{} constants are unsupported", ShaderTypeName(argumentType.m_shader_type)));
techset::CommonShaderArgValue value{.literal_value = literalValue}; techset::CommonShaderArgValue value{.literal_value = literalValue};
m_args.emplace_back(argumentType, commonDestination, value); m_args.emplace_back(argumentType, commonDestination, value);
@@ -143,6 +176,12 @@ namespace
} }
} }
if (!IsArgumentTypeSupported(argumentType))
{
return result::Unexpected(
std::format("{} {} are unsupported", ShaderTypeName(argumentType.m_shader_type), ArgTypeName(argumentType.m_value_type)));
}
techset::CommonShaderArgValue value{.name_hash = nameHash}; techset::CommonShaderArgValue value{.name_hash = nameHash};
m_args.emplace_back(argumentType, commonDestination, value); m_args.emplace_back(argumentType, commonDestination, value);
@@ -205,6 +244,9 @@ namespace
.m_value_type = techset::CommonShaderValueType::CODE_CONST, .m_value_type = techset::CommonShaderValueType::CODE_CONST,
}; };
if (!IsArgumentTypeSupported(argumentType))
return result::Unexpected(std::format("{} constants are unsupported", ShaderTypeName(argumentType.m_shader_type)));
const auto maybeInfo = m_common_code_source_infos.GetInfoForCodeConstSource(codeConstSource); const auto maybeInfo = m_common_code_source_infos.GetInfoForCodeConstSource(codeConstSource);
if (!maybeInfo) if (!maybeInfo)
return result::Unexpected<std::string>("Could not find info for code constant"); return result::Unexpected<std::string>("Could not find info for code constant");
@@ -235,7 +277,7 @@ namespace
} }
m_args.emplace_back(argumentType, commonDestination, techset::CommonShaderArgValue{.code_const_source = value}); m_args.emplace_back(argumentType, commonDestination, techset::CommonShaderArgValue{.code_const_source = value});
if (maybeInfo->techFlags) if (maybeInfo->techFlags && (!maybeInfo->techFlagShaderType || *maybeInfo->techFlagShaderType == m_shader_type))
m_tech_flags |= *maybeInfo->techFlags; m_tech_flags |= *maybeInfo->techFlags;
return NoResult{}; return NoResult{};
@@ -249,6 +291,9 @@ namespace
.m_value_type = techset::CommonShaderValueType::CODE_SAMPLER, .m_value_type = techset::CommonShaderValueType::CODE_SAMPLER,
}; };
if (!IsArgumentTypeSupported(argumentType))
return result::Unexpected(std::format("{} samplers are unsupported", ShaderTypeName(argumentType.m_shader_type)));
const auto maybeInfo = m_common_code_source_infos.GetInfoForCodeSamplerSource(codeSamplerSource); const auto maybeInfo = m_common_code_source_infos.GetInfoForCodeSamplerSource(codeSamplerSource);
if (!maybeInfo) if (!maybeInfo)
return result::Unexpected<std::string>("Could not find info for code sampler"); return result::Unexpected<std::string>("Could not find info for code sampler");
@@ -262,6 +307,24 @@ namespace
return NoResult{}; return NoResult{};
} }
static bool IsArgumentTypeSupported(const techset::CommonShaderArgumentType& argumentType)
{
if (argumentType.m_shader_type == techset::CommonTechniqueShaderType::PIXEL)
return true;
switch (argumentType.m_value_type)
{
case techset::CommonShaderValueType::LITERAL_CONST:
case techset::CommonShaderValueType::MATERIAL_CONST:
case techset::CommonShaderValueType::CODE_CONST:
return true;
case techset::CommonShaderValueType::MATERIAL_SAMPLER:
case techset::CommonShaderValueType::CODE_SAMPLER:
default:
return false;
}
}
[[nodiscard]] virtual size_t CompareArgumentDestinations(const techset::CommonShaderArg& arg0, const techset::CommonShaderArg& arg1) const = 0; [[nodiscard]] virtual size_t CompareArgumentDestinations(const techset::CommonShaderArg& arg0, const techset::CommonShaderArg& arg1) const = 0;
[[nodiscard]] virtual bool FindDestinationForConstant(techset::CommonShaderArgDestination& commonDestination, [[nodiscard]] virtual bool FindDestinationForConstant(techset::CommonShaderArgDestination& commonDestination,
@@ -279,6 +342,7 @@ namespace
techset::CommonCodeSourceInfos& m_common_code_source_infos; techset::CommonCodeSourceInfos& m_common_code_source_infos;
techset::CommonTechniqueShaderType m_shader_type; techset::CommonTechniqueShaderType m_shader_type;
std::string m_shader_name;
techset::CommonTechniqueShaderBin m_bin; techset::CommonTechniqueShaderBin m_bin;
std::vector<techset::CommonShaderArg> m_args; std::vector<techset::CommonShaderArg> m_args;
@@ -341,8 +405,6 @@ namespace
if (foundConstant == m_shader_info->m_constants.end()) if (foundConstant == m_shader_info->m_constants.end())
return false; return false;
const auto variableElementCount = std::max<unsigned>(foundConstant->m_register_count, 1);
commonDestination.dx9.m_destination_register = foundConstant->m_register_index; commonDestination.dx9.m_destination_register = foundConstant->m_register_index;
isTransposed = foundConstant->m_class == d3d9::ParameterClass::MATRIX_COLUMNS; isTransposed = foundConstant->m_class == d3d9::ParameterClass::MATRIX_COLUMNS;
rowCount = foundConstant->m_register_count; rowCount = foundConstant->m_register_count;
@@ -409,6 +471,15 @@ namespace
private: private:
result::Expected<NoResult, std::string> AutoCreateConstantArg(const d3d9::ShaderConstant& shaderArg) result::Expected<NoResult, std::string> AutoCreateConstantArg(const d3d9::ShaderConstant& shaderArg)
{ {
if (!IsArgumentTypeSupported(
techset::CommonShaderArgumentType{.m_shader_type = m_shader_type, .m_value_type = techset::CommonShaderValueType::CODE_CONST}))
{
con::warn("Shader {} uses unsupported argument type \"{} constant\". This may cause unstable behaviour.",
m_shader_name,
ShaderTypeName(m_shader_type));
return NoResult{};
}
const auto maybeCodeConst = m_common_code_source_infos.GetCodeConstSourceForAccessor(shaderArg.m_name); const auto maybeCodeConst = m_common_code_source_infos.GetCodeConstSourceForAccessor(shaderArg.m_name);
if (!maybeCodeConst) if (!maybeCodeConst)
{ {
@@ -444,7 +515,7 @@ namespace
return std::move(result); return std::move(result);
} }
if (constInfo->techFlags) if (constInfo->techFlags && (!constInfo->techFlagShaderType || *constInfo->techFlagShaderType == m_shader_type))
m_tech_flags |= *constInfo->techFlags; m_tech_flags |= *constInfo->techFlags;
return NoResult{}; return NoResult{};
@@ -464,6 +535,15 @@ namespace
result::Expected<NoResult, std::string> AutoCreateSamplerArg(const d3d9::ShaderConstant& shaderArg) result::Expected<NoResult, std::string> AutoCreateSamplerArg(const d3d9::ShaderConstant& shaderArg)
{ {
if (!IsArgumentTypeSupported(
techset::CommonShaderArgumentType{.m_shader_type = m_shader_type, .m_value_type = techset::CommonShaderValueType::CODE_SAMPLER}))
{
con::warn("Shader {} uses unsupported argument type \"{} sampler\". This may cause unstable behaviour.",
m_shader_name,
ShaderTypeName(m_shader_type));
return NoResult{};
}
const auto maybeCodeSampler = m_common_code_source_infos.GetCodeSamplerSourceForAccessor(shaderArg.m_name); const auto maybeCodeSampler = m_common_code_source_infos.GetCodeSamplerSourceForAccessor(shaderArg.m_name);
if (!maybeCodeSampler) if (!maybeCodeSampler)
return result::Unexpected(std::format("Missing assignment to shader texture {}", shaderArg.m_name)); return result::Unexpected(std::format("Missing assignment to shader texture {}", shaderArg.m_name));
@@ -745,6 +825,15 @@ namespace
result::Expected<NoResult, std::string> AutoCreateConstantArg(const d3d11::ConstantBufferVariable& variable, const size_t bufferIndex) result::Expected<NoResult, std::string> AutoCreateConstantArg(const d3d11::ConstantBufferVariable& variable, const size_t bufferIndex)
{ {
if (!IsArgumentTypeSupported(
techset::CommonShaderArgumentType{.m_shader_type = m_shader_type, .m_value_type = techset::CommonShaderValueType::CODE_CONST}))
{
con::warn("Shader {} uses unsupported argument type \"{} constant\". This may cause unstable behaviour.",
m_shader_name,
ShaderTypeName(m_shader_type));
return NoResult{};
}
const auto maybeCodeConst = m_common_code_source_infos.GetCodeConstSourceForAccessor(variable.m_name); const auto maybeCodeConst = m_common_code_source_infos.GetCodeConstSourceForAccessor(variable.m_name);
if (!maybeCodeConst) if (!maybeCodeConst)
{ {
@@ -782,7 +871,7 @@ namespace
return std::move(result); return std::move(result);
} }
if (constInfo->techFlags) if (constInfo->techFlags && (!constInfo->techFlagShaderType || *constInfo->techFlagShaderType == m_shader_type))
m_tech_flags |= *constInfo->techFlags; m_tech_flags |= *constInfo->techFlags;
return NoResult{}; return NoResult{};
@@ -790,6 +879,15 @@ namespace
result::Expected<NoResult, std::string> AutoCreateSamplerArg(const d3d11::BoundResource& textureResource, const unsigned samplerBindPoint) result::Expected<NoResult, std::string> AutoCreateSamplerArg(const d3d11::BoundResource& textureResource, const unsigned samplerBindPoint)
{ {
if (!IsArgumentTypeSupported(
techset::CommonShaderArgumentType{.m_shader_type = m_shader_type, .m_value_type = techset::CommonShaderValueType::CODE_SAMPLER}))
{
con::warn("Shader {} uses unsupported argument type \"{} sampler\". This may cause unstable behaviour.",
m_shader_name,
ShaderTypeName(m_shader_type));
return NoResult{};
}
const auto maybeCodeSampler = m_common_code_source_infos.GetCodeSamplerSourceForAccessor(textureResource.m_name); const auto maybeCodeSampler = m_common_code_source_infos.GetCodeSamplerSourceForAccessor(textureResource.m_name);
if (!maybeCodeSampler) if (!maybeCodeSampler)
return result::Unexpected(std::format("Missing assignment to shader texture {}", textureResource.m_name)); return result::Unexpected(std::format("Missing assignment to shader texture {}", textureResource.m_name));

View File

@@ -1,4 +1,4 @@
#options GAME(IW3, IW4, T6) #options GAME(IW3, IW4, T5, T6)
#filename "Game/" + GAME + "/Techset/TechniqueCompiler" + GAME + ".cpp" #filename "Game/" + GAME + "/Techset/TechniqueCompiler" + GAME + ".cpp"
@@ -297,6 +297,14 @@ namespace
if (ShouldApplyFlag200(technique)) if (ShouldApplyFlag200(technique))
technique.flags |= TECHNIQUE_FLAG_200; technique.flags |= TECHNIQUE_FLAG_200;
#elif defined(FEATURE_T5)
// 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_"))
{
technique.flags |= MTL_TECHFLAG_ZPREPASS;
}
#elif defined(FEATURE_T6) #elif defined(FEATURE_T6)
// Not a particularly cool way to do this but... // Not a particularly cool way to do this but...
// the game actually does this :shrug: // the game actually does this :shrug:
@@ -332,7 +340,7 @@ namespace
return technique; return technique;
} }
#if defined(FEATURE_T6) #if defined(FEATURE_T5) || defined(FEATURE_T6)
void ApplyTechFlagsFromMaterial(const Material& material, const Zone& zone) void ApplyTechFlagsFromMaterial(const Material& material, const Zone& zone)
{ {
if (!material.techniqueSet || !material.techniqueSet->name || !material.stateBitsTable) if (!material.techniqueSet || !material.techniqueSet->name || !material.stateBitsTable)
@@ -458,13 +466,15 @@ namespace
void FinalizeZone(AssetCreationContext& context) override void FinalizeZone(AssetCreationContext& context) override
{ {
#if defined(FEATURE_T6) #if defined(FEATURE_T5) || defined(FEATURE_T6)
const auto materials = m_zone.m_pools.PoolAssets<AssetMaterial>(); const auto materials = m_zone.m_pools.PoolAssets<AssetMaterial>();
for (auto* materialAsset : materials) for (auto* materialAsset : materials)
{ {
ApplyTechFlagsFromMaterial(*materialAsset->Asset(), m_zone); ApplyTechFlagsFromMaterial(*materialAsset->Asset(), m_zone);
} }
#endif
#if defined(FEATURE_T6)
const auto techniques = context.PoolSubAssets<SubAssetTechnique>(); const auto techniques = context.PoolSubAssets<SubAssetTechnique>();
for (auto* techniqueSubAsset : techniques) for (auto* techniqueSubAsset : techniques)
{ {

View File

@@ -1,4 +1,4 @@
#options GAME(IW3, IW4, T6) #options GAME(IW3, IW4, T5, T6)
#filename "Game/" + GAME + "/Techset/TechniqueCompiler" + GAME + ".h" #filename "Game/" + GAME + "/Techset/TechniqueCompiler" + GAME + ".h"

View File

@@ -1,4 +1,4 @@
#options GAME(IW3, IW4, T6) #options GAME(IW3, IW4, T5, T6)
#filename "Game/" + GAME + "/Techset/TechsetCompiler" + GAME + ".cpp" #filename "Game/" + GAME + "/Techset/TechsetCompiler" + GAME + ".cpp"

View File

@@ -1,4 +1,4 @@
#options GAME(IW3, IW4, T6) #options GAME(IW3, IW4, T5, T6)
#filename "Game/" + GAME + "/Techset/TechsetCompiler" + GAME + ".h" #filename "Game/" + GAME + "/Techset/TechsetCompiler" + GAME + ".h"

View File

@@ -1,4 +1,4 @@
#options GAME(IW3, IW4, T6) #options GAME(IW3, IW4, T5, T6)
#filename "Game/" + GAME + "/Techset/VertexDeclCompiler" + GAME + ".cpp" #filename "Game/" + GAME + "/Techset/VertexDeclCompiler" + GAME + ".cpp"
@@ -15,6 +15,7 @@
#define FEATURE_IW5 #define FEATURE_IW5
#elif GAME == "T5" #elif GAME == "T5"
#define FEATURE_T5 #define FEATURE_T5
#define IS_SUB_ASSET
#elif GAME == "T6" #elif GAME == "T6"
#define FEATURE_T6 #define FEATURE_T6
#define IS_SUB_ASSET #define IS_SUB_ASSET

View File

@@ -1,4 +1,4 @@
#options GAME(IW3, IW4, T6) #options GAME(IW3, IW4, T5, T6)
#filename "Game/" + GAME + "/Techset/VertexDeclCompiler" + GAME + ".h" #filename "Game/" + GAME + "/Techset/VertexDeclCompiler" + GAME + ".h"
@@ -11,6 +11,7 @@
#define FEATURE_IW5 #define FEATURE_IW5
#elif GAME == "T5" #elif GAME == "T5"
#define FEATURE_T5 #define FEATURE_T5
#define IS_SUB_ASSET
#elif GAME == "T6" #elif GAME == "T6"
#define FEATURE_T6 #define FEATURE_T6
#define IS_SUB_ASSET #define IS_SUB_ASSET

View File

@@ -6,6 +6,8 @@
#include "Game/T5/Image/ImageLoaderEmbeddedT5.h" #include "Game/T5/Image/ImageLoaderEmbeddedT5.h"
#include "Game/T5/Image/ImageLoaderExternalT5.h" #include "Game/T5/Image/ImageLoaderExternalT5.h"
#include "Game/T5/T5.h" #include "Game/T5/T5.h"
#include "Game/T5/Techset/PixelShaderLoaderT5.h"
#include "Game/T5/Techset/VertexShaderLoaderT5.h"
#include "Game/T5/XModel/LoaderXModelT5.h" #include "Game/T5/XModel/LoaderXModelT5.h"
#include "Localize/LoaderLocalizeT5.h" #include "Localize/LoaderLocalizeT5.h"
#include "Material/LoaderMaterialT5.h" #include "Material/LoaderMaterialT5.h"
@@ -136,6 +138,9 @@ namespace
// collection.AddAssetCreator(std::make_unique<AssetLoaderDDL>(memory)); // collection.AddAssetCreator(std::make_unique<AssetLoaderDDL>(memory));
// collection.AddAssetCreator(std::make_unique<AssetLoaderGlasses>(memory)); // collection.AddAssetCreator(std::make_unique<AssetLoaderGlasses>(memory));
// collection.AddAssetCreator(std::make_unique<AssetLoaderEmblemSet>(memory)); // collection.AddAssetCreator(std::make_unique<AssetLoaderEmblemSet>(memory));
collection.AddSubAssetCreator(techset::CreateVertexShaderLoaderT5(memory, searchPath));
collection.AddSubAssetCreator(techset::CreatePixelShaderLoaderT5(memory, searchPath));
} }
} // namespace } // namespace

View File

@@ -1,4 +1,4 @@
#options GAME(IW3, IW4, T6) #options GAME(IW3, IW4, T5, T6)
#filename "Game/" + GAME + "/Techset/PixelShaderLoader" + GAME + ".cpp" #filename "Game/" + GAME + "/Techset/PixelShaderLoader" + GAME + ".cpp"
@@ -18,6 +18,7 @@
#elif GAME == "T5" #elif GAME == "T5"
#define FEATURE_T5 #define FEATURE_T5
#define IS_DX9 #define IS_DX9
#define IS_SUB_ASSET
#elif GAME == "T6" #elif GAME == "T6"
#define FEATURE_T6 #define FEATURE_T6
#define IS_DX11 #define IS_DX11

View File

@@ -1,4 +1,4 @@
#options GAME(IW3, IW4, T6) #options GAME(IW3, IW4, T5, T6)
#filename "Game/" + GAME + "/Techset/PixelShaderLoader" + GAME + ".h" #filename "Game/" + GAME + "/Techset/PixelShaderLoader" + GAME + ".h"
@@ -11,6 +11,7 @@
#define FEATURE_IW5 #define FEATURE_IW5
#elif GAME == "T5" #elif GAME == "T5"
#define FEATURE_T5 #define FEATURE_T5
#define IS_SUB_ASSET
#elif GAME == "T6" #elif GAME == "T6"
#define FEATURE_T6 #define FEATURE_T6
#define IS_SUB_ASSET #define IS_SUB_ASSET

View File

@@ -1,4 +1,4 @@
#options GAME(IW3, IW4, T6) #options GAME(IW3, IW4, T5, T6)
#filename "Game/" + GAME + "/Techset/VertexShaderLoader" + GAME + ".cpp" #filename "Game/" + GAME + "/Techset/VertexShaderLoader" + GAME + ".cpp"
@@ -18,6 +18,7 @@
#elif GAME == "T5" #elif GAME == "T5"
#define FEATURE_T5 #define FEATURE_T5
#define IS_DX9 #define IS_DX9
#define IS_SUB_ASSET
#elif GAME == "T6" #elif GAME == "T6"
#define FEATURE_T6 #define FEATURE_T6
#define IS_DX11 #define IS_DX11

View File

@@ -1,4 +1,4 @@
#options GAME(IW3, IW4, T6) #options GAME(IW3, IW4, T5, T6)
#filename "Game/" + GAME + "/Techset/VertexShaderLoader" + GAME + ".h" #filename "Game/" + GAME + "/Techset/VertexShaderLoader" + GAME + ".h"
@@ -11,6 +11,7 @@
#define FEATURE_IW5 #define FEATURE_IW5
#elif GAME == "T5" #elif GAME == "T5"
#define FEATURE_T5 #define FEATURE_T5
#define IS_SUB_ASSET
#elif GAME == "T6" #elif GAME == "T6"
#define FEATURE_T6 #define FEATURE_T6
#define IS_SUB_ASSET #define IS_SUB_ASSET

View File

@@ -33,6 +33,7 @@ namespace
"DarkenPower", "DarkenPower",
"Detail_Amount", "Detail_Amount",
"Detail_Normal_Tile", "Detail_Normal_Tile",
"Diffuse_MapSampler",
"Diffuse_Normal_Height_Facing", "Diffuse_Normal_Height_Facing",
"Dimensions", "Dimensions",
"DispersionAmount", "DispersionAmount",
@@ -44,6 +45,7 @@ namespace
"EdgeMinDist", "EdgeMinDist",
"EdgeSize", "EdgeSize",
"Edge_Color_Multiplier", "Edge_Color_Multiplier",
"Edge_Intensity",
"Emissive_Amount", "Emissive_Amount",
"EnemiesColor", "EnemiesColor",
"Exposure", "Exposure",
@@ -143,6 +145,7 @@ namespace
"NormalHeightMultiplier", "NormalHeightMultiplier",
"Normal_Detail_Height", "Normal_Detail_Height",
"Normal_Detail_Scale", "Normal_Detail_Scale",
"Normal_MapSampler",
"Normal_Map_Size_Scale", "Normal_Map_Size_Scale",
"Normal_Variance_Scale", "Normal_Variance_Scale",
"NumFrames", "NumFrames",
@@ -157,6 +160,7 @@ namespace
"Player_Lookup_Scale", "Player_Lookup_Scale",
"PositiveColor", "PositiveColor",
"Power", "Power",
"PreviewCompID",
"PulseColor", "PulseColor",
"PulseInterval", "PulseInterval",
"PulseTime", "PulseTime",
@@ -165,6 +169,7 @@ namespace
"Radius", "Radius",
"ReflectionAmount", "ReflectionAmount",
"Reflection_Amount", "Reflection_Amount",
"Reflection_Amt",
"Reflection_Blur", "Reflection_Blur",
"Reticle_Alt_Color", "Reticle_Alt_Color",
"Reticle_Color", "Reticle_Color",
@@ -177,6 +182,7 @@ namespace
"ScanlineSpeed", "ScanlineSpeed",
"ScatterAmount", "ScatterAmount",
"ScatterSize", "ScatterSize",
"Scatter_Intensity",
"SceneNoise", "SceneNoise",
"SparkleBrightness", "SparkleBrightness",
"SparkleDensity", "SparkleDensity",
@@ -189,6 +195,7 @@ namespace
"SpecularAmount", "SpecularAmount",
"SpecularColor", "SpecularColor",
"Specular_Amount", "Specular_Amount",
"Specular_Color",
"Specular_Decay_Threshold", "Specular_Decay_Threshold",
"Speed", "Speed",
"StaticAmount", "StaticAmount",
@@ -202,6 +209,7 @@ namespace
"TearLookupSpeed", "TearLookupSpeed",
"TearMultiplier", "TearMultiplier",
"TearPower", "TearPower",
"Temporal_Sharpness",
"Thickness", "Thickness",
"TickMarkColorAndHarshness", "TickMarkColorAndHarshness",
"Tint", "Tint",
@@ -221,6 +229,9 @@ namespace
"WaterScale2", "WaterScale2",
"WaterSpeed1", "WaterSpeed1",
"WaterSpeed2", "WaterSpeed2",
"Wetness_Color",
"Wetness_Color_Gloss_Bias",
"Wetness_Specular_Swatch_Scale",
"Zoom", "Zoom",
"alphaDissolveParms", "alphaDissolveParms",
"alphaRevealParms", "alphaRevealParms",
@@ -230,6 +241,11 @@ namespace
"alphaRevealParms4", "alphaRevealParms4",
"clipSpaceLookupOffset", "clipSpaceLookupOffset",
"clipSpaceLookupScale", "clipSpaceLookupScale",
"cloakTextureControl0",
"cloakTextureControl1",
"clothcharrColorMapScale",
"clothcharrEmberColorAndBrightness",
"clothcharrMaskMapScale",
"cloudsFeather", "cloudsFeather",
"cloudsHeights", "cloudsHeights",
"cloudsUVMad1", "cloudsUVMad1",
@@ -333,6 +349,7 @@ namespace
"CompassMap", "CompassMap",
"Detail_Map", "Detail_Map",
"Diffuse", "Diffuse",
"DiffuseBurnt2",
"Diffuse_Map", "Diffuse_Map",
"DpadTexture", "DpadTexture",
"FontTextutre", "FontTextutre",
@@ -374,6 +391,7 @@ namespace
"Static", "Static",
"StaticMap", "StaticMap",
"Static_Noise_Map", "Static_Noise_Map",
"Stretch_Map",
"SunShadowSamplerState", "SunShadowSamplerState",
"SunShadowState", "SunShadowState",
"Surface_Normal_Map", "Surface_Normal_Map",

View File

@@ -1,272 +0,0 @@
#include "TechsetDumperT5.h"
#include "Game/T5/Material/MaterialConstantZoneStateT5.h"
#include "Game/T5/Techset/TechsetConstantsT5.h"
#include "Shader/ShaderCommon.h"
#include "Techset/CommonTechniqueDumper.h"
#include "Techset/CommonTechsetDumper.h"
#include "Techset/ShaderDumpingZoneState.h"
#include "Techset/TechniqueDumpingZoneState.h"
#include <cstdint>
using namespace T5;
namespace
{
void DumpPixelShader(const AssetDumpingContext& context, const MaterialPixelShader& pixelShader)
{
const auto shaderFile = context.OpenAssetFile(shader::GetFileNameForPixelShaderAssetName(pixelShader.name));
if (!shaderFile)
return;
shaderFile->write(reinterpret_cast<char*>(pixelShader.prog.loadDef.program), pixelShader.prog.loadDef.programSize * sizeof(uint32_t));
}
void DumpVertexShader(const AssetDumpingContext& context, const MaterialVertexShader& vertexShader)
{
const auto shaderFile = context.OpenAssetFile(shader::GetFileNameForVertexShaderAssetName(vertexShader.name));
if (!shaderFile)
return;
shaderFile->write(reinterpret_cast<char*>(vertexShader.prog.loadDef.program), vertexShader.prog.loadDef.programSize * sizeof(uint32_t));
}
void DumpShaders(AssetDumpingContext& context, const MaterialTechniqueSet& techset)
{
auto* shaderState = context.GetZoneAssetDumperState<techset::ShaderDumpingZoneState>();
for (const auto* technique : techset.techniques)
{
if (!technique || !shaderState->ShouldDumpTechnique(technique))
continue;
for (auto passIndex = 0u; passIndex < technique->passCount; passIndex++)
{
const auto* pixelShader = technique->passArray[passIndex].pixelShader;
if (pixelShader && shaderState->ShouldDumpPixelShader(pixelShader))
DumpPixelShader(context, *pixelShader);
const auto* vertexShader = technique->passArray[passIndex].vertexShader;
if (vertexShader && shaderState->ShouldDumpVertexShader(vertexShader))
DumpVertexShader(context, *vertexShader);
}
}
}
techset::CommonVertexDeclaration ConvertToCommonVertexDeclaration(const MaterialVertexDeclaration* vertexDecl)
{
std::vector<techset::CommonStreamRouting> commonRouting;
if (vertexDecl)
{
const auto streamCount = std::min(static_cast<size_t>(vertexDecl->streamCount), std::extent_v<decltype(MaterialVertexStreamRouting::data)>);
for (auto streamIndex = 0u; streamIndex < streamCount; streamIndex++)
{
const auto& routing = vertexDecl->routing.data[streamIndex];
commonRouting.emplace_back(static_cast<techset::CommonStreamSource>(routing.source),
static_cast<techset::CommonStreamDestination>(routing.dest));
}
}
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:
{
const techset::CommonShaderArgCodeConstValue codeConstValue{
.m_index = static_cast<techset::CommonCodeConstSource>(arg.u.codeConst.index),
.m_first_row = arg.u.codeConst.firstRow,
.m_row_count = arg.u.codeConst.rowCount,
};
const techset::CommonShaderArgValue value{.code_const_source = codeConstValue};
return techset::CommonShaderArg(commonArgumentTypes[arg.type], destination, value);
}
case MTL_ARG_MATERIAL_VERTEX_CONST:
case MTL_ARG_MATERIAL_PIXEL_CONST:
{
const techset::CommonShaderArgValue value{
.name_hash = arg.u.nameHash,
};
return techset::CommonShaderArg(commonArgumentTypes[arg.type], destination, value);
}
case MTL_ARG_CODE_PIXEL_SAMPLER:
{
const techset::CommonShaderArgValue 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:
{
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)
{
value.literal_value = {
(*arg.u.literalConst)[0],
(*arg.u.literalConst)[1],
(*arg.u.literalConst)[2],
(*arg.u.literalConst)[3],
};
}
return techset::CommonShaderArg(commonArgumentTypes[arg.type], destination, value);
}
}
}
techset::CommonTechniqueShader ConvertToCommonShader(const MaterialVertexShader* vertexShader)
{
techset::CommonTechniqueShader result{};
if (!vertexShader)
return result;
if (vertexShader->name)
result.m_name = vertexShader->name;
if (vertexShader->prog.loadDef.program)
{
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 MaterialPixelShader* pixelShader)
{
techset::CommonTechniqueShader result{};
if (!pixelShader)
return result;
if (pixelShader->name)
result.m_name = pixelShader->name;
if (pixelShader->prog.loadDef.program)
{
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;
}
techset::CommonTechnique ConvertToCommonTechnique(const MaterialTechnique& technique)
{
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),
std::string());
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]));
}
commonTechnique.m_passes.emplace_back(std::move(commonPass));
}
return commonTechnique;
}
void DumpTechniques(AssetDumpingContext& context, const MaterialTechniqueSet& techset, const bool debug)
{
auto* techniqueState = context.GetZoneAssetDumperState<techset::TechniqueDumpingZoneState>();
const auto* materialConstantState = context.GetZoneAssetDumperState<MaterialConstantZoneState>();
for (const auto* technique : techset.techniques)
{
if (technique && techniqueState->ShouldDumpTechnique(technique))
{
const auto commonTechnique = ConvertToCommonTechnique(*technique);
techset::DumpCommonTechnique(
context, commonTechnique, techset::DxVersion::DX9, commonCodeSourceInfos, commonRoutingInfos, *materialConstantState, debug);
}
}
}
techset::CommonTechset ConvertToCommonTechset(const MaterialTechniqueSet& techset)
{
std::vector<std::string> techniqueNames(std::extent_v<decltype(techniqueTypeNames)>);
for (auto techniqueIndex = 0u; techniqueIndex < std::extent_v<decltype(techniqueTypeNames)>; techniqueIndex++)
{
const auto* technique = techset.techniques[techniqueIndex];
if (technique && technique->name)
techniqueNames[techniqueIndex] = technique->name;
}
return techset::CommonTechset(techset.name, std::move(techniqueNames));
}
void DumpTechset(const AssetDumpingContext& context, const MaterialTechniqueSet& techset)
{
static techset::CommonTechniqueTypeNames commonNames(techniqueTypeNames, std::extent_v<decltype(techniqueTypeNames)>);
const auto commonTechset = ConvertToCommonTechset(techset);
techset::DumpCommonTechset(commonNames, context, commonTechset);
}
} // namespace
namespace techset
{
DumperT5::DumperT5(const bool debug)
: m_debug(debug)
{
}
void DumperT5::Dump(AssetDumpingContext& context)
{
context.GetZoneAssetDumperState<MaterialConstantZoneState>()->EnsureInitialized();
AbstractAssetDumper::Dump(context);
}
void DumperT5::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetTechniqueSet::Type>& asset)
{
const auto* techniqueSet = asset.Asset();
DumpTechset(context, *techniqueSet);
DumpTechniques(context, *techniqueSet, m_debug);
DumpShaders(context, *techniqueSet);
}
} // namespace techset

View File

@@ -1,21 +0,0 @@
#pragma once
#include "Dumping/AbstractAssetDumper.h"
#include "Game/T5/T5.h"
namespace techset
{
class DumperT5 final : public AbstractAssetDumper<T5::AssetTechniqueSet>
{
public:
explicit DumperT5(bool debug);
void Dump(AssetDumpingContext& context) override;
protected:
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<T5::AssetTechniqueSet::Type>& asset) override;
private:
bool m_debug;
};
} // namespace techset

View File

@@ -231,6 +231,7 @@ namespace
static_cast<unsigned>(arg.m_type.m_value_type)); static_cast<unsigned>(arg.m_type.m_value_type));
return; return;
} }
const auto buffer = std::ranges::find_if(shaderInfo.m_constant_buffers, const auto buffer = std::ranges::find_if(shaderInfo.m_constant_buffers,
[&boundResource](const d3d11::ConstantBuffer& constantBuffer) [&boundResource](const d3d11::ConstantBuffer& constantBuffer)
{ {
@@ -409,15 +410,15 @@ namespace
Indent(); Indent();
std::string materialPropertyName; std::string materialPropertyName;
if (m_constant_zone_state.GetConstantName(arg.m_value.name_hash, materialPropertyName) if (m_constant_zone_state.HashString(codeDestAccessor) == arg.m_value.name_hash)
|| m_constant_zone_state.GetTextureDefName(arg.m_value.name_hash, materialPropertyName))
{
m_stream << std::format("{} = material.{};\n", codeDestAccessor, materialPropertyName);
}
else if (m_constant_zone_state.HashString(codeDestAccessor) == arg.m_value.name_hash)
{ {
m_stream << std::format("{} = material.{};\n", codeDestAccessor, codeDestAccessor); m_stream << std::format("{} = material.{};\n", codeDestAccessor, codeDestAccessor);
} }
else if (m_constant_zone_state.GetConstantName(arg.m_value.name_hash, materialPropertyName)
|| m_constant_zone_state.GetTextureDefName(arg.m_value.name_hash, materialPropertyName))
{
m_stream << std::format("{} = material.{};\n", codeDestAccessor, materialPropertyName);
}
else else
{ {
m_stream << std::format("{} = material.#0x{:x};\n", codeDestAccessor, arg.m_value.name_hash); m_stream << std::format("{} = material.#0x{:x};\n", codeDestAccessor, arg.m_value.name_hash);

View File

@@ -1,4 +1,4 @@
#options GAME(IW3, IW4, T6) #options GAME(IW3, IW4, T5, T6)
#filename "Game/" + GAME + "/Techset/TechsetDumper" + GAME + ".cpp" #filename "Game/" + GAME + "/Techset/TechsetDumper" + GAME + ".cpp"
@@ -19,6 +19,7 @@
#elif GAME == "T5" #elif GAME == "T5"
#define FEATURE_T5 #define FEATURE_T5
#define IS_DX9 #define IS_DX9
#define DUMP_SHADERS "1"
#elif GAME == "T6" #elif GAME == "T6"
#define FEATURE_T6 #define FEATURE_T6
#define IS_DX11 #define IS_DX11

View File

@@ -1,4 +1,4 @@
#options GAME(IW3, IW4, T6) #options GAME(IW3, IW4, T5, T6)
#filename "Game/" + GAME + "/Techset/TechsetDumper" + GAME + ".h" #filename "Game/" + GAME + "/Techset/TechsetDumper" + GAME + ".h"