layers: Updating some CreateBuffer checks to use unique enums
authorKarl Schultz <karl@lunarg.com>
Thu, 6 Oct 2016 23:53:48 +0000 (17:53 -0600)
committerKarl Schultz <karl@lunarg.com>
Tue, 11 Oct 2016 14:49:33 +0000 (08:49 -0600)
Small batch of updates to use unique validation error enums and
messages for a few checks.  Updated the database file and
flagged some other checks that are missing with the error
enums and TODO notes.

Change-Id: I2020a88bbdcf7ea6d725f667523e89b160fe7ab8

layers/core_validation.cpp
layers/object_tracker.cpp
layers/parameter_validation.cpp
layers/parameter_validation_utils.h
layers/vk_validation_error_database.txt

index c9502ba..8ac3edd 100644 (file)
@@ -6306,7 +6306,11 @@ DestroyRenderPass(VkDevice device, VkRenderPass renderPass, const VkAllocationCa
 VKAPI_ATTR VkResult VKAPI_CALL CreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
                                             const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) {
     layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
-
+    // TODO: Add check for VALIDATION_ERROR_00658
+    // TODO: Add check for VALIDATION_ERROR_00666
+    // TODO: Add check for VALIDATION_ERROR_00667
+    // TODO: Add check for VALIDATION_ERROR_00668
+    // TODO: Add check for VALIDATION_ERROR_00669
     VkResult result = dev_data->dispatch_table.CreateBuffer(device, pCreateInfo, pAllocator, pBuffer);
 
     if (VK_SUCCESS == result) {
index 11a78c0..acb858e 100644 (file)
@@ -42,6 +42,8 @@
 
 #include "object_tracker.h"
 
+#include "vk_validation_error_messages.h"
+
 namespace object_tracker {
 
 static void InitObjectTracker(layer_data *my_data, const VkAllocationCallbacks *pAllocator) {
@@ -313,7 +315,8 @@ static void DestroyObject(T1 dispatchable_object, T2 object, VkDebugReportObject
 }
 
 template <typename T1, typename T2>
-static bool ValidateObject(T1 dispatchable_object, T2 object, VkDebugReportObjectTypeEXT object_type, bool null_allowed) {
+static bool ValidateObject(T1 dispatchable_object, T2 object, VkDebugReportObjectTypeEXT object_type, bool null_allowed,
+                           int error_code = -1) {
     if (null_allowed && (object == VK_NULL_HANDLE)) {
         return false;
     }
@@ -324,9 +327,10 @@ static bool ValidateObject(T1 dispatchable_object, T2 object, VkDebugReportObjec
         // If object is an image, also look for it in the swapchain image map
         if ((object_type != VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT) ||
             (device_data->swapchainImageMap.find(object_handle) == device_data->swapchainImageMap.end())) {
-            return log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type,
-                           object_handle, __LINE__, OBJTRACK_INVALID_OBJECT, LayerName,
-                           "Invalid %s Object 0x%" PRIxLEAST64, object_name[object_type], object_handle);
+            const char *error_msg = (error_code == -1) ? "" : validation_error_map[error_code];
+            return log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object_handle, __LINE__,
+                           error_code, LayerName, "Invalid %s Object 0x%" PRIxLEAST64 ". %s", object_name[object_type],
+                           object_handle, error_msg);
         }
     }
     return false;
@@ -1053,7 +1057,7 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateBuffer(VkDevice device, const VkBufferCreat
     bool skip_call = false;
     {
         std::lock_guard<std::mutex> lock(global_lock);
-        skip_call |= ValidateObject(device, device, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, false);
+        skip_call |= ValidateObject(device, device, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, false, VALIDATION_ERROR_00659);
     }
     if (skip_call) {
         return VK_ERROR_VALIDATION_FAILED_EXT;
index 59df9d8..1306217 100644 (file)
@@ -2361,6 +2361,17 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateBuffer(VkDevice device, const VkBufferCreat
     assert(device_data != nullptr);
     debug_report_data *report_data = device_data->report_data;
 
+    // TODO: Add check for VALIDATION_ERROR_00660
+    // TODO: Add check for VALIDATION_ERROR_00661
+    // TODO: Add check for VALIDATION_ERROR_00662
+    // TODO: Add check for VALIDATION_ERROR_00670
+    // TODO: Add check for VALIDATION_ERROR_00671
+    // TODO: Add check for VALIDATION_ERROR_00672
+    // TODO: Add check for VALIDATION_ERROR_00673
+    // TODO: Add check for VALIDATION_ERROR_00674
+    // TODO: Add check for VALIDATION_ERROR_00675
+    // TODO: Note that the above errors need to be generated from the next function, which is codegened.
+    // TODO: Add check for VALIDATION_ERROR_00663
     skip_call |= parameter_validation_vkCreateBuffer(report_data, pCreateInfo, pAllocator, pBuffer);
 
     if (pCreateInfo != nullptr) {
@@ -2368,20 +2379,22 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateBuffer(VkDevice device, const VkBufferCreat
         if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
             // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
             if (pCreateInfo->queueFamilyIndexCount <= 1) {
-                skip_call |=
-                    log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
-                            INVALID_USAGE, LayerName, "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
-                                                      "pCreateInfo->queueFamilyIndexCount must be greater than 1");
+                skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
+                                     __LINE__, VALIDATION_ERROR_00665, LayerName,
+                                     "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
+                                     "pCreateInfo->queueFamilyIndexCount must be greater than 1. %s",
+                                     validation_error_map[VALIDATION_ERROR_00665]);
             }
 
             // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
             // queueFamilyIndexCount uint32_t values
             if (pCreateInfo->pQueueFamilyIndices == nullptr) {
                 skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
-                                     __LINE__, REQUIRED_PARAMETER, LayerName,
+                                     __LINE__, VALIDATION_ERROR_00664, LayerName,
                                      "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
                                      "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
-                                     "pCreateInfo->queueFamilyIndexCount uint32_t values");
+                                     "pCreateInfo->queueFamilyIndexCount uint32_t values. %s",
+                                     validation_error_map[VALIDATION_ERROR_00664]);
             }
 
             // Ensure that the queue family indices were specified at device creation
index 5084d5a..4fe740c 100644 (file)
@@ -28,6 +28,7 @@
 #include "vulkan/vulkan.h"
 #include "vk_enum_string_helper.h"
 #include "vk_layer_logging.h"
+#include "vk_validation_error_messages.h"
 
 #include "parameter_name.h"
 
index 3817bfd..a4dcf94 100644 (file)
@@ -664,24 +664,24 @@ VALIDATION_ERROR_00654~^~U~^~Unknown~^~For more information refer to Vulkan Spec
 VALIDATION_ERROR_00655~^~U~^~Unknown~^~For more information refer to Vulkan Spec Section '10.2.2. Lazily Allocated Memory' which states 'memory must be a valid VkDeviceMemory handle' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#vkGetDeviceMemoryCommitment)
 VALIDATION_ERROR_00656~^~U~^~Unknown~^~For more information refer to Vulkan Spec Section '10.2.2. Lazily Allocated Memory' which states 'pCommittedMemoryInBytes must be a pointer to a VkDeviceSize value' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#vkGetDeviceMemoryCommitment)
 VALIDATION_ERROR_00657~^~U~^~Unknown~^~For more information refer to Vulkan Spec Section '10.2.2. Lazily Allocated Memory' which states 'memory must have been created, allocated, or retrieved from device' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#vkGetDeviceMemoryCommitment)
-VALIDATION_ERROR_00658~^~U~^~Unknown~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'If the flags member of pCreateInfo includes VK_BUFFER_CREATE_SPARSE_BINDING_BIT, creating this VkBuffer must not cause the total required sparse memory for all currently valid sparse resources on the device to exceed VkPhysicalDeviceLimits::sparseAddressSpaceSize' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#vkCreateBuffer)
-VALIDATION_ERROR_00659~^~U~^~Unknown~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'device must be a valid VkDevice handle' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#vkCreateBuffer)
-VALIDATION_ERROR_00660~^~U~^~Unknown~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'pCreateInfo must be a pointer to a valid VkBufferCreateInfo structure' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#vkCreateBuffer)
-VALIDATION_ERROR_00661~^~U~^~Unknown~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'If pAllocator is not NULL, pAllocator must be a pointer to a valid VkAllocationCallbacks structure' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#vkCreateBuffer)
-VALIDATION_ERROR_00662~^~U~^~Unknown~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'pBuffer must be a pointer to a VkBuffer handle' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#vkCreateBuffer)
-VALIDATION_ERROR_00663~^~U~^~Unknown~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'size must be greater than 0' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#VkBufferCreateFlagBits)
-VALIDATION_ERROR_00664~^~U~^~Unknown~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of queueFamilyIndexCount uint32_t values' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#VkBufferCreateFlagBits)
-VALIDATION_ERROR_00665~^~U~^~Unknown~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#VkBufferCreateFlagBits)
-VALIDATION_ERROR_00666~^~U~^~Unknown~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'If the sparse bindings feature is not enabled, flags must not contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#VkBufferCreateFlagBits)
-VALIDATION_ERROR_00667~^~U~^~Unknown~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'If the sparse buffer residency feature is not enabled, flags must not contain VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#VkBufferCreateFlagBits)
-VALIDATION_ERROR_00668~^~U~^~Unknown~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'If the sparse aliased residency feature is not enabled, flags must not contain VK_BUFFER_CREATE_SPARSE_ALIASED_BIT' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#VkBufferCreateFlagBits)
-VALIDATION_ERROR_00669~^~U~^~Unknown~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#VkBufferCreateFlagBits)
-VALIDATION_ERROR_00670~^~U~^~Unknown~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'sType must be VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#VkBufferCreateFlagBits)
-VALIDATION_ERROR_00671~^~U~^~Unknown~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'pNext must be NULL' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#VkBufferCreateFlagBits)
-VALIDATION_ERROR_00672~^~U~^~Unknown~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'flags must be a valid combination of VkBufferCreateFlagBits values' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#VkBufferCreateFlagBits)
-VALIDATION_ERROR_00673~^~U~^~Unknown~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'usage must be a valid combination of VkBufferUsageFlagBits values' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#VkBufferCreateFlagBits)
-VALIDATION_ERROR_00674~^~U~^~Unknown~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'usage must not be 0' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#VkBufferCreateFlagBits)
-VALIDATION_ERROR_00675~^~U~^~Unknown~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'sharingMode must be a valid VkSharingMode value' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#VkBufferCreateFlagBits)
+VALIDATION_ERROR_00658~^~N~^~None~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'If the flags member of pCreateInfo includes VK_BUFFER_CREATE_SPARSE_BINDING_BIT, creating this VkBuffer must not cause the total required sparse memory for all currently valid sparse resources on the device to exceed VkPhysicalDeviceLimits::sparseAddressSpaceSize' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#vkCreateBuffer)
+VALIDATION_ERROR_00659~^~Y~^~None~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'device must be a valid VkDevice handle' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#vkCreateBuffer)
+VALIDATION_ERROR_00660~^~N~^~None~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'pCreateInfo must be a pointer to a valid VkBufferCreateInfo structure' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#vkCreateBuffer)
+VALIDATION_ERROR_00661~^~N~^~None~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'If pAllocator is not NULL, pAllocator must be a pointer to a valid VkAllocationCallbacks structure' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#vkCreateBuffer)
+VALIDATION_ERROR_00662~^~N~^~None~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'pBuffer must be a pointer to a VkBuffer handle' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#vkCreateBuffer)
+VALIDATION_ERROR_00663~^~N~^~None~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'size must be greater than 0' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#VkBufferCreateFlagBits)
+VALIDATION_ERROR_00664~^~Y~^~None~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of queueFamilyIndexCount uint32_t values' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#VkBufferCreateFlagBits)
+VALIDATION_ERROR_00665~^~Y~^~None~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#VkBufferCreateFlagBits)
+VALIDATION_ERROR_00666~^~N~^~None~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'If the sparse bindings feature is not enabled, flags must not contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#VkBufferCreateFlagBits)
+VALIDATION_ERROR_00667~^~N~^~None~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'If the sparse buffer residency feature is not enabled, flags must not contain VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#VkBufferCreateFlagBits)
+VALIDATION_ERROR_00668~^~N~^~None~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'If the sparse aliased residency feature is not enabled, flags must not contain VK_BUFFER_CREATE_SPARSE_ALIASED_BIT' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#VkBufferCreateFlagBits)
+VALIDATION_ERROR_00669~^~N~^~None~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#VkBufferCreateFlagBits)
+VALIDATION_ERROR_00670~^~N~^~None~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'sType must be VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#VkBufferCreateFlagBits)
+VALIDATION_ERROR_00671~^~N~^~None~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'pNext must be NULL' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#VkBufferCreateFlagBits)
+VALIDATION_ERROR_00672~^~N~^~None~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'flags must be a valid combination of VkBufferCreateFlagBits values' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#VkBufferCreateFlagBits)
+VALIDATION_ERROR_00673~^~N~^~None~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'usage must be a valid combination of VkBufferUsageFlagBits values' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#VkBufferCreateFlagBits)
+VALIDATION_ERROR_00674~^~N~^~None~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'usage must not be 0' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#VkBufferCreateFlagBits)
+VALIDATION_ERROR_00675~^~N~^~None~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'sharingMode must be a valid VkSharingMode value' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#VkBufferCreateFlagBits)
 VALIDATION_ERROR_00676~^~U~^~Unknown~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'All submitted commands that refer to buffer, either directly or via a VkBufferView, must have completed execution' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#vkDestroyBuffer)
 VALIDATION_ERROR_00677~^~U~^~Unknown~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'If VkAllocationCallbacks were provided when buffer was created, a compatible set of callbacks must be provided here' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#vkDestroyBuffer)
 VALIDATION_ERROR_00678~^~U~^~Unknown~^~For more information refer to Vulkan Spec Section '11.1. Buffers' which states 'If no VkAllocationCallbacks were provided when buffer was created, pAllocator must be NULL' (https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#vkDestroyBuffer)