| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565 |
- /*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
- #include "RHITestFixture.h"
- #include <Atom/RHI.Reflect/RenderAttachmentLayoutBuilder.h>
- #include <AzCore/Name/NameDictionary.h>
- namespace UnitTest
- {
- using namespace AZ;
- using namespace RHI;
- class RenderAttachmentLayoutBuilderTests
- : public RHITestFixture
- {
- protected:
- template<class T>
- void ExpectEqMemory(AZStd::span<const T> expected, AZStd::span<const T> actual)
- {
- EXPECT_EQ(expected.size(), actual.size());
- EXPECT_TRUE(memcmp(expected.data(), actual.data(), expected.size() * sizeof(T)) == 0);
- }
- void ExpectEq(AZStd::span<const SubpassRenderAttachmentLayout> expected, AZStd::span<const SubpassRenderAttachmentLayout> actual)
- {
- EXPECT_EQ(expected.size(), actual.size());
- for (int i = 0; i < expected.size() && i < actual.size(); ++i)
- {
- const auto& expectedLayout = expected[i];
- const auto& actualLayout = actual[i];
- ExpectEqMemory<RenderAttachmentDescriptor>(
- { expectedLayout.m_rendertargetDescriptors.begin(), expectedLayout.m_rendertargetCount },
- { actualLayout.m_rendertargetDescriptors.begin(), actualLayout.m_rendertargetCount });
- ExpectEqMemory<SubpassInputDescriptor>(
- { expectedLayout.m_subpassInputDescriptors.begin(), expectedLayout.m_subpassInputCount },
- { actualLayout.m_subpassInputDescriptors.begin(), actualLayout.m_subpassInputCount });
- ExpectEqMemory<RenderAttachmentDescriptor>({ &expectedLayout.m_depthStencilDescriptor, 1 }, { &actualLayout.m_depthStencilDescriptor, 1 });
- }
- }
- void ExpectEq(const RenderAttachmentLayout& expected, const RenderAttachmentLayout& actual)
- {
- ExpectEqMemory<Format>({ expected.m_attachmentFormats.begin(), expected.m_attachmentCount }, { actual.m_attachmentFormats.begin(), actual.m_attachmentCount });
- ExpectEq({ expected.m_subpassLayouts.begin(), expected.m_subpassCount }, { actual.m_subpassLayouts.begin(), actual.m_subpassCount });
- }
- };
- TEST_F(RenderAttachmentLayoutBuilderTests, TestDefault)
- {
- RenderAttachmentLayout expected;
- RenderAttachmentLayout actual;
- ResultCode result = RenderAttachmentLayoutBuilder().End(actual);
- EXPECT_EQ(result, ResultCode::Success);
- ExpectEq(expected, actual);
- }
- TEST_F(RenderAttachmentLayoutBuilderTests, TestSingleSubpass)
- {
- RenderAttachmentLayout expected;
- {
- expected.m_subpassCount = 1;
- expected.m_attachmentCount = 3;
- expected.m_attachmentFormats[0] = Format::R16_FLOAT;
- expected.m_attachmentFormats[1] = Format::R8G8B8A8_SINT;
- expected.m_attachmentFormats[2] = Format::D16_UNORM;
- auto& subpassLayout = expected.m_subpassLayouts[0];
- subpassLayout.m_rendertargetCount = 2;
- subpassLayout.m_rendertargetDescriptors[0].m_attachmentIndex = 0;
- subpassLayout.m_rendertargetDescriptors[1].m_attachmentIndex = 1;
- subpassLayout.m_depthStencilDescriptor.m_attachmentIndex = 2;
- }
-
- RenderAttachmentLayout actual;
- {
- RHI::RenderAttachmentLayoutBuilder layoutBuilder;
- layoutBuilder.AddSubpass()
- ->RenderTargetAttachment(Format::R16_FLOAT)
- ->RenderTargetAttachment(Format::R8G8B8A8_SINT)
- ->DepthStencilAttachment(Format::D16_UNORM);
- ResultCode result = layoutBuilder.End(actual);
- EXPECT_EQ(result, ResultCode::Success);
- }
- ExpectEq(expected, actual);
- }
- TEST_F(RenderAttachmentLayoutBuilderTests, TestMultipleSubpasses)
- {
- RenderAttachmentLayout expected;
- {
- expected.m_subpassCount = 2;
- expected.m_attachmentCount = 4;
- expected.m_attachmentFormats[0] = Format::R10G10B10A2_UNORM;
- expected.m_attachmentFormats[1] = Format::R32_FLOAT;
- expected.m_attachmentFormats[2] = Format::R10G10B10A2_UNORM;
- expected.m_attachmentFormats[3] = Format::D24_UNORM_S8_UINT;
- {
- auto& subpassLayout = expected.m_subpassLayouts[0];
- subpassLayout.m_rendertargetCount = 2;
- subpassLayout.m_rendertargetDescriptors[0].m_attachmentIndex = 0;
- subpassLayout.m_rendertargetDescriptors[1].m_attachmentIndex = 1;
- }
- {
- auto& subpassLayout = expected.m_subpassLayouts[1];
- subpassLayout.m_rendertargetCount = 1;
- subpassLayout.m_rendertargetDescriptors[0].m_attachmentIndex = 2;
- subpassLayout.m_depthStencilDescriptor.m_attachmentIndex = 3;
- }
- }
- RenderAttachmentLayout actual;
- {
- RHI::RenderAttachmentLayoutBuilder layoutBuilder;
- layoutBuilder.AddSubpass()
- ->RenderTargetAttachment(Format::R10G10B10A2_UNORM)
- ->RenderTargetAttachment(Format::R32_FLOAT);
- layoutBuilder.AddSubpass()
- ->RenderTargetAttachment(Format::R10G10B10A2_UNORM)
- ->DepthStencilAttachment(Format::D24_UNORM_S8_UINT);
- ResultCode result = layoutBuilder.End(actual);
- EXPECT_EQ(result, ResultCode::Success);
- }
- ExpectEq(expected, actual);
- }
- TEST_F(RenderAttachmentLayoutBuilderTests, TestSubpassInputs)
- {
- RenderAttachmentLayout expected;
- {
- expected.m_subpassCount = 3;
- expected.m_attachmentCount = 4;
- expected.m_attachmentFormats[0] = Format::R10G10B10A2_UNORM;
- expected.m_attachmentFormats[1] = Format::R32_FLOAT;
- expected.m_attachmentFormats[2] = Format::R10G10B10A2_UNORM;
- expected.m_attachmentFormats[3] = Format::D24_UNORM_S8_UINT;
- {
- auto& subpassLayout = expected.m_subpassLayouts[0];
- subpassLayout.m_rendertargetCount = 2;
- subpassLayout.m_rendertargetDescriptors[0].m_attachmentIndex = 0;
- subpassLayout.m_rendertargetDescriptors[1].m_attachmentIndex = 1;
- }
- {
- auto& subpassLayout = expected.m_subpassLayouts[1];
- subpassLayout.m_rendertargetCount = 1;
- subpassLayout.m_rendertargetDescriptors[0].m_attachmentIndex = 2;
- subpassLayout.m_depthStencilDescriptor.m_attachmentIndex = 3;
- }
- {
- auto& subpassLayout = expected.m_subpassLayouts[2];
- subpassLayout.m_rendertargetCount = 1;
- subpassLayout.m_subpassInputCount = 2;
- subpassLayout.m_rendertargetDescriptors[0].m_attachmentIndex = 1;
- subpassLayout.m_subpassInputDescriptors[0] = RHI::SubpassInputDescriptor{ 2, ImageAspectFlags::Color };
- subpassLayout.m_subpassInputDescriptors[1] = RHI::SubpassInputDescriptor{ 0, ImageAspectFlags::Color };
- }
- }
- RenderAttachmentLayout actual;
- {
- RHI::RenderAttachmentLayoutBuilder layoutBuilder;
- layoutBuilder.AddSubpass()
- ->RenderTargetAttachment(Format::R10G10B10A2_UNORM, Name{ "InputAttachment1" })
- ->RenderTargetAttachment(Format::R32_FLOAT, Name{ "RenderTarget0" });
- layoutBuilder.AddSubpass()
- ->RenderTargetAttachment(Format::R10G10B10A2_UNORM, Name{ "InputAttachment0" })
- ->DepthStencilAttachment(Format::D24_UNORM_S8_UINT);
- layoutBuilder.AddSubpass()
- ->RenderTargetAttachment(Name{ "RenderTarget0" })
- ->SubpassInputAttachment(Name{ "InputAttachment0" }, ImageAspectFlags::Color)
- ->SubpassInputAttachment(Name{ "InputAttachment1" }, ImageAspectFlags::Color);
- ResultCode result = layoutBuilder.End(actual);
- EXPECT_EQ(result, ResultCode::Success);
- }
- ExpectEq(expected, actual);
- }
- TEST_F(RenderAttachmentLayoutBuilderTests, TestResolveAttachments)
- {
- RenderAttachmentLayout expected;
- {
- expected.m_subpassCount = 1;
- expected.m_attachmentCount = 4;
- expected.m_attachmentFormats[0] = Format::R16_FLOAT;
- expected.m_attachmentFormats[1] = Format::R16_FLOAT;
- expected.m_attachmentFormats[2] = Format::R8G8B8A8_SINT;
- expected.m_attachmentFormats[3] = Format::D16_UNORM;
- auto& subpassLayout = expected.m_subpassLayouts[0];
- subpassLayout.m_rendertargetCount = 2;
- subpassLayout.m_rendertargetDescriptors[0].m_attachmentIndex = 1;
- subpassLayout.m_rendertargetDescriptors[0].m_resolveAttachmentIndex = 0;
- subpassLayout.m_rendertargetDescriptors[1].m_attachmentIndex = 2;
- subpassLayout.m_depthStencilDescriptor.m_attachmentIndex = 3;
- }
- RenderAttachmentLayout actual;
- {
- RHI::RenderAttachmentLayoutBuilder layoutBuilder;
- layoutBuilder.AddSubpass()
- ->RenderTargetAttachment(Format::R16_FLOAT, true)
- ->RenderTargetAttachment(Format::R8G8B8A8_SINT)
- ->DepthStencilAttachment(Format::D16_UNORM);
- ResultCode result = layoutBuilder.End(actual);
- EXPECT_EQ(result, ResultCode::Success);
- }
- ExpectEq(expected, actual);
- }
- TEST_F(RenderAttachmentLayoutBuilderTests, TestRenderTargetByName)
- {
- RenderAttachmentLayout expected;
- {
- expected.m_subpassCount = 2;
- expected.m_attachmentCount = 3;
- expected.m_attachmentFormats[0] = Format::R16_FLOAT;
- expected.m_attachmentFormats[1] = Format::R8G8B8A8_SINT;
- expected.m_attachmentFormats[2] = Format::D16_UNORM;
- {
- auto& subpassLayout = expected.m_subpassLayouts[0];
- subpassLayout.m_rendertargetCount = 2;
- subpassLayout.m_rendertargetDescriptors[0].m_attachmentIndex = 0;
- subpassLayout.m_rendertargetDescriptors[1].m_attachmentIndex = 1;
- subpassLayout.m_depthStencilDescriptor.m_attachmentIndex = 2;
- }
- {
- auto& subpassLayout = expected.m_subpassLayouts[1];
- subpassLayout.m_rendertargetCount = 2;
- subpassLayout.m_rendertargetDescriptors[0].m_attachmentIndex = 0;
- subpassLayout.m_rendertargetDescriptors[1].m_attachmentIndex = 1;
- }
- }
- RenderAttachmentLayout actual;
- {
- RHI::RenderAttachmentLayoutBuilder layoutBuilder;
- layoutBuilder.AddSubpass()
- ->RenderTargetAttachment(Format::R16_FLOAT, Name{ "RenderTaret0" })
- ->RenderTargetAttachment(Format::R8G8B8A8_SINT, Name{ "RenderTaret1" })
- ->DepthStencilAttachment(Format::D16_UNORM);
- layoutBuilder.AddSubpass()
- ->RenderTargetAttachment(Name{ "RenderTaret0" })
- ->RenderTargetAttachment(Name{ "RenderTaret1" });
- ResultCode result = layoutBuilder.End(actual);
- EXPECT_EQ(result, ResultCode::Success);
- }
- ExpectEq(expected, actual);
- }
- TEST_F(RenderAttachmentLayoutBuilderTests, TestDepthStencil)
- {
- RenderAttachmentLayout expected;
- {
- expected.m_subpassCount = 2;
- expected.m_attachmentCount = 3;
- expected.m_attachmentFormats[0] = Format::R16_FLOAT;
- expected.m_attachmentFormats[1] = Format::R8G8B8A8_SINT;
- expected.m_attachmentFormats[2] = Format::D16_UNORM;
- {
- auto& subpassLayout = expected.m_subpassLayouts[0];
- subpassLayout.m_rendertargetCount = 2;
- subpassLayout.m_rendertargetDescriptors[0].m_attachmentIndex = 0;
- subpassLayout.m_rendertargetDescriptors[1].m_attachmentIndex = 1;
- subpassLayout.m_depthStencilDescriptor.m_attachmentIndex = 2;
- }
- {
- auto& subpassLayout = expected.m_subpassLayouts[1];
- subpassLayout.m_depthStencilDescriptor.m_attachmentIndex = 2;
- }
- }
- RenderAttachmentLayout actual;
- {
- RHI::RenderAttachmentLayoutBuilder layoutBuilder;
- layoutBuilder.AddSubpass()
- ->RenderTargetAttachment(Format::R16_FLOAT)
- ->RenderTargetAttachment(Format::R8G8B8A8_SINT)
- ->DepthStencilAttachment(Format::D16_UNORM);
- layoutBuilder.AddSubpass()
- ->DepthStencilAttachment();
- ResultCode result = layoutBuilder.End(actual);
- EXPECT_EQ(result, ResultCode::Success);
- }
- ExpectEq(expected, actual);
- }
- TEST_F(RenderAttachmentLayoutBuilderTests, TestResolveByName)
- {
- RenderAttachmentLayout expected;
- {
- expected.m_subpassCount = 1;
- expected.m_attachmentCount = 4;
- expected.m_attachmentFormats[0] = Format::R16_FLOAT;
- expected.m_attachmentFormats[1] = Format::R16_FLOAT;
- expected.m_attachmentFormats[2] = Format::R8G8B8A8_SINT;
- expected.m_attachmentFormats[3] = Format::D16_UNORM;
- auto& subpassLayout = expected.m_subpassLayouts[0];
- subpassLayout.m_rendertargetCount = 2;
- subpassLayout.m_rendertargetDescriptors[0].m_attachmentIndex = 1;
- subpassLayout.m_rendertargetDescriptors[0].m_resolveAttachmentIndex = 0;
- subpassLayout.m_rendertargetDescriptors[1].m_attachmentIndex = 2;
- subpassLayout.m_depthStencilDescriptor.m_attachmentIndex = 3;
- }
- RenderAttachmentLayout actual;
- {
- RHI::RenderAttachmentLayoutBuilder layoutBuilder;
- layoutBuilder.AddSubpass()
- ->RenderTargetAttachment(Format::R16_FLOAT, Name{ "RenderTarget0" })
- ->RenderTargetAttachment(Format::R8G8B8A8_SINT)
- ->DepthStencilAttachment(Format::D16_UNORM)
- ->ResolveAttachment(Name{ "RenderTarget0" });
- ResultCode result = layoutBuilder.End(actual);
- EXPECT_EQ(result, ResultCode::Success);
- }
- ExpectEq(expected, actual);
- }
- TEST_F(RenderAttachmentLayoutBuilderTests, TestResolveAsSubpassInput)
- {
- RenderAttachmentLayout expected;
- {
- expected.m_subpassCount = 2;
- expected.m_attachmentCount = 4;
- expected.m_attachmentFormats[0] = Format::R10G10B10A2_UNORM;
- expected.m_attachmentFormats[1] = Format::R10G10B10A2_UNORM;
- expected.m_attachmentFormats[2] = Format::R32_FLOAT;
- expected.m_attachmentFormats[3] = Format::D24_UNORM_S8_UINT;
- {
- auto& subpassLayout = expected.m_subpassLayouts[0];
- subpassLayout.m_rendertargetCount = 2;
- subpassLayout.m_rendertargetDescriptors[0].m_attachmentIndex = 1;
- subpassLayout.m_rendertargetDescriptors[0].m_resolveAttachmentIndex = 0;
- subpassLayout.m_rendertargetDescriptors[1].m_attachmentIndex = 2;
- }
- {
- auto& subpassLayout = expected.m_subpassLayouts[1];
- subpassLayout.m_subpassInputCount = 1;
- subpassLayout.m_subpassInputDescriptors[0] = RHI::SubpassInputDescriptor{ 0, ImageAspectFlags::Color };
- subpassLayout.m_depthStencilDescriptor.m_attachmentIndex = 3;
- }
- }
- RenderAttachmentLayout actual;
- {
- RHI::RenderAttachmentLayoutBuilder layoutBuilder;
- layoutBuilder.AddSubpass()
- ->RenderTargetAttachment(Format::R10G10B10A2_UNORM, Name{ "ColorAttachment0" })
- ->RenderTargetAttachment(Format::R32_FLOAT)
- ->ResolveAttachment(Name{ "ColorAttachment0" }, Name{ "Resolve0" });
- layoutBuilder.AddSubpass()
- ->SubpassInputAttachment(Name{ "Resolve0" }, ImageAspectFlags::Color)
- ->DepthStencilAttachment(Format::D24_UNORM_S8_UINT);
- ResultCode result = layoutBuilder.End(actual);
- EXPECT_EQ(result, ResultCode::Success);
- }
- ExpectEq(expected, actual);
- }
- TEST_F(RenderAttachmentLayoutBuilderTests, TestAttachmentLoadStoreAction)
- {
- RenderAttachmentLayout expected;
- AttachmentLoadStoreAction renderTargetLoadStoreAction;
- renderTargetLoadStoreAction.m_storeAction = RHI::AttachmentStoreAction::DontCare;
- AttachmentLoadStoreAction depthStencilLoadStoreAction;
- {
- expected.m_subpassCount = 1;
- expected.m_attachmentCount = 3;
- expected.m_attachmentFormats[0] = Format::R10G10B10A2_UNORM;
- expected.m_attachmentFormats[1] = Format::R32_FLOAT;
- expected.m_attachmentFormats[2] = Format::D24_UNORM_S8_UINT;
- {
- auto& subpassLayout = expected.m_subpassLayouts[0];
- subpassLayout.m_rendertargetCount = 2;
- subpassLayout.m_rendertargetDescriptors[0].m_attachmentIndex = 0;
- subpassLayout.m_rendertargetDescriptors[0].m_loadStoreAction = renderTargetLoadStoreAction;
- subpassLayout.m_rendertargetDescriptors[1].m_attachmentIndex = 1;
- subpassLayout.m_rendertargetDescriptors[1].m_loadStoreAction = depthStencilLoadStoreAction;
- subpassLayout.m_depthStencilDescriptor.m_attachmentIndex = 2;
- }
- }
- RenderAttachmentLayout actual;
- {
- RHI::RenderAttachmentLayoutBuilder layoutBuilder;
- depthStencilLoadStoreAction.m_storeActionStencil = RHI::AttachmentStoreAction::Store;
- layoutBuilder.AddSubpass()
- ->RenderTargetAttachment(Format::R10G10B10A2_UNORM, Name{"RenderTarget0"}, renderTargetLoadStoreAction)
- ->RenderTargetAttachment(Format::R32_FLOAT)
- ->DepthStencilAttachment(Format::D24_UNORM_S8_UINT, Name{ "DepthStencil" }, depthStencilLoadStoreAction);
- ResultCode result = layoutBuilder.End(actual);
- EXPECT_EQ(result, ResultCode::Success);
- }
- ExpectEq(expected, actual);
- }
- TEST_F(RenderAttachmentLayoutBuilderTests, TestInvalidRenderTargetFormat)
- {
- RenderAttachmentLayout actual;
- RHI::RenderAttachmentLayoutBuilder layoutBuilder;
- layoutBuilder.AddSubpass()
- ->RenderTargetAttachment(Format::Unknown)
- ->RenderTargetAttachment(Format::R32_FLOAT)
- ->DepthStencilAttachment(Format::D24_UNORM_S8_UINT);
- AZ_TEST_START_TRACE_SUPPRESSION;
- ResultCode result = layoutBuilder.End(actual);
- EXPECT_EQ(result, ResultCode::InvalidArgument);
- AZ_TEST_STOP_TRACE_SUPPRESSION(1);
- }
- TEST_F(RenderAttachmentLayoutBuilderTests, TestInvalidRenderTargetFormatByReference)
- {
- RenderAttachmentLayout actual;
- RHI::RenderAttachmentLayoutBuilder layoutBuilder;
- layoutBuilder.AddSubpass()
- ->RenderTargetAttachment(Format::R10G10B10A2_UNORM, Name{ "RenderAttachment0" })
- ->RenderTargetAttachment(Format::R32_FLOAT)
- ->DepthStencilAttachment(Format::D24_UNORM_S8_UINT);
- layoutBuilder.AddSubpass()
- ->RenderTargetAttachment(Format::R32_FLOAT, Name{ "RenderAttachment0" });
- AZ_TEST_START_TRACE_SUPPRESSION;
- ResultCode result = layoutBuilder.End(actual);
- EXPECT_EQ(result, ResultCode::InvalidArgument);
- AZ_TEST_STOP_TRACE_SUPPRESSION(1);
- }
- TEST_F(RenderAttachmentLayoutBuilderTests, TestInvalidRenderTargetName)
- {
- RenderAttachmentLayout actual;
- RHI::RenderAttachmentLayoutBuilder layoutBuilder;
- layoutBuilder.AddSubpass()
- ->RenderTargetAttachment(Name{ "RenderAttachment0" })
- ->RenderTargetAttachment(Format::R32_FLOAT)
- ->DepthStencilAttachment(Format::D24_UNORM_S8_UINT);
- AZ_TEST_START_TRACE_SUPPRESSION;
- ResultCode result = layoutBuilder.End(actual);
- EXPECT_EQ(result, ResultCode::InvalidArgument);
- AZ_TEST_STOP_TRACE_SUPPRESSION(1);
- }
- TEST_F(RenderAttachmentLayoutBuilderTests, TestInvalidDepthStencilFormat)
- {
- RenderAttachmentLayout actual;
- RHI::RenderAttachmentLayoutBuilder layoutBuilder;
- layoutBuilder.AddSubpass()
- ->RenderTargetAttachment(Format::R10G10B10A2_UNORM)
- ->RenderTargetAttachment(Format::R32_FLOAT)
- ->DepthStencilAttachment(Format::D24_UNORM_S8_UINT);
- layoutBuilder.AddSubpass()
- ->DepthStencilAttachment(Format::D32_FLOAT);
- AZ_TEST_START_TRACE_SUPPRESSION;
- ResultCode result = layoutBuilder.End(actual);
- EXPECT_EQ(result, ResultCode::InvalidArgument);
- AZ_TEST_STOP_TRACE_SUPPRESSION(1);
- }
- TEST_F(RenderAttachmentLayoutBuilderTests, TestInvalidDepthStencilName)
- {
- RenderAttachmentLayout actual;
- RHI::RenderAttachmentLayoutBuilder layoutBuilder;
- layoutBuilder.AddSubpass()
- ->RenderTargetAttachment(Format::R10G10B10A2_UNORM)
- ->RenderTargetAttachment(Format::R32_FLOAT)
- ->DepthStencilAttachment(Format::D24_UNORM_S8_UINT, Name{ "DepthStencil" });
- layoutBuilder.AddSubpass()
- ->DepthStencilAttachment(Name{ "InvalidDepthStencilName" });
- AZ_TEST_START_TRACE_SUPPRESSION;
- ResultCode result = layoutBuilder.End(actual);
- EXPECT_EQ(result, ResultCode::InvalidArgument);
- AZ_TEST_STOP_TRACE_SUPPRESSION(1);
- }
- TEST_F(RenderAttachmentLayoutBuilderTests, TestNotDefinedDepthStencilFormat)
- {
- RenderAttachmentLayout actual;
- RHI::RenderAttachmentLayoutBuilder layoutBuilder;
- layoutBuilder.AddSubpass()
- ->RenderTargetAttachment(Format::R10G10B10A2_UNORM)
- ->RenderTargetAttachment(Format::R32_FLOAT)
- ->DepthStencilAttachment();
- AZ_TEST_START_TRACE_SUPPRESSION;
- ResultCode result = layoutBuilder.End(actual);
- EXPECT_EQ(result, ResultCode::InvalidArgument);
- AZ_TEST_STOP_TRACE_SUPPRESSION(1);
- }
- TEST_F(RenderAttachmentLayoutBuilderTests, TestInvalidResolve)
- {
- RenderAttachmentLayout actual;
- RHI::RenderAttachmentLayoutBuilder layoutBuilder;
- AZ_TEST_START_TRACE_SUPPRESSION;
- layoutBuilder.AddSubpass()
- ->RenderTargetAttachment(Format::R10G10B10A2_UNORM)
- ->RenderTargetAttachment(Format::R32_FLOAT)
- ->ResolveAttachment(Name{ "InvalidAttachment" });
- AZ_TEST_STOP_TRACE_SUPPRESSION(1);
- }
- TEST_F(RenderAttachmentLayoutBuilderTests, TestInvalidSubpassInput)
- {
- RenderAttachmentLayout actual;
- RHI::RenderAttachmentLayoutBuilder layoutBuilder;
- layoutBuilder.AddSubpass()
- ->RenderTargetAttachment(Format::R10G10B10A2_UNORM)
- ->RenderTargetAttachment(Format::R32_FLOAT);
- layoutBuilder.AddSubpass()->SubpassInputAttachment(Name{ "InvalidSubpassInput" }, ImageAspectFlags::Color);
- AZ_TEST_START_TRACE_SUPPRESSION;
- ResultCode result = layoutBuilder.End(actual);
- EXPECT_EQ(result, ResultCode::InvalidArgument);
- AZ_TEST_STOP_TRACE_SUPPRESSION(1);
- }
- }
|