From 832f47edd3be8a4dc5acaf9f05f52fa1713ce89e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Thu, 24 Oct 2019 21:54:02 +0200 Subject: [PATCH] vkd3d: Clamp buffer image copy size to subresource dimensions. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes a vulkan validation error. Signed-off-by: RĂ©mi Bernon Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- libs/vkd3d/command.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c index 4338cd4e..c401349b 100644 --- a/libs/vkd3d/command.c +++ b/libs/vkd3d/command.c @@ -3091,17 +3091,24 @@ static void vk_buffer_image_copy_from_d3d12(VkBufferImageCopy *copy, copy->imageOffset.x = dst_x; copy->imageOffset.y = dst_y; copy->imageOffset.z = dst_z; + + vk_extent_3d_from_d3d12_miplevel(©->imageExtent, image_desc, + copy->imageSubresource.mipLevel); + copy->imageExtent.width -= copy->imageOffset.x; + copy->imageExtent.height -= copy->imageOffset.y; + copy->imageExtent.depth -= copy->imageOffset.z; + if (src_box) { - copy->imageExtent.width = src_box->right - src_box->left; - copy->imageExtent.height = src_box->bottom - src_box->top; - copy->imageExtent.depth = src_box->back - src_box->front; + copy->imageExtent.width = min(copy->imageExtent.width, src_box->right - src_box->left); + copy->imageExtent.height = min(copy->imageExtent.height, src_box->bottom - src_box->top); + copy->imageExtent.depth = min(copy->imageExtent.depth, src_box->back - src_box->front); } else { - copy->imageExtent.width = footprint->Footprint.Width; - copy->imageExtent.height = footprint->Footprint.Height; - copy->imageExtent.depth = footprint->Footprint.Depth; + copy->imageExtent.width = min(copy->imageExtent.width, footprint->Footprint.Width); + copy->imageExtent.height = min(copy->imageExtent.height, footprint->Footprint.Height); + copy->imageExtent.depth = min(copy->imageExtent.depth, footprint->Footprint.Depth); } }