From a413ef346e329a415d12985c2f07af08cbe68e8f Mon Sep 17 00:00:00 2001 From: assiduous Date: Wed, 17 Feb 2021 19:05:40 -0800 Subject: Testing swap chain: enabled capturing multiple fail images for the same test --- .../include/TestingSwapChainBase.hpp | 20 ++++++++++-------- .../src/PipelineResourceSignatureTest.cpp | 2 ++ .../src/TestingSwapChainBase.cpp | 24 ++++++++++++++-------- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/Tests/DiligentCoreAPITest/include/TestingSwapChainBase.hpp b/Tests/DiligentCoreAPITest/include/TestingSwapChainBase.hpp index b3c76772..e930aeb9 100644 --- a/Tests/DiligentCoreAPITest/include/TestingSwapChainBase.hpp +++ b/Tests/DiligentCoreAPITest/include/TestingSwapChainBase.hpp @@ -27,6 +27,7 @@ #pragma once #include +#include #include "ObjectBase.hpp" #include "RefCntAutoPtr.hpp" @@ -43,13 +44,14 @@ namespace Diligent namespace Testing { -void CompareTestImages(const Uint8* pReferencePixels, - Uint32 RefPixelsStride, - const Uint8* pPixels, - Uint32 PixelsStride, - Uint32 Width, - Uint32 Height, - TEXTURE_FORMAT Format); +void CompareTestImages(const Uint8* pReferencePixels, + Uint32 RefPixelsStride, + const Uint8* pPixels, + Uint32 PixelsStride, + Uint32 Width, + Uint32 Height, + TEXTURE_FORMAT Format, + std::unordered_map& FailureCounters); // {41BF4655-9B33-4E6C-9300-0CB45FBFE104} static constexpr INTERFACE_ID IID_TestingSwapChain = @@ -182,7 +184,7 @@ public: m_pContext->MapTextureSubresource(m_pStagingTexture, 0, 0, MAP_READ, MapFlag, nullptr, MapData); CompareTestImages(m_ReferenceData.data(), m_ReferenceDataPitch, reinterpret_cast(MapData.pData), MapData.Stride, - m_SwapChainDesc.Width, m_SwapChainDesc.Height, m_SwapChainDesc.ColorBufferFormat); + m_SwapChainDesc.Width, m_SwapChainDesc.Height, m_SwapChainDesc.ColorBufferFormat, m_FailureCounters); m_pContext->UnmapTextureSubresource(m_pStagingTexture, 0, 0); } @@ -238,6 +240,8 @@ protected: RefCntAutoPtr m_pDSV; RefCntAutoPtr m_pStagingTexture; + std::unordered_map m_FailureCounters; + std::vector m_ReferenceData; Uint32 m_ReferenceDataPitch = 0; }; diff --git a/Tests/DiligentCoreAPITest/src/PipelineResourceSignatureTest.cpp b/Tests/DiligentCoreAPITest/src/PipelineResourceSignatureTest.cpp index 785b4055..6794e41d 100644 --- a/Tests/DiligentCoreAPITest/src/PipelineResourceSignatureTest.cpp +++ b/Tests/DiligentCoreAPITest/src/PipelineResourceSignatureTest.cpp @@ -525,6 +525,8 @@ TEST_F(PipelineResourceSignatureTest, SingleVarType) pContext->Draw(DrawAttrs); pSwapChain->Present(); + std::cout << TestingEnvironment::GetCurrentTestStatusString() << ' ' + << GetShaderVariableTypeLiteralName(VarType) << " vars" << std::endl; } } diff --git a/Tests/DiligentCoreAPITest/src/TestingSwapChainBase.cpp b/Tests/DiligentCoreAPITest/src/TestingSwapChainBase.cpp index 7372dfed..16b43b55 100644 --- a/Tests/DiligentCoreAPITest/src/TestingSwapChainBase.cpp +++ b/Tests/DiligentCoreAPITest/src/TestingSwapChainBase.cpp @@ -41,13 +41,14 @@ namespace Diligent namespace Testing { -void CompareTestImages(const Uint8* pReferencePixels, - Uint32 RefPixelsStride, - const Uint8* pPixels, - Uint32 PixelsStride, - Uint32 Width, - Uint32 Height, - TEXTURE_FORMAT Format) +void CompareTestImages(const Uint8* pReferencePixels, + Uint32 RefPixelsStride, + const Uint8* pPixels, + Uint32 PixelsStride, + Uint32 Width, + Uint32 Height, + TEXTURE_FORMAT Format, + std::unordered_map& FailureCounters) { VERIFY_EXPR(pReferencePixels != nullptr); VERIFY_EXPR(pPixels != nullptr); @@ -108,15 +109,20 @@ void CompareTestImages(const Uint8* pReferencePixels, return dst; }; - std::string FileName = ValidateName(TestInfo->test_suite_name()); + std::string FileName{ValidateName(TestInfo->test_suite_name())}; + auto& FailureCounter = FailureCounters[FileName]; FileName += '.'; FileName += ValidateName(TestInfo->name()); - FileName += "_FAIL_.png"; + FileName += "_FAIL"; + if (FailureCounter > 0) + FileName += std::to_string(FailureCounter); + FileName += "_.png"; if (stbi_write_png(FileName.c_str(), Width * 2, Height * 2, 3, ReportImage.data(), (Width * 2) * 3) == 0) { LOG_ERROR_MESSAGE("Failed to write ", FileName); } ADD_FAILURE() << "Image rendered by the test is not identical to the reference image"; + ++FailureCounter; } } -- cgit v1.2.3