Merge branch 'main' into Atom/antonmic/lowEnd
This commit is contained in:
@@ -45,6 +45,8 @@ namespace AZ
|
||||
|
||||
private:
|
||||
RHI::Ptr<RHI::BufferPool> m_commonPools[static_cast<uint8_t>(CommonBufferPoolType::Count)];
|
||||
|
||||
bool m_initialized = false;
|
||||
};
|
||||
} // namespace RPI
|
||||
} // namespace AZ
|
||||
|
||||
@@ -80,6 +80,8 @@ namespace AZ
|
||||
Data::Asset<DefaultStreamingImageControllerAsset> m_defaultStreamingImageControllerAsset;
|
||||
|
||||
AZStd::fixed_vector<Data::Instance<Image>, static_cast<uint32_t>(SystemImage::Count)> m_systemImages;
|
||||
|
||||
bool m_initialized = false;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace AZ
|
||||
// --- Members ---
|
||||
|
||||
// Cached pointer to the pass library to simplify code
|
||||
PassLibrary* m_passLibary = nullptr;
|
||||
PassLibrary* m_passLibrary = nullptr;
|
||||
|
||||
// ClassNames are used to look up PassCreators. This list is 1-to-1 with the PassCreator list
|
||||
AZStd::vector<Name> m_passClassNames;
|
||||
|
||||
@@ -56,6 +56,9 @@ namespace AZ
|
||||
|
||||
// The list of passes created from this template
|
||||
AZStd::vector<Pass*> m_passes;
|
||||
|
||||
// The pass templates mapping asset id which this template is coming from.
|
||||
Data::AssetId m_mappingAssetId;
|
||||
};
|
||||
|
||||
typedef AZStd::unordered_map<Name, TemplateEntry> TemplateEntriesByName;
|
||||
@@ -82,7 +85,7 @@ namespace AZ
|
||||
void RemovePassFromLibrary(Pass* pass);
|
||||
|
||||
//! Load pass templates which are list in an AssetAliases
|
||||
void LoadPassTemplateMappings(const AZStd::string& templateMappingPath);
|
||||
bool LoadPassTemplateMappings(const AZStd::string& templateMappingPath);
|
||||
bool LoadPassTemplateMappings(Data::Asset<AnyAsset> mappingAsset);
|
||||
|
||||
//! Returns a list of passes found in the pass name mapping using the provided pass filter
|
||||
@@ -105,7 +108,7 @@ namespace AZ
|
||||
bool LoadPassAsset(const Name& name, const Data::Asset<PassAsset>& passAsset, bool hotReloading = false);
|
||||
|
||||
// Find asset with specified pass template asset id and load pass template from the asset.
|
||||
void LoadPassAsset(const Name& name, const Data::AssetId& passAssetId);
|
||||
bool LoadPassAsset(const Name& name, const Data::AssetId& passAssetId);
|
||||
|
||||
// Data::AssetBus::Handler overrides...
|
||||
void OnAssetReloaded(Data::Asset<Data::AssetData> asset) override;
|
||||
|
||||
@@ -55,6 +55,10 @@ namespace AZ
|
||||
//! Initializes the PassSystem and the Root Pass and creates the Pass InstanceDatabase
|
||||
void Init();
|
||||
|
||||
//! Initialize and load pass templates
|
||||
//! This function need to be called after Init()
|
||||
void InitPassTemplates();
|
||||
|
||||
//! Deletes the Root Pass and shuts down the PassSystem
|
||||
void Shutdown();
|
||||
|
||||
@@ -66,7 +70,7 @@ namespace AZ
|
||||
|
||||
// PassSystemInterface functions...
|
||||
void ProcessQueuedChanges() override;
|
||||
void LoadPassTemplateMappings(const AZStd::string& templateMappingPath) override;
|
||||
bool LoadPassTemplateMappings(const AZStd::string& templateMappingPath) override;
|
||||
void WriteTemplateToFile(const PassTemplate& passTemplate, AZStd::string_view assetFilePath) override;
|
||||
void DebugPrintPassHierarchy() override;
|
||||
bool IsBuilding() const override;
|
||||
@@ -74,6 +78,7 @@ namespace AZ
|
||||
void SetHotReloading(bool hotReloading) override;
|
||||
void SetTargetedPassDebuggingName(const AZ::Name& targetPassName) override;
|
||||
const AZ::Name& GetTargetedPassDebuggingName() const override;
|
||||
void ConnectEvent(OnReadyLoadTemplatesEvent::Handler& handler) override;
|
||||
|
||||
// PassSystemInterface factory related functions...
|
||||
void AddPassCreator(Name className, PassCreator createFunction) override;
|
||||
@@ -139,6 +144,9 @@ namespace AZ
|
||||
|
||||
// Counts the number of passes
|
||||
int32_t m_passCounter = 0;
|
||||
|
||||
// Events
|
||||
OnReadyLoadTemplatesEvent m_loadTemplatesEvent;
|
||||
};
|
||||
} // namespace RPI
|
||||
} // namespace AZ
|
||||
|
||||
@@ -64,8 +64,11 @@ namespace AZ
|
||||
//! initializing a scene;
|
||||
virtual void ProcessQueuedChanges() = 0;
|
||||
|
||||
//! Load pass templates listed in a name-assetid mapping asset
|
||||
virtual void LoadPassTemplateMappings(const AZStd::string& templateMappingPath) = 0;
|
||||
//! Load pass templates listed in a name-assetid mapping asset
|
||||
//! This function should be called before the render pipelines which use templates from this mappings are created.
|
||||
//! To load pass template mapping before any render pipelines are created, use OnReadyLoadTemplatesEvent::Handler to
|
||||
//! load desired pass template mappings
|
||||
virtual bool LoadPassTemplateMappings(const AZStd::string& templateMappingPath) = 0;
|
||||
|
||||
//! Writes a pass template to a .pass file which can then be used as a pass asset. Useful for
|
||||
//! quickly authoring a pass template in code and then outputting it as a pass asset using JSON
|
||||
@@ -148,6 +151,12 @@ namespace AZ
|
||||
//! Find the SwapChainPass associated with window Handle
|
||||
virtual SwapChainPass* FindSwapChainPass(AzFramework::NativeWindowHandle windowHandle) const = 0;
|
||||
|
||||
using OnReadyLoadTemplatesEvent = AZ::Event<>;
|
||||
//! Connect a handler to listen to the event that the pass system is ready to load pass templates
|
||||
//! The event is triggered when pass system is initialized and asset system is ready.
|
||||
//! The handler can add new pass templates or load pass template mappings from assets
|
||||
virtual void ConnectEvent(OnReadyLoadTemplatesEvent::Handler& handler) = 0;
|
||||
|
||||
private:
|
||||
// These functions are only meant to be used by the Pass class
|
||||
|
||||
@@ -164,17 +173,10 @@ namespace AZ
|
||||
virtual void UnregisterPass(Pass* pass) = 0;
|
||||
|
||||
};
|
||||
|
||||
//! Notifications of the pass system such attachments were rebuilt, pass tree changes
|
||||
class PassSystemNotificiations
|
||||
: public AZ::EBusTraits
|
||||
|
||||
namespace PassSystemEvents
|
||||
{
|
||||
public:
|
||||
}
|
||||
|
||||
//! Notify when any pass's attachment was rebuilt
|
||||
virtual void OnPassAttachmentsBuilt() = 0;
|
||||
};
|
||||
|
||||
using PassSystemNotificiationBus = AZ::EBus<PassSystemNotificiations>;
|
||||
} // namespace RPI
|
||||
} // namespace AZ
|
||||
|
||||
@@ -70,6 +70,7 @@ namespace AZ
|
||||
void Shutdown();
|
||||
|
||||
// RPISystemInterface overrides...
|
||||
bool IsInitialized() const override;
|
||||
void InitializeSystemAssets() override;
|
||||
void RegisterScene(ScenePtr scene) override;
|
||||
void UnregisterScene(ScenePtr scene) override;
|
||||
|
||||
@@ -40,6 +40,9 @@ namespace AZ
|
||||
//! Note: can't rely on the AzFramework::AssetCatalogEventBus's OnCatalogLoaded since the order of calling handlers is undefined.
|
||||
virtual void InitializeSystemAssets() = 0;
|
||||
|
||||
//! Was the RPI system initialized properly
|
||||
virtual bool IsInitialized() const = 0;
|
||||
|
||||
//! Register a created scene to RPISystem. Registered scene will be simulated and rendered in RPISystem ticks
|
||||
virtual void RegisterScene(ScenePtr scene) = 0;
|
||||
|
||||
|
||||
@@ -75,6 +75,9 @@ namespace AZ
|
||||
RHI::ShaderInputSamplerIndex FindShaderInputSamplerIndex(const Name& name) const;
|
||||
RHI::ShaderInputConstantIndex FindShaderInputConstantIndex(const Name& name) const;
|
||||
|
||||
RHI::ShaderInputBufferUnboundedArrayIndex FindShaderInputBufferUnboundedArrayIndex(const Name& name) const;
|
||||
RHI::ShaderInputImageUnboundedArrayIndex FindShaderInputImageUnboundedArrayIndex(const Name& name) const;
|
||||
|
||||
/// Returns the parent shader resource group asset.
|
||||
const Data::Asset<ShaderResourceGroupAsset>& GetAsset() const;
|
||||
|
||||
|
||||
@@ -91,6 +91,8 @@ namespace AZ
|
||||
const AZ::Matrix4x4& GetViewToWorldMatrix() const;
|
||||
const AZ::Matrix4x4& GetViewToClipMatrix() const;
|
||||
const AZ::Matrix4x4& GetWorldToClipMatrix() const;
|
||||
//! Get the camera's world transform, converted from the viewToWorld matrix's native y-up to z-up
|
||||
AZ::Transform GetCameraTransform() const;
|
||||
|
||||
//! Finalize draw lists in this view. This function should only be called when all
|
||||
//! draw packets for current frame are added.
|
||||
|
||||
@@ -92,6 +92,8 @@ namespace AZ
|
||||
virtual ViewPtr GetCurrentView(const Name& contextName) const = 0;
|
||||
};
|
||||
|
||||
using ViewportContextRequests = AZ::Interface<ViewportContextRequestsInterface>;
|
||||
|
||||
class ViewportContextManagerNotifications
|
||||
: public AZ::EBusTraits
|
||||
{
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#include <AzCore/Asset/AssetCommon.h>
|
||||
#include <AzCore/Asset/AssetManager.h>
|
||||
|
||||
#include <AzFramework/Asset/AssetSystemBus.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace RPI
|
||||
@@ -48,6 +50,12 @@ namespace AZ
|
||||
//! @return a null asset if the asset could not be found or loaded.
|
||||
template<typename AssetDataT>
|
||||
Data::Asset<AssetDataT> LoadAssetById(Data::AssetId assetId, TraceLevel reporting = TraceLevel::Warning);
|
||||
|
||||
//! Loads a critial asset using a file path (both source and product path should be same), on the current thread.
|
||||
//! If the asset wasn't compiled, wait until the asset is compiled.
|
||||
//! @return a null asset if the asset could not be compiled or loaded.
|
||||
template<typename AssetDataT>
|
||||
Data::Asset<AssetDataT> LoadCriticalAsset(const AZStd::string& assetFilePath, TraceLevel reporting = TraceLevel::Error);
|
||||
|
||||
template<typename AssetDataT>
|
||||
bool LoadBlocking(AZ::Data::Asset<AssetDataT>& asset, TraceLevel reporting = TraceLevel::Warning);
|
||||
@@ -89,7 +97,7 @@ namespace AZ
|
||||
assetId, AZ::Data::AssetLoadBehavior::PreLoad);
|
||||
asset.BlockUntilLoadComplete();
|
||||
|
||||
if (!asset.Get())
|
||||
if (!asset.IsReady())
|
||||
{
|
||||
AssetUtilsInternal::ReportIssue(reporting, AZStd::string::format("Could not load '%s'", productPath).c_str());
|
||||
return {};
|
||||
@@ -117,7 +125,7 @@ namespace AZ
|
||||
);
|
||||
asset.BlockUntilLoadComplete();
|
||||
|
||||
if (!asset.Get())
|
||||
if (!asset.IsReady())
|
||||
{
|
||||
AssetUtilsInternal::ReportIssue(reporting, AZStd::string::format("Could not load '%s'", assetId.ToString<AZStd::string>().c_str()).c_str());
|
||||
return {};
|
||||
@@ -126,6 +134,27 @@ namespace AZ
|
||||
return asset;
|
||||
}
|
||||
|
||||
template<typename AssetDataT>
|
||||
Data::Asset<AssetDataT> LoadCriticalAsset(const AZStd::string& assetFilePath, TraceLevel reporting)
|
||||
{
|
||||
bool apConnected = false;
|
||||
AzFramework::AssetSystemRequestBus::BroadcastResult(
|
||||
apConnected, &AzFramework::AssetSystemRequestBus::Events::ConnectedWithAssetProcessor);
|
||||
if (apConnected)
|
||||
{
|
||||
AzFramework::AssetSystem::AssetStatus status = AzFramework::AssetSystem::AssetStatus_Unknown;
|
||||
AzFramework::AssetSystemRequestBus::BroadcastResult(
|
||||
status, &AzFramework::AssetSystemRequestBus::Events::CompileAssetSync, assetFilePath);
|
||||
if (status != AzFramework::AssetSystem::AssetStatus_Compiled)
|
||||
{
|
||||
AssetUtilsInternal::ReportIssue(reporting, AZStd::string::format("Could not compile asset '%s'", assetFilePath.c_str()).c_str());
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
return LoadAssetByProductPath<AssetDataT>(assetFilePath.c_str(), reporting);
|
||||
}
|
||||
|
||||
template<typename AssetDataT>
|
||||
bool LoadBlocking(AZ::Data::Asset<AssetDataT>& asset, TraceLevel reporting)
|
||||
{
|
||||
|
||||
@@ -44,9 +44,6 @@ namespace AZ
|
||||
//! The path of the only one view srg asset for the RPI system. This is used to create any RPI::View.
|
||||
AZStd::string m_viewSrgAssetPath = "shaderlib/viewsrg_viewsrg.azsrg";
|
||||
|
||||
//! Path of pass templates' name-assetid mapping file.
|
||||
AZStd::string m_passTemplatesMappingPath = "Passes/PassTemplates.azasset";
|
||||
|
||||
ImageSystemDescriptor m_imageSystemDescriptor;
|
||||
GpuQuerySystemDescriptor m_gpuQuerySystemDescriptor;
|
||||
DynamicDrawSystemDescriptor m_dynamicDrawSystemDescriptor;
|
||||
|
||||
@@ -61,10 +61,16 @@ namespace AZ
|
||||
Data::InstanceDatabase<BufferPool>::Create(azrtti_typeid<ResourcePoolAsset>(), handler);
|
||||
}
|
||||
Interface<BufferSystemInterface>::Register(this);
|
||||
|
||||
m_initialized = true;
|
||||
}
|
||||
|
||||
void BufferSystem::Shutdown()
|
||||
{
|
||||
if (!m_initialized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (uint8_t index = 0; index < static_cast<uint8_t>(CommonBufferPoolType::Count); index++)
|
||||
{
|
||||
m_commonPools[index] = nullptr;
|
||||
@@ -72,6 +78,7 @@ namespace AZ
|
||||
Interface<BufferSystemInterface>::Unregister(this);
|
||||
Data::InstanceDatabase<Buffer>::Destroy();
|
||||
Data::InstanceDatabase<BufferPool>::Destroy();
|
||||
m_initialized = false;
|
||||
}
|
||||
|
||||
RHI::Ptr<RHI::BufferPool> BufferSystem::GetCommonBufferPool(CommonBufferPoolType poolType)
|
||||
@@ -87,6 +94,10 @@ namespace AZ
|
||||
|
||||
bool BufferSystem::CreateCommonBufferPool(CommonBufferPoolType poolType)
|
||||
{
|
||||
if (!m_initialized)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
auto* device = RHI::RHISystemInterface::Get()->GetDevice();
|
||||
|
||||
RHI::Ptr<RHI::BufferPool> bufferPool = RHI::Factory::Get().CreateBufferPool();
|
||||
|
||||
@@ -148,10 +148,16 @@ namespace AZ
|
||||
CreateDefaultResources(desc);
|
||||
|
||||
Interface<ImageSystemInterface>::Register(this);
|
||||
|
||||
m_initialized = true;
|
||||
}
|
||||
|
||||
void ImageSystem::Shutdown()
|
||||
{
|
||||
if (!m_initialized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Interface<ImageSystemInterface>::Unregister(this);
|
||||
|
||||
m_defaultStreamingImageControllerAsset.Release();
|
||||
@@ -167,6 +173,7 @@ namespace AZ
|
||||
Data::InstanceDatabase<StreamingImageController>::Destroy();
|
||||
|
||||
m_activeStreamingPools.clear();
|
||||
m_initialized = false;
|
||||
}
|
||||
|
||||
void ImageSystem::Update()
|
||||
|
||||
@@ -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,16 +326,26 @@ namespace AZ
|
||||
{
|
||||
Data::AssetBus::MultiHandler::BusConnect(passAssetId);
|
||||
}
|
||||
|
||||
return loadSuccess;
|
||||
}
|
||||
|
||||
void PassLibrary::LoadPassTemplateMappings(const AZStd::string& templateMappingPath)
|
||||
bool PassLibrary::LoadPassTemplateMappings(const AZStd::string& templateMappingPath)
|
||||
{
|
||||
Data::Asset<AnyAsset> mappingAsset = AssetUtils::LoadAssetByProductPath<AnyAsset>(templateMappingPath.c_str(), AssetUtils::TraceLevel::Error);
|
||||
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)
|
||||
{
|
||||
Data::AssetBus::MultiHandler::BusConnect(mappingAsset->GetId());
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
bool PassLibrary::LoadPassTemplateMappings(Data::Asset<AnyAsset> mappingAsset)
|
||||
@@ -349,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,9 +100,15 @@ namespace AZ
|
||||
m_rootPass->m_flags.m_partOfHierarchy = true;
|
||||
}
|
||||
|
||||
void PassSystem::LoadPassTemplateMappings(const AZStd::string& templateMappingPath)
|
||||
void PassSystem::InitPassTemplates()
|
||||
{
|
||||
m_passLibrary.LoadPassTemplateMappings(templateMappingPath);
|
||||
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);
|
||||
}
|
||||
|
||||
void PassSystem::WriteTemplateToFile(const PassTemplate& passTemplate, AZStd::string_view assetFilePath)
|
||||
@@ -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)
|
||||
|
||||
@@ -334,7 +334,6 @@ namespace AZ
|
||||
|
||||
void RPISystem::InitializeSystemAssets()
|
||||
{
|
||||
AzFramework::AssetSystem::AssetStatus status = AzFramework::AssetSystem::AssetStatus_Unknown;
|
||||
if (m_systemAssetsInitialized)
|
||||
{
|
||||
AZ_Warning("RPISystem", false , "InitializeSystemAssets should only be called once'");
|
||||
@@ -344,36 +343,42 @@ namespace AZ
|
||||
//[GFX TODO][ATOM-5867] - Move file loading code within RHI to reduce coupling with RPI
|
||||
AZStd::string platformLimitsFilePath = AZStd::string::format("config/platform/%s/%s/platformlimits.azasset", AZ_TRAIT_OS_PLATFORM_NAME, GetRenderApiName().GetCStr());
|
||||
AZStd::to_lower(platformLimitsFilePath.begin(), platformLimitsFilePath.end());
|
||||
// Wait for the platformlimits asset to be compiled (if it exists)
|
||||
AzFramework::AssetSystemRequestBus::BroadcastResult(
|
||||
status, &AzFramework::AssetSystemRequestBus::Events::CompileAssetSync, platformLimitsFilePath);
|
||||
Data::Asset<RPI::AnyAsset> platformLimitsAsset = RPI::AssetUtils::LoadAssetByProductPath<RPI::AnyAsset>(platformLimitsFilePath.c_str(), RPI::AssetUtils::TraceLevel::Error);
|
||||
m_descriptor.m_rhiSystemDescriptor.m_platformLimits = RPI::GetDataFromAnyAsset<RHI::PlatformLimits>(platformLimitsAsset);
|
||||
|
||||
Data::Asset<AnyAsset> platformLimitsAsset;
|
||||
platformLimitsAsset = RPI::AssetUtils::LoadCriticalAsset<AnyAsset>(platformLimitsFilePath.c_str(), RPI::AssetUtils::TraceLevel::None);
|
||||
// Only read the m_platformLimits if the platformLimitsAsset is ready.
|
||||
// The platformLimitsAsset may not exist for null renderer which is allowed
|
||||
if (platformLimitsAsset.IsReady())
|
||||
{
|
||||
m_descriptor.m_rhiSystemDescriptor.m_platformLimits = RPI::GetDataFromAnyAsset<RHI::PlatformLimits>(platformLimitsAsset);
|
||||
}
|
||||
|
||||
m_viewSrgAsset = AssetUtils::LoadCriticalAsset<ShaderResourceGroupAsset>( m_descriptor.m_viewSrgAssetPath.c_str());
|
||||
if (!m_viewSrgAsset.IsReady())
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_sceneSrgAsset = AssetUtils::LoadCriticalAsset<ShaderResourceGroupAsset>(m_descriptor.m_sceneSrgAssetPath.c_str());
|
||||
if (!m_sceneSrgAsset.IsReady())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_rhiSystem.Init(m_descriptor.m_rhiSystemDescriptor);
|
||||
m_imageSystem.Init(m_descriptor.m_imageSystemDescriptor);
|
||||
m_bufferSystem.Init();
|
||||
m_dynamicDraw.Init(m_descriptor.m_dynamicDrawSystemDescriptor);
|
||||
|
||||
// Wait for the assets be compiled
|
||||
AzFramework::AssetSystemRequestBus::BroadcastResult(
|
||||
status, &AzFramework::AssetSystemRequestBus::Events::CompileAssetSync, m_descriptor.m_viewSrgAssetPath);
|
||||
AZ_Error("RPISystem", status == AzFramework::AssetSystem::AssetStatus_Compiled, "Could not compile view SRG at '%s'", m_descriptor.m_viewSrgAssetPath.c_str());
|
||||
AzFramework::AssetSystemRequestBus::BroadcastResult(
|
||||
status, &AzFramework::AssetSystemRequestBus::Events::CompileAssetSync, m_descriptor.m_sceneSrgAssetPath);
|
||||
AZ_Error("RPISystem", status == AzFramework::AssetSystem::AssetStatus_Compiled, "Could not compile scene SRG at '%s'", m_descriptor.m_sceneSrgAssetPath.c_str());
|
||||
AzFramework::AssetSystemRequestBus::BroadcastResult(
|
||||
status, &AzFramework::AssetSystemRequestBus::Events::CompileAssetSync, m_descriptor.m_passTemplatesMappingPath);
|
||||
AZ_Error("RPISystem", status == AzFramework::AssetSystem::AssetStatus_Compiled, "Could not compile pass template mapping at '%s'", m_descriptor.m_passTemplatesMappingPath.c_str());
|
||||
m_passSystem.InitPassTemplates();
|
||||
|
||||
m_viewSrgAsset = AssetUtils::LoadAssetByProductPath<ShaderResourceGroupAsset>(m_descriptor.m_viewSrgAssetPath.c_str(), AssetUtils::TraceLevel::Error);
|
||||
m_sceneSrgAsset = AssetUtils::LoadAssetByProductPath<ShaderResourceGroupAsset>(m_descriptor.m_sceneSrgAssetPath.c_str(), AssetUtils::TraceLevel::Error);
|
||||
|
||||
// Have pass system load default pass template mapping
|
||||
m_passSystem.LoadPassTemplateMappings(m_descriptor.m_passTemplatesMappingPath);
|
||||
m_systemAssetsInitialized = true;
|
||||
}
|
||||
|
||||
bool RPISystem::IsInitialized() const
|
||||
{
|
||||
return m_systemAssetsInitialized;
|
||||
}
|
||||
|
||||
void RPISystem::InitializeSystemAssetsForTests()
|
||||
{
|
||||
if (m_systemAssetsInitialized)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -118,6 +118,16 @@ namespace AZ
|
||||
return m_layout->FindShaderInputConstantIndex(name);
|
||||
}
|
||||
|
||||
RHI::ShaderInputBufferUnboundedArrayIndex ShaderResourceGroup::FindShaderInputBufferUnboundedArrayIndex(const Name& name) const
|
||||
{
|
||||
return m_layout->FindShaderInputBufferUnboundedArrayIndex(name);
|
||||
}
|
||||
|
||||
RHI::ShaderInputImageUnboundedArrayIndex ShaderResourceGroup::FindShaderInputImageUnboundedArrayIndex(const Name& name) const
|
||||
{
|
||||
return m_layout->FindShaderInputImageUnboundedArrayIndex(name);
|
||||
}
|
||||
|
||||
const Data::Asset<ShaderResourceGroupAsset>& ShaderResourceGroup::GetAsset() const
|
||||
{
|
||||
return m_asset;
|
||||
|
||||
@@ -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] = {
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace AZ
|
||||
, m_windowContext(AZStd::make_shared<WindowContext>())
|
||||
, m_manager(manager)
|
||||
, m_name(name)
|
||||
, m_viewportSize(1, 1)
|
||||
{
|
||||
m_windowContext->Initialize(device, nativeWindow);
|
||||
AzFramework::WindowRequestBus::EventResult(
|
||||
@@ -39,9 +40,10 @@ namespace AZ
|
||||
{
|
||||
m_projectionMatrixChangedEvent.Signal(matrix);
|
||||
});
|
||||
|
||||
m_onViewMatrixChangedHandler = ViewportContext::MatrixChangedEvent::Handler([this](const AZ::Matrix4x4& matrix)
|
||||
{
|
||||
m_projectionMatrixChangedEvent.Signal(matrix);
|
||||
m_viewMatrixChangedEvent.Signal(matrix);
|
||||
});
|
||||
|
||||
SetRenderScene(renderScene);
|
||||
@@ -192,18 +194,14 @@ 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)
|
||||
{
|
||||
const auto view = GetDefaultView();
|
||||
view->SetCameraTransform(AZ::Matrix3x4::CreateFromTransform(transform.GetOrthogonalized()));
|
||||
m_viewMatrixChangedEvent.Signal(view->GetWorldToViewMatrix());
|
||||
}
|
||||
|
||||
void ViewportContext::SetDefaultView(ViewPtr view)
|
||||
|
||||
@@ -41,7 +41,11 @@ namespace AZ
|
||||
|
||||
const RHI::ShaderResourceGroupLayout* ShaderResourceGroupAsset::GetLayout() const
|
||||
{
|
||||
AZ_Assert(m_currentAPITypeIndex < m_perAPILayout.size(), "Invalid API Type index");
|
||||
AZ_Error("RHI::ShaderResourceGroupLayout", m_currentAPITypeIndex < m_perAPILayout.size(), "Invalid API Type index");
|
||||
if (m_currentAPITypeIndex >= m_perAPILayout.size())
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
return m_perAPILayout[m_currentAPITypeIndex].second.get();
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -75,6 +75,7 @@ namespace UnitTest
|
||||
|
||||
// Adding this handler to allow utility functions access the serialize context
|
||||
ComponentApplicationBus::Handler::BusConnect();
|
||||
AZ::Interface<AZ::ComponentApplicationRequests>::Register(this);
|
||||
|
||||
// Startup default local FileIO (hits OSAllocator) if not already setup.
|
||||
if (IO::FileIOBase::GetInstance() == nullptr)
|
||||
@@ -113,6 +114,7 @@ namespace UnitTest
|
||||
delete IO::FileIOBase::GetInstance();
|
||||
IO::FileIOBase::SetInstance(nullptr);
|
||||
|
||||
AZ::Interface<AZ::ComponentApplicationRequests>::Unregister(this);
|
||||
ComponentApplicationBus::Handler::BusDisconnect();
|
||||
|
||||
m_jsonRegistrationContext->EnableRemoveReflection();
|
||||
|
||||
@@ -41,6 +41,10 @@ namespace UnitTest
|
||||
void UnregisterComponentDescriptor(const AZ::ComponentDescriptor*) override { }
|
||||
void RegisterEntityAddedEventHandler(AZ::EntityAddedEvent::Handler&) override { }
|
||||
void RegisterEntityRemovedEventHandler(AZ::EntityRemovedEvent::Handler&) override { }
|
||||
void RegisterEntityActivatedEventHandler(AZ::EntityActivatedEvent::Handler&) override { }
|
||||
void RegisterEntityDeactivatedEventHandler(AZ::EntityDeactivatedEvent::Handler&) override { }
|
||||
void SignalEntityActivated(AZ::Entity*) override { }
|
||||
void SignalEntityDeactivated(AZ::Entity*) override { }
|
||||
bool AddEntity(AZ::Entity*) override { return false; }
|
||||
bool RemoveEntity(AZ::Entity*) override { return false; }
|
||||
bool DeleteEntity(const AZ::EntityId&) override { return false; }
|
||||
|
||||
@@ -38,6 +38,10 @@ namespace UnitTest
|
||||
void UnregisterComponentDescriptor(const AZ::ComponentDescriptor*) override { }
|
||||
void RegisterEntityAddedEventHandler(AZ::EntityAddedEvent::Handler&) override { }
|
||||
void RegisterEntityRemovedEventHandler(AZ::EntityRemovedEvent::Handler&) override { }
|
||||
void RegisterEntityActivatedEventHandler(AZ::EntityActivatedEvent::Handler&) override { }
|
||||
void RegisterEntityDeactivatedEventHandler(AZ::EntityDeactivatedEvent::Handler&) override { }
|
||||
void SignalEntityActivated(AZ::Entity*) override { }
|
||||
void SignalEntityDeactivated(AZ::Entity*) override { }
|
||||
bool AddEntity(AZ::Entity*) override { return false; }
|
||||
bool RemoveEntity(AZ::Entity*) override { return false; }
|
||||
bool DeleteEntity(const AZ::EntityId&) override { return false; }
|
||||
|
||||
Reference in New Issue
Block a user