Merge branch 'development' into ExposeLodControls
This commit is contained in:
@@ -10,7 +10,9 @@
|
||||
|
||||
#include <AzCore/JSON/document.h>
|
||||
#include <AzCore/Serialization/Json/JsonSerialization.h>
|
||||
|
||||
#include <AtomCore/Serialization/Json/JsonUtils.h>
|
||||
|
||||
#include <Atom/RPI.Edit/Common/JsonFileLoadContext.h>
|
||||
#include <Atom/RPI.Edit/Common/JsonReportingHelper.h>
|
||||
|
||||
@@ -118,7 +120,6 @@ namespace AZ
|
||||
AZ_Error("AZ::RPI::JsonUtils", false, "Failed to load object from json string: %s", loadResult.GetError().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace JsonUtils
|
||||
} // namespace RPI
|
||||
} // namespace AZ
|
||||
|
||||
+1
@@ -9,6 +9,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/base.h>
|
||||
#include <AzCore/RTTI/RTTI.h>
|
||||
#include <AzCore/Name/Name.h>
|
||||
#include <AzCore/Math/Uuid.h>
|
||||
#include <AzCore/std/containers/unordered_map.h>
|
||||
|
||||
@@ -25,8 +25,8 @@ namespace AZ
|
||||
//! DynamicBuffers are allocated by DynamicBufferAllocator. Check the description of DynamicBufferAllocator class for detail.
|
||||
//! The typical usage:
|
||||
//! // For every frame
|
||||
//! auto buffer = DynamicDrawInterface::Get()->GetDynamicBuffer(size);
|
||||
//! if (buffer) // the buffer could be empty if the allocation failed.e
|
||||
//! auto buffer = DynamicDrawInterface::Get()->GetDynamicBuffer(size, RHI::Alignment::InputAssembly);
|
||||
//! if (buffer) // the buffer could be empty if the allocation failed.
|
||||
//! {
|
||||
//! // write data to the buffer
|
||||
//! buffer->Write(data, size);
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace AZ
|
||||
|
||||
//! Get a DynamicBuffer from DynamicDrawSystem.
|
||||
//! The returned buffer will be invalidated every time the RPISystem's RenderTick is called
|
||||
virtual RHI::Ptr<DynamicBuffer> GetDynamicBuffer(uint32_t size, uint32_t alignment = 1) = 0;
|
||||
virtual RHI::Ptr<DynamicBuffer> GetDynamicBuffer(uint32_t size, uint32_t alignment) = 0;
|
||||
|
||||
//! Draw a geometry to a scene with a given material
|
||||
virtual void DrawGeometry(Data::Instance<Material> material, const GeometryData& geometry, ScenePtr scene) = 0;
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace AZ
|
||||
|
||||
// DynamicDrawInterface overrides...
|
||||
RHI::Ptr<DynamicDrawContext> CreateDynamicDrawContext() override;
|
||||
RHI::Ptr<DynamicBuffer> GetDynamicBuffer(uint32_t size, uint32_t alignment = 1) override;
|
||||
RHI::Ptr<DynamicBuffer> GetDynamicBuffer(uint32_t size, uint32_t alignment) override;
|
||||
void DrawGeometry(Data::Instance<Material> material, const GeometryData& geometry, ScenePtr scene) override;
|
||||
void AddDrawPacket(Scene* scene, AZStd::unique_ptr<const RHI::DrawPacket> drawPacket) override;
|
||||
AZStd::vector<RHI::DrawListView> GetDrawListsForPass(const RasterPass* pass) override;
|
||||
|
||||
@@ -64,6 +64,9 @@ namespace AZ
|
||||
|
||||
//! Find a child pass with a matching name and returns it. Return nullptr if none found.
|
||||
Ptr<Pass> FindChildPass(const Name& passName) const;
|
||||
|
||||
template<typename PassType>
|
||||
Ptr<PassType> FindChildPass() const;
|
||||
|
||||
//! Searches the tree for the first pass that has same pass name (Depth-first search). Return nullptr if none found.
|
||||
Ptr<Pass> FindPassByNameRecursive(const Name& passName) const;
|
||||
@@ -132,5 +135,20 @@ namespace AZ
|
||||
// Generates child passes from source PassTemplate
|
||||
void CreatePassesFromTemplate();
|
||||
};
|
||||
|
||||
template<typename PassType>
|
||||
inline Ptr<PassType> ParentPass::FindChildPass() const
|
||||
{
|
||||
for (const Ptr<Pass>& child : m_children)
|
||||
{
|
||||
PassType* pass = azrtti_cast<PassType*>(child.get());
|
||||
if (pass)
|
||||
{
|
||||
return pass;
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
} // namespace RPI
|
||||
} // namespace AZ
|
||||
|
||||
@@ -75,6 +75,12 @@ namespace AZ
|
||||
const AZ::Name& GetTargetedPassDebuggingName() const override;
|
||||
void ConnectEvent(OnReadyLoadTemplatesEvent::Handler& handler) override;
|
||||
PassSystemState GetState() const override;
|
||||
SwapChainPass* FindSwapChainPass(AzFramework::NativeWindowHandle windowHandle) const override;
|
||||
|
||||
// PassSystemInterface statistics related functions
|
||||
void IncrementFrameDrawItemCount(u32 numDrawItems) override;
|
||||
void IncrementFrameRenderPassCount() override;
|
||||
PassSystemFrameStatistics GetFrameStatistics() override;
|
||||
|
||||
// PassSystemInterface factory related functions...
|
||||
void AddPassCreator(Name className, PassCreator createFunction) override;
|
||||
@@ -93,7 +99,6 @@ namespace AZ
|
||||
void RegisterPass(Pass* pass) override;
|
||||
void UnregisterPass(Pass* pass) override;
|
||||
AZStd::vector<Pass*> FindPasses(const PassFilter& passFilter) const override;
|
||||
SwapChainPass* FindSwapChainPass(AzFramework::NativeWindowHandle windowHandle) const override;
|
||||
|
||||
private:
|
||||
// Returns the root of the pass tree hierarchy
|
||||
@@ -116,6 +121,9 @@ namespace AZ
|
||||
void QueueForRemoval(Pass* pass) override;
|
||||
void QueueForInitialization(Pass* pass) override;
|
||||
|
||||
// Resets the frame statistic counters
|
||||
void ResetFrameStatistics();
|
||||
|
||||
// Lists for queuing passes for various function calls
|
||||
// Name of the list reflects the pass function it will call
|
||||
AZStd::vector< Ptr<Pass> > m_buildPassList;
|
||||
@@ -141,13 +149,16 @@ namespace AZ
|
||||
AZ::Name m_targetedPassDebugName;
|
||||
|
||||
// Counts the number of passes
|
||||
int32_t m_passCounter = 0;
|
||||
u32 m_passCounter = 0;
|
||||
|
||||
// Events
|
||||
OnReadyLoadTemplatesEvent m_loadTemplatesEvent;
|
||||
|
||||
// Used to track what phase of execution the pass system is in
|
||||
PassSystemState m_state = PassSystemState::Unitialized;
|
||||
|
||||
// Counters used to gather statistics about the frame
|
||||
PassSystemFrameStatistics m_frameStatistics;
|
||||
};
|
||||
} // namespace RPI
|
||||
} // namespace AZ
|
||||
|
||||
@@ -67,6 +67,14 @@ namespace AZ
|
||||
FrameEnd,
|
||||
};
|
||||
|
||||
//! Frame counters used for collecting statistics
|
||||
struct PassSystemFrameStatistics
|
||||
{
|
||||
u32 m_numRenderPassesExecuted = 0;
|
||||
u32 m_totalDrawItemsRendered = 0;
|
||||
u32 m_maxDrawItemsRenderedInAPass = 0;
|
||||
};
|
||||
|
||||
class PassSystemInterface
|
||||
{
|
||||
friend class Pass;
|
||||
@@ -116,6 +124,27 @@ namespace AZ
|
||||
virtual void SetTargetedPassDebuggingName(const AZ::Name& targetPassName) = 0;
|
||||
virtual const AZ::Name& GetTargetedPassDebuggingName() const = 0;
|
||||
|
||||
//! 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;
|
||||
|
||||
virtual PassSystemState GetState() const = 0;
|
||||
|
||||
// Passes call this function to notify the pass system that they are drawing X draw items this frame
|
||||
// Used for Pass System statistics
|
||||
virtual void IncrementFrameDrawItemCount(u32 numDrawItems) = 0;
|
||||
|
||||
// Increments the counter for the number of render passes executed this frame (does not include passes that are disabled)
|
||||
virtual void IncrementFrameRenderPassCount() = 0;
|
||||
|
||||
// Get frame statistics from the Pass System
|
||||
virtual PassSystemFrameStatistics GetFrameStatistics() = 0;
|
||||
|
||||
// --- Pass Factory related functionality ---
|
||||
|
||||
//! Directly creates a pass given a PassDescriptor
|
||||
@@ -172,17 +201,6 @@ namespace AZ
|
||||
//! Find matching passes from registered passes with specified filter
|
||||
virtual AZStd::vector<Pass*> FindPasses(const PassFilter& passFilter) const = 0;
|
||||
|
||||
//! 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;
|
||||
|
||||
virtual PassSystemState GetState() const = 0;
|
||||
|
||||
private:
|
||||
// These functions are only meant to be used by the Pass class
|
||||
|
||||
@@ -200,7 +218,6 @@ namespace AZ
|
||||
|
||||
//! Unregisters the pass with the pass library. Called in the Pass destructor.
|
||||
virtual void UnregisterPass(Pass* pass) = 0;
|
||||
|
||||
};
|
||||
|
||||
namespace PassSystemEvents
|
||||
|
||||
@@ -38,11 +38,13 @@ namespace AZ
|
||||
|
||||
void SetDrawListTag(Name drawListName);
|
||||
|
||||
void SetPipelineStateDataIndex(u32 index);
|
||||
void SetPipelineStateDataIndex(uint32_t index);
|
||||
|
||||
//! Expose shader resource group.
|
||||
ShaderResourceGroup* GetShaderResourceGroup();
|
||||
|
||||
uint32_t GetDrawItemCount();
|
||||
|
||||
protected:
|
||||
explicit RasterPass(const PassDescriptor& descriptor);
|
||||
|
||||
@@ -76,6 +78,7 @@ namespace AZ
|
||||
RHI::Viewport m_viewportState;
|
||||
bool m_overrideScissorSate = false;
|
||||
bool m_overrideViewportState = false;
|
||||
uint32_t m_drawItemCount = 0;
|
||||
};
|
||||
} // namespace RPI
|
||||
} // namespace AZ
|
||||
|
||||
@@ -22,19 +22,21 @@ namespace AZ
|
||||
class Shader;
|
||||
|
||||
//! Get the asset ID for a given shader file path
|
||||
Data::AssetId GetShaderAssetId(const AZStd::string& shaderFilePath);
|
||||
Data::AssetId GetShaderAssetId(const AZStd::string& shaderFilePath, bool isCritical = false);
|
||||
|
||||
//! Finds a shader asset for the given shader asset ID. Optional shaderFilePath param for debugging.
|
||||
Data::Asset<ShaderAsset> FindShaderAsset(Data::AssetId shaderAssetId, const AZStd::string& shaderFilePath = "");
|
||||
|
||||
//! Finds a shader asset for the given shader file path
|
||||
Data::Asset<ShaderAsset> FindShaderAsset(const AZStd::string& shaderFilePath);
|
||||
Data::Asset<ShaderAsset> FindCriticalShaderAsset(const AZStd::string& shaderFilePath);
|
||||
|
||||
//! Loads a shader for the given shader asset ID. Optional shaderFilePath param for debugging.
|
||||
Data::Instance<Shader> LoadShader(Data::AssetId shaderAssetId, const AZStd::string& shaderFilePath = "");
|
||||
|
||||
//! Loads a shader for the given shader file path
|
||||
Data::Instance<Shader> LoadShader(const AZStd::string& shaderFilePath);
|
||||
Data::Instance<Shader> LoadCriticalShader(const AZStd::string& shaderFilePath);
|
||||
|
||||
//! Loads a streaming image asset for the given file path
|
||||
Data::Instance<RPI::StreamingImage> LoadStreamingTexture(AZStd::string_view path);
|
||||
|
||||
@@ -110,9 +110,6 @@ namespace AZ
|
||||
//! Value returned is 1.0f when an area equal to the viewport height squared is covered. Useful for accurate LOD decisions.
|
||||
float CalculateSphereAreaInClipSpace(const AZ::Vector3& sphereWorldPosition, float sphereRadius) const;
|
||||
|
||||
//! Invalidate the view srg to rebuild the srg.
|
||||
void InvalidateSrg();
|
||||
|
||||
const AZ::Name& GetName() const { return m_name; }
|
||||
const UsageFlags GetUsageFlags() { return m_usageFlags; }
|
||||
|
||||
@@ -192,9 +189,6 @@ namespace AZ
|
||||
// Clip space offset for camera jitter with taa
|
||||
Vector2 m_clipSpaceOffset = Vector2(0.0f, 0.0f);
|
||||
|
||||
// Flags whether view matrices are dirty which requires rebuild srg
|
||||
bool m_needBuildSrg = true;
|
||||
|
||||
MatrixChangedEvent m_onWorldToClipMatrixChange;
|
||||
MatrixChangedEvent m_onWorldToViewMatrixChange;
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace AZ
|
||||
AZ::TypeId GetStorageDataTypeId() const;
|
||||
|
||||
//! Returns the value of the enum from its name. If this property is not an enum or the name is undefined, InvalidEnumValue is returned.
|
||||
static constexpr uint32_t InvalidEnumValue = -1;
|
||||
static constexpr uint32_t InvalidEnumValue = std::numeric_limits<uint32_t>::max();
|
||||
uint32_t GetEnumValue(const AZ::Name& enumName) const;
|
||||
|
||||
//! Returns the unique name ID of this property
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace AZ
|
||||
|
||||
private:
|
||||
|
||||
static constexpr uint32_t UnspecifiedIndex = -1;
|
||||
static constexpr uint32_t UnspecifiedIndex = std::numeric_limits<uint32_t>::max();
|
||||
|
||||
//! Returns the node associated with the provided index.
|
||||
const ShaderVariantTreeNode& GetNode(uint32_t index) const;
|
||||
|
||||
Reference in New Issue
Block a user