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

fix: inconsistencies on t5 technique compilation

This commit is contained in:
Jan Laupetin
2026-03-15 15:31:01 +01:00
parent f4ed3e6c93
commit b93925c306
6 changed files with 64 additions and 14 deletions

View File

@@ -1533,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

@@ -315,6 +315,7 @@ namespace T5
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
.techFlags = MTL_TECHFLAG_USES_LIGHT_SPOT_FACTORS, .techFlags = MTL_TECHFLAG_USES_LIGHT_SPOT_FACTORS,
.techFlagShaderType = techset::CommonTechniqueShaderType::PIXEL,
}, },
{ {
.value = CONST_SRC_CODE_LIGHT_ATTENUATION, .value = CONST_SRC_CODE_LIGHT_ATTENUATION,
@@ -730,6 +731,7 @@ namespace T5
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
.techFlags = MTL_TECHFLAG_USES_GRASS, .techFlags = MTL_TECHFLAG_USES_GRASS,
.techFlagShaderType = techset::CommonTechniqueShaderType::VERTEX,
}, },
{ {
.value = CONST_SRC_CODE_GRASS_FORCE0, .value = CONST_SRC_CODE_GRASS_FORCE0,
@@ -737,6 +739,7 @@ namespace T5
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
.techFlags = MTL_TECHFLAG_USES_GRASS, .techFlags = MTL_TECHFLAG_USES_GRASS,
.techFlagShaderType = techset::CommonTechniqueShaderType::VERTEX,
}, },
{ {
.value = CONST_SRC_CODE_GRASS_FORCE1, .value = CONST_SRC_CODE_GRASS_FORCE1,
@@ -744,6 +747,7 @@ namespace T5
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
.techFlags = MTL_TECHFLAG_USES_GRASS, .techFlags = MTL_TECHFLAG_USES_GRASS,
.techFlagShaderType = techset::CommonTechniqueShaderType::VERTEX,
}, },
{ {
.value = CONST_SRC_CODE_GRASS_WIND_FORCE0, .value = CONST_SRC_CODE_GRASS_WIND_FORCE0,
@@ -751,6 +755,7 @@ namespace T5
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
.techFlags = MTL_TECHFLAG_USES_GRASS, .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,
@@ -841,7 +846,8 @@ namespace T5
.accessor = "destructibleParms", .accessor = "destructibleParms",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
.techFlags = TECHNIQUE_FLAG_200, .techFlags = MTL_TECHFLAG_200,
.techFlagShaderType = techset::CommonTechniqueShaderType::VERTEX,
}, },
{ {
.value = CONST_SRC_CODE_CLOUD_WORLD_AREA, .value = CONST_SRC_CODE_CLOUD_WORLD_AREA,
@@ -866,7 +872,8 @@ namespace T5
.accessor = "__characterCharredAmount", .accessor = "__characterCharredAmount",
.arrayCount = 0, .arrayCount = 0,
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY, .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
.techFlags = TECHNIQUE_FLAG_200, .techFlags = MTL_TECHFLAG_200,
.techFlagShaderType = techset::CommonTechniqueShaderType::VERTEX,
}, },
{ {
.value = CONST_SRC_CODE_TREECANOPY_PARMS, .value = CONST_SRC_CODE_TREECANOPY_PARMS,
@@ -879,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,
@@ -1587,7 +1596,7 @@ 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_SECONDARY, .customSamplerIndex = CUSTOM_SAMPLER_LIGHTMAP_PRIMARY,
}, },
{ {
.value = TEXTURE_SRC_CODE_LIGHTMAP_SECONDARY, .value = TEXTURE_SRC_CODE_LIGHTMAP_SECONDARY,
@@ -1709,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,

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

@@ -277,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{};
@@ -515,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{};
@@ -825,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)
{ {
@@ -862,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{};
@@ -870,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

@@ -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

@@ -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);