From c04ef0b2d87b0db0d4ec98c31db1f6b95ac71191 Mon Sep 17 00:00:00 2001 From: Mark Lobodzinski Date: Tue, 22 Nov 2016 14:46:39 -0700 Subject: layers: GH1182, Validate VkBufferImageCopy depth Validate that for buffer<-->image copies that (for 1D and 2D image types) the offset is 0 and the depth is 1. Change-Id: I8114ce78be926411a2938148bf4c60d86006f8a4 --- layers/image.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'layers/image.cpp') diff --git a/layers/image.cpp b/layers/image.cpp index 93574ca7..a07e7b3b 100644 --- a/layers/image.cpp +++ b/layers/image.cpp @@ -851,6 +851,18 @@ static bool ValidateBufferImageCopyData(layer_data *dev_data, uint32_t regionCou auto image_info = getImageState(dev_data, image); if (image_info) { + + if ((image_info->imageType == VK_IMAGE_TYPE_1D) || (image_info->imageType == VK_IMAGE_TYPE_2D)) { + if ((pRegions[i].imageOffset.z != 0) || (pRegions[i].imageExtent.depth != 1)) { + skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, + reinterpret_cast(image), __LINE__, VALIDATION_ERROR_01269, "IMAGE", + "%s(): pRegion[%d] imageOffset.z is %d and imageExtent.depth is %d. These must be 0 and 1, " + "respectively. %s", + function, i, pRegions[i].imageOffset.z, pRegions[i].imageExtent.depth, + validation_error_map[VALIDATION_ERROR_01269]); + } + } + // BufferOffset must be a multiple of the calling command's VkImage parameter's texel size auto texel_size = vk_format_get_size(image_info->format); if (vk_safe_modulo(pRegions[i].bufferOffset, texel_size) != 0) { @@ -860,6 +872,7 @@ static bool ValidateBufferImageCopyData(layer_data *dev_data, uint32_t regionCou " must be a multiple of this format's texel size (" PRINTF_SIZE_T_SPECIFIER "). %s", function, i, pRegions[i].bufferOffset, texel_size, validation_error_map[VALIDATION_ERROR_01263]); } + // BufferOffset must be a multiple of 4 if (vk_safe_modulo(pRegions[i].bufferOffset, 4) != 0) { skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, -- cgit v1.2.3