aboutsummaryrefslogtreecommitdiff
path: root/layers/image.cpp
diff options
context:
space:
mode:
authorMark Lobodzinski <mark@lunarg.com>2016-11-22 11:18:46 -0700
committerMark Lobodzinski <mark@lunarg.com>2016-11-23 07:56:43 -0700
commit43402c8b9f2564be1c7e585d188355f6a7979f66 (patch)
tree59c0323682802fc25772062e5ea31ddf1de7532f /layers/image.cpp
parent914367de725ba6917456a7384921c231937fd7ae (diff)
downloadusermoji-43402c8b9f2564be1c7e585d188355f6a7979f66.tar.xz
layers: Moved image/buffer aspect check
Moved this validation check into a routine shared by both copyImageToBuffer and copyBufferToImage. Change-Id: If53581cb7dd847492f52b9c2c95b0be25654074f
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;
}