summaryrefslogtreecommitdiffstats
path: root/Tests/TestApp/src
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-09-09 21:57:05 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-09-09 21:57:05 +0000
commit4a53e797919cc5d1fef1abfb5e3f646d80e374c6 (patch)
treead49562630616fd20cc25f4266da44059d142eef /Tests/TestApp/src
parentUdated core (diff)
downloadDiligentEngine-4a53e797919cc5d1fef1abfb5e3f646d80e374c6.tar.gz
DiligentEngine-4a53e797919cc5d1fef1abfb5e3f646d80e374c6.zip
Updated test + core and samples submodules
Diffstat (limited to 'Tests/TestApp/src')
-rw-r--r--Tests/TestApp/src/RingBufferTest.cpp239
-rw-r--r--Tests/TestApp/src/TestShaderVarAccess.cpp7
-rw-r--r--Tests/TestApp/src/VarSizeAllocationsManagerTest.cpp113
3 files changed, 264 insertions, 95 deletions
diff --git a/Tests/TestApp/src/RingBufferTest.cpp b/Tests/TestApp/src/RingBufferTest.cpp
index 03aec5a..60281c0 100644
--- a/Tests/TestApp/src/RingBufferTest.cpp
+++ b/Tests/TestApp/src/RingBufferTest.cpp
@@ -45,92 +45,253 @@ RingBufferTest::RingBufferTest() :
{
auto &Allocator = DefaultRawMemoryAllocator::GetAllocator();
{
- RingBuffer RB(1024, Allocator);
+ RingBuffer RB(1023, Allocator);
- auto Offset = RB.Allocate(256);
+ auto Offset = RB.Allocate(120, 16);
+ //
+ // O h
+ // | | |
+ // 0 128
VERIFY_EXPR(Offset == 0);
- Offset = RB.Allocate(256);
+
+ Offset = RB.Allocate(10, 1);
+ //
+ // t O h
+ // | | | |
+ // 0 128 138
+ VERIFY_EXPR(Offset == 128);
+
+ Offset = RB.Allocate(10, 32);
+ //
+ // t O h
+ // | | | |
+ // 0 128 138 160 192
+ VERIFY_EXPR(Offset == 160);
+
+ Offset = RB.Allocate(17, 1);
+ //
+ // t O h
+ // | | | |
+ // 0 128 138 160 192 209
+ VERIFY_EXPR(Offset == 192);
+
+ Offset = RB.Allocate(65, 64);
+ //
+ // t O h
+ // | | | |
+ // 0 128 138 160 192 209 256 384
VERIFY_EXPR(Offset == 256);
- RB.FinishCurrentFrame(0);
+ RB.FinishCurrentFrame(1);
+ //
+ // t h1
+ // | | |
+ // 0 384
+
- Offset = RB.Allocate(256);
+ Offset = RB.Allocate(100, 256);
+ //
+ // t h1 O h
+ // | | | | |
+ // 0 384 512 768
VERIFY_EXPR(Offset == 512);
- Offset = RB.Allocate(256);
+
+ Offset = RB.Allocate(127, 1);
+ //
+ // t h1 O h
+ // | | | | |
+ // 0 384 512 768 895 = 1023-128
VERIFY_EXPR(Offset == 768);
- RB.FinishCurrentFrame(1);
+ Offset = RB.Allocate(128, 2);
+ VERIFY_EXPR(Offset == RingBuffer::InvalidOffset);
+
+ Offset = RB.Allocate(128, 1);
+ //
+ // t h1 O h
+ // | | | |
+ // 0 384 512 768 895 1023
+ VERIFY_EXPR(Offset == 895);
+
+ RB.FinishCurrentFrame(2);
+ //
+ // t h1 h2,h
+ // | | |
+ // 0 384 1023
VERIFY_EXPR(RB.IsFull());
- Offset = RB.Allocate(256);
+ Offset = RB.Allocate(1, 1);
VERIFY_EXPR(Offset == RingBuffer::InvalidOffset);
RingBuffer RB1(std::move(RB));
+ VERIFY_EXPR(RB.IsEmpty());
+ RB1.ReleaseCompletedFrames(1);
+ //
+ // t h2
+ // | | |
+ // 0 384 1023
+
RB1.ReleaseCompletedFrames(2);
+ //
+ // h,t
+ // | |
+ // 0 1023
VERIFY_EXPR(RB1.IsEmpty());
-
VERIFY_EXPR(RB1.GetUsedSize() == 0);
-
- Offset = RB1.Allocate(256);
+
+ Offset = RB1.Allocate(256,1);
+ //
+ // O h t
+ // | | |
+ // 0 256 1023
VERIFY_EXPR(Offset == 0);
-
- Offset = RB1.Allocate(256);
+
+
+ Offset = RB1.Allocate(256, 16);
+ RB1.ReleaseCompletedFrames(0);
+ //
+ // O h t
+ // | | | |
+ // 0 256 512 1023
VERIFY_EXPR(Offset == 256);
RB1.FinishCurrentFrame(2);
- RB1.ReleaseCompletedFrames(3);
+ RB1.FinishCurrentFrame(3); // ignored
+ //
+ // h2 t
+ // | | |
+ // 0 512 1023
+ RB1.ReleaseCompletedFrames(2);
+ //
+ // h,t
+ // | |
+ // 0 1023
+ RB1.ReleaseCompletedFrames(3);
+
VERIFY_EXPR(RB1.GetUsedSize() == 0);
VERIFY_EXPR(RB1.IsEmpty());
- Offset = RB1.Allocate(256);
+ Offset = RB1.Allocate(512,1);
+ //
+ // O h
+ // | | |
+ // 0 512 1023
+ VERIFY_EXPR(Offset == 0);
+
+ RB1.FinishCurrentFrame(4);
+ RB1.FinishCurrentFrame(5);
+ //
+ // t h4
+ // | | |
+ // 0 512 1023
+
+ Offset = RB1.Allocate(129,1);
+ //
+ // t h4,O h
+ // | | | |
+ // 0 512 641 1023
VERIFY_EXPR(Offset == 512);
- Offset = RB1.Allocate(512);
+ RB1.ReleaseCompletedFrames(4);
+ //
+ // t h
+ // | | | |
+ // 0 512 641 1023
+
+
+ Offset = RB1.Allocate(128,128);
+ //
+ // t O h
+ // | | | | |
+ // 0 512 641 768 896 1023
+ VERIFY_EXPR(Offset == 768);
+
+ Offset = RB1.Allocate(513,64);
+ VERIFY_EXPR(Offset == RingBuffer::InvalidOffset);
+
+ Offset = RB1.Allocate(513,1);
+ VERIFY_EXPR(Offset == RingBuffer::InvalidOffset);
+
+ Offset = RB1.Allocate(255,1);
+ //
+ // O h t
+ // | | | |
+ // 0 255 512 1023
VERIFY_EXPR(Offset == 0);
+ RB1.FinishCurrentFrame(6);
+ //
+ // O h,h6 t
+ // | | | |
+ // 0 255 512 1023
+
+
+ Offset = RB1.Allocate(256, 2);
+ //
+ // h6 O t,h
+ // | | | | |
+ // 0 255 256 512 1023
+ VERIFY_EXPR(Offset == 256);
+
VERIFY_EXPR(RB1.IsFull());
- Offset = RB1.Allocate(1);
+ Offset = RB1.Allocate(1,1);
VERIFY_EXPR(Offset == RingBuffer::InvalidOffset);
- RB1.FinishCurrentFrame(3);
-
- RB = std::move(RB1);
- RB.ReleaseCompletedFrames(4);
- VERIFY_EXPR(RB.GetUsedSize() == 0);
- VERIFY_EXPR(RB.IsEmpty());
+ RB1.ReleaseCompletedFrames(6);
+ //
+ // t h
+ // | | | |
+ // 0 255 512 1023
- Offset = RB.Allocate(256);
+ Offset = RB1.Allocate(511, 1);
+ //
+ // t O h
+ // | | | |
+ // 0 255 512 1023
VERIFY_EXPR(Offset == 512);
- Offset = RB.Allocate(512+1);
- VERIFY_EXPR(Offset == RingBuffer::InvalidOffset);
- Offset = RB.Allocate(256);
- VERIFY_EXPR(Offset == 768);
- Offset = RB.Allocate(256);
+
+ Offset = RB1.Allocate(191,1);
+ //
+ // O h t
+ // | | | |
+ // 0 191 255 1023
VERIFY_EXPR(Offset == 0);
- Offset = RB.Allocate(256+1);
+
+ Offset = RB1.Allocate(64,2);
VERIFY_EXPR(Offset == RingBuffer::InvalidOffset);
- RB.FinishCurrentFrame(5);
- RB.ReleaseCompletedFrames(6);
+
+ Offset = RB1.Allocate(64,1);
+ //
+ // O t,h
+ // | | | |
+ // 0 191 255 1023
+ VERIFY_EXPR(Offset == 191);
+
+ Offset = RB1.Allocate(1,1);
+ VERIFY_EXPR(Offset == RingBuffer::InvalidOffset);
+
+ RB1.FinishCurrentFrame(7);
+ RB1.ReleaseCompletedFrames(7);
}
{
RingBuffer RB(1024, Allocator);
- auto offset = RB.Allocate(512);
+ auto offset = RB.Allocate(512, 1);
RB.FinishCurrentFrame(0);
RB.FinishCurrentFrame(1);
- RB.ReleaseCompletedFrames(2);
+ RB.ReleaseCompletedFrames(1);
RB.FinishCurrentFrame(2);
RB.FinishCurrentFrame(3);
- offset = RB.Allocate(512);
+ offset = RB.Allocate(512, 1);
RB.FinishCurrentFrame(4);
+ RB.ReleaseCompletedFrames(2);
RB.ReleaseCompletedFrames(3);
RB.ReleaseCompletedFrames(4);
- RB.ReleaseCompletedFrames(5);
- offset = RB.Allocate(512);
+ offset = RB.Allocate(512, 1);
RB.FinishCurrentFrame(5);
- RB.ReleaseCompletedFrames(6);
+ RB.ReleaseCompletedFrames(5);
}
-
+
SetStatus(TestResult::Succeeded);
}
diff --git a/Tests/TestApp/src/TestShaderVarAccess.cpp b/Tests/TestApp/src/TestShaderVarAccess.cpp
index 78791bf..1f59bfc 100644
--- a/Tests/TestApp/src/TestShaderVarAccess.cpp
+++ b/Tests/TestApp/src/TestShaderVarAccess.cpp
@@ -532,6 +532,13 @@ TestShaderVarAccess::TestShaderVarAccess( IRenderDevice *pDevice, IDeviceContext
pSRB->GetVariable(SHADER_TYPE_PIXEL, "g_rwBuff_Dyn")->Set(pFormattedBuffUAV[3]);
pSRB->GetVariable(SHADER_TYPE_PIXEL, "g_Buffer_Dyn")->Set(pFormattedBuffSRVs[2]);
+ LOG_INFO_MESSAGE("No worries about 3 errors below: attempting to access variables from inactive shader stage");
+ auto pNonExistingVar = pSRB->GetVariable(SHADER_TYPE_GEOMETRY, "g_NonExistingVar");
+ VERIFY_EXPR(pNonExistingVar == nullptr);
+ pNonExistingVar = pSRB->GetVariable(SHADER_TYPE_GEOMETRY, 4);
+ VERIFY_EXPR(pNonExistingVar == nullptr);
+ VERIFY_EXPR(pSRB->GetVariableCount(SHADER_TYPE_GEOMETRY) == 0);
+
m_pDeviceContext->SetRenderTargets(1, &pRTV, pDSV);
float Zero[4] = {};
m_pDeviceContext->ClearRenderTarget(pRTV, Zero);
diff --git a/Tests/TestApp/src/VarSizeAllocationsManagerTest.cpp b/Tests/TestApp/src/VarSizeAllocationsManagerTest.cpp
index 97ee76b..791efe3 100644
--- a/Tests/TestApp/src/VarSizeAllocationsManagerTest.cpp
+++ b/Tests/TestApp/src/VarSizeAllocationsManagerTest.cpp
@@ -44,77 +44,78 @@ VariableSizeAllocationsManagerTest::VariableSizeAllocationsManagerTest() :
UnitTestBase("Variable size allocation manager test")
{
auto &Allocator = DefaultRawMemoryAllocator::GetAllocator();
+
{
VariableSizeAllocationsManager ListMgr(128, Allocator);
VERIFY_EXPR(ListMgr.DbgGetNumFreeBlocks() == 1);
- auto o1 = ListMgr.Allocate(16);
- VERIFY_EXPR(o1 == 0);
+ auto a1 = ListMgr.Allocate(17, 4);
+ VERIFY_EXPR(a1.UnalignedOffset == 0 && a1.Size == 20);
VERIFY_EXPR(ListMgr.DbgGetNumFreeBlocks() == 1);
- auto o2 = ListMgr.Allocate(32);
- VERIFY_EXPR(o2 == 16);
+ auto a2 = ListMgr.Allocate(17, 8);
+ VERIFY_EXPR(a2.UnalignedOffset == 20 && a2.Size == 28);
- auto o3 = ListMgr.Allocate(8);
- VERIFY_EXPR(o3 == 48);
+ auto a3 = ListMgr.Allocate(8, 1);
+ VERIFY_EXPR(a3.UnalignedOffset == 48 && a3.Size == 8);
- auto o4 = ListMgr.Allocate(16);
- VERIFY_EXPR(o4 == 56);
+ auto a4 = ListMgr.Allocate(11, 8);
+ VERIFY_EXPR(a4.UnalignedOffset == 56 && a4.Size == 16);
- auto o5 = ListMgr.Allocate(64);
- VERIFY_EXPR(o5 == VariableSizeAllocationsManager::InvalidOffset);
+ auto a5 = ListMgr.Allocate(64, 1);
+ VERIFY_EXPR(a5.UnalignedOffset == VariableSizeAllocationsManager::InvalidOffset && a5.Size == 0);
- o5 = ListMgr.Allocate(16);
- VERIFY_EXPR(o5 == 72);
+ a5 = ListMgr.Allocate(16, 1);
+ VERIFY_EXPR(a5.UnalignedOffset == 72 && a5.Size == 16);
- auto o6 = ListMgr.Allocate(8);
- VERIFY_EXPR(o6 == 88);
+ auto a6 = ListMgr.Allocate(8, 1);
+ VERIFY_EXPR(a6.UnalignedOffset == 88 && a6.Size == 8);
- auto o7 = ListMgr.Allocate(16);
- VERIFY_EXPR(o7 == 96);
+ auto a7 = ListMgr.Allocate(16, 1);
+ VERIFY_EXPR(a7.UnalignedOffset == 96 && a7.Size == 16);
- auto o8 = ListMgr.Allocate(8);
- VERIFY_EXPR(o8 == 112);
+ auto a8 = ListMgr.Allocate(8, 1);
+ VERIFY_EXPR(a8.UnalignedOffset == 112 && a8.Size == 8);
VERIFY_EXPR(ListMgr.DbgGetNumFreeBlocks() == 1);
- auto o9 = ListMgr.Allocate(8);
- VERIFY_EXPR(o9 == 120);
+ auto a9 = ListMgr.Allocate(8, 1);
+ VERIFY_EXPR(a9.UnalignedOffset == 120 && a9.Size == 8);
VERIFY_EXPR(ListMgr.DbgGetNumFreeBlocks() == 0);
VERIFY_EXPR(ListMgr.IsFull());
- ListMgr.Free(o6, 8);
+ ListMgr.Free(std::move(a6));
VERIFY_EXPR(ListMgr.DbgGetNumFreeBlocks() == 1);
- ListMgr.Free(o8, 8);
+ ListMgr.Free(a8.UnalignedOffset, a8.Size);
VERIFY_EXPR(ListMgr.DbgGetNumFreeBlocks() == 2);
- ListMgr.Free(o9, 8);
+ ListMgr.Free(std::move(a9));
VERIFY_EXPR(ListMgr.DbgGetNumFreeBlocks() == 2);
- auto o10 = ListMgr.Allocate(16);
- VERIFY_EXPR(o10 == o8);
+ auto a10 = ListMgr.Allocate(16, 1);
+ VERIFY_EXPR(a10.UnalignedOffset == 112 && a10.Size == 16);
VERIFY_EXPR(ListMgr.DbgGetNumFreeBlocks() == 1);
- ListMgr.Free(o10, 16);
+ ListMgr.Free(a10.UnalignedOffset, a10.Size);
VERIFY_EXPR(ListMgr.DbgGetNumFreeBlocks() == 2);
- ListMgr.Free(o7, 16);
+ ListMgr.Free(std::move(a7));
VERIFY_EXPR(ListMgr.DbgGetNumFreeBlocks() == 1);
- ListMgr.Free(o4, 16);
+ ListMgr.Free(std::move(a4));
VERIFY_EXPR(ListMgr.DbgGetNumFreeBlocks() == 2);
- ListMgr.Free(o2, 32);
+ ListMgr.Free(a2.UnalignedOffset, a2.Size);
VERIFY_EXPR(ListMgr.DbgGetNumFreeBlocks() == 3);
- ListMgr.Free(o1, 16);
+ ListMgr.Free(std::move(a1));
VERIFY_EXPR(ListMgr.DbgGetNumFreeBlocks() == 3);
- ListMgr.Free(o3, 8);
+ ListMgr.Free(std::move(a3));
VERIFY_EXPR(ListMgr.DbgGetNumFreeBlocks() == 2);
- ListMgr.Free(o5, 16);
+ ListMgr.Free(std::move(a5));
VERIFY_EXPR(ListMgr.DbgGetNumFreeBlocks() == 1);
VERIFY_EXPR(ListMgr.IsEmpty());
@@ -130,15 +131,15 @@ VariableSizeAllocationsManagerTest::VariableSizeAllocationsManagerTest() :
{
++NumPerms;
VariableSizeAllocationsManager ListMgr(NumAllocs*4, Allocator);
- VariableSizeAllocationsManager::OffsetType allocs[NumAllocs];
+ VariableSizeAllocationsManager::Allocation allocs[NumAllocs];
for(size_t a=0; a < NumAllocs; ++a)
{
- allocs[a] = ListMgr.Allocate(4);
- VERIFY_EXPR(allocs[a] == a*4);
+ allocs[a] = ListMgr.Allocate(4, 1);
+ VERIFY_EXPR(allocs[a].UnalignedOffset == a*4 && allocs[a].Size == 4);
}
for(size_t a=0; a < NumAllocs; ++a)
{
- ListMgr.Free(allocs[ReleaseOrder[a]], 4);
+ ListMgr.Free(std::move(allocs[ReleaseOrder[a]]));
}
} while(std::next_permutation(std::begin(ReleaseOrder), std::end(ReleaseOrder)));
VERIFY_EXPR(NumPerms == 720);
@@ -146,37 +147,37 @@ VariableSizeAllocationsManagerTest::VariableSizeAllocationsManagerTest() :
{
VariableSizeGPUAllocationsManager ListMgr(128, Allocator);
- VariableSizeGPUAllocationsManager::OffsetType off[16];
- for(size_t o=0; o < _countof(off); ++o)
- off[o] = ListMgr.Allocate(8);
+ VariableSizeGPUAllocationsManager::Allocation al[16];
+ for(size_t o=0; o < _countof(al); ++o)
+ al[o] = ListMgr.Allocate(8, 4);
VERIFY_EXPR(ListMgr.IsFull());
- ListMgr.Free(off[1], 8, 0);
- ListMgr.Free(off[5], 8, 0);
- ListMgr.Free(off[4], 8, 0);
- ListMgr.Free(off[3], 8, 0);
+ ListMgr.Free(std::move(al[1]), 0);
+ ListMgr.Free(std::move(al[5]), 0);
+ ListMgr.Free(std::move(al[4]), 0);
+ ListMgr.Free(std::move(al[3]), 0);
- ListMgr.Free(off[10], 8, 1);
- ListMgr.Free(off[13], 8, 1);
- ListMgr.Free(off[2], 8, 1);
- ListMgr.Free(off[8], 8, 1);
+ ListMgr.Free(al[10].UnalignedOffset, al[10].Size, 1);
+ ListMgr.Free(al[13].UnalignedOffset, al[13].Size, 1);
+ ListMgr.Free(al[2].UnalignedOffset, al[2].Size, 1);
+ ListMgr.Free(al[8].UnalignedOffset, al[8].Size, 1);
ListMgr.ReleaseStaleAllocations(1);
- ListMgr.Free(off[14], 8, 2);
- ListMgr.Free(off[7], 8, 2);
- ListMgr.Free(off[0], 8, 2);
- ListMgr.Free(off[9], 8, 2);
+ ListMgr.Free(std::move(al[14]), 2);
+ ListMgr.Free(std::move(al[7]), 2);
+ ListMgr.Free(std::move(al[0]), 2);
+ ListMgr.Free(std::move(al[9]), 2);
ListMgr.ReleaseStaleAllocations(2);
- ListMgr.Free(off[12], 8, 1);
- ListMgr.Free(off[15], 8, 1);
- ListMgr.Free(off[6], 8, 1);
- ListMgr.Free(off[11], 8, 1);
+ ListMgr.Free(std::move(al[12]), 1);
+ ListMgr.Free(std::move(al[15]), 1);
+ ListMgr.Free(std::move(al[6]), 1);
+ ListMgr.Free(std::move(al[11]), 1);
ListMgr.ReleaseStaleAllocations(3);
}
-
+
SetStatus(TestResult::Succeeded);
}