aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Barbour <tony@LunarG.com>2018-04-19 11:41:36 -0600
committerTony-LunarG <tony@lunarg.com>2018-04-20 10:14:20 -0600
commit99b0d0c37e6e014272397756b1ae13034aa9fc0b (patch)
treed91c6b2bae8e9c7167fc2e7d0ebacb6c892bed10
parentac70234a5e4d8299ed1c8a5bb90227b57675387d (diff)
downloadusermoji-99b0d0c37e6e014272397756b1ae13034aa9fc0b.tar.xz
layers: Validate against nonCoherentAtomSize
FlushMappedMemoryRanges and InvalidateMappedMemoryRanges check size and offset against nonCoherentAtomSize. Github issues 329 & 2584 Gitlab Issue 611 Change-Id: I4cbc6c21f6fe4b6187b381b2565a90c61417bee5
-rw-r--r--layers/core_validation.cpp7
-rw-r--r--layers/vk_validation_error_database.txt2
2 files changed, 7 insertions, 2 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp
index a798cc62..30d6f3cb 100644
--- a/layers/core_validation.cpp
+++ b/layers/core_validation.cpp
@@ -9803,7 +9803,10 @@ static bool ValidateMappedMemoryRangeDeviceLimits(layer_data *dev_data, const ch
", which is not a multiple of VkPhysicalDeviceLimits::nonCoherentAtomSize (0x%" PRIxLEAST64 ").",
func_name, i, mem_ranges[i].offset, atom_size);
}
- if ((mem_ranges[i].size != VK_WHOLE_SIZE) && (SafeModulo(mem_ranges[i].size, atom_size) != 0)) {
+ auto mem_info = GetMemObjInfo(dev_data, mem_ranges[i].memory);
+ if ((mem_ranges[i].size != VK_WHOLE_SIZE) &&
+ (mem_ranges[i].size + mem_ranges[i].offset != mem_info->alloc_info.allocationSize) &&
+ (SafeModulo(mem_ranges[i].size, atom_size) != 0)) {
skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT,
HandleToUint64(mem_ranges->memory), VALIDATION_ERROR_0c200adc,
"%s: Size in pMemRanges[%d] is 0x%" PRIxLEAST64
@@ -9818,6 +9821,7 @@ static bool PreCallValidateFlushMappedMemoryRanges(layer_data *dev_data, uint32_
const VkMappedMemoryRange *mem_ranges) {
bool skip = false;
lock_guard_t lock(global_lock);
+ skip |= ValidateMappedMemoryRangeDeviceLimits(dev_data, "vkFlushMappedMemoryRanges", mem_range_count, mem_ranges);
skip |= ValidateAndCopyNoncoherentMemoryToDriver(dev_data, mem_range_count, mem_ranges);
skip |= validateMemoryIsMapped(dev_data, "vkFlushMappedMemoryRanges", mem_range_count, mem_ranges);
return skip;
@@ -9838,6 +9842,7 @@ static bool PreCallValidateInvalidateMappedMemoryRanges(layer_data *dev_data, ui
const VkMappedMemoryRange *mem_ranges) {
bool skip = false;
lock_guard_t lock(global_lock);
+ skip |= ValidateMappedMemoryRangeDeviceLimits(dev_data, "vkInvalidateMappedMemoryRanges", mem_range_count, mem_ranges);
skip |= validateMemoryIsMapped(dev_data, "vkInvalidateMappedMemoryRanges", mem_range_count, mem_ranges);
return skip;
}
diff --git a/layers/vk_validation_error_database.txt b/layers/vk_validation_error_database.txt
index 5f06ea34..fcafa9cd 100644
--- a/layers/vk_validation_error_database.txt
+++ b/layers/vk_validation_error_database.txt
@@ -923,7 +923,7 @@ VALIDATION_ERROR_0c20055a~^~Y~^~InvalidMemoryMapping~^~VkMappedMemoryRange~^~VUI
VALIDATION_ERROR_0c20055c~^~Y~^~InvalidMemoryMapping~^~VkMappedMemoryRange~^~VUID-VkMappedMemoryRange-size-00686~^~core~^~The spec valid usage text states 'If size is equal to VK_WHOLE_SIZE, offset must be within the currently mapped range of memory' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkMappedMemoryRange-size-00686)~^~
VALIDATION_ERROR_0c20055e~^~Y~^~InvalidMemoryMapping~^~VkMappedMemoryRange~^~VUID-VkMappedMemoryRange-offset-00687~^~core~^~The spec valid usage text states 'offset must be a multiple of VkPhysicalDeviceLimits::nonCoherentAtomSize' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkMappedMemoryRange-offset-00687)~^~see issues gitlab 611 and github 329
VALIDATION_ERROR_0c200ada~^~N~^~None~^~VkMappedMemoryRange~^~VUID-VkMappedMemoryRange-size-01389~^~core~^~The spec valid usage text states 'If size is equal to VK_WHOLE_SIZE, the end of the current mapping of memory must be a multiple of VkPhysicalDeviceLimits::nonCoherentAtomSize bytes from the beginning of the memory object.' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkMappedMemoryRange-size-01389)~^~
-VALIDATION_ERROR_0c200adc~^~Y~^~None~^~VkMappedMemoryRange~^~VUID-VkMappedMemoryRange-size-01390~^~core~^~The spec valid usage text states 'If size is not equal to VK_WHOLE_SIZE, size must either be a multiple of VkPhysicalDeviceLimits::nonCoherentAtomSize, or offset plus size must equal the size of memory.' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkMappedMemoryRange-size-01390)~^~
+VALIDATION_ERROR_0c200adc~^~Y~^~InvalidMemoryMapping~^~VkMappedMemoryRange~^~VUID-VkMappedMemoryRange-size-01390~^~core~^~The spec valid usage text states 'If size is not equal to VK_WHOLE_SIZE, size must either be a multiple of VkPhysicalDeviceLimits::nonCoherentAtomSize, or offset plus size must equal the size of memory.' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkMappedMemoryRange-size-01390)~^~
VALIDATION_ERROR_0c20c601~^~Y~^~None~^~VkMappedMemoryRange~^~VUID-VkMappedMemoryRange-memory-parameter~^~core~^~The spec valid usage text states 'memory must be a valid VkDeviceMemory handle' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkMappedMemoryRange-memory-parameter)~^~implicit, This error applies to both vkFlushMappedMemoryRanges and vkInvalidateMappedMemoryRanges.
VALIDATION_ERROR_0c21c40d~^~Y~^~Unknown~^~VkMappedMemoryRange~^~VUID-VkMappedMemoryRange-pNext-pNext~^~core~^~The spec valid usage text states 'pNext must be NULL' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkMappedMemoryRange-pNext-pNext)~^~implicit, TBD in parameter validation layer.
VALIDATION_ERROR_0c22b00b~^~N~^~Unknown~^~VkMappedMemoryRange~^~VUID-VkMappedMemoryRange-sType-sType~^~core~^~The spec valid usage text states 'sType must be VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkMappedMemoryRange-sType-sType)~^~implicit, TBD in parameter validation layer.