@@ -73,6 +73,8 @@ class ITestingSwapChain : public IObject
7373 virtual ITextureView* GetCurrentBackBufferUAV () = 0;
7474
7575 virtual void DumpBackBuffer (const char * FileName) = 0;
76+
77+ virtual void CompareWithSnapshot (ITexture* pTexture) = 0;
7678};
7779
7880template <typename SwapChainInterface>
@@ -173,33 +175,7 @@ class TestingSwapChainBase : public RefCountedObject<SwapChainCombinedBaseInterf
173175
174176 virtual void DILIGENT_CALL_TYPE Present (Uint32 SyncInterval = 1 ) override
175177 {
176- m_pContext->SetRenderTargets (0 , nullptr , nullptr , RESOURCE_STATE_TRANSITION_MODE_NONE);
177-
178- CopyTextureAttribs CopyInfo //
179- {
180- m_pRenderTarget,
181- RESOURCE_STATE_TRANSITION_MODE_TRANSITION,
182- m_pStagingTexture,
183- RESOURCE_STATE_TRANSITION_MODE_TRANSITION //
184- };
185- m_pContext->CopyTexture (CopyInfo);
186- m_pContext->WaitForIdle ();
187- MappedTextureSubresource MapData;
188-
189- auto MapFlag = MAP_FLAG_DO_NOT_WAIT;
190- if (m_pDevice->GetDeviceInfo ().Type == RENDER_DEVICE_TYPE_D3D11)
191- {
192- // As a matter of fact, we should be able to always use MAP_FLAG_DO_NOT_WAIT flag
193- // as we flush the context and idle the GPU before mapping the staging texture.
194- // Intel driver, however, still returns null unless we don't use D3D11_MAP_FLAG_DO_NOT_WAIT flag.
195- MapFlag = MAP_FLAG_NONE;
196- }
197-
198- m_pContext->MapTextureSubresource (m_pStagingTexture, 0 , 0 , MAP_READ, MapFlag, nullptr , MapData);
199- CompareTestImages (m_ReferenceData.data (), m_ReferenceDataPitch, static_cast <const Uint8*>(MapData.pData ), MapData.Stride ,
200- m_SwapChainDesc.Width , m_SwapChainDesc.Height , m_SwapChainDesc.ColorBufferFormat , m_FailureCounters);
201-
202- m_pContext->UnmapTextureSubresource (m_pStagingTexture, 0 , 0 );
178+ CompareWithSnapshot (nullptr );
203179 }
204180
205181 virtual void DILIGENT_CALL_TYPE Resize (Uint32 NewWidth, Uint32 NewHeight, SURFACE_TRANSFORM NewPreTransform) override final
@@ -271,6 +247,43 @@ class TestingSwapChainBase : public RefCountedObject<SwapChainCombinedBaseInterf
271247 m_pContext->UnmapTextureSubresource (m_pStagingTexture, 0 , 0 );
272248 }
273249
250+ virtual void CompareWithSnapshot (ITexture* pTexture) override
251+ {
252+ if (pTexture == nullptr )
253+ pTexture = m_pRenderTarget;
254+
255+ if (pTexture == m_pRenderTarget)
256+ {
257+ m_pContext->SetRenderTargets (0 , nullptr , nullptr , RESOURCE_STATE_TRANSITION_MODE_NONE);
258+ }
259+
260+ CopyTextureAttribs CopyInfo //
261+ {
262+ pTexture,
263+ RESOURCE_STATE_TRANSITION_MODE_TRANSITION,
264+ m_pStagingTexture,
265+ RESOURCE_STATE_TRANSITION_MODE_TRANSITION //
266+ };
267+ m_pContext->CopyTexture (CopyInfo);
268+ m_pContext->WaitForIdle ();
269+ MappedTextureSubresource MapData;
270+
271+ auto MapFlag = MAP_FLAG_DO_NOT_WAIT;
272+ if (m_pDevice->GetDeviceInfo ().Type == RENDER_DEVICE_TYPE_D3D11)
273+ {
274+ // As a matter of fact, we should be able to always use MAP_FLAG_DO_NOT_WAIT flag
275+ // as we flush the context and idle the GPU before mapping the staging texture.
276+ // Intel driver, however, still returns null unless we don't use D3D11_MAP_FLAG_DO_NOT_WAIT flag.
277+ MapFlag = MAP_FLAG_NONE;
278+ }
279+
280+ m_pContext->MapTextureSubresource (m_pStagingTexture, 0 , 0 , MAP_READ, MapFlag, nullptr , MapData);
281+ CompareTestImages (m_ReferenceData.data (), m_ReferenceDataPitch, static_cast <const Uint8*>(MapData.pData ), MapData.Stride ,
282+ m_SwapChainDesc.Width , m_SwapChainDesc.Height , m_SwapChainDesc.ColorBufferFormat , m_FailureCounters);
283+
284+ m_pContext->UnmapTextureSubresource (m_pStagingTexture, 0 , 0 );
285+ }
286+
274287protected:
275288 const SwapChainDesc m_SwapChainDesc;
276289 RefCntAutoPtr<IRenderDevice> m_pDevice;
0 commit comments