depth and render classification

Change depth and render texture resource classification
This commit is contained in:
MichelVachon
2018-12-07 12:31:35 +00:00
committed by baldurk
parent 5b11cfea0a
commit 76848d493b
2 changed files with 17 additions and 13 deletions
+7 -5
View File
@@ -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;
@@ -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);