#pragma once

#include "Game/IW4/CommonIW4.h"
#include "Game/IW4/IW4.h"
#include "Techset/CommonTechnique.h"
#include "Techset/CommonTechset.h"
#include "Techset/StateMap/StateMapLayout.h"

#include <type_traits>
#include <unordered_map>

namespace IW4
{
    static inline const char* techniqueTypeNames[]{
        "depth prepass",
        "build floatz",
        "build shadowmap depth",
        "build shadowmap color",
        "unlit",
        "emissive",
        "emissive dfog",
        "emissive shadow",
        "emissive shadow dfog",
        "lit",
        "lit dfog",
        "lit sun",
        "lit sun dfog",
        "lit sun shadow",
        "lit sun shadow dfog",
        "lit spot",
        "lit spot dfog",
        "lit spot shadow",
        "lit spot shadow dfog",
        "lit omni",
        "lit omni dfog",
        "lit omni shadow",
        "lit omni shadow dfog",
        "lit instanced",
        "lit instanced dfog",
        "lit instanced sun",
        "lit instanced sun dfog",
        "lit instanced sun shadow",
        "lit instanced sun shadow dfog",
        "lit instanced spot",
        "lit instanced spot dfog",
        "lit instanced spot shadow",
        "lit instanced spot shadow dfog",
        "lit instanced omni",
        "lit instanced omni dfog",
        "lit instanced omni shadow",
        "lit instanced omni shadow dfog",
        "light spot",
        "light omni",
        "light spot shadow",
        "fakelight normal",
        "fakelight view",
        "sunlight preview",
        "case texture",
        "solid wireframe",
        "shaded wireframe",
        "debug bumpmap",
        "debug bumpmap instanced",
    };
    static_assert(std::extent_v<decltype(techniqueTypeNames)> == TECHNIQUE_COUNT);
    static inline techset::CommonTechniqueTypeNames commonTechniqueTypeNames(techniqueTypeNames, std::extent_v<decltype(techniqueTypeNames)>);

    static inline techset::CommonStreamRoutingSourceInfo streamRoutingSources[]{
        {
         .name = "position",
         .abbreviation = "p",
         .optional = false,
         },
        {
         .name = "color",
         .abbreviation = "c",
         .optional = false,
         },
        {
         .name = "texcoord[0]",
         .abbreviation = "t0",
         .optional = false,
         },
        {
         .name = "normal",
         .abbreviation = "n",
         .optional = false,
         },
        {
         .name = "tangent",
         .abbreviation = "t",
         .optional = false,
         },
        {
         .name = "texcoord[1]",
         .abbreviation = "t1",
         .optional = true,
         },
        {
         .name = "texcoord[2]",
         .abbreviation = "t2",
         .optional = true,
         },
        {
         .name = "normalTransform[0]",
         .abbreviation = "n0",
         .optional = true,
         },
        {
         .name = "normalTransform[1]",
         .abbreviation = "n1",
         .optional = true,
         },
    };
    static_assert(std::extent_v<decltype(streamRoutingSources)> == STREAM_SRC_COUNT);

    static inline techset::CommonStreamRoutingDestinationInfo streamRoutingDestinations[]{
        {
         .name = "position",
         .abbreviation = "p",
         },
        {
         .name = "normal",
         .abbreviation = "n",
         },
        {
         .name = "color[0]",
         .abbreviation = "c0",
         },
        {
         .name = "color[1]",
         .abbreviation = "c1",
         },
        {
         .name = "depth",
         .abbreviation = "d",
         },
        {
         .name = "texcoord[0]",
         .abbreviation = "t0",
         },
        {
         .name = "texcoord[1]",
         .abbreviation = "t1",
         },
        {
         .name = "texcoord[2]",
         .abbreviation = "t2",
         },
        {
         .name = "texcoord[3]",
         .abbreviation = "t3",
         },
        {
         .name = "texcoord[4]",
         .abbreviation = "t4",
         },
        {
         .name = "texcoord[5]",
         .abbreviation = "t5",
         },
        {
         .name = "texcoord[6]",
         .abbreviation = "t6",
         },
        {
         .name = "texcoord[7]",
         .abbreviation = "t7",
         },
    };
    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,
         .accessor = "lightPosition",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_LIGHT_DIFFUSE,
         .accessor = "lightDiffuse",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_LIGHT_SPECULAR,
         .accessor = "lightSpecular",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_LIGHT_SPOTDIR,
         .accessor = "lightSpotDir",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_LIGHT_SPOTFACTORS,
         .accessor = "lightSpotFactors",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         .techFlags = MTL_TECHFLAG_USES_LIGHT_SPOT_FACTORS,
         },
        {
         .value = CONST_SRC_CODE_LIGHT_FALLOFF_PLACEMENT,
         .accessor = "lightFalloffPlacement",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_PARTICLE_CLOUD_COLOR,
         .accessor = "particleCloudColor",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_GAMETIME,
         .accessor = "gameTime",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_PIXEL_COST_FRACS,
         .accessor = "pixelCostFracs",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_PIXEL_COST_DECODE,
         .accessor = "pixelCostDecode",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_FILTER_TAP_0,
         .accessor = "filterTap",
         .arrayCount = 8,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_COLOR_MATRIX_R,
         .accessor = "colorMatrixR",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_COLOR_MATRIX_G,
         .accessor = "colorMatrixG",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_COLOR_MATRIX_B,
         .accessor = "colorMatrixB",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_SHADOWMAP_POLYGON_OFFSET,
         .accessor = "shadowmapPolygonOffset",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_RENDER_TARGET_SIZE,
         .accessor = "renderTargetSize",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_DOF_EQUATION_VIEWMODEL_AND_FAR_BLUR,
         .accessor = "dofEquationViewModelAndFarBlur",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_DOF_EQUATION_SCENE,
         .accessor = "dofEquationScene",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_DOF_LERP_SCALE,
         .accessor = "dofLerpScale",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_DOF_LERP_BIAS,
         .accessor = "dofLerpBias",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_DOF_ROW_DELTA,
         .accessor = "dofRowDelta",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_MOTION_MATRIX_X,
         .accessor = "motionMatrixX",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_MOTION_MATRIX_Y,
         .accessor = "motionMatrixY",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_MOTION_MATRIX_W,
         .accessor = "motionMatrixW",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_SHADOWMAP_SWITCH_PARTITION,
         .accessor = "shadowmapSwitchPartition",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_SHADOWMAP_SCALE,
         .accessor = "shadowmapScale",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_ZNEAR,
         .accessor = "zNear",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_LIGHTING_LOOKUP_SCALE,
         .accessor = "lightingLookupScale",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_DEBUG_BUMPMAP,
         .accessor = "debugBumpmap",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_MATERIAL_COLOR,
         .accessor = "materialColor",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_FOG,
         .accessor = "fogConsts",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_FOG_COLOR_LINEAR,
         .accessor = "fogColorLinear",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_FOG_COLOR_GAMMA,
         .accessor = "fogColorGamma",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_FOG_SUN_CONSTS,
         .accessor = "fogSunConsts",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_FOG_SUN_COLOR_LINEAR,
         .accessor = "fogSunColorLinear",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_FOG_SUN_COLOR_GAMMA,
         .accessor = "fogSunColorGamma",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_FOG_SUN_DIR,
         .accessor = "fogSunDir",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_GLOW_SETUP,
         .accessor = "glowSetup",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_GLOW_APPLY,
         .accessor = "glowApply",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_COLOR_BIAS,
         .accessor = "colorBias",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_COLOR_TINT_BASE,
         .accessor = "colorTintBase",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_COLOR_TINT_DELTA,
         .accessor = "colorTintDelta",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_COLOR_TINT_QUADRATIC_DELTA,
         .accessor = "colorTintQuadraticDelta",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_OUTDOOR_FEATHER_PARMS,
         .accessor = "outdoorFeatherParms",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_ENVMAP_PARMS,
         .accessor = "envMapParms",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_SUN_SHADOWMAP_PIXEL_ADJUST,
         .accessor = "sunShadowmapPixelAdjust",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_SPOT_SHADOWMAP_PIXEL_ADJUST,
         .accessor = "spotShadowmapPixelAdjust",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_COMPOSITE_FX_DISTORTION,
         .accessor = "fullscreenDistortion",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_POSTFX_FADE_EFFECT,
         .accessor = "fadeEffect",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_VIEWPORT_DIMENSIONS,
         .accessor = "viewportDimensions",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_FRAMEBUFFER_READ,
         .accessor = "framebufferRead",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_BASE_LIGHTING_COORDS,
         .accessor = "baseLightingCoords",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         },
        {
         .value = CONST_SRC_CODE_LIGHT_PROBE_AMBIENT,
         .accessor = "lightprobeAmbient",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         },
        {
         .value = CONST_SRC_CODE_NEARPLANE_ORG,
         .accessor = "nearPlaneOrg",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_NEARPLANE_DX,
         .accessor = "nearPlaneDx",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_NEARPLANE_DY,
         .accessor = "nearPlaneDy",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_CLIP_SPACE_LOOKUP_SCALE,
         .accessor = "clipSpaceLookupScale",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_CLIP_SPACE_LOOKUP_OFFSET,
         .accessor = "clipSpaceLookupOffset",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = CONST_SRC_CODE_PARTICLE_CLOUD_MATRIX0,
         .accessor = "particleCloudMatrix",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
         },
        {
         .value = CONST_SRC_CODE_PARTICLE_CLOUD_MATRIX1,
         .accessor = "particleCloudMatrix1",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
         },
        {
         .value = CONST_SRC_CODE_PARTICLE_CLOUD_MATRIX2,
         .accessor = "particleCloudMatrix2",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
         },
        {
         .value = CONST_SRC_CODE_PARTICLE_CLOUD_SPARK_COLOR0,
         .accessor = "particleCloudSparkColor0",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
         },
        {
         .value = CONST_SRC_CODE_PARTICLE_CLOUD_SPARK_COLOR1,
         .accessor = "particleCloudSparkColor1",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
         },
        {
         .value = CONST_SRC_CODE_PARTICLE_CLOUD_SPARK_COLOR2,
         .accessor = "particleCloudSparkColor2",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
         },
        {
         .value = CONST_SRC_CODE_PARTICLE_FOUNTAIN_PARM0,
         .accessor = "particleFountainParms0",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
         },
        {
         .value = CONST_SRC_CODE_PARTICLE_FOUNTAIN_PARM1,
         .accessor = "particleFountainParms1",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
         },
        {
         .value = CONST_SRC_CODE_DEPTH_FROM_CLIP,
         .accessor = "depthFromClip",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
         },
        {
         .value = CONST_SRC_CODE_CODE_MESH_ARG_0,
         .accessor = "codeMeshArg",
         .arrayCount = 2,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
         },
        {
         .value = CONST_SRC_CODE_VIEW_MATRIX,
         .accessor = "viewMatrix",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
         .transposedMatrix = CONST_SRC_CODE_TRANSPOSE_VIEW_MATRIX,
         },
        {
         .value = CONST_SRC_CODE_INVERSE_VIEW_MATRIX,
         .accessor = "inverseViewMatrix",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
         .transposedMatrix = CONST_SRC_CODE_INVERSE_TRANSPOSE_VIEW_MATRIX,
         },
        {
         .value = CONST_SRC_CODE_TRANSPOSE_VIEW_MATRIX,
         .accessor = "transposeViewMatrix",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
         .transposedMatrix = CONST_SRC_CODE_VIEW_MATRIX,
         },
        {
         .value = CONST_SRC_CODE_INVERSE_TRANSPOSE_VIEW_MATRIX,
         .accessor = "inverseTransposeViewMatrix",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
         .transposedMatrix = CONST_SRC_CODE_INVERSE_VIEW_MATRIX,
         },
        {
         .value = CONST_SRC_CODE_PROJECTION_MATRIX,
         .accessor = "projectionMatrix",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
         .transposedMatrix = CONST_SRC_CODE_TRANSPOSE_PROJECTION_MATRIX,
         },
        {
         .value = CONST_SRC_CODE_INVERSE_PROJECTION_MATRIX,
         .accessor = "inverseProjectionMatrix",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
         .transposedMatrix = CONST_SRC_CODE_INVERSE_TRANSPOSE_PROJECTION_MATRIX,
         },
        {
         .value = CONST_SRC_CODE_TRANSPOSE_PROJECTION_MATRIX,
         .accessor = "transposeProjectionMatrix",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
         .transposedMatrix = CONST_SRC_CODE_PROJECTION_MATRIX,
         },
        {
         .value = CONST_SRC_CODE_INVERSE_TRANSPOSE_PROJECTION_MATRIX,
         .accessor = "inverseTransposeProjectionMatrix",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
         .transposedMatrix = CONST_SRC_CODE_INVERSE_PROJECTION_MATRIX,
         },
        {
         .value = CONST_SRC_CODE_VIEW_PROJECTION_MATRIX,
         .accessor = "viewProjectionMatrix",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
         .transposedMatrix = CONST_SRC_CODE_TRANSPOSE_VIEW_PROJECTION_MATRIX,
         },
        {
         .value = CONST_SRC_CODE_INVERSE_VIEW_PROJECTION_MATRIX,
         .accessor = "inverseViewProjectionMatrix",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
         .transposedMatrix = CONST_SRC_CODE_INVERSE_TRANSPOSE_VIEW_PROJECTION_MATRIX,
         },
        {
         .value = CONST_SRC_CODE_TRANSPOSE_VIEW_PROJECTION_MATRIX,
         .accessor = "transposeViewProjectionMatrix",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
         .transposedMatrix = CONST_SRC_CODE_VIEW_PROJECTION_MATRIX,
         },
        {
         .value = CONST_SRC_CODE_INVERSE_TRANSPOSE_VIEW_PROJECTION_MATRIX,
         .accessor = "inverseTransposeViewProjectionMatrix",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
         .transposedMatrix = CONST_SRC_CODE_INVERSE_VIEW_PROJECTION_MATRIX,
         },
        {
         .value = CONST_SRC_CODE_SHADOW_LOOKUP_MATRIX,
         .accessor = "shadowLookupMatrix",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
         .transposedMatrix = CONST_SRC_CODE_TRANSPOSE_SHADOW_LOOKUP_MATRIX,
         },
        {
         .value = CONST_SRC_CODE_INVERSE_SHADOW_LOOKUP_MATRIX,
         .accessor = "inverseShadowLookupMatrix",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
         .transposedMatrix = CONST_SRC_CODE_INVERSE_TRANSPOSE_SHADOW_LOOKUP_MATRIX,
         },
        {
         .value = CONST_SRC_CODE_TRANSPOSE_SHADOW_LOOKUP_MATRIX,
         .accessor = "transposeShadowLookupMatrix",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
         .transposedMatrix = CONST_SRC_CODE_SHADOW_LOOKUP_MATRIX,
         },
        {
         .value = CONST_SRC_CODE_INVERSE_TRANSPOSE_SHADOW_LOOKUP_MATRIX,
         .accessor = "inverseTransposeShadowLookupMatrix",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
         .transposedMatrix = CONST_SRC_CODE_INVERSE_SHADOW_LOOKUP_MATRIX,
         },
        {
         .value = CONST_SRC_CODE_WORLD_OUTDOOR_LOOKUP_MATRIX,
         .accessor = "worldOutdoorLookupMatrix",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_TRANSPOSE_WORLD_OUTDOOR_LOOKUP_MATRIX,
         },
        {
         .value = CONST_SRC_CODE_INVERSE_WORLD_OUTDOOR_LOOKUP_MATRIX,
         .accessor = "inverseWorldOutdoorLookupMatrix",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_INVERSE_TRANSPOSE_WORLD_OUTDOOR_LOOKUP_MATRIX,
         },
        {
         .value = CONST_SRC_CODE_TRANSPOSE_WORLD_OUTDOOR_LOOKUP_MATRIX,
         .accessor = "transposeWorldOutdoorLookupMatrix",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_WORLD_OUTDOOR_LOOKUP_MATRIX,
         },
        {
         .value = CONST_SRC_CODE_INVERSE_TRANSPOSE_WORLD_OUTDOOR_LOOKUP_MATRIX,
         .accessor = "inverseTransposeWorldOutdoorLookupMatrix",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_INVERSE_WORLD_OUTDOOR_LOOKUP_MATRIX,
         },
        {
         .value = CONST_SRC_CODE_WORLD_MATRIX0,
         .accessor = "worldMatrix",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_TRANSPOSE_WORLD_MATRIX0,
         },
        {
         .value = CONST_SRC_CODE_INVERSE_WORLD_MATRIX0,
         .accessor = "inverseWorldMatrix",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_INVERSE_TRANSPOSE_WORLD_MATRIX0,
         },
        {
         .value = CONST_SRC_CODE_TRANSPOSE_WORLD_MATRIX0,
         .accessor = "transposeWorldMatrix",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_WORLD_MATRIX0,
         },
        {
         .value = CONST_SRC_CODE_INVERSE_TRANSPOSE_WORLD_MATRIX0,
         .accessor = "inverseTransposeWorldMatrix",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_INVERSE_WORLD_MATRIX0,
         },
        {
         .value = CONST_SRC_CODE_WORLD_VIEW_MATRIX0,
         .accessor = "worldViewMatrix",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_TRANSPOSE_WORLD_VIEW_MATRIX0,
         },
        {
         .value = CONST_SRC_CODE_INVERSE_WORLD_VIEW_MATRIX0,
         .accessor = "inverseWorldViewMatrix",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX0,
         },
        {
         .value = CONST_SRC_CODE_TRANSPOSE_WORLD_VIEW_MATRIX0,
         .accessor = "transposeWorldViewMatrix",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_WORLD_VIEW_MATRIX0,
         },
        {
         .value = CONST_SRC_CODE_INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX0,
         .accessor = "inverseTransposeWorldViewMatrix",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_INVERSE_WORLD_VIEW_MATRIX0,
         },
        {
         .value = CONST_SRC_CODE_WORLD_VIEW_PROJECTION_MATRIX0,
         .accessor = "worldViewProjectionMatrix",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_TRANSPOSE_WORLD_VIEW_PROJECTION_MATRIX0,
         },
        {
         .value = CONST_SRC_CODE_INVERSE_WORLD_VIEW_PROJECTION_MATRIX0,
         .accessor = "inverseWorldViewProjectionMatrix",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_INVERSE_TRANSPOSE_WORLD_VIEW_PROJECTION_MATRIX0,
         },
        {
         .value = CONST_SRC_CODE_TRANSPOSE_WORLD_VIEW_PROJECTION_MATRIX0,
         .accessor = "transposeWorldViewProjectionMatrix",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_WORLD_VIEW_PROJECTION_MATRIX0,
         },
        {
         .value = CONST_SRC_CODE_INVERSE_TRANSPOSE_WORLD_VIEW_PROJECTION_MATRIX0,
         .accessor = "inverseTransposeWorldViewProjectionMatrix",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_INVERSE_WORLD_VIEW_PROJECTION_MATRIX0,
         },
        {
         .value = CONST_SRC_CODE_WORLD_MATRIX1,
         .accessor = "worldMatrix1",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_TRANSPOSE_WORLD_MATRIX1,
         },
        {
         .value = CONST_SRC_CODE_INVERSE_WORLD_MATRIX1,
         .accessor = "inverseWorldMatrix1",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_INVERSE_TRANSPOSE_WORLD_MATRIX1,
         },
        {
         .value = CONST_SRC_CODE_TRANSPOSE_WORLD_MATRIX1,
         .accessor = "transposeWorldMatrix1",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_WORLD_MATRIX1,
         },
        {
         .value = CONST_SRC_CODE_INVERSE_TRANSPOSE_WORLD_MATRIX1,
         .accessor = "inverseTransposeWorldMatrix1",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_INVERSE_WORLD_MATRIX1,
         },
        {
         .value = CONST_SRC_CODE_WORLD_VIEW_MATRIX1,
         .accessor = "worldViewMatrix1",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_TRANSPOSE_WORLD_VIEW_MATRIX1,
         },
        {
         .value = CONST_SRC_CODE_INVERSE_WORLD_VIEW_MATRIX1,
         .accessor = "inverseWorldViewMatrix1",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX1,
         },
        {
         .value = CONST_SRC_CODE_TRANSPOSE_WORLD_VIEW_MATRIX1,
         .accessor = "transposeWorldViewMatrix1",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_WORLD_VIEW_MATRIX1,
         },
        {
         .value = CONST_SRC_CODE_INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX1,
         .accessor = "inverseTransposeWorldViewMatrix1",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_INVERSE_WORLD_VIEW_MATRIX1,
         },
        {
         .value = CONST_SRC_CODE_WORLD_VIEW_PROJECTION_MATRIX1,
         .accessor = "worldViewProjectionMatrix1",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_TRANSPOSE_WORLD_VIEW_PROJECTION_MATRIX1,
         },
        {
         .value = CONST_SRC_CODE_INVERSE_WORLD_VIEW_PROJECTION_MATRIX1,
         .accessor = "inverseWorldViewProjectionMatrix1",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_INVERSE_TRANSPOSE_WORLD_VIEW_PROJECTION_MATRIX1,
         },
        {
         .value = CONST_SRC_CODE_TRANSPOSE_WORLD_VIEW_PROJECTION_MATRIX1,
         .accessor = "transposeWorldViewProjectionMatrix1",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_WORLD_VIEW_PROJECTION_MATRIX1,
         },
        {
         .value = CONST_SRC_CODE_INVERSE_TRANSPOSE_WORLD_VIEW_PROJECTION_MATRIX1,
         .accessor = "inverseTransposeWorldViewProjectionMatrix1",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_INVERSE_WORLD_VIEW_PROJECTION_MATRIX1,
         },
        {
         .value = CONST_SRC_CODE_WORLD_MATRIX2,
         .accessor = "worldMatrix2",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_TRANSPOSE_WORLD_MATRIX2,
         },
        {
         .value = CONST_SRC_CODE_INVERSE_WORLD_MATRIX2,
         .accessor = "inverseWorldMatrix2",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_INVERSE_TRANSPOSE_WORLD_MATRIX2,
         },
        {
         .value = CONST_SRC_CODE_TRANSPOSE_WORLD_MATRIX2,
         .accessor = "transposeWorldMatrix2",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_WORLD_MATRIX2,
         },
        {
         .value = CONST_SRC_CODE_INVERSE_TRANSPOSE_WORLD_MATRIX2,
         .accessor = "inverseTransposeWorldMatrix2",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_INVERSE_WORLD_MATRIX2,
         },
        {
         .value = CONST_SRC_CODE_WORLD_VIEW_MATRIX2,
         .accessor = "worldViewMatrix2",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_TRANSPOSE_WORLD_VIEW_MATRIX2,
         },
        {
         .value = CONST_SRC_CODE_INVERSE_WORLD_VIEW_MATRIX2,
         .accessor = "inverseWorldViewMatrix2",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX2,
         },
        {
         .value = CONST_SRC_CODE_TRANSPOSE_WORLD_VIEW_MATRIX2,
         .accessor = "transposeWorldViewMatrix2",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_WORLD_VIEW_MATRIX2,
         },
        {
         .value = CONST_SRC_CODE_INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX2,
         .accessor = "inverseTransposeWorldViewMatrix2",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_INVERSE_WORLD_VIEW_MATRIX2,
         },
        {
         .value = CONST_SRC_CODE_WORLD_VIEW_PROJECTION_MATRIX2,
         .accessor = "worldViewProjectionMatrix2",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_TRANSPOSE_WORLD_VIEW_PROJECTION_MATRIX2,
         },
        {
         .value = CONST_SRC_CODE_INVERSE_WORLD_VIEW_PROJECTION_MATRIX2,
         .accessor = "inverseWorldViewProjectionMatrix2",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_INVERSE_TRANSPOSE_WORLD_VIEW_PROJECTION_MATRIX2,
         },
        {
         .value = CONST_SRC_CODE_TRANSPOSE_WORLD_VIEW_PROJECTION_MATRIX2,
         .accessor = "transposeWorldViewProjectionMatrix2",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_WORLD_VIEW_PROJECTION_MATRIX2,
         },
        {
         .value = CONST_SRC_CODE_INVERSE_TRANSPOSE_WORLD_VIEW_PROJECTION_MATRIX2,
         .accessor = "inverseTransposeWorldViewProjectionMatrix2",
         .arrayCount = 0,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
         .transposedMatrix = CONST_SRC_CODE_INVERSE_WORLD_VIEW_PROJECTION_MATRIX2,
         },
    };

    static inline techset::CommonCodeSamplerSourceInfo commonCodeSamplerSources[]{
        {
         .value = TEXTURE_SRC_CODE_BLACK,
         .accessor = "black",
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = TEXTURE_SRC_CODE_WHITE,
         .accessor = "white",
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = TEXTURE_SRC_CODE_IDENTITY_NORMAL_MAP,
         .accessor = "identityNormalMap",
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = TEXTURE_SRC_CODE_MODEL_LIGHTING,
         .accessor = "modelLightingSampler",
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .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,
         .accessor = "shadowmapSamplerSun",
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = TEXTURE_SRC_CODE_SHADOWMAP_SPOT,
         .accessor = "shadowmapSamplerSpot",
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = TEXTURE_SRC_CODE_FEEDBACK,
         .accessor = "feedbackSampler",
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
         },
        {
         .value = TEXTURE_SRC_CODE_RESOLVED_POST_SUN,
         .accessor = "resolvedPostSun",
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         .techFlags = MTL_TECHFLAG_NEEDS_RESOLVED_POST_SUN,
         },
        {
         .value = TEXTURE_SRC_CODE_RESOLVED_SCENE,
         .accessor = "resolvedScene",
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         .techFlags = MTL_TECHFLAG_NEEDS_RESOLVED_SCENE,
         },
        {
         .value = TEXTURE_SRC_CODE_POST_EFFECT_0,
         .accessor = "postEffect0",
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = TEXTURE_SRC_CODE_POST_EFFECT_1,
         .accessor = "postEffect1",
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = TEXTURE_SRC_CODE_LIGHT_ATTENUATION,
         .accessor = "attenuationSampler",
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
         },
        {
         .value = TEXTURE_SRC_CODE_OUTDOOR,
         .accessor = "outdoor",
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = TEXTURE_SRC_CODE_FLOATZ,
         .accessor = "floatZSampler",
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         .techFlags = MTL_TECHFLAG_USES_FLOATZ,
         },
        {
         .value = TEXTURE_SRC_CODE_PROCESSED_FLOATZ,
         .accessor = "processedFloatZSampler",
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         .techFlags = MTL_TECHFLAG_USES_FLOATZ,
         },
        {
         .value = TEXTURE_SRC_CODE_RAW_FLOATZ,
         .accessor = "rawFloatZSampler",
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         .techFlags = MTL_TECHFLAG_USES_FLOATZ,
         },
        {
         .value = TEXTURE_SRC_CODE_HALF_PARTICLES,
         .accessor = "halfParticleColorSampler",
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = TEXTURE_SRC_CODE_HALF_PARTICLES_Z,
         .accessor = "halfParticleDepthSampler",
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
        {
         .value = TEXTURE_SRC_CODE_CASE_TEXTURE,
         .accessor = "caseTexture" /* ? */,
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
         },
        {
         .value = TEXTURE_SRC_CODE_CINEMATIC_Y,
         .accessor = "cinematicYSampler",
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
         },
        {
         .value = TEXTURE_SRC_CODE_CINEMATIC_CR,
         .accessor = "cinematicCrSampler",
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
         },
        {
         .value = TEXTURE_SRC_CODE_CINEMATIC_CB,
         .accessor = "cinematicCbSampler",
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
         },
        {
         .value = TEXTURE_SRC_CODE_CINEMATIC_A,
         .accessor = "cinematicASampler",
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_OBJECT,
         },
        {
         .value = TEXTURE_SRC_CODE_REFLECTION_PROBE,
         .accessor = "reflectionProbeSampler",
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::CUSTOM,
         .customSamplerIndex = CUSTOM_SAMPLER_REFLECTION_PROBE,
         },
        {
         .value = TEXTURE_SRC_CODE_ALTERNATE_SCENE,
         .accessor = "alternateSceneSampler",
         .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
         },
    };

    // 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)> == MTL_ARG_COUNT);

    static inline techset::CommonCodeSourceInfos commonCodeSourceInfos(commonCodeConstSources,
                                                                       std::extent_v<decltype(commonCodeConstSources)>,
                                                                       commonCodeSamplerSources,
                                                                       std::extent_v<decltype(commonCodeSamplerSources)>,
                                                                       nullptr,
                                                                       0,
                                                                       commonArgumentTypes,
                                                                       std::extent_v<decltype(commonArgumentTypes)>);

    static inline MaterialTypeInfo g_materialTypeInfo[]{
        {"",    ""   },
        {"m/",  "m_" },
        {"mc/", "mc_"},
        {"mg/", "mg_"},
        {"w/",  "w_" },
        {"wc/", "wc_"},
    };
    static_assert(std::extent_v<decltype(g_materialTypeInfo)> == MTL_TYPE_COUNT);

    struct KnownMaterialTextureMap
    {
        const char* m_name;
        const char* m_additional_property_suffix;
    };

    static constexpr std::pair<uint32_t, KnownMaterialTextureMap> MakeKnownTextureMap(const char* name, const char* additionalPropertySuffix)
    {
        return std::make_pair(Common::R_HashString(name, 0u), KnownMaterialTextureMap{name, additionalPropertySuffix});
    }

    static inline std::unordered_map knownTextureMaps{
        MakeKnownTextureMap("colorMap", "Color"),
        MakeKnownTextureMap("colorMap0", "Color00"),
        MakeKnownTextureMap("colorMap1", "Color01"),
        MakeKnownTextureMap("colorMap2", "Color02"),
        MakeKnownTextureMap("normalMap", "Normal"),
        MakeKnownTextureMap("specularMap", "Specular"),
        MakeKnownTextureMap("detailMap", "Detail"),
    };

    static constexpr std::pair<uint32_t, const char*> MakeKnownConstantName(const char* name)
    {
        return std::make_pair(Common::R_HashString(name, 0u), name);
    }

    static inline std::unordered_map knownConstantNames{
        MakeKnownConstantName("distortionScale"),
        MakeKnownConstantName("eyeOffsetParms"),
        MakeKnownConstantName("falloffBeginColor"),
        MakeKnownConstantName("falloffEndColor"),
    };

    enum class StateMapLayout_e
    {
        ALPHA_TEST,
        BLEND_FUNC,
        SEPARATE_ALPHA_BLEND_FUNC,
        CULL_FACE,
        DEPTH_TEST,
        DEPTH_WRITE,
        COLOR_WRITE,
        GAMMA_WRITE,
        POLYGON_OFFSET,
        STENCIL,
        WIREFRAME
    };

    static inline state_map::StateMapLayoutEntries stateMapEntryLayout({
        {"alphaTest",              0, GFXS0_ATEST_MASK | GFXS0_ATEST_DISABLE,                            {"mtlAlphaTest"}                                            },
        {"blendFunc",              0, GFXS0_BLEND_RGB_MASK,                                              {"mtlBlendOp", "mtlSrcBlend", "mtlDestBlend"}               },
        {"separateAlphaBlendFunc", 0, GFXS0_BLEND_ALPHA_MASK,                                            {"mtlBlendOpAlpha", "mtlSrcBlendAlpha", "mtlDestBlendAlpha"}},
        {"cullFace",               0, GFXS0_CULL_MASK,                                                   {"mtlCullFace"}                                             },
        {"depthTest",              1, GFXS1_DEPTHTEST_MASK | GFXS1_DEPTHTEST_DISABLE,                    {"mtlDepthTest"}                                            },
        {"depthWrite",             1, GFXS1_DEPTHWRITE,                                                  {"mtlDepthWrite"}                                           },
        {"colorWrite",             0, GFXS0_COLORWRITE_MASK,                                             {"mtlColorWriteRgb", "mtlColorWriteAlpha"}                  },
        {"gammaWrite",
         0,                           GFXS0_GAMMAWRITE,
         {
             "mtlGammaWrite",
         }                                                                                                                                                           },
        {"polygonOffset",
         1,                           GFXS1_POLYGON_OFFSET_MASK,
         {
             "mtlPolygonOffset",
         }                                                                                                                                                           },
        {"stencil",
         1,                           GFXS1_STENCILFUNC_FRONTBACK_MASK | GFXS1_STENCILOP_FRONTBACK_MASK,
         {
             "mtlStencil",
             "mtlStencilFuncFront",
             "mtlStencilOpFrontPass",
             "mtlStencilOpFrontFail",
             "mtlStencilOpFrontZFail",
             "mtlStencilFuncBack",
             "mtlStencilOpBackPass",
             "mtlStencilOpBackFail",
             "mtlStencilOpBackZFail",
         }                                                                                                                                                           },
        {"wireframe",
         0,                           GFXS0_POLYMODE_LINE,
         {
             "mtlWireframe",
         }                                                                                                                                                           }
    });

    static inline state_map::StateMapLayoutVars stateMapVarLayout({
        {"mtlAlphaTest",
         0, {
             {"Always", GFXS0_ATEST_DISABLE},
             {"GE128", GFXS0_ATEST_GE_128},
             {"GT0", GFXS0_ATEST_GT_0},
             {"LT128", GFXS0_ATEST_LT_128},
         }},
        {"mtlBlendOp",
         0, {
             {"Add", GFXS_BLENDOP_ADD << GFXS0_BLENDOP_RGB_SHIFT},
             {"Subtract", GFXS_BLENDOP_SUBTRACT << GFXS0_BLENDOP_RGB_SHIFT},
             {"RevSubtract", GFXS_BLENDOP_REVSUBTRACT << GFXS0_BLENDOP_RGB_SHIFT},
             {"Min", GFXS_BLENDOP_MIN << GFXS0_BLENDOP_RGB_SHIFT},
             {"Max", GFXS_BLENDOP_MAX << GFXS0_BLENDOP_RGB_SHIFT},
             {"Disable", GFXS_BLENDOP_DISABLED << GFXS0_BLENDOP_RGB_SHIFT},
         }},
        {"mtlSrcBlend",
         0, {
             {"Zero", GFXS_BLEND_ZERO << GFXS0_SRCBLEND_RGB_SHIFT},
             {"One", GFXS_BLEND_ONE << GFXS0_SRCBLEND_RGB_SHIFT},
             {"SrcColor", GFXS_BLEND_SRCCOLOR << GFXS0_SRCBLEND_RGB_SHIFT},
             {"InvSrcColor", GFXS_BLEND_INVSRCCOLOR << GFXS0_SRCBLEND_RGB_SHIFT},
             {"SrcAlpha", GFXS_BLEND_SRCALPHA << GFXS0_SRCBLEND_RGB_SHIFT},
             {"InvSrcAlpha", GFXS_BLEND_INVSRCALPHA << GFXS0_SRCBLEND_RGB_SHIFT},
             {"DestAlpha", GFXS_BLEND_DESTALPHA << GFXS0_SRCBLEND_RGB_SHIFT},
             {"InvDestAlpha", GFXS_BLEND_INVDESTALPHA << GFXS0_SRCBLEND_RGB_SHIFT},
             {"DestColor", GFXS_BLEND_DESTCOLOR << GFXS0_SRCBLEND_RGB_SHIFT},
             {"InvDestColor", GFXS_BLEND_INVDESTCOLOR << GFXS0_SRCBLEND_RGB_SHIFT},
         }},
        {"mtlDestBlend",
         0, {
             {"Zero", GFXS_BLEND_ZERO << GFXS0_DSTBLEND_RGB_SHIFT},
             {"One", GFXS_BLEND_ONE << GFXS0_DSTBLEND_RGB_SHIFT},
             {"SrcColor", GFXS_BLEND_SRCCOLOR << GFXS0_DSTBLEND_RGB_SHIFT},
             {"InvSrcColor", GFXS_BLEND_INVSRCCOLOR << GFXS0_DSTBLEND_RGB_SHIFT},
             {"SrcAlpha", GFXS_BLEND_SRCALPHA << GFXS0_DSTBLEND_RGB_SHIFT},
             {"InvSrcAlpha", GFXS_BLEND_INVSRCALPHA << GFXS0_DSTBLEND_RGB_SHIFT},
             {"DestAlpha", GFXS_BLEND_DESTALPHA << GFXS0_DSTBLEND_RGB_SHIFT},
             {"InvDestAlpha", GFXS_BLEND_INVDESTALPHA << GFXS0_DSTBLEND_RGB_SHIFT},
             {"DestColor", GFXS_BLEND_DESTCOLOR << GFXS0_DSTBLEND_RGB_SHIFT},
             {"InvDestColor", GFXS_BLEND_INVDESTCOLOR << GFXS0_DSTBLEND_RGB_SHIFT},
         }},
        {"mtlBlendOpAlpha",
         0, {
             {"Add", GFXS_BLENDOP_ADD << GFXS0_BLENDOP_ALPHA_SHIFT},
             {"Subtract", GFXS_BLENDOP_SUBTRACT << GFXS0_BLENDOP_ALPHA_SHIFT},
             {"RevSubtract", GFXS_BLENDOP_REVSUBTRACT << GFXS0_BLENDOP_ALPHA_SHIFT},
             {"Min", GFXS_BLENDOP_MIN << GFXS0_BLENDOP_ALPHA_SHIFT},
             {"Max", GFXS_BLENDOP_MAX << GFXS0_BLENDOP_ALPHA_SHIFT},
             {"Disable", GFXS_BLENDOP_DISABLED << GFXS0_BLENDOP_ALPHA_SHIFT},
         }},
        {"mtlSrcBlendAlpha",
         0, {
             {"Zero", GFXS_BLEND_ZERO << GFXS0_SRCBLEND_ALPHA_SHIFT},
             {"One", GFXS_BLEND_ONE << GFXS0_SRCBLEND_ALPHA_SHIFT},
             {"SrcColor", GFXS_BLEND_SRCCOLOR << GFXS0_SRCBLEND_ALPHA_SHIFT},
             {"InvSrcColor", GFXS_BLEND_INVSRCCOLOR << GFXS0_SRCBLEND_ALPHA_SHIFT},
             {"SrcAlpha", GFXS_BLEND_SRCALPHA << GFXS0_SRCBLEND_ALPHA_SHIFT},
             {"InvSrcAlpha", GFXS_BLEND_INVSRCALPHA << GFXS0_SRCBLEND_ALPHA_SHIFT},
             {"DestAlpha", GFXS_BLEND_DESTALPHA << GFXS0_SRCBLEND_ALPHA_SHIFT},
             {"InvDestAlpha", GFXS_BLEND_INVDESTALPHA << GFXS0_SRCBLEND_ALPHA_SHIFT},
             {"DestColor", GFXS_BLEND_DESTCOLOR << GFXS0_SRCBLEND_ALPHA_SHIFT},
             {"InvDestColor", GFXS_BLEND_INVDESTCOLOR << GFXS0_SRCBLEND_ALPHA_SHIFT},
         }},
        {"mtlDestBlendAlpha",
         0, {
             {"Zero", GFXS_BLEND_ZERO << GFXS0_DSTBLEND_ALPHA_SHIFT},
             {"One", GFXS_BLEND_ONE << GFXS0_DSTBLEND_ALPHA_SHIFT},
             {"SrcColor", GFXS_BLEND_SRCCOLOR << GFXS0_DSTBLEND_ALPHA_SHIFT},
             {"InvSrcColor", GFXS_BLEND_INVSRCCOLOR << GFXS0_DSTBLEND_ALPHA_SHIFT},
             {"SrcAlpha", GFXS_BLEND_SRCALPHA << GFXS0_DSTBLEND_ALPHA_SHIFT},
             {"InvSrcAlpha", GFXS_BLEND_INVSRCALPHA << GFXS0_DSTBLEND_ALPHA_SHIFT},
             {"DestAlpha", GFXS_BLEND_DESTALPHA << GFXS0_DSTBLEND_ALPHA_SHIFT},
             {"InvDestAlpha", GFXS_BLEND_INVDESTALPHA << GFXS0_DSTBLEND_ALPHA_SHIFT},
             {"DestColor", GFXS_BLEND_DESTCOLOR << GFXS0_DSTBLEND_ALPHA_SHIFT},
             {"InvDestColor", GFXS_BLEND_INVDESTCOLOR << GFXS0_DSTBLEND_ALPHA_SHIFT},
         }},
        {"mtlCullFace",
         0, {
             {"None", GFXS0_CULL_NONE},
             {"Back", GFXS0_CULL_BACK},
             {"Front", GFXS0_CULL_FRONT},
         }},
        {"mtlColorWriteRgb",
         0, {
             {"Enable", GFXS0_COLORWRITE_RGB},
             {"Disable", 0},
         }},
        {"mtlColorWriteAlpha",
         0, {
             {"Enable", GFXS0_COLORWRITE_ALPHA},
             {"Disable", 0},
         }},
        {"mtlGammaWrite",
         0, {
             {"Enable", GFXS0_GAMMAWRITE},
             {"Disable", 0},
         }},
        {"mtlWireframe",
         0, {
             {"Enable", GFXS0_POLYMODE_LINE},
             {"Disable", 0},
         }},
        {"mtlDepthTest",
         1, {
             {"Disable", GFXS1_DEPTHTEST_DISABLE},
             {"Less", GFXS1_DEPTHTEST_LESS},
             {"LessEqual", GFXS1_DEPTHTEST_LESSEQUAL},
             {"Equal", GFXS1_DEPTHTEST_EQUAL},
             {"Always", GFXS1_DEPTHTEST_ALWAYS},
         }},
        {"mtlDepthWrite",
         1, {
             {"Enable", GFXS1_DEPTHWRITE},
             {"Disable", 0},
         }},
        {"mtlPolygonOffset",
         1, {
             {"1", GFXS1_POLYGON_OFFSET_1},
             {"2", GFXS1_POLYGON_OFFSET_2},
             {"shadowmap", GFXS1_POLYGON_OFFSET_SHADOWMAP},
             {"0", GFXS1_POLYGON_OFFSET_0},
         }},
        {"mtlStencil",
         1, {
             {"OneSided", GFXS1_STENCIL_FRONT_ENABLE},
             {"TwoSided", GFXS1_STENCIL_FRONT_ENABLE | GFXS1_STENCIL_BACK_ENABLE},
             {"Disable", 0},
         }},
        {"mtlStencilFuncFront",
         1, {
             {"Less", GFXS_STENCILFUNC_LESS << GFXS1_STENCIL_FRONT_FUNC_SHIFT},
             {"Equal", GFXS_STENCILFUNC_EQUAL << GFXS1_STENCIL_FRONT_FUNC_SHIFT},
             {"LessEqual", GFXS_STENCILFUNC_LESSEQUAL << GFXS1_STENCIL_FRONT_FUNC_SHIFT},
             {"Greater", GFXS_STENCILFUNC_GREATER << GFXS1_STENCIL_FRONT_FUNC_SHIFT},
             {"NotEqual", GFXS_STENCILFUNC_NOTEQUAL << GFXS1_STENCIL_FRONT_FUNC_SHIFT},
             {"GreaterEqual", GFXS_STENCILFUNC_GREATEREQUAL << GFXS1_STENCIL_FRONT_FUNC_SHIFT},
             {"Always", GFXS_STENCILFUNC_ALWAYS << GFXS1_STENCIL_FRONT_FUNC_SHIFT},
             {"Never", GFXS_STENCILFUNC_NEVER << GFXS1_STENCIL_FRONT_FUNC_SHIFT},
         }},
        {"mtlStencilOpFrontPass",
         1, {
             {"Zero", GFXS_STENCILOP_ZERO << GFXS1_STENCIL_FRONT_PASS_SHIFT},
             {"Replace", GFXS_STENCILOP_REPLACE << GFXS1_STENCIL_FRONT_PASS_SHIFT},
             {"IncrSat", GFXS_STENCILOP_INCRSAT << GFXS1_STENCIL_FRONT_PASS_SHIFT},
             {"DecrSat", GFXS_STENCILOP_DECRSAT << GFXS1_STENCIL_FRONT_PASS_SHIFT},
             {"Invert", GFXS_STENCILOP_INVERT << GFXS1_STENCIL_FRONT_PASS_SHIFT},
             {"Incr", GFXS_STENCILOP_INCR << GFXS1_STENCIL_FRONT_PASS_SHIFT},
             {"Decr", GFXS_STENCILOP_DECR << GFXS1_STENCIL_FRONT_PASS_SHIFT},
             {"Keep", GFXS_STENCILOP_KEEP << GFXS1_STENCIL_FRONT_PASS_SHIFT},
         }},
        {"mtlStencilOpFrontFail",
         1, {
             {"Zero", GFXS_STENCILOP_ZERO << GFXS1_STENCIL_FRONT_FAIL_SHIFT},
             {"Replace", GFXS_STENCILOP_REPLACE << GFXS1_STENCIL_FRONT_FAIL_SHIFT},
             {"IncrSat", GFXS_STENCILOP_INCRSAT << GFXS1_STENCIL_FRONT_FAIL_SHIFT},
             {"DecrSat", GFXS_STENCILOP_DECRSAT << GFXS1_STENCIL_FRONT_FAIL_SHIFT},
             {"Invert", GFXS_STENCILOP_INVERT << GFXS1_STENCIL_FRONT_FAIL_SHIFT},
             {"Incr", GFXS_STENCILOP_INCR << GFXS1_STENCIL_FRONT_FAIL_SHIFT},
             {"Decr", GFXS_STENCILOP_DECR << GFXS1_STENCIL_FRONT_FAIL_SHIFT},
             {"Keep", GFXS_STENCILOP_KEEP << GFXS1_STENCIL_FRONT_FAIL_SHIFT},
         }},
        {"mtlStencilOpFrontZFail",
         1, {
             {"Zero", GFXS_STENCILOP_ZERO << GFXS1_STENCIL_FRONT_ZFAIL_SHIFT},
             {"Replace", GFXS_STENCILOP_REPLACE << GFXS1_STENCIL_FRONT_ZFAIL_SHIFT},
             {"IncrSat", GFXS_STENCILOP_INCRSAT << GFXS1_STENCIL_FRONT_ZFAIL_SHIFT},
             {"DecrSat", GFXS_STENCILOP_DECRSAT << GFXS1_STENCIL_FRONT_ZFAIL_SHIFT},
             {"Invert", GFXS_STENCILOP_INVERT << GFXS1_STENCIL_FRONT_ZFAIL_SHIFT},
             {"Incr", GFXS_STENCILOP_INCR << GFXS1_STENCIL_FRONT_ZFAIL_SHIFT},
             {"Decr", GFXS_STENCILOP_DECR << GFXS1_STENCIL_FRONT_ZFAIL_SHIFT},
             {"Keep", GFXS_STENCILOP_KEEP << GFXS1_STENCIL_FRONT_ZFAIL_SHIFT},
         }},
        {"mtlStencilFuncBack",
         1, {
             {"Less", GFXS_STENCILFUNC_LESS << GFXS1_STENCIL_BACK_FUNC_SHIFT},
             {"Equal", GFXS_STENCILFUNC_EQUAL << GFXS1_STENCIL_BACK_FUNC_SHIFT},
             {"LessEqual", GFXS_STENCILFUNC_LESSEQUAL << GFXS1_STENCIL_BACK_FUNC_SHIFT},
             {"Greater", GFXS_STENCILFUNC_GREATER << GFXS1_STENCIL_BACK_FUNC_SHIFT},
             {"NotEqual", GFXS_STENCILFUNC_NOTEQUAL << GFXS1_STENCIL_BACK_FUNC_SHIFT},
             {"GreaterEqual", GFXS_STENCILFUNC_GREATEREQUAL << GFXS1_STENCIL_BACK_FUNC_SHIFT},
             {"Always", GFXS_STENCILFUNC_ALWAYS << GFXS1_STENCIL_BACK_FUNC_SHIFT},
             {"Never", GFXS_STENCILFUNC_NEVER << GFXS1_STENCIL_BACK_FUNC_SHIFT},
         }},
        {"mtlStencilOpBackPass",
         1, {
             {"Zero", GFXS_STENCILOP_ZERO << GFXS1_STENCIL_BACK_PASS_SHIFT},
             {"Replace", GFXS_STENCILOP_REPLACE << GFXS1_STENCIL_BACK_PASS_SHIFT},
             {"IncrSat", GFXS_STENCILOP_INCRSAT << GFXS1_STENCIL_BACK_PASS_SHIFT},
             {"DecrSat", GFXS_STENCILOP_DECRSAT << GFXS1_STENCIL_BACK_PASS_SHIFT},
             {"Invert", GFXS_STENCILOP_INVERT << GFXS1_STENCIL_BACK_PASS_SHIFT},
             {"Incr", GFXS_STENCILOP_INCR << GFXS1_STENCIL_BACK_PASS_SHIFT},
             {"Decr", GFXS_STENCILOP_DECR << GFXS1_STENCIL_BACK_PASS_SHIFT},
             {"Keep", GFXS_STENCILOP_KEEP << GFXS1_STENCIL_BACK_PASS_SHIFT},
         }},
        {"mtlStencilOpBackFail",
         1, {
             {"Zero", GFXS_STENCILOP_ZERO << GFXS1_STENCIL_BACK_FAIL_SHIFT},
             {"Replace", GFXS_STENCILOP_REPLACE << GFXS1_STENCIL_BACK_FAIL_SHIFT},
             {"IncrSat", GFXS_STENCILOP_INCRSAT << GFXS1_STENCIL_BACK_FAIL_SHIFT},
             {"DecrSat", GFXS_STENCILOP_DECRSAT << GFXS1_STENCIL_BACK_FAIL_SHIFT},
             {"Invert", GFXS_STENCILOP_INVERT << GFXS1_STENCIL_BACK_FAIL_SHIFT},
             {"Incr", GFXS_STENCILOP_INCR << GFXS1_STENCIL_BACK_FAIL_SHIFT},
             {"Decr", GFXS_STENCILOP_DECR << GFXS1_STENCIL_BACK_FAIL_SHIFT},
             {"Keep", GFXS_STENCILOP_KEEP << GFXS1_STENCIL_BACK_FAIL_SHIFT},
         }},
        {"mtlStencilOpBackZFail",
         1, {
             {"Zero", GFXS_STENCILOP_ZERO << GFXS1_STENCIL_BACK_ZFAIL_SHIFT},
             {"Replace", GFXS_STENCILOP_REPLACE << GFXS1_STENCIL_BACK_ZFAIL_SHIFT},
             {"IncrSat", GFXS_STENCILOP_INCRSAT << GFXS1_STENCIL_BACK_ZFAIL_SHIFT},
             {"DecrSat", GFXS_STENCILOP_DECRSAT << GFXS1_STENCIL_BACK_ZFAIL_SHIFT},
             {"Invert", GFXS_STENCILOP_INVERT << GFXS1_STENCIL_BACK_ZFAIL_SHIFT},
             {"Incr", GFXS_STENCILOP_INCR << GFXS1_STENCIL_BACK_ZFAIL_SHIFT},
             {"Decr", GFXS_STENCILOP_DECR << GFXS1_STENCIL_BACK_ZFAIL_SHIFT},
             {"Keep", GFXS_STENCILOP_KEEP << GFXS1_STENCIL_BACK_ZFAIL_SHIFT},
         }},
    });

    static inline state_map::StateMapLayout stateMapLayout(std::extent_v<decltype(GfxStateBits::loadBits.raw)>, stateMapEntryLayout, stateMapVarLayout);
} // namespace IW4
