From 9f3dfafbc29cd7712a549dd6c1a56e69b5c98425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Wed, 10 Jan 2018 18:17:54 -0800 Subject: [PATCH] D3D12: Fixed RTV desc. --- src/renderer_d3d11.cpp | 2 +- src/renderer_d3d12.cpp | 55 ++++++++++++++++++++++++++++++++++++++---- 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index 7acf0007d..bba332823 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -5433,7 +5433,7 @@ BX_PRAGMA_DIAGNOSTIC_POP(); } DX_CHECK(s_renderD3D11->m_device->CreateRenderTargetView( - NULL == texture.m_rt ? texture.m_ptr : texture.m_rt + NULL == texture.m_rt ? texture.m_ptr : texture.m_rt , &desc , &m_rtv[m_num] ) ); diff --git a/src/renderer_d3d12.cpp b/src/renderer_d3d12.cpp index 563530022..e8c811d94 100644 --- a/src/renderer_d3d12.cpp +++ b/src/renderer_d3d12.cpp @@ -2025,7 +2025,7 @@ namespace bgfx { namespace d3d12 m_backBufferDepthStencil = createCommittedResource(m_device, HeapProperty::Default, &resourceDesc, &clearValue); D3D12_DEPTH_STENCIL_VIEW_DESC dsvDesc; - ZeroMemory(&dsvDesc, sizeof(dsvDesc) ); + bx::memSet(&dsvDesc, 0, sizeof(dsvDesc) ); dsvDesc.Format = resourceDesc.Format; dsvDesc.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2D; dsvDesc.Flags = D3D12_DSV_FLAGS(0) @@ -4853,7 +4853,7 @@ data.NumQualityLevels = 0; BX_UNUSED(blockInfo); D3D12_DEPTH_STENCIL_VIEW_DESC dsvDesc; - ZeroMemory(&dsvDesc, sizeof(dsvDesc) ); + bx::memSet(&dsvDesc, 0, sizeof(dsvDesc) ); dsvDesc.Format = s_textureFormat[texture.m_textureFormat].m_fmtDsv; dsvDesc.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2D; dsvDesc.Flags = D3D12_DSV_FLAG_NONE @@ -4870,8 +4870,53 @@ data.NumQualityLevels = 0; { m_texture[m_num] = handle; D3D12_CPU_DESCRIPTOR_HANDLE rtv = { rtvDescriptor.ptr + m_num * rtvDescriptorSize }; + + D3D12_RENDER_TARGET_VIEW_DESC desc; + desc.Format = texture.m_srvd.Format; + + switch (texture.m_type) + { + default: + case TextureD3D12::Texture2D: +// if (1 < msaa.Count) +// { +// desc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2DMS; +// } +// else + { + desc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D; + desc.Texture2D.MipSlice = m_attachment[ii].mip; + desc.Texture2D.PlaneSlice = 0; + } + break; + + case TextureD3D12::TextureCube: +// if (1 < msaa.Count) +// { +// desc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2DMSARRAY; +// desc.Texture2DMSArray.ArraySize = 1; +// desc.Texture2DMSArray.FirstArraySlice = m_attachment[ii].layer; +// } +// else + { + desc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2DARRAY; + desc.Texture2DArray.ArraySize = 1; + desc.Texture2DArray.FirstArraySlice = m_attachment[ii].layer; + desc.Texture2DArray.MipSlice = m_attachment[ii].mip; + desc.Texture2DArray.PlaneSlice = 0; + } + break; + + case TextureD3D12::Texture3D: + desc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE3D; + desc.Texture3D.MipSlice = m_attachment[ii].mip; + desc.Texture3D.WSize = 1; + desc.Texture3D.FirstWSlice = m_attachment[ii].layer; + break; + } + device->CreateRenderTargetView(texture.m_ptr - , NULL + , &desc , rtv ); m_num++; @@ -5223,8 +5268,8 @@ data.NumQualityLevels = 0; box.bottom = blit.m_srcY + height;; box.back = blit.m_srcZ + bx::uint32_imax(1, depth); - D3D12_TEXTURE_COPY_LOCATION dstLocation = { dst.m_ptr, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, {{0,{DXGI_FORMAT_UNKNOWN,0,0,0,0}}} }; - D3D12_TEXTURE_COPY_LOCATION srcLocation = { src.m_ptr, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, {{0,{DXGI_FORMAT_UNKNOWN,0,0,0,0}}} }; + D3D12_TEXTURE_COPY_LOCATION dstLocation = { dst.m_ptr, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, { { 0, { DXGI_FORMAT_UNKNOWN, 0, 0, 0, 0 } } } }; + D3D12_TEXTURE_COPY_LOCATION srcLocation = { src.m_ptr, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, { { 0, { DXGI_FORMAT_UNKNOWN, 0, 0, 0, 0 } } } }; m_commandList->CopyTextureRegion(&dstLocation , blit.m_dstX , blit.m_dstY