aboutsummaryrefslogtreecommitdiff
path: root/layers/buffer_validation.cpp
diff options
context:
space:
mode:
authorCort Stratton <cort@google.com>2018-05-04 01:12:23 -0400
committerTobin Ehlis <tobine@google.com>2018-05-04 13:37:14 -0600
commit425391e45e0d53cf7454782dd5261deea12a5989 (patch)
treedb839e654d551bc4ebd9cb2dca98e0efc16250f0 /layers/buffer_validation.cpp
parent014e35bacc908d9dc71d9cff2f6bbad81c452d66 (diff)
downloadusermoji-425391e45e0d53cf7454782dd5261deea12a5989.tar.xz
layers: image transfer granularity check fixes
- Use appropriate VUIDs for all checks - Update tests to check for VUIDs instead of message substrings - Image granularity tests should be also be run on compressed images. They're *mostly* redundant with existing compressed-format-only checks, but I can't convince myself that they're *always* redundant, and the spec doesn't say to skip them. - Removed comments that the checks should be moved elsewhere; IMO they're fine where they are, but I welcome second opinions. - Compressed-format alignment checks should also apply to _422 single-plane formats.
Diffstat (limited to 'layers/buffer_validation.cpp')
-rw-r--r--layers/buffer_validation.cpp61
1 files changed, 24 insertions, 37 deletions
diff --git a/layers/buffer_validation.cpp b/layers/buffer_validation.cpp
index 330e187b..6605b606 100644
--- a/layers/buffer_validation.cpp
+++ b/layers/buffer_validation.cpp
@@ -1297,7 +1297,8 @@ static inline bool IsExtentAligned(const VkExtent3D *extent, const VkExtent3D *g
// Check elements of a VkOffset3D structure against a queue family's Image Transfer Granularity values
static inline bool CheckItgOffset(layer_data *device_data, const GLOBAL_CB_NODE *cb_node, const VkOffset3D *offset,
- const VkExtent3D *granularity, const uint32_t i, const char *function, const char *member) {
+ const VkExtent3D *granularity, const uint32_t i, const char *function, const char *member,
+ UNIQUE_VALIDATION_ERROR_CODE vuid) {
const debug_report_data *report_data = core_validation::GetReportData(device_data);
bool skip = false;
VkExtent3D offset_extent = {};
@@ -1308,7 +1309,7 @@ static inline bool CheckItgOffset(layer_data *device_data, const GLOBAL_CB_NODE
// If the queue family image transfer granularity is (0, 0, 0), then the offset must always be (0, 0, 0)
if (IsExtentAllZeroes(&offset_extent) == false) {
skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
- HandleToUint64(cb_node->commandBuffer), DRAWSTATE_IMAGE_TRANSFER_GRANULARITY,
+ HandleToUint64(cb_node->commandBuffer), vuid,
"%s: pRegion[%d].%s (x=%d, y=%d, z=%d) must be (x=0, y=0, z=0) when the command buffer's queue family "
"image transfer granularity is (w=0, h=0, d=0).",
function, i, member, offset->x, offset->y, offset->z);
@@ -1318,7 +1319,7 @@ static inline bool CheckItgOffset(layer_data *device_data, const GLOBAL_CB_NODE
// integer multiples of the image transfer granularity.
if (IsExtentAligned(&offset_extent, granularity) == false) {
skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
- HandleToUint64(cb_node->commandBuffer), DRAWSTATE_IMAGE_TRANSFER_GRANULARITY,
+ HandleToUint64(cb_node->commandBuffer), vuid,
"%s: pRegion[%d].%s (x=%d, y=%d, z=%d) dimensions must be even integer multiples of this command "
"buffer's queue family image transfer granularity (w=%d, h=%d, d=%d).",
function, i, member, offset->x, offset->y, offset->z, granularity->width, granularity->height,
@@ -1331,7 +1332,8 @@ static inline bool CheckItgOffset(layer_data *device_data, const GLOBAL_CB_NODE
// Check elements of a VkExtent3D structure against a queue family's Image Transfer Granularity values
static inline bool CheckItgExtent(layer_data *device_data, const GLOBAL_CB_NODE *cb_node, const VkExtent3D *extent,
const VkOffset3D *offset, const VkExtent3D *granularity, const VkExtent3D *subresource_extent,
- const VkImageType image_type, const uint32_t i, const char *function, const char *member) {
+ const VkImageType image_type, const uint32_t i, const char *function, const char *member,
+ UNIQUE_VALIDATION_ERROR_CODE vuid) {
const debug_report_data *report_data = core_validation::GetReportData(device_data);
bool skip = false;
if (IsExtentAllZeroes(granularity)) {
@@ -1339,7 +1341,7 @@ static inline bool CheckItgExtent(layer_data *device_data, const GLOBAL_CB_NODE
// subresource extent.
if (IsExtentEqual(extent, subresource_extent) == false) {
skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
- HandleToUint64(cb_node->commandBuffer), DRAWSTATE_IMAGE_TRANSFER_GRANULARITY,
+ HandleToUint64(cb_node->commandBuffer), vuid,
"%s: pRegion[%d].%s (w=%d, h=%d, d=%d) must match the image subresource extents (w=%d, h=%d, d=%d) "
"when the command buffer's queue family image transfer granularity is (w=0, h=0, d=0).",
function, i, member, extent->width, extent->height, extent->depth, subresource_extent->width,
@@ -1375,7 +1377,7 @@ static inline bool CheckItgExtent(layer_data *device_data, const GLOBAL_CB_NODE
}
if (!(x_ok && y_ok && z_ok)) {
skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
- HandleToUint64(cb_node->commandBuffer), DRAWSTATE_IMAGE_TRANSFER_GRANULARITY,
+ HandleToUint64(cb_node->commandBuffer), vuid,
"%s: pRegion[%d].%s (w=%d, h=%d, d=%d) dimensions must be even integer multiples of this command "
"buffer's queue family image transfer granularity (w=%d, h=%d, d=%d) or offset (x=%d, y=%d, z=%d) + "
"extent (w=%d, h=%d, d=%d) must match the image subresource extents (w=%d, h=%d, d=%d).",
@@ -1390,28 +1392,14 @@ static inline bool CheckItgExtent(layer_data *device_data, const GLOBAL_CB_NODE
// Check valid usage Image Transfer Granularity requirements for elements of a VkBufferImageCopy structure
bool ValidateCopyBufferImageTransferGranularityRequirements(layer_data *device_data, const GLOBAL_CB_NODE *cb_node,
const IMAGE_STATE *img, const VkBufferImageCopy *region,
- const uint32_t i, const char *function) {
+ const uint32_t i, const char *function,
+ UNIQUE_VALIDATION_ERROR_CODE vuid) {
bool skip = false;
- if (FormatIsCompressed(img->createInfo.format) == true) {
- // TODO: Add granularity checking for compressed formats
-
- // bufferRowLength must be a multiple of the compressed texel block width
- // bufferImageHeight must be a multiple of the compressed texel block height
- // all members of imageOffset must be a multiple of the corresponding dimensions of the compressed texel block
- // bufferOffset must be a multiple of the compressed texel block size in bytes
- // imageExtent.width must be a multiple of the compressed texel block width or (imageExtent.width + imageOffset.x)
- // must equal the image subresource width
- // imageExtent.height must be a multiple of the compressed texel block height or (imageExtent.height + imageOffset.y)
- // must equal the image subresource height
- // imageExtent.depth must be a multiple of the compressed texel block depth or (imageExtent.depth + imageOffset.z)
- // must equal the image subresource depth
- } else {
- VkExtent3D granularity = GetScaledItg(device_data, cb_node, img);
- skip |= CheckItgOffset(device_data, cb_node, &region->imageOffset, &granularity, i, function, "imageOffset");
- VkExtent3D subresource_extent = GetImageSubresourceExtent(img, &region->imageSubresource);
- skip |= CheckItgExtent(device_data, cb_node, &region->imageExtent, &region->imageOffset, &granularity, &subresource_extent,
- img->createInfo.imageType, i, function, "imageExtent");
- }
+ VkExtent3D granularity = GetScaledItg(device_data, cb_node, img);
+ skip |= CheckItgOffset(device_data, cb_node, &region->imageOffset, &granularity, i, function, "imageOffset", vuid);
+ VkExtent3D subresource_extent = GetImageSubresourceExtent(img, &region->imageSubresource);
+ skip |= CheckItgExtent(device_data, cb_node, &region->imageExtent, &region->imageOffset, &granularity, &subresource_extent,
+ img->createInfo.imageType, i, function, "imageExtent", vuid);
return skip;
}
@@ -1422,21 +1410,23 @@ bool ValidateCopyImageTransferGranularityRequirements(layer_data *device_data, c
bool skip = false;
// Source image checks
VkExtent3D granularity = GetScaledItg(device_data, cb_node, src_img);
- skip |= CheckItgOffset(device_data, cb_node, &region->srcOffset, &granularity, i, function, "srcOffset");
+ skip |=
+ CheckItgOffset(device_data, cb_node, &region->srcOffset, &granularity, i, function, "srcOffset", VALIDATION_ERROR_19000dee);
VkExtent3D subresource_extent = GetImageSubresourceExtent(src_img, &region->srcSubresource);
const VkExtent3D extent = region->extent;
skip |= CheckItgExtent(device_data, cb_node, &extent, &region->srcOffset, &granularity, &subresource_extent,
- src_img->createInfo.imageType, i, function, "extent");
+ src_img->createInfo.imageType, i, function, "extent", VALIDATION_ERROR_19000dee);
// Destination image checks
granularity = GetScaledItg(device_data, cb_node, dst_img);
- skip |= CheckItgOffset(device_data, cb_node, &region->dstOffset, &granularity, i, function, "dstOffset");
+ skip |=
+ CheckItgOffset(device_data, cb_node, &region->dstOffset, &granularity, i, function, "dstOffset", VALIDATION_ERROR_19000df0);
// Adjust dest extent, if necessary
const VkExtent3D dest_effective_extent =
GetAdjustedDestImageExtent(src_img->createInfo.format, dst_img->createInfo.format, extent);
subresource_extent = GetImageSubresourceExtent(dst_img, &region->dstSubresource);
skip |= CheckItgExtent(device_data, cb_node, &dest_effective_extent, &region->dstOffset, &granularity, &subresource_extent,
- dst_img->createInfo.imageType, i, function, "extent");
+ dst_img->createInfo.imageType, i, function, "extent", VALIDATION_ERROR_19000df0);
return skip;
}
@@ -3766,10 +3756,7 @@ bool ValidateBufferImageCopyData(const debug_report_data *report_data, uint32_t
}
// Checks that apply only to compressed images
- // TODO: there is a comment in ValidateCopyBufferImageTransferGranularityRequirements() in core_validation.cpp that
- // reserves a place for these compressed image checks. This block of code could move there once the image
- // stuff is moved into core validation.
- if (FormatIsCompressed(image_state->createInfo.format)) {
+ if (FormatIsCompressed(image_state->createInfo.format) || FormatIsSinglePlane_422(image_state->createInfo.format)) {
auto block_size = FormatCompressedTexelBlockExtent(image_state->createInfo.format);
// BufferRowLength must be a multiple of block width
@@ -4000,7 +3987,7 @@ bool PreCallValidateCmdCopyImageToBuffer(layer_data *device_data, VkImageLayout
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, "vkCmdCopyImageToBuffer()", VALIDATION_ERROR_1920017c,
&hit_error);
skip |= ValidateCopyBufferImageTransferGranularityRequirements(device_data, cb_node, src_image_state, &pRegions[i], i,
- "vkCmdCopyImageToBuffer()");
+ "vkCmdCopyImageToBuffer()", VALIDATION_ERROR_19200e04);
}
return skip;
}
@@ -4054,7 +4041,7 @@ bool PreCallValidateCmdCopyBufferToImage(layer_data *device_data, VkImageLayout
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, "vkCmdCopyBufferToImage()", VALIDATION_ERROR_18e0016a,
&hit_error);
skip |= ValidateCopyBufferImageTransferGranularityRequirements(device_data, cb_node, dst_image_state, &pRegions[i], i,
- "vkCmdCopyBufferToImage()");
+ "vkCmdCopyBufferToImage()", VALIDATION_ERROR_18e00e02);
}
return skip;
}