From ec3e81b7a7be77836ac52dc6168aa5ac4c498217 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sat, 17 Feb 2018 12:58:17 -0800 Subject: Added test result reporting --- Tests/TestApp/src/AllocatorTest.cpp | 4 +- Tests/TestApp/src/MTResourceCreationTest.cpp | 8 ++- Tests/TestApp/src/MathLibTest.cpp | 9 ++- Tests/TestApp/src/RenderScriptTest.cpp | 4 +- Tests/TestApp/src/RingBufferTest.cpp | 8 ++- Tests/TestApp/src/ShaderConverterTest.cpp | 6 +- Tests/TestApp/src/SmartPointerTest.cpp | 5 +- Tests/TestApp/src/TestApp.cpp | 11 +-- Tests/TestApp/src/TestBlendState.cpp | 3 +- Tests/TestApp/src/TestBufferAccess.cpp | 84 ++++++++++++---------- Tests/TestApp/src/TestBufferCreation.cpp | 15 +++- Tests/TestApp/src/TestComputeShaders.cpp | 12 +++- Tests/TestApp/src/TestCopyTexData.cpp | 6 ++ .../src/TestCreateObjFromNativeResD3D11.cpp | 11 ++- .../src/TestCreateObjFromNativeResD3D12.cpp | 8 ++- Tests/TestApp/src/TestCreateObjFromNativeResGL.cpp | 6 +- Tests/TestApp/src/TestDepthStencilState.cpp | 4 +- Tests/TestApp/src/TestDrawCommands.cpp | 2 + Tests/TestApp/src/TestGeometryShader.cpp | 4 +- Tests/TestApp/src/TestPipelineStateBase.cpp | 3 +- Tests/TestApp/src/TestRasterizerState.cpp | 4 +- Tests/TestApp/src/TestRenderTarget.cpp | 4 +- Tests/TestApp/src/TestSamplerCreation.cpp | 5 +- Tests/TestApp/src/TestShaderResArrays.cpp | 5 +- Tests/TestApp/src/TestTessellation.cpp | 4 +- Tests/TestApp/src/TestTextureCreation.cpp | 7 +- Tests/TestApp/src/TestTexturing.cpp | 10 ++- Tests/TestApp/src/TestVPAndSR.cpp | 5 +- Tests/TestApp/src/UnitTestBase.cpp | 58 +++++++++++++++ .../TestApp/src/VarSizeAllocationsManagerTest.cpp | 8 ++- 30 files changed, 239 insertions(+), 84 deletions(-) create mode 100644 Tests/TestApp/src/UnitTestBase.cpp (limited to 'Tests/TestApp/src') diff --git a/Tests/TestApp/src/AllocatorTest.cpp b/Tests/TestApp/src/AllocatorTest.cpp index 098317c..89ef347 100644 --- a/Tests/TestApp/src/AllocatorTest.cpp +++ b/Tests/TestApp/src/AllocatorTest.cpp @@ -34,7 +34,8 @@ using namespace Diligent; AllocatorTest TheTest; -AllocatorTest::AllocatorTest() +AllocatorTest::AllocatorTest() : + UnitTestBase("Allocator test") { const Uint32 AllocSize = 32; const Uint32 NumAllocationsPerPage = 16; @@ -78,4 +79,5 @@ AllocatorTest::AllocatorTest() // Double free //TestAllocator.Free( Allocations[0][0] ); + SetStatus(TestResult::Succeeded); } diff --git a/Tests/TestApp/src/MTResourceCreationTest.cpp b/Tests/TestApp/src/MTResourceCreationTest.cpp index f202ba4..22813cb 100644 --- a/Tests/TestApp/src/MTResourceCreationTest.cpp +++ b/Tests/TestApp/src/MTResourceCreationTest.cpp @@ -42,7 +42,8 @@ static const char g_ShaderSource[] = "} \n" ; -MTResourceCreationTest::MTResourceCreationTest(IRenderDevice *pDevice, IDeviceContext *pContext, Uint32 NumThreads) : +MTResourceCreationTest::MTResourceCreationTest(IRenderDevice *pDevice, IDeviceContext *pContext, Uint32 NumThreads) : + UnitTestBase("Multithreaded resource creation"), m_pDevice(pDevice), m_pContext(pContext) { @@ -243,5 +244,8 @@ void MTResourceCreationTest::StopThreads() m_bStopThreadsFlag = true; for(auto &t : m_Threads) t.join(); - LOG_INFO_MESSAGE("MTResourceCreationTest: Buffers created: ", m_NumBuffersCreated, " Textures created: ", m_NumTexturesCreated, " PSO Created: ", m_NumPSOCreated); + + std::stringstream infoss; + infoss << "Buffers created: " << m_NumBuffersCreated << " Textures created: " << m_NumTexturesCreated << " PSO Created: " << m_NumPSOCreated; + SetStatus(m_Threads.empty() ? TestResult::Skipped : TestResult::Succeeded, infoss.str().c_str()); } diff --git a/Tests/TestApp/src/MathLibTest.cpp b/Tests/TestApp/src/MathLibTest.cpp index 78b1560..1aac73e 100644 --- a/Tests/TestApp/src/MathLibTest.cpp +++ b/Tests/TestApp/src/MathLibTest.cpp @@ -27,13 +27,15 @@ #include "pch.h" #include "BasicMath.h" #include "DebugUtilities.h" +#include "UnitTestBase.h" using namespace Diligent; -class MathLibTest +class MathLibTest : public UnitTestBase { public: - MathLibTest() + MathLibTest() : + UnitTestBase("Mathlib test") { // Ctor { @@ -497,7 +499,8 @@ public: 9, 10, 11); std::hash()(m2); } + SetStatus(TestResult::Succeeded); } }; -static MathLibTest MathLibTest; \ No newline at end of file +static MathLibTest MathLibTest; diff --git a/Tests/TestApp/src/RenderScriptTest.cpp b/Tests/TestApp/src/RenderScriptTest.cpp index abe65e7..0b8242a 100644 --- a/Tests/TestApp/src/RenderScriptTest.cpp +++ b/Tests/TestApp/src/RenderScriptTest.cpp @@ -33,7 +33,8 @@ using namespace Diligent; -RenderScriptTest::RenderScriptTest( IRenderDevice *pRenderDevice, IDeviceContext *pContext ) +RenderScriptTest::RenderScriptTest( IRenderDevice *pRenderDevice, IDeviceContext *pContext ) : + UnitTestBase("RenderScript test") { RefCntAutoPtr pTestGlobalTexture; { @@ -421,4 +422,5 @@ RenderScriptTest::RenderScriptTest( IRenderDevice *pRenderDevice, IDeviceContext pScript->SetGlobalVariable( "svTestBlock", pShaderVar ); pScript->Run( "TestShaderVariable", pShaderVar ); } + SetStatus(TestResult::Succeeded); } diff --git a/Tests/TestApp/src/RingBufferTest.cpp b/Tests/TestApp/src/RingBufferTest.cpp index 9ab5dad..c139c93 100644 --- a/Tests/TestApp/src/RingBufferTest.cpp +++ b/Tests/TestApp/src/RingBufferTest.cpp @@ -28,10 +28,11 @@ #include "RingBuffer.h" #include "DefaultRawMemoryAllocator.h" #include "DebugUtilities.h" +#include "UnitTestBase.h" using namespace Diligent; -class RingBufferTest +class RingBufferTest : public UnitTestBase { public: RingBufferTest(); @@ -39,7 +40,8 @@ public: static RingBufferTest TheRingBufferTest; -RingBufferTest::RingBufferTest() +RingBufferTest::RingBufferTest() : + UnitTestBase("Ring buffer test") { auto &Allocator = DefaultRawMemoryAllocator::GetAllocator(); { @@ -129,4 +131,6 @@ RingBufferTest::RingBufferTest() RB.FinishCurrentFrame(5); RB.ReleaseCompletedFrames(6); } + + SetStatus(TestResult::Succeeded); } diff --git a/Tests/TestApp/src/ShaderConverterTest.cpp b/Tests/TestApp/src/ShaderConverterTest.cpp index a18229b..51dcfa3 100644 --- a/Tests/TestApp/src/ShaderConverterTest.cpp +++ b/Tests/TestApp/src/ShaderConverterTest.cpp @@ -35,7 +35,8 @@ using namespace Diligent; -ShaderConverterTest::ShaderConverterTest( IRenderDevice *pRenderDevice, IDeviceContext *pContext ) +ShaderConverterTest::ShaderConverterTest( IRenderDevice *pRenderDevice, IDeviceContext *pContext ) : + UnitTestBase("Shader Converter Test") { ShaderCreationAttribs CreationAttrs; CreationAttrs.FilePath = "Shaders\\ConverterTest.fx"; @@ -62,6 +63,7 @@ ShaderConverterTest::ShaderConverterTest( IRenderDevice *pRenderDevice, IDeviceC VERIFY_EXPR( pShader ); } + std::string status; if(pRenderDevice->GetDeviceCaps().bComputeShadersSupported) { CreationAttrs.FilePath = "Shaders\\CSConversionTest.fx"; @@ -70,5 +72,7 @@ ShaderConverterTest::ShaderConverterTest( IRenderDevice *pRenderDevice, IDeviceC RefCntAutoPtr pShader; //pRenderDevice->CreateShader( CreationAttrs, &pShader ); //VERIFY_EXPR( pShader ); + status = "Skipped compute shader conversion test"; } + SetStatus(TestResult::Succeeded, status.c_str()); } diff --git a/Tests/TestApp/src/SmartPointerTest.cpp b/Tests/TestApp/src/SmartPointerTest.cpp index 59cbae8..9ae9fc7 100644 --- a/Tests/TestApp/src/SmartPointerTest.cpp +++ b/Tests/TestApp/src/SmartPointerTest.cpp @@ -245,7 +245,9 @@ SmartPointerTest::~SmartPointerTest() t.join(); auto NumIterations = NumThreadInterations; - LOG_INFO_MESSAGE("SmartPointerTest: performed ", m_NumTestsPerformed, " concurrency tests with ", NumIterations, " iterations each"); + std::stringstream infoss; + infoss << "Performed " << m_NumTestsPerformed << " concurrency tests with " << NumIterations << " iterations each"; + SetStatus(TestResult::Succeeded, infoss.str().c_str()); } void SmartPointerTest::RunConcurrencyTest() @@ -281,6 +283,7 @@ void SmartPointerTest::RunConcurrencyTest() SmartPointerTest::SmartPointerTest() : + UnitTestBase("Smart pointer test"), m_pSharedObject(nullptr), m_NumThreadsCompleted(0) { diff --git a/Tests/TestApp/src/TestApp.cpp b/Tests/TestApp/src/TestApp.cpp index c57cf97..49609c2 100644 --- a/Tests/TestApp/src/TestApp.cpp +++ b/Tests/TestApp/src/TestApp.cpp @@ -224,12 +224,8 @@ void TestApp::InitializeRenderers() TestVPAndSR TestVPAndSR(m_pDevice, m_pImmediateContext); - - if(m_pDevice->GetDeviceCaps().bComputeShadersSupported) - { - m_pTestCS.reset(new TestComputeShaders); - m_pTestCS->Init(m_pDevice, m_pImmediateContext); - } + m_pTestCS.reset(new TestComputeShaders); + m_pTestCS->Init(m_pDevice, m_pImmediateContext); m_pTestRT.reset(new TestRenderTarget); m_pTestRT->Init(m_pDevice, m_pImmediateContext, -0.4f, 0.55f, 0.4f, 0.4f); @@ -480,8 +476,7 @@ void TestApp::Render() { m_pTestTexturing[i]->Draw(); } - if(m_pTestCS) - m_pTestCS->Draw(); + m_pTestCS->Draw(); m_pTestRT->Draw(); m_pTestShaderResArrays->Draw(); m_TestGS.Draw(); diff --git a/Tests/TestApp/src/TestBlendState.cpp b/Tests/TestApp/src/TestBlendState.cpp index a01a2fa..e54e4ad 100644 --- a/Tests/TestApp/src/TestBlendState.cpp +++ b/Tests/TestApp/src/TestBlendState.cpp @@ -48,7 +48,7 @@ void TestBlendState::CreateTestBS( BlendStateDesc &BSDesc ) } TestBlendState::TestBlendState( IRenderDevice *pDevice, IDeviceContext *pContext ) : - TestPipelineStateBase(pDevice), + TestPipelineStateBase(pDevice, "Blend state initialization test"), m_pDeviceContext(pContext) { m_PSODesc.Name = "PSO-TestBlendStates"; @@ -247,4 +247,5 @@ TestBlendState::TestBlendState( IRenderDevice *pDevice, IDeviceContext *pContext m_pDevice->CreatePipelineState(m_PSODesc, &pPSO ); pScript->Run( m_pDeviceContext, "TestPSOArg", pPSO ); } + SetStatus(TestResult::Succeeded); } diff --git a/Tests/TestApp/src/TestBufferAccess.cpp b/Tests/TestApp/src/TestBufferAccess.cpp index 376be0e..e74d592 100644 --- a/Tests/TestApp/src/TestBufferAccess.cpp +++ b/Tests/TestApp/src/TestBufferAccess.cpp @@ -33,6 +33,7 @@ using namespace Diligent; TestBufferAccess::TestBufferAccess() : + UnitTestBase("Buffer access test"), m_fXExtent(0), m_fYExtent(0) {} @@ -215,52 +216,57 @@ void TestBufferAccess::Draw(float fTime) m_pDeviceContext->Draw(DrawAttrs); -return; - MapHelper pStagingData; - // Test reading data from staging resource + bool TestStagingBuffers = false; + if(TestStagingBuffers) { - m_pInstBuff[4]->CopyData( m_pDeviceContext, m_pInstBuff[3], 0, 0, sizeof( instance_offsets ) ); - pStagingData.Map( m_pDeviceContext, m_pInstBuff[4], MAP_READ, 0 ); - for(int i = 0; i < _countof(instance_offsets); ++i) - assert(pStagingData[i] == instance_offsets[i]); - pStagingData.Unmap(); - } - - // D3D12 does not allow writing to the CPU-readable buffers - if(m_pRenderDevice->GetDeviceCaps().DevType != DeviceType::D3D12) - { - // Test writing data to staging resource + MapHelper pStagingData; + // Test reading data from staging resource { - pStagingData.Map( m_pDeviceContext, m_pInstBuff[5], MAP_WRITE, 0 ); - for(int Inst = 0; Inst < NumInstances; ++Inst) - { - pStagingData[Inst*2] = (1+Inst) * fDX; - pStagingData[Inst*2+1] = 4.f * fDY + sin(fTime*1.3f) * fDY * 0.3f; - } + m_pInstBuff[4]->CopyData( m_pDeviceContext, m_pInstBuff[3], 0, 0, sizeof( instance_offsets ) ); + pStagingData.Map( m_pDeviceContext, m_pInstBuff[4], MAP_READ, 0 ); + for(int i = 0; i < _countof(instance_offsets); ++i) + assert(pStagingData[i] == instance_offsets[i]); pStagingData.Unmap(); } - m_pInstBuff[2]->CopyData( m_pDeviceContext, m_pInstBuff[5], 0, 0, sizeof( instance_offsets ) ); - pBuffs[1] = m_pInstBuff[2]; - m_pDeviceContext->SetVertexBuffers( 0, _countof( pBuffs ), pBuffs, Strides, Offsets, SET_VERTEX_BUFFERS_FLAG_RESET ); - m_pDeviceContext->Draw(DrawAttrs); - - - // Test reading & writing data to the staging resource - /*{ - MapHelper pInstData2( m_pDeviceContext, m_pInstBuff[6], MAP_READ_WRITE, 0 ); - MapHelper pInstData3( std::move(pInstData2) ); - MapHelper pInstData; - pInstData = std::move(pInstData3); - static float fPrevTime = fTime; - for(int Inst = 0; Inst < NumInstances; ++Inst) + // D3D12 does not allow writing to the CPU-readable buffers + if(m_pRenderDevice->GetDeviceCaps().DevType != DeviceType::D3D12) + { + // Test writing data to staging resource { - pInstData[Inst*2] += (fTime-fPrevTime) * sin(fTime)*0.1f * m_fXExtent; + pStagingData.Map( m_pDeviceContext, m_pInstBuff[5], MAP_WRITE, 0 ); + for(int Inst = 0; Inst < NumInstances; ++Inst) + { + pStagingData[Inst*2] = (1+Inst) * fDX; + pStagingData[Inst*2+1] = 4.f * fDY + sin(fTime*1.3f) * fDY * 0.3f; + } + pStagingData.Unmap(); } - fPrevTime = fTime; - }*/ - m_pInstBuff[2]->CopyData( m_pDeviceContext, m_pInstBuff[6], 0, 0, sizeof( instance_offsets ) ); - m_pDeviceContext->Draw(DrawAttrs); + m_pInstBuff[2]->CopyData( m_pDeviceContext, m_pInstBuff[5], 0, 0, sizeof( instance_offsets ) ); + pBuffs[1] = m_pInstBuff[2]; + m_pDeviceContext->SetVertexBuffers( 0, _countof( pBuffs ), pBuffs, Strides, Offsets, SET_VERTEX_BUFFERS_FLAG_RESET ); + m_pDeviceContext->Draw(DrawAttrs); + + + // Test reading & writing data to the staging resource + /*{ + MapHelper pInstData2( m_pDeviceContext, m_pInstBuff[6], MAP_READ_WRITE, 0 ); + MapHelper pInstData3( std::move(pInstData2) ); + MapHelper pInstData; + pInstData = std::move(pInstData3); + static float fPrevTime = fTime; + for(int Inst = 0; Inst < NumInstances; ++Inst) + { + pInstData[Inst*2] += (fTime-fPrevTime) * sin(fTime)*0.1f * m_fXExtent; + } + fPrevTime = fTime; + }*/ + + m_pInstBuff[2]->CopyData( m_pDeviceContext, m_pInstBuff[6], 0, 0, sizeof( instance_offsets ) ); + m_pDeviceContext->Draw(DrawAttrs); + } } + + SetStatus(TestResult::Succeeded); } diff --git a/Tests/TestApp/src/TestBufferCreation.cpp b/Tests/TestApp/src/TestBufferCreation.cpp index 9e44d96..872f4bd 100644 --- a/Tests/TestApp/src/TestBufferCreation.cpp +++ b/Tests/TestApp/src/TestBufferCreation.cpp @@ -38,7 +38,8 @@ using namespace Diligent; -TestBufferCreation::TestBufferCreation(Diligent::IRenderDevice *pDevice, Diligent::IDeviceContext *pContext) +TestBufferCreation::TestBufferCreation(Diligent::IRenderDevice *pDevice, Diligent::IDeviceContext *pContext) : + UnitTestBase("Buffer creation test") { std::unique_ptr pTestCreateObjFromNativeRes; const auto DevCaps = pDevice->GetDeviceCaps(); @@ -67,7 +68,7 @@ TestBufferCreation::TestBufferCreation(Diligent::IRenderDevice *pDevice, Diligen default: UNEXPECTED("Unexpected device type"); } - + int BuffersCreated = 0; { Diligent::BufferDesc BuffDesc; BuffDesc.Name = "Buffer creation test 0"; @@ -78,6 +79,7 @@ TestBufferCreation::TestBufferCreation(Diligent::IRenderDevice *pDevice, Diligen VERIFY_EXPR(pBuffer); pTestCreateObjFromNativeRes->CreateBuffer(pBuffer); + ++BuffersCreated; } { @@ -90,6 +92,7 @@ TestBufferCreation::TestBufferCreation(Diligent::IRenderDevice *pDevice, Diligen VERIFY_EXPR(pBuffer); pTestCreateObjFromNativeRes->CreateBuffer(pBuffer); + ++BuffersCreated; } if(DevCaps.bComputeShadersSupported && DevCaps.bIndirectRenderingSupported) @@ -107,6 +110,7 @@ TestBufferCreation::TestBufferCreation(Diligent::IRenderDevice *pDevice, Diligen VERIFY_EXPR(pBuffer); pTestCreateObjFromNativeRes->CreateBuffer(pBuffer); + ++BuffersCreated; } if(DevCaps.bComputeShadersSupported) @@ -122,6 +126,7 @@ TestBufferCreation::TestBufferCreation(Diligent::IRenderDevice *pDevice, Diligen VERIFY_EXPR(pBuffer); pTestCreateObjFromNativeRes->CreateBuffer(pBuffer); + ++BuffersCreated; } { @@ -134,6 +139,10 @@ TestBufferCreation::TestBufferCreation(Diligent::IRenderDevice *pDevice, Diligen VERIFY_EXPR(pBuffer); pTestCreateObjFromNativeRes->CreateBuffer(pBuffer); + ++BuffersCreated; } - + + std::stringstream infoss; + infoss << "Created " << BuffersCreated << " test buffers."; + SetStatus(TestResult::Succeeded, infoss.str().c_str()); } diff --git a/Tests/TestApp/src/TestComputeShaders.cpp b/Tests/TestApp/src/TestComputeShaders.cpp index 43c6dd0..2461a51 100644 --- a/Tests/TestApp/src/TestComputeShaders.cpp +++ b/Tests/TestApp/src/TestComputeShaders.cpp @@ -31,12 +31,19 @@ using namespace Diligent; -TestComputeShaders::TestComputeShaders() +TestComputeShaders::TestComputeShaders() : + UnitTestBase("Compute shader test") { } void TestComputeShaders::Init( IRenderDevice *pDevice, IDeviceContext *pContext ) { + if(!pDevice->GetDeviceCaps().bComputeShadersSupported) + { + SetStatus(TestResult::Skipped, "Compute shaders are not supported"); + return; + } + m_pRenderDevice = pDevice; m_pDeviceContext = pContext; m_pRenderScript = CreateRenderScriptFromFile( "TestComputeShaders.lua", pDevice, pContext, []( ScriptParser *pScriptParser ) @@ -46,5 +53,8 @@ void TestComputeShaders::Init( IRenderDevice *pDevice, IDeviceContext *pContext void TestComputeShaders::Draw() { + if(!m_pDeviceContext) + return; + m_pRenderScript->Run( m_pDeviceContext, "Render" ); } diff --git a/Tests/TestApp/src/TestCopyTexData.cpp b/Tests/TestApp/src/TestCopyTexData.cpp index cbd6a24..5bb65e1 100644 --- a/Tests/TestApp/src/TestCopyTexData.cpp +++ b/Tests/TestApp/src/TestCopyTexData.cpp @@ -30,6 +30,7 @@ using namespace Diligent; TestCopyTexData::TestCopyTexData( IRenderDevice *pDevice, IDeviceContext *pContext ) : + UnitTestBase("Texture data copy test"), m_pDevice(pDevice), m_pContext(pContext) { @@ -68,12 +69,17 @@ TestCopyTexData::TestCopyTexData( IRenderDevice *pDevice, IDeviceContext *pConte TEX_FORMAT_R8_UINT, TEX_FORMAT_R8_SINT }; + int NumFormatsTested = 0; for( auto f = 0; f < _countof( TestFormats ); ++f ) { Test2DTexture(TestFormats[f]); Test2DTexArray(TestFormats[f]); Test3DTexture(TestFormats[f]); + ++NumFormatsTested; } + std::stringstream infoss; + infoss << "Formats tested: " << NumFormatsTested; + SetStatus(TestResult::Succeeded, infoss.str().c_str()); } void TestCopyTexData::Test2DTexture( TEXTURE_FORMAT Format ) diff --git a/Tests/TestApp/src/TestCreateObjFromNativeResD3D11.cpp b/Tests/TestApp/src/TestCreateObjFromNativeResD3D11.cpp index 41794c2..be8cfab 100644 --- a/Tests/TestApp/src/TestCreateObjFromNativeResD3D11.cpp +++ b/Tests/TestApp/src/TestCreateObjFromNativeResD3D11.cpp @@ -41,15 +41,18 @@ void TestCreateObjFromNativeResD3D11::CreateTexture(Diligent::ITexture *pTexture if (SrcTexDesc.Type == RESOURCE_DIM_TEX_1D || SrcTexDesc.Type == RESOURCE_DIM_TEX_1D_ARRAY) { pDeviceD3D11->CreateTextureFromD3DResource(static_cast(pd3d11Texture), &pTextureFromNativeD3D11Handle); + ++m_NumTexturesCreated; } else if (SrcTexDesc.Type == RESOURCE_DIM_TEX_2D || SrcTexDesc.Type == RESOURCE_DIM_TEX_2D_ARRAY || SrcTexDesc.Type == RESOURCE_DIM_TEX_CUBE || SrcTexDesc.Type == RESOURCE_DIM_TEX_CUBE_ARRAY) { pDeviceD3D11->CreateTextureFromD3DResource(static_cast(pd3d11Texture), &pTextureFromNativeD3D11Handle); + ++m_NumTexturesCreated; } else if (RESOURCE_DIM_TEX_3D) { pDeviceD3D11->CreateTextureFromD3DResource(static_cast(pd3d11Texture), &pTextureFromNativeD3D11Handle); + ++m_NumTexturesCreated; } else { @@ -78,7 +81,8 @@ void TestCreateObjFromNativeResD3D11::CreateBuffer(Diligent::IBuffer *pBuffer) { RefCntAutoPtr pBufferFromNativeD3D11Handle; pDeviceD3D11->CreateBufferFromD3DResource(pd3d11Buffer, SrcBuffDesc, &pBufferFromNativeD3D11Handle); - + ++m_NumBuffersCreated; + const auto &TestBufferDesc = pBufferFromNativeD3D11Handle->GetDesc(); VERIFY_EXPR(TestBufferDesc == SrcBuffDesc); @@ -93,7 +97,8 @@ void TestCreateObjFromNativeResD3D11::CreateBuffer(Diligent::IBuffer *pBuffer) BuffDesc.Format = SrcBuffDesc.Format; RefCntAutoPtr pBufferFromNativeD3D11Handle; pDeviceD3D11->CreateBufferFromD3DResource(pd3d11Buffer, BuffDesc, &pBufferFromNativeD3D11Handle); - + ++m_NumBuffersCreated; + const auto &TestBufferDesc = pBufferFromNativeD3D11Handle->GetDesc(); VERIFY_EXPR(TestBufferDesc == SrcBuffDesc); @@ -101,4 +106,4 @@ void TestCreateObjFromNativeResD3D11::CreateBuffer(Diligent::IBuffer *pBuffer) VERIFY_EXPR(pTestBufferD3D11->GetD3D11Buffer() == pd3d11Buffer); VERIFY_EXPR(pTestBufferD3D11->GetNativeHandle() == pd3d11Buffer); } -} \ No newline at end of file +} diff --git a/Tests/TestApp/src/TestCreateObjFromNativeResD3D12.cpp b/Tests/TestApp/src/TestCreateObjFromNativeResD3D12.cpp index 2a433a7..b402f7f 100644 --- a/Tests/TestApp/src/TestCreateObjFromNativeResD3D12.cpp +++ b/Tests/TestApp/src/TestCreateObjFromNativeResD3D12.cpp @@ -38,7 +38,8 @@ void TestCreateObjFromNativeResD3D12::CreateTexture(Diligent::ITexture *pTexture auto *pD3D12Texture = pTextureD3D12->GetD3D12Texture(); RefCntAutoPtr pTextureFromNativeD3D12Handle; pDeviceD3D12->CreateTextureFromD3DResource(pD3D12Texture, &pTextureFromNativeD3D12Handle); - + ++m_NumTexturesCreated; + auto TestTexDesc = pTextureFromNativeD3D12Handle->GetDesc(); if (SrcTexDesc.Type == RESOURCE_DIM_TEX_CUBE || SrcTexDesc.Type == RESOURCE_DIM_TEX_CUBE_ARRAY) { @@ -64,7 +65,8 @@ void TestCreateObjFromNativeResD3D12::CreateBuffer(Diligent::IBuffer *pBuffer) { RefCntAutoPtr pBufferFromNativeD3D12Handle; pDeviceD3D12->CreateBufferFromD3DResource(pD3D12Buffer, SrcBuffDesc, &pBufferFromNativeD3D12Handle); - + ++m_NumBuffersCreated; + const auto &TestBufferDesc = pBufferFromNativeD3D12Handle->GetDesc(); VERIFY_EXPR(TestBufferDesc == SrcBuffDesc); @@ -74,4 +76,4 @@ void TestCreateObjFromNativeResD3D12::CreateBuffer(Diligent::IBuffer *pBuffer) VERIFY_EXPR(TestBuffDataStartByteOffset == 0); VERIFY_EXPR(pTestBufferD3D12->GetNativeHandle() == pD3D12Buffer); } -} \ No newline at end of file +} diff --git a/Tests/TestApp/src/TestCreateObjFromNativeResGL.cpp b/Tests/TestApp/src/TestCreateObjFromNativeResGL.cpp index 9046a1f..0a61d22 100644 --- a/Tests/TestApp/src/TestCreateObjFromNativeResGL.cpp +++ b/Tests/TestApp/src/TestCreateObjFromNativeResGL.cpp @@ -107,7 +107,8 @@ void TestCreateObjFromNativeResGL::CreateTexture(Diligent::ITexture *pTexture) TmpTexDesc.MipLevels = 0; TmpTexDesc.Format = TEX_FORMAT_UNKNOWN; pDeviceGL->CreateTextureFromGLHandle(GLHandle, TmpTexDesc, &pAttachedTexture); - + ++m_NumTexturesCreated; + const auto &TestTexDesc = pAttachedTexture->GetDesc(); VERIFY_EXPR(TestTexDesc == SrcTexDesc); RefCntAutoPtr pAttachedTextureGL(pAttachedTexture, IID_TextureGL); @@ -127,7 +128,8 @@ void TestCreateObjFromNativeResGL::CreateBuffer(Diligent::IBuffer *pBuffer) RefCntAutoPtr pBufferFromNativeGLHandle; pDeviceGL->CreateBufferFromGLHandle(GLBufferHandle, SrcBuffDesc, &pBufferFromNativeGLHandle); - + ++m_NumBuffersCreated; + const auto &TestBufferDesc = pBufferFromNativeGLHandle->GetDesc(); VERIFY_EXPR(TestBufferDesc == SrcBuffDesc); diff --git a/Tests/TestApp/src/TestDepthStencilState.cpp b/Tests/TestApp/src/TestDepthStencilState.cpp index 8ddb00c..94c6198 100644 --- a/Tests/TestApp/src/TestDepthStencilState.cpp +++ b/Tests/TestApp/src/TestDepthStencilState.cpp @@ -46,7 +46,7 @@ void TestDepthStencilState::CreateTestDSS( DepthStencilStateDesc &DSSDesc ) } TestDepthStencilState::TestDepthStencilState( IRenderDevice *pDevice, IDeviceContext *pContext ) : - TestPipelineStateBase(pDevice), + TestPipelineStateBase(pDevice, "Depth-stencil state initialization test"), m_pDeviceContext(pContext) { DepthStencilStateDesc &DSSDesc = m_PSODesc.GraphicsPipeline.DepthStencilDesc; @@ -158,4 +158,6 @@ TestDepthStencilState::TestDepthStencilState( IRenderDevice *pDevice, IDeviceCon m_pDevice->CreatePipelineState( m_PSODesc, &pPSO ); pScript->Run( m_pDeviceContext, "TestDSSDesc", pPSO ); } + + SetStatus(TestResult::Succeeded); } diff --git a/Tests/TestApp/src/TestDrawCommands.cpp b/Tests/TestApp/src/TestDrawCommands.cpp index d2f8841..f8e341d 100644 --- a/Tests/TestApp/src/TestDrawCommands.cpp +++ b/Tests/TestApp/src/TestDrawCommands.cpp @@ -950,6 +950,8 @@ void TestDrawCommands::Draw() } m_pDeviceContext->SetVertexBuffers( 0, 0, nullptr, 0, 0, SET_VERTEX_BUFFERS_FLAG_RESET ); + + SetStatus(TestResult::Succeeded); } diff --git a/Tests/TestApp/src/TestGeometryShader.cpp b/Tests/TestApp/src/TestGeometryShader.cpp index a4982db..0352a8e 100644 --- a/Tests/TestApp/src/TestGeometryShader.cpp +++ b/Tests/TestApp/src/TestGeometryShader.cpp @@ -35,7 +35,7 @@ void TestGeometryShader::Init( IRenderDevice *pDevice, IDeviceContext *pDeviceCo { if(!pDevice->GetDeviceCaps().bGeometryShadersSupported) { - LOG_WARNING_MESSAGE("Geometry shaders are not supported"); + SetStatus(TestResult::Skipped, "Geometry shaders are not supported"); return; } @@ -92,4 +92,6 @@ void TestGeometryShader::Draw() DrawAttrs.Topology = Diligent::PRIMITIVE_TOPOLOGY_POINT_LIST; DrawAttrs.NumVertices = 2; // Draw 2 triangles m_pDeviceContext->Draw(DrawAttrs); + + SetStatus(TestResult::Succeeded); } diff --git a/Tests/TestApp/src/TestPipelineStateBase.cpp b/Tests/TestApp/src/TestPipelineStateBase.cpp index 6de3d7a..f5479eb 100644 --- a/Tests/TestApp/src/TestPipelineStateBase.cpp +++ b/Tests/TestApp/src/TestPipelineStateBase.cpp @@ -40,7 +40,8 @@ static const char g_ShaderSource[] = "} \n" ; -TestPipelineStateBase::TestPipelineStateBase(Diligent::IRenderDevice *pDevice) : +TestPipelineStateBase::TestPipelineStateBase(Diligent::IRenderDevice *pDevice, const char *Name) : + UnitTestBase(Name), m_pDevice(pDevice) { ShaderCreationAttribs Attrs; diff --git a/Tests/TestApp/src/TestRasterizerState.cpp b/Tests/TestApp/src/TestRasterizerState.cpp index add2713..64a1b41 100644 --- a/Tests/TestApp/src/TestRasterizerState.cpp +++ b/Tests/TestApp/src/TestRasterizerState.cpp @@ -43,7 +43,7 @@ void TestRasterizerState::CreateTestRS() } TestRasterizerState::TestRasterizerState( IRenderDevice *pDevice, IDeviceContext *pContext ) : - TestPipelineStateBase(pDevice), + TestPipelineStateBase(pDevice, "Rasterizer state initialization test"), m_pDeviceContext(pContext) { RasterizerStateDesc &RSDesc = m_PSODesc.GraphicsPipeline.RasterizerDesc; @@ -129,4 +129,6 @@ TestRasterizerState::TestRasterizerState( IRenderDevice *pDevice, IDeviceContext m_pDevice->CreatePipelineState(m_PSODesc, &pPSO ); pScript->Run( m_pDeviceContext, "TestRSDescFunc", pPSO ); } + + SetStatus(TestResult::Succeeded); } diff --git a/Tests/TestApp/src/TestRenderTarget.cpp b/Tests/TestApp/src/TestRenderTarget.cpp index 9f34203..485f818 100644 --- a/Tests/TestApp/src/TestRenderTarget.cpp +++ b/Tests/TestApp/src/TestRenderTarget.cpp @@ -31,7 +31,8 @@ using namespace Diligent; -TestRenderTarget::TestRenderTarget() +TestRenderTarget::TestRenderTarget() : + UnitTestBase("Render target test") { } @@ -51,4 +52,5 @@ void TestRenderTarget::Init( IRenderDevice *pDevice, IDeviceContext *pDeviceCont void TestRenderTarget::Draw() { m_pRenderScript->Run( m_pDeviceContext, "Render" ); + SetStatus(TestResult::Succeeded); } diff --git a/Tests/TestApp/src/TestSamplerCreation.cpp b/Tests/TestApp/src/TestSamplerCreation.cpp index d058e34..e46f7cd 100644 --- a/Tests/TestApp/src/TestSamplerCreation.cpp +++ b/Tests/TestApp/src/TestSamplerCreation.cpp @@ -27,7 +27,8 @@ using namespace Diligent; -TestSamplerCreation::TestSamplerCreation(IRenderDevice *pDevice) : +TestSamplerCreation::TestSamplerCreation(IRenderDevice *pDevice) : + UnitTestBase("Test sampler creation"), m_pDevice(pDevice) { // Test different filters @@ -123,4 +124,6 @@ TestSamplerCreation::TestSamplerCreation(IRenderDevice *pDevice) : m_pDevice->CreateSampler(SamplerDesc, &pSampler2); assert(pSampler1 == pSampler2); } + + SetStatus(TestResult::Succeeded); } diff --git a/Tests/TestApp/src/TestShaderResArrays.cpp b/Tests/TestApp/src/TestShaderResArrays.cpp index 9b2b422..dc65b9a 100644 --- a/Tests/TestApp/src/TestShaderResArrays.cpp +++ b/Tests/TestApp/src/TestShaderResArrays.cpp @@ -32,7 +32,8 @@ using namespace Diligent; -TestShaderResArrays::TestShaderResArrays(IRenderDevice *pDevice, IDeviceContext *pDeviceContext, bool bUseOpenGL, float fMinXCoord, float fMinYCoord, float fXExtent, float fYExtent) +TestShaderResArrays::TestShaderResArrays(IRenderDevice *pDevice, IDeviceContext *pDeviceContext, bool bUseOpenGL, float fMinXCoord, float fMinYCoord, float fXExtent, float fYExtent) : + UnitTestBase("Shader resource array test") { m_pRenderDevice = pDevice; m_pDeviceContext = pDeviceContext; @@ -187,4 +188,6 @@ void TestShaderResArrays::Draw() DrawAttrs.Topology = Diligent::PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; DrawAttrs.NumVertices = 4; // Draw quad m_pDeviceContext->Draw( DrawAttrs ); + + SetStatus(TestResult::Succeeded); } diff --git a/Tests/TestApp/src/TestTessellation.cpp b/Tests/TestApp/src/TestTessellation.cpp index 8acb890..dacb1cf 100644 --- a/Tests/TestApp/src/TestTessellation.cpp +++ b/Tests/TestApp/src/TestTessellation.cpp @@ -35,7 +35,7 @@ void TestTessellation::Init( IRenderDevice *pDevice, IDeviceContext *pDeviceCont { if(!pDevice->GetDeviceCaps().bTessellationSupported) { - LOG_WARNING_MESSAGE("Tessellation is not supported"); + SetStatus(TestResult::Skipped, "Tessellation is not supported"); return; } @@ -134,4 +134,6 @@ void TestTessellation::Draw() m_pDeviceContext->CommitShaderResources(nullptr, COMMIT_SHADER_RESOURCES_FLAG_TRANSITION_RESOURCES); DrawAttrs.NumVertices = 1; // Draw 1 tri patch m_pDeviceContext->Draw(DrawAttrs); + + SetStatus(TestResult::Succeeded); } diff --git a/Tests/TestApp/src/TestTextureCreation.cpp b/Tests/TestApp/src/TestTextureCreation.cpp index 029e6e4..bb95e15 100644 --- a/Tests/TestApp/src/TestTextureCreation.cpp +++ b/Tests/TestApp/src/TestTextureCreation.cpp @@ -539,7 +539,8 @@ private: std::unique_ptr m_pTestCreateObjFromNativeRes; }; -TestTextureCreation::TestTextureCreation( IRenderDevice *pDevice, IDeviceContext *pContext ) : +TestTextureCreation::TestTextureCreation( IRenderDevice *pDevice, IDeviceContext *pContext ) : + UnitTestBase("Texture creation test"), m_pDevice(pDevice) { TestTextureFormatAttribs(); @@ -689,10 +690,14 @@ TestTextureCreation::TestTextureCreation( IRenderDevice *pDevice, IDeviceContext LOG_WARNING_MESSAGE( "Texture format ", CurrAttrs.Name, " is not supported!\n" ); continue; } + ++m_NumFormatsTested; assert(CurrAttrs.PixelSize == PixelFormatAttribs.ComponentSize * PixelFormatAttribs.NumComponents || PixelFormatAttribs.ComponentType == COMPONENT_TYPE_COMPRESSED); Verifier.Test(CurrAttrs.Fmt, CurrAttrs.PixelSize, CurrAttrs.BindFlags, CurrAttrs.TestDataUpload); } + std::stringstream infoss; + infoss << "Formats tested: " << m_NumFormatsTested; + SetStatus(TestResult::Succeeded, infoss.str().c_str()); } void TestTextureCreation::CheckFormatSize(TEXTURE_FORMAT *begin, TEXTURE_FORMAT *end, Uint32 RefSize) diff --git a/Tests/TestApp/src/TestTexturing.cpp b/Tests/TestApp/src/TestTexturing.cpp index 69f0a49..ef032d0 100644 --- a/Tests/TestApp/src/TestTexturing.cpp +++ b/Tests/TestApp/src/TestTexturing.cpp @@ -32,7 +32,8 @@ using namespace Diligent; -TestTexturing::TestTexturing() : +TestTexturing::TestTexturing() : + UnitTestBase("Texturing test"), m_iTestTexWidth(512), m_iTestTexHeight(512), m_iMipLevels(8), @@ -265,6 +266,11 @@ void TestTexturing::Init( IRenderDevice *pDevice, IDeviceContext *pDeviceContext pVS->BindResources(m_pResourceMapping, 0); pPS->BindResources(m_pResourceMapping, 0); + + auto *FmtName = pDevice->GetTextureFormatInfo(TexFormat).Name; + m_TestName.append(" ("); + m_TestName.append(FmtName); + m_TestName.append(")"); } void TestTexturing::Draw() @@ -282,4 +288,6 @@ void TestTexturing::Draw() DrawAttrs.Topology = Diligent::PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; DrawAttrs.NumVertices = 4; // Draw quad m_pDeviceContext->Draw( DrawAttrs ); + + SetStatus(TestResult::Succeeded); } diff --git a/Tests/TestApp/src/TestVPAndSR.cpp b/Tests/TestApp/src/TestVPAndSR.cpp index 0f60bda..c3b8b74 100644 --- a/Tests/TestApp/src/TestVPAndSR.cpp +++ b/Tests/TestApp/src/TestVPAndSR.cpp @@ -31,7 +31,8 @@ using namespace Diligent; -TestVPAndSR::TestVPAndSR(IRenderDevice *pDevice, IDeviceContext *pContext ) +TestVPAndSR::TestVPAndSR(IRenderDevice *pDevice, IDeviceContext *pContext ) : + UnitTestBase("Viewport and scissor rect test") { m_pRenderDevice = pDevice; m_pDeviceContext = pContext; @@ -46,4 +47,6 @@ TestVPAndSR::TestVPAndSR(IRenderDevice *pDevice, IDeviceContext *pContext ) m_pRenderScript->Run( m_pDeviceContext, "SetViewports" ); m_pRenderScript->Run( m_pDeviceContext, "SetScissorRects" ); + + SetStatus(TestResult::Succeeded); } diff --git a/Tests/TestApp/src/UnitTestBase.cpp b/Tests/TestApp/src/UnitTestBase.cpp new file mode 100644 index 0000000..309242e --- /dev/null +++ b/Tests/TestApp/src/UnitTestBase.cpp @@ -0,0 +1,58 @@ +/* Copyright 2015-2017 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +// EngineSandbox.cpp : Defines the entry point for the application. +// + +#include +#include + +#include "pch.h" +#include "UnitTestBase.h" +#include "Errors.h" + +using namespace Diligent; + +int UnitTestBase::m_TotalTests = 0; +size_t UnitTestBase::m_MaxNameLen = 0; + +UnitTestBase::UnitTestBase(const char *Name) : + m_TestName(Name) +{ + m_MaxNameLen = std::max(m_MaxNameLen, m_TestName.length()); + m_TestNum = ++m_TotalTests; + LOG_INFO_MESSAGE("Initialized test ", m_TestNum, ": ", Name); +} + +UnitTestBase::~UnitTestBase() +{ + const char* TestResltStr[] = + { + "UNKNOWN", + "SKIPPED", + "FAILED", + "SUCCEEDED" + }; + LOG_INFO_MESSAGE("Test ", std::setw(2), m_TestNum, "/", m_TotalTests, " - ", std::setw(m_MaxNameLen), std::left, m_TestName, " : ", + TestResltStr[static_cast(m_TestResult)], ". ", m_TestResultInfo); +} diff --git a/Tests/TestApp/src/VarSizeAllocationsManagerTest.cpp b/Tests/TestApp/src/VarSizeAllocationsManagerTest.cpp index 5f50b59..1463bed 100644 --- a/Tests/TestApp/src/VarSizeAllocationsManagerTest.cpp +++ b/Tests/TestApp/src/VarSizeAllocationsManagerTest.cpp @@ -28,10 +28,11 @@ #include "VariableSizeGPUAllocationsManager.h" #include "DefaultRawMemoryAllocator.h" #include "DebugUtilities.h" +#include "UnitTestBase.h" using namespace Diligent; -class VariableSizeAllocationsManagerTest +class VariableSizeAllocationsManagerTest : public UnitTestBase { public: VariableSizeAllocationsManagerTest(); @@ -39,7 +40,8 @@ public: static VariableSizeAllocationsManagerTest TheVariableSizeAllocationsManagerTest; -VariableSizeAllocationsManagerTest::VariableSizeAllocationsManagerTest() +VariableSizeAllocationsManagerTest::VariableSizeAllocationsManagerTest() : + UnitTestBase("Variable size allocation manager test") { auto &Allocator = DefaultRawMemoryAllocator::GetAllocator(); { @@ -175,4 +177,6 @@ VariableSizeAllocationsManagerTest::VariableSizeAllocationsManagerTest() ListMgr.ReleaseStaleAllocations(3); } + + SetStatus(TestResult::Succeeded); } -- cgit v1.2.3