mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-03-05 12:33:02 +00:00
chore: handle flag 80 on t6 techniques
This commit is contained in:
@@ -25,7 +25,7 @@ namespace
|
||||
collection.AddAssetCreator(key_value_pairs::CreateCompilerT6(memory, zone, zoneDefinition.m_zone_definition, zoneStates));
|
||||
collection.AddAssetCreator(techset::CreateCompilerT6(memory, searchPath));
|
||||
|
||||
collection.AddSubAssetCreator(techset::CreateTechniqueCompilerT6(memory, searchPath));
|
||||
collection.AddSubAssetCreator(techset::CreateTechniqueCompilerT6(memory, zone, searchPath));
|
||||
collection.AddSubAssetCreator(techset::CreateVertexDeclCompilerT6(memory));
|
||||
}
|
||||
|
||||
|
||||
@@ -207,6 +207,27 @@ namespace
|
||||
return technique;
|
||||
}
|
||||
|
||||
void ApplyTechFlagsFromMaterial(const Material& material)
|
||||
{
|
||||
if (!material.techniqueSet || material.stateBitsTable)
|
||||
return;
|
||||
|
||||
for (auto techType = 0u; techType < TECHNIQUE_COUNT; techType++)
|
||||
{
|
||||
auto* technique = material.techniqueSet->techniques[techType];
|
||||
const auto stateBitsEntry = material.stateBitsEntry[techType];
|
||||
|
||||
if (!technique || stateBitsEntry < 0 || static_cast<decltype(Material::stateBitsCount)>(stateBitsEntry) >= material.stateBitsCount)
|
||||
continue;
|
||||
|
||||
const auto& stateBits = material.stateBitsTable[static_cast<decltype(Material::stateBitsCount)>(stateBitsEntry)].loadBits;
|
||||
const bool shouldSetFlag80 = stateBits.structured.depthTestDisabled == 0 || stateBits.structured.depthWrite > 0
|
||||
|| stateBits.structured.depthTest > 0 || stateBits.structured.polygonOffset > 0;
|
||||
if (shouldSetFlag80)
|
||||
technique->flags |= TECHNIQUE_FLAG_80;
|
||||
}
|
||||
}
|
||||
|
||||
class TechniqueShaderLoaderT6 final : public techset::ITechniqueShaderLoader
|
||||
{
|
||||
public:
|
||||
@@ -256,8 +277,9 @@ namespace
|
||||
class TechniqueCompilerT6 final : public SubAssetCreator<SubAssetTechnique>
|
||||
{
|
||||
public:
|
||||
TechniqueCompilerT6(MemoryManager& memory, ISearchPath& searchPath)
|
||||
TechniqueCompilerT6(MemoryManager& memory, Zone& zone, ISearchPath& searchPath)
|
||||
: m_memory(memory),
|
||||
m_zone(zone),
|
||||
m_search_path(searchPath)
|
||||
{
|
||||
}
|
||||
@@ -280,16 +302,26 @@ namespace
|
||||
return AssetCreationResult::Success(context.AddSubAsset(AssetRegistration<SubAssetTechnique>(subAssetName, convertedTechnique)));
|
||||
}
|
||||
|
||||
void FinalizeZone(AssetCreationContext& context) override
|
||||
{
|
||||
const auto materials = m_zone.m_pools.PoolAssets<AssetMaterial>();
|
||||
for (auto* materialAsset : materials)
|
||||
{
|
||||
ApplyTechFlagsFromMaterial(*materialAsset->Asset());
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
MemoryManager& m_memory;
|
||||
Zone& m_zone;
|
||||
ISearchPath& m_search_path;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace techset
|
||||
{
|
||||
std::unique_ptr<ISubAssetCreator> CreateTechniqueCompilerT6(MemoryManager& memory, ISearchPath& searchPath)
|
||||
std::unique_ptr<ISubAssetCreator> CreateTechniqueCompilerT6(MemoryManager& memory, Zone& zone, ISearchPath& searchPath)
|
||||
{
|
||||
return std::make_unique<TechniqueCompilerT6>(memory, searchPath);
|
||||
return std::make_unique<TechniqueCompilerT6>(memory, zone, searchPath);
|
||||
}
|
||||
} // namespace techset
|
||||
|
||||
@@ -8,5 +8,5 @@
|
||||
|
||||
namespace techset
|
||||
{
|
||||
std::unique_ptr<ISubAssetCreator> CreateTechniqueCompilerT6(MemoryManager& memory, ISearchPath& searchPath);
|
||||
std::unique_ptr<ISubAssetCreator> CreateTechniqueCompilerT6(MemoryManager& memory, Zone& zone, ISearchPath& searchPath);
|
||||
}
|
||||
|
||||
@@ -111,6 +111,8 @@ AssetCreationResult AssetCreatorCollection::CreateDefaultAsset(const asset_type_
|
||||
|
||||
void AssetCreatorCollection::FinalizeZone(AssetCreationContext& context) const
|
||||
{
|
||||
for (const auto& creator : m_sub_asset_creators)
|
||||
creator->FinalizeZone(context);
|
||||
for (const auto& creator : m_asset_creators)
|
||||
creator->FinalizeZone(context);
|
||||
for (const auto& postProcessor : m_asset_post_processors)
|
||||
|
||||
@@ -317,11 +317,12 @@ namespace
|
||||
if (arg.m_type.m_value_type == CommonShaderValueType::CODE_CONST)
|
||||
{
|
||||
auto constSourceInfo = m_code_source_infos.GetInfoForCodeConstSource(arg.m_value.code_const_source.m_index);
|
||||
const auto isMatrix = constSourceInfo && constSourceInfo->transposedMatrix.has_value();
|
||||
|
||||
if (isTransposed)
|
||||
{
|
||||
assert(constSourceInfo);
|
||||
if (constSourceInfo && constSourceInfo->transposedMatrix)
|
||||
assert(isMatrix);
|
||||
if (isMatrix)
|
||||
constSourceInfo = m_code_source_infos.GetInfoForCodeConstSource(*constSourceInfo->transposedMatrix);
|
||||
}
|
||||
|
||||
@@ -333,6 +334,10 @@ namespace
|
||||
else
|
||||
codeAccessor = std::format("{}[{}]", constSourceInfo->accessor, arg.m_value.code_const_source.m_index - constSourceInfo->value);
|
||||
|
||||
// Assert that the value uses 4 rows when matrix and 1 otherwise.
|
||||
// If this is untrue, there must be more code handling the selected rows
|
||||
assert((isMatrix && arg.m_value.code_const_source.m_row_count == 4) || arg.m_value.code_const_source.m_row_count == 1);
|
||||
|
||||
if (codeDestAccessor != codeAccessor)
|
||||
{
|
||||
Indent();
|
||||
|
||||
@@ -102,12 +102,12 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
AssetPoolIterator<Asset_t> begin()
|
||||
AssetPoolIterator<Asset_t> begin() const
|
||||
{
|
||||
return AssetPoolIterator<Asset_t>(m_asset_pool.begin());
|
||||
}
|
||||
|
||||
AssetPoolIterator<Asset_t> end()
|
||||
AssetPoolIterator<Asset_t> end() const
|
||||
{
|
||||
return AssetPoolIterator<Asset_t>(m_asset_pool.end());
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ TEST_CASE("TechniqueCompilerT6", "[t6][techset][compiler]")
|
||||
creatorCollection.AddSubAssetCreator(techset::CreateVertexShaderLoaderT6(memory, searchPath));
|
||||
creatorCollection.AddSubAssetCreator(techset::CreatePixelShaderLoaderT6(memory, searchPath));
|
||||
|
||||
auto loader = techset::CreateTechniqueCompilerT6(memory, searchPath);
|
||||
auto loader = techset::CreateTechniqueCompilerT6(memory, zone, searchPath);
|
||||
|
||||
SECTION("Can compile simple technique")
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user