mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-03-05 12:33:02 +00:00
fix: technique loading tech flags
This commit is contained in:
@@ -1504,6 +1504,29 @@ namespace T5
|
|||||||
const char* techniqueSetPrefix;
|
const char* techniqueSetPrefix;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum TechniqueFlags
|
||||||
|
{
|
||||||
|
TECHNIQUE_FLAG_1 = 0x1,
|
||||||
|
TECHNIQUE_FLAG_2 = 0x2,
|
||||||
|
TECHNIQUE_FLAG_4 = 0x4,
|
||||||
|
|
||||||
|
// Vertex decl has optional source
|
||||||
|
TECHNIQUE_FLAG_8 = 0x8,
|
||||||
|
|
||||||
|
TECHNIQUE_FLAG_10 = 0x10,
|
||||||
|
TECHNIQUE_FLAG_20 = 0x20,
|
||||||
|
TECHNIQUE_FLAG_40 = 0x40,
|
||||||
|
|
||||||
|
// Any material that has statebits according to any of the following sets this:
|
||||||
|
// - GFXS1_DEPTHWRITE set
|
||||||
|
// - Any depth test (No GFXS1_DEPTHTEST_DISABLE set)
|
||||||
|
// - Any polygon offset that is not GFXS1_POLYGON_OFFSET_0
|
||||||
|
TECHNIQUE_FLAG_80 = 0x80,
|
||||||
|
|
||||||
|
TECHNIQUE_FLAG_100 = 0x100,
|
||||||
|
TECHNIQUE_FLAG_200 = 0x200,
|
||||||
|
};
|
||||||
|
|
||||||
struct MaterialPass
|
struct MaterialPass
|
||||||
{
|
{
|
||||||
MaterialVertexDeclaration* vertexDecl;
|
MaterialVertexDeclaration* vertexDecl;
|
||||||
|
|||||||
@@ -3004,7 +3004,6 @@ namespace T6
|
|||||||
enum CustomSamplers
|
enum CustomSamplers
|
||||||
{
|
{
|
||||||
CUSTOM_SAMPLER_REFLECTION_PROBE = 0,
|
CUSTOM_SAMPLER_REFLECTION_PROBE = 0,
|
||||||
CUSTOM_SAMPLER_LIGHTMAP_PRIMARY,
|
|
||||||
CUSTOM_SAMPLER_LIGHTMAP_SECONDARY,
|
CUSTOM_SAMPLER_LIGHTMAP_SECONDARY,
|
||||||
|
|
||||||
CUSTOM_SAMPLER_COUNT
|
CUSTOM_SAMPLER_COUNT
|
||||||
@@ -3049,11 +3048,20 @@ namespace T6
|
|||||||
TECHNIQUE_FLAG_1 = 0x1,
|
TECHNIQUE_FLAG_1 = 0x1,
|
||||||
TECHNIQUE_FLAG_2 = 0x2,
|
TECHNIQUE_FLAG_2 = 0x2,
|
||||||
TECHNIQUE_FLAG_4 = 0x4,
|
TECHNIQUE_FLAG_4 = 0x4,
|
||||||
|
|
||||||
|
// Vertex decl has optional source
|
||||||
TECHNIQUE_FLAG_8 = 0x8,
|
TECHNIQUE_FLAG_8 = 0x8,
|
||||||
|
|
||||||
TECHNIQUE_FLAG_10 = 0x10,
|
TECHNIQUE_FLAG_10 = 0x10,
|
||||||
TECHNIQUE_FLAG_20 = 0x20,
|
TECHNIQUE_FLAG_20 = 0x20,
|
||||||
TECHNIQUE_FLAG_40 = 0x40,
|
TECHNIQUE_FLAG_40 = 0x40,
|
||||||
|
|
||||||
|
// Any material that has statebits according to any of the following sets this:
|
||||||
|
// - GFXS1_DEPTHWRITE set
|
||||||
|
// - Any depth test (No GFXS1_DEPTHTEST_DISABLE set)
|
||||||
|
// - Any polygon offset that is not GFXS1_POLYGON_OFFSET_0
|
||||||
TECHNIQUE_FLAG_80 = 0x80,
|
TECHNIQUE_FLAG_80 = 0x80,
|
||||||
|
|
||||||
TECHNIQUE_FLAG_100 = 0x100,
|
TECHNIQUE_FLAG_100 = 0x100,
|
||||||
TECHNIQUE_FLAG_200 = 0x200,
|
TECHNIQUE_FLAG_200 = 0x200,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1577,7 +1577,6 @@ namespace T6
|
|||||||
.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,
|
||||||
|
|||||||
@@ -151,6 +151,22 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
ConvertMaterialArgs(pass, commonPass, memory, context);
|
ConvertMaterialArgs(pass, commonPass, memory, context);
|
||||||
|
pass.customSamplerFlags = static_cast<decltype(MaterialPass::customSamplerFlags)>(commonPass.m_sampler_flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AnyDeclHasOptionalSource(const MaterialTechnique& technique)
|
||||||
|
{
|
||||||
|
for (auto passIndex = 0u; passIndex < technique.passCount; passIndex++)
|
||||||
|
{
|
||||||
|
const auto& pass = technique.passArray[passIndex];
|
||||||
|
if (!pass.vertexDecl)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (pass.vertexDecl->hasOptionalSource)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateTechniqueFlags(MaterialTechnique& technique, const techset::CommonTechnique& commonTechnique)
|
void UpdateTechniqueFlags(MaterialTechnique& technique, const techset::CommonTechnique& commonTechnique)
|
||||||
@@ -165,6 +181,9 @@ namespace
|
|||||||
{
|
{
|
||||||
technique.flags |= TECHNIQUE_FLAG_4;
|
technique.flags |= TECHNIQUE_FLAG_4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (AnyDeclHasOptionalSource(technique))
|
||||||
|
technique.flags |= TECHNIQUE_FLAG_8;
|
||||||
}
|
}
|
||||||
|
|
||||||
MaterialTechnique* ConvertTechnique(const techset::CommonTechnique& commonTechnique, AssetCreationContext& context, MemoryManager& memory)
|
MaterialTechnique* ConvertTechnique(const techset::CommonTechnique& commonTechnique, AssetCreationContext& context, MemoryManager& memory)
|
||||||
@@ -176,15 +195,15 @@ namespace
|
|||||||
|
|
||||||
technique->name = memory.Dup(commonTechnique.m_name.c_str());
|
technique->name = memory.Dup(commonTechnique.m_name.c_str());
|
||||||
|
|
||||||
// Take common flags and apply further logic
|
|
||||||
technique->flags = static_cast<decltype(MaterialTechnique::flags)>(commonTechnique.m_flags);
|
|
||||||
UpdateTechniqueFlags(*technique, commonTechnique);
|
|
||||||
|
|
||||||
technique->passCount = passCount;
|
technique->passCount = passCount;
|
||||||
|
|
||||||
for (auto passIndex = 0u; passIndex < passCount; passIndex++)
|
for (auto passIndex = 0u; passIndex < passCount; passIndex++)
|
||||||
ConvertMaterialPass(technique->passArray[passIndex], commonTechnique.m_passes[passIndex], context, memory);
|
ConvertMaterialPass(technique->passArray[passIndex], commonTechnique.m_passes[passIndex], context, memory);
|
||||||
|
|
||||||
|
// Take common flags and apply further logic
|
||||||
|
technique->flags = static_cast<decltype(MaterialTechnique::flags)>(commonTechnique.m_flags);
|
||||||
|
UpdateTechniqueFlags(*technique, commonTechnique);
|
||||||
|
|
||||||
return technique;
|
return technique;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ TEST_CASE("TechniqueCompilerT6", "[t6][techset][compiler]")
|
|||||||
|
|
||||||
SECTION("Can compile simple technique")
|
SECTION("Can compile simple technique")
|
||||||
{
|
{
|
||||||
searchPath.AddFileData("techniques/example_zprepass.tech", R"TECHNIQUE(
|
searchPath.AddFileData("techniques/pimp_technique_zprepass_example.tech", R"TECHNIQUE(
|
||||||
{
|
{
|
||||||
stateMap "passthrough";
|
stateMap "passthrough";
|
||||||
|
|
||||||
@@ -91,14 +91,16 @@ TEST_CASE("TechniqueCompilerT6", "[t6][techset][compiler]")
|
|||||||
GivenVertexShaderFile("simple.hlsl", searchPath);
|
GivenVertexShaderFile("simple.hlsl", searchPath);
|
||||||
GivenPixelShaderFile("simple.hlsl", searchPath);
|
GivenPixelShaderFile("simple.hlsl", searchPath);
|
||||||
|
|
||||||
auto result = loader->CreateSubAsset("example_zprepass", context);
|
auto result = loader->CreateSubAsset("pimp_technique_zprepass_example", context);
|
||||||
REQUIRE(result.HasBeenSuccessful());
|
REQUIRE(result.HasBeenSuccessful());
|
||||||
|
|
||||||
const auto* assetInfo = reinterpret_cast<XAssetInfo<MaterialTechnique>*>(result.GetAssetInfo());
|
const auto* assetInfo = reinterpret_cast<XAssetInfo<MaterialTechnique>*>(result.GetAssetInfo());
|
||||||
const auto* technique = assetInfo->Asset();
|
const auto* technique = assetInfo->Asset();
|
||||||
|
|
||||||
CHECK(technique->name == "example_zprepass"s);
|
CHECK(technique->name == "pimp_technique_zprepass_example"s);
|
||||||
CHECK(technique->flags == 0x84);
|
|
||||||
|
// Usually would be 0x80 set as well, but that's only set when postprocessing with materials
|
||||||
|
CHECK(technique->flags == 0x04);
|
||||||
|
|
||||||
REQUIRE(technique->passCount == 1);
|
REQUIRE(technique->passCount == 1);
|
||||||
auto& pass = technique->passArray[0];
|
auto& pass = technique->passArray[0];
|
||||||
@@ -186,7 +188,9 @@ TEST_CASE("TechniqueCompilerT6", "[t6][techset][compiler]")
|
|||||||
const auto* technique = assetInfo->Asset();
|
const auto* technique = assetInfo->Asset();
|
||||||
|
|
||||||
CHECK(technique->name == "example_lit_sun_shadow"s);
|
CHECK(technique->name == "example_lit_sun_shadow"s);
|
||||||
CHECK(technique->flags == 0x88);
|
|
||||||
|
// Usually would be 0x80 set as well, but that's only set when postprocessing with materials
|
||||||
|
CHECK(technique->flags == 0x08);
|
||||||
|
|
||||||
REQUIRE(technique->passCount == 1);
|
REQUIRE(technique->passCount == 1);
|
||||||
auto& pass = technique->passArray[0];
|
auto& pass = technique->passArray[0];
|
||||||
|
|||||||
Reference in New Issue
Block a user