Ver código fonte

D3D12: Fixed resource state transition during blit.

Branimir Karadžić 8 anos atrás
pai
commit
ef5129c7fc
1 arquivos alterados com 22 adições e 1 exclusões
  1. 22 1
      src/renderer_d3d12.cpp

+ 22 - 1
src/renderer_d3d12.cpp

@@ -5083,13 +5083,28 @@ data.NumQualityLevels = 0;
 
 	void RendererContextD3D12::submitBlit(BlitState& _bs, uint16_t _view)
 	{
+		TextureHandle currentSrc = { kInvalidHandle };
+		D3D12_RESOURCE_STATES state = D3D12_RESOURCE_STATES(UINT32_MAX);
+
 		while (_bs.hasItem(_view) )
 		{
 			const BlitItem& blit = _bs.advance();
 
-			const TextureD3D12& src = m_textures[blit.m_src.idx];
+			TextureD3D12& src = m_textures[blit.m_src.idx];
 			const TextureD3D12& dst = m_textures[blit.m_dst.idx];
 
+			if (currentSrc.idx != blit.m_src.idx)
+			{
+				if (D3D12_RESOURCE_STATES(UINT32_MAX) != state)
+				{
+					m_textures[currentSrc.idx].setState(m_commandList, state);
+				}
+
+				currentSrc = blit.m_src;
+
+				state = src.setState(m_commandList, D3D12_RESOURCE_STATE_COPY_SOURCE);
+			}
+
  			uint32_t srcWidth  = bx::uint32_min(src.m_width,  blit.m_srcX + blit.m_width)  - blit.m_srcX;
  			uint32_t srcHeight = bx::uint32_min(src.m_height, blit.m_srcY + blit.m_height) - blit.m_srcY;
  			uint32_t srcDepth  = bx::uint32_min(src.m_depth,  blit.m_srcZ + blit.m_depth)  - blit.m_srcZ;
@@ -5158,6 +5173,12 @@ data.NumQualityLevels = 0;
 					);
 			}
 		}
+
+		if (isValid(currentSrc)
+		&&  D3D12_RESOURCE_STATES(UINT32_MAX) != state)
+		{
+			m_textures[currentSrc.idx].setState(m_commandList, state);
+		}
 	}
 
 	void RendererContextD3D12::submit(Frame* _render, ClearQuad& /*_clearQuad*/, TextVideoMemBlitter& _textVideoMemBlitter)