diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2018-12-02 23:44:56 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2018-12-02 23:44:56 +0000 |
| commit | c7db634ec3e350b9cf665ec0f75455189a8eaace (patch) | |
| tree | 35ad25a85cdf99242bf8af3b8cd3c036654c05d1 /Tests/TestApp/src | |
| parent | Brought back MapType paramter to UnmapBuffer() function. (diff) | |
| download | DiligentEngine-c7db634ec3e350b9cf665ec0f75455189a8eaace.tar.gz DiligentEngine-c7db634ec3e350b9cf665ec0f75455189a8eaace.zip | |
Added explicit state transition control to CopyBuffer and CopyTexture methods
Replaced CLEAR_RENDER_TARGET_TRANSITION_MODE with RESOURCE_STATE_TRANSITION_MODE
Diffstat (limited to 'Tests/TestApp/src')
| -rw-r--r-- | Tests/TestApp/src/TestApp.cpp | 8 | ||||
| -rw-r--r-- | Tests/TestApp/src/TestBufferAccess.cpp | 14 | ||||
| -rw-r--r-- | Tests/TestApp/src/TestCopyTexData.cpp | 107 | ||||
| -rw-r--r-- | Tests/TestApp/src/TestSeparateTextureSampler.cpp | 2 | ||||
| -rw-r--r-- | Tests/TestApp/src/TestShaderResourceLayout.cpp | 2 | ||||
| -rw-r--r-- | Tests/TestApp/src/TestShaderVarAccess.cpp | 2 | ||||
| -rw-r--r-- | Tests/TestApp/src/TestTextureCreation.cpp | 7 |
7 files changed, 74 insertions, 68 deletions
diff --git a/Tests/TestApp/src/TestApp.cpp b/Tests/TestApp/src/TestApp.cpp index ab0b088..3a43243 100644 --- a/Tests/TestApp/src/TestApp.cpp +++ b/Tests/TestApp/src/TestApp.cpp @@ -524,7 +524,7 @@ void TestApp::InitializeRenderers() m_pImmediateContext->SetRenderTargets(0, nullptr, nullptr, SET_RENDER_TARGETS_FLAG_TRANSITION_ALL); float ClearColor[] = {0.1f, 0.2f, 0.4f, 1.0f}; - m_pImmediateContext->ClearRenderTarget(nullptr, ClearColor, CLEAR_RENDER_TARGET_VERIFY_STATE); + m_pImmediateContext->ClearRenderTarget(nullptr, ClearColor, RESOURCE_STATE_TRANSITION_MODE_VERIFY); DrawAttribs DrawAttrs; DrawAttrs.NumVertices = 3; DrawAttrs.Flags = DRAW_FLAG_TRANSITION_VERTEX_BUFFERS; @@ -532,7 +532,7 @@ void TestApp::InitializeRenderers() // This adds transition barrier for pTex1 m_pImmediateContext->SetRenderTargets(1, pRTVs, pDSV, SET_RENDER_TARGETS_FLAG_TRANSITION_ALL); - m_pImmediateContext->ClearRenderTarget(pRTVs[0], ClearColor, CLEAR_RENDER_TARGET_VERIFY_STATE); + m_pImmediateContext->ClearRenderTarget(pRTVs[0], ClearColor, RESOURCE_STATE_TRANSITION_MODE_VERIFY); m_pImmediateContext->ClearDepthStencil(pDSV, CLEAR_DEPTH_FLAG | CLEAR_DEPTH_STENCIL_VERIFY_STATE_FLAG); // Generate draw command to the bound render target m_pImmediateContext->Draw(DrawAttrs); @@ -632,14 +632,14 @@ void TestApp::Render() { m_pImmediateContext->SetRenderTargets(0, nullptr, nullptr, SET_RENDER_TARGETS_FLAG_TRANSITION_ALL); float ClearColor[] = {0.1f, 0.2f, 0.4f, 1.0f}; - m_pImmediateContext->ClearRenderTarget(nullptr, ClearColor, CLEAR_RENDER_TARGET_VERIFY_STATE); + m_pImmediateContext->ClearRenderTarget(nullptr, ClearColor, RESOURCE_STATE_TRANSITION_MODE_VERIFY); m_pImmediateContext->ClearDepthStencil(nullptr, CLEAR_DEPTH_FLAG| CLEAR_DEPTH_STENCIL_VERIFY_STATE_FLAG, 1.f); double dCurrTime = m_CurrTime; float instance_offsets[] = { -0.3f, (float)sin(dCurrTime + 0.5)*0.1f, 0.0f, (float)sin(dCurrTime)*0.1f, +0.3f, -0.3f + (float)cos(dCurrTime)*0.1f }; m_pImmediateContext->UpdateBuffer(m_pInstBuff2, sizeof(float) * 1, sizeof(float) * 5, &instance_offsets[1], RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - m_pImmediateContext->CopyBuffer(m_pInstBuff2, sizeof(float) * 2, m_pInstBuff, sizeof(float) * 2, sizeof(float) * 4); + m_pImmediateContext->CopyBuffer(m_pInstBuff2, sizeof(float) * 2, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, m_pInstBuff, sizeof(float) * 2, sizeof(float) * 4, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); { MapHelper<float> UniformData(m_pImmediateContext, m_pUniformBuff, MAP_WRITE, MAP_FLAG_DISCARD); diff --git a/Tests/TestApp/src/TestBufferAccess.cpp b/Tests/TestApp/src/TestBufferAccess.cpp index 14d097b..09e6e12 100644 --- a/Tests/TestApp/src/TestBufferAccess.cpp +++ b/Tests/TestApp/src/TestBufferAccess.cpp @@ -198,7 +198,7 @@ void TestBufferAccess::Draw(float fTime) instance_offsets[Inst*2+1] = 2.f * fDY + sin(fTime*0.8f) * fDY * 0.3f; } m_pDeviceContext->UpdateBuffer(m_pInstBuff[2], sizeof( float ) * 2, sizeof( float ) * 4, &instance_offsets[2], RESOURCE_STATE_TRANSITION_MODE_TRANSITION ); - m_pDeviceContext->CopyBuffer(m_pInstBuff[2], sizeof( float ) * 2, m_pInstBuff[1], sizeof( float ) * 2, sizeof( float ) * 4 ); + m_pDeviceContext->CopyBuffer(m_pInstBuff[2], sizeof( float ) * 2, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, m_pInstBuff[1], sizeof( float ) * 2, sizeof( float ) * 4, RESOURCE_STATE_TRANSITION_MODE_TRANSITION ); m_pDeviceContext->Draw(DrawAttrs); @@ -225,7 +225,7 @@ void TestBufferAccess::Draw(float fTime) MapHelper<float> pStagingData; // Test reading data from staging resource { - m_pDeviceContext->CopyBuffer(m_pInstBuff[3], 0, m_pInstBuff[4], 0, sizeof( instance_offsets ) ); + m_pDeviceContext->CopyBuffer(m_pInstBuff[3], 0, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, m_pInstBuff[4], 0, sizeof( instance_offsets ), RESOURCE_STATE_TRANSITION_MODE_TRANSITION ); pStagingData.Map( m_pDeviceContext, m_pInstBuff[4], MAP_READ, MAP_FLAG_NONE ); for(int i = 0; i < _countof(instance_offsets); ++i) assert(pStagingData[i] == instance_offsets[i]); @@ -246,7 +246,13 @@ void TestBufferAccess::Draw(float fTime) pStagingData.Unmap(); } - m_pDeviceContext->CopyBuffer(m_pInstBuff[5], 0, m_pInstBuff[2], 0, sizeof( instance_offsets ) ); + StateTransitionDesc Barriers[2] = + { + StateTransitionDesc{m_pInstBuff[5], RESOURCE_STATE_UNKNOWN, RESOURCE_STATE_COPY_SOURCE, true}, + StateTransitionDesc{m_pInstBuff[2], RESOURCE_STATE_UNKNOWN, RESOURCE_STATE_COPY_DEST, true}, + }; + m_pDeviceContext->TransitionResourceStates(2, Barriers); + m_pDeviceContext->CopyBuffer(m_pInstBuff[5], 0, RESOURCE_STATE_TRANSITION_MODE_VERIFY, m_pInstBuff[2], 0, sizeof( instance_offsets ), RESOURCE_STATE_TRANSITION_MODE_VERIFY ); pBuffs[3] = m_pInstBuff[2]; m_pDeviceContext->SetVertexBuffers( 0, _countof( pBuffs ), pBuffs, Offsets, SET_VERTEX_BUFFERS_FLAG_RESET ); m_pDeviceContext->Draw(DrawAttrs); @@ -266,7 +272,7 @@ void TestBufferAccess::Draw(float fTime) fPrevTime = fTime; }*/ - m_pDeviceContext->CopyBuffer(m_pInstBuff[6], 0, m_pInstBuff[2], 0, sizeof( instance_offsets ) ); + m_pDeviceContext->CopyBuffer(m_pInstBuff[6], 0, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, m_pInstBuff[2], 0, sizeof( instance_offsets ), RESOURCE_STATE_TRANSITION_MODE_TRANSITION ); m_pDeviceContext->Draw(DrawAttrs); } } diff --git a/Tests/TestApp/src/TestCopyTexData.cpp b/Tests/TestApp/src/TestCopyTexData.cpp index 2be5c7f..c024228 100644 --- a/Tests/TestApp/src/TestCopyTexData.cpp +++ b/Tests/TestApp/src/TestCopyTexData.cpp @@ -108,31 +108,27 @@ void TestCopyTexData::Test2DTexture( TEXTURE_FORMAT Format ) m_pDevice->CreateTexture( TexDesc, InitData, &pSrcTex ); m_pDevice->CreateTexture( TexDesc, TextureData(), &pDstTex ); - m_pContext->CopyTexture(pSrcTex, - 2, // Src mip - 0, // Src slice - nullptr, // Box - pDstTex, - 1, // dst mip - 0, // dst slice - 32, 16, 0 // XYZ offset - ); + CopyTextureAttribs CopyAttribs; + CopyAttribs.pSrcTexture = pSrcTex; + CopyAttribs.SrcMipLevel = 2; + CopyAttribs.pDstTexture = pDstTex; + CopyAttribs.DstMipLevel = 1; + CopyAttribs.DstX = 32; + CopyAttribs.DstY = 16; + CopyAttribs.DstZ = 0; + CopyAttribs.SrcTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_TRANSITION; + CopyAttribs.DstTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_TRANSITION; + m_pContext->CopyTexture(CopyAttribs); Box SrcBox; SrcBox.MinX = 3; SrcBox.MaxX = 19; SrcBox.MinY = 1; SrcBox.MaxY = 32; - m_pContext->CopyTexture(pSrcTex, - 2, // Src mip - 0, // Src slice - &SrcBox, // Box - pDstTex, - 1, // dst mip - 0, // dst slice - 32, 16, 0 // XYZ offset - ); - + CopyAttribs.pSrcBox = &SrcBox; + CopyAttribs.SrcTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_VERIFY; + CopyAttribs.DstTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_VERIFY; + m_pContext->CopyTexture(CopyAttribs); } void TestCopyTexData::Test2DTexArray( TEXTURE_FORMAT Format ) @@ -168,30 +164,30 @@ void TestCopyTexData::Test2DTexArray( TEXTURE_FORMAT Format ) m_pDevice->CreateTexture( TexDesc, InitData, &pSrcTex ); m_pDevice->CreateTexture( TexDesc, TextureData(), &pDstTex ); - m_pContext->CopyTexture(pSrcTex, - 2, // Src mip - 3, // Src slice - nullptr, // Box - pDstTex, - 1, // dst mip - 6, // dst slice - 32, 16, 0 // XYZ offset - ); + CopyTextureAttribs CopyAttribs; + CopyAttribs.pSrcTexture = pSrcTex; + CopyAttribs.SrcMipLevel = 2; + CopyAttribs.SrcSlice = 3; + CopyAttribs.pDstTexture = pDstTex; + CopyAttribs.DstMipLevel = 1; + CopyAttribs.DstSlice = 6; + CopyAttribs.DstX = 32; + CopyAttribs.DstY = 16; + CopyAttribs.DstZ = 0; + CopyAttribs.SrcTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_TRANSITION; + CopyAttribs.DstTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_TRANSITION; + m_pContext->CopyTexture(CopyAttribs); Box SrcBox; SrcBox.MinX = 3; SrcBox.MaxX = 19; SrcBox.MinY = 1; SrcBox.MaxY = 32; - m_pContext->CopyTexture(pSrcTex, - 2, // Src mip - 3, // Src slice - &SrcBox, // Box - pDstTex, - 1, // dst mip - 5, // dst slice - 32, 16, 0 // XYZ offset - ); + CopyAttribs.DstSlice = 5; + CopyAttribs.pSrcBox = &SrcBox; + CopyAttribs.SrcTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_VERIFY; + CopyAttribs.DstTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_VERIFY; + m_pContext->CopyTexture(CopyAttribs); } void TestCopyTexData::Test3DTexture( TEXTURE_FORMAT Format ) @@ -221,28 +217,29 @@ void TestCopyTexData::Test3DTexture( TEXTURE_FORMAT Format ) m_pDevice->CreateTexture( TexDesc, InitData, &pSrcTex ); m_pDevice->CreateTexture( TexDesc, TextureData(), &pDstTex ); - m_pContext->CopyTexture(pSrcTex, - 2, // Src mip - 0, // Src slice - nullptr, // Box - pDstTex, - 1, // dst mip - 0, // dst slice - 16, 8, 0 // XYZ offset - ); + CopyTextureAttribs CopyAttribs; + CopyAttribs.pSrcTexture = pSrcTex; + CopyAttribs.SrcMipLevel = 2; + CopyAttribs.pDstTexture = pDstTex; + CopyAttribs.DstMipLevel = 1; + CopyAttribs.DstX = 16; + CopyAttribs.DstY = 8; + CopyAttribs.DstZ = 0; + CopyAttribs.SrcTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_TRANSITION; + CopyAttribs.DstTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_TRANSITION; + + m_pContext->CopyTexture(CopyAttribs); Box SrcBox; SrcBox.MinX = 3; SrcBox.MaxX = 19; SrcBox.MinY = 1; SrcBox.MaxY = 32; - m_pContext->CopyTexture(pSrcTex, - 1, // Src mip - 0, // Src slice - &SrcBox, // Box - pDstTex, - 0, // dst mip - 0, // dst slice - 32, 16, 0 // XYZ offset - ); + CopyAttribs.pSrcBox = &SrcBox; + CopyAttribs.SrcMipLevel = 1; + CopyAttribs.DstMipLevel = 0; + CopyAttribs.DstX = 32; + CopyAttribs.DstY = 16; + CopyAttribs.DstZ = 0; + m_pContext->CopyTexture(CopyAttribs); } diff --git a/Tests/TestApp/src/TestSeparateTextureSampler.cpp b/Tests/TestApp/src/TestSeparateTextureSampler.cpp index 989fa05..a39e80b 100644 --- a/Tests/TestApp/src/TestSeparateTextureSampler.cpp +++ b/Tests/TestApp/src/TestSeparateTextureSampler.cpp @@ -153,7 +153,7 @@ TestSeparateTextureSampler::TestSeparateTextureSampler(IRenderDevice *pDevice, I ITextureView* pRTV[] = {pRenderTarget->GetDefaultView(TEXTURE_VIEW_RENDER_TARGET)}; pContext->SetRenderTargets(1, pRTV, nullptr, SET_RENDER_TARGETS_FLAG_TRANSITION_ALL); float Zero[4] = {}; - pContext->ClearRenderTarget(pRTV[0], Zero, CLEAR_RENDER_TARGET_VERIFY_STATE); + pContext->ClearRenderTarget(pRTV[0], Zero, RESOURCE_STATE_TRANSITION_MODE_VERIFY); pContext->SetPipelineState(pPSO); pContext->CommitShaderResources(pSRB, COMMIT_SHADER_RESOURCES_FLAG_TRANSITION_RESOURCES); DrawAttribs DrawAttrs; diff --git a/Tests/TestApp/src/TestShaderResourceLayout.cpp b/Tests/TestApp/src/TestShaderResourceLayout.cpp index 85cedf2..c12c039 100644 --- a/Tests/TestApp/src/TestShaderResourceLayout.cpp +++ b/Tests/TestApp/src/TestShaderResourceLayout.cpp @@ -87,7 +87,7 @@ TestShaderResourceLayout::TestShaderResourceLayout( IRenderDevice *pDevice, IDev auto *pRTV = pRenderTarget->GetDefaultView(TEXTURE_VIEW_RENDER_TARGET); m_pDeviceContext->SetRenderTargets(1, &pRTV, nullptr, SET_RENDER_TARGETS_FLAG_TRANSITION_ALL); float Zero[4] = {}; - m_pDeviceContext->ClearRenderTarget(pRTV, Zero, CLEAR_RENDER_TARGET_VERIFY_STATE); + m_pDeviceContext->ClearRenderTarget(pRTV, Zero, RESOURCE_STATE_TRANSITION_MODE_VERIFY); BufferDesc BuffDesc; BuffDesc.uiSizeInBytes = 1024; diff --git a/Tests/TestApp/src/TestShaderVarAccess.cpp b/Tests/TestApp/src/TestShaderVarAccess.cpp index 00efe34..606f3b3 100644 --- a/Tests/TestApp/src/TestShaderVarAccess.cpp +++ b/Tests/TestApp/src/TestShaderVarAccess.cpp @@ -554,7 +554,7 @@ TestShaderVarAccess::TestShaderVarAccess( IRenderDevice *pDevice, IDeviceContext m_pDeviceContext->SetRenderTargets(1, &pRTV, pDSV, SET_RENDER_TARGETS_FLAG_TRANSITION_ALL); float Zero[4] = {}; - m_pDeviceContext->ClearRenderTarget(pRTV, Zero, CLEAR_RENDER_TARGET_VERIFY_STATE); + m_pDeviceContext->ClearRenderTarget(pRTV, Zero, RESOURCE_STATE_TRANSITION_MODE_VERIFY); m_pDeviceContext->ClearDepthStencil(pDSV, CLEAR_DEPTH_FLAG | CLEAR_DEPTH_STENCIL_VERIFY_STATE_FLAG); pContext->CommitShaderResources(pSRB, COMMIT_SHADER_RESOURCES_FLAG_TRANSITION_RESOURCES); diff --git a/Tests/TestApp/src/TestTextureCreation.cpp b/Tests/TestApp/src/TestTextureCreation.cpp index 71efb5f..11a0a48 100644 --- a/Tests/TestApp/src/TestTextureCreation.cpp +++ b/Tests/TestApp/src/TestTextureCreation.cpp @@ -273,7 +273,8 @@ private: { // In D3D11 if CopySubresourceRegion is used with Multisampled or D3D11_BIND_DEPTH_STENCIL Resources, // then the whole Subresource must be copied. - m_pDeviceContext->CopyTexture(pTestTex2, 0, 0, nullptr, pTestTex, 0, 0, 0,0,0); + CopyTextureAttribs CopyAttribs(pTestTex2, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, pTestTex, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + m_pDeviceContext->CopyTexture(CopyAttribs); } else { @@ -285,7 +286,9 @@ private: SrcBox.MaxY = std::max(TexDesc.Height/3, SrcBox.MinY+1); SrcBox.MaxZ = ( TexDesc.Type == RESOURCE_DIM_TEX_3D ) ? std::max(TexDesc.Depth/3, SrcBox.MinZ+1) : 1; //pTestTex2->UpdateData(m_pDeviceContext, 0, 0, DstBox, SubResources[0]); - m_pDeviceContext->CopyTexture(pTestTex2, 0, 0, &SrcBox, pTestTex, 0, 0, 0,0,0); + CopyTextureAttribs CopyAttribs(pTestTex2, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, pTestTex, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + CopyAttribs.pSrcBox = &SrcBox; + m_pDeviceContext->CopyTexture(CopyAttribs); } } |
