[dxvk] Implement depth-stencil upload via temporary buffer

This commit is contained in:
Philip Rebohle 2019-03-26 17:48:57 +01:00
parent 0d889e0dcd
commit b3ea1b02eb
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 62 additions and 0 deletions

View File

@ -1776,6 +1776,46 @@ namespace dxvk {
}
void DxvkContext::updateDepthStencilImage(
const Rc<DxvkImage>& image,
const VkImageSubresourceLayers& subresources,
VkOffset2D imageOffset,
VkExtent2D imageExtent,
const void* data,
VkDeviceSize pitchPerRow,
VkDeviceSize pitchPerLayer,
VkFormat format) {
auto formatInfo = imageFormatInfo(format);
VkExtent3D extent3D;
extent3D.width = imageExtent.width;
extent3D.height = imageExtent.height;
extent3D.depth = subresources.layerCount;
VkDeviceSize pixelCount = extent3D.width * extent3D.height * extent3D.depth;
DxvkBufferCreateInfo tmpBufferInfo;
tmpBufferInfo.size = pixelCount * formatInfo->elementSize;
tmpBufferInfo.usage = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT;
tmpBufferInfo.stages = VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
tmpBufferInfo.access = VK_ACCESS_SHADER_READ_BIT;
auto tmpBuffer = m_device->createBuffer(tmpBufferInfo,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
util::packImageData(
reinterpret_cast<char*>(tmpBuffer->mapPtr(0)),
reinterpret_cast<const char*>(data),
extent3D, formatInfo->elementSize,
pitchPerRow, pitchPerLayer);
copyPackedBufferToDepthStencilImage(
image, subresources, imageOffset, imageExtent,
tmpBuffer, 0, format);
}
void DxvkContext::setViewports(
uint32_t viewportCount,
const VkViewport* viewports,

View File

@ -676,6 +676,28 @@ namespace dxvk {
VkDeviceSize pitchPerRow,
VkDeviceSize pitchPerLayer);
/**
* \brief Updates an depth-stencil image
*
* \param [in] image Destination image
* \param [in] subsresources Image subresources to update
* \param [in] imageOffset Offset of the image area to update
* \param [in] imageExtent Size of the image area to update
* \param [in] data Source data
* \param [in] pitchPerRow Row pitch of the source data
* \param [in] pitchPerLayer Layer pitch of the source data
* \param [in] format Packed depth-stencil format
*/
void updateDepthStencilImage(
const Rc<DxvkImage>& image,
const VkImageSubresourceLayers& subresources,
VkOffset2D imageOffset,
VkExtent2D imageExtent,
const void* data,
VkDeviceSize pitchPerRow,
VkDeviceSize pitchPerLayer,
VkFormat format);
/**
* \brief Sets viewports
*