From ff52a00553ce6c8dc5398ff4eb9dd923d10ceada Mon Sep 17 00:00:00 2001 From: Jesse Natalie Date: Wed, 14 Jun 2023 15:54:00 -0700 Subject: [PATCH] dzn: Align placed footprints used when copying linear <-> optimal for BC formats Part-of: --- src/microsoft/vulkan/dzn_image.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/microsoft/vulkan/dzn_image.c b/src/microsoft/vulkan/dzn_image.c index 41784eebe37..407696cbece 100644 --- a/src/microsoft/vulkan/dzn_image.c +++ b/src/microsoft/vulkan/dzn_image.c @@ -157,8 +157,8 @@ dzn_image_create(struct dzn_device *device, D3D12_RESOURCE_DESC tmp_desc = { .Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D, .Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT, - .Width = ALIGN(image->vk.extent.width, util_format_get_blockwidth(pfmt)), - .Height = (UINT)ALIGN(image->vk.extent.height, util_format_get_blockheight(pfmt)), + .Width = ALIGN_POT(image->vk.extent.width, util_format_get_blockwidth(pfmt)), + .Height = (UINT)ALIGN_POT(image->vk.extent.height, util_format_get_blockheight(pfmt)), .DepthOrArraySize = 1, .MipLevels = 1, .Format = @@ -429,13 +429,17 @@ dzn_image_get_copy_loc(const struct dzn_image *image, if (image->desc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER) { assert((subres->baseArrayLayer + layer) == 0); assert(subres->mipLevel == 0); + enum pipe_format pfmt = vk_format_to_pipe_format(image->vk.format); + uint32_t blkw = util_format_get_blockwidth(pfmt); + uint32_t blkh = util_format_get_blockheight(pfmt); + uint32_t blkd = util_format_get_blockdepth(pfmt); loc.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT; loc.PlacedFootprint.Offset = 0; loc.PlacedFootprint.Footprint.Format = dzn_image_get_placed_footprint_format(pdev, image->vk.format, aspect); - loc.PlacedFootprint.Footprint.Width = image->vk.extent.width; - loc.PlacedFootprint.Footprint.Height = image->vk.extent.height; - loc.PlacedFootprint.Footprint.Depth = image->vk.extent.depth; + loc.PlacedFootprint.Footprint.Width = ALIGN_POT(image->vk.extent.width, blkw); + loc.PlacedFootprint.Footprint.Height = ALIGN_POT(image->vk.extent.height, blkh); + loc.PlacedFootprint.Footprint.Depth = ALIGN_POT(image->vk.extent.depth, blkd); loc.PlacedFootprint.Footprint.RowPitch = image->linear.row_stride; } else { loc.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;