diff --git a/renderdoc/driver/d3d12/d3d12_initstate.cpp b/renderdoc/driver/d3d12/d3d12_initstate.cpp index 1024eb152..69a5243de 100644 --- a/renderdoc/driver/d3d12/d3d12_initstate.cpp +++ b/renderdoc/driver/d3d12/d3d12_initstate.cpp @@ -129,10 +129,11 @@ bool D3D12ResourceManager::Prepare_InitialState(ID3D12DeviceChild *res) D3D12_RESOURCE_STATES destState = D3D12_RESOURCE_STATE_COPY_SOURCE; ID3D12Resource *unwrappedCopySource = r->GetReal(); + bool isDepth = + IsDepthFormat(desc.Format) || (desc.Flags & D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL) != 0; + if(desc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE2D && desc.SampleDesc.Count > 1) { - bool isDepth = IsDepthFormat(desc.Format); - desc.Alignment = 0; desc.DepthOrArraySize *= (UINT16)desc.SampleDesc.Count; desc.SampleDesc.Count = 1; @@ -207,8 +208,8 @@ bool D3D12ResourceManager::Prepare_InitialState(ID3D12DeviceChild *res) D3D12_RESOURCE_BARRIER b = {}; b.Transition.pResource = arrayTexture; b.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES; - b.Transition.StateBefore = IsDepthFormat(desc.Format) ? D3D12_RESOURCE_STATE_DEPTH_WRITE - : D3D12_RESOURCE_STATE_RENDER_TARGET; + b.Transition.StateBefore = + isDepth ? D3D12_RESOURCE_STATE_DEPTH_WRITE : D3D12_RESOURCE_STATE_RENDER_TARGET; b.Transition.StateAfter = D3D12_RESOURCE_STATE_COPY_SOURCE; list->ResourceBarrier(1, &b); @@ -589,7 +590,8 @@ bool D3D12ResourceManager::Serialise_InitialState(SerialiserType &ser, ResourceI arrayDesc.SampleDesc.Quality = 0; arrayDesc.Flags = D3D12_RESOURCE_FLAG_NONE; - bool isDepth = IsDepthFormat(resDesc.Format); + bool isDepth = IsDepthFormat(resDesc.Format) || + (resDesc.Flags & D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL) != 0; D3D12_RESOURCE_DESC msaaDesc = resDesc; arrayDesc.Alignment = 0; diff --git a/renderdoc/driver/d3d12/d3d12_msaa_array_conv.cpp b/renderdoc/driver/d3d12/d3d12_msaa_array_conv.cpp index dae7679d3..d41155a66 100644 --- a/renderdoc/driver/d3d12/d3d12_msaa_array_conv.cpp +++ b/renderdoc/driver/d3d12/d3d12_msaa_array_conv.cpp @@ -59,13 +59,14 @@ void D3D12DebugManager::CopyTex2DMSToArray(ID3D12Resource *destArray, ID3D12Reso dsvDesc.Texture2DArray.FirstArraySlice = 0; dsvDesc.Texture2DArray.MipSlice = 0; - bool depthFormat = IsDepthFormat(rtvDesc.Format); + bool isDepth = IsDepthFormat(rtvDesc.Format) || + (descMS.Flags & D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL) != 0; bool intFormat = IsUIntFormat(rtvDesc.Format) || IsIntFormat(rtvDesc.Format); bool stencil = false; DXGI_FORMAT stencilFormat = DXGI_FORMAT_UNKNOWN; - if(depthFormat) + if(isDepth) { switch(descMS.Format) { @@ -137,7 +138,7 @@ void D3D12DebugManager::CopyTex2DMSToArray(ID3D12Resource *destArray, ID3D12Reso pipeDesc.RTVFormats[0] = rtvDesc.Format; pipeDesc.DSVFormat = DXGI_FORMAT_UNKNOWN; - if(depthFormat) + if(isDepth) { pipeDesc.PS.BytecodeLength = m_DepthMS2Array->GetBufferSize(); pipeDesc.PS.pShaderBytecode = m_DepthMS2Array->GetBufferPointer(); @@ -209,7 +210,7 @@ void D3D12DebugManager::CopyTex2DMSToArray(ID3D12Resource *destArray, ID3D12Reso dsvDesc.Texture2DArray.FirstArraySlice = slice * descMS.SampleDesc.Count + sample; rtvDesc.Texture2DArray.FirstArraySlice = slice * descMS.SampleDesc.Count + sample; - if(depthFormat) + if(isDepth) { m_pDevice->GetReal()->CreateDepthStencilView(destArray, &dsvDesc, dsv); list->OMSetRenderTargets(0, NULL, FALSE, &dsv); @@ -322,13 +323,14 @@ void D3D12DebugManager::CopyArrayToTex2DMS(ID3D12Resource *destMS, ID3D12Resourc dsvDesc.Format = srvDesc.Format; dsvDesc.Texture2DMSArray.ArraySize = 1; - bool depthFormat = IsDepthFormat(rtvDesc.Format); + bool isDepth = IsDepthFormat(rtvDesc.Format) || + (descArr.Flags & D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL) != 0; bool intFormat = IsUIntFormat(rtvDesc.Format) || IsIntFormat(rtvDesc.Format); bool stencil = false; DXGI_FORMAT stencilFormat = DXGI_FORMAT_UNKNOWN; - if(depthFormat) + if(isDepth) { switch(descMS.Format) { @@ -411,7 +413,7 @@ void D3D12DebugManager::CopyArrayToTex2DMS(ID3D12Resource *destMS, ID3D12Resourc pipeDesc.RTVFormats[0] = rtvDesc.Format; pipeDesc.DSVFormat = DXGI_FORMAT_UNKNOWN; - if(depthFormat) + if(isDepth) { pipeDesc.PS.BytecodeLength = m_DepthArray2MS->GetBufferSize(); pipeDesc.PS.pShaderBytecode = m_DepthArray2MS->GetBufferPointer(); @@ -482,7 +484,7 @@ void D3D12DebugManager::CopyArrayToTex2DMS(ID3D12Resource *destMS, ID3D12Resourc rtvDesc.Texture2DMSArray.FirstArraySlice = slice; dsvDesc.Texture2DMSArray.FirstArraySlice = slice; - if(depthFormat) + if(isDepth) { m_pDevice->CreateDepthStencilView(destMS, &dsvDesc, dsv); list->OMSetRenderTargets(0, NULL, FALSE, &dsv);