diff options
| author | Dustin Graves <dustin@lunarg.com> | 2016-03-31 18:01:37 -0600 |
|---|---|---|
| committer | Tobin Ehlis <tobine@google.com> | 2016-04-01 15:37:50 -0600 |
| commit | 1d4b952c921f331c4207d6b2745daf5e42869a24 (patch) | |
| tree | 02b599d4f5aaf24cffe8fec5016e51c421d6e8f1 /layers/core_validation.cpp | |
| parent | 6cf5e08f26b2784e616be556178ebe4956a11fe4 (diff) | |
| download | usermoji-1d4b952c921f331c4207d6b2745daf5e42869a24.tar.xz | |
layers: LX414: Fix device_limits alignment check
Fix buffer/descriptor offset alignment checks in device_limits:
- vkUpdateDescriptorSets offset check was not performed with
the correct physical device alignments.
- vkBindBufferMemory offset check was always performed with the
UBO alignment. This check has been moved to core_validation,
where the offset is checked against the alignment associated
with its usage type and the alignment retrieved from
vkGetBufferMemoryRequirements.
Change-Id: I4f64e06c44972a224d1930cb0798a9f472b768f2
Diffstat (limited to 'layers/core_validation.cpp')
| -rw-r--r-- | layers/core_validation.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index 20c9076c..63879bc1 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -5955,6 +5955,48 @@ vkBindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory mem, VkDevic skipCall |= validate_buffer_image_aliasing(dev_data, buffer_handle, mem, memoryOffset, memRequirements, dev_data->memObjMap[mem].bufferRanges, dev_data->memObjMap[mem].imageRanges, VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT); + // Validate memory requirements alignment + if (vk_safe_modulo(memoryOffset, memRequirements.alignment) != 0) { + skipCall |= + log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, + __LINE__, DRAWSTATE_INVALID_BUFFER_MEMORY_OFFSET, "DS", + "vkBindBufferMemory(): memoryOffset is %#" PRIxLEAST64 " but must be an integer multiple of the " + "VkMemoryRequirements::alignment value %#" PRIxLEAST64 + ", returned from a call to vkGetBufferMemoryRequirements with buffer", + memoryOffset, memRequirements.alignment); + } + // Validate device limits alignments + VkBufferUsageFlags usage = dev_data->bufferMap[buffer].create_info->usage; + if (usage & (VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT)) { + if (vk_safe_modulo(memoryOffset, dev_data->physDevProperties.properties.limits.minTexelBufferOffsetAlignment) != 0) { + skipCall |= + log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, + 0, __LINE__, DRAWSTATE_INVALID_TEXEL_BUFFER_OFFSET, "DS", + "vkBindBufferMemory(): memoryOffset is %#" PRIxLEAST64 " but must be a multiple of " + "device limit minTexelBufferOffsetAlignment %#" PRIxLEAST64, + memoryOffset, dev_data->physDevProperties.properties.limits.minTexelBufferOffsetAlignment); + } + } + if (usage & VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT) { + if (vk_safe_modulo(memoryOffset, dev_data->physDevProperties.properties.limits.minUniformBufferOffsetAlignment) != 0) { + skipCall |= + log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, + 0, __LINE__, DRAWSTATE_INVALID_UNIFORM_BUFFER_OFFSET, "DS", + "vkBindBufferMemory(): memoryOffset is %#" PRIxLEAST64 " but must be a multiple of " + "device limit minUniformBufferOffsetAlignment %#" PRIxLEAST64, + memoryOffset, dev_data->physDevProperties.properties.limits.minUniformBufferOffsetAlignment); + } + } + if (usage & VK_BUFFER_USAGE_STORAGE_BUFFER_BIT) { + if (vk_safe_modulo(memoryOffset, dev_data->physDevProperties.properties.limits.minStorageBufferOffsetAlignment) != 0) { + skipCall |= + log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, + 0, __LINE__, DRAWSTATE_INVALID_STORAGE_BUFFER_OFFSET, "DS", + "vkBindBufferMemory(): memoryOffset is %#" PRIxLEAST64 " but must be a multiple of " + "device limit minStorageBufferOffsetAlignment %#" PRIxLEAST64, + memoryOffset, dev_data->physDevProperties.properties.limits.minStorageBufferOffsetAlignment); + } + } } print_mem_list(dev_data, device); loader_platform_thread_unlock_mutex(&globalLock); |
