From 3fb58f98f9cec6ca94a0093ca70a30f50bc8a71b Mon Sep 17 00:00:00 2001 From: Shannon McPherson Date: Wed, 2 May 2018 15:24:37 -0600 Subject: [PATCH] layers: Track display and display mode objects Add VkDisplayKHR and VkDisplayModeKHR tracking to VK_LAYER_LUNARG_object_tracker. Change-Id: I63004cfe734793593bea12700ea9cd1bdefeab0d --- layers/object_tracker_utils.cpp | 56 +++++++++++++++++++++++++++++++++++++ scripts/object_tracker_generator.py | 4 ++- 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/layers/object_tracker_utils.cpp b/layers/object_tracker_utils.cpp index cb0f4c5..26c5ff4 100644 --- a/layers/object_tracker_utils.cpp +++ b/layers/object_tracker_utils.cpp @@ -1243,6 +1243,62 @@ VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceQueueFamilyProperties2KHR(VkPhysical } } +VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, + VkDisplayPropertiesKHR *pProperties) { + bool skip = false; + std::unique_lock lock(global_lock); + skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_2b827a01, + VALIDATION_ERROR_UNDEFINED); + lock.unlock(); + + if (skip) { + return VK_ERROR_VALIDATION_FAILED_EXT; + } + VkResult result = get_dispatch_table(ot_instance_table_map, physicalDevice) + ->GetPhysicalDeviceDisplayPropertiesKHR(physicalDevice, pPropertyCount, pProperties); + + lock.lock(); + if (result == VK_SUCCESS) { + if (pProperties) { + for (uint32_t i = 0; i < *pPropertyCount; ++i) { + CreateObject(physicalDevice, pProperties[i].display, kVulkanObjectTypeDisplayKHR, nullptr); + } + } + } + lock.unlock(); + + return result; +} + +VKAPI_ATTR VkResult VKAPI_CALL GetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, + uint32_t *pPropertyCount, VkDisplayModePropertiesKHR *pProperties) { + bool skip = false; + std::unique_lock lock(global_lock); + skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_29827a01, + VALIDATION_ERROR_UNDEFINED); + skip |= ValidateObject(physicalDevice, display, kVulkanObjectTypeDisplayKHR, false, VALIDATION_ERROR_29806001, + VALIDATION_ERROR_UNDEFINED); + lock.unlock(); + + if (skip) { + return VK_ERROR_VALIDATION_FAILED_EXT; + } + VkResult result = get_dispatch_table(ot_instance_table_map, physicalDevice) + ->GetDisplayModePropertiesKHR(physicalDevice, display, pPropertyCount, pProperties); + + lock.lock(); + if (result == VK_SUCCESS) { + if (pProperties) { + for (uint32_t i = 0; i < *pPropertyCount; ++i) { + CreateObject(physicalDevice, pProperties[i].displayMode, kVulkanObjectTypeDisplayModeKHR, nullptr); + } + } + } + lock.unlock(); + + return result; +} + VKAPI_ATTR VkResult VKAPI_CALL DebugMarkerSetObjectNameEXT(VkDevice device, const VkDebugMarkerObjectNameInfoEXT *pNameInfo) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); diff --git a/scripts/object_tracker_generator.py b/scripts/object_tracker_generator.py index 96dabc7..9e0a375 100644 --- a/scripts/object_tracker_generator.py +++ b/scripts/object_tracker_generator.py @@ -184,6 +184,8 @@ class ObjectTrackerOutputGenerator(OutputGenerator): 'vkCmdBeginDebugUtilsLabelEXT', 'vkCmdEndDebugUtilsLabelEXT', 'vkCmdInsertDebugUtilsLabelEXT', + 'vkGetDisplayModePropertiesKHR', + 'vkGetPhysicalDeviceDisplayPropertiesKHR', ] # These VUIDS are not implicit, but are best handled in this layer. Codegen for vkDestroy calls will generate a key # which is translated here into a good VU. Saves ~40 checks. @@ -650,7 +652,7 @@ class ObjectTrackerOutputGenerator(OutputGenerator): return object_list # # Construct list of extension structs containing handles, or extension structs that share a - # tag WITH an extension struct containing handles. + # tag WITH an extension struct containing handles. def GenerateCommandWrapExtensionList(self): for struct in self.structMembers: if (len(struct.members) > 1) and struct.members[1].extstructs is not None: -- 2.7.4