Addressed PR feedback

Signed-off-by: antonmic <56370189+antonmic@users.noreply.github.com>
This commit is contained in:
antonmic
2021-11-10 11:56:45 -08:00
parent 1f72001cdb
commit 3fd03479de
5 changed files with 12 additions and 9 deletions
@@ -153,7 +153,7 @@ namespace AZ
Data::Instance<RPI::Model> GetModel(const MeshHandle& meshHandle) const override;
Data::Asset<RPI::ModelAsset> GetModelAsset(const MeshHandle& meshHandle) const override;
AZStd::vector<Data::Instance<RPI::ShaderResourceGroup>>& GetObjectSrgs(const MeshHandle& meshHandle) const override;
const AZStd::vector<Data::Instance<RPI::ShaderResourceGroup>>& GetObjectSrgs(const MeshHandle& meshHandle) const override;
void QueueObjectSrgForCompile(const MeshHandle& meshHandle) const override;
void SetMaterialAssignmentMap(const MeshHandle& meshHandle, const Data::Instance<RPI::Material>& material) override;
void SetMaterialAssignmentMap(const MeshHandle& meshHandle, const MaterialAssignmentMap& materials) override;
@@ -61,12 +61,15 @@ namespace AZ
virtual Data::Instance<RPI::Model> GetModel(const MeshHandle& meshHandle) const = 0;
//! Gets the underlying RPI::ModelAsset for a meshHandle.
virtual Data::Asset<RPI::ModelAsset> GetModelAsset(const MeshHandle& meshHandle) const = 0;
//! Gets the ObjectSrg for a meshHandle.
//! Updating the ObjectSrg should be followed by a call to QueueObjectSrgForCompile,
//! instead of compiling the srg directly. This way, if the srg has already been queued for compile,
//! it will not be queued twice in the same frame. The ObjectSrg should not be updated during
//! Gets the ObjectSrgs for a meshHandle.
//! Updating the ObjectSrgs should be followed by a call to QueueObjectSrgForCompile,
//! instead of compiling the srgs directly. This way, if the srgs have already been queued for compile,
//! they will not be queued twice in the same frame. The ObjectSrgs should not be updated during
//! Simulate, or it will create a race between updating the data and the call to Compile
virtual AZStd::vector<Data::Instance<RPI::ShaderResourceGroup>>& GetObjectSrgs(const MeshHandle& meshHandle) const = 0;
//! Cases where there may be multiple ObjectSrgs: if a model has multiple submeshes and those submeshes use different
//! materials with different object SRGs.
virtual const AZStd::vector<Data::Instance<RPI::ShaderResourceGroup>>& GetObjectSrgs(const MeshHandle& meshHandle) const = 0;
//! Queues the object srg for compile.
virtual void QueueObjectSrgForCompile(const MeshHandle& meshHandle) const = 0;
//! Sets the MaterialAssignmentMap for a meshHandle, using just a single material for the DefaultMaterialAssignmentId.
@@ -19,7 +19,7 @@ namespace UnitTest
MOCK_METHOD1(CloneMesh, MeshHandle(const MeshHandle&));
MOCK_CONST_METHOD1(GetModel, AZStd::intrusive_ptr<AZ::RPI::Model>(const MeshHandle&));
MOCK_CONST_METHOD1(GetModelAsset, AZ::Data::Asset<AZ::RPI::ModelAsset>(const MeshHandle&));
MOCK_CONST_METHOD1(GetObjectSrgs, AZStd::vector<AZStd::intrusive_ptr<AZ::RPI::ShaderResourceGroup>>&(const MeshHandle&));
MOCK_CONST_METHOD1(GetObjectSrgs, const AZStd::vector<AZStd::intrusive_ptr<AZ::RPI::ShaderResourceGroup>>&(const MeshHandle&));
MOCK_CONST_METHOD1(QueueObjectSrgForCompile, void(const MeshHandle&));
MOCK_CONST_METHOD1(GetMaterialAssignmentMap, const AZ::Render::MaterialAssignmentMap&(const MeshHandle&));
MOCK_METHOD2(ConnectModelChangeEventHandler, void(const MeshHandle&, ModelChangedEvent::Handler&));
@@ -215,7 +215,7 @@ namespace AZ
return {};
}
AZStd::vector<Data::Instance<RPI::ShaderResourceGroup>>& MeshFeatureProcessor::GetObjectSrgs(const MeshHandle& meshHandle) const
const AZStd::vector<Data::Instance<RPI::ShaderResourceGroup>>& MeshFeatureProcessor::GetObjectSrgs(const MeshHandle& meshHandle) const
{
static AZStd::vector<Data::Instance<RPI::ShaderResourceGroup>> staticEmptyList;
return meshHandle.IsValid() ? meshHandle->m_objectSrgList : staticEmptyList;
@@ -880,7 +880,7 @@ namespace AZ
{
if (m_meshHandle)
{
AZStd::vector<Data::Instance<RPI::ShaderResourceGroup>>& wrinkleMaskObjectSrgs = m_meshFeatureProcessor->GetObjectSrgs(*m_meshHandle);
const AZStd::vector<Data::Instance<RPI::ShaderResourceGroup>>& wrinkleMaskObjectSrgs = m_meshFeatureProcessor->GetObjectSrgs(*m_meshHandle);
for (auto& wrinkleMaskObjectSrg : wrinkleMaskObjectSrgs)
{