aboutsummaryrefslogtreecommitdiff
path: root/layers/core_validation.cpp
diff options
context:
space:
mode:
authorMark Lobodzinski <mark@lunarg.com>2017-02-07 17:20:06 -0700
committerMark Lobodzinski <mark@lunarg.com>2017-02-08 10:25:28 -0700
commit9130c607fe15aa36d209ef9fc694ecf5cbe2178f (patch)
treec07251575023462b878cad9b70a12cf53be5eba1 /layers/core_validation.cpp
parent33128800424932d91b06b574e05b91d89f9cedf2 (diff)
downloadusermoji-9130c607fe15aa36d209ef9fc694ecf5cbe2178f.tar.xz
layers: Move ValidateMapImageLayouts out of CV
Change-Id: Ib9d9c169b1306a7ed6f243bbb957719305340a2e
Diffstat (limited to 'layers/core_validation.cpp')
-rw-r--r--layers/core_validation.cpp34
1 files changed, 2 insertions, 32 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp
index 60431051..3f3bed4b 100644
--- a/layers/core_validation.cpp
+++ b/layers/core_validation.cpp
@@ -5295,7 +5295,7 @@ static bool rangesIntersect(layer_data const *dev_data, MEMORY_RANGE const *rang
return true;
}
// Simplified rangesIntersect that calls above function to check range1 for intersection with offset & end addresses
-static bool rangesIntersect(layer_data const *dev_data, MEMORY_RANGE const *range1, VkDeviceSize offset, VkDeviceSize end) {
+bool rangesIntersect(layer_data const *dev_data, MEMORY_RANGE const *range1, VkDeviceSize offset, VkDeviceSize end) {
// Create a local MEMORY_RANGE struct to wrap offset/size
MEMORY_RANGE range_wrap;
// Synch linear with range1 to avoid padding and potential validation error case
@@ -10381,36 +10381,6 @@ VKAPI_ATTR void VKAPI_CALL CmdExecuteCommands(VkCommandBuffer commandBuffer, uin
if (!skip_call) dev_data->dispatch_table.CmdExecuteCommands(commandBuffer, commandBuffersCount, pCommandBuffers);
}
-// For any image objects that overlap mapped memory, verify that their layouts are PREINIT or GENERAL
-static bool ValidateMapImageLayouts(VkDevice device, DEVICE_MEM_INFO const *mem_info, VkDeviceSize offset,
- VkDeviceSize end_offset) {
- bool skip_call = false;
- layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
- // Iterate over all bound image ranges and verify that for any that overlap the
- // map ranges, the layouts are VK_IMAGE_LAYOUT_PREINITIALIZED or VK_IMAGE_LAYOUT_GENERAL
- // TODO : This can be optimized if we store ranges based on starting address and early exit when we pass our range
- for (auto image_handle : mem_info->bound_images) {
- auto img_it = mem_info->bound_ranges.find(image_handle);
- if (img_it != mem_info->bound_ranges.end()) {
- if (rangesIntersect(dev_data, &img_it->second, offset, end_offset)) {
- std::vector<VkImageLayout> layouts;
- if (FindLayouts(dev_data, VkImage(image_handle), layouts)) {
- for (auto layout : layouts) {
- if (layout != VK_IMAGE_LAYOUT_PREINITIALIZED && layout != VK_IMAGE_LAYOUT_GENERAL) {
- skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT,
- (VkDebugReportObjectTypeEXT)0, 0, __LINE__, DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS",
- "Cannot map an image with layout %s. Only "
- "GENERAL or PREINITIALIZED are supported.",
- string_VkImageLayout(layout));
- }
- }
- }
- }
- }
- }
- return skip_call;
-}
-
VKAPI_ATTR VkResult VKAPI_CALL MapMemory(VkDevice device, VkDeviceMemory mem, VkDeviceSize offset, VkDeviceSize size, VkFlags flags,
void **ppData) {
layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
@@ -10423,7 +10393,7 @@ VKAPI_ATTR VkResult VKAPI_CALL MapMemory(VkDevice device, VkDeviceMemory mem, Vk
// TODO : This could me more fine-grained to track just region that is valid
mem_info->global_valid = true;
auto end_offset = (VK_WHOLE_SIZE == size) ? mem_info->alloc_info.allocationSize - 1 : offset + size - 1;
- skip_call |= ValidateMapImageLayouts(device, mem_info, offset, end_offset);
+ skip_call |= ValidateMapImageLayouts(dev_data, device, mem_info, offset, end_offset);
// TODO : Do we need to create new "bound_range" for the mapped range?
SetMemRangesValid(dev_data, mem_info, offset, end_offset);
if ((dev_data->phys_dev_mem_props.memoryTypes[mem_info->alloc_info.memoryTypeIndex].propertyFlags &