aboutsummaryrefslogtreecommitdiff
path: root/layers/image.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'layers/image.cpp')
-rw-r--r--layers/image.cpp28
1 files changed, 12 insertions, 16 deletions
diff --git a/layers/image.cpp b/layers/image.cpp
index 536932bd..242c0a6a 100644
--- a/layers/image.cpp
+++ b/layers/image.cpp
@@ -32,8 +32,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <limits.h>
#include <unordered_map>
#include <vector>
+#include <bitset>
#include "vk_loader_platform.h"
#include "vk_dispatch_table_helper.h"
@@ -885,6 +887,16 @@ static bool ValidateBufferImageCopyData(layer_data *dev_data, uint32_t regionCou
function, i, pRegions[i].bufferImageHeight, pRegions[i].imageExtent.height,
validation_error_map[VALIDATION_ERROR_01266]);
}
+
+ const int num_bits = sizeof(VkFlags) * CHAR_BIT;
+ std::bitset<num_bits> aspect_mask_bits (pRegions[i].imageSubresource.aspectMask);
+ if (aspect_mask_bits.count() != 1) {
+ skip |=
+ log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
+ reinterpret_cast<uint64_t &>(image), __LINE__, VALIDATION_ERROR_01280, "IMAGE",
+ "%s: aspectMasks for imageSubresource in each region must have only a single bit set. %s", function,
+ validation_error_map[VALIDATION_ERROR_01280]);
+ }
}
}
@@ -907,14 +919,6 @@ static bool PreCallValidateCmdCopyImageToBuffer(layer_data *dev_data, VkCommandB
skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
(uint64_t)commandBuffer, __LINE__, IMAGE_MISMATCHED_IMAGE_ASPECT, "IMAGE", str);
}
-
- VkImageAspectFlags aspectMask = pRegions[i].imageSubresource.aspectMask;
- if ((aspectMask != VK_IMAGE_ASPECT_COLOR_BIT) && (aspectMask != VK_IMAGE_ASPECT_DEPTH_BIT) &&
- (aspectMask != VK_IMAGE_ASPECT_STENCIL_BIT)) {
- char const str[] = "vkCmdCopyImageToBuffer: aspectMasks for each region must specify only COLOR or DEPTH or STENCIL";
- skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
- (uint64_t)commandBuffer, __LINE__, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", str);
- }
}
return skip;
}
@@ -946,14 +950,6 @@ static bool PreCallValidateCmdCopyBufferToImage(layer_data *dev_data, VkCommandB
skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
(uint64_t)commandBuffer, __LINE__, IMAGE_MISMATCHED_IMAGE_ASPECT, "IMAGE", str);
}
-
- VkImageAspectFlags aspectMask = pRegions[i].imageSubresource.aspectMask;
- if ((aspectMask != VK_IMAGE_ASPECT_COLOR_BIT) && (aspectMask != VK_IMAGE_ASPECT_DEPTH_BIT) &&
- (aspectMask != VK_IMAGE_ASPECT_STENCIL_BIT)) {
- char const str[] = "vkCmdCopyBufferToImage: aspectMasks for each region must specify only COLOR or DEPTH or STENCIL";
- skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
- (uint64_t)commandBuffer, __LINE__, IMAGE_INVALID_IMAGE_ASPECT, "IMAGE", str);
- }
}
return skip;
}