cc615a8f32
* [ATOM-15472] Shader Build Pipeline: Remove Deprecated Files And Functions That Predate The Shader Supervariants These are the essential impactful changes as a result of deprecating the ShaderResourceGroupAsset. * Addressed feedback by @moudgils. Better comments in header files. * More updates related with deprecation of ShaderResourceGroupAsset * Deleted the temporary version 2 classes. * Updated version of the shader asset builders. * Updated version of all the shader related classes impacted by the Supervariant concept and deprecation of ShaderResourceGroupAsset * Changes to *.pass and DGI, Reflections and RayTracing. * changes to material related assets * changes to core lights * Changes to auxgeom/dynamic draw. * changes to decals, lyshine, imguipass * changes to RPI Pass classes * Shader for SceneSrg, ViewSrg and ForwardPass Srgs. * changes to mesh, skinned mesh, Morphtarget. * Fixes to RayTracingPass.cpp & now allow empty srg in shaders. * Updated Atom_RPI.Tests * Simplified InstanceDatabase by removing AddHandler ------------------------------------------------------------------------------------ * Updated DiffuseGI precompiled shaders. Added RayTracingSceneSrg and RayTracingMaterialSrg shader asset. Updated ShaderAssetCreator::Clone to handle the supervariant when processing root variants. Co-authored-by: Doug McDiarmid <dmcdiar@amazon.com> ------------------------------------------------------------------------------------ * Changed semantics for some PassSrg to SRG_PerPass_WithFallback. AuxGeom/FixedShapeProcessor.cpp requires SRG_PerDraw on ObjectSrg. Removed names of SceneSrg and ViewSrg from RPISystemDescriptor.cpp * Moved ShaderLib/Atom/Features/DummyEntryFunctions.azsli To Gems/Atom/RPI/Assets/ShaderLib/Atom/RPI/DummyEntryFunctions.azsli Removed redundant checking for finalization in ShaderResourceGroupLayout.cpp * Fixed race condition bug for Shader::FindOrCreate. InstanceDatabase<>::CreateInstance() needs to be atomic for instance creation and initialization. Added optional InstanceHandler::CreateFunctionWithParams to accomodate to the needs of Instances that need more than an asset reference to be able to be created an initialzed. Removed ShaderResourceGroup::FindOrCreate() only ::Create is available now. * Renamed scene_and_view_srgs.* as SceneAndViewSrgs.* Changed GetAzslFileOfOrigin for GetUniqueId * Fixed unit tests. * Reverted the serialization name of m_uniqueId back to "m_azslFileOfOrigin" so precompiled shaders don't fail in layout comparison. * Fixed AtomCore.Tests Removed non-applicable test. InstanceDatabase.AddHandler() is not available anymore. * The Null rhi is re-enabled for shader compilation. Signed-off-by: garrieta <garrieta@amazon.com>
116 lines
6.4 KiB
C++
116 lines
6.4 KiB
C++
/*
|
|
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
|
* its licensors.
|
|
*
|
|
* For complete copyright and license terms please see the LICENSE at the root of this
|
|
* distribution (the "License"). All use of this software is governed by the License,
|
|
* or, if provided, by the license below or the license accompanying this file. Do not
|
|
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
*
|
|
*/
|
|
|
|
#include <AzTest/AzTest.h>
|
|
#include <Common/RPITestFixture.h>
|
|
#include <Common/ShaderAssetTestUtils.h>
|
|
|
|
#include <Atom/RPI.Public/Shader/ShaderResourceGroup.h>
|
|
|
|
namespace UnitTest
|
|
{
|
|
using namespace AZ;
|
|
using namespace RPI;
|
|
|
|
class ShaderResourceGroupGeneralTests
|
|
: public RPITestFixture
|
|
{
|
|
protected:
|
|
RHI::Ptr<RHI::ShaderResourceGroupLayout> m_testSrgLayout;
|
|
Data::Asset<ShaderAsset> m_testShaderAsset;
|
|
|
|
RHI::Ptr<RHI::ShaderResourceGroupLayout> CreateTestSrgLayout(const char* nameId)
|
|
{
|
|
RHI::Ptr<RHI::ShaderResourceGroupLayout> srgLayout = RHI::ShaderResourceGroupLayout::Create();
|
|
|
|
srgLayout->SetName(Name(nameId));
|
|
srgLayout->SetBindingSlot(0);
|
|
srgLayout->AddShaderInput(RHI::ShaderInputBufferDescriptor{ Name{ "MyBufferA" }, RHI::ShaderInputBufferAccess::ReadWrite, RHI::ShaderInputBufferType::Raw, 1, 4, 1 });
|
|
srgLayout->AddShaderInput(RHI::ShaderInputBufferDescriptor{ Name{ "MyBufferB" }, RHI::ShaderInputBufferAccess::ReadWrite, RHI::ShaderInputBufferType::Raw, 1, 4, 2 });
|
|
srgLayout->AddShaderInput(RHI::ShaderInputImageDescriptor{ Name{ "MyImageA" }, RHI::ShaderInputImageAccess::Read, RHI::ShaderInputImageType::Image2D, 1, 3 });
|
|
srgLayout->AddShaderInput(RHI::ShaderInputImageDescriptor{ Name{ "MyImageB" }, RHI::ShaderInputImageAccess::Read, RHI::ShaderInputImageType::Image2D, 1, 4 });
|
|
srgLayout->AddShaderInput(RHI::ShaderInputSamplerDescriptor{ Name{ "MySamplerA" }, 1, 5 });
|
|
srgLayout->AddShaderInput(RHI::ShaderInputSamplerDescriptor{ Name{ "MySamplerB" }, 1, 6 });
|
|
srgLayout->AddShaderInput(RHI::ShaderInputConstantDescriptor{ Name{ "MyFloatA" }, 0, 4, 0 });
|
|
srgLayout->AddShaderInput(RHI::ShaderInputConstantDescriptor{ Name{ "MyFloatB" }, 4, 4, 0 });
|
|
srgLayout->Finalize();
|
|
|
|
return srgLayout;
|
|
}
|
|
|
|
void SetUp() override
|
|
{
|
|
RPITestFixture::SetUp();
|
|
|
|
m_testSrgLayout = CreateTestSrgLayout("TestSrg");
|
|
m_testShaderAsset = CreateTestShaderAsset(Uuid::CreateRandom(), m_testSrgLayout);
|
|
}
|
|
|
|
void TearDown() override
|
|
{
|
|
m_testSrgLayout = nullptr;
|
|
m_testShaderAsset.Reset();
|
|
|
|
RPITestFixture::TearDown();
|
|
}
|
|
};
|
|
|
|
TEST_F(ShaderResourceGroupGeneralTests, TestCreate)
|
|
{
|
|
Data::Instance<ShaderResourceGroup> srgInstance3 = ShaderResourceGroup::Create(m_testShaderAsset, AZ::RPI::DefaultSupervariantIndex, m_testSrgLayout->GetName());
|
|
Data::Instance<ShaderResourceGroup> srgInstance4 = ShaderResourceGroup::Create(m_testShaderAsset, AZ::RPI::DefaultSupervariantIndex, m_testSrgLayout->GetName());
|
|
|
|
EXPECT_TRUE(srgInstance3);
|
|
EXPECT_TRUE(srgInstance4);
|
|
|
|
// Instances created via Create should be the same object
|
|
|
|
EXPECT_NE(srgInstance3, srgInstance4);
|
|
}
|
|
|
|
TEST_F(ShaderResourceGroupGeneralTests, TestResourcePool)
|
|
{
|
|
Data::Instance<ShaderResourceGroup> srgA_instance1 = ShaderResourceGroup::Create(m_testShaderAsset, AZ::RPI::DefaultSupervariantIndex, m_testSrgLayout->GetName());
|
|
Data::Instance<ShaderResourceGroup> srgA_instance2 = ShaderResourceGroup::Create(m_testShaderAsset, AZ::RPI::DefaultSupervariantIndex, m_testSrgLayout->GetName());
|
|
|
|
auto srgLayoutB = CreateTestSrgLayout("TestSrgB");
|
|
auto shaderAssetB = CreateTestShaderAsset(Uuid::CreateRandom(), srgLayoutB);
|
|
Data::Instance<ShaderResourceGroup> srgB_instance1 = ShaderResourceGroup::Create(shaderAssetB, AZ::RPI::DefaultSupervariantIndex, srgLayoutB->GetName());
|
|
Data::Instance<ShaderResourceGroup> srgB_instance2 = ShaderResourceGroup::Create(shaderAssetB, AZ::RPI::DefaultSupervariantIndex, srgLayoutB->GetName());
|
|
|
|
// All instances based on the same asset should have the same pool
|
|
|
|
EXPECT_EQ(srgA_instance1->GetRHIShaderResourceGroup()->GetPool(), srgA_instance2->GetRHIShaderResourceGroup()->GetPool());
|
|
EXPECT_EQ(srgB_instance1->GetRHIShaderResourceGroup()->GetPool(), srgB_instance2->GetRHIShaderResourceGroup()->GetPool());
|
|
|
|
// Instances based on a different asset should have a different pool
|
|
|
|
EXPECT_NE(srgA_instance1->GetRHIShaderResourceGroup()->GetPool(), srgB_instance1->GetRHIShaderResourceGroup()->GetPool());
|
|
EXPECT_NE(srgA_instance1->GetRHIShaderResourceGroup()->GetPool(), srgB_instance2->GetRHIShaderResourceGroup()->GetPool());
|
|
}
|
|
|
|
TEST_F(ShaderResourceGroupGeneralTests, TestLayoutWrapperFunctions)
|
|
{
|
|
Data::Instance<ShaderResourceGroup> testSrg = ShaderResourceGroup::Create(m_testShaderAsset, AZ::RPI::DefaultSupervariantIndex, m_testSrgLayout->GetName());
|
|
|
|
EXPECT_TRUE(testSrg->GetLayout());
|
|
EXPECT_EQ(testSrg->FindShaderInputBufferIndex(Name{ "MyBufferA" }), testSrg->GetLayout()->FindShaderInputBufferIndex(Name{ "MyBufferA" }));
|
|
EXPECT_EQ(testSrg->FindShaderInputBufferIndex(Name{ "MyBufferB" }), testSrg->GetLayout()->FindShaderInputBufferIndex(Name{ "MyBufferB" }));
|
|
EXPECT_EQ(testSrg->FindShaderInputImageIndex(Name{ "MyImageA" }), testSrg->GetLayout()->FindShaderInputImageIndex(Name{ "MyImageA" }));
|
|
EXPECT_EQ(testSrg->FindShaderInputImageIndex(Name{ "MyImageB" }), testSrg->GetLayout()->FindShaderInputImageIndex(Name{ "MyImageB" }));
|
|
EXPECT_EQ(testSrg->FindShaderInputSamplerIndex(Name{ "MySamplerA" }), testSrg->GetLayout()->FindShaderInputSamplerIndex(Name{ "MySamplerA" }));
|
|
EXPECT_EQ(testSrg->FindShaderInputSamplerIndex(Name{ "MySamplerB" }), testSrg->GetLayout()->FindShaderInputSamplerIndex(Name{ "MySamplerB" }));
|
|
EXPECT_EQ(testSrg->FindShaderInputConstantIndex(Name{ "MyFloatA" }), testSrg->GetLayout()->FindShaderInputConstantIndex(Name{ "MyFloatA" }));
|
|
EXPECT_EQ(testSrg->FindShaderInputConstantIndex(Name{ "MyFloatB" }), testSrg->GetLayout()->FindShaderInputConstantIndex(Name{ "MyFloatB" }));
|
|
}
|
|
}
|