From 302c6b5e6c6977203b5da53c9dac11f15e0d853f Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Tue, 26 Mar 2019 17:49:14 +0100 Subject: [PATCH] [d3d11] Implement depth-stencil uploads in resource initializer --- src/d3d11/d3d11_device.cpp | 2 +- src/d3d11/d3d11_initializer.cpp | 35 ++++++++++++++++++++++++--------- src/d3d11/d3d11_initializer.h | 5 ++++- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/d3d11/d3d11_device.cpp b/src/d3d11/d3d11_device.cpp index 09c34155e..ef07a6957 100644 --- a/src/d3d11/d3d11_device.cpp +++ b/src/d3d11/d3d11_device.cpp @@ -39,7 +39,7 @@ namespace dxvk { m_d3d11Formats (m_dxvkAdapter), m_d3d11Options (m_dxvkAdapter->instance()->config()), m_dxbcOptions (m_dxvkDevice, m_d3d11Options) { - m_initializer = new D3D11Initializer(m_dxvkDevice); + m_initializer = new D3D11Initializer(this); m_context = new D3D11ImmediateContext(this, m_dxvkDevice); m_d3d10Device = new D3D10Device(this, m_context); diff --git a/src/d3d11/d3d11_initializer.cpp b/src/d3d11/d3d11_initializer.cpp index fa958d065..25359679d 100644 --- a/src/d3d11/d3d11_initializer.cpp +++ b/src/d3d11/d3d11_initializer.cpp @@ -1,12 +1,15 @@ #include +#include "d3d11_device.h" #include "d3d11_initializer.h" namespace dxvk { D3D11Initializer::D3D11Initializer( - const Rc& Device) - : m_device(Device), m_context(m_device->createContext()) { + D3D11Device* pParent) + : m_parent(pParent), + m_device(pParent->GetDXVKDevice()), + m_context(m_device->createContext()) { m_context->beginRecording( m_device->createCommandList()); } @@ -104,6 +107,9 @@ namespace dxvk { Rc image = pTexture->GetImage(); + VkFormat packedFormat = m_parent->LookupPackedFormat( + pTexture->Desc()->Format, pTexture->GetFormatMode()).Format; + auto formatInfo = imageFormatInfo(image->info().format); if (pInitialData != nullptr && pInitialData->pSysMem != nullptr) { @@ -131,13 +137,24 @@ namespace dxvk { m_transferMemory += util::computeImageDataSize( image->info().format, mipLevelExtent); - m_context->updateImage( - image, subresourceLayers, - mipLevelOffset, - mipLevelExtent, - pInitialData[id].pSysMem, - pInitialData[id].SysMemPitch, - pInitialData[id].SysMemSlicePitch); + if (formatInfo->aspectMask != (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) { + m_context->updateImage( + image, subresourceLayers, + mipLevelOffset, + mipLevelExtent, + pInitialData[id].pSysMem, + pInitialData[id].SysMemPitch, + pInitialData[id].SysMemSlicePitch); + } else { + m_context->updateDepthStencilImage( + image, subresourceLayers, + VkOffset2D { mipLevelOffset.x, mipLevelOffset.y }, + VkExtent2D { mipLevelExtent.width, mipLevelExtent.height }, + pInitialData[id].pSysMem, + pInitialData[id].SysMemPitch, + pInitialData[id].SysMemSlicePitch, + packedFormat); + } } } } else { diff --git a/src/d3d11/d3d11_initializer.h b/src/d3d11/d3d11_initializer.h index c4b82d353..96a094d6a 100644 --- a/src/d3d11/d3d11_initializer.h +++ b/src/d3d11/d3d11_initializer.h @@ -5,6 +5,8 @@ namespace dxvk { + class D3D11Device; + /** * \brief Resource initialization context * @@ -19,7 +21,7 @@ namespace dxvk { public: D3D11Initializer( - const Rc& Device); + D3D11Device* pParent); ~D3D11Initializer(); @@ -37,6 +39,7 @@ namespace dxvk { std::mutex m_mutex; + D3D11Device* m_parent; Rc m_device; Rc m_context;