aboutsummaryrefslogtreecommitdiff
path: root/layers/device_limits.cpp
diff options
context:
space:
mode:
authorDustin Graves <dustin@lunarg.com>2016-03-31 18:01:37 -0600
committerTobin Ehlis <tobine@google.com>2016-04-01 15:37:50 -0600
commit1d4b952c921f331c4207d6b2745daf5e42869a24 (patch)
tree02b599d4f5aaf24cffe8fec5016e51c421d6e8f1 /layers/device_limits.cpp
parent6cf5e08f26b2784e616be556178ebe4956a11fe4 (diff)
downloadusermoji-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/device_limits.cpp')
-rw-r--r--layers/device_limits.cpp34
1 files changed, 5 insertions, 29 deletions
diff --git a/layers/device_limits.cpp b/layers/device_limits.cpp
index f0812e27..41afaab4 100644
--- a/layers/device_limits.cpp
+++ b/layers/device_limits.cpp
@@ -63,10 +63,10 @@ struct layer_data {
unique_ptr<PHYSICAL_DEVICE_STATE> physicalDeviceState;
VkPhysicalDeviceFeatures actualPhysicalDeviceFeatures;
VkPhysicalDeviceFeatures requestedPhysicalDeviceFeatures;
- unordered_map<VkDevice, VkPhysicalDeviceProperties> physDevPropertyMap;
// Track physical device per logical device
VkPhysicalDevice physicalDevice;
+ VkPhysicalDeviceProperties physicalDeviceProperties;
// Vector indices correspond to queueFamilyIndex
vector<unique_ptr<VkQueueFamilyProperties>> queueFamilyProperties;
@@ -448,15 +448,14 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice g
return result;
}
- layer_data *my_instance_data = get_my_data_ptr(get_dispatch_key(gpu), layer_data_map);
layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(*pDevice), layer_data_map);
my_device_data->device_dispatch_table = new VkLayerDispatchTable;
layer_init_device_dispatch_table(*pDevice, my_device_data->device_dispatch_table, fpGetDeviceProcAddr);
- my_device_data->report_data = layer_debug_report_create_device(my_instance_data->report_data, *pDevice);
+ my_device_data->report_data = layer_debug_report_create_device(phy_dev_data->report_data, *pDevice);
my_device_data->physicalDevice = gpu;
// Get physical device properties for this device
- phy_dev_data->instance_dispatch_table->GetPhysicalDeviceProperties(gpu, &(phy_dev_data->physDevPropertyMap[*pDevice]));
+ phy_dev_data->instance_dispatch_table->GetPhysicalDeviceProperties(gpu, &(my_device_data->physicalDeviceProperties));
return result;
}
@@ -553,27 +552,6 @@ vkGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex
dev_data->device_dispatch_table->GetDeviceQueue(device, queueFamilyIndex, queueIndex, pQueue);
}
-VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
-vkBindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory mem, VkDeviceSize memoryOffset) {
- layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
- VkResult result = VK_ERROR_VALIDATION_FAILED_EXT;
- VkBool32 skipCall = VK_FALSE;
-
- VkDeviceSize uniformAlignment = dev_data->physDevPropertyMap[device].limits.minUniformBufferOffsetAlignment;
- if (vk_safe_modulo(memoryOffset, uniformAlignment) != 0) {
- skipCall |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT,
- 0, __LINE__, DEVLIMITS_INVALID_UNIFORM_BUFFER_OFFSET, "DL",
- "vkBindBufferMemory(): memoryOffset %#" PRIxLEAST64
- " must be a multiple of device limit minUniformBufferOffsetAlignment %#" PRIxLEAST64,
- memoryOffset, uniformAlignment);
- }
-
- if (VK_FALSE == skipCall) {
- result = dev_data->device_dispatch_table->BindBufferMemory(device, buffer, mem, memoryOffset);
- }
- return result;
-}
-
VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL
vkUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet *pDescriptorWrites,
uint32_t descriptorCopyCount, const VkCopyDescriptorSet *pDescriptorCopies) {
@@ -583,7 +561,7 @@ vkUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, const VkW
for (uint32_t i = 0; i < descriptorWriteCount; i++) {
if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
(pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
- VkDeviceSize uniformAlignment = dev_data->physDevPropertyMap[device].limits.minUniformBufferOffsetAlignment;
+ VkDeviceSize uniformAlignment = dev_data->physicalDeviceProperties.limits.minUniformBufferOffsetAlignment;
for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
if (vk_safe_modulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) {
skipCall |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT,
@@ -596,7 +574,7 @@ vkUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, const VkW
}
} else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
(pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
- VkDeviceSize storageAlignment = dev_data->physDevPropertyMap[device].limits.minStorageBufferOffsetAlignment;
+ VkDeviceSize storageAlignment = dev_data->physicalDeviceProperties.limits.minStorageBufferOffsetAlignment;
for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
if (vk_safe_modulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) {
skipCall |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT,
@@ -713,8 +691,6 @@ VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkD
return (PFN_vkVoidFunction)vkBeginCommandBuffer;
if (!strcmp(funcName, "vkCmdUpdateBuffer"))
return (PFN_vkVoidFunction)vkCmdUpdateBuffer;
- if (!strcmp(funcName, "vkBindBufferMemory"))
- return (PFN_vkVoidFunction)vkBindBufferMemory;
if (!strcmp(funcName, "vkUpdateDescriptorSets"))
return (PFN_vkVoidFunction)vkUpdateDescriptorSets;
if (!strcmp(funcName, "vkCmdFillBuffer"))