diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index cc2871063..fa0d1fb73 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -432,145 +432,6 @@ namespace dxvk { } - void DxvkContext::clearColorImage( - const Rc& image, - const VkClearColorValue& value, - const VkImageSubresourceRange& subresources) { - this->spillRenderPass(false); - - VkImageLayout imageLayoutClear = image->pickLayout(VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); - - this->initializeImage(image, subresources, - imageLayoutClear, - VK_PIPELINE_STAGE_TRANSFER_BIT, - VK_ACCESS_TRANSFER_WRITE_BIT); - - m_execAcquires.recordCommands(m_cmd); - - m_cmd->cmdClearColorImage(image->handle(), - imageLayoutClear, &value, 1, &subresources); - - m_execBarriers.accessImage(image, subresources, - imageLayoutClear, - VK_PIPELINE_STAGE_TRANSFER_BIT, - VK_ACCESS_TRANSFER_WRITE_BIT, - image->info().layout, - image->info().stages, - image->info().access); - - m_cmd->trackResource(image); - } - - - void DxvkContext::clearDepthStencilImage( - const Rc& image, - const VkClearDepthStencilValue& value, - const VkImageSubresourceRange& subresources) { - this->spillRenderPass(false); - - m_execBarriers.recordCommands(m_cmd); - - VkImageLayout imageLayoutClear = image->pickLayout(VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); - - this->initializeImage(image, subresources, - imageLayoutClear, - VK_PIPELINE_STAGE_TRANSFER_BIT, - VK_ACCESS_TRANSFER_WRITE_BIT); - - m_execAcquires.recordCommands(m_cmd); - - m_cmd->cmdClearDepthStencilImage(image->handle(), - imageLayoutClear, &value, 1, &subresources); - - m_execBarriers.accessImage( - image, subresources, - imageLayoutClear, - VK_PIPELINE_STAGE_TRANSFER_BIT, - VK_ACCESS_TRANSFER_WRITE_BIT, - image->info().layout, - image->info().stages, - image->info().access); - - m_cmd->trackResource(image); - } - - - void DxvkContext::clearCompressedColorImage( - const Rc& image, - const VkImageSubresourceRange& subresources) { - this->spillRenderPass(false); - - VkImageLayout layout = image->pickLayout(VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); - - this->initializeImage(image, subresources, layout, - VK_PIPELINE_STAGE_TRANSFER_BIT, - VK_ACCESS_TRANSFER_WRITE_BIT); - - m_execAcquires.recordCommands(m_cmd); - - auto formatInfo = image->formatInfo(); - - for (auto aspects = formatInfo->aspectMask; aspects; ) { - auto aspect = vk::getNextAspect(aspects); - auto extent = image->mipLevelExtent(subresources.baseMipLevel); - auto elementSize = formatInfo->elementSize; - - if (formatInfo->flags.test(DxvkFormatFlag::MultiPlane)) { - auto plane = &formatInfo->planes[vk::getPlaneIndex(aspect)]; - extent.width /= plane->blockSize.width; - extent.height /= plane->blockSize.height; - elementSize = plane->elementSize; - } - - // Allocate enough staging buffer memory to fit one - // single subresource, then dispatch multiple copies - VkExtent3D blockCount = util::computeBlockCount(extent, formatInfo->blockSize); - VkDeviceSize dataSize = util::flattenImageExtent(blockCount) * elementSize; - - auto zeroBuffer = createZeroBuffer(dataSize); - auto zeroHandle = zeroBuffer->getSliceHandle(); - - for (uint32_t level = 0; level < subresources.levelCount; level++) { - VkOffset3D offset = VkOffset3D { 0, 0, 0 }; - VkExtent3D extent = image->mipLevelExtent(subresources.baseMipLevel + level); - - if (formatInfo->flags.test(DxvkFormatFlag::MultiPlane)) { - auto plane = &formatInfo->planes[vk::getPlaneIndex(aspect)]; - extent.width /= plane->blockSize.width; - extent.height /= plane->blockSize.height; - } - - for (uint32_t layer = 0; layer < subresources.layerCount; layer++) { - VkBufferImageCopy region; - region.bufferOffset = zeroHandle.offset; - region.bufferRowLength = 0; - region.bufferImageHeight = 0; - region.imageSubresource = vk::makeSubresourceLayers( - vk::pickSubresource(subresources, level, layer)); - region.imageSubresource.aspectMask = aspect; - region.imageOffset = offset; - region.imageExtent = extent; - - m_cmd->cmdCopyBufferToImage(DxvkCmdBuffer::ExecBuffer, - zeroHandle.handle, image->handle(), layout, 1, ®ion); - } - } - - m_cmd->trackResource(zeroBuffer); - } - - m_execBarriers.accessImage( - image, subresources, layout, - VK_PIPELINE_STAGE_TRANSFER_BIT, - VK_ACCESS_TRANSFER_WRITE_BIT, - image->info().layout, - image->info().stages, - image->info().access); - - m_cmd->trackResource(image); - } - - void DxvkContext::clearRenderTarget( const Rc& imageView, VkImageAspectFlags clearAspects, @@ -5272,26 +5133,6 @@ namespace dxvk { } - void DxvkContext::initializeImage( - const Rc& image, - const VkImageSubresourceRange& subresources, - VkImageLayout dstLayout, - VkPipelineStageFlags dstStages, - VkAccessFlags dstAccess) { - if (m_execBarriers.isImageDirty(image, subresources, DxvkAccess::Write)) - m_execBarriers.recordCommands(m_cmd); - - VkPipelineStageFlags srcStages = 0; - - if (image->isInUse()) - srcStages = dstStages; - - m_execAcquires.accessImage(image, subresources, - VK_IMAGE_LAYOUT_UNDEFINED, srcStages, 0, - dstLayout, dstStages, dstAccess); - } - - VkDescriptorSet DxvkContext::allocateDescriptorSet( VkDescriptorSetLayout layout) { if (m_descPool == nullptr) diff --git a/src/dxvk/dxvk_context.h b/src/dxvk/dxvk_context.h index 6282750d4..b52143abe 100644 --- a/src/dxvk/dxvk_context.h +++ b/src/dxvk/dxvk_context.h @@ -240,40 +240,6 @@ namespace dxvk { VkDeviceSize length, VkClearColorValue value); - /** - * \brief Clears subresources of a color image - * - * \param [in] image The image to clear - * \param [in] value Clear value - * \param [in] subresources Subresources to clear - */ - void clearColorImage( - const Rc& image, - const VkClearColorValue& value, - const VkImageSubresourceRange& subresources); - - /** - * \brief Clears subresources of a depth-stencil image - * - * \param [in] image The image to clear - * \param [in] value Clear value - * \param [in] subresources Subresources to clear - */ - void clearDepthStencilImage( - const Rc& image, - const VkClearDepthStencilValue& value, - const VkImageSubresourceRange& subresources); - - /** - * \brief Clears a compressed image to black - * - * \param [in] image The image to clear - * \param [in] subresources Subresources to clear - */ - void clearCompressedColorImage( - const Rc& image, - const VkImageSubresourceRange& subresources); - /** * \brief Clears an active render target * @@ -1321,13 +1287,6 @@ namespace dxvk { VkPipelineStageFlags dstStages, VkAccessFlags dstAccess); - void initializeImage( - const Rc& image, - const VkImageSubresourceRange& subresources, - VkImageLayout dstLayout, - VkPipelineStageFlags dstStages, - VkAccessFlags dstAccess); - VkDescriptorSet allocateDescriptorSet( VkDescriptorSetLayout layout);