D3D resolveBindTexture fixes

This commit is contained in:
Jack Andersen 2016-02-25 19:35:12 -10:00
parent 0eb11ef78a
commit b1481f9043
2 changed files with 39 additions and 2 deletions

View File

@ -333,10 +333,10 @@ class D3D11TextureR : public ITextureR
if (enableShaderDepthBind)
{
ThrowIfFailed(ctx->m_dev->CreateTexture2D(&CD3D11_TEXTURE2D_DESC(DXGI_FORMAT_D24_UNORM_S8_UINT, width, height,
ThrowIfFailed(ctx->m_dev->CreateTexture2D(&CD3D11_TEXTURE2D_DESC(DXGI_FORMAT_R24G8_TYPELESS, width, height,
1, 1, D3D11_BIND_SHADER_RESOURCE, D3D11_USAGE_DEFAULT, 0, samples), nullptr, &m_depthBindTex));
ThrowIfFailed(ctx->m_dev->CreateShaderResourceView(m_depthBindTex.Get(),
&CD3D11_SHADER_RESOURCE_VIEW_DESC(m_depthBindTex.Get(), srvDim), &m_depthSrv));
&CD3D11_SHADER_RESOURCE_VIEW_DESC(m_depthBindTex.Get(), srvDim, DXGI_FORMAT_R24G8_TYPELESS), &m_depthSrv));
}
}
@ -1218,6 +1218,7 @@ void D3D11CommandQueue::execute()
gfxF->procDeletes();
ThrowIfFailed(m_deferredCtx->FinishCommandList(false, &m_cmdLists[m_fillBuf]));
m_deferredCtx->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
m_workDoPresent[m_fillBuf] = m_doPresent;
m_doPresent = nullptr;

View File

@ -1195,6 +1195,15 @@ struct D3D12CommandQueue : IGraphicsCommandQueue
const D3D12TextureR* tex = static_cast<const D3D12TextureR*>(texture);
if (color && tex->m_enableShaderColorBind)
{
D3D12_RESOURCE_BARRIER copySetup[] =
{
CD3DX12_RESOURCE_BARRIER::Transition(tex->m_colorTex.Get(),
D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE),
CD3DX12_RESOURCE_BARRIER::Transition(tex->m_colorBindTex.Get(),
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_STATE_COPY_DEST)
};
m_cmdList->ResourceBarrier(2, copySetup);
if (tex->m_samples > 1)
{
m_cmdList->CopyResource(tex->m_colorBindTex.Get(), tex->m_colorTex.Get());
@ -1209,10 +1218,37 @@ struct D3D12CommandQueue : IGraphicsCommandQueue
src.SubresourceIndex = 0;
m_cmdList->CopyTextureRegion(&dst, rect.location[0], y, 0, &src, &box);
}
D3D12_RESOURCE_BARRIER copyTeardown[] =
{
CD3DX12_RESOURCE_BARRIER::Transition(tex->m_colorTex.Get(),
D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET),
CD3DX12_RESOURCE_BARRIER::Transition(tex->m_colorBindTex.Get(),
D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE)
};
m_cmdList->ResourceBarrier(2, copyTeardown);
}
if (depth && tex->m_enableShaderDepthBind)
{
D3D12_RESOURCE_BARRIER copySetup[] =
{
CD3DX12_RESOURCE_BARRIER::Transition(tex->m_depthTex.Get(),
D3D12_RESOURCE_STATE_DEPTH_WRITE, D3D12_RESOURCE_STATE_COPY_SOURCE),
CD3DX12_RESOURCE_BARRIER::Transition(tex->m_depthBindTex.Get(),
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_STATE_COPY_DEST)
};
m_cmdList->ResourceBarrier(2, copySetup);
m_cmdList->CopyResource(tex->m_depthBindTex.Get(), tex->m_depthTex.Get());
D3D12_RESOURCE_BARRIER copyTeardown[] =
{
CD3DX12_RESOURCE_BARRIER::Transition(tex->m_depthTex.Get(),
D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_DEPTH_WRITE),
CD3DX12_RESOURCE_BARRIER::Transition(tex->m_depthBindTex.Get(),
D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE)
};
m_cmdList->ResourceBarrier(2, copyTeardown);
}
}