Enable material version updates.
Signed-off-by: Robin <rbarrand@amazon.com>
This commit is contained in:
@@ -119,6 +119,29 @@ namespace AZ
|
||||
|
||||
using PropertyList = AZStd::vector<PropertyDefinition>;
|
||||
|
||||
struct VersionUpdatesRenameOperationDefinition
|
||||
{
|
||||
AZ_TYPE_INFO(AZ::RPI::MaterialTypeSourceData::VersionUpdatesRenameOperationDefinition, "{F2295489-E15A-46CC-929F-8D42DEDBCF14}");
|
||||
|
||||
AZStd::string m_operation;
|
||||
|
||||
AZStd::string m_renameFrom;
|
||||
AZStd::string m_renameTo;
|
||||
};
|
||||
|
||||
// TODO: Support script operations. We will only be supporting rename for now.
|
||||
using VersionUpdateActions = AZStd::vector<VersionUpdatesRenameOperationDefinition>;
|
||||
|
||||
struct VersionUpdateDefinition
|
||||
{
|
||||
AZ_TYPE_INFO(AZ::RPI::MaterialTypeSourceData::VersionUpdateDefinition, "{2C9D3B91-0585-4BC9-91D2-4CF0C71BC4B7}");
|
||||
|
||||
uint32_t m_toVersion;
|
||||
VersionUpdateActions m_actions;
|
||||
};
|
||||
|
||||
using VersionUpdates = AZStd::vector<VersionUpdateDefinition>;
|
||||
|
||||
struct PropertyLayout
|
||||
{
|
||||
AZ_TYPE_INFO(AZ::RPI::MaterialTypeSourceData::PropertyLayout, "{AE53CF3F-5C3B-44F5-B2FB-306F0EB06393}");
|
||||
@@ -135,6 +158,11 @@ namespace AZ
|
||||
|
||||
AZStd::string m_description;
|
||||
|
||||
//! Version 1 is the default and should not contain any version update.
|
||||
uint32_t m_version = 1;
|
||||
|
||||
VersionUpdates m_versionUpdates;
|
||||
|
||||
PropertyLayout m_propertyLayout;
|
||||
|
||||
//! A list of shader variants that are always used at runtime; they cannot be turned off
|
||||
|
||||
@@ -119,6 +119,11 @@ namespace AZ
|
||||
//! from m_materialTypeAsset.
|
||||
void RealignPropertyValuesAndNames();
|
||||
|
||||
//! Renames properties in m_propertyNames based on the MaterialTypeAsset's version update.
|
||||
void RenamePropertyNames();
|
||||
template <typename iteratorType>
|
||||
void RenamePropertyNames(iteratorType start, iteratorType end);
|
||||
|
||||
//! Called by asset creators to assign the asset to a ready state.
|
||||
void SetReady();
|
||||
|
||||
@@ -143,6 +148,10 @@ namespace AZ
|
||||
//! If empty, this implies that m_propertyValues is aligned with the entries in m_materialPropertiesLayout.
|
||||
AZStd::vector<AZ::Name> m_propertyNames;
|
||||
|
||||
//! The materialTypeVersion this materialAsset was based of. If the versions do not match at runtime when a
|
||||
//! materialTypeAsset is loaded, an update will be performed on m_propertyNames if populated.
|
||||
uint32_t m_materialTypeVersion = 1;
|
||||
|
||||
//! A flag to determine if m_propertyValues needs to be aligned with MaterialPropertiesLayout. Set to true whenever
|
||||
//! m_materialTypeAsset is reinitializing.
|
||||
bool m_isDirty = true;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <Atom/RPI.Reflect/Material/ShaderCollection.h>
|
||||
#include <Atom/RPI.Reflect/Material/MaterialPropertiesLayout.h>
|
||||
#include <Atom/RPI.Reflect/Material/MaterialFunctor.h>
|
||||
#include <Atom/RPI.Reflect/Material/MaterialVersionUpdate.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -123,6 +124,13 @@ namespace AZ
|
||||
//! Returns a map from the UV shader inputs to a custom name.
|
||||
MaterialUvNameMap GetUvNameMap() const;
|
||||
|
||||
//! Returns the version of the MaterialTypeAsset.
|
||||
uint32_t GetVersion() const;
|
||||
//! Returns the version update containing the actions to perform. If a version
|
||||
//! is not defined in m_materialVersionUpdatesMap, a material version with the specified
|
||||
//! version but empty actions will be returned.
|
||||
const MaterialVersionUpdate GetMaterialVersionUpdate(uint32_t version) const;
|
||||
|
||||
private:
|
||||
bool PostLoadInit() override;
|
||||
|
||||
@@ -162,6 +170,12 @@ namespace AZ
|
||||
//! Index in @m_shaderCollection of the shader asset that contains the ObjectSrg.
|
||||
uint32_t m_objectSrgShaderIndex = InvalidShaderIndex;
|
||||
|
||||
//! The version of this MaterialTypeAsset. If the version is greater than 1, actions performed
|
||||
//! to update this MaterialTypeAsset will be in m_materialVersionUpdateMap
|
||||
uint32_t m_version = 1;
|
||||
|
||||
//! Contains actions to perform for each material update version.
|
||||
MaterialVersionUpdateMap m_materialVersionUpdateMap;
|
||||
};
|
||||
|
||||
class MaterialTypeAssetHandler : public AssetHandler<MaterialTypeAsset>
|
||||
|
||||
@@ -38,6 +38,11 @@ namespace AZ
|
||||
void AddShader(const AZ::Data::Asset<ShaderAsset>& shaderAsset, const ShaderVariantId& shaderVaraintId = ShaderVariantId{}, const AZ::Name& shaderTag = Uuid::CreateRandom().ToString<AZ::Name>());
|
||||
void AddShader(const AZ::Data::Asset<ShaderAsset>& shaderAsset, const AZ::Name& shaderTag);
|
||||
|
||||
//! Sets the version of the MaterialTypeAsset
|
||||
void SetVersion(uint32_t version);
|
||||
//! Adds a version update object into the MaterialTypeAsset
|
||||
void AddVersionUpdate(uint32_t toVersion, MaterialVersionUpdate materialVersionUpdate);
|
||||
|
||||
//! Indicates that this MaterialType will own the specified shader option.
|
||||
//! Material-owned shader options can be connected to material properties (either directly or through functors).
|
||||
//! They cannot be accessed externally (for example, through the Material::SetSystemShaderOption() function).
|
||||
@@ -112,6 +117,7 @@ namespace AZ
|
||||
//! Saves the per-material SRG layout in m_shaderResourceGroupLayout for easier access
|
||||
void CacheMaterialSrgLayout();
|
||||
|
||||
bool ValidateMaterialVersion();
|
||||
bool ValidateBeginMaterialProperty();
|
||||
bool ValidateEndMaterialProperty();
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/RTTI/ReflectContext.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
#include <AzCore/std/containers/map.h>
|
||||
#include <AzCore/std/string/string.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace RPI
|
||||
{
|
||||
struct MaterialVersionUpdate
|
||||
{
|
||||
AZ_TYPE_INFO(AZ::RPI::MaterialVersionUpdate, "{B36E7712-AED8-46AA-AFE0-01F8F884C44A}");
|
||||
|
||||
static void Reflect(ReflectContext* context);
|
||||
|
||||
struct Action
|
||||
{
|
||||
AZ_TYPE_INFO(AZ::RPI::MaterialVersionUpdate::Action, "{A1FBEB19-EA05-40F0-9700-57D048DF572B}");
|
||||
|
||||
AZStd::string m_operation;
|
||||
AZStd::map<AZStd::string, AZStd::string> m_argsMap;
|
||||
|
||||
Action() = default;
|
||||
Action(const AZStd::string& operation, const AZStd::initializer_list<AZStd::pair<AZStd::string, AZStd::string>>& args);
|
||||
void AddArgs(const AZStd::string& key, const AZStd::string& argument);
|
||||
};
|
||||
|
||||
MaterialVersionUpdate() = default;
|
||||
MaterialVersionUpdate(uint32_t toVersion);
|
||||
|
||||
uint32_t m_toVersion;
|
||||
|
||||
using Actions = AZStd::vector<Action>;
|
||||
Actions m_actions;
|
||||
};
|
||||
|
||||
using MaterialVersionUpdateMap = AZStd::map<uint32_t, MaterialVersionUpdate>;
|
||||
} // namespace RPI
|
||||
} // namespace AZ
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <Atom/RPI.Edit/Common/AssetUtils.h>
|
||||
#include <Atom/RPI.Reflect/Material/MaterialTypeAssetCreator.h>
|
||||
#include <Atom/RPI.Reflect/Material/MaterialFunctor.h>
|
||||
#include <Atom/RPI.Reflect/Material/MaterialVersionUpdate.h>
|
||||
#include <Atom/RPI.Reflect/Shader/ShaderOptionGroup.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzCore/Serialization/Json/RegistrationContext.h>
|
||||
@@ -58,6 +59,23 @@ namespace AZ
|
||||
|
||||
serializeContext->RegisterGenericType<PropertyConnectionList>();
|
||||
|
||||
serializeContext->Class<VersionUpdatesRenameOperationDefinition>()
|
||||
->Version(1)
|
||||
->Field("op", &VersionUpdatesRenameOperationDefinition::m_operation)
|
||||
->Field("from", &VersionUpdatesRenameOperationDefinition::m_renameFrom)
|
||||
->Field("to", &VersionUpdatesRenameOperationDefinition::m_renameTo)
|
||||
;
|
||||
|
||||
serializeContext->RegisterGenericType<VersionUpdateActions>();
|
||||
|
||||
serializeContext->Class<VersionUpdateDefinition>()
|
||||
->Version(1)
|
||||
->Field("toVersion", &VersionUpdateDefinition::m_toVersion)
|
||||
->Field("actions", &VersionUpdateDefinition::m_actions)
|
||||
;
|
||||
|
||||
serializeContext->RegisterGenericType<VersionUpdates>();
|
||||
|
||||
serializeContext->Class<GroupDefinition>()
|
||||
->Version(1)
|
||||
->Field("id", &GroupDefinition::m_nameId)
|
||||
@@ -86,8 +104,10 @@ namespace AZ
|
||||
serializeContext->RegisterGenericType<UvNameMap>();
|
||||
|
||||
serializeContext->Class<MaterialTypeSourceData>()
|
||||
->Version(3)
|
||||
->Version(4)
|
||||
->Field("description", &MaterialTypeSourceData::m_description)
|
||||
->Field("version", &MaterialTypeSourceData::m_version)
|
||||
->Field("versionUpdates", &MaterialTypeSourceData::m_versionUpdates)
|
||||
->Field("propertyLayout", &MaterialTypeSourceData::m_propertyLayout)
|
||||
->Field("shaders", &MaterialTypeSourceData::m_shaderCollection)
|
||||
->Field("functors", &MaterialTypeSourceData::m_materialFunctorSourceData)
|
||||
@@ -290,6 +310,19 @@ namespace AZ
|
||||
materialTypeAssetCreator.SetElevateWarnings(elevateWarnings);
|
||||
materialTypeAssetCreator.Begin(assetId);
|
||||
|
||||
// Set materialtype version and add each version update object into MaterialTypeAsset.
|
||||
materialTypeAssetCreator.SetVersion(m_version);
|
||||
for (const auto& versionUpdate : m_versionUpdates)
|
||||
{
|
||||
MaterialVersionUpdate materialVersionUpdate;
|
||||
for (const auto& action : versionUpdate.m_actions)
|
||||
{
|
||||
materialVersionUpdate.m_actions.push_back(
|
||||
MaterialVersionUpdate::Action("rename", { { "from", action.m_renameFrom }, { "to", action.m_renameTo } }));
|
||||
}
|
||||
materialTypeAssetCreator.AddVersionUpdate(versionUpdate.m_toVersion, materialVersionUpdate);
|
||||
}
|
||||
|
||||
// Used to gather all the UV streams used in this material type from its shaders in alphabetical order.
|
||||
auto semanticComp = [](const RHI::ShaderSemantic& lhs, const RHI::ShaderSemantic& rhs) -> bool
|
||||
{
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <Atom/RPI.Reflect/Material/MaterialAsset.h>
|
||||
#include <Atom/RPI.Reflect/Material/MaterialPropertiesLayout.h>
|
||||
#include <Atom/RPI.Reflect/Material/MaterialFunctor.h>
|
||||
#include <Atom/RPI.Reflect/Material/MaterialVersionUpdate.h>
|
||||
#include <Atom/RPI.Reflect/Asset/AssetHandler.h>
|
||||
#include <Atom/RPI.Public/Shader/ShaderReloadDebugTracker.h>
|
||||
|
||||
@@ -31,8 +32,9 @@ namespace AZ
|
||||
if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<MaterialAsset, AZ::Data::AssetData>()
|
||||
->Version(10)
|
||||
->Version(11) // Material version update
|
||||
->Field("materialTypeAsset", &MaterialAsset::m_materialTypeAsset)
|
||||
->Field("materialTypeVersion", &MaterialAsset::m_materialTypeVersion)
|
||||
->Field("propertyValues", &MaterialAsset::m_propertyValues)
|
||||
->Field("propertyNames", &MaterialAsset::m_propertyNames)
|
||||
;
|
||||
@@ -102,9 +104,19 @@ namespace AZ
|
||||
|
||||
AZStd::array_view<MaterialPropertyValue> MaterialAsset::GetPropertyValues() const
|
||||
{
|
||||
if (!m_propertyNames.empty() && m_isDirty)
|
||||
if (!m_propertyNames.empty())
|
||||
{
|
||||
const_cast<MaterialAsset*>(this)->RealignPropertyValuesAndNames();
|
||||
const uint32_t materialTypeVersion = m_materialTypeAsset->GetVersion();
|
||||
if (m_materialTypeVersion != materialTypeVersion)
|
||||
{
|
||||
const_cast<MaterialAsset*>(this)->RenamePropertyNames();
|
||||
const_cast<uint32_t&>(m_materialTypeVersion) = materialTypeVersion;
|
||||
}
|
||||
|
||||
if (m_isDirty)
|
||||
{
|
||||
const_cast<MaterialAsset*>(this)->RealignPropertyValuesAndNames();
|
||||
}
|
||||
}
|
||||
|
||||
return m_propertyValues;
|
||||
@@ -182,6 +194,52 @@ namespace AZ
|
||||
m_isDirty = false;
|
||||
}
|
||||
|
||||
template <typename iteratorType>
|
||||
void MaterialAsset::RenamePropertyNames(iteratorType start, iteratorType end)
|
||||
{
|
||||
for (iteratorType it = start; it != end; ++it)
|
||||
{
|
||||
for (auto& propertyName : m_propertyNames)
|
||||
{
|
||||
const auto toFromIterator = it->find(propertyName.GetCStr());
|
||||
if (toFromIterator != it->end())
|
||||
{
|
||||
propertyName = AZ::Name{ toFromIterator->second };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MaterialAsset::RenamePropertyNames()
|
||||
{
|
||||
// construct toFrom map in ascending order of version.
|
||||
AZStd::vector<AZStd::map<AZStd::string, AZStd::string>> versionToFrom;
|
||||
|
||||
const bool ascending = m_materialTypeVersion < m_materialTypeAsset->GetVersion();
|
||||
for (int i = 0; i < AZStd::abs(static_cast<int>(m_materialTypeVersion - m_materialTypeAsset->GetVersion())); ++i)
|
||||
{
|
||||
const auto& versionUpdate = m_materialTypeAsset->GetMaterialVersionUpdate((m_materialTypeVersion < m_materialTypeAsset->GetVersion() ? m_materialTypeVersion : m_materialTypeAsset->GetVersion()) + i + 1);
|
||||
|
||||
versionToFrom.push_back();
|
||||
for (const auto& action : versionUpdate.m_actions)
|
||||
{
|
||||
const AZStd::string from = ascending ? action.m_argsMap.find("from")->second : action.m_argsMap.find("to")->second;
|
||||
const AZStd::string to = ascending ? action.m_argsMap.find("to")->second : action.m_argsMap.find("from")->second;
|
||||
|
||||
versionToFrom[i][from] = to;
|
||||
}
|
||||
}
|
||||
|
||||
if (ascending)
|
||||
{
|
||||
RenamePropertyNames(versionToFrom.cbegin(), versionToFrom.cend());
|
||||
}
|
||||
else
|
||||
{
|
||||
RenamePropertyNames(versionToFrom.crbegin(), versionToFrom.crend());
|
||||
}
|
||||
}
|
||||
|
||||
void MaterialAsset::ReinitializeMaterialTypeAsset(Data::Asset<Data::AssetData> asset)
|
||||
{
|
||||
Data::Asset<MaterialTypeAsset> newMaterialTypeAsset = { asset.GetAs<MaterialTypeAsset>(), AZ::Data::AssetLoadBehavior::PreLoad };
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace AZ
|
||||
if (ValidateIsReady())
|
||||
{
|
||||
m_asset->m_materialTypeAsset = parentMaterial.m_materialTypeAsset;
|
||||
m_asset->m_materialTypeVersion = m_asset->m_materialTypeAsset->GetVersion();
|
||||
|
||||
if (!m_asset->m_materialTypeAsset)
|
||||
{
|
||||
@@ -69,6 +70,7 @@ namespace AZ
|
||||
ReportError("MaterialTypeAsset is null");
|
||||
return;
|
||||
}
|
||||
m_asset->m_materialTypeVersion = m_asset->m_materialTypeAsset->GetVersion();
|
||||
|
||||
m_materialPropertiesLayout = m_asset->GetMaterialPropertiesLayout();
|
||||
if (includeMaterialPropertyNames)
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace AZ
|
||||
|
||||
void MaterialTypeAsset::Reflect(ReflectContext* context)
|
||||
{
|
||||
MaterialVersionUpdate::Reflect(context);
|
||||
UvNamePair::Reflect(context);
|
||||
|
||||
if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
|
||||
@@ -44,7 +45,9 @@ namespace AZ
|
||||
serializeContext->RegisterGenericType<MaterialUvNameMap>();
|
||||
|
||||
serializeContext->Class<MaterialTypeAsset, AZ::Data::AssetData>()
|
||||
->Version(4) // ATOM-15472
|
||||
->Version(5) // Material version update
|
||||
->Field("Version", &MaterialTypeAsset::m_version)
|
||||
->Field("VersionUpdates", &MaterialTypeAsset::m_materialVersionUpdateMap)
|
||||
->Field("ShaderCollection", &MaterialTypeAsset::m_shaderCollection)
|
||||
->Field("MaterialFunctors", &MaterialTypeAsset::m_materialFunctors)
|
||||
->Field("MaterialSrgShaderIndex", &MaterialTypeAsset::m_materialSrgShaderIndex)
|
||||
@@ -161,6 +164,17 @@ namespace AZ
|
||||
return m_uvNameMap;
|
||||
}
|
||||
|
||||
uint32_t MaterialTypeAsset::GetVersion() const
|
||||
{
|
||||
return m_version;
|
||||
}
|
||||
|
||||
const AZ::RPI::MaterialVersionUpdate MaterialTypeAsset::GetMaterialVersionUpdate(uint32_t version) const
|
||||
{
|
||||
const auto it = m_materialVersionUpdateMap.find(version);
|
||||
return it != m_materialVersionUpdateMap.end() ? it->second : MaterialVersionUpdate(version);
|
||||
}
|
||||
|
||||
void MaterialTypeAsset::SetReady()
|
||||
{
|
||||
m_status = AssetStatus::Ready;
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace AZ
|
||||
|
||||
bool MaterialTypeAssetCreator::End(Data::Asset<MaterialTypeAsset>& result)
|
||||
{
|
||||
if (!ValidateIsReady() || !ValidateEndMaterialProperty())
|
||||
if (!ValidateIsReady() || !ValidateEndMaterialProperty() || !ValidateMaterialVersion())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -100,6 +100,35 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
bool MaterialTypeAssetCreator::ValidateMaterialVersion()
|
||||
{
|
||||
AZStd::vector<AZStd::string> renamedPropertieNames;
|
||||
const auto& materialVersionUpdate = m_asset->GetMaterialVersionUpdate(m_asset->m_version);
|
||||
for (const auto& action : materialVersionUpdate.m_actions)
|
||||
{
|
||||
const auto it = action.m_argsMap.find("to");
|
||||
if (it != action.m_argsMap.end())
|
||||
{
|
||||
renamedPropertieNames.push_back(it->second);
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& propertyName : renamedPropertieNames)
|
||||
{
|
||||
const auto propertyIndex = m_asset->m_materialPropertiesLayout->FindPropertyIndex(AZ::Name{ propertyName });
|
||||
if (!propertyIndex.IsValid())
|
||||
{
|
||||
ReportError(AZStd::string::format(
|
||||
"Renamed property '%s' not found in material property layout. Check that the property name has been "
|
||||
"upgraded to the correct version",
|
||||
propertyName.c_str())
|
||||
.c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void MaterialTypeAssetCreator::AddShader(const AZ::Data::Asset<ShaderAsset>& shaderAsset, const ShaderVariantId& shaderVaraintId, const AZ::Name& shaderTag)
|
||||
{
|
||||
if (ValidateIsReady() && ValidateNotNull(shaderAsset, "ShaderAsset"))
|
||||
@@ -123,6 +152,16 @@ namespace AZ
|
||||
AddShader(shaderAsset, ShaderVariantId{}, shaderTag);
|
||||
}
|
||||
|
||||
void MaterialTypeAssetCreator::SetVersion(uint32_t version)
|
||||
{
|
||||
m_asset->m_version = version;
|
||||
}
|
||||
|
||||
void MaterialTypeAssetCreator::AddVersionUpdate(uint32_t toVersion, MaterialVersionUpdate materialVersionUpdate)
|
||||
{
|
||||
m_asset->m_materialVersionUpdateMap[toVersion] = materialVersionUpdate;
|
||||
}
|
||||
|
||||
void MaterialTypeAssetCreator::ClaimShaderOptionOwnership(const Name& shaderOptionName)
|
||||
{
|
||||
bool optionFound = false;
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Atom/RPI.Reflect/Material/MaterialVersionUpdate.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace RPI
|
||||
{
|
||||
void MaterialVersionUpdate::Reflect(ReflectContext* context)
|
||||
{
|
||||
if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<MaterialVersionUpdate::Action>()
|
||||
->Version(1)
|
||||
->Field("ArgsMap", &Action::m_argsMap)
|
||||
->Field("Operation", &Action::m_operation)
|
||||
;
|
||||
|
||||
serializeContext->RegisterGenericType<MaterialVersionUpdate::Actions>();
|
||||
|
||||
serializeContext->Class<MaterialVersionUpdate>()
|
||||
->Version(1)
|
||||
->Field("ToVersion", &MaterialVersionUpdate::m_toVersion)
|
||||
->Field("Actions", &MaterialVersionUpdate::m_actions)
|
||||
;
|
||||
|
||||
serializeContext->RegisterGenericType<MaterialVersionUpdateMap>();
|
||||
}
|
||||
}
|
||||
|
||||
MaterialVersionUpdate::MaterialVersionUpdate(uint32_t toVersion)
|
||||
: m_toVersion(toVersion)
|
||||
{
|
||||
}
|
||||
|
||||
MaterialVersionUpdate::Action::Action(const AZStd::string& operation, const AZStd::initializer_list<AZStd::pair<AZStd::string, AZStd::string>>& args)
|
||||
: m_operation(operation)
|
||||
{
|
||||
for (const auto& arg : args)
|
||||
{
|
||||
AddArgs(arg.first, arg.second);
|
||||
}
|
||||
}
|
||||
|
||||
void MaterialVersionUpdate::Action::AddArgs(const AZStd::string& key, const AZStd::string& argument)
|
||||
{
|
||||
m_argsMap[key] = argument;
|
||||
}
|
||||
} // namespace RPI
|
||||
} // namespace AZ
|
||||
@@ -61,6 +61,7 @@ set(FILES
|
||||
Include/Atom/RPI.Reflect/Material/MaterialTypeAssetCreator.h
|
||||
Include/Atom/RPI.Reflect/Material/ShaderCollection.h
|
||||
Include/Atom/RPI.Reflect/Material/MaterialFunctor.h
|
||||
Include/Atom/RPI.Reflect/Material/MaterialVersionUpdate.h
|
||||
Include/Atom/RPI.Reflect/Pass/ComputePassData.h
|
||||
Include/Atom/RPI.Reflect/Pass/CopyPassData.h
|
||||
Include/Atom/RPI.Reflect/Pass/DownsampleMipChainPassData.h
|
||||
@@ -141,6 +142,7 @@ set(FILES
|
||||
Source/RPI.Reflect/Material/MaterialTypeAssetCreator.cpp
|
||||
Source/RPI.Reflect/Material/ShaderCollection.cpp
|
||||
Source/RPI.Reflect/Material/MaterialFunctor.cpp
|
||||
Source/RPI.Reflect/Material/MaterialVersionUpdate.cpp
|
||||
Source/RPI.Reflect/Pass/PassAsset.cpp
|
||||
Source/RPI.Reflect/Pass/PassAttachmentReflect.cpp
|
||||
Source/RPI.Reflect/Pass/PassRequest.cpp
|
||||
|
||||
Reference in New Issue
Block a user