mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-15 07:29:17 +01:00
[dxvk] Support multi-plane formats in clearCompressedColorImage
This commit is contained in:
parent
ed57019e13
commit
a660b35f6e
@ -500,15 +500,6 @@ namespace dxvk {
|
|||||||
const VkImageSubresourceRange& subresources) {
|
const VkImageSubresourceRange& subresources) {
|
||||||
this->spillRenderPass(false);
|
this->spillRenderPass(false);
|
||||||
|
|
||||||
// Allocate enough staging buffer memory to fit one
|
|
||||||
// single subresource, then dispatch multiple copies
|
|
||||||
VkDeviceSize dataSize = util::computeImageDataSize(
|
|
||||||
image->info().format,
|
|
||||||
image->mipLevelExtent(subresources.baseMipLevel));
|
|
||||||
|
|
||||||
auto zeroBuffer = createZeroBuffer(dataSize);
|
|
||||||
auto zeroHandle = zeroBuffer->getSliceHandle();
|
|
||||||
|
|
||||||
VkImageLayout layout = image->pickLayout(VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
VkImageLayout layout = image->pickLayout(VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
||||||
|
|
||||||
this->initializeImage(image, subresources, layout,
|
this->initializeImage(image, subresources, layout,
|
||||||
@ -517,10 +508,38 @@ namespace dxvk {
|
|||||||
|
|
||||||
m_execAcquires.recordCommands(m_cmd);
|
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++) {
|
for (uint32_t level = 0; level < subresources.levelCount; level++) {
|
||||||
VkOffset3D offset = VkOffset3D { 0, 0, 0 };
|
VkOffset3D offset = VkOffset3D { 0, 0, 0 };
|
||||||
VkExtent3D extent = image->mipLevelExtent(subresources.baseMipLevel + level);
|
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++) {
|
for (uint32_t layer = 0; layer < subresources.layerCount; layer++) {
|
||||||
VkBufferImageCopy region;
|
VkBufferImageCopy region;
|
||||||
region.bufferOffset = zeroHandle.offset;
|
region.bufferOffset = zeroHandle.offset;
|
||||||
@ -528,6 +547,7 @@ namespace dxvk {
|
|||||||
region.bufferImageHeight = 0;
|
region.bufferImageHeight = 0;
|
||||||
region.imageSubresource = vk::makeSubresourceLayers(
|
region.imageSubresource = vk::makeSubresourceLayers(
|
||||||
vk::pickSubresource(subresources, level, layer));
|
vk::pickSubresource(subresources, level, layer));
|
||||||
|
region.imageSubresource.aspectMask = aspect;
|
||||||
region.imageOffset = offset;
|
region.imageOffset = offset;
|
||||||
region.imageExtent = extent;
|
region.imageExtent = extent;
|
||||||
|
|
||||||
@ -536,6 +556,9 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_cmd->trackResource<DxvkAccess::Read>(zeroBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
m_execBarriers.accessImage(
|
m_execBarriers.accessImage(
|
||||||
image, subresources, layout,
|
image, subresources, layout,
|
||||||
VK_PIPELINE_STAGE_TRANSFER_BIT,
|
VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||||
@ -545,7 +568,6 @@ namespace dxvk {
|
|||||||
image->info().access);
|
image->info().access);
|
||||||
|
|
||||||
m_cmd->trackResource<DxvkAccess::Write>(image);
|
m_cmd->trackResource<DxvkAccess::Write>(image);
|
||||||
m_cmd->trackResource<DxvkAccess::Read>(zeroBuffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user