layers: Add check to make sure inherited queries in enabled before use.
authorMichael Lentine <mlentine@google.com>
Thu, 28 Jan 2016 20:20:46 +0000 (14:20 -0600)
committerTobin Ehlis <tobine@google.com>
Wed, 3 Feb 2016 22:51:51 +0000 (15:51 -0700)
layers/device_limits.cpp
layers/device_limits.h
layers/vk_validation_layer_details.md

index 699abf4..54d0176 100644 (file)
@@ -540,6 +540,20 @@ VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkFreeCommandBuffers(VkDevice device,
     get_my_data_ptr(get_dispatch_key(device), layer_data_map)->device_dispatch_table->FreeCommandBuffers(device, commandPool, count, pCommandBuffers);
 }
 
+VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkBeginCommandBuffer(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo* pBeginInfo)
+{
+    bool skipCall = false;
+    layer_data *dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map);
+    const VkCommandBufferInheritanceInfo *pInfo = pBeginInfo->pInheritanceInfo;
+    if (dev_data->actualPhysicalDeviceFeatures.inheritedQueries == VK_FALSE && pInfo && pInfo->occlusionQueryEnable != VK_FALSE) {
+        skipCall |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, reinterpret_cast<uint64_t>(commandBuffer), __LINE__,
+                            DEVLIMITS_INVALID_INHERITED_QUERY, "DL",
+                            "Cannot set inherited occlusionQueryEnable in vkBeginCommandBuffer() when device does not support inheritedQueries.");
+    }
+    if (!skipCall)
+        dev_data->device_dispatch_table->BeginCommandBuffer(commandBuffer, pBeginInfo);
+}
+
 VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue* pQueue)
 {
     VkBool32 skipCall = VK_FALSE;
@@ -739,6 +753,8 @@ VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkD
         return (PFN_vkVoidFunction) vkAllocateCommandBuffers;
     if (!strcmp(funcName, "vkFreeCommandBuffers"))
         return (PFN_vkVoidFunction) vkFreeCommandBuffers;
+    if (!strcmp(funcName, "vkBeginCommandBuffer"))
+        return (PFN_vkVoidFunction) vkBeginCommandBuffer;
     if (!strcmp(funcName, "vkCmdUpdateBuffer"))
         return (PFN_vkVoidFunction) vkCmdUpdateBuffer;
     if (!strcmp(funcName, "vkBindBufferMemory"))
index ac6e23e..3ef9104 100644 (file)
@@ -41,6 +41,7 @@ typedef enum _DEV_LIMITS_ERROR
     DEVLIMITS_NONE,                             // Used for INFO & other non-error messages
     DEVLIMITS_INVALID_INSTANCE,                 // Invalid instance used
     DEVLIMITS_INVALID_PHYSICAL_DEVICE,          // Invalid physical device used
+    DEVLIMITS_INVALID_INHERITED_QUERY,          // Invalid use of inherited query
     DEVLIMITS_MUST_QUERY_COUNT,                 // Failed to make initial call to an API to query the count
     DEVLIMITS_MUST_QUERY_PROPERTIES,            // Failed to make initial call to an API to query properties
     DEVLIMITS_INVALID_CALL_SEQUENCE,            // Flag generic case of an invalid call sequence by the app
index fa3d6fa..4a78b5b 100644 (file)
@@ -316,6 +316,7 @@ For the second category of errors, VK_LAYER_LUNARG_device_limits stores its own
 | ----- | -------- | ---------------- | ---------------- | -------- | ---------- |
 | Valid instance | If an invalid instance is used, this error will be flagged | INVALID_INSTANCE | vkEnumeratePhysicalDevices | NA | VK_LAYER_LUNARG_object_tracker should also catch this so if we made sure VK_LAYER_LUNARG_object_tracker was always on top, we could avoid this check |
 | Valid physical device | Enum used for informational messages | INVALID_PHYSICAL_DEVICE | vkEnumeratePhysicalDevices | NA | VK_LAYER_LUNARG_object_tracker should also catch this so if we made sure VK_LAYER_LUNARG_object_tracker was always on top, we could avoid this check |
+| Valid inherited query | If an invalid inherited query is used, this error will be flagged | INVALID_INHERITED_QUERY | vkBeginCommandBuffer | NA | None |
 | Querying array counts | For API calls where an array count should be queried with an initial call and a NULL array pointer, verify that such a call was made before making a call with non-null array pointer. | MUST_QUERY_COUNT | vkEnumeratePhysicalDevices vkGetPhysicalDeviceQueueFamilyProperties | NA | Create focused test |
 | Array count value | For API calls where an array of details is queried, verify that the size of the requested array matches the size of the array supported by the device. | COUNT_MISMATCH | vkEnumeratePhysicalDevices vkGetPhysicalDeviceQueueFamilyProperties | NA | Create focused test |
 | Queue Creation | When creating/requesting queues, make sure that QueueFamilyPropertiesIndex and index/count within that queue family are valid. | INVALID_QUEUE_CREATE_REQUEST | vkGetDeviceQueue vkCreateDevice | NA | Create focused test |