layers: Migrate OT layer to use layer chassis
Add changes to support layer chassis-based build of the
object_tracker layer which replaces the legacy object-
tracker build, including cmake and Android updates.
Change-Id: If914cc3094fcf17b0f2e1002842d0b58b876d2b0
diff --git a/build-android/android-generate.bat b/build-android/android-generate.bat
index 99bfcbb..5b37483 100644
--- a/build-android/android-generate.bat
+++ b/build-android/android-generate.bat
@@ -32,9 +32,13 @@
py -3 ../../../scripts/lvl_genvk.py -registry %HEADERS_REGISTRY_PATH%/vk.xml -scripts %HEADERS_REGISTRY_PATH% unique_objects_wrappers.h
py -3 ../../../scripts/lvl_genvk.py -registry %HEADERS_REGISTRY_PATH%/vk.xml -scripts %HEADERS_REGISTRY_PATH% vk_layer_dispatch_table.h
py -3 ../../../scripts/lvl_genvk.py -registry %HEADERS_REGISTRY_PATH%/vk.xml -scripts %HEADERS_REGISTRY_PATH% vk_extension_helper.h
-py -3 ../../../scripts/lvl_genvk.py -registry %HEADERS_REGISTRY_PATH%/vk.xml -scripts %HEADERS_REGISTRY_PATH% object_tracker.cpp
py -3 ../../../scripts/lvl_genvk.py -registry %HEADERS_REGISTRY_PATH%/vk.xml -scripts %HEADERS_REGISTRY_PATH% vk_typemap_helper.h
+py -3 ../../../scripts/lvl_genvk.py -registry %HEADERS_REGISTRY_PATH%/vk.xml -scripts %HEADERS_REGISTRY_PATH% object_tracker.cpp
+py -3 ../../../scripts/lvl_genvk.py -registry %HEADERS_REGISTRY_PATH%/vk.xml -scripts %HEADERS_REGISTRY_PATH% object_tracker.h
+py -3 ../../../scripts/lvl_genvk.py -registry %HEADERS_REGISTRY_PATH%/vk.xml -scripts %HEADERS_REGISTRY_PATH% chassis.cpp
+py -3 ../../../scripts/lvl_genvk.py -registry %HEADERS_REGISTRY_PATH%/vk.xml -scripts %HEADERS_REGISTRY_PATH% chassis.h
+
set SPIRV_TOOLS_PATH=../../third_party/shaderc/third_party/spirv-tools
set SPIRV_TOOLS_UUID=spirv_tools_uuid.txt
diff --git a/build-android/android-generate.sh b/build-android/android-generate.sh
index c6b1bfb..6aa52d6 100755
--- a/build-android/android-generate.sh
+++ b/build-android/android-generate.sh
@@ -33,8 +33,11 @@
( cd generated/include; python3 ../../../scripts/lvl_genvk.py -registry $HEADERS_REGISTRY_PATH/vk.xml -scripts $HEADERS_REGISTRY_PATH unique_objects_wrappers.h )
( cd generated/include; python3 ../../../scripts/lvl_genvk.py -registry $HEADERS_REGISTRY_PATH/vk.xml -scripts $HEADERS_REGISTRY_PATH vk_layer_dispatch_table.h )
( cd generated/include; python3 ../../../scripts/lvl_genvk.py -registry $HEADERS_REGISTRY_PATH/vk.xml -scripts $HEADERS_REGISTRY_PATH vk_extension_helper.h )
-( cd generated/include; python3 ../../../scripts/lvl_genvk.py -registry $HEADERS_REGISTRY_PATH/vk.xml -scripts $HEADERS_REGISTRY_PATH object_tracker.cpp )
( cd generated/include; python3 ../../../scripts/lvl_genvk.py -registry $HEADERS_REGISTRY_PATH/vk.xml -scripts $HEADERS_REGISTRY_PATH vk_typemap_helper.h )
+( cd generated/include; python3 ../../../scripts/lvl_genvk.py -registry $HEADERS_REGISTRY_PATH/vk.xml -scripts $HEADERS_REGISTRY_PATH object_tracker.cpp )
+( cd generated/include; python3 ../../../scripts/lvl_genvk.py -registry $HEADERS_REGISTRY_PATH/vk.xml -scripts $HEADERS_REGISTRY_PATH object_tracker.h )
+( cd generated/include; python3 ../../../scripts/lvl_genvk.py -registry $HEADERS_REGISTRY_PATH/vk.xml -scripts $HEADERS_REGISTRY_PATH chassis.cpp )
+( cd generated/include; python3 ../../../scripts/lvl_genvk.py -registry $HEADERS_REGISTRY_PATH/vk.xml -scripts $HEADERS_REGISTRY_PATH chassis.h )
SPIRV_TOOLS_PATH=../../third_party/shaderc/third_party/spirv-tools
SPIRV_TOOLS_UUID=spirv_tools_uuid.txt
diff --git a/build-android/cmake/layerlib/CMakeLists.txt b/build-android/cmake/layerlib/CMakeLists.txt
index 66076b7..b600e1d 100644
--- a/build-android/cmake/layerlib/CMakeLists.txt
+++ b/build-android/cmake/layerlib/CMakeLists.txt
@@ -98,6 +98,7 @@
add_library(VkLayer_object_tracker SHARED
${COMMON_DIR}/include/object_tracker.cpp
+ ${COMMON_DIR}/include/chassis.cpp
${SRC_DIR}/layers/object_tracker_utils.cpp)
target_include_directories(VkLayer_object_tracker PRIVATE
${SRC_DIR}/include
diff --git a/build-android/jni/Android.mk b/build-android/jni/Android.mk
index fad0ad5..8d753d7 100644
--- a/build-android/jni/Android.mk
+++ b/build-android/jni/Android.mk
@@ -70,6 +70,7 @@
include $(CLEAR_VARS)
LOCAL_MODULE := VkLayer_object_tracker
LOCAL_SRC_FILES += $(LAYER_DIR)/include/object_tracker.cpp
+LOCAL_SRC_FILES += $(LAYER_DIR)/include/chassis.cpp
LOCAL_SRC_FILES += $(SRC_DIR)/layers/object_tracker_utils.cpp
LOCAL_C_INCLUDES += $(VULKAN_INCLUDE) \
$(LOCAL_PATH)/$(SRC_DIR)/layers \
diff --git a/layers/CMakeLists.txt b/layers/CMakeLists.txt
index e5489d1..e7bac96 100644
--- a/layers/CMakeLists.txt
+++ b/layers/CMakeLists.txt
@@ -85,7 +85,8 @@
set(TARGET_NAMES
VkLayer_core_validation
- VkLayer_object_tracker
+ # VkLayer_object_tracker
+ VkLayer_object_lifetimes
VkLayer_unique_objects
VkLayer_parameter_validation
VkLayer_standard_validation
@@ -155,6 +156,7 @@
threading.cpp
parameter_validation_utils.cpp
unique_objects.cpp
+ chassis.cpp
PROPERTIES
COMPILE_FLAGS
"/bigobj")
@@ -175,13 +177,14 @@
GenerateFromVkXml(parameter_validation_generator.py parameter_validation.cpp)
GenerateFromVkXml(unique_objects_generator.py unique_objects_wrappers.h)
GenerateFromVkXml(dispatch_table_helper_generator.py vk_dispatch_table_helper.h)
-GenerateFromVkXml(object_tracker_generator.py object_tracker_utils_auto.cpp)
-GenerateFromVkXml(object_tracker_generator.py object_tracker_core_auto.cpp)
-
+GenerateFromVkXml(object_tracker_generator.py object_tracker.cpp)
+GenerateFromVkXml(object_tracker_generator.py object_tracker.h)
+GenerateFromVkXml(layer_chassis_generator.py chassis.cpp)
+GenerateFromVkXml(layer_chassis_generator.py chassis.h)
if(BUILD_LAYERS)
AddVkLayer(core_validation core_validation.cpp convert_to_renderpass2.cpp descriptor_sets.cpp buffer_validation.cpp shader_validation.cpp xxhash.c)
- AddVkLayer(object_tracker object_tracker_utils_auto.cpp object_tracker_core_auto.cpp object_tracker_utils.cpp object_tracker_core.cpp)
+ AddVkLayer(object_lifetimes object_tracker.cpp object_tracker.h object_tracker_utils.cpp chassis.cpp chassis.h)
AddVkLayer(threading threading.cpp thread_check.h)
AddVkLayer(unique_objects unique_objects.cpp unique_objects_wrappers.h)
AddVkLayer(parameter_validation
diff --git a/layers/VkLayer_object_lifetimes.def b/layers/VkLayer_object_lifetimes.def
new file mode 100644
index 0000000..9b170e4
--- /dev/null
+++ b/layers/VkLayer_object_lifetimes.def
@@ -0,0 +1,30 @@
+
+;;;; Begin Copyright Notice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;
+; Copyright (c) 2015-2016 The Khronos Group Inc.
+; Copyright (c) 2015-2016 Valve Corporation
+; Copyright (c) 2015-2016 LunarG, Inc.
+;
+; Licensed under the Apache License, Version 2.0 (the "License");
+; you may not use this file except in compliance with the License.
+; You may obtain a copy of the License at
+;
+; http://www.apache.org/licenses/LICENSE-2.0
+;
+; Unless required by applicable law or agreed to in writing, software
+; distributed under the License is distributed on an "AS IS" BASIS,
+; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+; See the License for the specific language governing permissions and
+; limitations under the License.
+;
+; Author: Mark Lobodzinski <mark@lunarg.com>
+;
+;;;; End Copyright Notice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+LIBRARY VkLayer_object_lifetimes
+EXPORTS
+vkGetInstanceProcAddr
+vkGetDeviceProcAddr
+vkEnumerateInstanceLayerProperties
+vkEnumerateInstanceExtensionProperties
+vkNegotiateLoaderLayerInterfaceVersion
diff --git a/layers/interceptor_objects.h b/layers/interceptor_objects.h
new file mode 100644
index 0000000..88f13b5
--- /dev/null
+++ b/layers/interceptor_objects.h
@@ -0,0 +1 @@
+#include "object_lifetime_validation.h"
diff --git a/layers/json/VkLayer_object_lifetimes.json.in b/layers/json/VkLayer_object_lifetimes.json.in
new file mode 100644
index 0000000..faba46d
--- /dev/null
+++ b/layers/json/VkLayer_object_lifetimes.json.in
@@ -0,0 +1,29 @@
+{
+ "file_format_version" : "1.1.0",
+ "layer" : {
+ "name": "VK_LAYER_LUNARG_object_tracker",
+ "type": "GLOBAL",
+ "library_path": "@RELATIVE_LAYER_BINARY@",
+ "api_version": "@VK_VERSION@",
+ "implementation_version": "1",
+ "description": "LunarG Validation Layer",
+ "instance_extensions": [
+ {
+ "name": "VK_EXT_debug_report",
+ "spec_version": "6"
+ }
+ ],
+ "device_extensions": [
+ {
+ "name": "VK_EXT_debug_marker",
+ "spec_version": "4",
+ "entrypoints": ["vkDebugMarkerSetObjectTagEXT",
+ "vkDebugMarkerSetObjectNameEXT",
+ "vkCmdDebugMarkerBeginEXT",
+ "vkCmdDebugMarkerEndEXT",
+ "vkCmdDebugMarkerInsertEXT"
+ ]
+ }
+ ]
+ }
+}
diff --git a/layers/object_lifetime_validation.h b/layers/object_lifetime_validation.h
index 186a167..1b8db72 100644
--- a/layers/object_lifetime_validation.h
+++ b/layers/object_lifetime_validation.h
@@ -20,26 +20,6 @@
* Author: Tobin Ehlis <tobine@google.com>
*/
-#pragma once
-
-#include <mutex>
-#include <cinttypes>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unordered_map>
-#include <unordered_set>
-
-#include "vulkan/vulkan.h"
-#include "vk_object_types.h"
-#include "vk_layer_logging.h"
-#include "object_lifetimes.h"
-
-namespace object_tracker {
-
-#include "precall.h"
-#include "postcall.h"
-
// Suppress unused warning on Linux
#if defined(__GNUC__)
#define DECORATE_UNUSED __attribute__((unused))
@@ -58,95 +38,58 @@
extern uint64_t object_track_index;
-bool DeviceReportUndestroyedObjects(VkDevice device, VulkanObjectType object_type, const std::string &error_code);
-void DeviceDestroyUndestroyedObjects(VkDevice device, VulkanObjectType object_type);
-void CreateQueue(VkDevice device, VkQueue vkObj);
-void AddQueueInfo(VkDevice device, uint32_t queue_node_index, VkQueue queue);
-void ValidateQueueFlags(VkQueue queue, const char *function);
-void AllocateCommandBuffer(VkDevice device, const VkCommandPool command_pool, const VkCommandBuffer command_buffer,
- VkCommandBufferLevel level);
-void AllocateDescriptorSet(VkDevice device, VkDescriptorPool descriptor_pool, VkDescriptorSet descriptor_set);
-void CreateSwapchainImageObject(VkDevice dispatchable_object, VkImage swapchain_image, VkSwapchainKHR swapchain);
-bool ReportUndestroyedObjects(VkDevice device, const std::string &error_code);
-void DestroyUndestroyedObjects(VkDevice device);
-bool ValidateDeviceObject(uint64_t device_handle, const std::string &invalid_handle_code, const std::string &wrong_device_code);
+class ObjectLifetimes : public layer_chassis {
+ public:
+ // Constructor for state_tracker
+ ObjectLifetimes(){};
-template <typename T1, typename T2>
-bool InstanceValidateObject(T1 dispatchable_object, T2 object, VulkanObjectType object_type, bool null_allowed,
- const std::string &invalid_handle_code, const std::string &wrong_device_code) {
- if (null_allowed && (object == VK_NULL_HANDLE)) {
- return false;
- }
- auto object_handle = HandleToUint64(object);
+ bool DeviceReportUndestroyedObjects(VkDevice device, VulkanObjectType object_type, const std::string &error_code);
+ void DeviceDestroyUndestroyedObjects(VkDevice device, VulkanObjectType object_type);
+ void CreateQueue(VkDevice device, VkQueue vkObj);
+ void AddQueueInfo(VkDevice device, uint32_t queue_node_index, VkQueue queue);
+ void ValidateQueueFlags(VkQueue queue, const char *function);
+ void AllocateCommandBuffer(VkDevice device, const VkCommandPool command_pool, const VkCommandBuffer command_buffer,
+ VkCommandBufferLevel level);
+ void AllocateDescriptorSet(VkDevice device, VkDescriptorPool descriptor_pool, VkDescriptorSet descriptor_set);
+ void CreateSwapchainImageObject(VkDevice dispatchable_object, VkImage swapchain_image, VkSwapchainKHR swapchain);
+ bool ReportUndestroyedObjects(VkDevice device, const std::string &error_code);
+ void DestroyUndestroyedObjects(VkDevice device);
+ bool ValidateDeviceObject(uint64_t device_handle, const std::string &invalid_handle_code, const std::string &wrong_device_code);
+ void DestroyQueueDataStructures(VkDevice device);
+ bool ValidateCommandBuffer(VkDevice device, VkCommandPool command_pool, VkCommandBuffer command_buffer);
+ bool ValidateDescriptorSet(VkDevice device, VkDescriptorPool descriptor_pool, VkDescriptorSet descriptor_set);
+ bool ValidateSamplerObjects(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo);
+ template <typename DispObj>
+ bool ValidateDescriptorWrite(DispObj disp, VkWriteDescriptorSet const *desc, bool isPush);
- if (object_type == kVulkanObjectTypeDevice) {
- return ValidateDeviceObject(object_handle, invalid_handle_code, wrong_device_code);
- }
-
- VkDebugReportObjectTypeEXT debug_object_type = get_debug_report_enum[object_type];
- instance_layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(dispatchable_object), instance_layer_data_map);
- // Look for object in object map
- if (instance_data->objdata.object_map[object_type].find(object_handle) ==
- instance_data->objdata.object_map[object_type].end()) {
- // Object not found, look for it in other instance object maps
- for (auto other_instance_data : instance_layer_data_map) {
- if (other_instance_data.second != instance_data) {
- if (other_instance_data.second->objdata.object_map[object_type].find(object_handle) !=
- other_instance_data.second->objdata.object_map[object_type].end()) {
- // Object found on another instance, report an error if object has a instance parent error code
- if ((wrong_device_code != kVUIDUndefined) && (object_type != kVulkanObjectTypeSurfaceKHR)) {
- return log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, debug_object_type, object_handle,
- wrong_device_code,
- "Object 0x%" PRIxLEAST64
- " was not created, allocated or retrieved from the correct instance.",
- object_handle);
- } else {
- return false;
- }
- }
- }
+ template <typename T1, typename T2>
+ bool InstanceValidateObject(T1 dispatchable_object, T2 object, VulkanObjectType object_type, bool null_allowed,
+ const std::string &invalid_handle_code, const std::string &wrong_device_code) {
+ if (null_allowed && (object == VK_NULL_HANDLE)) {
+ return false;
}
- // Report an error if object was not found anywhere
- return log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, debug_object_type, object_handle,
- invalid_handle_code, "Invalid %s Object 0x%" PRIxLEAST64 ".", object_string[object_type], object_handle);
- }
- return false;
-}
+ auto object_handle = HandleToUint64(object);
-template <typename T1, typename T2>
-bool DeviceValidateObject(T1 dispatchable_object, T2 object, VulkanObjectType object_type, bool null_allowed,
- const std::string &invalid_handle_code, const std::string &wrong_device_code) {
- if (null_allowed && (object == VK_NULL_HANDLE)) {
- return false;
- }
- auto object_handle = HandleToUint64(object);
+ if (object_type == kVulkanObjectTypeDevice) {
+ return ValidateDeviceObject(object_handle, invalid_handle_code, wrong_device_code);
+ }
- if (object_type == kVulkanObjectTypeDevice) {
- return ValidateDeviceObject(object_handle, invalid_handle_code, wrong_device_code);
- }
-
- VkDebugReportObjectTypeEXT debug_object_type = get_debug_report_enum[object_type];
-
- layer_data *device_data = GetLayerDataPtr(get_dispatch_key(dispatchable_object), layer_data_map);
- // Look for object in device object map
- if (device_data->objdata.object_map[object_type].find(object_handle) == device_data->objdata.object_map[object_type].end()) {
- // If object is an image, also look for it in the swapchain image map
- if ((object_type != kVulkanObjectTypeImage) ||
- (device_data->objdata.swapchainImageMap.find(object_handle) == device_data->objdata.swapchainImageMap.end())) {
- // Object not found, look for it in other device object maps
- for (auto other_device_data : layer_data_map) {
- if (other_device_data.second != device_data) {
- if (other_device_data.second->objdata.object_map[object_type].find(object_handle) !=
- other_device_data.second->objdata.object_map[object_type].end() ||
- (object_type == kVulkanObjectTypeImage &&
- other_device_data.second->objdata.swapchainImageMap.find(object_handle) !=
- other_device_data.second->objdata.swapchainImageMap.end())) {
- // Object found on other device, report an error if object has a device parent error code
+ VkDebugReportObjectTypeEXT debug_object_type = get_debug_report_enum[object_type];
+ instance_layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(dispatchable_object), instance_layer_data_map);
+ // Look for object in object map
+ if (instance_data->objdata.object_map[object_type].find(object_handle) ==
+ instance_data->objdata.object_map[object_type].end()) {
+ // Object not found, look for it in other instance object maps
+ for (auto other_instance_data : instance_layer_data_map) {
+ if (other_instance_data.second != instance_data) {
+ if (other_instance_data.second->objdata.object_map[object_type].find(object_handle) !=
+ other_instance_data.second->objdata.object_map[object_type].end()) {
+ // Object found on another instance, report an error if object has a instance parent error code
if ((wrong_device_code != kVUIDUndefined) && (object_type != kVulkanObjectTypeSurfaceKHR)) {
- return log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, debug_object_type,
+ return log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, debug_object_type,
object_handle, wrong_device_code,
"Object 0x%" PRIxLEAST64
- " was not created, allocated or retrieved from the correct device.",
+ " was not created, allocated or retrieved from the correct instance.",
object_handle);
} else {
return false;
@@ -155,142 +98,199 @@
}
}
// Report an error if object was not found anywhere
- return log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, debug_object_type, object_handle,
+ return log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, debug_object_type, object_handle,
invalid_handle_code, "Invalid %s Object 0x%" PRIxLEAST64 ".", object_string[object_type], object_handle);
}
+ return false;
}
- return false;
-}
-static void InsertObjectInMap(uint64_t object_handle, VulkanObjectType object_type, object_lifetime *obj_data,
- debug_report_data *report_data, bool custom_allocator) {
- if (!obj_data->object_map[object_type].count(object_handle)) {
+ template <typename T1, typename T2>
+ bool DeviceValidateObject(T1 dispatchable_object, T2 object, VulkanObjectType object_type, bool null_allowed,
+ const std::string &invalid_handle_code, const std::string &wrong_device_code) {
+ if (null_allowed && (object == VK_NULL_HANDLE)) {
+ return false;
+ }
+ auto object_handle = HandleToUint64(object);
+
+ if (object_type == kVulkanObjectTypeDevice) {
+ return ValidateDeviceObject(object_handle, invalid_handle_code, wrong_device_code);
+ }
+
VkDebugReportObjectTypeEXT debug_object_type = get_debug_report_enum[object_type];
- log_msg(report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, debug_object_type, object_handle, kVUID_ObjectTracker_Info,
- "OBJ[0x%" PRIxLEAST64 "] : CREATE %s object 0x%" PRIxLEAST64, object_track_index++, object_string[object_type],
- object_handle);
- ObjTrackState *pNewObjNode = new ObjTrackState;
- pNewObjNode->object_type = object_type;
- pNewObjNode->status = custom_allocator ? OBJSTATUS_CUSTOM_ALLOCATOR : OBJSTATUS_NONE;
- pNewObjNode->handle = object_handle;
-
- obj_data->object_map[object_type][object_handle] = pNewObjNode;
- obj_data->num_objects[object_type]++;
- obj_data->num_total_objects++;
+ layer_data *device_data = GetLayerDataPtr(get_dispatch_key(dispatchable_object), layer_data_map);
+ // Look for object in device object map
+ if (device_data->objdata.object_map[object_type].find(object_handle) ==
+ device_data->objdata.object_map[object_type].end()) {
+ // If object is an image, also look for it in the swapchain image map
+ if ((object_type != kVulkanObjectTypeImage) ||
+ (device_data->objdata.swapchainImageMap.find(object_handle) == device_data->objdata.swapchainImageMap.end())) {
+ // Object not found, look for it in other device object maps
+ for (auto other_device_data : layer_data_map) {
+ if (other_device_data.second != device_data) {
+ if (other_device_data.second->objdata.object_map[object_type].find(object_handle) !=
+ other_device_data.second->objdata.object_map[object_type].end() ||
+ (object_type == kVulkanObjectTypeImage &&
+ other_device_data.second->objdata.swapchainImageMap.find(object_handle) !=
+ other_device_data.second->objdata.swapchainImageMap.end())) {
+ // Object found on other device, report an error if object has a device parent error code
+ if ((wrong_device_code != kVUIDUndefined) && (object_type != kVulkanObjectTypeSurfaceKHR)) {
+ return log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, debug_object_type,
+ object_handle, wrong_device_code,
+ "Object 0x%" PRIxLEAST64
+ " was not created, allocated or retrieved from the correct device.",
+ object_handle);
+ } else {
+ return false;
+ }
+ }
+ }
+ }
+ // Report an error if object was not found anywhere
+ return log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, debug_object_type, object_handle,
+ invalid_handle_code, "Invalid %s Object 0x%" PRIxLEAST64 ".", object_string[object_type],
+ object_handle);
+ }
+ }
+ return false;
}
-}
-template <typename T1, typename T2>
-void InstanceCreateObject(T1 dispatchable_object, T2 object, VulkanObjectType object_type,
- const VkAllocationCallbacks *pAllocator) {
- instance_layer_data *layer_data = GetLayerDataPtr(get_dispatch_key(dispatchable_object), instance_layer_data_map);
- InsertObjectInMap(HandleToUint64(object), object_type, &layer_data->objdata, layer_data->report_data, (pAllocator != nullptr));
-}
+ static void InsertObjectInMap(uint64_t object_handle, VulkanObjectType object_type, object_lifetime *obj_data,
+ debug_report_data *report_data, bool custom_allocator) {
+ if (!obj_data->object_map[object_type].count(object_handle)) {
+ VkDebugReportObjectTypeEXT debug_object_type = get_debug_report_enum[object_type];
+ log_msg(report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, debug_object_type, object_handle, kVUID_ObjectTracker_Info,
+ "OBJ[0x%" PRIxLEAST64 "] : CREATE %s object 0x%" PRIxLEAST64, object_track_index++, object_string[object_type],
+ object_handle);
-template <typename T1, typename T2>
-void DeviceCreateObject(T1 dispatchable_object, T2 object, VulkanObjectType object_type, const VkAllocationCallbacks *pAllocator) {
- layer_data *layer_data = GetLayerDataPtr(get_dispatch_key(dispatchable_object), layer_data_map);
- InsertObjectInMap(HandleToUint64(object), object_type, &layer_data->objdata, layer_data->report_data, (pAllocator != nullptr));
-}
+ ObjTrackState *pNewObjNode = new ObjTrackState;
+ pNewObjNode->object_type = object_type;
+ pNewObjNode->status = custom_allocator ? OBJSTATUS_CUSTOM_ALLOCATOR : OBJSTATUS_NONE;
+ pNewObjNode->handle = object_handle;
-template <typename T1>
-void DestroyObjectSilently(object_lifetime *obj_data, T1 object, VulkanObjectType object_type) {
- auto object_handle = HandleToUint64(object);
- assert(object_handle != VK_NULL_HANDLE);
-
- auto item = obj_data->object_map[object_type].find(object_handle);
- assert(item != obj_data->object_map[object_type].end());
-
- ObjTrackState *pNode = item->second;
- assert(obj_data->num_total_objects > 0);
-
- obj_data->num_total_objects--;
- assert(obj_data->num_objects[pNode->object_type] > 0);
-
- obj_data->num_objects[pNode->object_type]--;
-
- delete pNode;
- obj_data->object_map[object_type].erase(item);
-}
-
-template <typename T1>
-void DeleteObjectFromMap(T1 object, VulkanObjectType object_type, object_lifetime *obj_data) {
- auto object_handle = HandleToUint64(object);
- if (object_handle != VK_NULL_HANDLE) {
- auto item = obj_data->object_map[object_type].find(object_handle);
- if (item != obj_data->object_map[object_type].end()) {
- DestroyObjectSilently(obj_data, object, object_type);
+ obj_data->object_map[object_type][object_handle] = pNewObjNode;
+ obj_data->num_objects[object_type]++;
+ obj_data->num_total_objects++;
}
}
-}
-template <typename T1, typename T2>
-void InstanceRecordDestroyObject(T1 dispatchable_object, T2 object, VulkanObjectType object_type) {
- instance_layer_data *layer_data = GetLayerDataPtr(get_dispatch_key(dispatchable_object), instance_layer_data_map);
- DeleteObjectFromMap(object, object_type, &layer_data->objdata);
-}
+ template <typename T1, typename T2>
+ void InstanceCreateObject(T1 dispatchable_object, T2 object, VulkanObjectType object_type,
+ const VkAllocationCallbacks *pAllocator) {
+ instance_layer_data *layer_data = GetLayerDataPtr(get_dispatch_key(dispatchable_object), instance_layer_data_map);
+ InsertObjectInMap(HandleToUint64(object), object_type, &layer_data->objdata, layer_data->report_data,
+ (pAllocator != nullptr));
+ }
-template <typename T1, typename T2>
-void DeviceRecordDestroyObject(T1 dispatchable_object, T2 object, VulkanObjectType object_type) {
- layer_data *layer_data = GetLayerDataPtr(get_dispatch_key(dispatchable_object), layer_data_map);
- DeleteObjectFromMap(object, object_type, &layer_data->objdata);
-}
+ template <typename T1, typename T2>
+ void DeviceCreateObject(T1 dispatchable_object, T2 object, VulkanObjectType object_type,
+ const VkAllocationCallbacks *pAllocator) {
+ layer_data *layer_data = GetLayerDataPtr(get_dispatch_key(dispatchable_object), layer_data_map);
+ InsertObjectInMap(HandleToUint64(object), object_type, &layer_data->objdata, layer_data->report_data,
+ (pAllocator != nullptr));
+ }
-template <typename T1>
-bool ValidateDestroyObject(T1 object, VulkanObjectType object_type, const VkAllocationCallbacks *pAllocator,
- const std::string &expected_custom_allocator_code, const std::string &expected_default_allocator_code,
- object_lifetime *obj_data, debug_report_data *report_data) {
- auto object_handle = HandleToUint64(object);
- bool custom_allocator = pAllocator != nullptr;
- VkDebugReportObjectTypeEXT debug_object_type = get_debug_report_enum[object_type];
- bool skip = false;
+ template <typename T1>
+ void DestroyObjectSilently(object_lifetime *obj_data, T1 object, VulkanObjectType object_type) {
+ auto object_handle = HandleToUint64(object);
+ assert(object_handle != VK_NULL_HANDLE);
- if (object_handle != VK_NULL_HANDLE) {
auto item = obj_data->object_map[object_type].find(object_handle);
- if (item != obj_data->object_map[object_type].end()) {
- ObjTrackState *pNode = item->second;
- skip |= log_msg(report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, debug_object_type, object_handle,
- kVUID_ObjectTracker_Info,
- "OBJ_STAT Destroy %s obj 0x%" PRIxLEAST64 " (%" PRIu64 " total objs remain & %" PRIu64 " %s objs).",
- object_string[object_type], HandleToUint64(object), obj_data->num_total_objects - 1,
- obj_data->num_objects[pNode->object_type] - 1, object_string[object_type]);
+ assert(item != obj_data->object_map[object_type].end());
- auto allocated_with_custom = (pNode->status & OBJSTATUS_CUSTOM_ALLOCATOR) ? true : false;
- if (allocated_with_custom && !custom_allocator && expected_custom_allocator_code != kVUIDUndefined) {
- // This check only verifies that custom allocation callbacks were provided to both Create and Destroy calls,
- // it cannot verify that these allocation callbacks are compatible with each other.
- skip |= log_msg(
- report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, debug_object_type, object_handle, expected_custom_allocator_code,
- "Custom allocator not specified while destroying %s obj 0x%" PRIxLEAST64 " but specified at creation.",
- object_string[object_type], object_handle);
- } else if (!allocated_with_custom && custom_allocator && expected_default_allocator_code != kVUIDUndefined) {
- skip |= log_msg(
- report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, debug_object_type, object_handle, expected_default_allocator_code,
- "Custom allocator specified while destroying %s obj 0x%" PRIxLEAST64 " but not specified at creation.",
- object_string[object_type], object_handle);
+ ObjTrackState *pNode = item->second;
+ assert(obj_data->num_total_objects > 0);
+
+ obj_data->num_total_objects--;
+ assert(obj_data->num_objects[pNode->object_type] > 0);
+
+ obj_data->num_objects[pNode->object_type]--;
+
+ delete pNode;
+ obj_data->object_map[object_type].erase(item);
+ }
+
+ template <typename T1>
+ void DeleteObjectFromMap(T1 object, VulkanObjectType object_type, object_lifetime *obj_data) {
+ auto object_handle = HandleToUint64(object);
+ if (object_handle != VK_NULL_HANDLE) {
+ auto item = obj_data->object_map[object_type].find(object_handle);
+ if (item != obj_data->object_map[object_type].end()) {
+ DestroyObjectSilently(obj_data, object, object_type);
}
}
}
- return skip;
-}
-template <typename T1, typename T2>
-bool InstanceValidateDestroyObject(T1 dispatchable_object, T2 object, VulkanObjectType object_type,
- const VkAllocationCallbacks *pAllocator, const std::string &expected_custom_allocator_code,
- const std::string &expected_default_allocator_code) {
- instance_layer_data *layer_data = GetLayerDataPtr(get_dispatch_key(dispatchable_object), instance_layer_data_map);
- return ValidateDestroyObject(object, object_type, pAllocator, expected_custom_allocator_code, expected_default_allocator_code,
- &layer_data->objdata, layer_data->report_data);
-}
+ template <typename T1, typename T2>
+ void InstanceRecordDestroyObject(T1 dispatchable_object, T2 object, VulkanObjectType object_type) {
+ instance_layer_data *layer_data = GetLayerDataPtr(get_dispatch_key(dispatchable_object), instance_layer_data_map);
+ DeleteObjectFromMap(object, object_type, &layer_data->objdata);
+ }
-template <typename T1, typename T2>
-bool DeviceValidateDestroyObject(T1 dispatchable_object, T2 object, VulkanObjectType object_type,
- const VkAllocationCallbacks *pAllocator, const std::string &expected_custom_allocator_code,
- const std::string &expected_default_allocator_code) {
- layer_data *layer_data = GetLayerDataPtr(get_dispatch_key(dispatchable_object), layer_data_map);
- return ValidateDestroyObject(object, object_type, pAllocator, expected_custom_allocator_code, expected_default_allocator_code,
- &layer_data->objdata, layer_data->report_data);
-}
+ template <typename T1, typename T2>
+ void DeviceRecordDestroyObject(T1 dispatchable_object, T2 object, VulkanObjectType object_type) {
+ layer_data *layer_data = GetLayerDataPtr(get_dispatch_key(dispatchable_object), layer_data_map);
+ DeleteObjectFromMap(object, object_type, &layer_data->objdata);
+ }
-} // namespace object_tracker
+ template <typename T1>
+ bool ValidateDestroyObject(T1 object, VulkanObjectType object_type, const VkAllocationCallbacks *pAllocator,
+ const std::string &expected_custom_allocator_code,
+ const std::string &expected_default_allocator_code, object_lifetime *obj_data,
+ debug_report_data *report_data) {
+ auto object_handle = HandleToUint64(object);
+ bool custom_allocator = pAllocator != nullptr;
+ VkDebugReportObjectTypeEXT debug_object_type = get_debug_report_enum[object_type];
+ bool skip = false;
+
+ if (object_handle != VK_NULL_HANDLE) {
+ auto item = obj_data->object_map[object_type].find(object_handle);
+ if (item != obj_data->object_map[object_type].end()) {
+ ObjTrackState *pNode = item->second;
+ skip |= log_msg(report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, debug_object_type, object_handle,
+ kVUID_ObjectTracker_Info,
+ "OBJ_STAT Destroy %s obj 0x%" PRIxLEAST64 " (%" PRIu64 " total objs remain & %" PRIu64 " %s objs).",
+ object_string[object_type], HandleToUint64(object), obj_data->num_total_objects - 1,
+ obj_data->num_objects[pNode->object_type] - 1, object_string[object_type]);
+
+ auto allocated_with_custom = (pNode->status & OBJSTATUS_CUSTOM_ALLOCATOR) ? true : false;
+ if (allocated_with_custom && !custom_allocator && expected_custom_allocator_code != kVUIDUndefined) {
+ // This check only verifies that custom allocation callbacks were provided to both Create and Destroy calls,
+ // it cannot verify that these allocation callbacks are compatible with each other.
+ skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, debug_object_type, object_handle,
+ expected_custom_allocator_code,
+ "Custom allocator not specified while destroying %s obj 0x%" PRIxLEAST64
+ " but specified at creation.",
+ object_string[object_type], object_handle);
+ } else if (!allocated_with_custom && custom_allocator && expected_default_allocator_code != kVUIDUndefined) {
+ skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, debug_object_type, object_handle,
+ expected_default_allocator_code,
+ "Custom allocator specified while destroying %s obj 0x%" PRIxLEAST64
+ " but not specified at creation.",
+ object_string[object_type], object_handle);
+ }
+ }
+ }
+ return skip;
+ }
+
+ template <typename T1, typename T2>
+ bool InstanceValidateDestroyObject(T1 dispatchable_object, T2 object, VulkanObjectType object_type,
+ const VkAllocationCallbacks *pAllocator, const std::string &expected_custom_allocator_code,
+ const std::string &expected_default_allocator_code) {
+ instance_layer_data *layer_data = GetLayerDataPtr(get_dispatch_key(dispatchable_object), instance_layer_data_map);
+ return ValidateDestroyObject(object, object_type, pAllocator, expected_custom_allocator_code,
+ expected_default_allocator_code, &layer_data->objdata, layer_data->report_data);
+ }
+
+ template <typename T1, typename T2>
+ bool DeviceValidateDestroyObject(T1 dispatchable_object, T2 object, VulkanObjectType object_type,
+ const VkAllocationCallbacks *pAllocator, const std::string &expected_custom_allocator_code,
+ const std::string &expected_default_allocator_code) {
+ layer_data *layer_data = GetLayerDataPtr(get_dispatch_key(dispatchable_object), layer_data_map);
+ return ValidateDestroyObject(object, object_type, pAllocator, expected_custom_allocator_code,
+ expected_default_allocator_code, &layer_data->objdata, layer_data->report_data);
+ }
+
+#include "object_tracker.h"
+};
diff --git a/layers/object_lifetimes.h b/layers/object_lifetimes.h
index 26ee06f..aeb1097 100644
--- a/layers/object_lifetimes.h
+++ b/layers/object_lifetimes.h
@@ -25,8 +25,6 @@
#include "vulkan/vulkan.h"
#include "vk_object_types.h"
-namespace object_tracker {
-
// Object Status -- used to track state of individual objects
typedef VkFlags ObjectStatusFlags;
enum ObjectStatusFlagBits {
@@ -73,5 +71,3 @@
// Default constructor
object_lifetime() : num_objects{}, num_total_objects(0), object_map{} { object_map.resize(kVulkanObjectTypeMax + 1); }
};
-
-} // namespace object_tracker
diff --git a/layers/object_tracker.h b/layers/object_tracker.h
deleted file mode 100644
index f71d365..0000000
--- a/layers/object_tracker.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/* Copyright (c) 2015-2018 The Khronos Group Inc.
- * Copyright (c) 2015-2018 Valve Corporation
- * Copyright (c) 2015-2018 LunarG, Inc.
- * Copyright (C) 2015-2018 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Author: Mark Lobodzinski <mark@lunarg.com>
- * Author: Jon Ashburn <jon@lunarg.com>
- * Author: Tobin Ehlis <tobin@lunarg.com>
- */
-
-#pragma once
-
-#include <mutex>
-#include <cinttypes>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unordered_map>
-#include <unordered_set>
-
-#include "vk_loader_platform.h"
-#include "vulkan/vulkan.h"
-#include "vk_layer_config.h"
-#include "vk_layer_data.h"
-#include "vk_layer_logging.h"
-#include "vk_object_types.h"
-#include "vulkan/vk_layer.h"
-#include "vk_enum_string_helper.h"
-#include "vk_layer_extension_utils.h"
-#include "vk_layer_utils.h"
-#include "vulkan/vk_layer.h"
-#include "vk_dispatch_table_helper.h"
-#include "vk_extension_helper.h"
-#include "object_lifetimes.h"
-
-
-
-namespace object_tracker {
-
-struct layer_data;
-struct instance_layer_data;
-
-extern std::unordered_map<void *, layer_data *> layer_data_map;
-extern std::unordered_map<void *, instance_layer_data *> instance_layer_data_map;
-extern std::mutex global_lock;
-extern uint32_t loader_layer_if_version;
-extern const std::unordered_map<std::string, void *> name_to_funcptr_map;
-
-struct instance_layer_data {
- object_lifetime objdata;
- VkInstance instance;
-
- debug_report_data *report_data;
- std::vector<VkDebugReportCallbackEXT> logging_callback;
- std::vector<VkDebugUtilsMessengerEXT> logging_messenger;
- // The following are for keeping track of the temporary callbacks that can be used in vkCreateInstance and vkDestroyInstance
- uint32_t num_tmp_report_callbacks;
- VkDebugReportCallbackCreateInfoEXT *tmp_report_create_infos;
- VkDebugReportCallbackEXT *tmp_report_callbacks;
- uint32_t num_tmp_debug_messengers;
- VkDebugUtilsMessengerCreateInfoEXT *tmp_messenger_create_infos;
- VkDebugUtilsMessengerEXT *tmp_debug_messengers;
- VkLayerInstanceDispatchTable instance_dispatch_table;
-
- // Default constructor
- instance_layer_data()
- : report_data(nullptr),
- num_tmp_report_callbacks(0),
- tmp_report_create_infos(nullptr),
- tmp_report_callbacks(nullptr),
- num_tmp_debug_messengers(0),
- tmp_messenger_create_infos(nullptr),
- tmp_debug_messengers(nullptr),
- instance_dispatch_table{} {}
-};
-
-struct layer_data {
- object_lifetime objdata;
-
- std::unordered_set<std::string> device_extension_set;
- debug_report_data *report_data;
- VkLayerDispatchTable device_dispatch_table;
-
- instance_layer_data *instance_data;
- VkPhysicalDevice physical_device;
-
- // Default constructor
- layer_data() : instance_data(nullptr), physical_device(nullptr), report_data(nullptr), device_dispatch_table{} {}
-};
-
-} // namespace object_tracker
diff --git a/layers/object_tracker_core.cpp b/layers/object_tracker_core.cpp
deleted file mode 100644
index 39973c4..0000000
--- a/layers/object_tracker_core.cpp
+++ /dev/null
@@ -1,944 +0,0 @@
-/* Copyright (c) 2015-2018 The Khronos Group Inc.
- * Copyright (c) 2015-2018 Valve Corporation
- * Copyright (c) 2015-2018 LunarG, Inc.
- * Copyright (C) 2015-2018 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Author: Mark Lobodzinski <mark@lunarg.com>
- * Author: Jon Ashburn <jon@lunarg.com>
- * Author: Tobin Ehlis <tobine@google.com>
- */
-
-#define VALIDATION_ERROR_MAP_IMPL
-
-#include "object_tracker.h"
-#include "object_lifetime_validation.h"
-
-
-namespace object_tracker {
-
-#include "precall.h"
-#include "postcall.h"
-
-std::unordered_map<void *, layer_data *> layer_data_map;
-std::unordered_map<void *, instance_layer_data *> instance_layer_data_map;
-std::mutex global_lock;
-uint32_t loader_layer_if_version = CURRENT_LOADER_LAYER_INTERFACE_VERSION;
-
-void InitObjectTracker(instance_layer_data *my_data, const VkAllocationCallbacks *pAllocator) {
- layer_debug_report_actions(my_data->report_data, my_data->logging_callback, pAllocator, "lunarg_object_tracker");
- layer_debug_messenger_actions(my_data->report_data, my_data->logging_messenger, pAllocator, "lunarg_object_tracker");
-}
-
-
-VKAPI_ATTR void VKAPI_CALL CmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint,
- VkPipelineLayout layout, uint32_t set, uint32_t descriptorWriteCount,
- const VkWriteDescriptorSet *pDescriptorWrites) {
- bool skip = false;
- {
- std::lock_guard<std::mutex> lock(global_lock);
- skip |= PreCallValidateCmdPushDescriptorSetKHR(commandBuffer, pipelineBindPoint, layout, set, descriptorWriteCount,
- pDescriptorWrites);
- if (skip) return;
- }
- layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
- device_data->device_dispatch_table.CmdPushDescriptorSetKHR(commandBuffer, pipelineBindPoint, layout, set, descriptorWriteCount,
- pDescriptorWrites);
-}
-
-VKAPI_ATTR void VKAPI_CALL DestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) {
- dispatch_key key = get_dispatch_key(instance);
- instance_layer_data *instance_data = GetLayerDataPtr(key, instance_layer_data_map);
- {
- std::lock_guard<std::mutex> lock(global_lock);
- bool skip = PreCallValidateDestroyInstance(instance, pAllocator);
- if (skip) return;
- PreCallRecordDestroyInstance(instance, pAllocator);
- }
- instance_data->instance_dispatch_table.DestroyInstance(instance, pAllocator);
- {
- std::lock_guard<std::mutex> lock(global_lock);
- PostCallRecordDestroyInstance(instance, pAllocator);
- }
-}
-
-VKAPI_ATTR void VKAPI_CALL DestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator) {
- layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
- {
- bool skip = false;
- std::lock_guard<std::mutex> lock(global_lock);
- skip = PreCallValidateDestroyDevice(device, pAllocator);
- // Skipping down-chain destroydevice calls will hose any upstream validation layers
- PreCallRecordDestroyDevice(device, pAllocator);
- }
- dispatch_key key = get_dispatch_key(device);
- device_data->device_dispatch_table.DestroyDevice(device, pAllocator);
- FreeLayerDataPtr(key, layer_data_map);
-}
-
-VKAPI_ATTR void VKAPI_CALL GetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue *pQueue) {
- {
- std::lock_guard<std::mutex> lock(global_lock);
- bool skip = PreCallValidateGetDeviceQueue(device, queueFamilyIndex, queueIndex, pQueue);
- if (skip) return;
- }
- layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
- device_data->device_dispatch_table.GetDeviceQueue(device, queueFamilyIndex, queueIndex, pQueue);
- {
- if (*pQueue != VK_NULL_HANDLE) {
- std::lock_guard<std::mutex> lock(global_lock);
- PostCallRecordGetDeviceQueue(device, queueFamilyIndex, queueIndex, pQueue);
- }
- }
-}
-
-VKAPI_ATTR void VKAPI_CALL GetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2 *pQueueInfo, VkQueue *pQueue) {
- {
- std::lock_guard<std::mutex> lock(global_lock);
- bool skip = PreCallValidateGetDeviceQueue2(device, pQueueInfo, pQueue);
- if (skip) return;
- }
- layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
- device_data->device_dispatch_table.GetDeviceQueue2(device, pQueueInfo, pQueue);
- {
- if (*pQueue != VK_NULL_HANDLE) {
- std::lock_guard<std::mutex> lock(global_lock);
- PostCallRecordGetDeviceQueue2(device, pQueueInfo, pQueue);
- }
- }
-}
-
-VKAPI_ATTR void VKAPI_CALL UpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
- const VkWriteDescriptorSet *pDescriptorWrites, uint32_t descriptorCopyCount,
- const VkCopyDescriptorSet *pDescriptorCopies) {
- {
- std::lock_guard<std::mutex> lock(global_lock);
- bool skip = PreCallValidateUpdateDescriptorSets(device, descriptorWriteCount, pDescriptorWrites, descriptorCopyCount,
- pDescriptorCopies);
- if (skip) return;
- }
- layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
- device_data->device_dispatch_table.UpdateDescriptorSets(device, descriptorWriteCount, pDescriptorWrites, descriptorCopyCount,
- pDescriptorCopies);
-}
-
-VKAPI_ATTR VkResult VKAPI_CALL CreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount,
- const VkComputePipelineCreateInfo *pCreateInfos,
- const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) {
- {
- std::lock_guard<std::mutex> lock(global_lock);
- bool skip =
- PreCallValidateCreateComputePipelines(device, pipelineCache, createInfoCount, pCreateInfos, pAllocator, pPipelines);
- if (skip) return VK_ERROR_VALIDATION_FAILED_EXT;
- }
- layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
- VkResult result = device_data->device_dispatch_table.CreateComputePipelines(device, pipelineCache, createInfoCount,
- pCreateInfos, pAllocator, pPipelines);
- {
- std::lock_guard<std::mutex> lock(global_lock);
- PostCallRecordCreateComputePipelines(device, pipelineCache, createInfoCount, pCreateInfos, pAllocator, pPipelines);
- }
- return result;
-}
-
-VKAPI_ATTR VkResult VKAPI_CALL ResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool,
- VkDescriptorPoolResetFlags flags) {
- {
- std::lock_guard<std::mutex> lock(global_lock);
- bool skip = PreCallValidateResetDescriptorPool(device, descriptorPool, flags);
- if (skip) return VK_ERROR_VALIDATION_FAILED_EXT;
- PreCallRecordResetDescriptorPool(device, descriptorPool, flags);
- }
- layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
- VkResult result = device_data->device_dispatch_table.ResetDescriptorPool(device, descriptorPool, flags);
- return result;
-}
-
-VKAPI_ATTR VkResult VKAPI_CALL BeginCommandBuffer(VkCommandBuffer command_buffer, const VkCommandBufferBeginInfo *begin_info) {
- {
- std::lock_guard<std::mutex> lock(global_lock);
- bool skip = PreCallValidateBeginCommandBuffer(command_buffer, begin_info);
- if (skip) return VK_ERROR_VALIDATION_FAILED_EXT;
- }
- layer_data *device_data = GetLayerDataPtr(get_dispatch_key(command_buffer), layer_data_map);
- VkResult result = device_data->device_dispatch_table.BeginCommandBuffer(command_buffer, begin_info);
- return result;
-}
-
-VKAPI_ATTR VkResult VKAPI_CALL CreateDebugReportCallbackEXT(VkInstance instance,
- const VkDebugReportCallbackCreateInfoEXT *pCreateInfo,
- const VkAllocationCallbacks *pAllocator,
- VkDebugReportCallbackEXT *pCallback) {
- auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map);
- VkResult result =
- instance_data->instance_dispatch_table.CreateDebugReportCallbackEXT(instance, pCreateInfo, pAllocator, pCallback);
- if (VK_SUCCESS == result) {
- result = layer_create_report_callback(instance_data->report_data, false, pCreateInfo, pAllocator, pCallback);
- PostCallRecordCreateDebugReportCallbackEXT(instance, pCreateInfo, pAllocator, pCallback);
- }
- return result;
-}
-
-VKAPI_ATTR void VKAPI_CALL DestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT msgCallback,
- const VkAllocationCallbacks *pAllocator) {
- {
- std::lock_guard<std::mutex> lock(global_lock);
- bool skip = PreCallValidateDestroyDebugReportCallbackEXT(instance, msgCallback, pAllocator);
- if (skip) return;
- PreCallRecordDestroyDebugReportCallbackEXT(instance, msgCallback, pAllocator);
- }
- auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map);
- instance_data->instance_dispatch_table.DestroyDebugReportCallbackEXT(instance, msgCallback, pAllocator);
- layer_destroy_report_callback(instance_data->report_data, msgCallback, pAllocator);
-}
-
-VKAPI_ATTR void VKAPI_CALL DebugReportMessageEXT(VkInstance instance, VkDebugReportFlagsEXT flags,
- VkDebugReportObjectTypeEXT objType, uint64_t object, size_t location,
- int32_t msgCode, const char *pLayerPrefix, const char *pMsg) {
- auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map);
- instance_data->instance_dispatch_table.DebugReportMessageEXT(instance, flags, objType, object, location, msgCode, pLayerPrefix,
- pMsg);
-}
-
-// VK_EXT_debug_utils commands
-
-VKAPI_ATTR VkResult VKAPI_CALL SetDebugUtilsObjectNameEXT(VkDevice device, const VkDebugUtilsObjectNameInfoEXT *pNameInfo) {
- {
- std::lock_guard<std::mutex> lock(global_lock);
- bool skip = PreCallValidateSetDebugUtilsObjectNameEXT(device, pNameInfo);
- if (skip) return VK_ERROR_VALIDATION_FAILED_EXT;
- }
- layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
- if (pNameInfo->pObjectName) {
- std::lock_guard<std::mutex> lock(global_lock);
- dev_data->report_data->debugUtilsObjectNameMap->insert(
- std::make_pair<uint64_t, std::string>((uint64_t &&) pNameInfo->objectHandle, pNameInfo->pObjectName));
- } else {
- std::lock_guard<std::mutex> lock(global_lock);
- dev_data->report_data->debugUtilsObjectNameMap->erase(pNameInfo->objectHandle);
- }
- VkResult result = dev_data->device_dispatch_table.SetDebugUtilsObjectNameEXT(device, pNameInfo);
- return result;
-}
-
-VKAPI_ATTR VkResult VKAPI_CALL SetDebugUtilsObjectTagEXT(VkDevice device, const VkDebugUtilsObjectTagInfoEXT *pTagInfo) {
- {
- std::lock_guard<std::mutex> lock(global_lock);
- bool skip = PreCallValidateSetDebugUtilsObjectTagEXT(device, pTagInfo);
- if (skip) return VK_ERROR_VALIDATION_FAILED_EXT;
- }
- layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
- VkResult result = dev_data->device_dispatch_table.SetDebugUtilsObjectTagEXT(device, pTagInfo);
- return result;
-}
-
-VKAPI_ATTR void VKAPI_CALL QueueBeginDebugUtilsLabelEXT(VkQueue queue, const VkDebugUtilsLabelEXT *pLabelInfo) {
- layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(queue), layer_data_map);
- {
- std::lock_guard<std::mutex> lock(global_lock);
- bool skip = PreCallValidateQueueBeginDebugUtilsLabelEXT(queue, pLabelInfo);
- if (skip) return;
- BeginQueueDebugUtilsLabel(dev_data->report_data, queue, pLabelInfo);
- }
- dev_data->device_dispatch_table.QueueBeginDebugUtilsLabelEXT(queue, pLabelInfo);
-}
-
-VKAPI_ATTR void VKAPI_CALL QueueEndDebugUtilsLabelEXT(VkQueue queue) {
- {
- std::lock_guard<std::mutex> lock(global_lock);
- bool skip = PreCallValidateQueueEndDebugUtilsLabelEXT(queue);
- if (skip) return;
- }
- layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(queue), layer_data_map);
- dev_data->device_dispatch_table.QueueEndDebugUtilsLabelEXT(queue);
- {
- std::lock_guard<std::mutex> lock(global_lock);
- EndQueueDebugUtilsLabel(dev_data->report_data, queue);
- }
-}
-
-VKAPI_ATTR void VKAPI_CALL QueueInsertDebugUtilsLabelEXT(VkQueue queue, const VkDebugUtilsLabelEXT *pLabelInfo) {
- {
- std::lock_guard<std::mutex> lock(global_lock);
- bool skip = PreCallValidateQueueInsertDebugUtilsLabelEXT(queue, pLabelInfo);
- if (skip) return;
- }
- layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(queue), layer_data_map);
- {
- std::lock_guard<std::mutex> lock(global_lock);
- InsertQueueDebugUtilsLabel(dev_data->report_data, queue, pLabelInfo);
- }
- dev_data->device_dispatch_table.QueueInsertDebugUtilsLabelEXT(queue, pLabelInfo);
-}
-
-VKAPI_ATTR void VKAPI_CALL CmdBeginDebugUtilsLabelEXT(VkCommandBuffer commandBuffer, const VkDebugUtilsLabelEXT *pLabelInfo) {
- {
- std::lock_guard<std::mutex> lock(global_lock);
- bool skip = PreCallValidateCmdBeginDebugUtilsLabelEXT(commandBuffer, pLabelInfo);
- if (skip) return;
- }
- layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
- {
- std::lock_guard<std::mutex> lock(global_lock);
- BeginCmdDebugUtilsLabel(dev_data->report_data, commandBuffer, pLabelInfo);
- }
- dev_data->device_dispatch_table.CmdBeginDebugUtilsLabelEXT(commandBuffer, pLabelInfo);
-}
-
-VKAPI_ATTR void VKAPI_CALL CmdEndDebugUtilsLabelEXT(VkCommandBuffer commandBuffer) {
- {
- std::lock_guard<std::mutex> lock(global_lock);
- bool skip = PreCallValidateCmdEndDebugUtilsLabelEXT(commandBuffer);
- if (skip) return;
- }
- layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
- dev_data->device_dispatch_table.CmdEndDebugUtilsLabelEXT(commandBuffer);
- {
- std::lock_guard<std::mutex> lock(global_lock);
- EndCmdDebugUtilsLabel(dev_data->report_data, commandBuffer);
- }
-}
-
-VKAPI_ATTR void VKAPI_CALL CmdInsertDebugUtilsLabelEXT(VkCommandBuffer commandBuffer, const VkDebugUtilsLabelEXT *pLabelInfo) {
- {
- std::lock_guard<std::mutex> lock(global_lock);
- bool skip = PreCallValidateCmdInsertDebugUtilsLabelEXT(commandBuffer, pLabelInfo);
- if (skip) return;
- }
- layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
- {
- std::lock_guard<std::mutex> lock(global_lock);
- InsertCmdDebugUtilsLabel(dev_data->report_data, commandBuffer, pLabelInfo);
- }
- dev_data->device_dispatch_table.CmdInsertDebugUtilsLabelEXT(commandBuffer, pLabelInfo);
-}
-
-VKAPI_ATTR VkResult VKAPI_CALL CreateDebugUtilsMessengerEXT(VkInstance instance,
- const VkDebugUtilsMessengerCreateInfoEXT *pCreateInfo,
- const VkAllocationCallbacks *pAllocator,
- VkDebugUtilsMessengerEXT *pMessenger) {
- {
- std::lock_guard<std::mutex> lock(global_lock);
- bool skip = PreCallValidateCreateDebugUtilsMessengerEXT(instance, pCreateInfo, pAllocator, pMessenger);
- if (skip) return VK_ERROR_VALIDATION_FAILED_EXT;
- }
- auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map);
- VkResult result =
- instance_data->instance_dispatch_table.CreateDebugUtilsMessengerEXT(instance, pCreateInfo, pAllocator, pMessenger);
- if (VK_SUCCESS == result) {
- result = layer_create_messenger_callback(instance_data->report_data, false, pCreateInfo, pAllocator, pMessenger);
- PostCallRecordCreateDebugUtilsMessengerEXT(instance, pCreateInfo, pAllocator, pMessenger);
- }
- return result;
-}
-
-VKAPI_ATTR void VKAPI_CALL DestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT messenger,
- const VkAllocationCallbacks *pAllocator) {
- {
- std::lock_guard<std::mutex> lock(global_lock);
- bool skip = PreCallValidateDestroyDebugUtilsMessengerEXT(instance, messenger, pAllocator);
- if (skip) return;
- PreCallRecordDestroyDebugUtilsMessengerEXT(instance, messenger, pAllocator);
- }
- auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map);
- instance_data->instance_dispatch_table.DestroyDebugUtilsMessengerEXT(instance, messenger, pAllocator);
- layer_destroy_messenger_callback(instance_data->report_data, messenger, pAllocator);
-}
-
-VKAPI_ATTR void VKAPI_CALL SubmitDebugUtilsMessageEXT(VkInstance instance, VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
- VkDebugUtilsMessageTypeFlagsEXT messageTypes,
- const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData) {
- {
- std::lock_guard<std::mutex> lock(global_lock);
- bool skip = PreCallValidateSubmitDebugUtilsMessageEXT(instance, messageSeverity, messageTypes, pCallbackData);
- if (skip) return;
- }
-
- auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map);
- instance_data->instance_dispatch_table.SubmitDebugUtilsMessageEXT(instance, messageSeverity, messageTypes, pCallbackData);
-}
-
-static const VkExtensionProperties instance_extensions[] = { {VK_EXT_DEBUG_REPORT_EXTENSION_NAME, VK_EXT_DEBUG_REPORT_SPEC_VERSION},
- {VK_EXT_DEBUG_UTILS_EXTENSION_NAME, VK_EXT_DEBUG_UTILS_SPEC_VERSION} };
-
-static const VkLayerProperties globalLayerProps = { "VK_LAYER_LUNARG_object_tracker",
- VK_LAYER_API_VERSION, // specVersion
- 1, // implementationVersion
- "LunarG Validation Layer" };
-
-VKAPI_ATTR VkResult VKAPI_CALL EnumerateInstanceLayerProperties(uint32_t *pCount, VkLayerProperties *pProperties) {
- return util_GetLayerProperties(1, &globalLayerProps, pCount, pProperties);
-}
-
-VKAPI_ATTR VkResult VKAPI_CALL EnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pCount,
- VkLayerProperties *pProperties) {
- {
- std::lock_guard<std::mutex> lock(global_lock);
- bool skip = PreCallValidateEnumerateDeviceLayerProperties(physicalDevice, pCount, pProperties);
- if (skip) return VK_ERROR_VALIDATION_FAILED_EXT;
- }
- return util_GetLayerProperties(1, &globalLayerProps, pCount, pProperties);
-}
-
-VKAPI_ATTR VkResult VKAPI_CALL EnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pCount,
- VkExtensionProperties *pProperties) {
- if (pLayerName && !strcmp(pLayerName, globalLayerProps.layerName))
- return util_GetExtensionProperties(1, instance_extensions, pCount, pProperties);
-
- return VK_ERROR_LAYER_NOT_PRESENT;
-}
-
-VKAPI_ATTR VkResult VKAPI_CALL EnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char *pLayerName,
- uint32_t *pCount, VkExtensionProperties *pProperties) {
- {
- std::lock_guard<std::mutex> lock(global_lock);
- bool skip = PreCallValidateEnumerateDeviceExtensionProperties(physicalDevice, pLayerName, pCount, pProperties);
- if (skip) return VK_ERROR_VALIDATION_FAILED_EXT;
- }
- if (pLayerName && !strcmp(pLayerName, globalLayerProps.layerName))
- return util_GetExtensionProperties(0, nullptr, pCount, pProperties);
- auto instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), instance_layer_data_map);
- return instance_data->instance_dispatch_table.EnumerateDeviceExtensionProperties(physicalDevice, NULL, pCount, pProperties);
-}
-
-VKAPI_ATTR VkResult VKAPI_CALL CreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
- const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) {
- std::lock_guard<std::mutex> lock(global_lock);
- bool skip = PreCallValidateCreateDevice(physicalDevice, pCreateInfo, pAllocator, pDevice);
- if (skip) return VK_ERROR_VALIDATION_FAILED_EXT;
-
- instance_layer_data *phy_dev_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), instance_layer_data_map);
- VkLayerDeviceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO);
-
- assert(chain_info->u.pLayerInfo);
- PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr;
- PFN_vkGetDeviceProcAddr fpGetDeviceProcAddr = chain_info->u.pLayerInfo->pfnNextGetDeviceProcAddr;
- PFN_vkCreateDevice fpCreateDevice = (PFN_vkCreateDevice)fpGetInstanceProcAddr(phy_dev_data->instance, "vkCreateDevice");
- if (fpCreateDevice == NULL) {
- return VK_ERROR_INITIALIZATION_FAILED;
- }
-
- // Advance the link info for the next element on the chain
- chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext;
-
- VkResult result = fpCreateDevice(physicalDevice, pCreateInfo, pAllocator, pDevice);
- if (result != VK_SUCCESS) {
- return result;
- }
-
- layer_data *device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
- device_data->report_data = layer_debug_utils_create_device(phy_dev_data->report_data, *pDevice);
- layer_init_device_dispatch_table(*pDevice, &device_data->device_dispatch_table, fpGetDeviceProcAddr);
-
- // Save pCreateInfo device extension list for GetDeviceProcAddr()
- for (uint32_t extn = 0; extn < pCreateInfo->enabledExtensionCount; extn++) {
- device_data->device_extension_set.insert(pCreateInfo->ppEnabledExtensionNames[extn]);
- }
-
- // Add link back to physDev
- device_data->physical_device = physicalDevice;
- device_data->instance_data = phy_dev_data;
-
- PostCallRecordCreateDevice(physicalDevice, pCreateInfo, pAllocator, pDevice);
-
- return result;
-}
-
-VKAPI_ATTR VkResult VKAPI_CALL GetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t *pSwapchainImageCount,
- VkImage *pSwapchainImages) {
- {
- std::lock_guard<std::mutex> lock(global_lock);
- bool skip = PreCallValidateGetSwapchainImagesKHR(device, swapchain, pSwapchainImageCount, pSwapchainImages);
- if (skip) return VK_ERROR_VALIDATION_FAILED_EXT;
- }
- layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
- VkResult result =
- device_data->device_dispatch_table.GetSwapchainImagesKHR(device, swapchain, pSwapchainImageCount, pSwapchainImages);
- {
- std::lock_guard<std::mutex> lock(global_lock);
- PostCallRecordGetSwapchainImagesKHR(device, swapchain, pSwapchainImageCount, pSwapchainImages);
- }
- return result;
-}
-
-VKAPI_ATTR VkResult VKAPI_CALL CreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
- const VkAllocationCallbacks *pAllocator,
- VkDescriptorSetLayout *pSetLayout) {
- {
- std::lock_guard<std::mutex> lock(global_lock);
- bool skip = PreCallValidateCreateDescriptorSetLayout(device, pCreateInfo, pAllocator, pSetLayout);
- if (skip) return VK_ERROR_VALIDATION_FAILED_EXT;
- }
- layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
- VkResult result = device_data->device_dispatch_table.CreateDescriptorSetLayout(device, pCreateInfo, pAllocator, pSetLayout);
- if (VK_SUCCESS == result) {
- std::lock_guard<std::mutex> lock(global_lock);
- PostCallRecordCreateDescriptorSetLayout(device, pCreateInfo, pAllocator, pSetLayout);
- }
- return result;
-}
-
-VKAPI_ATTR void VKAPI_CALL GetDescriptorSetLayoutSupport(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
- VkDescriptorSetLayoutSupport *pSupport) {
- bool skip = false;
- {
- std::lock_guard<std::mutex> lock(global_lock);
- skip = PreCallValidateGetDescriptorSetLayoutSupport(device, pCreateInfo, pSupport);
- }
- if (skip) return;
- GetLayerDataPtr(get_dispatch_key(device), layer_data_map)
- ->device_dispatch_table.GetDescriptorSetLayoutSupport(device, pCreateInfo, pSupport);
-}
-
-VKAPI_ATTR void VKAPI_CALL GetDescriptorSetLayoutSupportKHR(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
- VkDescriptorSetLayoutSupport *pSupport) {
- bool skip = false;
- {
- std::lock_guard<std::mutex> lock(global_lock);
- skip = PreCallValidateGetDescriptorSetLayoutSupport(device, pCreateInfo, pSupport);
- }
- if (skip) return;
- GetLayerDataPtr(get_dispatch_key(device), layer_data_map)
- ->device_dispatch_table.GetDescriptorSetLayoutSupportKHR(device, pCreateInfo, pSupport);
-}
-
-VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice,
- uint32_t *pQueueFamilyPropertyCount,
- VkQueueFamilyProperties *pQueueFamilyProperties) {
- bool skip = false;
- {
- std::lock_guard<std::mutex> lock(global_lock);
- skip |= PreCallValidateGetPhysicalDeviceQueueFamilyProperties(physicalDevice, pQueueFamilyPropertyCount,
- pQueueFamilyProperties);
- }
- if (skip) return;
-
- auto instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), instance_layer_data_map);
- instance_data->instance_dispatch_table.GetPhysicalDeviceQueueFamilyProperties(physicalDevice, pQueueFamilyPropertyCount,
- pQueueFamilyProperties);
- std::lock_guard<std::mutex> lock(global_lock);
- PostCallRecordGetPhysicalDeviceQueueFamilyProperties(physicalDevice, pQueueFamilyPropertyCount, pQueueFamilyProperties);
-}
-
-VKAPI_ATTR VkResult VKAPI_CALL CreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
- VkInstance *pInstance) {
- VkLayerInstanceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO);
-
- assert(chain_info->u.pLayerInfo);
- PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr;
- PFN_vkCreateInstance fpCreateInstance = (PFN_vkCreateInstance)fpGetInstanceProcAddr(NULL, "vkCreateInstance");
- if (fpCreateInstance == NULL) {
- return VK_ERROR_INITIALIZATION_FAILED;
- }
-
- // Advance the link info for the next element on the chain
- chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext;
-
- VkResult result = fpCreateInstance(pCreateInfo, pAllocator, pInstance);
- if (result != VK_SUCCESS) {
- return result;
- }
-
- instance_layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), instance_layer_data_map);
- instance_data->instance = *pInstance;
- layer_init_instance_dispatch_table(*pInstance, &instance_data->instance_dispatch_table, fpGetInstanceProcAddr);
-
- // Look for one or more debug report create info structures, and copy the
- // callback(s) for each one found (for use by vkDestroyInstance)
- layer_copy_tmp_debug_messengers(pCreateInfo->pNext, &instance_data->num_tmp_debug_messengers,
- &instance_data->tmp_messenger_create_infos, &instance_data->tmp_debug_messengers);
- layer_copy_tmp_report_callbacks(pCreateInfo->pNext, &instance_data->num_tmp_report_callbacks,
- &instance_data->tmp_report_create_infos, &instance_data->tmp_report_callbacks);
-
- instance_data->report_data =
- debug_utils_create_instance(&instance_data->instance_dispatch_table, *pInstance, pCreateInfo->enabledExtensionCount,
- pCreateInfo->ppEnabledExtensionNames);
-
- InitObjectTracker(instance_data, pAllocator);
-
- PostCallRecordCreateInstance(pCreateInfo, pAllocator, pInstance);
-
- return result;
-}
-
-VKAPI_ATTR VkResult VKAPI_CALL EnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount,
- VkPhysicalDevice *pPhysicalDevices) {
- bool skip = VK_FALSE;
- {
- std::lock_guard<std::mutex> lock(global_lock);
- skip |= PreCallValidateEnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices);
- }
- if (skip) return VK_ERROR_VALIDATION_FAILED_EXT;
-
- instance_layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map);
- VkResult result =
- instance_data->instance_dispatch_table.EnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices);
- if (result == VK_SUCCESS) {
- std::lock_guard<std::mutex> lock(global_lock);
- PostCallRecordEnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices);
- }
- return result;
-}
-
-VKAPI_ATTR VkResult VKAPI_CALL AllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
- VkCommandBuffer *pCommandBuffers) {
- bool skip = VK_FALSE;
- {
- std::unique_lock<std::mutex> lock(global_lock);
- skip = PreCallValidateAllocateCommandBuffers(device, pAllocateInfo, pCommandBuffers);
- }
- if (skip) return VK_ERROR_VALIDATION_FAILED_EXT;
-
- layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
- VkResult result = device_data->device_dispatch_table.AllocateCommandBuffers(device, pAllocateInfo, pCommandBuffers);
- if (VK_SUCCESS == result) {
- std::unique_lock<std::mutex> lock(global_lock);
- PostCallRecordAllocateCommandBuffers(device, pAllocateInfo, pCommandBuffers);
- }
-
- return result;
-}
-
-VKAPI_ATTR VkResult VKAPI_CALL AllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo *pAllocateInfo,
- VkDescriptorSet *pDescriptorSets) {
- bool skip = VK_FALSE;
- {
- std::unique_lock<std::mutex> lock(global_lock);
- skip = PreCallValidateAllocateDescriptorSets(device, pAllocateInfo, pDescriptorSets);
- }
- if (skip) return VK_ERROR_VALIDATION_FAILED_EXT;
-
- layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
- VkResult result = device_data->device_dispatch_table.AllocateDescriptorSets(device, pAllocateInfo, pDescriptorSets);
-
- if (VK_SUCCESS == result) {
- std::unique_lock<std::mutex> lock(global_lock);
- PostCallRecordAllocateDescriptorSets(device, pAllocateInfo, pDescriptorSets);
- }
-
- return result;
-}
-
-VKAPI_ATTR void VKAPI_CALL FreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
- const VkCommandBuffer *pCommandBuffers) {
- bool skip = false;
- {
- std::unique_lock<std::mutex> lock(global_lock);
- skip = PreCallValidateFreeCommandBuffers(device, commandPool, commandBufferCount, pCommandBuffers);
- if (skip) return;
- PreCallRecordFreeCommandBuffers(device, commandPool, commandBufferCount, pCommandBuffers);
- }
- layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
- device_data->device_dispatch_table.FreeCommandBuffers(device, commandPool, commandBufferCount, pCommandBuffers);
-}
-
-VKAPI_ATTR void VKAPI_CALL DestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, const VkAllocationCallbacks *pAllocator) {
- bool skip = false;
- {
- std::unique_lock<std::mutex> lock(global_lock);
- skip = PreCallValidateDestroySwapchainKHR(device, swapchain, pAllocator);
- if (skip) return;
- PreCallRecordDestroySwapchainKHR(device, swapchain, pAllocator);
- }
- layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
- device_data->device_dispatch_table.DestroySwapchainKHR(device, swapchain, pAllocator);
-}
-
-VKAPI_ATTR VkResult VKAPI_CALL FreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount,
- const VkDescriptorSet *pDescriptorSets) {
- bool skip = false;
- {
- std::unique_lock<std::mutex> lock(global_lock);
- skip = PreCallValidateFreeDescriptorSets(device, descriptorPool, descriptorSetCount, pDescriptorSets);
- if (skip) return VK_ERROR_VALIDATION_FAILED_EXT;
- PreCallRecordFreeDescriptorSets(device, descriptorPool, descriptorSetCount, pDescriptorSets);
- }
- layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
- return device_data->device_dispatch_table.FreeDescriptorSets(device, descriptorPool, descriptorSetCount, pDescriptorSets);
-}
-
-VKAPI_ATTR void VKAPI_CALL DestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool,
- const VkAllocationCallbacks *pAllocator) {
- bool skip = false;
- {
- std::unique_lock<std::mutex> lock(global_lock);
- skip = PreCallValidateDestroyDescriptorPool(device, descriptorPool, pAllocator);
- if (skip) return;
- PreCallRecordDestroyDescriptorPool(device, descriptorPool, pAllocator);
- }
- layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
- device_data->device_dispatch_table.DestroyDescriptorPool(device, descriptorPool, pAllocator);
-}
-
-VKAPI_ATTR void VKAPI_CALL DestroyCommandPool(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks *pAllocator) {
- bool skip = false;
- {
- std::unique_lock<std::mutex> lock(global_lock);
- skip = PreCallValidateDestroyCommandPool(device, commandPool, pAllocator);
- if (skip) return;
- PreCallRecordDestroyCommandPool(device, commandPool, pAllocator);
- }
- layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
- device_data->device_dispatch_table.DestroyCommandPool(device, commandPool, pAllocator);
-}
-
-VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceQueueFamilyProperties2(VkPhysicalDevice physicalDevice,
- uint32_t *pQueueFamilyPropertyCount,
- VkQueueFamilyProperties2KHR *pQueueFamilyProperties) {
- bool skip = false;
- {
- std::lock_guard<std::mutex> lock(global_lock);
- skip |= PreCallValidateGetPhysicalDeviceQueueFamilyProperties2(physicalDevice, pQueueFamilyPropertyCount,
- pQueueFamilyProperties);
- }
- if (skip) return;
- instance_layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), instance_layer_data_map);
- instance_data->instance_dispatch_table.GetPhysicalDeviceQueueFamilyProperties2(physicalDevice, pQueueFamilyPropertyCount,
- pQueueFamilyProperties);
- std::lock_guard<std::mutex> lock(global_lock);
- PostCallRecordGetPhysicalDeviceQueueFamilyProperties2(physicalDevice, pQueueFamilyPropertyCount, pQueueFamilyProperties);
-}
-
-VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceQueueFamilyProperties2KHR(VkPhysicalDevice physicalDevice,
- uint32_t *pQueueFamilyPropertyCount,
- VkQueueFamilyProperties2KHR *pQueueFamilyProperties) {
-
- bool skip = false;
- {
- std::lock_guard<std::mutex> lock(global_lock);
- skip |= PreCallValidateGetPhysicalDeviceQueueFamilyProperties2(physicalDevice, pQueueFamilyPropertyCount,
- pQueueFamilyProperties);
- }
- if (skip) return;
- instance_layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), instance_layer_data_map);
- instance_data->instance_dispatch_table.GetPhysicalDeviceQueueFamilyProperties2(physicalDevice, pQueueFamilyPropertyCount,
- pQueueFamilyProperties);
- std::lock_guard<std::mutex> lock(global_lock);
- PostCallRecordGetPhysicalDeviceQueueFamilyProperties2(physicalDevice, pQueueFamilyPropertyCount, pQueueFamilyProperties);
-}
-
-VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
- VkDisplayPropertiesKHR *pProperties) {
- bool skip = false;
- {
- std::lock_guard<std::mutex> lock(global_lock);
- skip |= PreCallValidateGetPhysicalDeviceDisplayPropertiesKHR(physicalDevice, pPropertyCount, pProperties);
- }
- if (skip) return VK_ERROR_VALIDATION_FAILED_EXT;
-
- instance_layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), instance_layer_data_map);
- VkResult result =
- instance_data->instance_dispatch_table.GetPhysicalDeviceDisplayPropertiesKHR(physicalDevice, pPropertyCount, pProperties);
-
- if (result == VK_SUCCESS) {
- std::lock_guard<std::mutex> lock(global_lock);
- PostCallRecordGetPhysicalDeviceDisplayPropertiesKHR(physicalDevice, pPropertyCount, pProperties);
- }
- return result;
-}
-
-VKAPI_ATTR VkResult VKAPI_CALL GetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
- uint32_t *pPropertyCount, VkDisplayModePropertiesKHR *pProperties) {
- bool skip = false;
- {
- std::unique_lock<std::mutex> lock(global_lock);
- skip |= PreCallValidateGetDisplayModePropertiesKHR(physicalDevice, display, pPropertyCount, pProperties);
- }
- if (skip) return VK_ERROR_VALIDATION_FAILED_EXT;
-
- instance_layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), instance_layer_data_map);
- VkResult result =
- instance_data->instance_dispatch_table.GetDisplayModePropertiesKHR(physicalDevice, display, pPropertyCount, pProperties);
-
- if (result == VK_SUCCESS) {
- if (pProperties) {
- std::unique_lock<std::mutex> lock(global_lock);
- PostCallRecordGetDisplayModePropertiesKHR(physicalDevice, display, pPropertyCount, pProperties);
- }
- }
- return result;
-}
-
-VKAPI_ATTR VkResult VKAPI_CALL DebugMarkerSetObjectNameEXT(VkDevice device, const VkDebugMarkerObjectNameInfoEXT *pNameInfo) {
- bool skip = VK_FALSE;
- layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
- {
- std::unique_lock<std::mutex> lock(global_lock);
- skip |= PreCallValidateDebugMarkerSetObjectNameEXT(device, pNameInfo);
- if (skip) return VK_ERROR_VALIDATION_FAILED_EXT;
- if (pNameInfo->pObjectName) {
- dev_data->report_data->debugObjectNameMap->insert(
- std::make_pair<uint64_t, std::string>((uint64_t &&) pNameInfo->object, pNameInfo->pObjectName));
- } else {
- dev_data->report_data->debugObjectNameMap->erase(pNameInfo->object);
- }
- }
- VkResult result = dev_data->device_dispatch_table.DebugMarkerSetObjectNameEXT(device, pNameInfo);
- return result;
-}
-
-// This is not a Vulkan API, but is part of the loader-layer interface.
-VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetPhysicalDeviceProcAddr(VkInstance instance, const char *funcName) {
- instance_layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map);
- if (instance_data->instance_dispatch_table.GetPhysicalDeviceProcAddr == NULL) {
- return NULL;
- }
- return instance_data->instance_dispatch_table.GetPhysicalDeviceProcAddr(instance, funcName);
-}
-
-
-VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetDeviceProcAddr(VkDevice device, const char *funcName) {
- {
- std::unique_lock<std::mutex> lock(global_lock);
- bool skip = PreCallValidateGetDeviceProcAddr(device, funcName);
- if (skip) return nullptr;
- }
- layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
- if (!ApiParentExtensionEnabled(funcName, device_data->device_extension_set)) {
- return nullptr;
- }
- const auto item = name_to_funcptr_map.find(funcName);
- if (item != name_to_funcptr_map.end()) {
- return reinterpret_cast<PFN_vkVoidFunction>(item->second);
- }
- if (!device_data->device_dispatch_table.GetDeviceProcAddr) return NULL;
- return device_data->device_dispatch_table.GetDeviceProcAddr(device, funcName);
-}
-
-VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetInstanceProcAddr(VkInstance instance, const char *funcName) {
- if (instance != nullptr) {
- std::unique_lock<std::mutex> lock(global_lock);
- bool skip = PreCallValidateGetInstanceProcAddr(instance, funcName);
- if (skip) return nullptr;
- }
- const auto item = name_to_funcptr_map.find(funcName);
- if (item != name_to_funcptr_map.end()) {
- return reinterpret_cast<PFN_vkVoidFunction>(item->second);
- }
- instance_layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map);
- if (!instance_data->instance_dispatch_table.GetInstanceProcAddr) return nullptr;
- return instance_data->instance_dispatch_table.GetInstanceProcAddr(instance, funcName);
-}
-
-VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceDisplayProperties2KHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
- VkDisplayProperties2KHR *pProperties) {
- {
- std::lock_guard<std::mutex> lock(global_lock);
- bool skip = PreCallValidateGetPhysicalDeviceDisplayProperties2KHR(physicalDevice, pPropertyCount, pProperties);
- if (skip) return VK_ERROR_VALIDATION_FAILED_EXT;
- }
- instance_layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), instance_layer_data_map);
- VkResult result =
- instance_data->instance_dispatch_table.GetPhysicalDeviceDisplayProperties2KHR(physicalDevice, pPropertyCount, pProperties);
- if (pProperties && (VK_SUCCESS == result || VK_INCOMPLETE == result)) {
- std::lock_guard<std::mutex> lock(global_lock);
- PostCallRecordGetPhysicalDeviceDisplayProperties2KHR(physicalDevice, pPropertyCount, pProperties);
- }
-
- return result;
-}
-
-VKAPI_ATTR VkResult VKAPI_CALL GetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice, uint32_t planeIndex,
- uint32_t *pDisplayCount, VkDisplayKHR *pDisplays) {
- {
- std::lock_guard<std::mutex> lock(global_lock);
- bool skip = PreCallValidateGetDisplayPlaneSupportedDisplaysKHR(physicalDevice, planeIndex, pDisplayCount, pDisplays);
- if (skip) return VK_ERROR_VALIDATION_FAILED_EXT;
- }
- instance_layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), instance_layer_data_map);
- VkResult result = instance_data->instance_dispatch_table.GetDisplayPlaneSupportedDisplaysKHR(physicalDevice, planeIndex,
- pDisplayCount, pDisplays);
- if (pDisplays && (VK_SUCCESS == result || VK_INCOMPLETE == result)) {
- std::lock_guard<std::mutex> lock(global_lock);
- PostCallRecordGetDisplayPlaneSupportedDisplaysKHR(physicalDevice, planeIndex, pDisplayCount, pDisplays);
- }
- return result;
-}
-
-VKAPI_ATTR VkResult VKAPI_CALL GetDisplayModeProperties2KHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
- uint32_t *pPropertyCount, VkDisplayModeProperties2KHR *pProperties) {
- {
- std::lock_guard<std::mutex> lock(global_lock);
- bool skip = PreCallValidateGetDisplayModeProperties2KHR(physicalDevice, display, pPropertyCount, pProperties);
- if (skip) return VK_ERROR_VALIDATION_FAILED_EXT;
- }
- instance_layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), instance_layer_data_map);
- VkResult result =
- instance_data->instance_dispatch_table.GetDisplayModeProperties2KHR(physicalDevice, display, pPropertyCount, pProperties);
- if (pProperties && (VK_SUCCESS == result || VK_INCOMPLETE == result)) {
- std::lock_guard<std::mutex> lock(global_lock);
- PostCallRecordGetDisplayModeProperties2KHR(physicalDevice, display, pPropertyCount, pProperties);
- }
- return result;
-}
-
-} // namespace object_tracker
-
-VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pCount,
- VkExtensionProperties *pProperties) {
- return object_tracker::EnumerateInstanceExtensionProperties(pLayerName, pCount, pProperties);
-}
-
-VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(uint32_t *pCount,
- VkLayerProperties *pProperties) {
- return object_tracker::EnumerateInstanceLayerProperties(pCount, pProperties);
-}
-
-VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pCount,
- VkLayerProperties *pProperties) {
- // The layer command handles VK_NULL_HANDLE just fine internally
- assert(physicalDevice == VK_NULL_HANDLE);
- return object_tracker::EnumerateDeviceLayerProperties(VK_NULL_HANDLE, pCount, pProperties);
-}
-
-VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice dev, const char *funcName) {
- return object_tracker::GetDeviceProcAddr(dev, funcName);
-}
-
-VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *funcName) {
- return object_tracker::GetInstanceProcAddr(instance, funcName);
-}
-
-VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
- const char *pLayerName, uint32_t *pCount,
- VkExtensionProperties *pProperties) {
- // The layer command handles VK_NULL_HANDLE just fine internally
- assert(physicalDevice == VK_NULL_HANDLE);
- return object_tracker::EnumerateDeviceExtensionProperties(VK_NULL_HANDLE, pLayerName, pCount, pProperties);
-}
-
-VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_layerGetPhysicalDeviceProcAddr(VkInstance instance,
- const char *funcName) {
- return object_tracker::GetPhysicalDeviceProcAddr(instance, funcName);
-}
-
-VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkNegotiateLoaderLayerInterfaceVersion(VkNegotiateLayerInterface *pVersionStruct) {
- assert(pVersionStruct != NULL);
- assert(pVersionStruct->sType == LAYER_NEGOTIATE_INTERFACE_STRUCT);
-
- // Fill in the function pointers if our version is at least capable of having the structure contain them.
- if (pVersionStruct->loaderLayerInterfaceVersion >= 2) {
- pVersionStruct->pfnGetInstanceProcAddr = vkGetInstanceProcAddr;
- pVersionStruct->pfnGetDeviceProcAddr = vkGetDeviceProcAddr;
- pVersionStruct->pfnGetPhysicalDeviceProcAddr = vk_layerGetPhysicalDeviceProcAddr;
- }
-
- if (pVersionStruct->loaderLayerInterfaceVersion < CURRENT_LOADER_LAYER_INTERFACE_VERSION) {
- object_tracker::loader_layer_if_version = pVersionStruct->loaderLayerInterfaceVersion;
- } else if (pVersionStruct->loaderLayerInterfaceVersion > CURRENT_LOADER_LAYER_INTERFACE_VERSION) {
- pVersionStruct->loaderLayerInterfaceVersion = CURRENT_LOADER_LAYER_INTERFACE_VERSION;
- }
-
- return VK_SUCCESS;
-}
diff --git a/layers/object_tracker_utils.cpp b/layers/object_tracker_utils.cpp
index 8206c07..88f367e 100644
--- a/layers/object_tracker_utils.cpp
+++ b/layers/object_tracker_utils.cpp
@@ -20,15 +20,13 @@
* Author: Tobin Ehlis <tobin@lunarg.com>
*/
-#include "object_tracker.h"
+#include "chassis.h"
#include "object_lifetime_validation.h"
-namespace object_tracker {
-
uint64_t object_track_index = 0;
// Add new queue to head of global queue list
-void AddQueueInfo(VkDevice device, uint32_t queue_node_index, VkQueue queue) {
+void ObjectLifetimes::AddQueueInfo(VkDevice device, uint32_t queue_node_index, VkQueue queue) {
layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
auto queueItem = device_data->objdata.queue_info_map.find(queue);
if (queueItem == device_data->objdata.queue_info_map.end()) {
@@ -47,7 +45,7 @@
}
// Destroy memRef lists and free all memory
-void DestroyQueueDataStructures(VkDevice device) {
+void ObjectLifetimes::DestroyQueueDataStructures(VkDevice device) {
layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
for (auto queue_item : device_data->objdata.queue_info_map) {
@@ -73,7 +71,7 @@
}
// Check Queue type flags for selected queue operations
-void ValidateQueueFlags(VkQueue queue, const char *function) {
+void ObjectLifetimes::ValidateQueueFlags(VkQueue queue, const char *function) {
layer_data *device_data = GetLayerDataPtr(get_dispatch_key(queue), layer_data_map);
auto queue_item = device_data->objdata.queue_info_map.find(queue);
if (queue_item != device_data->objdata.queue_info_map.end()) {
@@ -94,7 +92,8 @@
// Look for this device object in any of the instance child devices lists.
// NOTE: This is of dubious value. In most circumstances Vulkan will die a flaming death if a dispatchable object is invalid.
// However, if this layer is loaded first and GetProcAddress is used to make API calls, it will detect bad DOs.
-bool ValidateDeviceObject(uint64_t device_handle, const std::string &invalid_handle_code, const std::string &wrong_device_code) {
+bool ObjectLifetimes::ValidateDeviceObject(uint64_t device_handle, const std::string &invalid_handle_code,
+ const std::string &wrong_device_code) {
VkInstance last_instance = nullptr;
for (auto instance_data : instance_layer_data_map) {
for (auto object : instance_data.second->objdata.object_map[kVulkanObjectTypeDevice]) {
@@ -109,8 +108,8 @@
invalid_handle_code, "Invalid Device Object 0x%" PRIxLEAST64 ".", device_handle);
}
-void AllocateCommandBuffer(VkDevice device, const VkCommandPool command_pool, const VkCommandBuffer command_buffer,
- VkCommandBufferLevel level) {
+void ObjectLifetimes::AllocateCommandBuffer(VkDevice device, const VkCommandPool command_pool, const VkCommandBuffer command_buffer,
+ VkCommandBufferLevel level) {
layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
log_msg(device_data->report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
@@ -131,7 +130,7 @@
device_data->objdata.num_total_objects++;
}
-bool ValidateCommandBuffer(VkDevice device, VkCommandPool command_pool, VkCommandBuffer command_buffer) {
+bool ObjectLifetimes::ValidateCommandBuffer(VkDevice device, VkCommandPool command_pool, VkCommandBuffer command_buffer) {
layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
bool skip = false;
uint64_t object_handle = HandleToUint64(command_buffer);
@@ -154,7 +153,7 @@
return skip;
}
-void AllocateDescriptorSet(VkDevice device, VkDescriptorPool descriptor_pool, VkDescriptorSet descriptor_set) {
+void ObjectLifetimes::AllocateDescriptorSet(VkDevice device, VkDescriptorPool descriptor_pool, VkDescriptorSet descriptor_set) {
layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
log_msg(device_data->report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT,
@@ -171,7 +170,7 @@
device_data->objdata.num_total_objects++;
}
-bool ValidateDescriptorSet(VkDevice device, VkDescriptorPool descriptor_pool, VkDescriptorSet descriptor_set) {
+bool ObjectLifetimes::ValidateDescriptorSet(VkDevice device, VkDescriptorPool descriptor_pool, VkDescriptorSet descriptor_set) {
layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
bool skip = false;
uint64_t object_handle = HandleToUint64(descriptor_set);
@@ -195,7 +194,7 @@
}
template <typename DispObj>
-bool ValidateDescriptorWrite(DispObj disp, VkWriteDescriptorSet const *desc, bool isPush) {
+bool ObjectLifetimes::ValidateDescriptorWrite(DispObj disp, VkWriteDescriptorSet const *desc, bool isPush) {
bool skip = false;
if (!isPush && desc->dstSet) {
@@ -237,9 +236,9 @@
return skip;
}
-bool PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint,
- VkPipelineLayout layout, uint32_t set, uint32_t descriptorWriteCount,
- const VkWriteDescriptorSet *pDescriptorWrites) {
+bool ObjectLifetimes::PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint,
+ VkPipelineLayout layout, uint32_t set, uint32_t descriptorWriteCount,
+ const VkWriteDescriptorSet *pDescriptorWrites) {
bool skip = false;
skip |= DeviceValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false,
"VUID-vkCmdPushDescriptorSetKHR-commandBuffer-parameter",
@@ -254,7 +253,7 @@
return skip;
}
-void CreateQueue(VkDevice device, VkQueue vkObj) {
+void ObjectLifetimes::CreateQueue(VkDevice device, VkQueue vkObj) {
layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
log_msg(device_data->report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT,
@@ -276,7 +275,7 @@
p_obj_node->handle = HandleToUint64(vkObj);
}
-void CreateSwapchainImageObject(VkDevice dispatchable_object, VkImage swapchain_image, VkSwapchainKHR swapchain) {
+void ObjectLifetimes::CreateSwapchainImageObject(VkDevice dispatchable_object, VkImage swapchain_image, VkSwapchainKHR swapchain) {
layer_data *device_data = GetLayerDataPtr(get_dispatch_key(dispatchable_object), layer_data_map);
log_msg(device_data->report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT,
HandleToUint64(swapchain_image), kVUID_ObjectTracker_Info, "OBJ[0x%" PRIxLEAST64 "] : CREATE %s object 0x%" PRIxLEAST64,
@@ -290,7 +289,7 @@
device_data->objdata.swapchainImageMap[HandleToUint64(swapchain_image)] = pNewObjNode;
}
-bool DeviceReportUndestroyedObjects(VkDevice device, VulkanObjectType object_type, const std::string &error_code) {
+bool ObjectLifetimes::DeviceReportUndestroyedObjects(VkDevice device, VulkanObjectType object_type, const std::string &error_code) {
bool skip = false;
layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
for (const auto &item : device_data->objdata.object_map[object_type]) {
@@ -303,7 +302,7 @@
return skip;
}
-void DeviceDestroyUndestroyedObjects(VkDevice device, VulkanObjectType object_type) {
+void ObjectLifetimes::DeviceDestroyUndestroyedObjects(VkDevice device, VulkanObjectType object_type) {
layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
while (!device_data->objdata.object_map[object_type].empty()) {
auto item = device_data->objdata.object_map[object_type].begin();
@@ -313,7 +312,7 @@
}
}
-bool PreCallValidateDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) {
+bool ObjectLifetimes::PreCallValidateDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) {
dispatch_key key = get_dispatch_key(instance);
instance_layer_data *instance_data = GetLayerDataPtr(key, instance_layer_data_map);
bool skip = false;
@@ -346,20 +345,26 @@
return skip;
}
-void PreCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) {
+bool ObjectLifetimes::PreCallValidateEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount,
+ VkPhysicalDevice *pPhysicalDevices) {
+ bool skip = InstanceValidateObject(instance, instance, kVulkanObjectTypeInstance, false,
+ "VUID-vkEnumeratePhysicalDevices-instance-parameter", kVUIDUndefined);
+ return skip;
+}
+
+void ObjectLifetimes::PostCallRecordEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount,
+ VkPhysicalDevice *pPhysicalDevices) {
+ if (pPhysicalDevices) {
+ for (uint32_t i = 0; i < *pPhysicalDeviceCount; i++) {
+ InstanceCreateObject(instance, pPhysicalDevices[i], kVulkanObjectTypePhysicalDevice, nullptr);
+ }
+ }
+}
+
+void ObjectLifetimes::PreCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) {
dispatch_key key = get_dispatch_key(instance);
instance_layer_data *instance_data = GetLayerDataPtr(key, instance_layer_data_map);
- // Enable the temporary callback(s) here to catch cleanup issues:
- if (instance_data->num_tmp_debug_messengers > 0) {
- layer_enable_tmp_debug_messengers(instance_data->report_data, instance_data->num_tmp_debug_messengers,
- instance_data->tmp_messenger_create_infos, instance_data->tmp_debug_messengers);
- }
- if (instance_data->num_tmp_report_callbacks > 0) {
- layer_enable_tmp_report_callbacks(instance_data->report_data, instance_data->num_tmp_report_callbacks,
- instance_data->tmp_report_create_infos, instance_data->tmp_report_callbacks);
- }
-
// Destroy physical devices
for (auto iit = instance_data->objdata.object_map[kVulkanObjectTypePhysicalDevice].begin();
iit != instance_data->objdata.object_map[kVulkanObjectTypePhysicalDevice].end();) {
@@ -383,43 +388,11 @@
instance_data->objdata.object_map[kVulkanObjectTypeDevice].clear();
}
-void PostCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) {
- dispatch_key key = get_dispatch_key(instance);
- instance_layer_data *instance_data = GetLayerDataPtr(key, instance_layer_data_map);
-
- // Disable and cleanup the temporary callback(s):
- layer_disable_tmp_debug_messengers(instance_data->report_data, instance_data->num_tmp_debug_messengers,
- instance_data->tmp_debug_messengers);
- layer_disable_tmp_report_callbacks(instance_data->report_data, instance_data->num_tmp_report_callbacks,
- instance_data->tmp_report_callbacks);
- if (instance_data->num_tmp_debug_messengers > 0) {
- layer_free_tmp_debug_messengers(instance_data->tmp_messenger_create_infos, instance_data->tmp_debug_messengers);
- instance_data->num_tmp_debug_messengers = 0;
- }
- if (instance_data->num_tmp_report_callbacks > 0) {
- layer_free_tmp_report_callbacks(instance_data->tmp_report_create_infos, instance_data->tmp_report_callbacks);
- instance_data->num_tmp_report_callbacks = 0;
- }
-
- // Clean up logging callback, if any
- while (instance_data->logging_messenger.size() > 0) {
- VkDebugUtilsMessengerEXT messenger = instance_data->logging_messenger.back();
- layer_destroy_messenger_callback(instance_data->report_data, messenger, pAllocator);
- instance_data->logging_messenger.pop_back();
- }
- while (instance_data->logging_callback.size() > 0) {
- VkDebugReportCallbackEXT callback = instance_data->logging_callback.back();
- layer_destroy_report_callback(instance_data->report_data, callback, pAllocator);
- instance_data->logging_callback.pop_back();
- }
-
+void ObjectLifetimes::PostCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) {
InstanceRecordDestroyObject(instance, instance, kVulkanObjectTypeInstance);
-
- layer_debug_utils_destroy_instance(instance_data->report_data);
- FreeLayerDataPtr(key, instance_layer_data_map);
}
-bool PreCallValidateDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator) {
+bool ObjectLifetimes::PreCallValidateDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator) {
layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
bool skip = false;
skip |= DeviceValidateObject(device, device, kVulkanObjectTypeDevice, true, "VUID-vkDestroyDevice-device-parameter",
@@ -432,7 +405,7 @@
return skip;
}
-void PreCallRecordDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator) {
+void ObjectLifetimes::PreCallRecordDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator) {
layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
InstanceRecordDestroyObject(device_data->physical_device, device, kVulkanObjectTypeDevice);
DestroyUndestroyedObjects(device);
@@ -441,31 +414,34 @@
DestroyQueueDataStructures(device);
}
-bool PreCallValidateGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue *pQueue) {
+bool ObjectLifetimes::PreCallValidateGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex,
+ VkQueue *pQueue) {
bool skip = false;
skip |= DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkGetDeviceQueue-device-parameter",
kVUIDUndefined);
return skip;
}
-void PostCallRecordGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue *pQueue) {
+void ObjectLifetimes::PostCallRecordGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex,
+ VkQueue *pQueue) {
CreateQueue(device, *pQueue);
AddQueueInfo(device, queueFamilyIndex, *pQueue);
}
-bool PreCallValidateGetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2 *pQueueInfo, VkQueue *pQueue) {
+bool ObjectLifetimes::PreCallValidateGetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2 *pQueueInfo, VkQueue *pQueue) {
return DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkGetDeviceQueue2-device-parameter",
kVUIDUndefined);
}
-void PostCallRecordGetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2 *pQueueInfo, VkQueue *pQueue) {
+void ObjectLifetimes::PostCallRecordGetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2 *pQueueInfo, VkQueue *pQueue) {
CreateQueue(device, *pQueue);
AddQueueInfo(device, pQueueInfo->queueFamilyIndex, *pQueue);
}
-bool PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
- const VkWriteDescriptorSet *pDescriptorWrites, uint32_t descriptorCopyCount,
- const VkCopyDescriptorSet *pDescriptorCopies) {
+bool ObjectLifetimes::PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
+ const VkWriteDescriptorSet *pDescriptorWrites,
+ uint32_t descriptorCopyCount,
+ const VkCopyDescriptorSet *pDescriptorCopies) {
bool skip = false;
skip |= DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkUpdateDescriptorSets-device-parameter",
kVUIDUndefined);
@@ -489,54 +465,8 @@
return skip;
}
-bool PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount,
- const VkComputePipelineCreateInfo *pCreateInfos, const VkAllocationCallbacks *pAllocator,
- VkPipeline *pPipelines) {
- bool skip = VK_FALSE;
- skip |= DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkCreateComputePipelines-device-parameter",
- kVUIDUndefined);
- if (pCreateInfos) {
- for (uint32_t idx0 = 0; idx0 < createInfoCount; ++idx0) {
- if (pCreateInfos[idx0].basePipelineHandle) {
- skip |= DeviceValidateObject(device, pCreateInfos[idx0].basePipelineHandle, kVulkanObjectTypePipeline, true,
- "VUID-VkComputePipelineCreateInfo-flags-00697",
- "VUID-VkComputePipelineCreateInfo-commonparent");
- }
- if (pCreateInfos[idx0].layout) {
- skip |= DeviceValidateObject(device, pCreateInfos[idx0].layout, kVulkanObjectTypePipelineLayout, false,
- "VUID-VkComputePipelineCreateInfo-layout-parameter",
- "VUID-VkComputePipelineCreateInfo-commonparent");
- }
- if (pCreateInfos[idx0].stage.module) {
- skip |= DeviceValidateObject(device, pCreateInfos[idx0].stage.module, kVulkanObjectTypeShaderModule, false,
- "VUID-VkPipelineShaderStageCreateInfo-module-parameter", kVUIDUndefined);
- }
- }
- }
- if (pipelineCache) {
- skip |= DeviceValidateObject(device, pipelineCache, kVulkanObjectTypePipelineCache, true,
- "VUID-vkCreateComputePipelines-pipelineCache-parameter",
- "VUID-vkCreateComputePipelines-pipelineCache-parent");
- }
- if (skip) {
- for (uint32_t i = 0; i < createInfoCount; i++) {
- pPipelines[i] = VK_NULL_HANDLE;
- }
- }
- return skip;
-}
-
-void PostCallRecordCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount,
- const VkComputePipelineCreateInfo *pCreateInfos, const VkAllocationCallbacks *pAllocator,
- VkPipeline *pPipelines) {
- for (uint32_t idx1 = 0; idx1 < createInfoCount; ++idx1) {
- if (pPipelines[idx1] != VK_NULL_HANDLE) {
- DeviceCreateObject(device, pPipelines[idx1], kVulkanObjectTypePipeline, pAllocator);
- }
- }
-}
-
-bool PreCallValidateResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags) {
+bool ObjectLifetimes::PreCallValidateResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool,
+ VkDescriptorPoolResetFlags flags) {
bool skip = false;
layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
@@ -554,7 +484,8 @@
return skip;
}
-void PreCallRecordResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags) {
+void ObjectLifetimes::PreCallRecordResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool,
+ VkDescriptorPoolResetFlags flags) {
layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
// A DescriptorPool's descriptor sets are implicitly deleted when the pool is reset. Remove this pool's descriptor sets from
@@ -569,7 +500,8 @@
}
}
-bool PreCallValidateBeginCommandBuffer(VkCommandBuffer command_buffer, const VkCommandBufferBeginInfo *begin_info) {
+bool ObjectLifetimes::PreCallValidateBeginCommandBuffer(VkCommandBuffer command_buffer,
+ const VkCommandBufferBeginInfo *begin_info) {
layer_data *device_data = GetLayerDataPtr(get_dispatch_key(command_buffer), layer_data_map);
bool skip = false;
skip |= DeviceValidateObject(command_buffer, command_buffer, kVulkanObjectTypeCommandBuffer, false,
@@ -589,133 +521,8 @@
return skip;
}
-void PostCallRecordCreateDebugReportCallbackEXT(VkInstance instance, const VkDebugReportCallbackCreateInfoEXT *pCreateInfo,
- const VkAllocationCallbacks *pAllocator, VkDebugReportCallbackEXT *pCallback) {
- InstanceCreateObject(instance, *pCallback, kVulkanObjectTypeDebugReportCallbackEXT, pAllocator);
-}
-
-bool PreCallValidateDestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT msgCallback,
- const VkAllocationCallbacks *pAllocator) {
- bool skip = InstanceValidateDestroyObject(instance, msgCallback, kVulkanObjectTypeDebugReportCallbackEXT, pAllocator,
- "VUID-vkDestroyDebugReportCallbackEXT-instance-01242",
- "VUID-vkDestroyDebugReportCallbackEXT-instance-01243");
- return skip;
-}
-
-void PreCallRecordDestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT msgCallback,
- const VkAllocationCallbacks *pAllocator) {
- InstanceRecordDestroyObject(instance, msgCallback, kVulkanObjectTypeDebugReportCallbackEXT);
-}
-
-// VK_EXT_debug_utils commands
-
-bool PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device, const VkDebugUtilsObjectNameInfoEXT *pNameInfo) {
- return DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false,
- "VUID-vkSetDebugUtilsObjectNameEXT-device-parameter", kVUIDUndefined);
-}
-
-bool PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device, const VkDebugUtilsObjectTagInfoEXT *pTagInfo) {
- return DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkSetDebugUtilsObjectTagEXT-device-parameter",
- kVUIDUndefined);
-}
-
-bool PreCallValidateQueueBeginDebugUtilsLabelEXT(VkQueue queue, const VkDebugUtilsLabelEXT *pLabelInfo) {
- return DeviceValidateObject(queue, queue, kVulkanObjectTypeQueue, false, "VUID-vkQueueBeginDebugUtilsLabelEXT-queue-parameter",
- kVUIDUndefined);
-}
-
-bool PreCallValidateQueueEndDebugUtilsLabelEXT(VkQueue queue) {
- return DeviceValidateObject(queue, queue, kVulkanObjectTypeQueue, false, "VUID-vkQueueEndDebugUtilsLabelEXT-queue-parameter",
- kVUIDUndefined);
-}
-
-bool PreCallValidateQueueInsertDebugUtilsLabelEXT(VkQueue queue, const VkDebugUtilsLabelEXT *pLabelInfo) {
- return DeviceValidateObject(queue, queue, kVulkanObjectTypeQueue, false, "VUID-vkQueueInsertDebugUtilsLabelEXT-queue-parameter",
- kVUIDUndefined);
-}
-
-bool PreCallValidateCmdBeginDebugUtilsLabelEXT(VkCommandBuffer commandBuffer, const VkDebugUtilsLabelEXT *pLabelInfo) {
- return DeviceValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false,
- "VUID-vkCmdBeginDebugUtilsLabelEXT-commandBuffer-parameter", kVUIDUndefined);
-}
-
-bool PreCallValidateCmdEndDebugUtilsLabelEXT(VkCommandBuffer commandBuffer) {
- return DeviceValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false,
- "VUID-vkCmdEndDebugUtilsLabelEXT-commandBuffer-parameter", kVUIDUndefined);
-}
-
-bool PreCallValidateCmdInsertDebugUtilsLabelEXT(VkCommandBuffer commandBuffer, const VkDebugUtilsLabelEXT *pLabelInfo) {
- return DeviceValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false,
- "VUID-vkCmdInsertDebugUtilsLabelEXT-commandBuffer-parameter", kVUIDUndefined);
-}
-
-bool PreCallValidateCreateDebugUtilsMessengerEXT(VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT *pCreateInfo,
- const VkAllocationCallbacks *pAllocator, VkDebugUtilsMessengerEXT *pMessenger) {
- return InstanceValidateObject(instance, instance, kVulkanObjectTypeInstance, false,
- "VUID-vkCreateDebugUtilsMessengerEXT-instance-parameter", kVUIDUndefined);
-}
-
-void PostCallRecordCreateDebugUtilsMessengerEXT(VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT *pCreateInfo,
- const VkAllocationCallbacks *pAllocator, VkDebugUtilsMessengerEXT *pMessenger) {
- InstanceCreateObject(instance, *pMessenger, kVulkanObjectTypeDebugUtilsMessengerEXT, pAllocator);
-}
-
-bool PreCallValidateDestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT messenger,
- const VkAllocationCallbacks *pAllocator) {
- bool skip = false;
- skip |= InstanceValidateObject(instance, instance, kVulkanObjectTypeInstance, false,
- "VUID-vkDestroyDebugUtilsMessengerEXT-instance-parameter", kVUIDUndefined);
- skip |= InstanceValidateObject(instance, messenger, kVulkanObjectTypeDebugUtilsMessengerEXT, false,
- "VUID-vkDestroyDebugUtilsMessengerEXT-messenger-parameter",
- "VUID-vkDestroyDebugUtilsMessengerEXT-messenger-parent");
- skip |= InstanceValidateDestroyObject(instance, messenger, kVulkanObjectTypeDebugUtilsMessengerEXT, pAllocator,
- "VUID-vkDestroyDebugUtilsMessengerEXT-messenger-01915",
- "VUID-vkDestroyDebugUtilsMessengerEXT-messenger-01916");
- return skip;
-}
-
-void PreCallRecordDestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT messenger,
- const VkAllocationCallbacks *pAllocator) {
- InstanceRecordDestroyObject(instance, messenger, kVulkanObjectTypeDebugUtilsMessengerEXT);
-}
-
-bool PreCallValidateSubmitDebugUtilsMessageEXT(VkInstance instance, VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
- VkDebugUtilsMessageTypeFlagsEXT messageTypes,
- const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData) {
- bool skip = false;
- skip |= InstanceValidateObject(instance, instance, kVulkanObjectTypeInstance, false,
- "VUID-vkeSubmitDebugUtilsMessageEXT-instance-parameter", kVUIDUndefined);
- return skip;
-}
-
-bool PreCallValidateEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pCount,
- VkLayerProperties *pProperties) {
- // Set null_allowed to true here to cover for the lame loader-layer interface wrapper calls
- return InstanceValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, true,
- "VUID-vkEnumerateDeviceLayerProperties-physicalDevice-parameter", kVUIDUndefined);
-}
-
-bool PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char *pLayerName, uint32_t *pCount,
- VkExtensionProperties *pProperties) {
- // Set null_allowed to true here to cover for the lame loader-layer interface wrapper calls
- return InstanceValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, true,
- "VUID-vkEnumerateDeviceExtensionProperties-physicalDevice-parameter", kVUIDUndefined);
-}
-
-bool PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
- const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) {
- return InstanceValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false,
- "VUID-vkCreateDevice-physicalDevice-parameter", kVUIDUndefined);
-}
-
-void PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
- const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) {
- instance_layer_data *phy_dev_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), instance_layer_data_map);
- InstanceCreateObject(phy_dev_data->instance, *pDevice, kVulkanObjectTypeDevice, pAllocator);
-}
-
-bool PreCallValidateGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t *pSwapchainImageCount,
- VkImage *pSwapchainImages) {
+bool ObjectLifetimes::PreCallValidateGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain,
+ uint32_t *pSwapchainImageCount, VkImage *pSwapchainImages) {
bool skip = false;
skip |= DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkGetSwapchainImagesKHR-device-parameter",
"VUID-vkGetSwapchainImagesKHR-commonparent");
@@ -724,8 +531,8 @@
return skip;
}
-void PostCallRecordGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t *pSwapchainImageCount,
- VkImage *pSwapchainImages) {
+void ObjectLifetimes::PostCallRecordGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t *pSwapchainImageCount,
+ VkImage *pSwapchainImages) {
if (pSwapchainImages != NULL) {
for (uint32_t i = 0; i < *pSwapchainImageCount; i++) {
CreateSwapchainImageObject(device, pSwapchainImages[i], swapchain);
@@ -733,8 +540,9 @@
}
}
-bool PreCallValidateCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
- const VkAllocationCallbacks *pAllocator, VkDescriptorSetLayout *pSetLayout) {
+bool ObjectLifetimes::PreCallValidateCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
+ const VkAllocationCallbacks *pAllocator,
+ VkDescriptorSetLayout *pSetLayout) {
bool skip = false;
skip |= DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false,
"VUID-vkCreateDescriptorSetLayout-device-parameter", kVUIDUndefined);
@@ -757,12 +565,13 @@
return skip;
}
-void PostCallRecordCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
- const VkAllocationCallbacks *pAllocator, VkDescriptorSetLayout *pSetLayout) {
+void ObjectLifetimes::PostCallRecordCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
+ const VkAllocationCallbacks *pAllocator,
+ VkDescriptorSetLayout *pSetLayout) {
DeviceCreateObject(device, *pSetLayout, kVulkanObjectTypeDescriptorSetLayout, pAllocator);
}
-inline bool ValidateSamplerObjects(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo) {
+bool ObjectLifetimes::ValidateSamplerObjects(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo) {
bool skip = false;
if (pCreateInfo->pBindings) {
for (uint32_t index1 = 0; index1 < pCreateInfo->bindingCount; ++index1) {
@@ -778,8 +587,9 @@
return skip;
}
-bool PreCallValidateGetDescriptorSetLayoutSupport(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
- VkDescriptorSetLayoutSupport *pSupport) {
+bool ObjectLifetimes::PreCallValidateGetDescriptorSetLayoutSupport(VkDevice device,
+ const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
+ VkDescriptorSetLayoutSupport *pSupport) {
bool skip = DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false,
"VUID-vkGetDescriptorSetLayoutSupport-device-parameter", kVUIDUndefined);
if (pCreateInfo) {
@@ -787,8 +597,9 @@
}
return skip;
}
-bool PreCallValidateGetDescriptorSetLayoutSupportKHR(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
- VkDescriptorSetLayoutSupport *pSupport) {
+bool ObjectLifetimes::PreCallValidateGetDescriptorSetLayoutSupportKHR(VkDevice device,
+ const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
+ VkDescriptorSetLayoutSupport *pSupport) {
bool skip = DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false,
"VUID-vkGetDescriptorSetLayoutSupportKHR-device-parameter", kVUIDUndefined);
if (pCreateInfo) {
@@ -797,15 +608,16 @@
return skip;
}
-bool PreCallValidateGetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount,
- VkQueueFamilyProperties *pQueueFamilyProperties) {
- bool skip = InstanceValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false,
- "VUID-vkGetPhysicalDeviceQueueFamilyProperties-physicalDevice-parameter", kVUIDUndefined);
- return skip;
+bool ObjectLifetimes::PreCallValidateGetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice,
+ uint32_t *pQueueFamilyPropertyCount,
+ VkQueueFamilyProperties *pQueueFamilyProperties) {
+ return InstanceValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false,
+ "VUID-vkGetPhysicalDeviceQueueFamilyProperties-physicalDevice-parameter", kVUIDUndefined);
}
-void PostCallRecordGetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount,
- VkQueueFamilyProperties *pQueueFamilyProperties) {
+void ObjectLifetimes::PostCallRecordGetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice,
+ uint32_t *pQueueFamilyPropertyCount,
+ VkQueueFamilyProperties *pQueueFamilyProperties) {
if (pQueueFamilyProperties != NULL) {
auto instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), instance_layer_data_map);
if (instance_data->objdata.queue_family_properties.size() < *pQueueFamilyPropertyCount) {
@@ -817,29 +629,13 @@
}
}
-void PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
- VkInstance *pInstance) {
+void ObjectLifetimes::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
+ VkInstance *pInstance) {
InstanceCreateObject(*pInstance, *pInstance, kVulkanObjectTypeInstance, pAllocator);
}
-bool PreCallValidateEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount,
- VkPhysicalDevice *pPhysicalDevices) {
- bool skip = InstanceValidateObject(instance, instance, kVulkanObjectTypeInstance, false,
- "VUID-vkEnumeratePhysicalDevices-instance-parameter", kVUIDUndefined);
- return skip;
-}
-
-void PostCallRecordEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount,
- VkPhysicalDevice *pPhysicalDevices) {
- if (pPhysicalDevices) {
- for (uint32_t i = 0; i < *pPhysicalDeviceCount; i++) {
- InstanceCreateObject(instance, pPhysicalDevices[i], kVulkanObjectTypePhysicalDevice, nullptr);
- }
- }
-}
-
-bool PreCallValidateAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
- VkCommandBuffer *pCommandBuffers) {
+bool ObjectLifetimes::PreCallValidateAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
+ VkCommandBuffer *pCommandBuffers) {
bool skip = false;
skip |= DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkAllocateCommandBuffers-device-parameter",
kVUIDUndefined);
@@ -848,15 +644,15 @@
return skip;
}
-void PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
- VkCommandBuffer *pCommandBuffers) {
+void ObjectLifetimes::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
+ VkCommandBuffer *pCommandBuffers) {
for (uint32_t i = 0; i < pAllocateInfo->commandBufferCount; i++) {
AllocateCommandBuffer(device, pAllocateInfo->commandPool, pCommandBuffers[i], pAllocateInfo->level);
}
}
-bool PreCallValidateAllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo *pAllocateInfo,
- VkDescriptorSet *pDescriptorSets) {
+bool ObjectLifetimes::PreCallValidateAllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo *pAllocateInfo,
+ VkDescriptorSet *pDescriptorSets) {
bool skip = false;
skip |= DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkAllocateDescriptorSets-device-parameter",
kVUIDUndefined);
@@ -871,15 +667,15 @@
return skip;
}
-void PostCallRecordAllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo *pAllocateInfo,
- VkDescriptorSet *pDescriptorSets) {
+void ObjectLifetimes::PostCallRecordAllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo *pAllocateInfo,
+ VkDescriptorSet *pDescriptorSets) {
for (uint32_t i = 0; i < pAllocateInfo->descriptorSetCount; i++) {
AllocateDescriptorSet(device, pAllocateInfo->descriptorPool, pDescriptorSets[i]);
}
}
-bool PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
- const VkCommandBuffer *pCommandBuffers) {
+bool ObjectLifetimes::PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
+ const VkCommandBuffer *pCommandBuffers) {
bool skip = false;
skip |= DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkFreeCommandBuffers-device-parameter",
kVUIDUndefined);
@@ -895,19 +691,21 @@
return skip;
}
-void PreCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
- const VkCommandBuffer *pCommandBuffers) {
+void ObjectLifetimes::PreCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
+ const VkCommandBuffer *pCommandBuffers) {
for (uint32_t i = 0; i < commandBufferCount; i++) {
DeviceRecordDestroyObject(device, pCommandBuffers[i], kVulkanObjectTypeCommandBuffer);
}
}
-bool PreCallValidateDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, const VkAllocationCallbacks *pAllocator) {
+bool ObjectLifetimes::PreCallValidateDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain,
+ const VkAllocationCallbacks *pAllocator) {
return DeviceValidateDestroyObject(device, swapchain, kVulkanObjectTypeSwapchainKHR, pAllocator,
"VUID-vkDestroySwapchainKHR-swapchain-01283", "VUID-vkDestroySwapchainKHR-swapchain-01284");
}
-void PreCallRecordDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, const VkAllocationCallbacks *pAllocator) {
+void ObjectLifetimes::PreCallRecordDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain,
+ const VkAllocationCallbacks *pAllocator) {
DeviceRecordDestroyObject(device, swapchain, kVulkanObjectTypeSwapchainKHR);
layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
std::unordered_map<uint64_t, ObjTrackState *>::iterator itr = device_data->objdata.swapchainImageMap.begin();
@@ -923,8 +721,8 @@
}
}
-bool PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount,
- const VkDescriptorSet *pDescriptorSets) {
+bool ObjectLifetimes::PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
+ uint32_t descriptorSetCount, const VkDescriptorSet *pDescriptorSets) {
bool skip = false;
skip |= DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkFreeDescriptorSets-device-parameter",
kVUIDUndefined);
@@ -940,15 +738,15 @@
}
return skip;
}
-void PreCallRecordFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount,
- const VkDescriptorSet *pDescriptorSets) {
+void ObjectLifetimes::PreCallRecordFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount,
+ const VkDescriptorSet *pDescriptorSets) {
for (uint32_t i = 0; i < descriptorSetCount; i++) {
DeviceRecordDestroyObject(device, pDescriptorSets[i], kVulkanObjectTypeDescriptorSet);
}
}
-bool PreCallValidateDestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool,
- const VkAllocationCallbacks *pAllocator) {
+bool ObjectLifetimes::PreCallValidateDestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool,
+ const VkAllocationCallbacks *pAllocator) {
layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
bool skip = false;
skip |= DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkDestroyDescriptorPool-device-parameter",
@@ -971,7 +769,8 @@
"VUID-vkDestroyDescriptorPool-descriptorPool-00305");
return skip;
}
-void PreCallRecordDestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, const VkAllocationCallbacks *pAllocator) {
+void ObjectLifetimes::PreCallRecordDestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool,
+ const VkAllocationCallbacks *pAllocator) {
layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
std::unordered_map<uint64_t, ObjTrackState *>::iterator itr =
device_data->objdata.object_map[kVulkanObjectTypeDescriptorSet].begin();
@@ -985,7 +784,8 @@
DeviceRecordDestroyObject(device, descriptorPool, kVulkanObjectTypeDescriptorPool);
}
-bool PreCallValidateDestroyCommandPool(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks *pAllocator) {
+bool ObjectLifetimes::PreCallValidateDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
+ const VkAllocationCallbacks *pAllocator) {
layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
bool skip = false;
skip |= DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkDestroyCommandPool-device-parameter",
@@ -1009,7 +809,8 @@
return skip;
}
-void PreCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks *pAllocator) {
+void ObjectLifetimes::PreCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
+ const VkAllocationCallbacks *pAllocator) {
layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
auto itr = device_data->objdata.object_map[kVulkanObjectTypeCommandBuffer].begin();
auto del_itr = itr;
@@ -1024,14 +825,23 @@
DeviceRecordDestroyObject(device, commandPool, kVulkanObjectTypeCommandPool);
}
-bool PreCallValidateGetPhysicalDeviceQueueFamilyProperties2(VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount,
- VkQueueFamilyProperties2KHR *pQueueFamilyProperties) {
+bool ObjectLifetimes::PreCallValidateGetPhysicalDeviceQueueFamilyProperties2(VkPhysicalDevice physicalDevice,
+ uint32_t *pQueueFamilyPropertyCount,
+ VkQueueFamilyProperties2KHR *pQueueFamilyProperties) {
return InstanceValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false,
"VUID-vkGetPhysicalDeviceQueueFamilyProperties2-physicalDevice-parameter", kVUIDUndefined);
}
-void PostCallRecordGetPhysicalDeviceQueueFamilyProperties2(VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount,
- VkQueueFamilyProperties2KHR *pQueueFamilyProperties) {
+bool ObjectLifetimes::PreCallValidateGetPhysicalDeviceQueueFamilyProperties2KHR(VkPhysicalDevice physicalDevice,
+ uint32_t *pQueueFamilyPropertyCount,
+ VkQueueFamilyProperties2 *pQueueFamilyProperties) {
+ return InstanceValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false,
+ "VUID-vkGetPhysicalDeviceQueueFamilyProperties2KHR-physicalDevice-parameter", kVUIDUndefined);
+}
+
+void ObjectLifetimes::PostCallRecordGetPhysicalDeviceQueueFamilyProperties2(VkPhysicalDevice physicalDevice,
+ uint32_t *pQueueFamilyPropertyCount,
+ VkQueueFamilyProperties2KHR *pQueueFamilyProperties) {
instance_layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), instance_layer_data_map);
if (pQueueFamilyProperties != NULL) {
if (instance_data->objdata.queue_family_properties.size() < *pQueueFamilyPropertyCount) {
@@ -1043,15 +853,28 @@
}
}
-bool PreCallValidateGetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
- VkDisplayPropertiesKHR *pProperties) {
- bool skip = InstanceValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false,
- "VUID-vkGetPhysicalDeviceDisplayPropertiesKHR-physicalDevice-parameter", kVUIDUndefined);
- return skip;
+void ObjectLifetimes::PostCallRecordGetPhysicalDeviceQueueFamilyProperties2KHR(
+ VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount, VkQueueFamilyProperties2KHR *pQueueFamilyProperties) {
+ instance_layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), instance_layer_data_map);
+ if (pQueueFamilyProperties != NULL) {
+ if (instance_data->objdata.queue_family_properties.size() < *pQueueFamilyPropertyCount) {
+ instance_data->objdata.queue_family_properties.resize(*pQueueFamilyPropertyCount);
+ }
+ for (uint32_t i = 0; i < *pQueueFamilyPropertyCount; i++) {
+ instance_data->objdata.queue_family_properties[i] = pQueueFamilyProperties[i].queueFamilyProperties;
+ }
+ }
}
-void PostCallRecordGetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
- VkDisplayPropertiesKHR *pProperties) {
+bool ObjectLifetimes::PreCallValidateGetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice,
+ uint32_t *pPropertyCount,
+ VkDisplayPropertiesKHR *pProperties) {
+ return InstanceValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false,
+ "VUID-vkGetPhysicalDeviceDisplayPropertiesKHR-physicalDevice-parameter", kVUIDUndefined);
+}
+
+void ObjectLifetimes::PostCallRecordGetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
+ VkDisplayPropertiesKHR *pProperties) {
if (pProperties) {
for (uint32_t i = 0; i < *pPropertyCount; ++i) {
InstanceCreateObject(physicalDevice, pProperties[i].display, kVulkanObjectTypeDisplayKHR, nullptr);
@@ -1059,8 +882,9 @@
}
}
-bool PreCallValidateGetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, uint32_t *pPropertyCount,
- VkDisplayModePropertiesKHR *pProperties) {
+bool ObjectLifetimes::PreCallValidateGetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
+ uint32_t *pPropertyCount,
+ VkDisplayModePropertiesKHR *pProperties) {
bool skip = false;
skip |= InstanceValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false,
"VUID-vkGetDisplayModePropertiesKHR-physicalDevice-parameter", kVUIDUndefined);
@@ -1070,8 +894,8 @@
return skip;
}
-void PostCallRecordGetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, uint32_t *pPropertyCount,
- VkDisplayModePropertiesKHR *pProperties) {
+void ObjectLifetimes::PostCallRecordGetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
+ uint32_t *pPropertyCount, VkDisplayModePropertiesKHR *pProperties) {
if (pProperties) {
for (uint32_t i = 0; i < *pPropertyCount; ++i) {
InstanceCreateObject(physicalDevice, pProperties[i].displayMode, kVulkanObjectTypeDisplayModeKHR, nullptr);
@@ -1079,63 +903,38 @@
}
}
-bool PreCallValidateDebugMarkerSetObjectNameEXT(VkDevice device, const VkDebugMarkerObjectNameInfoEXT *pNameInfo) {
- return DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false,
- "VUID-vkDebugMarkerSetObjectNameEXT-device-parameter", kVUIDUndefined);
-}
-
-bool PreCallValidateGetDeviceProcAddr(VkDevice device, const char *funcName) {
- return DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkGetDeviceProcAddr-device-parameter",
- kVUIDUndefined);
-}
-
-bool PreCallValidateGetInstanceProcAddr(VkInstance instance, const char *funcName) {
- return InstanceValidateObject(instance, instance, kVulkanObjectTypeInstance, false,
- "VUID-vkGetInstanceProcAddr-instance-parameter", kVUIDUndefined);
-}
-
-bool PreCallValidateGetPhysicalDeviceDisplayProperties2KHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
- VkDisplayProperties2KHR *pProperties) {
+bool ObjectLifetimes::PreCallValidateGetPhysicalDeviceDisplayProperties2KHR(VkPhysicalDevice physicalDevice,
+ uint32_t *pPropertyCount,
+ VkDisplayProperties2KHR *pProperties) {
return InstanceValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false,
"VUID-vkGetPhysicalDeviceDisplayProperties2KHR-physicalDevice-parameter", kVUIDUndefined);
}
-void PostCallRecordGetPhysicalDeviceDisplayProperties2KHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
- VkDisplayProperties2KHR *pProperties) {
+void ObjectLifetimes::PostCallRecordGetPhysicalDeviceDisplayProperties2KHR(VkPhysicalDevice physicalDevice,
+ uint32_t *pPropertyCount,
+ VkDisplayProperties2KHR *pProperties) {
for (uint32_t index = 0; index < *pPropertyCount; ++index) {
InstanceCreateObject(physicalDevice, pProperties[index].displayProperties.display, kVulkanObjectTypeDisplayKHR, nullptr);
}
}
-bool PreCallValidateGetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice, uint32_t planeIndex,
- uint32_t *pDisplayCount, VkDisplayKHR *pDisplays) {
- return InstanceValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false,
- "VUID-vkGetDisplayPlaneSupportedDisplaysKHR-physicalDevice-parameter", kVUIDUndefined);
-}
-
-void PostCallRecordGetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice, uint32_t planeIndex,
- uint32_t *pDisplayCount, VkDisplayKHR *pDisplays) {
- for (uint32_t index = 0; index < *pDisplayCount; ++index) {
- InstanceCreateObject(physicalDevice, pDisplays[index], kVulkanObjectTypeDisplayKHR, nullptr);
- }
-}
-
-bool PreCallValidateGetDisplayModeProperties2KHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, uint32_t *pPropertyCount,
- VkDisplayModeProperties2KHR *pProperties) {
+bool ObjectLifetimes::PreCallValidateGetDisplayModeProperties2KHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
+ uint32_t *pPropertyCount,
+ VkDisplayModeProperties2KHR *pProperties) {
bool skip = false;
skip |= InstanceValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false,
"VUID-vkGetDisplayModeProperties2KHR-physicalDevice-parameter", kVUIDUndefined);
skip |= InstanceValidateObject(physicalDevice, display, kVulkanObjectTypeDisplayKHR, false,
"VUID-vkGetDisplayModeProperties2KHR-display-parameter", kVUIDUndefined);
+
return skip;
}
-void PostCallRecordGetDisplayModeProperties2KHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, uint32_t *pPropertyCount,
- VkDisplayModeProperties2KHR *pProperties) {
+void ObjectLifetimes::PostCallRecordGetDisplayModeProperties2KHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
+ uint32_t *pPropertyCount,
+ VkDisplayModeProperties2KHR *pProperties) {
for (uint32_t index = 0; index < *pPropertyCount; ++index) {
InstanceCreateObject(physicalDevice, pProperties[index].displayModeProperties.displayMode, kVulkanObjectTypeDisplayModeKHR,
nullptr);
}
}
-
-} // namespace object_tracker
diff --git a/scripts/layer_chassis_generator.py b/scripts/layer_chassis_generator.py
index 2ca3891..a27fcd6 100644
--- a/scripts/layer_chassis_generator.py
+++ b/scripts/layer_chassis_generator.py
@@ -155,43 +155,19 @@
#define VALIDATION_ERROR_MAP_IMPL
-#include "vk_loader_platform.h"
-#include "vk_dispatch_table_helper.h"
-#include "vk_layer_data.h"
-#include "vk_layer_extension_utils.h"
-#include "vk_layer_logging.h"
-#include "vk_extension_helper.h"
-#include "vk_layer_utils.h"
+#include "chassis.h"
class layer_chassis;
std::vector<layer_chassis *> global_interceptor_list;
debug_report_data *report_data = VK_NULL_HANDLE;
-#include "chassis.h"
+std::unordered_map<void *, layer_data *> layer_data_map;
+std::unordered_map<void *, instance_layer_data *> instance_layer_data_map;
-struct instance_layer_data {
- VkLayerInstanceDispatchTable dispatch_table;
- VkInstance instance = VK_NULL_HANDLE;
- debug_report_data *report_data = nullptr;
- std::vector<VkDebugReportCallbackEXT> logging_callback;
- std::vector<VkDebugUtilsMessengerEXT> logging_messenger;
- InstanceExtensions extensions;
-};
-
-struct layer_data {
- debug_report_data *report_data = nullptr;
- VkLayerDispatchTable dispatch_table;
- DeviceExtensions extensions = {};
- VkDevice device = VK_NULL_HANDLE;
- VkPhysicalDevice physical_device = VK_NULL_HANDLE;
- instance_layer_data *instance_data = nullptr;
-};
-
-static std::unordered_map<void *, layer_data *> layer_data_map;
-static std::unordered_map<void *, instance_layer_data *> instance_layer_data_map;
-
+// Create an object_lifetime object and add it to the global_interceptor_list
#include "interceptor_objects.h"
+ObjectLifetimes object_tracker_object;
using mutex_t = std::mutex;
using lock_guard_t = std::lock_guard<mutex_t>;
@@ -298,7 +274,7 @@
instance_data->report_data = debug_utils_create_instance(
&instance_data->dispatch_table, *pInstance, pCreateInfo->enabledExtensionCount, pCreateInfo->ppEnabledExtensionNames);
instance_data->extensions.InitFromInstanceCreateInfo((pCreateInfo->pApplicationInfo ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0), pCreateInfo);
- layer_debug_messenger_actions(instance_data->report_data, instance_data->logging_messenger, pAllocator, "lunarg_validation_layer");
+ layer_debug_messenger_actions(instance_data->report_data, instance_data->logging_messenger, pAllocator, "lunarg_object_tracker");
report_data = instance_data->report_data;
for (auto intercept : global_interceptor_list) {
@@ -551,8 +527,62 @@
if (genOpts.prefixText):
for s in genOpts.prefixText:
write(s, file=self.outFile)
+ write('#include <mutex>', file=self.outFile)
+ write('#include <cinttypes>', file=self.outFile)
+ write('#include <stdio.h>', file=self.outFile)
+ write('#include <stdlib.h>', file=self.outFile)
+ write('#include <string.h>', file=self.outFile)
+ write('#include <unordered_map>', file=self.outFile)
+ write('#include <unordered_set>', file=self.outFile)
+
+ write('#include "vk_loader_platform.h"', file=self.outFile)
+ write('#include "vulkan/vulkan.h"', file=self.outFile)
+ write('#include "vk_layer_config.h"', file=self.outFile)
+ write('#include "vk_layer_data.h"', file=self.outFile)
+ write('#include "vk_layer_logging.h"', file=self.outFile)
+ write('#include "vk_object_types.h"', file=self.outFile)
write('#include "vulkan/vk_layer.h"', file=self.outFile)
- write('#include <unordered_map>\n', file=self.outFile)
+ write('#include "vk_enum_string_helper.h"', file=self.outFile)
+ write('#include "vk_layer_extension_utils.h"', file=self.outFile)
+ write('#include "vk_layer_utils.h"', file=self.outFile)
+ write('#include "vulkan/vk_layer.h"', file=self.outFile)
+ write('#include "vk_dispatch_table_helper.h"', file=self.outFile)
+ write('#include "vk_validation_error_messages.h"', file=self.outFile)
+ write('#include "vk_extension_helper.h"', file=self.outFile)
+ write('', file=self.outFile)
+
+
+ # TODO: Need some ifdef code here for which layer is being built!
+ write('#include "object_lifetimes.h"', file=self.outFile)
+ write('', file=self.outFile)
+
+ write('struct instance_layer_data {', file=self.outFile)
+ write(' VkLayerInstanceDispatchTable dispatch_table;', file=self.outFile)
+ write(' VkInstance instance = VK_NULL_HANDLE;', file=self.outFile)
+ write(' debug_report_data *report_data = nullptr;', file=self.outFile)
+ write(' std::vector<VkDebugReportCallbackEXT> logging_callback;', file=self.outFile)
+ write(' std::vector<VkDebugUtilsMessengerEXT> logging_messenger;', file=self.outFile)
+ write(' InstanceExtensions extensions;', file=self.outFile)
+ write('', file=self.outFile)
+ # TODO: Need some ifdef code here for which layer is being built!
+ write(' object_lifetime objdata;', file=self.outFile)
+ write('};', file=self.outFile)
+ write('', file=self.outFile)
+ write('struct layer_data {', file=self.outFile)
+ write(' debug_report_data *report_data = nullptr;', file=self.outFile)
+ write(' VkLayerDispatchTable dispatch_table;', file=self.outFile)
+ write(' DeviceExtensions extensions = {};', file=self.outFile)
+ write(' VkDevice device = VK_NULL_HANDLE;', file=self.outFile)
+ write(' VkPhysicalDevice physical_device = VK_NULL_HANDLE;', file=self.outFile)
+ write(' instance_layer_data *instance_data = nullptr;', file=self.outFile)
+ write('', file=self.outFile)
+ # TODO: Need some ifdef code here for which layer is being built!
+ write(' object_lifetime objdata;', file=self.outFile)
+ write('};', file=self.outFile)
+ write('', file=self.outFile)
+ write('extern std::unordered_map<void *, layer_data *> layer_data_map;', file=self.outFile)
+ write('extern std::unordered_map<void *, instance_layer_data *> instance_layer_data_map;', file=self.outFile)
+ write('', file=self.outFile)
write('class layer_chassis;', file=self.outFile)
write('extern std::vector<layer_chassis *> global_interceptor_list;', file=self.outFile)
write('extern debug_report_data *report_data;\n', file=self.outFile)
@@ -619,7 +649,7 @@
write('\n'.join(self.sections['command']), end=u'', file=self.outFile)
self.newline()
if (self.featureExtraProtect != None):
- write('#endif /*', self.featureExtraProtect, '*/', file=self.outFile)
+ write('#endif //', self.featureExtraProtect, file=self.outFile)
# Finish processing in superclass
OutputGenerator.endFeature(self)
#
@@ -662,9 +692,6 @@
prototype = prototype.replace(")", "", 1)
prototype = prototype.replace(";", " {};")
- if 'GetPhysicalDeviceMemoryProperties' in prototype:
- stop = 'here'
-
# Build up pre/post call virtual function declarations
pre_call_validate = 'virtual bool PreCallValidate' + prototype
pre_call_validate = pre_call_validate.replace("{}", " { return false; }")
@@ -776,7 +803,10 @@
self.appendSection('command', ' ' + assignresult + API + '(' + paramstext + ');')
# Generate post-call object processing source code
- self.appendSection('command', ' {')
+ return_check = ''
+ if (resulttype.text == 'VkResult'):
+ return_check = 'if (VK_SUCCESS == result) '
+ self.appendSection('command', ' %s{' % return_check)
self.appendSection('command', ' std::lock_guard<std::mutex> lock(global_lock);')
self.appendSection('command', ' for (auto intercept : global_interceptor_list) {')
self.appendSection('command', ' intercept->PostCallRecord%s(%s);' % (api_function_name[2:], paramstext))
diff --git a/scripts/lvl_genvk.py b/scripts/lvl_genvk.py
index 3aaf748..cb46f5e 100644
--- a/scripts/lvl_genvk.py
+++ b/scripts/lvl_genvk.py
@@ -180,11 +180,11 @@
expandEnumerants = False)
]
- # Options for object_tracker validation routines
- genOpts['object_tracker_utils_auto.cpp'] = [
+ # Options for object_tracker code-generated validation routines
+ genOpts['object_tracker.cpp'] = [
ObjectTrackerOutputGenerator,
ObjectTrackerGeneratorOptions(
- filename = 'object_tracker_utils_auto.cpp',
+ filename = 'object_tracker.cpp',
directory = directory,
apiname = 'vulkan',
profile = None,
@@ -204,11 +204,11 @@
valid_usage_path = args.scripts)
]
- # Options for object_tracker core routines
- genOpts['object_tracker_core_auto.cpp'] = [
+ # Options for object_tracker code-generated prototypes
+ genOpts['object_tracker.h'] = [
ObjectTrackerOutputGenerator,
ObjectTrackerGeneratorOptions(
- filename = 'object_tracker_core_auto.cpp',
+ filename = 'object_tracker.h',
directory = directory,
apiname = 'vulkan',
profile = None,
diff --git a/scripts/object_tracker_generator.py b/scripts/object_tracker_generator.py
index 3588c28..2ca353b 100644
--- a/scripts/object_tracker_generator.py
+++ b/scripts/object_tracker_generator.py
@@ -127,71 +127,38 @@
diagFile = sys.stdout):
OutputGenerator.__init__(self, errFile, warnFile, diagFile)
self.INDENT_SPACES = 4
- self.intercepts = []
+ self.prototypes = []
self.instance_extensions = []
self.device_extensions = []
# Commands which are not autogenerated but still intercepted
self.no_autogen_list = [
'vkDestroyInstance',
- 'vkDestroyDevice',
- 'vkUpdateDescriptorSets',
- 'vkDestroyDebugReportCallbackEXT',
- 'vkDebugReportMessageEXT',
- 'vkGetPhysicalDeviceQueueFamilyProperties',
- 'vkFreeCommandBuffers',
- 'vkDestroySwapchainKHR',
- 'vkDestroyDescriptorPool',
- 'vkDestroyCommandPool',
- 'vkGetPhysicalDeviceQueueFamilyProperties2',
- 'vkGetPhysicalDeviceQueueFamilyProperties2KHR',
- 'vkResetDescriptorPool',
- 'vkBeginCommandBuffer',
- 'vkCreateDebugReportCallbackEXT',
- 'vkEnumerateInstanceLayerProperties',
- 'vkEnumerateDeviceLayerProperties',
- 'vkEnumerateInstanceExtensionProperties',
- 'vkEnumerateDeviceExtensionProperties',
- 'vkCreateDevice',
'vkCreateInstance',
'vkEnumeratePhysicalDevices',
+ 'vkGetPhysicalDeviceQueueFamilyProperties',
+ 'vkGetPhysicalDeviceQueueFamilyProperties2',
+ 'vkGetPhysicalDeviceQueueFamilyProperties2KHR',
+ 'vkGetDeviceQueue',
+ 'vkGetDeviceQueue2',
+ 'vkCreateDescriptorSetLayout',
+ 'vkDestroyDescriptorPool',
+ 'vkDestroyCommandPool',
'vkAllocateCommandBuffers',
'vkAllocateDescriptorSets',
'vkFreeDescriptorSets',
- 'vkCmdPushDescriptorSetKHR',
- 'vkDebugMarkerSetObjectNameEXT',
- 'vkGetPhysicalDeviceProcAddr',
- 'vkGetDeviceProcAddr',
- 'vkGetInstanceProcAddr',
- 'vkEnumerateInstanceExtensionProperties',
- 'vkEnumerateInstanceLayerProperties',
- 'vkEnumerateDeviceLayerProperties',
- 'vkGetDeviceProcAddr',
- 'vkGetInstanceProcAddr',
- 'vkEnumerateDeviceExtensionProperties',
- 'vk_layerGetPhysicalDeviceProcAddr',
- 'vkNegotiateLoaderLayerInterfaceVersion',
- 'vkCreateComputePipelines',
- 'vkGetDeviceQueue',
- 'vkGetDeviceQueue2',
- 'vkGetSwapchainImagesKHR',
- 'vkCreateDescriptorSetLayout',
+ 'vkFreeCommandBuffers',
+ 'vkUpdateDescriptorSets',
+ 'vkBeginCommandBuffer',
'vkGetDescriptorSetLayoutSupport',
'vkGetDescriptorSetLayoutSupportKHR',
- 'vkCreateDebugUtilsMessengerEXT',
- 'vkDestroyDebugUtilsMessengerEXT',
- 'vkSubmitDebugUtilsMessageEXT',
- 'vkSetDebugUtilsObjectNameEXT',
- 'vkSetDebugUtilsObjectTagEXT',
- 'vkQueueBeginDebugUtilsLabelEXT',
- 'vkQueueEndDebugUtilsLabelEXT',
- 'vkQueueInsertDebugUtilsLabelEXT',
- 'vkCmdBeginDebugUtilsLabelEXT',
- 'vkCmdEndDebugUtilsLabelEXT',
- 'vkCmdInsertDebugUtilsLabelEXT',
- 'vkGetDisplayModePropertiesKHR',
+ 'vkDestroySwapchainKHR',
+ 'vkGetSwapchainImagesKHR',
+ 'vkCmdPushDescriptorSetKHR',
+ 'vkDestroyDevice',
+ 'vkResetDescriptorPool',
'vkGetPhysicalDeviceDisplayPropertiesKHR',
'vkGetPhysicalDeviceDisplayProperties2KHR',
- 'vkGetDisplayPlaneSupportedDisplaysKHR',
+ 'vkGetDisplayModePropertiesKHR',
'vkGetDisplayModeProperties2KHR',
]
# These VUIDS are not implicit, but are best handled in this layer. Codegen for vkDestroy calls will generate a key
@@ -326,7 +293,7 @@
# Generate the object tracker undestroyed object validation function
def GenReportFunc(self):
output_func = ''
- output_func += 'bool ReportUndestroyedObjects(VkDevice device, const std::string& error_code) {\n'
+ output_func += 'bool ObjectLifetimes::ReportUndestroyedObjects(VkDevice device, const std::string& error_code) {\n'
output_func += ' bool skip = false;\n'
output_func += ' skip |= DeviceReportUndestroyedObjects(device, kVulkanObjectTypeCommandBuffer, error_code);\n'
for handle in self.object_types:
@@ -340,7 +307,7 @@
# Generate the object tracker undestroyed object destruction function
def GenDestroyFunc(self):
output_func = ''
- output_func += 'void DestroyUndestroyedObjects(VkDevice device) {\n'
+ output_func += 'void ObjectLifetimes::DestroyUndestroyedObjects(VkDevice device) {\n'
output_func += ' DeviceDestroyUndestroyedObjects(device, kVulkanObjectTypeCommandBuffer);\n'
for handle in self.object_types:
if self.isHandleTypeNonDispatchable(handle):
@@ -363,11 +330,11 @@
for s in self.ExtractVUIDs(l):
yield s
#
- # Separate content for validation (utils) and core files
+ # Separate content for validation source and header files
def otwrite(self, dest, formatstring):
- if 'core' in self.genOpts.filename and (dest == 'core' or dest == 'both'):
+ if 'object_tracker.h' in self.genOpts.filename and (dest == 'hdr' or dest == 'both'):
write(formatstring, file=self.outFile)
- elif 'utils' in self.genOpts.filename and (dest == 'util' or dest == 'both'):
+ elif 'object_tracker.cpp' in self.genOpts.filename and (dest == 'cpp' or dest == 'both'):
write(formatstring, file=self.outFile)
#
@@ -375,10 +342,10 @@
def beginFile(self, genOpts):
OutputGenerator.beginFile(self, genOpts)
- core_file = (genOpts.filename == 'object_tracker_utils_auto.cpp')
- utils_file = (genOpts.filename == 'object_tracker_core_auto.cpp')
+ header_file = (genOpts.filename == 'object_tracker.h')
+ source_file = (genOpts.filename == 'object_tracker.cpp')
- if not core_file and not utils_file:
+ if not header_file and not source_file:
print("Error: Output Filenames have changed, update generator source.\n")
sys.exit(1)
@@ -427,15 +394,10 @@
copyright += ' *\n'
copyright += ' ****************************************************************************/\n'
self.otwrite('both', copyright)
- # Namespace
self.newline()
- self.otwrite('both', '#include "object_tracker.h"')
- self.otwrite('both', '#include "object_lifetime_validation.h"')
- self.otwrite('both', '\n')
- self.otwrite('both', 'namespace object_tracker {')
- self.otwrite('core', '#include "precall.h"')
- self.otwrite('core', '#include "postcall.h"')
- self.otwrite('core', '\n')
+ self.otwrite('cpp', '#include "chassis.h"')
+ self.otwrite('cpp', '#include "object_lifetime_validation.h"')
+ self.otwrite('cpp', '\n')
#
# Now that the data is all collected and complete, generate and output the object validation routines
@@ -449,10 +411,10 @@
self.newline()
# Build undestroyed objects destruction function
destroy_func = self.GenDestroyFunc()
- self.otwrite('util', '\n')
- self.otwrite('util', '// ObjectTracker undestroyed objects validation function')
- self.otwrite('util', '%s' % report_func)
- self.otwrite('util', '%s' % destroy_func)
+ self.otwrite('cpp', '\n')
+ self.otwrite('cpp', '// ObjectTracker undestroyed objects validation function')
+ self.otwrite('cpp', '%s' % report_func)
+ self.otwrite('cpp', '%s' % destroy_func)
# Actually write the interface to the output file.
if (self.emit):
self.newline()
@@ -469,14 +431,18 @@
else:
self.otwrite('both', '\n')
- # Record intercepted procedures
- self.otwrite('core', '// Map of all APIs to be intercepted by this layer')
- self.otwrite('core', 'const std::unordered_map<std::string, void*> name_to_funcptr_map = {')
- intercepts = '\n'.join(self.intercepts)
- self.otwrite('core', '%s' % intercepts)
- self.otwrite('core', '};\n\n')
- self.otwrite('both', '} // namespace object_tracker')
- # Finish processing in superclass
+
+ self.otwrite('hdr', 'void PostCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator);')
+ self.otwrite('hdr', 'void PreCallRecordResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags);')
+ self.otwrite('hdr', 'void PostCallRecordGetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount, VkQueueFamilyProperties *pQueueFamilyProperties);')
+ self.otwrite('hdr', 'void PreCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, const VkCommandBuffer *pCommandBuffers);')
+ self.otwrite('hdr', 'void PreCallRecordFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, const VkDescriptorSet *pDescriptorSets);')
+ self.otwrite('hdr', 'void PostCallRecordGetPhysicalDeviceQueueFamilyProperties2(VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount, VkQueueFamilyProperties2KHR *pQueueFamilyProperties);')
+ self.otwrite('hdr', 'void PostCallRecordGetPhysicalDeviceQueueFamilyProperties2KHR(VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount, VkQueueFamilyProperties2KHR *pQueueFamilyProperties);')
+ self.otwrite('hdr', 'void PostCallRecordGetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, VkDisplayPropertiesKHR *pProperties);')
+ self.otwrite('hdr', 'void PostCallRecordGetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, uint32_t *pPropertyCount, VkDisplayModePropertiesKHR *pProperties);')
+ self.otwrite('hdr', 'void PostCallRecordGetPhysicalDeviceDisplayProperties2KHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, VkDisplayProperties2KHR *pProperties);')
+ self.otwrite('hdr', 'void PostCallRecordGetDisplayModeProperties2KHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, uint32_t *pPropertyCount, VkDisplayModeProperties2KHR *pProperties);')
OutputGenerator.endFile(self)
#
# Processing point at beginning of each extension definition
@@ -713,6 +679,7 @@
def generate_create_object_code(self, indent, proto, params, cmd_info, allocator):
create_obj_code = ''
handle_type = params[-1].find('type')
+
if self.isHandleTypeObject(handle_type.text):
# Check for special case where multiple handles are returned
object_array = False
@@ -721,7 +688,10 @@
handle_name = params[-1].find('name')
object_dest = '*%s' % handle_name.text
if object_array == True:
- create_obj_code += '%sfor (uint32_t index = 0; index < %s; index++) {\n' % (indent, cmd_info[-1].len)
+ countispointer = ''
+ if 'uint32_t*' in cmd_info[-2].cdecl:
+ countispointer = '*'
+ create_obj_code += '%sfor (uint32_t index = 0; index < %s%s; index++) {\n' % (indent, countispointer, cmd_info[-1].len)
indent = self.incIndent(indent)
object_dest = '%s[index]' % cmd_info[-1].name
@@ -942,29 +912,21 @@
cmdinfo = cmddata.cmdinfo
if cmdname in self.interface_functions:
continue
+ manual = False
if cmdname in self.no_autogen_list:
- if 'core' in self.genOpts.filename:
- decls = self.makeCDecls(cmdinfo.elem)
- self.appendSection('command', '')
- self.appendSection('command', '// Declare only')
- self.appendSection('command', decls[0])
- self.intercepts += [ ' {"%s", (void *)%s},' % (cmdname,cmdname[2:]) ]
- continue
+ manual = True
+
# Generate object handling code
(pre_call_validate, pre_call_record, post_call_record) = self.generate_wrapping_code(cmdinfo.elem)
- # If API doesn't contain any object handles, don't fool with it
- if not pre_call_validate and not pre_call_record and not post_call_record:
- continue
-
feature_extra_protect = cmddata.extra_protect
if (feature_extra_protect is not None):
self.appendSection('command', '')
self.appendSection('command', '#ifdef '+ feature_extra_protect)
- self.intercepts += [ '#ifdef %s' % feature_extra_protect ]
+ self.prototypes += [ '#ifdef %s' % feature_extra_protect ]
# Add intercept to procmap
- self.intercepts += [ ' {"%s", (void*)%s},' % (cmdname,cmdname[2:]) ]
+ self.prototypes += [ ' {"%s", (void*)%s},' % (cmdname,cmdname[2:]) ]
decls = self.makeCDecls(cmdinfo.elem)
@@ -976,12 +938,28 @@
fcn_call = cmdinfo.elem.attrib.get('name').replace('vk', 'TOKEN', 1) + '(' + paramstext + ');'
func_decl_template = decls[0][:-1].split('VKAPI_CALL ')
- func_decl_template = func_decl_template[1] + ' {'
+ func_decl_template = func_decl_template[1]
- if 'utils' in self.genOpts.filename:
- # Output PreCallValidateAPI function if necessary
+ if 'object_tracker.h' in self.genOpts.filename:
+ # Output PreCallValidateAPI prototype if necessary
if pre_call_validate:
- pre_cv_func_decl = 'bool PreCallValidate' + func_decl_template
+ pre_cv_func_decl = 'bool PreCallValidate' + func_decl_template + ';'
+ self.appendSection('command', pre_cv_func_decl)
+
+ # Output PreCallRecordAPI prototype if necessary
+ if pre_call_record:
+ pre_cr_func_decl = 'void PreCallRecord' + func_decl_template + ';'
+ self.appendSection('command', pre_cr_func_decl)
+
+ # Output PosCallRecordAPI prototype if necessary
+ if post_call_record:
+ post_cr_func_decl = 'void PostCallRecord' + func_decl_template + ';'
+ self.appendSection('command', post_cr_func_decl)
+
+ if 'object_tracker.cpp' in self.genOpts.filename:
+ # Output PreCallValidateAPI function if necessary
+ if pre_call_validate and not manual:
+ pre_cv_func_decl = 'bool ObjectLifetimes::PreCallValidate' + func_decl_template + ' {'
self.appendSection('command', '')
self.appendSection('command', pre_cv_func_decl)
self.appendSection('command', ' bool skip = false;')
@@ -990,93 +968,21 @@
self.appendSection('command', '}')
# Output PreCallRecordAPI function if necessary
- if pre_call_record:
- pre_cr_func_decl = 'void PreCallRecord' + func_decl_template
+ if pre_call_record and not manual:
+ pre_cr_func_decl = 'void ObjectLifetimes::PreCallRecord' + func_decl_template + ' {'
self.appendSection('command', '')
self.appendSection('command', pre_cr_func_decl)
self.appendSection('command', pre_call_record)
self.appendSection('command', '}')
# Output PosCallRecordAPI function if necessary
- if post_call_record:
- post_cr_func_decl = 'void PostCallRecord' + func_decl_template
+ if post_call_record and not manual:
+ post_cr_func_decl = 'void ObjectLifetimes::PostCallRecord' + func_decl_template + ' {'
self.appendSection('command', '')
self.appendSection('command', post_cr_func_decl)
self.appendSection('command', post_call_record)
self.appendSection('command', '}')
- if 'core' in self.genOpts.filename:
- # Output API function:
- self.appendSection('command', '')
- self.appendSection('command', decls[0][:-1])
- self.appendSection('command', '{')
-
- # Handle return values, if any
- resulttype = cmdinfo.elem.find('proto/type')
- if (resulttype is not None and resulttype.text == 'void'):
- resulttype = None
- if (resulttype is not None):
- assignresult = resulttype.text + ' result = '
- else:
- assignresult = ''
-
- # Output all pre-API-call source
- if pre_call_validate:
- self.appendSection('command', ' bool skip = false;')
- if pre_call_validate or pre_call_record:
- self.appendSection('command', ' {')
- self.appendSection('command', ' std::lock_guard<std::mutex> lock(global_lock);')
- # If necessary, add call to PreCallValidateApi(...);
- if pre_call_validate:
- pcv_call = fcn_call.replace('TOKEN', ' skip |= PreCallValidate', 1)
- self.appendSection('command', pcv_call)
- if assignresult != '':
- if resulttype.text == 'VkResult':
- self.appendSection('command', ' if (skip) return VK_ERROR_VALIDATION_FAILED_EXT;')
- elif resulttype.text == 'VkBool32':
- self.appendSection('command', ' if (skip) return VK_FALSE;')
- else:
- raise Exception('Unknown result type ' + resulttype.text)
- else:
- self.appendSection('command', ' if (skip) return;')
- # If necessary, add call to PreCallRecordApi(...);
- if pre_call_record:
- pre_cr_call = fcn_call.replace('TOKEN', ' PreCallRecord', 1)
- self.appendSection('command', pre_cr_call)
-
- if pre_call_validate or pre_call_record:
- self.appendSection('command', ' }')
-
- # Build down-chain call strings and output source
- # Use correct dispatch table
- disp_name = cmdinfo.elem.find('param/name').text
- disp_type = cmdinfo.elem.find('param/type').text
- map_type = ''
- if disp_type in ["VkInstance", "VkPhysicalDevice"] or cmdname == 'vkCreateInstance':
- object_type = 'instance'
- map_type = 'instance_'
- else:
- object_type = 'device'
- dispatch_table = 'GetLayerDataPtr(get_dispatch_key(%s), %slayer_data_map)->%s_dispatch_table.' % (disp_name, map_type, object_type)
- down_chain_call = fcn_call.replace('TOKEN', dispatch_table, 1)
- self.appendSection('command', ' ' + assignresult + down_chain_call)
-
- # If necessary, add call to PostCallRecordApi(...);
- if post_call_record:
- if assignresult:
- if resulttype.text == 'VkResult':
- self.appendSection('command', ' if (VK_SUCCESS == result) {')
- elif resulttype.text == 'VkBool32':
- self.appendSection('command', ' if (VK_TRUE == result) {')
- self.appendSection('command', ' std::lock_guard<std::mutex> lock(global_lock);')
- post_cr_call = fcn_call.replace('TOKEN', ' PostCallRecord', 1)
- self.appendSection('command', post_cr_call)
- self.appendSection('command', ' }')
-
- # Handle the return result variable, if any
- if (resulttype is not None):
- self.appendSection('command', ' return result;')
- self.appendSection('command', '}')
if (feature_extra_protect is not None):
self.appendSection('command', '#endif // '+ feature_extra_protect)
- self.intercepts += [ '#endif' ]
+ self.prototypes += [ '#endif' ]
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index cb586e8..255a70d 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -124,7 +124,7 @@
VkLayer_utils
VkLayer_core_validation-json
VkLayer_device_profile_api-json
- VkLayer_object_tracker-json
+ VkLayer_object_lifetimes-json
VkLayer_parameter_validation-json
VkLayer_standard_validation-json
VkLayer_threading-json