Merge remote-tracking branch 'origin/main' into Atom/santorac/NewLayeringWorkflow

This commit is contained in:
Chris Santora
2021-05-19 16:57:49 -07:00
1648 changed files with 14429 additions and 94150 deletions
@@ -93,11 +93,12 @@ namespace AZ
void Pass::SetEnabled(bool enabled)
{
m_flags.m_enabled = enabled;
OnHierarchyChange();
}
bool Pass::IsEnabled() const
{
return m_flags.m_enabled;
return m_flags.m_enabled && (m_flags.m_parentEnabled || m_parent == nullptr);
}
// --- Error Logging ---
@@ -140,6 +141,7 @@ namespace AZ
}
// Set new tree depth and path
m_flags.m_parentEnabled = m_parent->m_flags.m_enabled && (m_parent->m_flags.m_parentEnabled || m_parent->m_parent == nullptr);
m_treeDepth = m_parent->m_treeDepth + 1;
m_path = ConcatPassName(m_parent->m_path, m_name);
m_flags.m_partOfHierarchy = m_parent->m_flags.m_partOfHierarchy;
@@ -36,7 +36,7 @@ namespace AZ
{
void PassFactory::Init(PassLibrary* passLibrary)
{
m_passLibary = passLibrary;
m_passLibrary = passLibrary;
AddCorePasses();
}
@@ -125,7 +125,7 @@ namespace AZ
Ptr<Pass> PassFactory::CreatePassFromTemplate(Name templateName, Name passName)
{
const AZStd::shared_ptr<PassTemplate>& passTemplate = m_passLibary->GetPassTemplate(templateName);
const AZStd::shared_ptr<PassTemplate>& passTemplate = m_passLibrary->GetPassTemplate(templateName);
if (passTemplate == nullptr)
{
AZ_Error("PassFactory", false, "FAILED TO CREATE PASS [%s]. Could not find pass template [%s]", passName.GetCStr(), templateName.GetCStr());
@@ -143,7 +143,7 @@ namespace AZ
return nullptr;
}
const AZStd::shared_ptr<PassTemplate>& passTemplate = m_passLibary->GetPassTemplate(passRequest->m_templateName);
const AZStd::shared_ptr<PassTemplate>& passTemplate = m_passLibrary->GetPassTemplate(passRequest->m_templateName);
if (passTemplate == nullptr)
{
AZ_Error("PassFactory", false, "FAILED TO CREATE PASS [%s]. Could not find pass template [%s]", passRequest->m_passName.GetCStr(), passRequest->m_templateName.GetCStr());
@@ -262,6 +262,7 @@ namespace AZ
}
// Handle template mapping reload
// Note: it's a known issue that when mapping asset got reloaded, we only handle the new entries
Data::Asset<AnyAsset> templateMappings = { asset.GetAs<AnyAsset>(), AZ::Data::AssetLoadBehavior::PreLoad };
if (templateMappings)
{
@@ -310,7 +311,7 @@ namespace AZ
return success;
}
void PassLibrary::LoadPassAsset(const Name& name, const Data::AssetId& passAssetId)
bool PassLibrary::LoadPassAsset(const Name& name, const Data::AssetId& passAssetId)
{
Data::Asset<PassAsset> passAsset;
if (passAssetId.IsValid())
@@ -325,11 +326,20 @@ namespace AZ
{
Data::AssetBus::MultiHandler::BusConnect(passAssetId);
}
return loadSuccess;
}
bool PassLibrary::LoadPassTemplateMappings(const AZStd::string& templateMappingPath)
{
Data::Asset<AnyAsset> mappingAsset = AssetUtils::LoadCriticalAsset<AnyAsset>(templateMappingPath.c_str(), AssetUtils::TraceLevel::Error);
if (m_templateMappingAssets.find(mappingAsset.GetId()) != m_templateMappingAssets.end())
{
AZ_Warning("PassLibrary", false, "Pass template mapping [%s] was already loaded", mappingAsset.GetHint().c_str());
return true;
}
bool success = LoadPassTemplateMappings(mappingAsset);
if (success)
{
@@ -350,13 +360,29 @@ namespace AZ
}
const AZStd::unordered_map<AZStd::string, Data::AssetId>& assetMapping = mappings->GetAssetMapping();
Data::AssetId mappingAssetId = mappingAsset.GetId();
m_templateEntries.reserve(m_templateEntries.size() + assetMapping.size());
for (const auto& assetInfo : assetMapping)
{
Name templateName = AZ::Name(assetInfo.first);
if (!HasTemplate(templateName))
{
LoadPassAsset(templateName, assetInfo.second);
bool loaded = LoadPassAsset(templateName, assetInfo.second);
if (loaded)
{
auto& entry = m_templateEntries[templateName];
entry.m_mappingAssetId = mappingAssetId;
}
}
else
{
// Report a warning if the template was setup in another mappping asset.
// We won't report a warning if the template was loaded from same asset. This only happens when the asset got reloaded.
if (m_templateEntries[templateName].m_mappingAssetId != mappingAssetId)
{
AZ_Warning("PassLibrary", false, "Template [%s] was aleady added to the library. Duplicated template from [%s]",
templateName.GetCStr(), mappingAsset.ToString<AZStd::string>().c_str());
}
}
}
@@ -100,6 +100,12 @@ namespace AZ
m_rootPass->m_flags.m_partOfHierarchy = true;
}
void PassSystem::InitPassTemplates()
{
AZ_Assert(m_rootPass, "PassSystem::Init() need to be called");
m_loadTemplatesEvent.Signal();
}
bool PassSystem::LoadPassTemplateMappings(const AZStd::string& templateMappingPath)
{
return m_passLibrary.LoadPassTemplateMappings(templateMappingPath);
@@ -213,7 +219,6 @@ namespace AZ
DebugPrintPassHierarchy();
}
#endif
PassSystemNotificiationBus::Broadcast(&PassSystemNotificiationBus::Events::OnPassAttachmentsBuilt);
}
m_isBuilding = false;
@@ -323,6 +328,11 @@ namespace AZ
return m_targetedPassDebugName;
}
void PassSystem::ConnectEvent(OnReadyLoadTemplatesEvent::Handler& handler)
{
handler.Connect(m_loadTemplatesEvent);
}
// --- Pass Factory Functions ---
void PassSystem::AddPassCreator(Name className, PassCreator createFunction)
@@ -369,12 +369,7 @@ namespace AZ
m_bufferSystem.Init();
m_dynamicDraw.Init(m_descriptor.m_dynamicDrawSystemDescriptor);
// Have pass system load default pass template mapping
bool passSystemReady = m_passSystem.LoadPassTemplateMappings(m_descriptor.m_passTemplatesMappingPath);
if (!passSystemReady)
{
return;
}
m_passSystem.InitPassTemplates();
m_systemAssetsInitialized = true;
}
@@ -99,7 +99,6 @@ namespace AZ
{
WaitAndCleanCompletionJob(m_simulationCompletion);
SceneRequestBus::Handler::BusDisconnect();
DisableAllFeatureProcessors();
// Remove all the render pipelines. Need to process queued changes with pass system before and after remove render pipelines
AZ::RPI::PassSystemInterface::Get()->ProcessQueuedChanges();
@@ -111,6 +110,8 @@ namespace AZ
m_pipelines.clear();
AZ::RPI::PassSystemInterface::Get()->ProcessQueuedChanges();
Deactivate();
delete m_cullingScene;
}
@@ -138,8 +139,11 @@ namespace AZ
void Scene::Deactivate()
{
AZ_Assert(m_activated, "Not activated");
if (!m_activated)
{
return;
}
for (auto& fp : m_featureProcessors)
{
fp->Deactivate();
@@ -240,7 +244,6 @@ namespace AZ
fp->Deactivate();
}
m_featureProcessors.clear();
m_pipelineStatesLookup.clear();
}
FeatureProcessor* Scene::GetFeatureProcessor(const FeatureProcessorId& featureProcessorId) const
+10 -1
View File
@@ -110,6 +110,15 @@ namespace AZ
InvalidateSrg();
}
AZ::Transform View::GetCameraTransform() const
{
static const Quaternion yUpToZUp = Quaternion::CreateRotationX(-AZ::Constants::HalfPi);
return AZ::Transform::CreateFromQuaternionAndTranslation(
Quaternion::CreateFromMatrix4x4(m_viewToWorldMatrix) * yUpToZUp,
m_viewToWorldMatrix.GetTranslation()
).GetOrthogonalized();
}
void View::SetCameraTransform(const AZ::Matrix3x4& cameraTransform)
{
m_position = cameraTransform.GetTranslation();
@@ -118,7 +127,7 @@ namespace AZ
// is in a Z-up world and an identity matrix means that it faces along the positive-Y axis and Z is up.
// An identity view matrix on the other hand looks along the negative Z-axis.
// So we adjust for this by rotating the camera world matrix by 90 degrees around the X axis.
AZ::Matrix3x4 zUpToYUp = AZ::Matrix3x4::CreateRotationX(AZ::Constants::HalfPi);
static AZ::Matrix3x4 zUpToYUp = AZ::Matrix3x4::CreateRotationX(AZ::Constants::HalfPi);
AZ::Matrix3x4 yUpWorld = cameraTransform * zUpToYUp;
float viewToWorldMatrixRaw[16] = {
@@ -194,12 +194,7 @@ namespace AZ
AZ::Transform ViewportContext::GetCameraTransform() const
{
const Matrix4x4& worldToViewMatrix = GetDefaultView()->GetViewToWorldMatrix();
const Quaternion zUpToYUp = Quaternion::CreateRotationX(-AZ::Constants::HalfPi);
return AZ::Transform::CreateFromQuaternionAndTranslation(
Quaternion::CreateFromMatrix4x4(worldToViewMatrix) * zUpToYUp,
worldToViewMatrix.GetTranslation()
).GetOrthogonalized();
return GetDefaultView()->GetCameraTransform();
}
void ViewportContext::SetCameraTransform(const AZ::Transform& transform)
@@ -12,6 +12,7 @@
#include <Atom/RPI.Reflect/Shader/ShaderVariantTreeAsset.h>
#include <AzCore/Casting/numeric_cast.h>
#include <AzCore/IO/Path/Path.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/std/algorithm.h>
@@ -40,15 +41,12 @@ namespace AZ
Data::AssetId ShaderVariantTreeAsset::GetShaderVariantTreeAssetIdFromShaderAssetId(const Data::AssetId& shaderAssetId)
{
//From the shaderAssetId We can deduce the path of the shader asset, and from the path of the shader asset we can deduce the path of the ShaderVariantTreeAsset.
AZStd::string shaderAssetPath;
AZ::Data::AssetCatalogRequestBus::BroadcastResult(shaderAssetPath
, &AZ::Data::AssetCatalogRequests::GetAssetPathById
, shaderAssetId);
AZStd::string shaderAssetPathRoot;
AZStd::string shaderAssetPathName;
AzFramework::StringFunc::Path::Split(shaderAssetPath.c_str(), nullptr /*drive*/, &shaderAssetPathRoot, &shaderAssetPathName, nullptr /*extension*/);
AZ::IO::FixedMaxPath shaderAssetPath;
AZ::Data::AssetCatalogRequestBus::BroadcastResult(shaderAssetPath.Native(), &AZ::Data::AssetCatalogRequests::GetAssetPathById
, shaderAssetId);
AZ::IO::FixedMaxPath shaderAssetPathRoot = shaderAssetPath.ParentPath();
AZ::IO::FixedMaxPath shaderAssetPathName = shaderAssetPath.Stem();
AZStd::string shaderVariantTreeAssetDir;
AzFramework::StringFunc::Path::Join(ShaderVariantTreeAsset::CommonSubFolderLowerCase, shaderAssetPathRoot.c_str(), shaderVariantTreeAssetDir);
AZStd::string shaderVariantTreeAssetFilename = AZStd::string::format("%s.%s", shaderAssetPathName.c_str(), ShaderVariantTreeAsset::Extension);
@@ -63,8 +61,7 @@ namespace AZ
{
// If the game project did not customize the shadervariantlist, let's see if the original author of the .shader file
// provided a shadervariantlist.
shaderVariantTreeAssetDir = shaderAssetPathRoot;
AzFramework::StringFunc::Path::Join(shaderVariantTreeAssetDir.c_str(), shaderVariantTreeAssetFilename.c_str(), shaderVariantTreeAssetPath);
AzFramework::StringFunc::Path::Join(shaderAssetPathRoot.c_str(), shaderVariantTreeAssetFilename.c_str(), shaderVariantTreeAssetPath);
AZ::Data::AssetCatalogRequestBus::BroadcastResult(shaderVariantTreeAssetId, &AZ::Data::AssetCatalogRequests::GetAssetIdByPath
, shaderVariantTreeAssetPath.c_str(), AZ::Data::s_invalidAssetType, false);
}