#!/bin/bash
# Copyright 2015 The Android Open Source Project
+# Copyright (C) 2015 Valve Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
python ../vk_helper.py --gen_enum_string_helper ../include/vulkan/vulkan.h --abs_out_dir generated
python ../vk_helper.py --gen_struct_wrappers ../include/vulkan/vulkan.h --abs_out_dir generated
-python ../vk-layer-generate.py Generic ../include/vulkan/vulkan.h > generated/generic_layer.cpp
-python ../vk-layer-generate.py APIDump ../include/vulkan/vulkan.h > generated/api_dump.cpp
-python ../vk-layer-generate.py ObjectTracker ../include/vulkan/vulkan.h > generated/object_track.cpp
-python ../vk-layer-generate.py Threading ../include/vulkan/vulkan.h > generated/threading.cpp
+python ../vk-layer-generate.py generic ../include/vulkan/vulkan.h > generated/generic_layer.cpp
+python ../vk-layer-generate.py api_dump ../include/vulkan/vulkan.h > generated/api_dump.cpp
+python ../vk-layer-generate.py object_tracker ../include/vulkan/vulkan.h > generated/object_tracker.cpp
+python ../vk-layer-generate.py threading ../include/vulkan/vulkan.h > generated/threading.cpp
# Copyright 2015 The Android Open Source Project\r
+# Copyright (C) 2015 Valve Corporation\r
\r
# Licensed under the Apache License, Version 2.0 (the "License");\r
# you may not use this file except in compliance with the License.\r
include $(BUILD_STATIC_LIBRARY)\r
\r
include $(CLEAR_VARS)\r
-LOCAL_MODULE := VKLayerBasic\r
+LOCAL_MODULE := VkLayer_basic\r
LOCAL_SRC_FILES += $(SRC_DIR)/layers/basic.cpp\r
LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp\r
LOCAL_C_INCLUDES += $(SRC_DIR)/include \\r
include $(BUILD_SHARED_LIBRARY)\r
\r
include $(CLEAR_VARS)\r
-LOCAL_MODULE := VKLayerDrawState\r
+LOCAL_MODULE := VkLayer_draw_state\r
LOCAL_SRC_FILES += $(SRC_DIR)/layers/draw_state.cpp\r
LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_debug_marker_table.cpp\r
LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp\r
include $(BUILD_SHARED_LIBRARY)\r
\r
include $(CLEAR_VARS)\r
-LOCAL_MODULE := VKLayerMemTracker\r
+LOCAL_MODULE := VkLayer_mem_tracker\r
LOCAL_SRC_FILES += $(SRC_DIR)/layers/mem_tracker.cpp\r
LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp\r
LOCAL_C_INCLUDES += $(SRC_DIR)/include \\r
include $(BUILD_SHARED_LIBRARY)\r
\r
include $(CLEAR_VARS)\r
-LOCAL_MODULE := VKLayerDeviceLimits\r
+LOCAL_MODULE := VkLayer_device_limits\r
LOCAL_SRC_FILES += $(SRC_DIR)/layers/device_limits.cpp\r
LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_debug_marker_table.cpp\r
LOCAL_C_INCLUDES += $(SRC_DIR)/include \\r
include $(BUILD_SHARED_LIBRARY)\r
\r
include $(CLEAR_VARS)\r
-LOCAL_MODULE := VKLayerImage\r
+LOCAL_MODULE := VkLayer_image\r
LOCAL_SRC_FILES += $(SRC_DIR)/layers/image.cpp\r
LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp\r
LOCAL_C_INCLUDES += $(SRC_DIR)/include \\r
include $(BUILD_SHARED_LIBRARY)\r
\r
include $(CLEAR_VARS)\r
-LOCAL_MODULE := VKLayerParamChecker\r
+LOCAL_MODULE := VkLayer_param_checker\r
LOCAL_SRC_FILES += $(SRC_DIR)/layers/param_checker.cpp\r
LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_debug_marker_table.cpp\r
LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp\r
include $(BUILD_SHARED_LIBRARY)\r
\r
include $(CLEAR_VARS)\r
-LOCAL_MODULE := VKLayerGeneric\r
+LOCAL_MODULE := VkLayer_generic\r
LOCAL_SRC_FILES += $(SRC_DIR)/buildAndroid/generated/generic_layer.cpp\r
LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp\r
LOCAL_C_INCLUDES += $(SRC_DIR)/include \\r
include $(BUILD_SHARED_LIBRARY)\r
\r
include $(CLEAR_VARS)\r
-LOCAL_MODULE := VKLayerAPIDump\r
+LOCAL_MODULE := VkLayer_api_dump\r
LOCAL_SRC_FILES += $(SRC_DIR)/buildAndroid/generated/api_dump.cpp\r
LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp\r
LOCAL_C_INCLUDES += $(SRC_DIR)/include \\r
include $(BUILD_SHARED_LIBRARY)\r
\r
include $(CLEAR_VARS)\r
-LOCAL_MODULE := VKLayerObjectTracker\r
-LOCAL_SRC_FILES += $(SRC_DIR)/buildAndroid/generated/object_track.cpp\r
+LOCAL_MODULE := VkLayer_object_tracker\r
+LOCAL_SRC_FILES += $(SRC_DIR)/buildAndroid/generated/object_tracker.cpp\r
LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp\r
LOCAL_C_INCLUDES += $(SRC_DIR)/include \\r
$(SRC_DIR)/layers \\r
include $(BUILD_SHARED_LIBRARY)\r
\r
include $(CLEAR_VARS)\r
-LOCAL_MODULE := VKLayerThreading\r
+LOCAL_MODULE := VkLayer_threading\r
LOCAL_SRC_FILES += $(SRC_DIR)/buildAndroid/generated/threading.cpp\r
LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp\r
LOCAL_C_INCLUDES += $(SRC_DIR)/include \\r
include $(BUILD_SHARED_LIBRARY)\r
\r
include $(CLEAR_VARS)\r
-LOCAL_MODULE := VKLayerValidationTests\r
+LOCAL_MODULE := VkLayerValidationTests\r
LOCAL_SRC_FILES += $(SRC_DIR)/tests/layer_validation_tests.cpp \\r
$(SRC_DIR)/tests/vktestbinding.cpp \\r
$(SRC_DIR)/tests/vktestframeworkandroid.cpp \\r
# Copyright 2015 The Android Open Source Project\r
+# Copyright (C) 2015 Valve Corporation\r
\r
# Licensed under the Apache License, Version 2.0 (the "License");\r
# you may not use this file except in compliance with the License.\r
APP_ABI := armeabi-v7a arm64-v8a x86 x86_64 mips mips64\r
APP_PLATFORM := android-22\r
APP_STL := gnustl_static\r
-APP_MODULES := layer_utils VKLayerBasic VKLayerDrawState VKLayerMemTracker VKLayerDeviceLimits VKLayerImage VKLayerParamChecker VKLayerGeneric VKLayerAPIDump VKLayerObjectTracker VKLayerThreading VKLayerValidationTests\r
+APP_MODULES := layer_utils VkLayer_basic VkLayer_draw_state VkLayer_mem_tracker VkLayer_device_limits VkLayer_image VkLayer_param_checker VkLayer_generic VkLayer_api_dump VkLayer_object_tracker VkLayer_threading VkLayerValidationTests\r
APP_CPPFLAGS += -std=c++11 -DVK_PROTOTYPES\r
NDK_TOOLCHAIN_VERSION := 4.8\r
uint32_t enabled_layer_count = 0;
char *instance_validation_layers[] = {
- "VK_LAYER_LUNARG_Threading",
- "VK_LAYER_LUNARG_MemTracker",
- "VK_LAYER_LUNARG_ObjectTracker",
- "VK_LAYER_LUNARG_DrawState",
- "VK_LAYER_LUNARG_ParamChecker",
- "VK_LAYER_LUNARG_Swapchain",
- "VK_LAYER_LUNARG_DeviceLimits",
- "VK_LAYER_LUNARG_Image",
+ "VK_LAYER_LUNARG_threading",
+ "VK_LAYER_LUNARG_mem_tracker",
+ "VK_LAYER_LUNARG_object_tracker",
+ "VK_LAYER_LUNARG_draw_state",
+ "VK_LAYER_LUNARG_param_checker",
+ "VK_LAYER_LUNARG_swapchain",
+ "VK_LAYER_LUNARG_device_limits",
+ "VK_LAYER_LUNARG_image",
};
char *device_validation_layers[] = {
- "VK_LAYER_LUNARG_Threading",
- "VK_LAYER_LUNARG_MemTracker",
- "VK_LAYER_LUNARG_ObjectTracker",
- "VK_LAYER_LUNARG_DrawState",
- "VK_LAYER_LUNARG_ParamChecker",
- "VK_LAYER_LUNARG_Swapchain",
- "VK_LAYER_LUNARG_DeviceLimits",
- "VK_LAYER_LUNARG_Image",
+ "VK_LAYER_LUNARG_threading",
+ "VK_LAYER_LUNARG_mem_tracker",
+ "VK_LAYER_LUNARG_object_tracker",
+ "VK_LAYER_LUNARG_draw_state",
+ "VK_LAYER_LUNARG_param_checker",
+ "VK_LAYER_LUNARG_swapchain",
+ "VK_LAYER_LUNARG_device_limits",
+ "VK_LAYER_LUNARG_image",
};
/* Look for validation layers */
uint32_t enabled_layer_count = 0;
char *instance_validation_layers[] = {
- "VK_LUNARG_LAYER_MemTracker",
+ "VK_LUNARG_LAYER_mem_tracker",
};
char *device_validation_layers[] = {
- "VK_LUNARG_LAYER_MemTracker",
+ "VK_LUNARG_LAYER_mem_tracker",
};
/* Look for validation layers */
endmacro()
set(LAYER_JSON_FILES
- api_dump
- basic
- draw_state
- generic
- image
- mem_tracker
- multi
- object_tracker
- param_checker
- screenshot
- swapchain
- threading
- device_limits
+ VkLayer_api_dump
+ VkLayer_basic
+ VkLayer_draw_state
+ VkLayer_generic
+ VkLayer_image
+ VkLayer_mem_tracker
+ VkLayer_multi
+ VkLayer_object_tracker
+ VkLayer_param_checker
+ VkLayer_screenshot
+ VkLayer_swapchain
+ VkLayer_threading
+ VkLayer_device_limits
)
set(VK_LAYER_RPATH /usr/lib/x86_64-linux-gnu/vulkan/layer:/usr/lib/i386-linux-gnu/vulkan/layer)
if (WIN32)
macro(add_vk_layer target)
- add_custom_command(OUTPUT VKLayer${target}.def
- COMMAND ${PYTHON_CMD} ${PROJECT_SOURCE_DIR}/vk-generate.py win-def-file VKLayer${target} layer > VKLayer${target}.def
+ add_custom_command(OUTPUT VkLayer_${target}.def
+ COMMAND ${PYTHON_CMD} ${PROJECT_SOURCE_DIR}/vk-generate.py win-def-file VkLayer_${target} layer > VkLayer_${target}.def
DEPENDS ${PROJECT_SOURCE_DIR}/vk-generate.py ${PROJECT_SOURCE_DIR}/vk.py
)
- add_library(VKLayer${target} SHARED ${ARGN} VKLayer${target}.def)
- target_link_Libraries(VKLayer${target} layer_utils)
- add_dependencies(VKLayer${target} layer_utils_static)
- add_dependencies(VKLayer${target} generate_vk_layer_helpers)
- set_target_properties(VKLayer${target} PROPERTIES LINK_FLAGS "/DEF:${CMAKE_CURRENT_BINARY_DIR}/VKLayer${target}.def")
+ add_library(VkLayer_${target} SHARED ${ARGN} VkLayer_${target}.def)
+ target_link_Libraries(VkLayer_${target} layer_utils)
+ add_dependencies(VkLayer_${target} layer_utils_static)
+ add_dependencies(VkLayer_${target} generate_vk_layer_helpers)
+ set_target_properties(VkLayer_${target} PROPERTIES LINK_FLAGS "/DEF:${CMAKE_CURRENT_BINARY_DIR}/VkLayer_${target}.def")
endmacro()
else()
macro(add_vk_layer target)
- add_library(VKLayer${target} SHARED ${ARGN})
- target_link_Libraries(VKLayer${target} layer_utils)
- add_dependencies(VKLayer${target} generate_vk_layer_helpers)
- set_target_properties(VKLayer${target} PROPERTIES LINK_FLAGS "-Wl,-Bsymbolic")
- install(TARGETS VKLayer${target} DESTINATION ${PROJECT_BINARY_DIR}/install_staging)
+ add_library(VkLayer_${target} SHARED ${ARGN})
+ target_link_Libraries(VkLayer_${target} layer_utils)
+ add_dependencies(VkLayer_${target} generate_vk_layer_helpers)
+ set_target_properties(VkLayer_${target} PROPERTIES LINK_FLAGS "-Wl,-Bsymbolic")
+ install(TARGETS VkLayer_${target} DESTINATION ${PROJECT_BINARY_DIR}/install_staging)
endmacro()
endif()
run_vk_helper(gen_enum_string_helper vk_enum_string_helper.h)
run_vk_helper(gen_struct_wrappers
vk_struct_string_helper.h
- vk_struct_string_helper_cpp.h
+ vk_struct_string_helper_cpp.h
vk_struct_string_helper_no_addr.h
vk_struct_string_helper_no_addr_cpp.h
- vk_struct_size_helper.h
- vk_struct_size_helper.c
+ vk_struct_size_helper.h
+ vk_struct_size_helper.c
vk_struct_wrappers.h
vk_struct_wrappers.cpp
)
vk_enum_string_helper.h
vk_struct_string_helper.h
vk_struct_string_helper_no_addr.h
- vk_struct_string_helper_cpp.h
+ vk_struct_string_helper_cpp.h
vk_struct_string_helper_no_addr_cpp.h
- vk_struct_size_helper.h
- vk_struct_size_helper.c
+ vk_struct_size_helper.h
+ vk_struct_size_helper.c
vk_struct_wrappers.h
vk_struct_wrappers.cpp
)
-run_vk_layer_generate(Generic generic_layer.cpp)
-run_vk_layer_generate(APIDump api_dump.cpp)
-run_vk_layer_generate(ObjectTracker object_track.cpp)
-run_vk_layer_generate(Threading threading.cpp)
+run_vk_layer_generate(generic generic_layer.cpp)
+run_vk_layer_generate(api_dump api_dump.cpp)
+run_vk_layer_generate(object_tracker object_tracker.cpp)
+run_vk_layer_generate(threading threading.cpp)
add_library(layer_utils SHARED vk_layer_config.cpp vk_layer_extension_utils.cpp vk_layer_utils.cpp)
if (WIN32)
install(TARGETS layer_utils DESTINATION ${PROJECT_BINARY_DIR}/install_staging)
endif()
-add_vk_layer(Basic basic.cpp vk_layer_table.cpp)
-add_vk_layer(Multi multi.cpp vk_layer_table.cpp)
-add_vk_layer(DrawState draw_state.cpp vk_layer_debug_marker_table.cpp vk_layer_table.cpp)
-add_vk_layer(DeviceLimits device_limits.cpp vk_layer_debug_marker_table.cpp vk_layer_table.cpp vk_layer_utils.cpp)
-add_vk_layer(MemTracker mem_tracker.cpp vk_layer_table.cpp)
-add_vk_layer(Image image.cpp vk_layer_table.cpp)
-add_vk_layer(ParamChecker param_checker.cpp vk_layer_debug_marker_table.cpp vk_layer_table.cpp)
-add_vk_layer(ScreenShot screenshot.cpp vk_layer_table.cpp)
-add_vk_layer(Swapchain swapchain.cpp vk_layer_table.cpp)
+add_vk_layer(basic basic.cpp vk_layer_table.cpp)
+add_vk_layer(multi multi.cpp vk_layer_table.cpp)
+add_vk_layer(draw_state draw_state.cpp vk_layer_debug_marker_table.cpp vk_layer_table.cpp)
+add_vk_layer(device_limits device_limits.cpp vk_layer_debug_marker_table.cpp vk_layer_table.cpp vk_layer_utils.cpp)
+add_vk_layer(mem_tracker mem_tracker.cpp vk_layer_table.cpp)
+add_vk_layer(image image.cpp vk_layer_table.cpp)
+add_vk_layer(param_checker param_checker.cpp vk_layer_debug_marker_table.cpp vk_layer_table.cpp)
+add_vk_layer(screenshot screenshot.cpp vk_layer_table.cpp)
+add_vk_layer(swapchain swapchain.cpp vk_layer_table.cpp)
# generated
-add_vk_layer(Generic generic_layer.cpp vk_layer_table.cpp)
-add_vk_layer(APIDump api_dump.cpp vk_layer_table.cpp)
-add_vk_layer(ObjectTracker object_track.cpp vk_layer_table.cpp)
-add_vk_layer(Threading threading.cpp vk_layer_table.cpp)
+add_vk_layer(generic generic_layer.cpp vk_layer_table.cpp)
+add_vk_layer(api_dump api_dump.cpp vk_layer_table.cpp)
+add_vk_layer(object_tracker object_tracker.cpp vk_layer_table.cpp)
+add_vk_layer(threading threading.cpp vk_layer_table.cpp)
-include/vkLayer.h - header file for layer code.
### Templates
-layers/basic.cpp (name=VK_LAYER_LUNARG_Basic) simple example wrapping a few entrypoints. Shows layer features:
+layers/basic.cpp (name=VK_LAYER_LUNARG_basic) simple example wrapping a few entrypoints. Shows layer features:
- Multiple dispatch tables for supporting multiple GPUs.
- Example layer extension function shown.
- Layer extension advertised by vkGetXXXExtension().
layers/multi.cpp (name=VK_LAYER_LUNARG_multi1:VK_LAYER_LUNARG_multi2) simple example showing multiple layers per library
-(build dir)/layer/generic_layer.cpp (name=VK_LAYER_LUNARG_Generic) - auto generated example wrapping all VK entrypoints.
+(build dir)/layer/generic_layer.cpp (name=VK_LAYER_LUNARG_generic) - auto generated example wrapping all VK entrypoints.
### Layer Details
For complete details of current validation layers, including all of the validation checks that they perform, please refer to the document layers/vk_validation_layer_details.md. Below is a brief overview of each layer.
### Print API Calls and Parameter Values
-(build dir)/layers/api_dump.cpp (name=VK_LAYER_LUNARG_APIDump) - print out API calls along with parameter values
+(build dir)/layers/api_dump.cpp (name=VK_LAYER_LUNARG_api_dump) - print out API calls along with parameter values
### Print Object Stats
-(build dir)/layers/object_track.cpp (name=VK_LAYER_LUNARG_ObjectTracker) - Track object creation, use, and destruction. As objects are created, they're stored in a map. As objects are used, the layer verifies they exist in the map, flagging errors for unknown objects. As objects are destroyed, they're removed from the map. At vkDestroyDevice() and vkDestroyInstance() times, if any objects have not been destroyed, they are reported as leaked objects. If a Dbg callback function is registered, this layer will use callback function(s) for reporting, otherwise uses stdout.
+(build dir)/layers/object_tracker.cpp (name=VK_LAYER_LUNARG_object_tracker) - Track object creation, use, and destruction. As objects are created, they're stored in a map. As objects are used, the layer verifies they exist in the map, flagging errors for unknown objects. As objects are destroyed, they're removed from the map. At vkDestroyDevice() and vkDestroyInstance() times, if any objects have not been destroyed, they are reported as leaked objects. If a Dbg callback function is registered, this layer will use callback function(s) for reporting, otherwise uses stdout.
### Validate Draw State and Shaders
-layers/draw\_state.cpp (name=VK_LAYER_LUNARG_DrawState) - DrawState tracks the Descriptor Set, Pipeline State, Shaders, and dynamic state performing some point validation as states are created and used, and further validation at each Draw call. Of primary interest is making sure that the resources bound to Descriptor Sets correctly align with the layout specified for the Set. Additionally DrawState include sharder validation (formerly separate ShaderChecker layer) that inspects the SPIR-V shader images and fixed function pipeline stages at PSO creation time. It flags errors when inconsistencies are found across interfaces between shader stages. The exact behavior of the checks depends on the pair of pipeline stages involved. If a Dbg callback function is registered, this layer will use callback function(s) for reporting, otherwise uses stdout.
+layers/draw\_state.cpp (name=VK_LAYER_LUNARG_draw_state) - DrawState tracks the Descriptor Set, Pipeline State, Shaders, and dynamic state performing some point validation as states are created and used, and further validation at each Draw call. Of primary interest is making sure that the resources bound to Descriptor Sets correctly align with the layout specified for the Set. Additionally DrawState include sharder validation (formerly separate ShaderChecker layer) that inspects the SPIR-V shader images and fixed function pipeline stages at PSO creation time. It flags errors when inconsistencies are found across interfaces between shader stages. The exact behavior of the checks depends on the pair of pipeline stages involved. If a Dbg callback function is registered, this layer will use callback function(s) for reporting, otherwise uses stdout.
### Track GPU Memory
-layers/mem\_tracker.cpp (name=VK_LAYER_LUNARG_MemTracker) - The MemTracker layer tracks memory objects and references and validates that they are managed correctly by the application. This includes tracking object bindings, memory hazards, and memory object lifetimes. MemTracker validates several other hazard-related issues related to command buffers, fences, and memory mapping. If a Dbg callback function is registered, this layer will use callback function(s) for reporting, otherwise uses stdout.
+layers/mem\_tracker.cpp (name=VK_LAYER_LUNARG_mem_tracker) - The MemTracker layer tracks memory objects and references and validates that they are managed correctly by the application. This includes tracking object bindings, memory hazards, and memory object lifetimes. MemTracker validates several other hazard-related issues related to command buffers, fences, and memory mapping. If a Dbg callback function is registered, this layer will use callback function(s) for reporting, otherwise uses stdout.
### Check parameters
-layers/param_checker.cpp (name=VK_LAYER_LUNARG_ParamChecker) - Check the input parameters to API calls for validity. If a Dbg callback function is registered, this layer will use callback function(s) for reporting, otherwise uses stdout.
+layers/param_checker.cpp (name=VK_LAYER_LUNARG_param_checker) - Check the input parameters to API calls for validity. If a Dbg callback function is registered, this layer will use callback function(s) for reporting, otherwise uses stdout.
### Image parameters
-layers/image.cpp (name=VK_LAYER_LUNARG_Image) - The Image layer is intended to validate image parameters, formats, and correct use. Images are a significant enough area that they were given a separate layer. If a Dbg callback function is registered, this layer will use callback function(s) for reporting, otherwise uses stdout.
+layers/image.cpp (name=VK_LAYER_LUNARG_image) - The Image layer is intended to validate image parameters, formats, and correct use. Images are a significant enough area that they were given a separate layer. If a Dbg callback function is registered, this layer will use callback function(s) for reporting, otherwise uses stdout.
### Check threading
-<build dir>/layers/threading.cpp (name=VK_LAYER_LUNARG_Threading) - Check multithreading of API calls for validity. Currently this checks that only one thread at a time uses an object in free-threaded API calls. If a Dbg callback function is registered, this layer will use callback function(s) for reporting, otherwise uses stdout.
+<build dir>/layers/threading.cpp (name=VK_LAYER_LUNARG_threading) - Check multithreading of API calls for validity. Currently this checks that only one thread at a time uses an object in free-threaded API calls. If a Dbg callback function is registered, this layer will use callback function(s) for reporting, otherwise uses stdout.
### Swapchain
-<build dir>/layer/swapchain.cpp (name=VK_LAYER_LUNARG_Swapchain) - Check that WSI extensions are being used correctly.
+<build dir>/layer/swapchain.cpp (name=VK_LAYER_LUNARG_swapchain) - Check that WSI extensions are being used correctly.
### Device Limitations
-layers/device_limits.cpp (name=VK_LAYER_LUNARG_DeviceLimits) - This layer is intended to capture underlying device features and limitations and then flag errors if an app makes requests for unsupported features or exceeding limitations. This layer is a work in progress and currently only flags some high-level errors without flagging errors on specific feature and limitation. If a Dbg callback function is registered, this layer will use callback function(s) for reporting, otherwise uses stdout.
+layers/device_limits.cpp (name=VK_LAYER_LUNARG_device_limits) - This layer is intended to capture underlying device features and limitations and then flag errors if an app makes requests for unsupported features or exceeding limitations. This layer is a work in progress and currently only flags some high-level errors without flagging errors on specific feature and limitation. If a Dbg callback function is registered, this layer will use callback function(s) for reporting, otherwise uses stdout.
## Using Layers
1. Build VK loader and i965 icd driver using normal steps (cmake and make)
-2. Place libVKLayer<name>.so in the same directory as your VK test or app:
+2. Place libVkLayer_<name>.so in the same directory as your VK test or app:
- cp build/layer/libVKLayerBasic.so build/layer/libVKLayerGeneric.so build/tests
+ cp build/layer/libVkLayer_basic.so build/layer/libVkLayer_generic.so build/tests
This is required for the Loader to be able to scan and enumerate your library.
Alternatively, use the VK\_LAYER\_PATH environment variable to specify where the layer libraries reside.
4. Specify which Layers to activate by using
vkCreateDevice and/or vkCreateInstance or environment variables.
- export VK\_INSTANCE\_LAYERS=VK_LAYER_LUNARG_Basic:VK_LAYER_LUNARG_Generic
- export VK\_DEVICE\_LAYERS=VK_LAYER_LUNARG_Basic:VK_LAYER_LUNARG_Generic
+ export VK\_INSTANCE\_LAYERS=VK_LAYER_LUNARG_basic:VK_LAYER_LUNARG_generic
+ export VK\_DEVICE\_LAYERS=VK_LAYER_LUNARG_basic:VK_LAYER_LUNARG_generic
cd build/tests; ./vkinfo
## Tips for writing new layers
implementation; exceptions are vkGetXXXXProcAddr,
which must have the correct name since the Loader calls these entrypoints;
8. entrypoint names must be exported to the OSes dynamic loader with VK\_LAYER\_EXPORT;
-9. Layer naming convention is camel case same name as in library: libVKLayer<name>.so
+9. Layer naming convention is camel case same name as in library: libVkLayer_<name>.so
10. For multiple layers in one library the manifest file can specify each layer.
## Status
--- /dev/null
+/*
+ *
+ * Copyright (C) 2015 Valve Corporation
+ * Copyright (C) 2015 Google Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Author: Courtney Goeltzenleuchter <courtney@LunarG.com>
+ * Author: Jon Ashburn <jon@lunarg.com>
+ *
+ */
+#pragma once
+
+#include "vulkan/vk_layer.h"
+
+/*
+ * This file contains static functions for the generated layer api_dump
+ */
+
+#define LAYER_PROPS_ARRAY_SIZE 1
+static const VkLayerProperties layerProps[LAYER_PROPS_ARRAY_SIZE] = {
+ {
+ "VK_LAYER_LUNARG_api_dump",
+ VK_API_VERSION, // specVersion
+ VK_MAKE_VERSION(0, 1, 0), // implementationVersion
+ "layer: api_dump",
+ }
+};
+
+#define LAYER_DEV_PROPS_ARRAY_SIZE 1
+static const VkLayerProperties layerDevProps[LAYER_DEV_PROPS_ARRAY_SIZE] = {
+ {
+ "VK_LAYER_LUNARG_api_dump",
+ VK_API_VERSION, // specVersion
+ VK_MAKE_VERSION(0, 1, 0), // implementationVersion
+ "layer: api_dump",
+ }
+};
+
+struct devExts {
+ bool wsi_enabled;
+};
+
+struct instExts {
+ bool wsi_enabled;
+};
+
+static std::unordered_map<void *, struct devExts> deviceExtMap;
+static std::unordered_map<void *, struct instExts> instanceExtMap;
+
+static void createDeviceRegisterExtensions(const VkDeviceCreateInfo* pCreateInfo, VkDevice device)
+{
+ uint32_t i;
+ VkLayerDispatchTable *pDisp = device_dispatch_table(device);
+ PFN_vkGetDeviceProcAddr gpa = pDisp->GetDeviceProcAddr;
+ pDisp->CreateSwapchainKHR = (PFN_vkCreateSwapchainKHR) gpa(device, "vkCreateSwapchainKHR");
+ pDisp->DestroySwapchainKHR = (PFN_vkDestroySwapchainKHR) gpa(device, "vkDestroySwapchainKHR");
+ pDisp->GetSwapchainImagesKHR = (PFN_vkGetSwapchainImagesKHR) gpa(device, "vkGetSwapchainImagesKHR");
+ pDisp->AcquireNextImageKHR = (PFN_vkAcquireNextImageKHR) gpa(device, "vkAcquireNextImageKHR");
+ pDisp->QueuePresentKHR = (PFN_vkQueuePresentKHR) gpa(device, "vkQueuePresentKHR");
+
+ deviceExtMap[pDisp].wsi_enabled = false;
+ for (i = 0; i < pCreateInfo->enabledExtensionNameCount; i++) {
+ if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SWAPCHAIN_EXTENSION_NAME) == 0)
+ deviceExtMap[pDisp].wsi_enabled = true;
+
+ }
+}
+
+static void createInstanceRegisterExtensions(const VkInstanceCreateInfo* pCreateInfo, VkInstance instance)
+{
+ uint32_t i;
+ VkLayerInstanceDispatchTable *pDisp = instance_dispatch_table(instance);
+ PFN_vkGetInstanceProcAddr gpa = pDisp->GetInstanceProcAddr;
+ pDisp->GetPhysicalDeviceSurfaceSupportKHR = (PFN_vkGetPhysicalDeviceSurfaceSupportKHR) gpa(instance, "vkGetPhysicalDeviceSurfaceSupportKHR");
+ pDisp->GetPhysicalDeviceSurfaceCapabilitiesKHR = (PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR) gpa(instance, "vkGetPhysicalDeviceSurfaceCapabilitiesKHR");
+ pDisp->GetPhysicalDeviceSurfaceFormatsKHR = (PFN_vkGetPhysicalDeviceSurfaceFormatsKHR) gpa(instance, "vkGetPhysicalDeviceSurfaceFormatsKHR");
+ pDisp->GetPhysicalDeviceSurfacePresentModesKHR = (PFN_vkGetPhysicalDeviceSurfacePresentModesKHR) gpa(instance, "vkGetPhysicalDeviceSurfacePresentModesKHR");
+
+#if VK_USE_PLATFORM_WIN32_KHR
+ pDisp->CreateWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR) gpa(instance, "vkCreateWin32SurfaceKHR");
+ pDisp->GetPhysicalDeviceWin32PresentationSupportKHR = (PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceWin32PresentationSupportKHR");
+#endif // VK_USE_PLATFORM_WIN32_KHR
+#ifdef VK_USE_PLATFORM_XCB_KHR
+ pDisp->CreateXcbSurfaceKHR = (PFN_vkCreateXcbSurfaceKHR) gpa(instance, "vkCreateXcbSurfaceKHR");
+ pDisp->GetPhysicalDeviceXcbPresentationSupportKHR = (PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceXcbPresentationSupportKHR");
+#endif // VK_USE_PLATFORM_XCB_KHR
+#ifdef VK_USE_PLATFORM_XLIB_KHR
+ pDisp->CreateXlibSurfaceKHR = (PFN_vkCreateXlibSurfaceKHR) gpa(instance, "vkCreateXlibSurfaceKHR");
+ pDisp->GetPhysicalDeviceXlibPresentationSupportKHR = (PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceXlibPresentationSupportKHR");
+#endif // VK_USE_PLATFORM_XLIB_KHR
+#ifdef VK_USE_PLATFORM_MIR_KHR
+ pDisp->CreateMirSurfaceKHR = (PFN_vkCreateMirSurfaceKHR) gpa(instance, "vkCreateMirSurfaceKHR");
+ pDisp->GetPhysicalDeviceMirPresentationSupportKHR = (PFN_vkGetPhysicalDeviceMirPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceMirPresentationSupportKHR");
+#endif // VK_USE_PLATFORM_MIR_KHR
+#ifdef VK_USE_PLATFORM_WAYLAND_KHR
+ pDisp->CreateWaylandSurfaceKHR = (PFN_vkCreateWaylandSurfaceKHR) gpa(instance, "vkCreateWaylandSurfaceKHR");
+ pDisp->GetPhysicalDeviceWaylandPresentationSupportKHR = (PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceWaylandPresentationSupportKHR");
+#endif // VK_USE_PLATFORM_WAYLAND_KHR
+#ifdef VK_USE_PLATFORM_ANDROID_KHR
+ pDisp->CreateAndroidSurfaceKHR = (PFN_vkCreateAndroidSurfaceKHR) gpa(instance, "vkCreateAndroidSurfaceKHR");
+#endif // VK_USE_PLATFORM_ANDROID_KHR
+
+ instanceExtMap[pDisp].wsi_enabled = false;
+ for (i = 0; i < pCreateInfo->enabledExtensionNameCount; i++) {
+ if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SURFACE_EXTENSION_NAME) == 0)
+ instanceExtMap[pDisp].wsi_enabled = true;
+
+ }
+}
+
+++ /dev/null
-/*
- *
- * Copyright (C) 2015 Valve Corporation
- * Copyright (C) 2015 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Author: Courtney Goeltzenleuchter <courtney@LunarG.com>
- * Author: Jon Ashburn <jon@lunarg.com>
- *
- */
-#pragma once
-
-#include "vulkan/vk_layer.h"
-
-/*
- * This file contains static functions for the generated layer Generic
- */
-
-#define LAYER_PROPS_ARRAY_SIZE 1
-static const VkLayerProperties layerProps[LAYER_PROPS_ARRAY_SIZE] = {
- {
- "VK_LAYER_LUNARG_api_dump",
- VK_API_VERSION, // specVersion
- VK_MAKE_VERSION(0, 1, 0), // implementationVersion
- "layer: APIDump",
- }
-};
-
-#define LAYER_DEV_PROPS_ARRAY_SIZE 1
-static const VkLayerProperties layerDevProps[LAYER_DEV_PROPS_ARRAY_SIZE] = {
- {
- "VK_LAYER_LUNARG_api_dump",
- VK_API_VERSION, // specVersion
- VK_MAKE_VERSION(0, 1, 0), // implementationVersion
- "layer: APIDump",
- }
-};
-
-struct devExts {
- bool wsi_enabled;
-};
-
-struct instExts {
- bool wsi_enabled;
-};
-
-static std::unordered_map<void *, struct devExts> deviceExtMap;
-static std::unordered_map<void *, struct instExts> instanceExtMap;
-
-static void createDeviceRegisterExtensions(const VkDeviceCreateInfo* pCreateInfo, VkDevice device)
-{
- uint32_t i;
- VkLayerDispatchTable *pDisp = device_dispatch_table(device);
- PFN_vkGetDeviceProcAddr gpa = pDisp->GetDeviceProcAddr;
- pDisp->CreateSwapchainKHR = (PFN_vkCreateSwapchainKHR) gpa(device, "vkCreateSwapchainKHR");
- pDisp->DestroySwapchainKHR = (PFN_vkDestroySwapchainKHR) gpa(device, "vkDestroySwapchainKHR");
- pDisp->GetSwapchainImagesKHR = (PFN_vkGetSwapchainImagesKHR) gpa(device, "vkGetSwapchainImagesKHR");
- pDisp->AcquireNextImageKHR = (PFN_vkAcquireNextImageKHR) gpa(device, "vkAcquireNextImageKHR");
- pDisp->QueuePresentKHR = (PFN_vkQueuePresentKHR) gpa(device, "vkQueuePresentKHR");
-
- deviceExtMap[pDisp].wsi_enabled = false;
- for (i = 0; i < pCreateInfo->enabledExtensionNameCount; i++) {
- if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SWAPCHAIN_EXTENSION_NAME) == 0)
- deviceExtMap[pDisp].wsi_enabled = true;
-
- }
-}
-
-static void createInstanceRegisterExtensions(const VkInstanceCreateInfo* pCreateInfo, VkInstance instance)
-{
- uint32_t i;
- VkLayerInstanceDispatchTable *pDisp = instance_dispatch_table(instance);
- PFN_vkGetInstanceProcAddr gpa = pDisp->GetInstanceProcAddr;
- pDisp->GetPhysicalDeviceSurfaceSupportKHR = (PFN_vkGetPhysicalDeviceSurfaceSupportKHR) gpa(instance, "vkGetPhysicalDeviceSurfaceSupportKHR");
- pDisp->GetPhysicalDeviceSurfaceCapabilitiesKHR = (PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR) gpa(instance, "vkGetPhysicalDeviceSurfaceCapabilitiesKHR");
- pDisp->GetPhysicalDeviceSurfaceFormatsKHR = (PFN_vkGetPhysicalDeviceSurfaceFormatsKHR) gpa(instance, "vkGetPhysicalDeviceSurfaceFormatsKHR");
- pDisp->GetPhysicalDeviceSurfacePresentModesKHR = (PFN_vkGetPhysicalDeviceSurfacePresentModesKHR) gpa(instance, "vkGetPhysicalDeviceSurfacePresentModesKHR");
-
-#if VK_USE_PLATFORM_WIN32_KHR
- pDisp->CreateWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR) gpa(instance, "vkCreateWin32SurfaceKHR");
- pDisp->GetPhysicalDeviceWin32PresentationSupportKHR = (PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceWin32PresentationSupportKHR");
-#endif // VK_USE_PLATFORM_WIN32_KHR
-#ifdef VK_USE_PLATFORM_XCB_KHR
- pDisp->CreateXcbSurfaceKHR = (PFN_vkCreateXcbSurfaceKHR) gpa(instance, "vkCreateXcbSurfaceKHR");
- pDisp->GetPhysicalDeviceXcbPresentationSupportKHR = (PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceXcbPresentationSupportKHR");
-#endif // VK_USE_PLATFORM_XCB_KHR
-#ifdef VK_USE_PLATFORM_XLIB_KHR
- pDisp->CreateXlibSurfaceKHR = (PFN_vkCreateXlibSurfaceKHR) gpa(instance, "vkCreateXlibSurfaceKHR");
- pDisp->GetPhysicalDeviceXlibPresentationSupportKHR = (PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceXlibPresentationSupportKHR");
-#endif // VK_USE_PLATFORM_XLIB_KHR
-#ifdef VK_USE_PLATFORM_MIR_KHR
- pDisp->CreateMirSurfaceKHR = (PFN_vkCreateMirSurfaceKHR) gpa(instance, "vkCreateMirSurfaceKHR");
- pDisp->GetPhysicalDeviceMirPresentationSupportKHR = (PFN_vkGetPhysicalDeviceMirPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceMirPresentationSupportKHR");
-#endif // VK_USE_PLATFORM_MIR_KHR
-#ifdef VK_USE_PLATFORM_WAYLAND_KHR
- pDisp->CreateWaylandSurfaceKHR = (PFN_vkCreateWaylandSurfaceKHR) gpa(instance, "vkCreateWaylandSurfaceKHR");
- pDisp->GetPhysicalDeviceWaylandPresentationSupportKHR = (PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceWaylandPresentationSupportKHR");
-#endif // VK_USE_PLATFORM_WAYLAND_KHR
-#ifdef VK_USE_PLATFORM_ANDROID_KHR
- pDisp->CreateAndroidSurfaceKHR = (PFN_vkCreateAndroidSurfaceKHR) gpa(instance, "vkCreateAndroidSurfaceKHR");
-#endif // VK_USE_PLATFORM_ANDROID_KHR
-
- instanceExtMap[pDisp].wsi_enabled = false;
- for (i = 0; i < pCreateInfo->enabledExtensionNameCount; i++) {
- if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SURFACE_EXTENSION_NAME) == 0)
- instanceExtMap[pDisp].wsi_enabled = true;
-
- }
-}
-
static const VkLayerProperties globalLayerProps[] = {
{
- "Basic",
+ "basic",
VK_API_VERSION, // specVersion
VK_MAKE_VERSION(0, 1, 0), // implementationVersion
- "layer: Basic",
+ "layer: basic",
}
};
"VK_LAYER_LUNARG_basic",
VK_API_VERSION,
VK_MAKE_VERSION(0, 1, 0),
- "Sample layer: Basic, implements vkLayerExtension1",
+ "Sample layer: basic, implements vkLayerExtension1",
}
};
"VK_LAYER_LUNARG_draw_state",
VK_API_VERSION,
VK_MAKE_VERSION(0, 1, 0),
- "Validation layer: DrawState",
+ "Validation layer: draw_state",
}
};
static const VkLayerProperties ds_device_layers[] = {
{
- "DrawState",
+ "draw_state",
VK_API_VERSION,
VK_MAKE_VERSION(0, 1, 0),
- "Validation layer: DrawState",
+ "Validation layer: draw_state",
}
};
#include "vulkan/vk_layer.h"
/*
- * This file contains static functions for the generated layer Generic
+ * This file contains static functions for the generated layer generic
*/
// The following is for logging error messages:
"VK_LAYER_LUNARG_generic",
VK_API_VERSION, // specVersion
VK_MAKE_VERSION(0, 1, 0), // implementationVersion
- "layer: Generic",
+ "layer: generic",
}
};
"VK_LAYER_LUNARG_generic",
VK_API_VERSION, // specVersion
VK_MAKE_VERSION(0, 1, 0), // implementationVersion
- "layer: Generic",
+ "layer: generic",
}
};
"VK_LAYER_LUNARG_image",
VK_API_VERSION,
VK_MAKE_VERSION(0, 1, 0),
- "Validation layer: Image",
+ "Validation layer: image",
}
};
--- /dev/null
+{
+ "file_format_version" : "1.0.0",
+ "layer" : {
+ "name": "VK_LAYER_LUNARG_api_dump",
+ "type": "GLOBAL",
+ "library_path": "./libVkLayer_api_dump.so",
+ "api_version": "0.210.0",
+ "implementation_version": "1",
+ "description": "LunarG debug layer"
+ }
+}
--- /dev/null
+{
+ "file_format_version" : "1.0.0",
+ "layer" : {
+ "name": "VK_LAYER_LUNARG_basic",
+ "type": "GLOBAL",
+ "library_path": "./libVkLayer_basic.so",
+ "api_version": "0.210.0",
+ "implementation_version": "1",
+ "description": "LunarG Sample Layer",
+ "device_extensions": [
+ {
+ "name": "VK_LUNARG_LayerExtension1",
+ "spec_version": "0",
+ "entrypoints": ["vkLayerExtension1"]
+ }
+ ]
+ }
+}
--- /dev/null
+{
+ "file_format_version" : "1.0.0",
+ "layer" : {
+ "name": "VK_LAYER_LUNARG_basic",
+ "type": "GLOBAL",
+ "library_path": "/etc/vulkan/implicit_layer.d/libVkLayer_basic.so",
+ "api_version": "0.210.0",
+ "implementation_version": "1",
+ "description": "LunarG Sample Layer",
+ "device_extensions": [
+ {
+ "name": "VK_LUNARG_LayerExtension1",
+ "spec_version": "0",
+ "entrypoints": ["vkLayerExtension1"]
+ }
+ ],
+ "disable_environment": { "DISABLE_LAYER_BASIC_1": "1"},
+ "enable_environment": { "ENABLE_LAYER_BASIC_1": "134"}
+ }
+}
--- /dev/null
+{
+ "file_format_version" : "1.0.0",
+ "layer" : {
+ "name": "VK_LAYER_LUNARG_device_limits",
+ "type": "GLOBAL",
+ "library_path": "./libVkLayer_device_limits.so",
+ "api_version": "0.210.0",
+ "implementation_version": "1",
+ "description": "LunarG Validation Layer",
+ "instance_extensions": [
+ {
+ "name": "VK_EXT_debug_report",
+ "spec_version": "2"
+ }
+ ]
+ }
+}
--- /dev/null
+{
+ "file_format_version" : "1.0.0",
+ "layer" : {
+ "name": "VK_LAYER_LUNARG_draw_state",
+ "type": "GLOBAL",
+ "library_path": "./libVkLayer_draw_state.so",
+ "api_version": "0.210.0",
+ "implementation_version": "1",
+ "description": "LunarG Validation Layer",
+ "instance_extensions": [
+ {
+ "name": "VK_EXT_debug_report",
+ "spec_version": "2"
+ }
+ ],
+ "device_extensions": [
+ {
+ "name": "VK_LUNARG_DEBUG_MARKER",
+ "spec_version": "0",
+ "entrypoints": ["vkCmdDbgMarkerBegin","vkCmdDbgMarkerEnd"]
+ }
+ ]
+ }
+}
--- /dev/null
+{
+ "file_format_version" : "1.0.0",
+ "layer" : {
+ "name": "VK_LAYER_LUNARG_generic",
+ "type": "GLOBAL",
+ "library_path": "./libVkLayer_generic.so",
+ "api_version": "0.210.0",
+ "implementation_version": "1",
+ "description": "LunarG Sample Layer"
+ }
+}
--- /dev/null
+{
+ "file_format_version" : "1.0.0",
+ "layer" : {
+ "name": "VK_LAYER_LUNARG_image",
+ "type": "GLOBAL",
+ "library_path": "./libVkLayer_image.so",
+ "api_version": "0.210.0",
+ "implementation_version": "1",
+ "description": "LunarG Validation Layer",
+ "instance_extensions": [
+ {
+ "name": "VK_EXT_debug_report",
+ "spec_version": "2"
+ }
+ ]
+ }
+}
--- /dev/null
+{
+ "file_format_version" : "1.0.0",
+ "layer" : {
+ "name": "VK_LAYER_LUNARG_mem_tracker",
+ "type": "GLOBAL",
+ "library_path": "./libVkLayer_mem_tracker.so",
+ "api_version": "0.210.0",
+ "implementation_version": "1",
+ "description": "LunarG Validation Layer",
+ "instance_extensions": [
+ {
+ "name": "VK_EXT_debug_report",
+ "spec_version": "2"
+ }
+ ]
+ }
+}
--- /dev/null
+{
+ "file_format_version" : "1.0.0",
+ "layer" : {
+ "name": "VK_LAYER_LUNARG_multi1",
+ "type": "DEVICE",
+ "library_path": "./libVkLayer_multi.so",
+ "api_version": "0.210.0",
+ "implementation_version": "1",
+ "description": "LunarG Sample multiple layer per library",
+ "functions" : {
+ "vkGetDeviceProcAddr" : "multi1GetDeviceProcAddr"
+ }
+ },
+ "layer" : {
+ "name": "VK_LUNARG_multi2",
+ "type": "INSTANCE",
+ "library_path": "./libVkLayer_multi.so",
+ "api_version": "0.210.0",
+ "implementation_version": "1",
+ "description": "LunarG Sample multiple layer per library",
+ "functions" : {
+ "vkGetInstanceProcAddr" : "multi2GetInstanceProcAddr"
+ }
+ }
+}
--- /dev/null
+{
+ "file_format_version" : "1.0.0",
+ "layer" : {
+ "name": "VK_LAYER_LUNARG_object_tracker",
+ "type": "GLOBAL",
+ "library_path": "./libVkLayer_object_tracker.so",
+ "api_version": "0.210.0",
+ "implementation_version": "1",
+ "description": "LunarG Validation Layer",
+ "instance_extensions": [
+ {
+ "name": "VK_EXT_debug_report",
+ "spec_version": "2"
+ }
+ ]
+ }
+}
--- /dev/null
+{
+ "file_format_version" : "1.0.0",
+ "layer" : {
+ "name": "VK_LAYER_LUNARG_param_checker",
+ "type": "GLOBAL",
+ "library_path": "./libVkLayer_param_checker.so",
+ "api_version": "0.210.0",
+ "implementation_version": "1",
+ "description": "LunarG Validation Layer",
+ "instance_extensions": [
+ {
+ "name": "VK_EXT_debug_report",
+ "spec_version": "2"
+ }
+ ]
+ }
+}
--- /dev/null
+{
+ "file_format_version" : "1.0.0",
+ "layer" : {
+ "name": "VK_LAYER_LUNARG_screenshot",
+ "type": "GLOBAL",
+ "library_path": "./libVkLayer_screenshot.so",
+ "api_version": "0.210.0",
+ "implementation_version": "1",
+ "description": "LunarG image capture layer"
+ }
+}
--- /dev/null
+{
+ "file_format_version" : "1.0.0",
+ "layer" : {
+ "name": "VK_LAYER_LUNARG_swapchain",
+ "type": "GLOBAL",
+ "library_path": "./libVkLayer_swapchain.so",
+ "api_version": "0.210.0",
+ "implementation_version": "1",
+ "description": "LunarG Validation Layer",
+ "instance_extensions": [
+ {
+ "name": "VK_EXT_debug_report",
+ "spec_version": "2"
+ }
+ ]
+ }
+}
--- /dev/null
+{
+ "file_format_version" : "1.0.0",
+ "layer" : {
+ "name": "VK_LAYER_LUNARG_threading",
+ "type": "GLOBAL",
+ "library_path": "./libVkLayer_threading.so",
+ "api_version": "0.210.0",
+ "implementation_version": "1",
+ "description": "LunarG Validation Layer",
+ "instance_extensions": [
+ {
+ "name": "VK_EXT_debug_report",
+ "spec_version": "2"
+ }
+ ]
+ }
+}
+++ /dev/null
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_APIDump",
- "type": "GLOBAL",
- "library_path": "./libVKLayerAPIDump.so",
- "api_version": "0.210.0",
- "implementation_version": "1",
- "description": "LunarG debug layer"
- }
-}
+++ /dev/null
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_Basic",
- "type": "GLOBAL",
- "library_path": "./libVKLayerBasic.so",
- "api_version": "0.210.0",
- "implementation_version": "1",
- "description": "LunarG Sample Layer",
- "device_extensions": [
- {
- "name": "VK_LUNARG_LayerExtension1",
- "spec_version": "0",
- "entrypoints": ["vkLayerExtension1"]
- }
- ]
- }
-}
+++ /dev/null
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_Basic",
- "type": "GLOBAL",
- "library_path": "/etc/vulkan/implicit_layer.d/libVKLayerBasic.so",
- "api_version": "0.210.0",
- "implementation_version": "1",
- "description": "LunarG Sample Layer",
- "device_extensions": [
- {
- "name": "VK_LUNARG_LayerExtension1",
- "spec_version": "0",
- "entrypoints": ["vkLayerExtension1"]
- }
- ],
- "disable_environment": { "DISABLE_LAYER_BASIC_1": "1"},
- "enable_environment": { "ENABLE_LAYER_BASIC_1": "134"}
- }
-}
+++ /dev/null
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_DeviceLimits",
- "type": "GLOBAL",
- "library_path": "./libVKLayerDeviceLimits.so",
- "api_version": "0.210.0",
- "implementation_version": "1",
- "description": "LunarG Validation Layer",
- "instance_extensions": [
- {
- "name": "VK_EXT_debug_report",
- "spec_version": "2"
- }
- ]
- }
-}
+++ /dev/null
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_DrawState",
- "type": "GLOBAL",
- "library_path": "./libVKLayerDrawState.so",
- "api_version": "0.210.0",
- "implementation_version": "1",
- "description": "LunarG Validation Layer",
- "instance_extensions": [
- {
- "name": "VK_EXT_debug_report",
- "spec_version": "2"
- }
- ],
- "device_extensions": [
- {
- "name": "VK_LUNARG_DEBUG_MARKER",
- "spec_version": "0",
- "entrypoints": ["vkCmdDbgMarkerBegin","vkCmdDbgMarkerEnd"]
- }
- ]
- }
-}
+++ /dev/null
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_Generic",
- "type": "GLOBAL",
- "library_path": "./libVKLayerGeneric.so",
- "api_version": "0.210.0",
- "implementation_version": "1",
- "description": "LunarG Sample Layer"
- }
-}
+++ /dev/null
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_Image",
- "type": "GLOBAL",
- "library_path": "./libVKLayerImage.so",
- "api_version": "0.210.0",
- "implementation_version": "1",
- "description": "LunarG Validation Layer",
- "instance_extensions": [
- {
- "name": "VK_EXT_debug_report",
- "spec_version": "2"
- }
- ]
- }
-}
+++ /dev/null
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_MemTracker",
- "type": "GLOBAL",
- "library_path": "./libVKLayerMemTracker.so",
- "api_version": "0.210.0",
- "implementation_version": "1",
- "description": "LunarG Validation Layer",
- "instance_extensions": [
- {
- "name": "VK_EXT_debug_report",
- "spec_version": "2"
- }
- ]
- }
-}
+++ /dev/null
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_multi1",
- "type": "DEVICE",
- "library_path": "./libVKLayerMulti.so",
- "api_version": "0.210.0",
- "implementation_version": "1",
- "description": "LunarG Sample multiple layer per library",
- "functions" : {
- "vkGetDeviceProcAddr" : "multi1GetDeviceProcAddr"
- }
- },
- "layer" : {
- "name": "VK_LUNARG_multi2",
- "type": "INSTANCE",
- "library_path": "./libVKLayerMulti.so",
- "api_version": "0.210.0",
- "implementation_version": "1",
- "description": "LunarG Sample multiple layer per library",
- "functions" : {
- "vkGetInstanceProcAddr" : "multi2GetInstanceProcAddr"
- }
- }
-}
+++ /dev/null
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_ObjectTracker",
- "type": "GLOBAL",
- "library_path": "./libVKLayerObjectTracker.so",
- "api_version": "0.210.0",
- "implementation_version": "1",
- "description": "LunarG Validation Layer",
- "instance_extensions": [
- {
- "name": "VK_EXT_debug_report",
- "spec_version": "2"
- }
- ]
- }
-}
+++ /dev/null
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_ParamChecker",
- "type": "GLOBAL",
- "library_path": "./libVKLayerParamChecker.so",
- "api_version": "0.210.0",
- "implementation_version": "1",
- "description": "LunarG Validation Layer",
- "instance_extensions": [
- {
- "name": "VK_EXT_debug_report",
- "spec_version": "2"
- }
- ]
- }
-}
+++ /dev/null
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_ScreenShot",
- "type": "GLOBAL",
- "library_path": "./libVKLayerScreenShot.so",
- "api_version": "0.210.0",
- "implementation_version": "1",
- "description": "LunarG image capture layer"
- }
-}
+++ /dev/null
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_Swapchain",
- "type": "GLOBAL",
- "library_path": "./libVKLayerSwapchain.so",
- "api_version": "0.210.0",
- "implementation_version": "1",
- "description": "LunarG Validation Layer",
- "instance_extensions": [
- {
- "name": "VK_EXT_debug_report",
- "spec_version": "2"
- }
- ]
- }
-}
+++ /dev/null
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_Threading",
- "type": "GLOBAL",
- "library_path": "./libVKLayerThreading.so",
- "api_version": "0.210.0",
- "implementation_version": "1",
- "description": "LunarG Validation Layer",
- "instance_extensions": [
- {
- "name": "VK_EXT_debug_report",
- "spec_version": "2"
- }
- ]
- }
-}
"VK_LAYER_LUNARG_mem_tracker",
VK_API_VERSION,
VK_MAKE_VERSION(0, 1, 0),
- "Validation layer: MemTracker",
+ "Validation layer: mem_tracker",
}
};
+++ /dev/null
-/*
- *
- * Copyright (C) 2015 Valve Corporation
- * Copyright (C) 2015 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Author: Jon Ashburn <jon@lunarg.com>
- * Author: Mark Lobodzinski <mark@lunarg.com>
- * Author: Tobin Ehlis <tobin@lunarg.com>
- */
-
-#include "vulkan/vk_layer.h"
-#include "vk_layer_extension_utils.h"
-#include "vk_enum_string_helper.h"
-
-// Object Tracker ERROR codes
-typedef enum _OBJECT_TRACK_ERROR
-{
- OBJTRACK_NONE, // Used for INFO & other non-error messages
- OBJTRACK_UNKNOWN_OBJECT, // Updating uses of object that's not in global object list
- OBJTRACK_INTERNAL_ERROR, // Bug with data tracking within the layer
- OBJTRACK_DESTROY_OBJECT_FAILED, // Couldn't find object to be destroyed
- OBJTRACK_OBJECT_LEAK, // OBJECT was not correctly freed/destroyed
- OBJTRACK_OBJCOUNT_MAX_EXCEEDED, // Request for Object data in excess of max obj count
- OBJTRACK_INVALID_OBJECT, // Object used that has never been created
- OBJTRACK_DESCRIPTOR_POOL_MISMATCH, // Descriptor Pools specified incorrectly
- OBJTRACK_COMMAND_POOL_MISMATCH, // Command Pools specified incorrectly
-} OBJECT_TRACK_ERROR;
-
-// Object Status -- used to track state of individual objects
-typedef VkFlags ObjectStatusFlags;
-typedef enum _ObjectStatusFlagBits
-{
- OBJSTATUS_NONE = 0x00000000, // No status is set
- OBJSTATUS_FENCE_IS_SUBMITTED = 0x00000001, // Fence has been submitted
- OBJSTATUS_VIEWPORT_BOUND = 0x00000002, // Viewport state object has been bound
- OBJSTATUS_RASTER_BOUND = 0x00000004, // Viewport state object has been bound
- OBJSTATUS_COLOR_BLEND_BOUND = 0x00000008, // Viewport state object has been bound
- OBJSTATUS_DEPTH_STENCIL_BOUND = 0x00000010, // Viewport state object has been bound
- OBJSTATUS_GPU_MEM_MAPPED = 0x00000020, // Memory object is currently mapped
-} ObjectStatusFlagBits;
-
-typedef struct _OBJTRACK_NODE {
- uint64_t vkObj; // Object handle
- VkDebugReportObjectTypeEXT objType; // Object type identifier
- ObjectStatusFlags status; // Object state
- uint64_t parentObj; // Parent object
-} OBJTRACK_NODE;
-
-// prototype for extension functions
-uint64_t objTrackGetObjectCount(VkDevice device);
-uint64_t objTrackGetObjectsOfTypeCount(VkDevice, VkDebugReportObjectTypeEXT type);
-
-// Func ptr typedefs
-typedef uint64_t (*OBJ_TRACK_GET_OBJECT_COUNT)(VkDevice);
-typedef uint64_t (*OBJ_TRACK_GET_OBJECTS_OF_TYPE_COUNT)(VkDevice, VkDebugReportObjectTypeEXT);
-
-struct layer_data {
- debug_report_data *report_data;
- //TODO: put instance data here
- VkDebugReportCallbackEXT logging_callback;
- bool wsi_enabled;
- bool objtrack_extensions_enabled;
-
- layer_data() :
- report_data(nullptr),
- logging_callback(VK_NULL_HANDLE),
- wsi_enabled(false),
- objtrack_extensions_enabled(false)
- {};
-};
-
-struct instExts {
- bool wsi_enabled;
-};
-
-static std::unordered_map<void *, struct instExts> instanceExtMap;
-static std::unordered_map<void*, layer_data *> layer_data_map;
-static device_table_map ObjectTracker_device_table_map;
-static instance_table_map ObjectTracker_instance_table_map;
-
-// We need additionally validate image usage using a separate map
-// of swapchain-created images
-static unordered_map<uint64_t, OBJTRACK_NODE*> swapchainImageMap;
-
-static long long unsigned int object_track_index = 0;
-static int objLockInitialized = 0;
-static loader_platform_thread_mutex objLock;
-
-// Objects stored in a global map w/ struct containing basic info
-// unordered_map<const void*, OBJTRACK_NODE*> objMap;
-
-#define NUM_OBJECT_TYPES (VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_EXT+1)
-
-static uint64_t numObjs[NUM_OBJECT_TYPES] = {0};
-static uint64_t numTotalObjs = 0;
-static VkQueueFamilyProperties *queueInfo = NULL;
-static uint32_t queueCount = 0;
-
-template layer_data *get_my_data_ptr<layer_data>(
- void *data_key, std::unordered_map<void *, layer_data *> &data_map);
-
-static inline const char* string_VkDebugReportObjectTypeEXT(VkDebugReportObjectTypeEXT input_value)
-{
- switch ((VkDebugReportObjectTypeEXT)input_value)
- {
- case VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT:
- return "VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT";
- case VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT:
- return "VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT";
- case VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT:
- return "VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT";
- case VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT:
- return "VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT";
- case VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT:
- return "VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT";
- case VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT:
- return "VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT";
- case VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT_EXT:
- return "VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT_EXT";
- case VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT:
- return "VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT";
- case VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT:
- return "VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT";
- case VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT:
- return "VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT";
- case VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT:
- return "VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT";
- case VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT:
- return "VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT";
- case VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT:
- return "VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT";
- case VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT:
- return "VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT";
- case VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT:
- return "VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT";
- case VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT:
- return "VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT";
- case VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT:
- return "VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT";
- case VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_LAYOUT_EXT:
- return "VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_LAYOUT_EXT";
- case VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_CACHE_EXT:
- return "VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_CACHE_EXT";
- case VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT:
- return "VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT";
- case VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT:
- return "VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT";
- case VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT:
- return "VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT";
- case VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT:
- return "VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT";
- case VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT:
- return "VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT";
- case VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT:
- return "VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT";
- case VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT:
- return "VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT";
- default:
- return "Unhandled VkObjectType";
- }
-}
-
-//
-// Internal Object Tracker Functions
-//
-
-static void createDeviceRegisterExtensions(const VkDeviceCreateInfo* pCreateInfo, VkDevice device)
-{
- layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
- VkLayerDispatchTable *pDisp = get_dispatch_table(ObjectTracker_device_table_map, device);
- PFN_vkGetDeviceProcAddr gpa = pDisp->GetDeviceProcAddr;
- pDisp->CreateSwapchainKHR = (PFN_vkCreateSwapchainKHR) gpa(device, "vkCreateSwapchainKHR");
- pDisp->DestroySwapchainKHR = (PFN_vkDestroySwapchainKHR) gpa(device, "vkDestroySwapchainKHR");
- pDisp->GetSwapchainImagesKHR = (PFN_vkGetSwapchainImagesKHR) gpa(device, "vkGetSwapchainImagesKHR");
- pDisp->AcquireNextImageKHR = (PFN_vkAcquireNextImageKHR) gpa(device, "vkAcquireNextImageKHR");
- pDisp->QueuePresentKHR = (PFN_vkQueuePresentKHR) gpa(device, "vkQueuePresentKHR");
- my_device_data->wsi_enabled = false;
- for (uint32_t i = 0; i < pCreateInfo->enabledExtensionNameCount; i++) {
- if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SWAPCHAIN_EXTENSION_NAME) == 0)
- my_device_data->wsi_enabled = true;
-
- if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], "OBJTRACK_EXTENSIONS") == 0)
- my_device_data->objtrack_extensions_enabled = true;
- }
-}
-
-static void createInstanceRegisterExtensions(const VkInstanceCreateInfo* pCreateInfo, VkInstance instance)
-{
- uint32_t i;
- VkLayerInstanceDispatchTable *pDisp = get_dispatch_table(ObjectTracker_instance_table_map, instance);
- PFN_vkGetInstanceProcAddr gpa = pDisp->GetInstanceProcAddr;
- pDisp->GetPhysicalDeviceSurfaceSupportKHR = (PFN_vkGetPhysicalDeviceSurfaceSupportKHR) gpa(instance, "vkGetPhysicalDeviceSurfaceSupportKHR");
- pDisp->GetPhysicalDeviceSurfaceCapabilitiesKHR = (PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR) gpa(instance, "vkGetPhysicalDeviceSurfaceCapabilitiesKHR");
- pDisp->GetPhysicalDeviceSurfaceFormatsKHR = (PFN_vkGetPhysicalDeviceSurfaceFormatsKHR) gpa(instance, "vkGetPhysicalDeviceSurfaceFormatsKHR");
- pDisp->GetPhysicalDeviceSurfacePresentModesKHR = (PFN_vkGetPhysicalDeviceSurfacePresentModesKHR) gpa(instance, "vkGetPhysicalDeviceSurfacePresentModesKHR");
-
-#if VK_USE_PLATFORM_WIN32_KHR
- pDisp->CreateWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR) gpa(instance, "vkCreateWin32SurfaceKHR");
- pDisp->GetPhysicalDeviceWin32PresentationSupportKHR = (PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceWin32PresentationSupportKHR");
-#endif // VK_USE_PLATFORM_WIN32_KHR
-#ifdef VK_USE_PLATFORM_XCB_KHR
- pDisp->CreateXcbSurfaceKHR = (PFN_vkCreateXcbSurfaceKHR) gpa(instance, "vkCreateXcbSurfaceKHR");
- pDisp->GetPhysicalDeviceXcbPresentationSupportKHR = (PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceXcbPresentationSupportKHR");
-#endif // VK_USE_PLATFORM_XCB_KHR
-#ifdef VK_USE_PLATFORM_XLIB_KHR
- pDisp->CreateXlibSurfaceKHR = (PFN_vkCreateXlibSurfaceKHR) gpa(instance, "vkCreateXlibSurfaceKHR");
- pDisp->GetPhysicalDeviceXlibPresentationSupportKHR = (PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceXlibPresentationSupportKHR");
-#endif // VK_USE_PLATFORM_XLIB_KHR
-#ifdef VK_USE_PLATFORM_MIR_KHR
- pDisp->CreateMirSurfaceKHR = (PFN_vkCreateMirSurfaceKHR) gpa(instance, "vkCreateMirSurfaceKHR");
- pDisp->GetPhysicalDeviceMirPresentationSupportKHR = (PFN_vkGetPhysicalDeviceMirPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceMirPresentationSupportKHR");
-#endif // VK_USE_PLATFORM_MIR_KHR
-#ifdef VK_USE_PLATFORM_WAYLAND_KHR
- pDisp->CreateWaylandSurfaceKHR = (PFN_vkCreateWaylandSurfaceKHR) gpa(instance, "vkCreateWaylandSurfaceKHR");
- pDisp->GetPhysicalDeviceWaylandPresentationSupportKHR = (PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceWaylandPresentationSupportKHR");
-#endif // VK_USE_PLATFORM_WAYLAND_KHR
-#ifdef VK_USE_PLATFORM_ANDROID_KHR
- pDisp->CreateAndroidSurfaceKHR = (PFN_vkCreateAndroidSurfaceKHR) gpa(instance, "vkCreateAndroidSurfaceKHR");
-#endif // VK_USE_PLATFORM_ANDROID_KHR
-
- instanceExtMap[pDisp].wsi_enabled = false;
- for (i = 0; i < pCreateInfo->enabledExtensionNameCount; i++) {
- if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SURFACE_EXTENSION_NAME) == 0)
- instanceExtMap[pDisp].wsi_enabled = true;
-
- }
-}
-
-// Indicate device or instance dispatch table type
-typedef enum _DispTableType
-{
- DISP_TBL_TYPE_INSTANCE,
- DISP_TBL_TYPE_DEVICE,
-} DispTableType;
-
-debug_report_data *mdd(const void* object)
-{
- dispatch_key key = get_dispatch_key(object);
- layer_data *my_data = get_my_data_ptr(key, layer_data_map);
- return my_data->report_data;
-}
-
-debug_report_data *mid(VkInstance object)
-{
- dispatch_key key = get_dispatch_key(object);
- layer_data *my_data = get_my_data_ptr(key, layer_data_map);
- return my_data->report_data;
-}
-
-// For each Queue's doubly linked-list of mem refs
-typedef struct _OT_MEM_INFO {
- VkDeviceMemory mem;
- struct _OT_MEM_INFO *pNextMI;
- struct _OT_MEM_INFO *pPrevMI;
-
-} OT_MEM_INFO;
-
-// Track Queue information
-typedef struct _OT_QUEUE_INFO {
- OT_MEM_INFO *pMemRefList;
- struct _OT_QUEUE_INFO *pNextQI;
- uint32_t queueNodeIndex;
- VkQueue queue;
- uint32_t refCount;
-} OT_QUEUE_INFO;
-
-// Global list of QueueInfo structures, one per queue
-static OT_QUEUE_INFO *g_pQueueInfo = NULL;
-
-// Convert an object type enum to an object type array index
-static uint32_t
-objTypeToIndex(
- uint32_t objType)
-{
- uint32_t index = objType;
- return index;
-}
-
-// Add new queue to head of global queue list
-static void
-addQueueInfo(
- uint32_t queueNodeIndex,
- VkQueue queue)
-{
- OT_QUEUE_INFO *pQueueInfo = new OT_QUEUE_INFO;
-
- if (pQueueInfo != NULL) {
- memset(pQueueInfo, 0, sizeof(OT_QUEUE_INFO));
- pQueueInfo->queue = queue;
- pQueueInfo->queueNodeIndex = queueNodeIndex;
- pQueueInfo->pNextQI = g_pQueueInfo;
- g_pQueueInfo = pQueueInfo;
- }
- else {
- log_msg(mdd(queue), VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT, reinterpret_cast<uint64_t>(queue), 0, OBJTRACK_INTERNAL_ERROR, "OBJTRACK",
- "ERROR: VK_ERROR_OUT_OF_HOST_MEMORY -- could not allocate memory for Queue Information");
- }
-}
-
-// Destroy memRef lists and free all memory
-static void
-destroyQueueMemRefLists(void)
-{
- OT_QUEUE_INFO *pQueueInfo = g_pQueueInfo;
- OT_QUEUE_INFO *pDelQueueInfo = NULL;
- while (pQueueInfo != NULL) {
- OT_MEM_INFO *pMemInfo = pQueueInfo->pMemRefList;
- while (pMemInfo != NULL) {
- OT_MEM_INFO *pDelMemInfo = pMemInfo;
- pMemInfo = pMemInfo->pNextMI;
- delete pDelMemInfo;
- }
- pDelQueueInfo = pQueueInfo;
- pQueueInfo = pQueueInfo->pNextQI;
- delete pDelQueueInfo;
- }
- g_pQueueInfo = pQueueInfo;
-}
-
-static void
-setGpuQueueInfoState(
- uint32_t count,
- void *pData)
-{
- queueCount = count;
- queueInfo = (VkQueueFamilyProperties*)realloc((void*)queueInfo, count * sizeof(VkQueueFamilyProperties));
- if (queueInfo != NULL) {
- memcpy(queueInfo, pData, count * sizeof(VkQueueFamilyProperties));
- }
-}
-
-// Check Queue type flags for selected queue operations
-static void
-validateQueueFlags(
- VkQueue queue,
- const char *function)
-{
- OT_QUEUE_INFO *pQueueInfo = g_pQueueInfo;
- while ((pQueueInfo != NULL) && (pQueueInfo->queue != queue)) {
- pQueueInfo = pQueueInfo->pNextQI;
- }
- if (pQueueInfo != NULL) {
- if ((queueInfo != NULL) && (queueInfo[pQueueInfo->queueNodeIndex].queueFlags & VK_QUEUE_SPARSE_BINDING_BIT) == 0) {
- log_msg(mdd(queue), VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT, reinterpret_cast<uint64_t>(queue), 0, OBJTRACK_UNKNOWN_OBJECT, "OBJTRACK",
- "Attempting %s on a non-memory-management capable queue -- VK_QUEUE_SPARSE_BINDING_BIT not set", function);
- } else {
- log_msg(mdd(queue), VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT, reinterpret_cast<uint64_t>(queue), 0, OBJTRACK_UNKNOWN_OBJECT, "OBJTRACK",
- "Attempting %s on a possibly non-memory-management capable queue -- VK_QUEUE_SPARSE_BINDING_BIT not known", function);
- }
- }
-}
-
-/* TODO: Port to new type safety */
-#if 0
-// Check object status for selected flag state
-static VkBool32
-validate_status(
- VkObject dispatchable_object,
- VkObject vkObj,
- VkObjectType objType,
- ObjectStatusFlags status_mask,
- ObjectStatusFlags status_flag,
- VkFlags msg_flags,
- OBJECT_TRACK_ERROR error_code,
- const char *fail_msg)
-{
- if (objMap.find(vkObj) != objMap.end()) {
- OBJTRACK_NODE* pNode = objMap[vkObj];
- if ((pNode->status & status_mask) != status_flag) {
- char str[1024];
- log_msg(mdd(dispatchable_object), msg_flags, pNode->objType, vkObj, 0, OBJTRACK_UNKNOWN_OBJECT, "OBJTRACK",
- "OBJECT VALIDATION WARNING: %s object 0x%" PRIxLEAST64 ": %s", string_VkObjectType(objType),
- reinterpret_cast<uint64_t>(vkObj), fail_msg);
- return VK_FALSE;
- }
- return VK_TRUE;
- }
- else {
- // If we do not find it print an error
- log_msg(mdd(dispatchable_object), msg_flags, (VkObjectType) 0, vkObj, 0, OBJTRACK_UNKNOWN_OBJECT, "OBJTRACK",
- "Unable to obtain status for non-existent object 0x%" PRIxLEAST64 " of %s type",
- reinterpret_cast<uint64_t>(vkObj), string_VkObjectType(objType));
- return VK_FALSE;
- }
-}
-#endif
-
-#include "vk_dispatch_table_helper.h"
-static void
-initObjectTracker(
- layer_data *my_data,
- const VkAllocationCallbacks *pAllocator)
-{
- uint32_t report_flags = 0;
- uint32_t debug_action = 0;
- FILE *log_output = NULL;
- const char *option_str;
- // initialize ObjectTracker options
- report_flags = getLayerOptionFlags("ObjectTrackerReportFlags", 0);
- getLayerOptionEnum("ObjectTrackerDebugAction", (uint32_t *) &debug_action);
-
- if (debug_action & VK_DBG_LAYER_ACTION_LOG_MSG)
- {
- option_str = getLayerOption("ObjectTrackerLogFilename");
- log_output = getLayerLogOutput(option_str, "ObjectTracker");
- VkDebugReportCallbackCreateInfoEXT dbgInfo;
- memset(&dbgInfo, 0, sizeof(dbgInfo));
- dbgInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT;
- dbgInfo.pfnCallback = log_callback;
- dbgInfo.pUserData = log_output;
- dbgInfo.flags = report_flags;
- layer_create_msg_callback(my_data->report_data, &dbgInfo, pAllocator, &my_data->logging_callback);
- }
-
- if (!objLockInitialized)
- {
- // TODO/TBD: Need to delete this mutex sometime. How??? One
- // suggestion is to call this during vkCreateInstance(), and then we
- // can clean it up during vkDestroyInstance(). However, that requires
- // that the layer have per-instance locks. We need to come back and
- // address this soon.
- loader_platform_thread_create_mutex(&objLock);
- objLockInitialized = 1;
- }
-}
-
-//
-// Forward declares of generated routines
-//
-
-static void create_physical_device(VkInstance dispatchable_object, VkPhysicalDevice vkObj, VkDebugReportObjectTypeEXT objType);
-static void create_instance(VkInstance dispatchable_object, VkInstance object, VkDebugReportObjectTypeEXT objType);
-static void create_device(VkDevice dispatchable_object, VkDevice object, VkDebugReportObjectTypeEXT objType);
-static void create_queue(VkDevice dispatchable_object, VkQueue vkObj, VkDebugReportObjectTypeEXT objType);
-static VkBool32 validate_image(VkQueue dispatchable_object, VkImage object);
-static VkBool32 validate_image(VkCommandBuffer dispatchable_object, VkImage object);
-static VkBool32 validate_command_buffer(VkQueue dispatchable_object, VkCommandBuffer object);
-static VkBool32 validate_descriptor_set(VkCommandBuffer dispatchable_object, VkDescriptorSet object);
-static VkBool32 validate_instance(VkInstance dispatchable_object, VkInstance object);
-static VkBool32 validate_device(VkDevice dispatchable_object, VkDevice object);
-static VkBool32 validate_descriptor_pool(VkDevice dispatchable_object, VkDescriptorPool object);
-static VkBool32 validate_descriptor_set_layout(VkDevice dispatchable_object, VkDescriptorSetLayout object);
-static VkBool32 validate_command_pool(VkDevice dispatchable_object, VkCommandPool object);
-static void destroy_command_pool(VkDevice dispatchable_object, VkCommandPool object);
-static void destroy_command_buffer(VkCommandBuffer dispatchable_object, VkCommandBuffer object);
-static void destroy_descriptor_pool(VkDevice dispatchable_object, VkDescriptorPool object);
-static void destroy_descriptor_set(VkDevice dispatchable_object, VkDescriptorSet object);
-static void destroy_instance(VkInstance dispatchable_object, VkInstance object);
-static void destroy_device_memory(VkDevice dispatchable_object, VkDeviceMemory object);
-static VkBool32 set_device_memory_status(VkDevice dispatchable_object, VkDeviceMemory object, VkDebugReportObjectTypeEXT objType, ObjectStatusFlags status_flag);
-static VkBool32 reset_device_memory_status(VkDevice dispatchable_object, VkDeviceMemory object, VkDebugReportObjectTypeEXT objType, ObjectStatusFlags status_flag);
-#if 0
-static VkBool32 validate_status(VkDevice dispatchable_object, VkFence object, VkDebugReportObjectTypeEXT objType,
- ObjectStatusFlags status_mask, ObjectStatusFlags status_flag, VkFlags msg_flags, OBJECT_TRACK_ERROR error_code,
- const char *fail_msg);
-#endif
-extern unordered_map<uint64_t, OBJTRACK_NODE*> VkPhysicalDeviceMap;
-extern unordered_map<uint64_t, OBJTRACK_NODE*> VkImageMap;
-extern unordered_map<uint64_t, OBJTRACK_NODE*> VkQueueMap;
-extern unordered_map<uint64_t, OBJTRACK_NODE*> VkDescriptorSetMap;
-extern unordered_map<uint64_t, OBJTRACK_NODE*> VkBufferMap;
-extern unordered_map<uint64_t, OBJTRACK_NODE*> VkFenceMap;
-extern unordered_map<uint64_t, OBJTRACK_NODE*> VkSemaphoreMap;
-extern unordered_map<uint64_t, OBJTRACK_NODE*> VkCommandPoolMap;
-extern unordered_map<uint64_t, OBJTRACK_NODE*> VkCommandBufferMap;
-extern unordered_map<uint64_t, OBJTRACK_NODE*> VkSwapchainKHRMap;
-
-static VkBool32 validate_image(VkQueue dispatchable_object, VkImage object)
-{
- if ((VkImageMap.find(reinterpret_cast<uint64_t>(object)) == VkImageMap.end()) &&
- (swapchainImageMap.find(reinterpret_cast<uint64_t>(object)) == swapchainImageMap.end())) {
- return log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT) 0, (uint64_t) object, 0, OBJTRACK_INVALID_OBJECT, "OBJTRACK",
- "Invalid VkImage Object %" PRIu64, reinterpret_cast<uint64_t>(object));
- }
- return VK_FALSE;
-}
-
-static VkBool32 validate_image(VkCommandBuffer dispatchable_object, VkImage object)
-{
- if ((VkImageMap.find(reinterpret_cast<uint64_t>(object)) == VkImageMap.end()) &&
- (swapchainImageMap.find(reinterpret_cast<uint64_t>(object)) == swapchainImageMap.end())) {
- return log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT) 0, (uint64_t) object, 0, OBJTRACK_INVALID_OBJECT, "OBJTRACK",
- "Invalid VkImage Object %" PRIu64, reinterpret_cast<uint64_t>(object));
- }
- return VK_FALSE;
-}
-
-static VkBool32 validate_command_buffer(VkQueue dispatchable_object, VkCommandBuffer object)
-{
- if (VkCommandBufferMap.find(reinterpret_cast<uint64_t>(object)) == VkCommandBufferMap.end()) {
- return log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT) 0, reinterpret_cast<uint64_t>(object), 0, OBJTRACK_INVALID_OBJECT, "OBJTRACK",
- "Invalid VkCommandBuffer Object %" PRIu64, reinterpret_cast<uint64_t>(object));
- }
- return VK_FALSE;
-}
-
-static VkBool32 validate_descriptor_set(VkCommandBuffer dispatchable_object, VkDescriptorSet object)
-{
- if (VkDescriptorSetMap.find(reinterpret_cast<uint64_t>(object)) == VkDescriptorSetMap.end()) {
- return log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT) 0, (uint64_t) object, 0, OBJTRACK_INVALID_OBJECT, "OBJTRACK",
- "Invalid VkDescriptorSet Object %" PRIu64, reinterpret_cast<uint64_t>(object));
- }
- return VK_FALSE;
-}
-
-static VkBool32 validate_buffer(VkQueue dispatchable_object, VkBuffer object)
-{
- if (VkBufferMap.find(reinterpret_cast<uint64_t>(object)) != VkBufferMap.end()) {
- return log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT) 0, (uint64_t) object, 0, OBJTRACK_INVALID_OBJECT, "OBJTRACK",
- "Invalid VkBuffer Object %" PRIu64, reinterpret_cast<uint64_t>(object));
- }
- return VK_FALSE;
-}
-
-static VkBool32 set_status(VkQueue dispatchable_object, VkFence object, VkDebugReportObjectTypeEXT objType, ObjectStatusFlags status_flag)
-{
- VkBool32 skipCall = VK_FALSE;
- if (object != VK_NULL_HANDLE) {
- if (VkFenceMap.find(reinterpret_cast<uint64_t>(object)) != VkFenceMap.end()) {
- OBJTRACK_NODE* pNode = VkFenceMap[reinterpret_cast<uint64_t>(object)];
- pNode->status |= status_flag;
- }
- else {
- // If we do not find it print an error
- skipCall |= log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT) 0, (uint64_t) object, 0, OBJTRACK_NONE, "OBJTRACK",
- "Unable to set status for non-existent object 0x%" PRIxLEAST64 " of %s type",
- reinterpret_cast<uint64_t>(object), string_VkDebugReportObjectTypeEXT(objType));
- }
- }
- return skipCall;
-}
-
-static VkBool32 validate_semaphore(VkQueue dispatchable_object, VkSemaphore object)
-{
- if (VkSemaphoreMap.find(reinterpret_cast<uint64_t>(object)) == VkSemaphoreMap.end()) {
- return log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT) 0, (uint64_t) object, 0, OBJTRACK_INVALID_OBJECT, "OBJTRACK",
- "Invalid VkSemaphore Object %" PRIu64, reinterpret_cast<uint64_t>(object));
- }
- return VK_FALSE;
-}
-
-static VkBool32 validate_command_buffer(VkDevice dispatchable_object, VkCommandBuffer object)
-{
- if (VkCommandBufferMap.find(reinterpret_cast<uint64_t>(object)) == VkCommandBufferMap.end()) {
- return log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT) 0, reinterpret_cast<uint64_t>(object), 0, OBJTRACK_INVALID_OBJECT, "OBJTRACK",
- "Invalid VkCommandBuffer Object %" PRIu64, reinterpret_cast<uint64_t>(object));
- }
- return VK_FALSE;
-}
-
-static void create_physical_device(VkInstance dispatchable_object, VkPhysicalDevice vkObj, VkDebugReportObjectTypeEXT objType)
-{
- log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_INFO_BIT_EXT, objType, reinterpret_cast<uint64_t>(vkObj), 0, OBJTRACK_NONE, "OBJTRACK",
- "OBJ[%llu] : CREATE %s object 0x%" PRIxLEAST64 , object_track_index++, string_VkDebugReportObjectTypeEXT(objType),
- reinterpret_cast<uint64_t>(vkObj));
-
- OBJTRACK_NODE* pNewObjNode = new OBJTRACK_NODE;
- pNewObjNode->objType = objType;
- pNewObjNode->status = OBJSTATUS_NONE;
- pNewObjNode->vkObj = reinterpret_cast<uint64_t>(vkObj);
- VkPhysicalDeviceMap[reinterpret_cast<uint64_t>(vkObj)] = pNewObjNode;
- uint32_t objIndex = objTypeToIndex(objType);
- numObjs[objIndex]++;
- numTotalObjs++;
-}
-
-static void create_surface_khr(VkInstance instance, VkSurfaceKHR surface, VkDebugReportObjectTypeEXT objType)
-{
- // TODO: Add tracking of surface objects
-}
-
-static void destroy_surface_khr(VkInstance instance, VkSurfaceKHR surface)
-{
- // TODO: Add tracking of surface objects
-}
-
-static void alloc_command_buffer(VkDevice device, VkCommandPool commandPool, VkCommandBuffer vkObj, VkDebugReportObjectTypeEXT objType)
-{
- log_msg(mdd(device), VK_DEBUG_REPORT_INFO_BIT_EXT, objType, reinterpret_cast<uint64_t>(vkObj), 0, OBJTRACK_NONE, "OBJTRACK",
- "OBJ[%llu] : CREATE %s object 0x%" PRIxLEAST64 , object_track_index++, string_VkDebugReportObjectTypeEXT(objType),
- reinterpret_cast<uint64_t>(vkObj));
-
- OBJTRACK_NODE* pNewObjNode = new OBJTRACK_NODE;
- pNewObjNode->objType = objType;
- pNewObjNode->status = OBJSTATUS_NONE;
- pNewObjNode->vkObj = reinterpret_cast<uint64_t>(vkObj);
- pNewObjNode->parentObj = (uint64_t) commandPool;
- VkCommandBufferMap[reinterpret_cast<uint64_t>(vkObj)] = pNewObjNode;
- uint32_t objIndex = objTypeToIndex(objType);
- numObjs[objIndex]++;
- numTotalObjs++;
-}
-
-static void free_command_buffer(VkDevice device, VkCommandPool commandPool, VkCommandBuffer commandBuffer)
-{
- uint64_t object_handle = reinterpret_cast<uint64_t>(commandBuffer);
- if (VkCommandBufferMap.find(object_handle) != VkCommandBufferMap.end()) {
- OBJTRACK_NODE* pNode = VkCommandBufferMap[(uint64_t)commandBuffer];
-
- if (pNode->parentObj != reinterpret_cast<uint64_t>(commandPool)) {
- log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, pNode->objType, object_handle, 0, OBJTRACK_COMMAND_POOL_MISMATCH, "OBJTRACK",
- "FreeCommandBuffers is attempting to free Command Buffer 0x%" PRIxLEAST64 " belonging to Command Pool 0x%" PRIxLEAST64 " from pool 0x%" PRIxLEAST64 ").",
- reinterpret_cast<uint64_t>(commandBuffer), pNode->parentObj, reinterpret_cast<uint64_t>(commandPool));
- } else {
-
- uint32_t objIndex = objTypeToIndex(pNode->objType);
- assert(numTotalObjs > 0);
- numTotalObjs--;
- assert(numObjs[objIndex] > 0);
- numObjs[objIndex]--;
- log_msg(mdd(device), VK_DEBUG_REPORT_INFO_BIT_EXT, pNode->objType, object_handle, 0, OBJTRACK_NONE, "OBJTRACK",
- "OBJ_STAT Destroy %s obj 0x%" PRIxLEAST64 " (%" PRIu64 " total objs remain & %" PRIu64 " %s objs).",
- string_VkDebugReportObjectTypeEXT(pNode->objType), reinterpret_cast<uint64_t>(commandBuffer), numTotalObjs, numObjs[objIndex],
- string_VkDebugReportObjectTypeEXT(pNode->objType));
- delete pNode;
- VkCommandBufferMap.erase(object_handle);
- }
- } else {
- log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT) 0, object_handle, 0, OBJTRACK_NONE, "OBJTRACK",
- "Unable to remove obj 0x%" PRIxLEAST64 ". Was it created? Has it already been destroyed?",
- object_handle);
- }
-}
-
-static void alloc_descriptor_set(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorSet vkObj, VkDebugReportObjectTypeEXT objType)
-{
- log_msg(mdd(device), VK_DEBUG_REPORT_INFO_BIT_EXT, objType, reinterpret_cast<uint64_t>(vkObj), 0, OBJTRACK_NONE, "OBJTRACK",
- "OBJ[%llu] : CREATE %s object 0x%" PRIxLEAST64 , object_track_index++, string_VkDebugReportObjectTypeEXT(objType),
- reinterpret_cast<uint64_t>(vkObj));
-
- OBJTRACK_NODE* pNewObjNode = new OBJTRACK_NODE;
- pNewObjNode->objType = objType;
- pNewObjNode->status = OBJSTATUS_NONE;
- pNewObjNode->vkObj = reinterpret_cast<uint64_t>(vkObj);
- pNewObjNode->parentObj = (uint64_t) descriptorPool;
- VkDescriptorSetMap[(uint64_t)vkObj] = pNewObjNode;
- uint32_t objIndex = objTypeToIndex(objType);
- numObjs[objIndex]++;
- numTotalObjs++;
-}
-
-static void free_descriptor_set(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorSet descriptorSet)
-{
- uint64_t object_handle = reinterpret_cast<uint64_t>(descriptorSet);
- if (VkDescriptorSetMap.find(object_handle) != VkDescriptorSetMap.end()) {
- OBJTRACK_NODE* pNode = VkDescriptorSetMap[(uint64_t)descriptorSet];
-
- if (pNode->parentObj != reinterpret_cast<uint64_t>(descriptorPool)) {
- log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, pNode->objType, object_handle, 0, OBJTRACK_DESCRIPTOR_POOL_MISMATCH, "OBJTRACK",
- "FreeDescriptorSets is attempting to free descriptorSet 0x%" PRIxLEAST64 " belonging to Descriptor Pool 0x%" PRIxLEAST64 " from pool 0x%" PRIxLEAST64 ").",
- reinterpret_cast<uint64_t>(descriptorSet), pNode->parentObj, reinterpret_cast<uint64_t>(descriptorPool));
- } else {
- uint32_t objIndex = objTypeToIndex(pNode->objType);
- assert(numTotalObjs > 0);
- numTotalObjs--;
- assert(numObjs[objIndex] > 0);
- numObjs[objIndex]--;
- log_msg(mdd(device), VK_DEBUG_REPORT_INFO_BIT_EXT, pNode->objType, object_handle, 0, OBJTRACK_NONE, "OBJTRACK",
- "OBJ_STAT Destroy %s obj 0x%" PRIxLEAST64 " (%" PRIu64 " total objs remain & %" PRIu64 " %s objs).",
- string_VkDebugReportObjectTypeEXT(pNode->objType), reinterpret_cast<uint64_t>(descriptorSet), numTotalObjs, numObjs[objIndex],
- string_VkDebugReportObjectTypeEXT(pNode->objType));
- delete pNode;
- VkDescriptorSetMap.erase(object_handle);
- }
- } else {
- log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT) 0, object_handle, 0, OBJTRACK_NONE, "OBJTRACK",
- "Unable to remove obj 0x%" PRIxLEAST64 ". Was it created? Has it already been destroyed?",
- object_handle);
- }
-}
-
-static void create_swapchain_khr(VkDevice dispatchable_object, VkSwapchainKHR vkObj, VkDebugReportObjectTypeEXT objType)
-{
- log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_INFO_BIT_EXT, objType, (uint64_t) vkObj, 0, OBJTRACK_NONE, "OBJTRACK",
- "OBJ[%llu] : CREATE %s object 0x%" PRIxLEAST64 , object_track_index++, string_VkDebugReportObjectTypeEXT(objType),
- reinterpret_cast<uint64_t>(vkObj));
-
- OBJTRACK_NODE* pNewObjNode = new OBJTRACK_NODE;
- pNewObjNode->objType = objType;
- pNewObjNode->status = OBJSTATUS_NONE;
- pNewObjNode->vkObj = (uint64_t) vkObj;
- VkSwapchainKHRMap[reinterpret_cast<uint64_t>(vkObj)] = pNewObjNode;
- uint32_t objIndex = objTypeToIndex(objType);
- numObjs[objIndex]++;
- numTotalObjs++;
-}
-static void create_queue(VkDevice dispatchable_object, VkQueue vkObj, VkDebugReportObjectTypeEXT objType)
-{
- log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_INFO_BIT_EXT, objType, reinterpret_cast<uint64_t>(vkObj), 0, OBJTRACK_NONE, "OBJTRACK",
- "OBJ[%llu] : CREATE %s object 0x%" PRIxLEAST64 , object_track_index++, string_VkDebugReportObjectTypeEXT(objType),
- reinterpret_cast<uint64_t>(vkObj));
-
- OBJTRACK_NODE* pNewObjNode = new OBJTRACK_NODE;
- pNewObjNode->objType = objType;
- pNewObjNode->status = OBJSTATUS_NONE;
- pNewObjNode->vkObj = reinterpret_cast<uint64_t>(vkObj);
- VkQueueMap[reinterpret_cast<uint64_t>(vkObj)] = pNewObjNode;
- uint32_t objIndex = objTypeToIndex(objType);
- numObjs[objIndex]++;
- numTotalObjs++;
-}
-static void create_swapchain_image_obj(VkDevice dispatchable_object, VkImage vkObj, VkSwapchainKHR swapchain)
-{
- log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_INFO_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, (uint64_t) vkObj, 0, OBJTRACK_NONE, "OBJTRACK",
- "OBJ[%llu] : CREATE %s object 0x%" PRIxLEAST64 , object_track_index++, "SwapchainImage",
- reinterpret_cast<uint64_t>(vkObj));
-
- OBJTRACK_NODE* pNewObjNode = new OBJTRACK_NODE;
- pNewObjNode->objType = VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT;
- pNewObjNode->status = OBJSTATUS_NONE;
- pNewObjNode->vkObj = (uint64_t) vkObj;
- pNewObjNode->parentObj = (uint64_t) swapchain;
- swapchainImageMap[reinterpret_cast<uint64_t>(vkObj)] = pNewObjNode;
-}
-
-static void destroy_swapchain(VkDevice dispatchable_object, VkSwapchainKHR object)
-{
- if (VkSwapchainKHRMap.find(reinterpret_cast<uint64_t>(object)) != VkSwapchainKHRMap.end()) {
- OBJTRACK_NODE* pNode = VkSwapchainKHRMap[reinterpret_cast<uint64_t>(object)];
- uint32_t objIndex = objTypeToIndex(pNode->objType);
- assert(numTotalObjs > 0);
- numTotalObjs--;
- assert(numObjs[objIndex] > 0);
- numObjs[objIndex]--;
- log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_INFO_BIT_EXT, pNode->objType, (uint64_t) object, 0, OBJTRACK_NONE, "OBJTRACK",
- "OBJ_STAT Destroy %s obj 0x%" PRIxLEAST64 " (%" PRIu64 " total objs remain & %" PRIu64 " %s objs).",
- string_VkDebugReportObjectTypeEXT(pNode->objType), (uint64_t) object, numTotalObjs, numObjs[objIndex],
- string_VkDebugReportObjectTypeEXT(pNode->objType));
- delete pNode;
- VkSwapchainKHRMap.erase(reinterpret_cast<uint64_t>(object));
- } else {
- log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT) 0, (uint64_t) object, 0, OBJTRACK_NONE, "OBJTRACK",
- "Unable to remove obj 0x%" PRIxLEAST64 ". Was it created? Has it already been destroyed?",
- reinterpret_cast<uint64_t>(object));
- }
-}
-//
-// Non-auto-generated API functions called by generated code
-//
-VkResult
-explicit_CreateInstance(
- const VkInstanceCreateInfo *pCreateInfo,
- const VkAllocationCallbacks * pAllocator,
- VkInstance * pInstance)
-{
-
- VkLayerInstanceDispatchTable *pInstanceTable = get_dispatch_table(ObjectTracker_instance_table_map, *pInstance);
- VkResult result = pInstanceTable->CreateInstance(pCreateInfo, pAllocator, pInstance);
-
- if (result == VK_SUCCESS) {
- layer_data *my_data = get_my_data_ptr(get_dispatch_key(*pInstance), layer_data_map);
- my_data->report_data = debug_report_create_instance(
- pInstanceTable,
- *pInstance,
- pCreateInfo->enabledExtensionNameCount,
- pCreateInfo->ppEnabledExtensionNames);
- createInstanceRegisterExtensions(pCreateInfo, *pInstance);
-
- initObjectTracker(my_data, pAllocator);
- create_instance(*pInstance, *pInstance, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT);
- }
- return result;
-}
-
-void
-explicit_GetPhysicalDeviceQueueFamilyProperties(
- VkPhysicalDevice gpu,
- uint32_t* pCount,
- VkQueueFamilyProperties* pProperties)
-{
- get_dispatch_table(ObjectTracker_instance_table_map, gpu)->GetPhysicalDeviceQueueFamilyProperties(gpu, pCount, pProperties);
-
- loader_platform_thread_lock_mutex(&objLock);
- if (pProperties != NULL)
- setGpuQueueInfoState(*pCount, pProperties);
- loader_platform_thread_unlock_mutex(&objLock);
-}
-
-VkResult
-explicit_CreateDevice(
- VkPhysicalDevice gpu,
- const VkDeviceCreateInfo *pCreateInfo,
- const VkAllocationCallbacks *pAllocator,
- VkDevice *pDevice)
-{
- loader_platform_thread_lock_mutex(&objLock);
-// VkLayerInstanceDispatchTable *pInstanceTable = get_dispatch_table(ObjectTracker_instance_table_map, gpu);
- VkLayerDispatchTable *pDeviceTable = get_dispatch_table(ObjectTracker_device_table_map, *pDevice);
- VkResult result = pDeviceTable->CreateDevice(gpu, pCreateInfo, pAllocator, pDevice);
- if (result == VK_SUCCESS) {
- layer_data *my_instance_data = get_my_data_ptr(get_dispatch_key(gpu), layer_data_map);
- //// VkLayerDispatchTable *pTable = get_dispatch_table(ObjectTracker_device_table_map, *pDevice);
- layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(*pDevice), layer_data_map);
- my_device_data->report_data = layer_debug_report_create_device(my_instance_data->report_data, *pDevice);
- create_device(*pDevice, *pDevice, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT);
- createDeviceRegisterExtensions(pCreateInfo, *pDevice);
- }
-
- loader_platform_thread_unlock_mutex(&objLock);
- return result;
-}
-
-VkResult explicit_EnumeratePhysicalDevices(VkInstance instance, uint32_t* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices)
-{
- VkBool32 skipCall = VK_FALSE;
- loader_platform_thread_lock_mutex(&objLock);
- skipCall |= validate_instance(instance, instance);
- loader_platform_thread_unlock_mutex(&objLock);
- if (skipCall)
- return VK_ERROR_VALIDATION_FAILED_EXT;
- VkResult result = get_dispatch_table(ObjectTracker_instance_table_map, instance)->EnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices);
- loader_platform_thread_lock_mutex(&objLock);
- if (result == VK_SUCCESS) {
- if (pPhysicalDevices) {
- for (uint32_t i = 0; i < *pPhysicalDeviceCount; i++) {
- create_physical_device(instance, pPhysicalDevices[i], VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT);
- }
- }
- }
- loader_platform_thread_unlock_mutex(&objLock);
- return result;
-}
-
-void
-explicit_GetDeviceQueue(
- VkDevice device,
- uint32_t queueNodeIndex,
- uint32_t queueIndex,
- VkQueue *pQueue)
-{
- loader_platform_thread_lock_mutex(&objLock);
- validate_device(device, device);
- loader_platform_thread_unlock_mutex(&objLock);
-
- get_dispatch_table(ObjectTracker_device_table_map, device)->GetDeviceQueue(device, queueNodeIndex, queueIndex, pQueue);
-
- loader_platform_thread_lock_mutex(&objLock);
- addQueueInfo(queueNodeIndex, *pQueue);
- create_queue(device, *pQueue, VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT);
- loader_platform_thread_unlock_mutex(&objLock);
-}
-
-VkResult
-explicit_MapMemory(
- VkDevice device,
- VkDeviceMemory mem,
- VkDeviceSize offset,
- VkDeviceSize size,
- VkFlags flags,
- void **ppData)
-{
- VkBool32 skipCall = VK_FALSE;
- loader_platform_thread_lock_mutex(&objLock);
- skipCall |= set_device_memory_status(device, mem, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, OBJSTATUS_GPU_MEM_MAPPED);
- skipCall |= validate_device(device, device);
- loader_platform_thread_unlock_mutex(&objLock);
- if (skipCall == VK_TRUE)
- return VK_ERROR_VALIDATION_FAILED_EXT;
-
- VkResult result = get_dispatch_table(ObjectTracker_device_table_map, device)->MapMemory(device, mem, offset, size, flags, ppData);
-
- return result;
-}
-
-void
-explicit_UnmapMemory(
- VkDevice device,
- VkDeviceMemory mem)
-{
- VkBool32 skipCall = VK_FALSE;
- loader_platform_thread_lock_mutex(&objLock);
- skipCall |= reset_device_memory_status(device, mem, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, OBJSTATUS_GPU_MEM_MAPPED);
- skipCall |= validate_device(device, device);
- loader_platform_thread_unlock_mutex(&objLock);
- if (skipCall == VK_TRUE)
- return;
-
- get_dispatch_table(ObjectTracker_device_table_map, device)->UnmapMemory(device, mem);
-}
-
-VkResult
-explicit_QueueBindSparse(
- VkQueue queue,
- uint32_t bindInfoCount,
- const VkBindSparseInfo* pBindInfo,
- VkFence fence)
-{
- loader_platform_thread_lock_mutex(&objLock);
- validateQueueFlags(queue, "QueueBindSparse");
-
- for (uint32_t i = 0; i < bindInfoCount; i++) {
- for (uint32_t j = 0; j < pBindInfo[i].bufferBindCount; j++)
- validate_buffer(queue, pBindInfo[i].pBufferBinds[j].buffer);
- for (uint32_t j = 0; j < pBindInfo[i].imageOpaqueBindCount; j++)
- validate_image(queue, pBindInfo[i].pImageOpaqueBinds[j].image);
- for (uint32_t j = 0; j < pBindInfo[i].imageBindCount; j++)
- validate_image(queue, pBindInfo[i].pImageBinds[j].image);
- }
-
- loader_platform_thread_unlock_mutex(&objLock);
-
- VkResult result = get_dispatch_table(ObjectTracker_device_table_map, queue)->QueueBindSparse(queue, bindInfoCount, pBindInfo, fence);
- return result;
-}
-
-VkResult
-explicit_AllocateCommandBuffers(
- VkDevice device,
- const VkCommandBufferAllocateInfo *pAllocateInfo,
- VkCommandBuffer* pCommandBuffers)
-{
- VkBool32 skipCall = VK_FALSE;
- loader_platform_thread_lock_mutex(&objLock);
- skipCall |= validate_device(device, device);
- skipCall |= validate_command_pool(device, pAllocateInfo->commandPool);
- loader_platform_thread_unlock_mutex(&objLock);
-
- if (skipCall) {
- return VK_ERROR_VALIDATION_FAILED_EXT;
- }
-
- VkResult result = get_dispatch_table(ObjectTracker_device_table_map, device)->AllocateCommandBuffers(
- device, pAllocateInfo, pCommandBuffers);
-
- loader_platform_thread_lock_mutex(&objLock);
- for (uint32_t i = 0; i < pAllocateInfo->bufferCount; i++) {
- alloc_command_buffer(device, pAllocateInfo->commandPool, pCommandBuffers[i], VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT);
- }
- loader_platform_thread_unlock_mutex(&objLock);
-
- return result;
-}
-
-VkResult
-explicit_AllocateDescriptorSets(
- VkDevice device,
- const VkDescriptorSetAllocateInfo *pAllocateInfo,
- VkDescriptorSet *pDescriptorSets)
-{
- VkBool32 skipCall = VK_FALSE;
- loader_platform_thread_lock_mutex(&objLock);
- skipCall |= validate_device(device, device);
- skipCall |= validate_descriptor_pool(device, pAllocateInfo->descriptorPool);
- for (uint32_t i = 0; i < pAllocateInfo->setLayoutCount; i++) {
- skipCall |= validate_descriptor_set_layout(device, pAllocateInfo->pSetLayouts[i]);
- }
- loader_platform_thread_unlock_mutex(&objLock);
- if (skipCall)
- return VK_ERROR_VALIDATION_FAILED_EXT;
-
- VkResult result = get_dispatch_table(ObjectTracker_device_table_map, device)->AllocateDescriptorSets(
- device, pAllocateInfo, pDescriptorSets);
-
- loader_platform_thread_lock_mutex(&objLock);
- for (uint32_t i = 0; i < pAllocateInfo->setLayoutCount; i++) {
- alloc_descriptor_set(device, pAllocateInfo->descriptorPool, pDescriptorSets[i], VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT);
- }
- loader_platform_thread_unlock_mutex(&objLock);
-
- return result;
-}
-
-void
-explicit_FreeCommandBuffers(
- VkDevice device,
- VkCommandPool commandPool,
- uint32_t commandBufferCount,
- const VkCommandBuffer *pCommandBuffers)
-{
- loader_platform_thread_lock_mutex(&objLock);
- validate_command_pool(device, commandPool);
- validate_device(device, device);
- loader_platform_thread_unlock_mutex(&objLock);
-
- get_dispatch_table(ObjectTracker_device_table_map, device)->FreeCommandBuffers(device,
- commandPool, commandBufferCount, pCommandBuffers);
-
- loader_platform_thread_lock_mutex(&objLock);
- for (uint32_t i = 0; i < commandBufferCount; i++)
- {
- free_command_buffer(device, commandPool, *pCommandBuffers);
- pCommandBuffers++;
- }
- loader_platform_thread_unlock_mutex(&objLock);
-}
-
-void
-explicit_DestroySwapchainKHR(
- VkDevice device,
- VkSwapchainKHR swapchain,
- const VkAllocationCallbacks *pAllocator)
-{
- loader_platform_thread_lock_mutex(&objLock);
- // A swapchain's images are implicitly deleted when the swapchain is deleted.
- // Remove this swapchain's images from our map of such images.
- unordered_map<uint64_t, OBJTRACK_NODE*>::iterator itr = swapchainImageMap.begin();
- while (itr != swapchainImageMap.end()) {
- OBJTRACK_NODE* pNode = (*itr).second;
- if (pNode->parentObj == reinterpret_cast<uint64_t>(swapchain)) {
- swapchainImageMap.erase(itr++);
- } else {
- ++itr;
- }
- }
- destroy_swapchain(device, swapchain);
- loader_platform_thread_unlock_mutex(&objLock);
-
- get_dispatch_table(ObjectTracker_device_table_map, device)->DestroySwapchainKHR(device, swapchain, pAllocator);
-}
-
-void
-explicit_FreeMemory(
- VkDevice device,
- VkDeviceMemory mem,
- const VkAllocationCallbacks* pAllocator)
-{
- loader_platform_thread_lock_mutex(&objLock);
- validate_device(device, device);
- loader_platform_thread_unlock_mutex(&objLock);
-
- get_dispatch_table(ObjectTracker_device_table_map, device)->FreeMemory(device, mem, pAllocator);
-
- loader_platform_thread_lock_mutex(&objLock);
- destroy_device_memory(device, mem);
- loader_platform_thread_unlock_mutex(&objLock);
-}
-
-VkResult
-explicit_FreeDescriptorSets(
- VkDevice device,
- VkDescriptorPool descriptorPool,
- uint32_t count,
- const VkDescriptorSet *pDescriptorSets)
-{
- loader_platform_thread_lock_mutex(&objLock);
- validate_descriptor_pool(device, descriptorPool);
- validate_device(device, device);
- loader_platform_thread_unlock_mutex(&objLock);
- VkResult result = get_dispatch_table(ObjectTracker_device_table_map, device)->FreeDescriptorSets(device, descriptorPool, count, pDescriptorSets);
-
- loader_platform_thread_lock_mutex(&objLock);
- for (uint32_t i=0; i<count; i++)
- {
- free_descriptor_set(device, descriptorPool, *pDescriptorSets++);
- }
- loader_platform_thread_unlock_mutex(&objLock);
- return result;
-}
-
-void
-explicit_DestroyDescriptorPool(
- VkDevice device,
- VkDescriptorPool descriptorPool,
- const VkAllocationCallbacks *pAllocator)
-{
- VkBool32 skipCall = VK_FALSE;
- loader_platform_thread_lock_mutex(&objLock);
- skipCall |= validate_device(device, device);
- skipCall |= validate_descriptor_pool(device, descriptorPool);
- loader_platform_thread_unlock_mutex(&objLock);
- if (skipCall) {
- return;
- }
- // A DescriptorPool's descriptor sets are implicitly deleted when the pool is deleted.
- // Remove this pool's descriptor sets from our descriptorSet map.
- loader_platform_thread_lock_mutex(&objLock);
- unordered_map<uint64_t, OBJTRACK_NODE*>::iterator itr = VkDescriptorSetMap.begin();
- while (itr != VkDescriptorSetMap.end()) {
- OBJTRACK_NODE* pNode = (*itr).second;
- auto del_itr = itr++;
- if (pNode->parentObj == reinterpret_cast<uint64_t>(descriptorPool)) {
- destroy_descriptor_set(device, reinterpret_cast<VkDescriptorSet>((*del_itr).first));
- }
- }
- destroy_descriptor_pool(device, descriptorPool);
- loader_platform_thread_unlock_mutex(&objLock);
- get_dispatch_table(ObjectTracker_device_table_map, device)->DestroyDescriptorPool(device, descriptorPool, pAllocator);
-}
-
-void
-explicit_DestroyCommandPool(
- VkDevice device,
- VkCommandPool commandPool,
- const VkAllocationCallbacks *pAllocator)
-{
- VkBool32 skipCall = VK_FALSE;
- loader_platform_thread_lock_mutex(&objLock);
- skipCall |= validate_device(device, device);
- skipCall |= validate_command_pool(device, commandPool);
- loader_platform_thread_unlock_mutex(&objLock);
- if (skipCall) {
- return;
- }
- loader_platform_thread_lock_mutex(&objLock);
- // A CommandPool's command buffers are implicitly deleted when the pool is deleted.
- // Remove this pool's cmdBuffers from our cmd buffer map.
- unordered_map<uint64_t, OBJTRACK_NODE*>::iterator itr = VkCommandBufferMap.begin();
- unordered_map<uint64_t, OBJTRACK_NODE*>::iterator del_itr;
- while (itr != VkCommandBufferMap.end()) {
- OBJTRACK_NODE* pNode = (*itr).second;
- del_itr = itr++;
- if (pNode->parentObj == reinterpret_cast<uint64_t>(commandPool)) {
- destroy_command_buffer(reinterpret_cast<VkCommandBuffer>((*del_itr).first),
- reinterpret_cast<VkCommandBuffer>((*del_itr).first));
- }
- }
- destroy_command_pool(device, commandPool);
- loader_platform_thread_unlock_mutex(&objLock);
- get_dispatch_table(ObjectTracker_device_table_map, device)->DestroyCommandPool(device, commandPool, pAllocator);
-}
-
-VkResult
-explicit_GetSwapchainImagesKHR(
- VkDevice device,
- VkSwapchainKHR swapchain,
- uint32_t *pCount,
- VkImage *pSwapchainImages)
-{
- VkBool32 skipCall = VK_FALSE;
- loader_platform_thread_lock_mutex(&objLock);
- skipCall |= validate_device(device, device);
- loader_platform_thread_unlock_mutex(&objLock);
- if (skipCall)
- return VK_ERROR_VALIDATION_FAILED_EXT;
-
- VkResult result = get_dispatch_table(ObjectTracker_device_table_map, device)->GetSwapchainImagesKHR(device, swapchain, pCount, pSwapchainImages);
-
- if (pSwapchainImages != NULL) {
- loader_platform_thread_lock_mutex(&objLock);
- for (uint32_t i = 0; i < *pCount; i++) {
- create_swapchain_image_obj(device, pSwapchainImages[i], swapchain);
- }
- loader_platform_thread_unlock_mutex(&objLock);
- }
- return result;
-}
-
--- /dev/null
+/*
+ *
+ * Copyright (C) 2015 Valve Corporation
+ * Copyright (C) 2015 Google Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Author: Jon Ashburn <jon@lunarg.com>
+ * Author: Mark Lobodzinski <mark@lunarg.com>
+ * Author: Tobin Ehlis <tobin@lunarg.com>
+ */
+
+#include "vulkan/vk_layer.h"
+#include "vk_layer_extension_utils.h"
+#include "vk_enum_string_helper.h"
+
+// Object Tracker ERROR codes
+typedef enum _OBJECT_TRACK_ERROR
+{
+ OBJTRACK_NONE, // Used for INFO & other non-error messages
+ OBJTRACK_UNKNOWN_OBJECT, // Updating uses of object that's not in global object list
+ OBJTRACK_INTERNAL_ERROR, // Bug with data tracking within the layer
+ OBJTRACK_DESTROY_OBJECT_FAILED, // Couldn't find object to be destroyed
+ OBJTRACK_OBJECT_LEAK, // OBJECT was not correctly freed/destroyed
+ OBJTRACK_OBJCOUNT_MAX_EXCEEDED, // Request for Object data in excess of max obj count
+ OBJTRACK_INVALID_OBJECT, // Object used that has never been created
+ OBJTRACK_DESCRIPTOR_POOL_MISMATCH, // Descriptor Pools specified incorrectly
+ OBJTRACK_COMMAND_POOL_MISMATCH, // Command Pools specified incorrectly
+} OBJECT_TRACK_ERROR;
+
+// Object Status -- used to track state of individual objects
+typedef VkFlags ObjectStatusFlags;
+typedef enum _ObjectStatusFlagBits
+{
+ OBJSTATUS_NONE = 0x00000000, // No status is set
+ OBJSTATUS_FENCE_IS_SUBMITTED = 0x00000001, // Fence has been submitted
+ OBJSTATUS_VIEWPORT_BOUND = 0x00000002, // Viewport state object has been bound
+ OBJSTATUS_RASTER_BOUND = 0x00000004, // Viewport state object has been bound
+ OBJSTATUS_COLOR_BLEND_BOUND = 0x00000008, // Viewport state object has been bound
+ OBJSTATUS_DEPTH_STENCIL_BOUND = 0x00000010, // Viewport state object has been bound
+ OBJSTATUS_GPU_MEM_MAPPED = 0x00000020, // Memory object is currently mapped
+} ObjectStatusFlagBits;
+
+typedef struct _OBJTRACK_NODE {
+ uint64_t vkObj; // Object handle
+ VkDebugReportObjectTypeEXT objType; // Object type identifier
+ ObjectStatusFlags status; // Object state
+ uint64_t parentObj; // Parent object
+} OBJTRACK_NODE;
+
+// prototype for extension functions
+uint64_t objTrackGetObjectCount(VkDevice device);
+uint64_t objTrackGetObjectsOfTypeCount(VkDevice, VkDebugReportObjectTypeEXT type);
+
+// Func ptr typedefs
+typedef uint64_t (*OBJ_TRACK_GET_OBJECT_COUNT)(VkDevice);
+typedef uint64_t (*OBJ_TRACK_GET_OBJECTS_OF_TYPE_COUNT)(VkDevice, VkDebugReportObjectTypeEXT);
+
+struct layer_data {
+ debug_report_data *report_data;
+ //TODO: put instance data here
+ VkDebugReportCallbackEXT logging_callback;
+ bool wsi_enabled;
+ bool objtrack_extensions_enabled;
+
+ layer_data() :
+ report_data(nullptr),
+ logging_callback(VK_NULL_HANDLE),
+ wsi_enabled(false),
+ objtrack_extensions_enabled(false)
+ {};
+};
+
+struct instExts {
+ bool wsi_enabled;
+};
+
+static std::unordered_map<void *, struct instExts> instanceExtMap;
+static std::unordered_map<void*, layer_data *> layer_data_map;
+static device_table_map object_tracker_device_table_map;
+static instance_table_map object_tracker_instance_table_map;
+
+// We need additionally validate image usage using a separate map
+// of swapchain-created images
+static unordered_map<uint64_t, OBJTRACK_NODE*> swapchainImageMap;
+
+static long long unsigned int object_track_index = 0;
+static int objLockInitialized = 0;
+static loader_platform_thread_mutex objLock;
+
+// Objects stored in a global map w/ struct containing basic info
+// unordered_map<const void*, OBJTRACK_NODE*> objMap;
+
+#define NUM_OBJECT_TYPES (VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_EXT+1)
+
+static uint64_t numObjs[NUM_OBJECT_TYPES] = {0};
+static uint64_t numTotalObjs = 0;
+static VkQueueFamilyProperties *queueInfo = NULL;
+static uint32_t queueCount = 0;
+
+template layer_data *get_my_data_ptr<layer_data>(
+ void *data_key, std::unordered_map<void *, layer_data *> &data_map);
+
+static inline const char* string_VkDebugReportObjectTypeEXT(VkDebugReportObjectTypeEXT input_value)
+{
+ switch ((VkDebugReportObjectTypeEXT)input_value)
+ {
+ case VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT:
+ return "VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT";
+ case VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT:
+ return "VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT";
+ case VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT:
+ return "VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT";
+ case VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT:
+ return "VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT";
+ case VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT:
+ return "VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT";
+ case VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT:
+ return "VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT";
+ case VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT_EXT:
+ return "VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT_EXT";
+ case VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT:
+ return "VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT";
+ case VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT:
+ return "VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT";
+ case VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT:
+ return "VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT";
+ case VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT:
+ return "VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT";
+ case VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT:
+ return "VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT";
+ case VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT:
+ return "VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT";
+ case VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT:
+ return "VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT";
+ case VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT:
+ return "VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT";
+ case VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT:
+ return "VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT";
+ case VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT:
+ return "VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT";
+ case VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_LAYOUT_EXT:
+ return "VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_LAYOUT_EXT";
+ case VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_CACHE_EXT:
+ return "VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_CACHE_EXT";
+ case VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT:
+ return "VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT";
+ case VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT:
+ return "VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT";
+ case VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT:
+ return "VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT";
+ case VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT:
+ return "VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT";
+ case VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT:
+ return "VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT";
+ case VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT:
+ return "VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT";
+ case VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT:
+ return "VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT";
+ default:
+ return "Unhandled VkObjectType";
+ }
+}
+
+//
+// Internal Object Tracker Functions
+//
+
+static void createDeviceRegisterExtensions(const VkDeviceCreateInfo* pCreateInfo, VkDevice device)
+{
+ layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
+ VkLayerDispatchTable *pDisp = get_dispatch_table(object_tracker_device_table_map, device);
+ PFN_vkGetDeviceProcAddr gpa = pDisp->GetDeviceProcAddr;
+ pDisp->CreateSwapchainKHR = (PFN_vkCreateSwapchainKHR) gpa(device, "vkCreateSwapchainKHR");
+ pDisp->DestroySwapchainKHR = (PFN_vkDestroySwapchainKHR) gpa(device, "vkDestroySwapchainKHR");
+ pDisp->GetSwapchainImagesKHR = (PFN_vkGetSwapchainImagesKHR) gpa(device, "vkGetSwapchainImagesKHR");
+ pDisp->AcquireNextImageKHR = (PFN_vkAcquireNextImageKHR) gpa(device, "vkAcquireNextImageKHR");
+ pDisp->QueuePresentKHR = (PFN_vkQueuePresentKHR) gpa(device, "vkQueuePresentKHR");
+ my_device_data->wsi_enabled = false;
+ for (uint32_t i = 0; i < pCreateInfo->enabledExtensionNameCount; i++) {
+ if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SWAPCHAIN_EXTENSION_NAME) == 0)
+ my_device_data->wsi_enabled = true;
+
+ if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], "OBJTRACK_EXTENSIONS") == 0)
+ my_device_data->objtrack_extensions_enabled = true;
+ }
+}
+
+static void createInstanceRegisterExtensions(const VkInstanceCreateInfo* pCreateInfo, VkInstance instance)
+{
+ uint32_t i;
+ VkLayerInstanceDispatchTable *pDisp = get_dispatch_table(object_tracker_instance_table_map, instance);
+ PFN_vkGetInstanceProcAddr gpa = pDisp->GetInstanceProcAddr;
+ pDisp->GetPhysicalDeviceSurfaceSupportKHR = (PFN_vkGetPhysicalDeviceSurfaceSupportKHR) gpa(instance, "vkGetPhysicalDeviceSurfaceSupportKHR");
+ pDisp->GetPhysicalDeviceSurfaceCapabilitiesKHR = (PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR) gpa(instance, "vkGetPhysicalDeviceSurfaceCapabilitiesKHR");
+ pDisp->GetPhysicalDeviceSurfaceFormatsKHR = (PFN_vkGetPhysicalDeviceSurfaceFormatsKHR) gpa(instance, "vkGetPhysicalDeviceSurfaceFormatsKHR");
+ pDisp->GetPhysicalDeviceSurfacePresentModesKHR = (PFN_vkGetPhysicalDeviceSurfacePresentModesKHR) gpa(instance, "vkGetPhysicalDeviceSurfacePresentModesKHR");
+
+#if VK_USE_PLATFORM_WIN32_KHR
+ pDisp->CreateWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR) gpa(instance, "vkCreateWin32SurfaceKHR");
+ pDisp->GetPhysicalDeviceWin32PresentationSupportKHR = (PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceWin32PresentationSupportKHR");
+#endif // VK_USE_PLATFORM_WIN32_KHR
+#ifdef VK_USE_PLATFORM_XCB_KHR
+ pDisp->CreateXcbSurfaceKHR = (PFN_vkCreateXcbSurfaceKHR) gpa(instance, "vkCreateXcbSurfaceKHR");
+ pDisp->GetPhysicalDeviceXcbPresentationSupportKHR = (PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceXcbPresentationSupportKHR");
+#endif // VK_USE_PLATFORM_XCB_KHR
+#ifdef VK_USE_PLATFORM_XLIB_KHR
+ pDisp->CreateXlibSurfaceKHR = (PFN_vkCreateXlibSurfaceKHR) gpa(instance, "vkCreateXlibSurfaceKHR");
+ pDisp->GetPhysicalDeviceXlibPresentationSupportKHR = (PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceXlibPresentationSupportKHR");
+#endif // VK_USE_PLATFORM_XLIB_KHR
+#ifdef VK_USE_PLATFORM_MIR_KHR
+ pDisp->CreateMirSurfaceKHR = (PFN_vkCreateMirSurfaceKHR) gpa(instance, "vkCreateMirSurfaceKHR");
+ pDisp->GetPhysicalDeviceMirPresentationSupportKHR = (PFN_vkGetPhysicalDeviceMirPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceMirPresentationSupportKHR");
+#endif // VK_USE_PLATFORM_MIR_KHR
+#ifdef VK_USE_PLATFORM_WAYLAND_KHR
+ pDisp->CreateWaylandSurfaceKHR = (PFN_vkCreateWaylandSurfaceKHR) gpa(instance, "vkCreateWaylandSurfaceKHR");
+ pDisp->GetPhysicalDeviceWaylandPresentationSupportKHR = (PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceWaylandPresentationSupportKHR");
+#endif // VK_USE_PLATFORM_WAYLAND_KHR
+#ifdef VK_USE_PLATFORM_ANDROID_KHR
+ pDisp->CreateAndroidSurfaceKHR = (PFN_vkCreateAndroidSurfaceKHR) gpa(instance, "vkCreateAndroidSurfaceKHR");
+#endif // VK_USE_PLATFORM_ANDROID_KHR
+
+ instanceExtMap[pDisp].wsi_enabled = false;
+ for (i = 0; i < pCreateInfo->enabledExtensionNameCount; i++) {
+ if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SURFACE_EXTENSION_NAME) == 0)
+ instanceExtMap[pDisp].wsi_enabled = true;
+
+ }
+}
+
+// Indicate device or instance dispatch table type
+typedef enum _DispTableType
+{
+ DISP_TBL_TYPE_INSTANCE,
+ DISP_TBL_TYPE_DEVICE,
+} DispTableType;
+
+debug_report_data *mdd(const void* object)
+{
+ dispatch_key key = get_dispatch_key(object);
+ layer_data *my_data = get_my_data_ptr(key, layer_data_map);
+ return my_data->report_data;
+}
+
+debug_report_data *mid(VkInstance object)
+{
+ dispatch_key key = get_dispatch_key(object);
+ layer_data *my_data = get_my_data_ptr(key, layer_data_map);
+ return my_data->report_data;
+}
+
+// For each Queue's doubly linked-list of mem refs
+typedef struct _OT_MEM_INFO {
+ VkDeviceMemory mem;
+ struct _OT_MEM_INFO *pNextMI;
+ struct _OT_MEM_INFO *pPrevMI;
+
+} OT_MEM_INFO;
+
+// Track Queue information
+typedef struct _OT_QUEUE_INFO {
+ OT_MEM_INFO *pMemRefList;
+ struct _OT_QUEUE_INFO *pNextQI;
+ uint32_t queueNodeIndex;
+ VkQueue queue;
+ uint32_t refCount;
+} OT_QUEUE_INFO;
+
+// Global list of QueueInfo structures, one per queue
+static OT_QUEUE_INFO *g_pQueueInfo = NULL;
+
+// Convert an object type enum to an object type array index
+static uint32_t
+objTypeToIndex(
+ uint32_t objType)
+{
+ uint32_t index = objType;
+ return index;
+}
+
+// Add new queue to head of global queue list
+static void
+addQueueInfo(
+ uint32_t queueNodeIndex,
+ VkQueue queue)
+{
+ OT_QUEUE_INFO *pQueueInfo = new OT_QUEUE_INFO;
+
+ if (pQueueInfo != NULL) {
+ memset(pQueueInfo, 0, sizeof(OT_QUEUE_INFO));
+ pQueueInfo->queue = queue;
+ pQueueInfo->queueNodeIndex = queueNodeIndex;
+ pQueueInfo->pNextQI = g_pQueueInfo;
+ g_pQueueInfo = pQueueInfo;
+ }
+ else {
+ log_msg(mdd(queue), VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT, reinterpret_cast<uint64_t>(queue), 0, OBJTRACK_INTERNAL_ERROR, "OBJTRACK",
+ "ERROR: VK_ERROR_OUT_OF_HOST_MEMORY -- could not allocate memory for Queue Information");
+ }
+}
+
+// Destroy memRef lists and free all memory
+static void
+destroyQueueMemRefLists(void)
+{
+ OT_QUEUE_INFO *pQueueInfo = g_pQueueInfo;
+ OT_QUEUE_INFO *pDelQueueInfo = NULL;
+ while (pQueueInfo != NULL) {
+ OT_MEM_INFO *pMemInfo = pQueueInfo->pMemRefList;
+ while (pMemInfo != NULL) {
+ OT_MEM_INFO *pDelMemInfo = pMemInfo;
+ pMemInfo = pMemInfo->pNextMI;
+ delete pDelMemInfo;
+ }
+ pDelQueueInfo = pQueueInfo;
+ pQueueInfo = pQueueInfo->pNextQI;
+ delete pDelQueueInfo;
+ }
+ g_pQueueInfo = pQueueInfo;
+}
+
+static void
+setGpuQueueInfoState(
+ uint32_t count,
+ void *pData)
+{
+ queueCount = count;
+ queueInfo = (VkQueueFamilyProperties*)realloc((void*)queueInfo, count * sizeof(VkQueueFamilyProperties));
+ if (queueInfo != NULL) {
+ memcpy(queueInfo, pData, count * sizeof(VkQueueFamilyProperties));
+ }
+}
+
+// Check Queue type flags for selected queue operations
+static void
+validateQueueFlags(
+ VkQueue queue,
+ const char *function)
+{
+ OT_QUEUE_INFO *pQueueInfo = g_pQueueInfo;
+ while ((pQueueInfo != NULL) && (pQueueInfo->queue != queue)) {
+ pQueueInfo = pQueueInfo->pNextQI;
+ }
+ if (pQueueInfo != NULL) {
+ if ((queueInfo != NULL) && (queueInfo[pQueueInfo->queueNodeIndex].queueFlags & VK_QUEUE_SPARSE_BINDING_BIT) == 0) {
+ log_msg(mdd(queue), VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT, reinterpret_cast<uint64_t>(queue), 0, OBJTRACK_UNKNOWN_OBJECT, "OBJTRACK",
+ "Attempting %s on a non-memory-management capable queue -- VK_QUEUE_SPARSE_BINDING_BIT not set", function);
+ } else {
+ log_msg(mdd(queue), VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT, reinterpret_cast<uint64_t>(queue), 0, OBJTRACK_UNKNOWN_OBJECT, "OBJTRACK",
+ "Attempting %s on a possibly non-memory-management capable queue -- VK_QUEUE_SPARSE_BINDING_BIT not known", function);
+ }
+ }
+}
+
+/* TODO: Port to new type safety */
+#if 0
+// Check object status for selected flag state
+static VkBool32
+validate_status(
+ VkObject dispatchable_object,
+ VkObject vkObj,
+ VkObjectType objType,
+ ObjectStatusFlags status_mask,
+ ObjectStatusFlags status_flag,
+ VkFlags msg_flags,
+ OBJECT_TRACK_ERROR error_code,
+ const char *fail_msg)
+{
+ if (objMap.find(vkObj) != objMap.end()) {
+ OBJTRACK_NODE* pNode = objMap[vkObj];
+ if ((pNode->status & status_mask) != status_flag) {
+ char str[1024];
+ log_msg(mdd(dispatchable_object), msg_flags, pNode->objType, vkObj, 0, OBJTRACK_UNKNOWN_OBJECT, "OBJTRACK",
+ "OBJECT VALIDATION WARNING: %s object 0x%" PRIxLEAST64 ": %s", string_VkObjectType(objType),
+ reinterpret_cast<uint64_t>(vkObj), fail_msg);
+ return VK_FALSE;
+ }
+ return VK_TRUE;
+ }
+ else {
+ // If we do not find it print an error
+ log_msg(mdd(dispatchable_object), msg_flags, (VkObjectType) 0, vkObj, 0, OBJTRACK_UNKNOWN_OBJECT, "OBJTRACK",
+ "Unable to obtain status for non-existent object 0x%" PRIxLEAST64 " of %s type",
+ reinterpret_cast<uint64_t>(vkObj), string_VkObjectType(objType));
+ return VK_FALSE;
+ }
+}
+#endif
+
+#include "vk_dispatch_table_helper.h"
+static void
+initObjectTracker(
+ layer_data *my_data,
+ const VkAllocationCallbacks *pAllocator)
+{
+ uint32_t report_flags = 0;
+ uint32_t debug_action = 0;
+ FILE *log_output = NULL;
+ const char *option_str;
+ // initialize ObjectTracker options
+ report_flags = getLayerOptionFlags("ObjectTrackerReportFlags", 0);
+ getLayerOptionEnum("ObjectTrackerDebugAction", (uint32_t *) &debug_action);
+
+ if (debug_action & VK_DBG_LAYER_ACTION_LOG_MSG)
+ {
+ option_str = getLayerOption("ObjectTrackerLogFilename");
+ log_output = getLayerLogOutput(option_str, "ObjectTracker");
+ VkDebugReportCallbackCreateInfoEXT dbgInfo;
+ memset(&dbgInfo, 0, sizeof(dbgInfo));
+ dbgInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT;
+ dbgInfo.pfnCallback = log_callback;
+ dbgInfo.pUserData = log_output;
+ dbgInfo.flags = report_flags;
+ layer_create_msg_callback(my_data->report_data, &dbgInfo, pAllocator, &my_data->logging_callback);
+ }
+
+ if (!objLockInitialized)
+ {
+ // TODO/TBD: Need to delete this mutex sometime. How??? One
+ // suggestion is to call this during vkCreateInstance(), and then we
+ // can clean it up during vkDestroyInstance(). However, that requires
+ // that the layer have per-instance locks. We need to come back and
+ // address this soon.
+ loader_platform_thread_create_mutex(&objLock);
+ objLockInitialized = 1;
+ }
+}
+
+//
+// Forward declares of generated routines
+//
+
+static void create_physical_device(VkInstance dispatchable_object, VkPhysicalDevice vkObj, VkDebugReportObjectTypeEXT objType);
+static void create_instance(VkInstance dispatchable_object, VkInstance object, VkDebugReportObjectTypeEXT objType);
+static void create_device(VkDevice dispatchable_object, VkDevice object, VkDebugReportObjectTypeEXT objType);
+static void create_queue(VkDevice dispatchable_object, VkQueue vkObj, VkDebugReportObjectTypeEXT objType);
+static VkBool32 validate_image(VkQueue dispatchable_object, VkImage object);
+static VkBool32 validate_image(VkCommandBuffer dispatchable_object, VkImage object);
+static VkBool32 validate_command_buffer(VkQueue dispatchable_object, VkCommandBuffer object);
+static VkBool32 validate_descriptor_set(VkCommandBuffer dispatchable_object, VkDescriptorSet object);
+static VkBool32 validate_instance(VkInstance dispatchable_object, VkInstance object);
+static VkBool32 validate_device(VkDevice dispatchable_object, VkDevice object);
+static VkBool32 validate_descriptor_pool(VkDevice dispatchable_object, VkDescriptorPool object);
+static VkBool32 validate_descriptor_set_layout(VkDevice dispatchable_object, VkDescriptorSetLayout object);
+static VkBool32 validate_command_pool(VkDevice dispatchable_object, VkCommandPool object);
+static void destroy_command_pool(VkDevice dispatchable_object, VkCommandPool object);
+static void destroy_command_buffer(VkCommandBuffer dispatchable_object, VkCommandBuffer object);
+static void destroy_descriptor_pool(VkDevice dispatchable_object, VkDescriptorPool object);
+static void destroy_descriptor_set(VkDevice dispatchable_object, VkDescriptorSet object);
+static void destroy_instance(VkInstance dispatchable_object, VkInstance object);
+static void destroy_device_memory(VkDevice dispatchable_object, VkDeviceMemory object);
+static VkBool32 set_device_memory_status(VkDevice dispatchable_object, VkDeviceMemory object, VkDebugReportObjectTypeEXT objType, ObjectStatusFlags status_flag);
+static VkBool32 reset_device_memory_status(VkDevice dispatchable_object, VkDeviceMemory object, VkDebugReportObjectTypeEXT objType, ObjectStatusFlags status_flag);
+#if 0
+static VkBool32 validate_status(VkDevice dispatchable_object, VkFence object, VkDebugReportObjectTypeEXT objType,
+ ObjectStatusFlags status_mask, ObjectStatusFlags status_flag, VkFlags msg_flags, OBJECT_TRACK_ERROR error_code,
+ const char *fail_msg);
+#endif
+extern unordered_map<uint64_t, OBJTRACK_NODE*> VkPhysicalDeviceMap;
+extern unordered_map<uint64_t, OBJTRACK_NODE*> VkImageMap;
+extern unordered_map<uint64_t, OBJTRACK_NODE*> VkQueueMap;
+extern unordered_map<uint64_t, OBJTRACK_NODE*> VkDescriptorSetMap;
+extern unordered_map<uint64_t, OBJTRACK_NODE*> VkBufferMap;
+extern unordered_map<uint64_t, OBJTRACK_NODE*> VkFenceMap;
+extern unordered_map<uint64_t, OBJTRACK_NODE*> VkSemaphoreMap;
+extern unordered_map<uint64_t, OBJTRACK_NODE*> VkCommandPoolMap;
+extern unordered_map<uint64_t, OBJTRACK_NODE*> VkCommandBufferMap;
+extern unordered_map<uint64_t, OBJTRACK_NODE*> VkSwapchainKHRMap;
+
+static VkBool32 validate_image(VkQueue dispatchable_object, VkImage object)
+{
+ if ((VkImageMap.find(reinterpret_cast<uint64_t>(object)) == VkImageMap.end()) &&
+ (swapchainImageMap.find(reinterpret_cast<uint64_t>(object)) == swapchainImageMap.end())) {
+ return log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT) 0, (uint64_t) object, 0, OBJTRACK_INVALID_OBJECT, "OBJTRACK",
+ "Invalid VkImage Object %" PRIu64, reinterpret_cast<uint64_t>(object));
+ }
+ return VK_FALSE;
+}
+
+static VkBool32 validate_image(VkCommandBuffer dispatchable_object, VkImage object)
+{
+ if ((VkImageMap.find(reinterpret_cast<uint64_t>(object)) == VkImageMap.end()) &&
+ (swapchainImageMap.find(reinterpret_cast<uint64_t>(object)) == swapchainImageMap.end())) {
+ return log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT) 0, (uint64_t) object, 0, OBJTRACK_INVALID_OBJECT, "OBJTRACK",
+ "Invalid VkImage Object %" PRIu64, reinterpret_cast<uint64_t>(object));
+ }
+ return VK_FALSE;
+}
+
+static VkBool32 validate_command_buffer(VkQueue dispatchable_object, VkCommandBuffer object)
+{
+ if (VkCommandBufferMap.find(reinterpret_cast<uint64_t>(object)) == VkCommandBufferMap.end()) {
+ return log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT) 0, reinterpret_cast<uint64_t>(object), 0, OBJTRACK_INVALID_OBJECT, "OBJTRACK",
+ "Invalid VkCommandBuffer Object %" PRIu64, reinterpret_cast<uint64_t>(object));
+ }
+ return VK_FALSE;
+}
+
+static VkBool32 validate_descriptor_set(VkCommandBuffer dispatchable_object, VkDescriptorSet object)
+{
+ if (VkDescriptorSetMap.find(reinterpret_cast<uint64_t>(object)) == VkDescriptorSetMap.end()) {
+ return log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT) 0, (uint64_t) object, 0, OBJTRACK_INVALID_OBJECT, "OBJTRACK",
+ "Invalid VkDescriptorSet Object %" PRIu64, reinterpret_cast<uint64_t>(object));
+ }
+ return VK_FALSE;
+}
+
+static VkBool32 validate_buffer(VkQueue dispatchable_object, VkBuffer object)
+{
+ if (VkBufferMap.find(reinterpret_cast<uint64_t>(object)) != VkBufferMap.end()) {
+ return log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT) 0, (uint64_t) object, 0, OBJTRACK_INVALID_OBJECT, "OBJTRACK",
+ "Invalid VkBuffer Object %" PRIu64, reinterpret_cast<uint64_t>(object));
+ }
+ return VK_FALSE;
+}
+
+static VkBool32 set_status(VkQueue dispatchable_object, VkFence object, VkDebugReportObjectTypeEXT objType, ObjectStatusFlags status_flag)
+{
+ VkBool32 skipCall = VK_FALSE;
+ if (object != VK_NULL_HANDLE) {
+ if (VkFenceMap.find(reinterpret_cast<uint64_t>(object)) != VkFenceMap.end()) {
+ OBJTRACK_NODE* pNode = VkFenceMap[reinterpret_cast<uint64_t>(object)];
+ pNode->status |= status_flag;
+ }
+ else {
+ // If we do not find it print an error
+ skipCall |= log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT) 0, (uint64_t) object, 0, OBJTRACK_NONE, "OBJTRACK",
+ "Unable to set status for non-existent object 0x%" PRIxLEAST64 " of %s type",
+ reinterpret_cast<uint64_t>(object), string_VkDebugReportObjectTypeEXT(objType));
+ }
+ }
+ return skipCall;
+}
+
+static VkBool32 validate_semaphore(VkQueue dispatchable_object, VkSemaphore object)
+{
+ if (VkSemaphoreMap.find(reinterpret_cast<uint64_t>(object)) == VkSemaphoreMap.end()) {
+ return log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT) 0, (uint64_t) object, 0, OBJTRACK_INVALID_OBJECT, "OBJTRACK",
+ "Invalid VkSemaphore Object %" PRIu64, reinterpret_cast<uint64_t>(object));
+ }
+ return VK_FALSE;
+}
+
+static VkBool32 validate_command_buffer(VkDevice dispatchable_object, VkCommandBuffer object)
+{
+ if (VkCommandBufferMap.find(reinterpret_cast<uint64_t>(object)) == VkCommandBufferMap.end()) {
+ return log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT) 0, reinterpret_cast<uint64_t>(object), 0, OBJTRACK_INVALID_OBJECT, "OBJTRACK",
+ "Invalid VkCommandBuffer Object %" PRIu64, reinterpret_cast<uint64_t>(object));
+ }
+ return VK_FALSE;
+}
+
+static void create_physical_device(VkInstance dispatchable_object, VkPhysicalDevice vkObj, VkDebugReportObjectTypeEXT objType)
+{
+ log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_INFO_BIT_EXT, objType, reinterpret_cast<uint64_t>(vkObj), 0, OBJTRACK_NONE, "OBJTRACK",
+ "OBJ[%llu] : CREATE %s object 0x%" PRIxLEAST64 , object_track_index++, string_VkDebugReportObjectTypeEXT(objType),
+ reinterpret_cast<uint64_t>(vkObj));
+
+ OBJTRACK_NODE* pNewObjNode = new OBJTRACK_NODE;
+ pNewObjNode->objType = objType;
+ pNewObjNode->status = OBJSTATUS_NONE;
+ pNewObjNode->vkObj = reinterpret_cast<uint64_t>(vkObj);
+ VkPhysicalDeviceMap[reinterpret_cast<uint64_t>(vkObj)] = pNewObjNode;
+ uint32_t objIndex = objTypeToIndex(objType);
+ numObjs[objIndex]++;
+ numTotalObjs++;
+}
+
+static void create_surface_khr(VkInstance instance, VkSurfaceKHR surface, VkDebugReportObjectTypeEXT objType)
+{
+ // TODO: Add tracking of surface objects
+}
+
+static void destroy_surface_khr(VkInstance instance, VkSurfaceKHR surface)
+{
+ // TODO: Add tracking of surface objects
+}
+
+static void alloc_command_buffer(VkDevice device, VkCommandPool commandPool, VkCommandBuffer vkObj, VkDebugReportObjectTypeEXT objType)
+{
+ log_msg(mdd(device), VK_DEBUG_REPORT_INFO_BIT_EXT, objType, reinterpret_cast<uint64_t>(vkObj), 0, OBJTRACK_NONE, "OBJTRACK",
+ "OBJ[%llu] : CREATE %s object 0x%" PRIxLEAST64 , object_track_index++, string_VkDebugReportObjectTypeEXT(objType),
+ reinterpret_cast<uint64_t>(vkObj));
+
+ OBJTRACK_NODE* pNewObjNode = new OBJTRACK_NODE;
+ pNewObjNode->objType = objType;
+ pNewObjNode->status = OBJSTATUS_NONE;
+ pNewObjNode->vkObj = reinterpret_cast<uint64_t>(vkObj);
+ pNewObjNode->parentObj = (uint64_t) commandPool;
+ VkCommandBufferMap[reinterpret_cast<uint64_t>(vkObj)] = pNewObjNode;
+ uint32_t objIndex = objTypeToIndex(objType);
+ numObjs[objIndex]++;
+ numTotalObjs++;
+}
+
+static void free_command_buffer(VkDevice device, VkCommandPool commandPool, VkCommandBuffer commandBuffer)
+{
+ uint64_t object_handle = reinterpret_cast<uint64_t>(commandBuffer);
+ if (VkCommandBufferMap.find(object_handle) != VkCommandBufferMap.end()) {
+ OBJTRACK_NODE* pNode = VkCommandBufferMap[(uint64_t)commandBuffer];
+
+ if (pNode->parentObj != reinterpret_cast<uint64_t>(commandPool)) {
+ log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, pNode->objType, object_handle, 0, OBJTRACK_COMMAND_POOL_MISMATCH, "OBJTRACK",
+ "FreeCommandBuffers is attempting to free Command Buffer 0x%" PRIxLEAST64 " belonging to Command Pool 0x%" PRIxLEAST64 " from pool 0x%" PRIxLEAST64 ").",
+ reinterpret_cast<uint64_t>(commandBuffer), pNode->parentObj, reinterpret_cast<uint64_t>(commandPool));
+ } else {
+
+ uint32_t objIndex = objTypeToIndex(pNode->objType);
+ assert(numTotalObjs > 0);
+ numTotalObjs--;
+ assert(numObjs[objIndex] > 0);
+ numObjs[objIndex]--;
+ log_msg(mdd(device), VK_DEBUG_REPORT_INFO_BIT_EXT, pNode->objType, object_handle, 0, OBJTRACK_NONE, "OBJTRACK",
+ "OBJ_STAT Destroy %s obj 0x%" PRIxLEAST64 " (%" PRIu64 " total objs remain & %" PRIu64 " %s objs).",
+ string_VkDebugReportObjectTypeEXT(pNode->objType), reinterpret_cast<uint64_t>(commandBuffer), numTotalObjs, numObjs[objIndex],
+ string_VkDebugReportObjectTypeEXT(pNode->objType));
+ delete pNode;
+ VkCommandBufferMap.erase(object_handle);
+ }
+ } else {
+ log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT) 0, object_handle, 0, OBJTRACK_NONE, "OBJTRACK",
+ "Unable to remove obj 0x%" PRIxLEAST64 ". Was it created? Has it already been destroyed?",
+ object_handle);
+ }
+}
+
+static void alloc_descriptor_set(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorSet vkObj, VkDebugReportObjectTypeEXT objType)
+{
+ log_msg(mdd(device), VK_DEBUG_REPORT_INFO_BIT_EXT, objType, reinterpret_cast<uint64_t>(vkObj), 0, OBJTRACK_NONE, "OBJTRACK",
+ "OBJ[%llu] : CREATE %s object 0x%" PRIxLEAST64 , object_track_index++, string_VkDebugReportObjectTypeEXT(objType),
+ reinterpret_cast<uint64_t>(vkObj));
+
+ OBJTRACK_NODE* pNewObjNode = new OBJTRACK_NODE;
+ pNewObjNode->objType = objType;
+ pNewObjNode->status = OBJSTATUS_NONE;
+ pNewObjNode->vkObj = reinterpret_cast<uint64_t>(vkObj);
+ pNewObjNode->parentObj = (uint64_t) descriptorPool;
+ VkDescriptorSetMap[(uint64_t)vkObj] = pNewObjNode;
+ uint32_t objIndex = objTypeToIndex(objType);
+ numObjs[objIndex]++;
+ numTotalObjs++;
+}
+
+static void free_descriptor_set(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorSet descriptorSet)
+{
+ uint64_t object_handle = reinterpret_cast<uint64_t>(descriptorSet);
+ if (VkDescriptorSetMap.find(object_handle) != VkDescriptorSetMap.end()) {
+ OBJTRACK_NODE* pNode = VkDescriptorSetMap[(uint64_t)descriptorSet];
+
+ if (pNode->parentObj != reinterpret_cast<uint64_t>(descriptorPool)) {
+ log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, pNode->objType, object_handle, 0, OBJTRACK_DESCRIPTOR_POOL_MISMATCH, "OBJTRACK",
+ "FreeDescriptorSets is attempting to free descriptorSet 0x%" PRIxLEAST64 " belonging to Descriptor Pool 0x%" PRIxLEAST64 " from pool 0x%" PRIxLEAST64 ").",
+ reinterpret_cast<uint64_t>(descriptorSet), pNode->parentObj, reinterpret_cast<uint64_t>(descriptorPool));
+ } else {
+ uint32_t objIndex = objTypeToIndex(pNode->objType);
+ assert(numTotalObjs > 0);
+ numTotalObjs--;
+ assert(numObjs[objIndex] > 0);
+ numObjs[objIndex]--;
+ log_msg(mdd(device), VK_DEBUG_REPORT_INFO_BIT_EXT, pNode->objType, object_handle, 0, OBJTRACK_NONE, "OBJTRACK",
+ "OBJ_STAT Destroy %s obj 0x%" PRIxLEAST64 " (%" PRIu64 " total objs remain & %" PRIu64 " %s objs).",
+ string_VkDebugReportObjectTypeEXT(pNode->objType), reinterpret_cast<uint64_t>(descriptorSet), numTotalObjs, numObjs[objIndex],
+ string_VkDebugReportObjectTypeEXT(pNode->objType));
+ delete pNode;
+ VkDescriptorSetMap.erase(object_handle);
+ }
+ } else {
+ log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT) 0, object_handle, 0, OBJTRACK_NONE, "OBJTRACK",
+ "Unable to remove obj 0x%" PRIxLEAST64 ". Was it created? Has it already been destroyed?",
+ object_handle);
+ }
+}
+
+static void create_swapchain_khr(VkDevice dispatchable_object, VkSwapchainKHR vkObj, VkDebugReportObjectTypeEXT objType)
+{
+ log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_INFO_BIT_EXT, objType, (uint64_t) vkObj, 0, OBJTRACK_NONE, "OBJTRACK",
+ "OBJ[%llu] : CREATE %s object 0x%" PRIxLEAST64 , object_track_index++, string_VkDebugReportObjectTypeEXT(objType),
+ reinterpret_cast<uint64_t>(vkObj));
+
+ OBJTRACK_NODE* pNewObjNode = new OBJTRACK_NODE;
+ pNewObjNode->objType = objType;
+ pNewObjNode->status = OBJSTATUS_NONE;
+ pNewObjNode->vkObj = (uint64_t) vkObj;
+ VkSwapchainKHRMap[reinterpret_cast<uint64_t>(vkObj)] = pNewObjNode;
+ uint32_t objIndex = objTypeToIndex(objType);
+ numObjs[objIndex]++;
+ numTotalObjs++;
+}
+static void create_queue(VkDevice dispatchable_object, VkQueue vkObj, VkDebugReportObjectTypeEXT objType)
+{
+ log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_INFO_BIT_EXT, objType, reinterpret_cast<uint64_t>(vkObj), 0, OBJTRACK_NONE, "OBJTRACK",
+ "OBJ[%llu] : CREATE %s object 0x%" PRIxLEAST64 , object_track_index++, string_VkDebugReportObjectTypeEXT(objType),
+ reinterpret_cast<uint64_t>(vkObj));
+
+ OBJTRACK_NODE* pNewObjNode = new OBJTRACK_NODE;
+ pNewObjNode->objType = objType;
+ pNewObjNode->status = OBJSTATUS_NONE;
+ pNewObjNode->vkObj = reinterpret_cast<uint64_t>(vkObj);
+ VkQueueMap[reinterpret_cast<uint64_t>(vkObj)] = pNewObjNode;
+ uint32_t objIndex = objTypeToIndex(objType);
+ numObjs[objIndex]++;
+ numTotalObjs++;
+}
+static void create_swapchain_image_obj(VkDevice dispatchable_object, VkImage vkObj, VkSwapchainKHR swapchain)
+{
+ log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_INFO_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, (uint64_t) vkObj, 0, OBJTRACK_NONE, "OBJTRACK",
+ "OBJ[%llu] : CREATE %s object 0x%" PRIxLEAST64 , object_track_index++, "SwapchainImage",
+ reinterpret_cast<uint64_t>(vkObj));
+
+ OBJTRACK_NODE* pNewObjNode = new OBJTRACK_NODE;
+ pNewObjNode->objType = VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT;
+ pNewObjNode->status = OBJSTATUS_NONE;
+ pNewObjNode->vkObj = (uint64_t) vkObj;
+ pNewObjNode->parentObj = (uint64_t) swapchain;
+ swapchainImageMap[reinterpret_cast<uint64_t>(vkObj)] = pNewObjNode;
+}
+
+static void destroy_swapchain(VkDevice dispatchable_object, VkSwapchainKHR object)
+{
+ if (VkSwapchainKHRMap.find(reinterpret_cast<uint64_t>(object)) != VkSwapchainKHRMap.end()) {
+ OBJTRACK_NODE* pNode = VkSwapchainKHRMap[reinterpret_cast<uint64_t>(object)];
+ uint32_t objIndex = objTypeToIndex(pNode->objType);
+ assert(numTotalObjs > 0);
+ numTotalObjs--;
+ assert(numObjs[objIndex] > 0);
+ numObjs[objIndex]--;
+ log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_INFO_BIT_EXT, pNode->objType, (uint64_t) object, 0, OBJTRACK_NONE, "OBJTRACK",
+ "OBJ_STAT Destroy %s obj 0x%" PRIxLEAST64 " (%" PRIu64 " total objs remain & %" PRIu64 " %s objs).",
+ string_VkDebugReportObjectTypeEXT(pNode->objType), (uint64_t) object, numTotalObjs, numObjs[objIndex],
+ string_VkDebugReportObjectTypeEXT(pNode->objType));
+ delete pNode;
+ VkSwapchainKHRMap.erase(reinterpret_cast<uint64_t>(object));
+ } else {
+ log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT) 0, (uint64_t) object, 0, OBJTRACK_NONE, "OBJTRACK",
+ "Unable to remove obj 0x%" PRIxLEAST64 ". Was it created? Has it already been destroyed?",
+ reinterpret_cast<uint64_t>(object));
+ }
+}
+//
+// Non-auto-generated API functions called by generated code
+//
+VkResult
+explicit_CreateInstance(
+ const VkInstanceCreateInfo *pCreateInfo,
+ const VkAllocationCallbacks * pAllocator,
+ VkInstance * pInstance)
+{
+
+ VkLayerInstanceDispatchTable *pInstanceTable = get_dispatch_table(object_tracker_instance_table_map, *pInstance);
+ VkResult result = pInstanceTable->CreateInstance(pCreateInfo, pAllocator, pInstance);
+
+ if (result == VK_SUCCESS) {
+ layer_data *my_data = get_my_data_ptr(get_dispatch_key(*pInstance), layer_data_map);
+ my_data->report_data = debug_report_create_instance(
+ pInstanceTable,
+ *pInstance,
+ pCreateInfo->enabledExtensionNameCount,
+ pCreateInfo->ppEnabledExtensionNames);
+ createInstanceRegisterExtensions(pCreateInfo, *pInstance);
+
+ initObjectTracker(my_data, pAllocator);
+ create_instance(*pInstance, *pInstance, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT);
+ }
+ return result;
+}
+
+void
+explicit_GetPhysicalDeviceQueueFamilyProperties(
+ VkPhysicalDevice gpu,
+ uint32_t* pCount,
+ VkQueueFamilyProperties* pProperties)
+{
+ get_dispatch_table(object_tracker_instance_table_map, gpu)->GetPhysicalDeviceQueueFamilyProperties(gpu, pCount, pProperties);
+
+ loader_platform_thread_lock_mutex(&objLock);
+ if (pProperties != NULL)
+ setGpuQueueInfoState(*pCount, pProperties);
+ loader_platform_thread_unlock_mutex(&objLock);
+}
+
+VkResult
+explicit_CreateDevice(
+ VkPhysicalDevice gpu,
+ const VkDeviceCreateInfo *pCreateInfo,
+ const VkAllocationCallbacks *pAllocator,
+ VkDevice *pDevice)
+{
+ loader_platform_thread_lock_mutex(&objLock);
+ VkLayerDispatchTable *pDeviceTable = get_dispatch_table(object_tracker_device_table_map, *pDevice);
+ VkResult result = pDeviceTable->CreateDevice(gpu, pCreateInfo, pAllocator, pDevice);
+ if (result == VK_SUCCESS) {
+ layer_data *my_instance_data = get_my_data_ptr(get_dispatch_key(gpu), layer_data_map);
+ layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(*pDevice), layer_data_map);
+ my_device_data->report_data = layer_debug_report_create_device(my_instance_data->report_data, *pDevice);
+ create_device(*pDevice, *pDevice, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT);
+ createDeviceRegisterExtensions(pCreateInfo, *pDevice);
+ }
+
+ loader_platform_thread_unlock_mutex(&objLock);
+ return result;
+}
+
+VkResult explicit_EnumeratePhysicalDevices(VkInstance instance, uint32_t* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices)
+{
+ VkBool32 skipCall = VK_FALSE;
+ loader_platform_thread_lock_mutex(&objLock);
+ skipCall |= validate_instance(instance, instance);
+ loader_platform_thread_unlock_mutex(&objLock);
+ if (skipCall)
+ return VK_ERROR_VALIDATION_FAILED_EXT;
+ VkResult result = get_dispatch_table(object_tracker_instance_table_map, instance)->EnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices);
+ loader_platform_thread_lock_mutex(&objLock);
+ if (result == VK_SUCCESS) {
+ if (pPhysicalDevices) {
+ for (uint32_t i = 0; i < *pPhysicalDeviceCount; i++) {
+ create_physical_device(instance, pPhysicalDevices[i], VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT);
+ }
+ }
+ }
+ loader_platform_thread_unlock_mutex(&objLock);
+ return result;
+}
+
+void
+explicit_GetDeviceQueue(
+ VkDevice device,
+ uint32_t queueNodeIndex,
+ uint32_t queueIndex,
+ VkQueue *pQueue)
+{
+ loader_platform_thread_lock_mutex(&objLock);
+ validate_device(device, device);
+ loader_platform_thread_unlock_mutex(&objLock);
+
+ get_dispatch_table(object_tracker_device_table_map, device)->GetDeviceQueue(device, queueNodeIndex, queueIndex, pQueue);
+
+ loader_platform_thread_lock_mutex(&objLock);
+ addQueueInfo(queueNodeIndex, *pQueue);
+ create_queue(device, *pQueue, VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT);
+ loader_platform_thread_unlock_mutex(&objLock);
+}
+
+VkResult
+explicit_MapMemory(
+ VkDevice device,
+ VkDeviceMemory mem,
+ VkDeviceSize offset,
+ VkDeviceSize size,
+ VkFlags flags,
+ void **ppData)
+{
+ VkBool32 skipCall = VK_FALSE;
+ loader_platform_thread_lock_mutex(&objLock);
+ skipCall |= set_device_memory_status(device, mem, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, OBJSTATUS_GPU_MEM_MAPPED);
+ skipCall |= validate_device(device, device);
+ loader_platform_thread_unlock_mutex(&objLock);
+ if (skipCall == VK_TRUE)
+ return VK_ERROR_VALIDATION_FAILED_EXT;
+
+ VkResult result = get_dispatch_table(object_tracker_device_table_map, device)->MapMemory(device, mem, offset, size, flags, ppData);
+
+ return result;
+}
+
+void
+explicit_UnmapMemory(
+ VkDevice device,
+ VkDeviceMemory mem)
+{
+ VkBool32 skipCall = VK_FALSE;
+ loader_platform_thread_lock_mutex(&objLock);
+ skipCall |= reset_device_memory_status(device, mem, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, OBJSTATUS_GPU_MEM_MAPPED);
+ skipCall |= validate_device(device, device);
+ loader_platform_thread_unlock_mutex(&objLock);
+ if (skipCall == VK_TRUE)
+ return;
+
+ get_dispatch_table(object_tracker_device_table_map, device)->UnmapMemory(device, mem);
+}
+
+VkResult
+explicit_QueueBindSparse(
+ VkQueue queue,
+ uint32_t bindInfoCount,
+ const VkBindSparseInfo* pBindInfo,
+ VkFence fence)
+{
+ loader_platform_thread_lock_mutex(&objLock);
+ validateQueueFlags(queue, "QueueBindSparse");
+
+ for (uint32_t i = 0; i < bindInfoCount; i++) {
+ for (uint32_t j = 0; j < pBindInfo[i].bufferBindCount; j++)
+ validate_buffer(queue, pBindInfo[i].pBufferBinds[j].buffer);
+ for (uint32_t j = 0; j < pBindInfo[i].imageOpaqueBindCount; j++)
+ validate_image(queue, pBindInfo[i].pImageOpaqueBinds[j].image);
+ for (uint32_t j = 0; j < pBindInfo[i].imageBindCount; j++)
+ validate_image(queue, pBindInfo[i].pImageBinds[j].image);
+ }
+
+ loader_platform_thread_unlock_mutex(&objLock);
+
+ VkResult result = get_dispatch_table(object_tracker_device_table_map, queue)->QueueBindSparse(queue, bindInfoCount, pBindInfo, fence);
+ return result;
+}
+
+VkResult
+explicit_AllocateCommandBuffers(
+ VkDevice device,
+ const VkCommandBufferAllocateInfo *pAllocateInfo,
+ VkCommandBuffer* pCommandBuffers)
+{
+ VkBool32 skipCall = VK_FALSE;
+ loader_platform_thread_lock_mutex(&objLock);
+ skipCall |= validate_device(device, device);
+ skipCall |= validate_command_pool(device, pAllocateInfo->commandPool);
+ loader_platform_thread_unlock_mutex(&objLock);
+
+ if (skipCall) {
+ return VK_ERROR_VALIDATION_FAILED_EXT;
+ }
+
+ VkResult result = get_dispatch_table(object_tracker_device_table_map, device)->AllocateCommandBuffers(
+ device, pAllocateInfo, pCommandBuffers);
+
+ loader_platform_thread_lock_mutex(&objLock);
+ for (uint32_t i = 0; i < pAllocateInfo->bufferCount; i++) {
+ alloc_command_buffer(device, pAllocateInfo->commandPool, pCommandBuffers[i], VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT);
+ }
+ loader_platform_thread_unlock_mutex(&objLock);
+
+ return result;
+}
+
+VkResult
+explicit_AllocateDescriptorSets(
+ VkDevice device,
+ const VkDescriptorSetAllocateInfo *pAllocateInfo,
+ VkDescriptorSet *pDescriptorSets)
+{
+ VkBool32 skipCall = VK_FALSE;
+ loader_platform_thread_lock_mutex(&objLock);
+ skipCall |= validate_device(device, device);
+ skipCall |= validate_descriptor_pool(device, pAllocateInfo->descriptorPool);
+ for (uint32_t i = 0; i < pAllocateInfo->setLayoutCount; i++) {
+ skipCall |= validate_descriptor_set_layout(device, pAllocateInfo->pSetLayouts[i]);
+ }
+ loader_platform_thread_unlock_mutex(&objLock);
+ if (skipCall)
+ return VK_ERROR_VALIDATION_FAILED_EXT;
+
+ VkResult result = get_dispatch_table(object_tracker_device_table_map, device)->AllocateDescriptorSets(
+ device, pAllocateInfo, pDescriptorSets);
+
+ loader_platform_thread_lock_mutex(&objLock);
+ for (uint32_t i = 0; i < pAllocateInfo->setLayoutCount; i++) {
+ alloc_descriptor_set(device, pAllocateInfo->descriptorPool, pDescriptorSets[i], VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT);
+ }
+ loader_platform_thread_unlock_mutex(&objLock);
+
+ return result;
+}
+
+void
+explicit_FreeCommandBuffers(
+ VkDevice device,
+ VkCommandPool commandPool,
+ uint32_t commandBufferCount,
+ const VkCommandBuffer *pCommandBuffers)
+{
+ loader_platform_thread_lock_mutex(&objLock);
+ validate_command_pool(device, commandPool);
+ validate_device(device, device);
+ loader_platform_thread_unlock_mutex(&objLock);
+
+ get_dispatch_table(object_tracker_device_table_map, device)->FreeCommandBuffers(device,
+ commandPool, commandBufferCount, pCommandBuffers);
+
+ loader_platform_thread_lock_mutex(&objLock);
+ for (uint32_t i = 0; i < commandBufferCount; i++)
+ {
+ free_command_buffer(device, commandPool, *pCommandBuffers);
+ pCommandBuffers++;
+ }
+ loader_platform_thread_unlock_mutex(&objLock);
+}
+
+void
+explicit_DestroySwapchainKHR(
+ VkDevice device,
+ VkSwapchainKHR swapchain,
+ const VkAllocationCallbacks *pAllocator)
+{
+ loader_platform_thread_lock_mutex(&objLock);
+ // A swapchain's images are implicitly deleted when the swapchain is deleted.
+ // Remove this swapchain's images from our map of such images.
+ unordered_map<uint64_t, OBJTRACK_NODE*>::iterator itr = swapchainImageMap.begin();
+ while (itr != swapchainImageMap.end()) {
+ OBJTRACK_NODE* pNode = (*itr).second;
+ if (pNode->parentObj == reinterpret_cast<uint64_t>(swapchain)) {
+ swapchainImageMap.erase(itr++);
+ } else {
+ ++itr;
+ }
+ }
+ destroy_swapchain(device, swapchain);
+ loader_platform_thread_unlock_mutex(&objLock);
+
+ get_dispatch_table(object_tracker_device_table_map, device)->DestroySwapchainKHR(device, swapchain, pAllocator);
+}
+
+void
+explicit_FreeMemory(
+ VkDevice device,
+ VkDeviceMemory mem,
+ const VkAllocationCallbacks* pAllocator)
+{
+ loader_platform_thread_lock_mutex(&objLock);
+ validate_device(device, device);
+ loader_platform_thread_unlock_mutex(&objLock);
+
+ get_dispatch_table(object_tracker_device_table_map, device)->FreeMemory(device, mem, pAllocator);
+
+ loader_platform_thread_lock_mutex(&objLock);
+ destroy_device_memory(device, mem);
+ loader_platform_thread_unlock_mutex(&objLock);
+}
+
+VkResult
+explicit_FreeDescriptorSets(
+ VkDevice device,
+ VkDescriptorPool descriptorPool,
+ uint32_t count,
+ const VkDescriptorSet *pDescriptorSets)
+{
+ loader_platform_thread_lock_mutex(&objLock);
+ validate_descriptor_pool(device, descriptorPool);
+ validate_device(device, device);
+ loader_platform_thread_unlock_mutex(&objLock);
+ VkResult result = get_dispatch_table(object_tracker_device_table_map, device)->FreeDescriptorSets(device, descriptorPool, count, pDescriptorSets);
+
+ loader_platform_thread_lock_mutex(&objLock);
+ for (uint32_t i=0; i<count; i++)
+ {
+ free_descriptor_set(device, descriptorPool, *pDescriptorSets++);
+ }
+ loader_platform_thread_unlock_mutex(&objLock);
+ return result;
+}
+
+void
+explicit_DestroyDescriptorPool(
+ VkDevice device,
+ VkDescriptorPool descriptorPool,
+ const VkAllocationCallbacks *pAllocator)
+{
+ VkBool32 skipCall = VK_FALSE;
+ loader_platform_thread_lock_mutex(&objLock);
+ skipCall |= validate_device(device, device);
+ skipCall |= validate_descriptor_pool(device, descriptorPool);
+ loader_platform_thread_unlock_mutex(&objLock);
+ if (skipCall) {
+ return;
+ }
+ // A DescriptorPool's descriptor sets are implicitly deleted when the pool is deleted.
+ // Remove this pool's descriptor sets from our descriptorSet map.
+ loader_platform_thread_lock_mutex(&objLock);
+ unordered_map<uint64_t, OBJTRACK_NODE*>::iterator itr = VkDescriptorSetMap.begin();
+ while (itr != VkDescriptorSetMap.end()) {
+ OBJTRACK_NODE* pNode = (*itr).second;
+ auto del_itr = itr++;
+ if (pNode->parentObj == reinterpret_cast<uint64_t>(descriptorPool)) {
+ destroy_descriptor_set(device, reinterpret_cast<VkDescriptorSet>((*del_itr).first));
+ }
+ }
+ destroy_descriptor_pool(device, descriptorPool);
+ loader_platform_thread_unlock_mutex(&objLock);
+ get_dispatch_table(object_tracker_device_table_map, device)->DestroyDescriptorPool(device, descriptorPool, pAllocator);
+}
+
+void
+explicit_DestroyCommandPool(
+ VkDevice device,
+ VkCommandPool commandPool,
+ const VkAllocationCallbacks *pAllocator)
+{
+ VkBool32 skipCall = VK_FALSE;
+ loader_platform_thread_lock_mutex(&objLock);
+ skipCall |= validate_device(device, device);
+ skipCall |= validate_command_pool(device, commandPool);
+ loader_platform_thread_unlock_mutex(&objLock);
+ if (skipCall) {
+ return;
+ }
+ loader_platform_thread_lock_mutex(&objLock);
+ // A CommandPool's command buffers are implicitly deleted when the pool is deleted.
+ // Remove this pool's cmdBuffers from our cmd buffer map.
+ unordered_map<uint64_t, OBJTRACK_NODE*>::iterator itr = VkCommandBufferMap.begin();
+ unordered_map<uint64_t, OBJTRACK_NODE*>::iterator del_itr;
+ while (itr != VkCommandBufferMap.end()) {
+ OBJTRACK_NODE* pNode = (*itr).second;
+ del_itr = itr++;
+ if (pNode->parentObj == reinterpret_cast<uint64_t>(commandPool)) {
+ destroy_command_buffer(reinterpret_cast<VkCommandBuffer>((*del_itr).first),
+ reinterpret_cast<VkCommandBuffer>((*del_itr).first));
+ }
+ }
+ destroy_command_pool(device, commandPool);
+ loader_platform_thread_unlock_mutex(&objLock);
+ get_dispatch_table(object_tracker_device_table_map, device)->DestroyCommandPool(device, commandPool, pAllocator);
+}
+
+VkResult
+explicit_GetSwapchainImagesKHR(
+ VkDevice device,
+ VkSwapchainKHR swapchain,
+ uint32_t *pCount,
+ VkImage *pSwapchainImages)
+{
+ VkBool32 skipCall = VK_FALSE;
+ loader_platform_thread_lock_mutex(&objLock);
+ skipCall |= validate_device(device, device);
+ loader_platform_thread_unlock_mutex(&objLock);
+ if (skipCall)
+ return VK_ERROR_VALIDATION_FAILED_EXT;
+
+ VkResult result = get_dispatch_table(object_tracker_device_table_map, device)->GetSwapchainImagesKHR(device, swapchain, pCount, pSwapchainImages);
+
+ if (pSwapchainImages != NULL) {
+ loader_platform_thread_lock_mutex(&objLock);
+ for (uint32_t i = 0; i < *pCount; i++) {
+ create_swapchain_image_obj(device, pSwapchainImages[i], swapchain);
+ }
+ loader_platform_thread_unlock_mutex(&objLock);
+ }
+ return result;
+}
+
static const VkLayerProperties pc_global_layers[] = {
{
- "ParamChecker",
+ "param_checker",
VK_API_VERSION,
VK_MAKE_VERSION(0, 1, 0),
- "Validation layer: ParamChecker",
+ "Validation layer: param_checker",
}
};
static const VkLayerProperties ss_device_layers[] = {
{
- "ScreenShot",
+ "screenshot",
VK_API_VERSION,
VK_MAKE_VERSION(0, 1, 0),
- "Layer: ScreenShot",
+ "Layer: screenshot",
}
};
static const VkLayerProperties swapchain_global_layers[] = {
{
- "Swapchain",
+ "swapchain",
VK_API_VERSION,
VK_MAKE_VERSION(0, 1, 0),
- "Validation layer: Swapchain",
+ "Validation layer: swapchain",
}
};
"VK_LAYER_LUNARG_swapchain",
VK_API_VERSION, // specVersion
VK_MAKE_VERSION(0, 1, 0), // implementationVersion
- "layer: Swapchain",
+ "layer: swapchain",
}
};
"VK_LAYER_LUNARG_swapchain",
VK_API_VERSION, // specVersion
VK_MAKE_VERSION(0, 1, 0), // implementationVersion
- "layer: Swapchain",
+ "layer: swapchain",
}
};
};
static std::unordered_map<void*, layer_data *> layer_data_map;
-static device_table_map Threading_device_table_map;
-static instance_table_map Threading_instance_table_map;
+static device_table_map threading_device_table_map;
+static instance_table_map threading_instance_table_map;
static inline debug_report_data *mdd(const void* object)
{
#
# Example of actual settings for each layer
#
-# VK_LUNARG_LAYER_DeviceLimits Settings
+# VK_LUNARG_LAYER_device_limits Settings
DeviceLimitsDebugAction = VK_DBG_LAYER_ACTION_LOG_MSG
DeviceLimitsReportFlags = error,warn,perf
DeviceLimitsLogFilename = stdout
-# VK_LUNARG_LAYER_DrawState Settings
+# VK_LUNARG_LAYER_draw_state Settings
DrawStateDebugAction = VK_DBG_LAYER_ACTION_LOG_MSG
DrawStateReportFlags = error,warn,perf
DrawStateLogFilename = stdout
-# VK_LUNARG_LAYER_Image Settings
+# VK_LUNARG_LAYER_image Settings
ImageDebugAction = VK_DBG_LAYER_ACTION_LOG_MSG
ImageReportFlags = error,warn,perf
ImageLogFilename = stdout
-# VK_LUNARG_LAYER_MemTracker Settings
+# VK_LUNARG_LAYER_mem_tracker Settings
MemTrackerDebugAction = VK_DBG_LAYER_ACTION_LOG_MSG
MemTrackerReportFlags = error,warn,perf
MemTrackerLogFilename = stdout
-# VK_LUNARG_LAYER_ObjectTracker Settings
+# VK_LUNARG_LAYER_object_tracker Settings
ObjectTrackerDebugAction = VK_DBG_LAYER_ACTION_LOG_MSG
ObjectTrackerReportFlags = error,warn,perf
ObjectTrackerLogFilename = stdout
-# VK_LUNARG_LAYER_ParamChecker Settings
+# VK_LUNARG_LAYER_param_checker Settings
ParamCheckerDebugAction = VK_DBG_LAYER_ACTION_LOG_MSG
ParamCheckerReportFlags = error,warn,perf
ParamCheckerLogFilename = stdout
-# VK_LUNARG_LAYER_Swapchain Settings
+# VK_LUNARG_LAYER_swapchain Settings
SwapchainDebugAction = VK_DBG_LAYER_ACTION_LOG_MSG
SwapchainReportFlags = error,warn,perf
SwapchainLogFilename = stdout
-# VK_LUNARG_LAYER_Threading Settings
+# VK_LUNARG_LAYER_threading Settings
ThreadingDebugAction = VK_DBG_LAYER_ACTION_LOG_MSG
ThreadingReportFlags = error,warn,perf
ThreadingLogFilename = stdout
-# VK_LUNARG_LAYER_APIDump Settings - NOTE that VK_LUNARG_LAYER_APIDump is
+# VK_LUNARG_LAYER_api_dump Settings - NOTE that VK_LUNARG_LAYER_api_dump is
# not a validation layer and the common settings for ReportFlags and
# DebugAction do not apply
# Detailed TRUE causes parameter details to be dumped in addition to API calls
-APIDumpDetailed = TRUE
+ApiDumpDetailed = TRUE
# NoAddr TRUE causes "address" to be dumped in place of hex addresses
-APIDumpNoAddr = FALSE
+ApiDumpNoAddr = FALSE
# File = TRUE indicates that output should be written to file instead of STDOUT
-APIDumpFile = FALSE
+ApiDumpFile = FALSE
# LogFilename is file to dump to when "File = TRUE" default is "vk_apidump.txt"
-APIDumpLogFilename = stdout
+ApiDumpLogFilename = stdout
# Flush = TRUE causes IO to be flushed after each line that's written
-APIDumpFlush = FALSE
+ApiDumpFlush = FALSE
# Validation Layer Details
-## VK_LAYER_LUNARG_DrawState
+## VK_LAYER_LUNARG_draw_state
-### VK_LAYER_LUNARG_DrawState Overview
+### VK_LAYER_LUNARG_draw_state Overview
-The VK_LAYER_LUNARG_DrawState layer tracks state leading into Draw cmds. This includes the Pipeline state, dynamic state, shaders, and descriptor set state. VK_LAYER_LUNARG_DrawState validates the consistency and correctness between and within these states. VK_LAYER_LUNARG_DrawState also includes SPIR-V validation which functionality is recorded under the VK_LAYER_LUNARG_ShaderChecker section below.
+The VK_LAYER_LUNARG_draw_state layer tracks state leading into Draw cmds. This includes the Pipeline state, dynamic state, shaders, and descriptor set state. VK_LAYER_LUNARG_draw_state validates the consistency and correctness between and within these states. VK_LAYER_LUNARG_draw_state also includes SPIR-V validation which functionality is recorded under the VK_LAYER_LUNARG_ShaderChecker section below.
-### VK_LAYER_LUNARG_DrawState Details Table
+### VK_LAYER_LUNARG_draw_state Details Table
| Check | Overview | ENUM DRAWSTATE_* | Relevant API | Testname | Notes/TODO |
| ----- | -------- | ---------------- | ------------ | -------- | ---------- |
| Validate DbgMarker exensions | Validates that DbgMarker extensions have been enabled before use | INVALID_EXTENSION | vkCmdDbgMarkerBegin vkCmdDbgMarkerEnd | TBD | None |
| Valid BeginCommandBuffer state | Must not call Begin on command buffers that are being recorded, and primary command buffers must specify VK_NULL_HANDLE for RenderPass or Framebuffer parameters, while secondary command buffers must provide non-null parameters, | BEGIN_CB_INVALID_STATE | vkBeginCommandBuffer | PrimaryCommandBufferFramebufferAndRenderpass SecondaryCommandBufferFramebufferAndRenderpass | None |
| Valid Command Buffer Reset | Can only reset individual command buffer that was allocated from a pool with VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set | INVALID_COMMAND_BUFFER_RESET | vkBeginCommandBuffer vkResetCommandBuffer | CommandBufferResetErrors | None |
-| PSO Bound | Verify that a properly created and valid pipeline object is bound to the CommandBuffer specified in these calls | NO_PIPELINE_BOUND | vkCmdBindDescriptorSets vkCmdBindVertexBuffers | PipelineNotBound | This check is currently more related to VK_LAYER_LUNARG_DrawState data structures and less about verifying that PSO is bound at all appropriate points in API. For API purposes, need to make sure this is checked at Draw time and any other relevant calls. |
-| Valid DescriptorPool | Verifies that the descriptor set pool object was properly created and is valid | INVALID_POOL | vkResetDescriptorPool vkAllocateDescriptorSets | None | This is just an internal layer data structure check. VK_LAYER_LUNARG_ParamChecker or VK_LAYER_LUNARG_ObjectTracker should really catch bad DSPool |
+| PSO Bound | Verify that a properly created and valid pipeline object is bound to the CommandBuffer specified in these calls | NO_PIPELINE_BOUND | vkCmdBindDescriptorSets vkCmdBindVertexBuffers | PipelineNotBound | This check is currently more related to VK_LAYER_LUNARG_draw_state data structures and less about verifying that PSO is bound at all appropriate points in API. For API purposes, need to make sure this is checked at Draw time and any other relevant calls. |
+| Valid DescriptorPool | Verifies that the descriptor set pool object was properly created and is valid | INVALID_POOL | vkResetDescriptorPool vkAllocateDescriptorSets | None | This is just an internal layer data structure check. VK_LAYER_LUNARG_param_checker or VK_LAYER_LUNARG_object_tracker should really catch bad DSPool |
| Valid DescriptorSet | Validate that descriptor set was properly created and is currently valid | INVALID_SET | vkCmdBindDescriptorSets | None | Is this needed other places (like Update/Clear descriptors) |
| Valid DescriptorSetLayout | Flag DescriptorSetLayout object that was not properly created | INVALID_LAYOUT | vkAllocateDescriptorSets | None | Anywhere else to check this? |
| Valid Pipeline | Flag VkPipeline object that was not properly created | INVALID_PIPELINE | vkCmdBindPipeline | InvalidPipeline | NA |
| Correct Clear Use | Warn user if CmdClear for Color or DepthStencil issued to Cmd Buffer prior to a Draw Cmd. RenderPass LOAD_OP_CLEAR is preferred in this case. | CLEAR_CMD_BEFORE_DRAW | vkCmdClearColorImage vkCmdClearDepthStencilImage | ClearCmdNoDraw | NA |
| Index Buffer Binding | Verify that an index buffer is bound at the point when an indexed draw is attempted. | INDEX_BUFFER_NOT_BOUND | vkCmdDrawIndexed vkCmdDrawIndexedIndirect | TODO | Implement validation test |
| Viewport and Scissors match | In PSO viewportCount and scissorCount must match. Also for each count that is non-zero, there corresponding data array ptr should be non-NULL. | VIEWPORT_SCISSOR_MISMATCH | vkCreateGraphicsPipelines vkCmdSetViewport vkCmdSetScissor | TODO | Implement validation test |
-| Valid Image Aspects for descriptor Updates | When updating ImageView for Descriptor Sets with layout of DEPTH_STENCIL type, the Image Aspect must not have both the DEPTH and STENCIL aspects set, but must have one of the two set. For COLOR_ATTACHMENT, aspect must have COLOR_BIT set. | INVALID_IMAGE_ASPECT | vkUpdateDescriptorSets | DepthStencilImageViewWithColorAspectBitError | This test hits Image layer error, but tough to create case that that skips that error and gets to VK_LAYER_LUNARG_DrawState error. |
+| Valid Image Aspects for descriptor Updates | When updating ImageView for Descriptor Sets with layout of DEPTH_STENCIL type, the Image Aspect must not have both the DEPTH and STENCIL aspects set, but must have one of the two set. For COLOR_ATTACHMENT, aspect must have COLOR_BIT set. | INVALID_IMAGE_ASPECT | vkUpdateDescriptorSets | DepthStencilImageViewWithColorAspectBitError | This test hits Image layer error, but tough to create case that that skips that error and gets to VK_LAYER_LUNARG_draw_state error. |
| Valid sampler descriptor Updates | An invalid sampler is used when updating SAMPLER descriptor. | SAMPLER_DESCRIPTOR_ERROR | vkUpdateDescriptorSets | SampleDescriptorUpdateError | Currently only making sure sampler handle is known, can add further validation for sampler parameters |
| Immutable sampler update consistency | Within a single write update, all sampler updates must use either immutable samplers or non-immutable samplers, but not a combination of both. | INCONSISTENT_IMMUTABLE_SAMPLER_UPDATE | vkUpdateDescriptorSets | None | Write a test for this case |
| Valid imageView descriptor Updates | An invalid imageView is used when updating *_IMAGE or *_ATTACHMENT descriptor. | IMAGEVIEW_DESCRIPTOR_ERROR | vkUpdateDescriptorSets | ImageViewDescriptorUpdateError | Currently only making sure imageView handle is known, can add further validation for imageView and underlying image parameters |
| Verify Memory Access Flags/Memory Barriers | Validate correct access flags for memory barriers | INVALID_BARRIER | vkCmdWaitEvents VkCmdPipelineBarrier | TBD | None |
| NA | Enum used for informational messages | NONE | | NA | None |
| NA | Enum used for errors in the layer itself. This does not indicate an app issue, but instead a bug in the layer. | INTERNAL_ERROR | | NA | None |
-| NA | Enum used when VK_LAYER_LUNARG_Drawstate attempts to allocate memory for its own internal use and is unable to. | OUT_OF_MEMORY | | NA | None |
-| NA | Enum used when VK_LAYER_LUNARG_Drawstate attempts to allocate memory for its own internal use and is unable to. | OUT_OF_MEMORY | | NA | None |
+| NA | Enum used when VK_LAYER_LUNARG_draw_state attempts to allocate memory for its own internal use and is unable to. | OUT_OF_MEMORY | | NA | None |
+| NA | Enum used when VK_LAYER_LUNARG_draw_state attempts to allocate memory for its own internal use and is unable to. | OUT_OF_MEMORY | | NA | None |
-### VK_LAYER_LUNARG_DrawState Pending Work
-Additional checks to be added to VK_LAYER_LUNARG_DrawState
+### VK_LAYER_LUNARG_draw_state Pending Work
+Additional checks to be added to VK_LAYER_LUNARG_draw_state
7. Lifetime validation (See [bug 13383](https://cvs.khronos.org/bugzilla/show_bug.cgi?id=13383))
8. XGL_DESCRIPTOR_SET
### VK_LAYER_LUNARG_ShaderChecker Overview
-The VK_LAYER_LUNARG_ShaderChecker functionality is part of VK_LAYER_LUNARG_DrawState layer and it inspects the SPIR-V shader images and fixed function pipeline stages at PSO creation time.
+The VK_LAYER_LUNARG_ShaderChecker functionality is part of VK_LAYER_LUNARG_draw_state layer and it inspects the SPIR-V shader images and fixed function pipeline stages at PSO creation time.
It flags errors when inconsistencies are found across interfaces between shader stages. The exact behavior of the checks
depends on the pair of pipeline stages involved.
- Additional test cases for variously broken SPIRV images
- Validation of a single SPIRV image in isolation (the spec describes many constraints)
-## VK_LAYER_LUNARG_ParamChecker
+## VK_LAYER_LUNARG_param_checker
-### VK_LAYER_LUNARG_ParamChecker Overview
+### VK_LAYER_LUNARG_param_checker Overview
-The VK_LAYER_LUNARG_ParamChecker layer validates parameter values and flags errors for any values that are outside of acceptable values for the given parameter.
+The VK_LAYER_LUNARG_param_checker layer validates parameter values and flags errors for any values that are outside of acceptable values for the given parameter.
-### VK_LAYER_LUNARG_ParamChecker Details Table
+### VK_LAYER_LUNARG_param_checker Details Table
| Check | Overview | ENUM | Relevant API | Testname | Notes/TODO |
| ----- | -------- | ---------------- | ------------ | -------- | ---------- |
| Call results, Output Parameters | Return values are checked for VK_SUCCESS, returned pointers are checked to be NON-NULL, enumerated types of return values are checked to be within the defined range. | NA | vkEnumeratePhysicalDevices vkGetPhysicalDeviceFeatures vkGetPhysicalDeviceFormatProperties vkGetPhysicalDeviceImageFormatProperties vkGetPhysicalDeviceLimits vkGetPhysicalDeviceProperties vkGetPhysicalDeviceQueueFamilyProperties vkGetPhysicalDeviceMemoryProperties vkGetDeviceQueue vkQueueSubmit vkQueueWaitIdle vkDeviceWaitIdle vkAllocateMemory vkFreeMemory vkMapMemory vkUnmapMemory vkFlushMappedMemoryRanges vkInvalidateMappedMemoryRanges vkGetDeviceMemoryCommitment vkBindBufferMemory vkBindImageMemory vkGetBufferMemoryRequirements vkGetImageMemoryRequirements vkGetImageSparseMemoryRequirements vkGetPhysicalDeviceSparseImageFormatProperties vkQueueBindSparse vkCreateFence vkDestroyFence vkResetFences vkGetFenceStatus vkWaitForFences vkCreateSemaphore vkDestroySemaphore vkCreateEvent vkDestroyEvent vkGetEventStatus vkSetEvent vkResetEvent vkCreateQueryPool vkDestroyQueryPool vkGetQueryPoolResults vkCreateBuffer vkDestroyBuffer vkCreateBufferView vkDestroyBufferView vkCreateImage vkDestroyImage vkGetImageSubresourceLayout vkCreateImageView vkDestroyImageView vkDestroyShaderModule vkCreatePipelineCache vkDestroyPipelineCache vkGetPipelineCacheData vkMergePipelineCaches vkCreateGraphicsPipelines vkCreateComputePipelines vkDestroyPipeline vkCreatePipelineLayout vkDestroyPipelineLayout vkCreateSampler vkDestroySampler vkCreateDescriptorSetLayout vkDestroyDescriptorSetLayout vkCreateDescriptorPool vkDestroyDescriptorPool vkResetDescriptorPool vkAllocateDescriptorSets vkFreeDescriptorSets vkUpdateDescriptorSets vkCreateFramebuffer vkDestroyFramebuffer vkCreateRenderPass vkDestroyRenderPass vkGetRenderAreaGranularity vkCreateCommandPool vkDestroyCommandPool vkResetCommandPool vkAllocateCommandBuffers vkFreeCommandBuffers vkBeginCommandBuffer vkEndCommandBuffer vkResetCommandBuffer vkCmdBindPipeline vkCmdBindDescriptorSets vkCmdBindIndexBuffer vkCmdBindVertexBuffers vkCmdDraw vkCmdDrawIndexed vkCmdDrawIndirect vkCmdDrawIndexedIndirect vkCmdDispatch vkCmdDispatchIndirect vkCmdCopyBuffer vkCmdCopyImage vkCmdBlitImage vkCmdCopyBufferToImage vkCmdCopyImageToBuffer vkCmdUpdateBuffer vkCmdFillBuffer vkCmdClearColorImage vkCmdClearDepthStencilImage vkCmdClearAttachments vkCmdResolveImage vkCmdSetEvent vkCmdResetEvent vkCmdWaitEvents vkCmdPipelineBarrier vkCmdBeginQuery vkCmdEndQuery vkCmdResetQueryPool vkCmdWriteTimestamp vkCmdCopyQueryPoolResults vkCmdPushConstants vkCmdBeginRenderPass vkCmdNextSubpass vkCmdEndRenderPass vkCmdExecuteCommands | TBD | NA |
| NA | Enum used for informational messages | NONE | | NA | None |
-### VK_LAYER_LUNARG_ParamChecker Pending Work
+### VK_LAYER_LUNARG_param_checker Pending Work
Additional work to be done
1. Source2 was creating a VK_FORMAT_R8_SRGB texture (and image view) which was not supported by the underlying implementation (rendersystemtest imageformat test). Checking that formats are supported by the implementation is something the validation layer could do using the VK_FORMAT_INFO_TYPE_PROPERTIES query. There are probably a bunch of checks here you could be doing around vkCreateImage formats along with whether image/color/depth attachment views are valid. I’m not sure how much of this is already there.
8. Check for valid VkIndexType in vkCmdBindIndexBuffer() should be in PreCmdBindIndexBuffer() call
9. Check for valid VkPipelineBindPoint in vkCmdBindPipeline() & vkCmdBindDescriptorSets() should be in PreCmdBindPipeline() & PreCmdBindDescriptorSets() calls respectively.
-## VK_LAYER_LUNARG_Image
+## VK_LAYER_LUNARG_image
-### VK_LAYER_LUNARG_Image Layer Overview
+### VK_LAYER_LUNARG_image Layer Overview
-The VK_LAYER_LUNARG_Image layer is responsible for validating format-related information and enforcing format restrictions.
+The VK_LAYER_LUNARG_image layer is responsible for validating format-related information and enforcing format restrictions.
-### VK_LAYER_LUNARG_Image Layer Details Table
+### VK_LAYER_LUNARG_image Layer Details Table
DETAILS TABLE PENDING
| Verify Image Format Limits | Verifies that image creation parameters are with the device format limits | INVALID_FORMAT_LIMITS_VIOLATION | vkCreateImage | TBD | NA |
| NA | Enum used for informational messages | NONE | | NA | None |
-### VK_LAYER_LUNARG_Image Pending Work
+### VK_LAYER_LUNARG_image Pending Work
Additional work to be done
-## VK_LAYER_LUNARG_MemTracker
+## VK_LAYER_LUNARG_mem_tracker
-### VK_LAYER_LUNARG_MemTracker Overview
+### VK_LAYER_LUNARG_mem_tracker Overview
-The VK_LAYER_LUNARG_MemTracker layer tracks memory objects and references and validates that they are managed correctly by the application. This includes tracking object bindings, memory hazards, and memory object lifetimes. VK_LAYER_LUNARG_MemTracker validates several other hazard-related issues related to command buffers, fences, and memory mapping.
+The VK_LAYER_LUNARG_mem_tracker layer tracks memory objects and references and validates that they are managed correctly by the application. This includes tracking object bindings, memory hazards, and memory object lifetimes. VK_LAYER_LUNARG_mem_tracker validates several other hazard-related issues related to command buffers, fences, and memory mapping.
-### VK_LAYER_LUNARG_MemTracker Details Table
+### VK_LAYER_LUNARG_mem_tracker Details Table
| Check | Overview | ENUM MEMTRACK_* | Relevant API | Testname | Notes/TODO |
| ----- | -------- | ---------------- | ------------ | -------- | ---------- |
| Free Referenced Memory | Checks to see if memory being freed still has current references | FREED_MEM_REF | vmFreeMemory | FreeBoundMemory | NA |
| Memory Properly Bound | Validate that the memory object referenced in the call was properly created, is currently valid, and is properly bound to the object | MISSING_MEM_BINDINGS | vkCmdDrawIndirect vkCmdDrawIndexedIndirect vkCmdDispatchIndirect vkCmdCopyBuffer vkCmdCopyQueryPoolResults vkCmdCopyImage vkCmdBlitImage vkCmdCopyBufferToImage vkCmdCopyImageToBuffer vkCmdUpdateBuffer vkCmdFillBuffer vkCmdClearColorImage vkCmdClearDepthStencilImage vkCmdResolveImage | NA | NA |
| Valid Object | Verifies that the specified Vulkan object was created properly and is currently valid | INVALID_OBJECT | vkCmdBindPipeline vkCmdDrawIndirect vkCmdDrawIndexedIndirect vkCmdDispatchIndirect vkCmdCopyBuffer vkCmdCopyImage vkCmdBlitImage vkCmdCopyBufferToImage vkCmdCopyImageToBuffer vkCmdUpdateBuffer vkCmdFillBuffer vkCmdClearColorImage vkCmdClearDepthStencilImage vkCmdResolveImage | NA | NA |
-| Bind Invalid Memory | Validate that memory object was correctly created, that the command buffer object was correctly created, and that both are currently valid objects. | MEMORY_BINDING_ERROR | vkQueueBindSparse vkCmdDrawIndirect vkCmdDrawIndexedIndirect vkCmdDispatchIndirect vkCmdCopyBuffer vkCmdCopyImage vkCmdBlitImage vkCmdCopyBufferToImage vkCmdCopyImageToBuffer vkCmdUpdateBuffer vkCmdFillBuffer vkCmdClearColorImage vkCmdClearDepthStencilImage vkCmdResolveImage | NA | The valid Object checks are primarily the responsibilty of VK_LAYER_LUNARG_ObjectTracker layer, so these checks are more of a backup in case VK_LAYER_LUNARG_ObjectTracker is not enabled |
+| Bind Invalid Memory | Validate that memory object was correctly created, that the command buffer object was correctly created, and that both are currently valid objects. | MEMORY_BINDING_ERROR | vkQueueBindSparse vkCmdDrawIndirect vkCmdDrawIndexedIndirect vkCmdDispatchIndirect vkCmdCopyBuffer vkCmdCopyImage vkCmdBlitImage vkCmdCopyBufferToImage vkCmdCopyImageToBuffer vkCmdUpdateBuffer vkCmdFillBuffer vkCmdClearColorImage vkCmdClearDepthStencilImage vkCmdResolveImage | NA | The valid Object checks are primarily the responsibilty of VK_LAYER_LUNARG_object_tracker layer, so these checks are more of a backup in case VK_LAYER_LUNARG_object_tracker is not enabled |
| Objects Not Destroyed | Verify all objects destroyed at DestroyDevice time | MEMORY_LEAK | vkDestroyDevice | NA | NA |
| Memory Mapping State | Verifies that mapped memory is CPU-visible | INVALID_STATE | vkMapMemory | MapMemWithoutHostVisibleBit | NA |
| Command Buffer Synchronization | Command Buffer must be complete before BeginCommandBuffer or ResetCommandBuffer can be called | RESET_CB_WHILE_IN_FLIGHT | vkBeginCommandBuffer vkResetCommandBuffer | CallBeginCommandBufferBeforeCompletion CallBeginCommandBufferBeforeCompletion | NA |
| NA | Enum used for informational messages | NONE | | NA | None |
| NA | Enum used for errors in the layer itself. This does not indicate an app issue, but instead a bug in the layer. | INTERNAL_ERROR | | NA | None |
-### VK_LAYER_LUNARG_MemTracker Pending Work
+### VK_LAYER_LUNARG_mem_tracker Pending Work
-#### VK_LAYER_LUNARG_MemTracker Enhancements
+#### VK_LAYER_LUNARG_mem_tracker Enhancements
1. Flag any memory hazards: Validate that the pipeline barriers for buffers are sufficient to avoid hazards
2. Make sure that the XGL_IMAGE_VIEW_ATTACH_INFO.layout matches the layout of the image as determined by the last IMAGE_MEMORY_BARRIER
12. Modify INVALID_FENCE_STATE to be WARNINGs instead of ERROR
13. Report destroy or modify of resources in use on queues and not cleared by fence or WaitIdle. Could be fence, semaphore, or objects used by submitted CommandBuffers.
-## VK_LAYER_LUNARG_ObjectTracker
+## VK_LAYER_LUNARG_object_tracker
-### VK_LAYER_LUNARG_ObjectTracker Overview
+### VK_LAYER_LUNARG_object_tracker Overview
-The VK_LAYER_LUNARG_ObjectTracker layer maintains a record of all Vulkan objects. It flags errors when invalid objects are used and at DestroyInstance time it flags any objects that were not properly destroyed.
+The VK_LAYER_LUNARG_object_tracker layer maintains a record of all Vulkan objects. It flags errors when invalid objects are used and at DestroyInstance time it flags any objects that were not properly destroyed.
-### VK_LAYER_LUNARG_ObjectTracker Details Table
+### VK_LAYER_LUNARG_object_tracker Details Table
| Check | Overview | ENUM OBJTRACK_* | Relevant API | Testname | Notes/TODO |
| ----- | -------- | ---------------- | ------------ | -------- | ---------- |
| NA | Enum used for informational messages | NONE | | NA | None |
| NA | Enum used for errors in the layer itself. This does not indicate an app issue, but instead a bug in the layer. | INTERNAL_ERROR | | NA | None |
-### VK_LAYER_LUNARG_ObjectTracker Pending Work
+### VK_LAYER_LUNARG_object_tracker Pending Work
4. Verify images have CmdPipelineBarrier layouts matching new layout parameters to Cmd*Image* functions
6. For specific object instances that are allowed to be NULL, update object validation to verify that such objects are either NULL or valid
9. Use reference counting for non-dispatchable objects. Multiple object creation calls may return identical handles.
10. Update codegen for destroy_obj & validate_obj to generate all of the correct signatures and use the generated code
-## VK_LAYER_LUNARG_Threading
+## VK_LAYER_LUNARG_threading
-### VK_LAYER_LUNARG_Threading Overview
+### VK_LAYER_LUNARG_threading Overview
-The VK_LAYER_LUNARG_Threading layer checks for simultaneous use of objects by calls from multiple threads.
+The VK_LAYER_LUNARG_threading layer checks for simultaneous use of objects by calls from multiple threads.
Application code is responsible for preventing simultaneous use of the same objects by certain calls that modify objects.
See [bug 13433](https://cvs.khronos.org/bugzilla/show_bug.cgi?id=13433) and
<https://cvs.khronos.org/svn/repos/oglc/trunk/nextgen/vulkan/function_properties.csv>
The layer can only observe when a mutual exclusion rule is actually violated.
It cannot insure that there is no latent race condition.
-### VK_LAYER_LUNARG_Threading Details Table
+### VK_LAYER_LUNARG_threading Details Table
| Check | Overview | ENUM THREADING_CHECKER_* | Relevant API | Testname | Notes/TODO |
| ----- | -------- | ---------------- | ---------------- | -------- | ---------- |
| Thread Reentrancy | Detects cases of a single thread calling Vulkan reentrantly | SINGLE_THREAD_REUSE | vkQueueSubmit vkFreeMemory vkMapMemory vkUnmapMemory vkFlushMappedMemoryRanges vkInvalidateMappedMemoryRanges vkBindBufferMemory vkBindImageMemory vkQueueBindSparse vkDestroySemaphore vkDestroyBuffer vkDestroyImage vkDestroyDescriptorPool vkResetDescriptorPool vkAllocateDescriptorSets vkFreeDescriptorSets vkFreeCommandBuffers vkBeginCommandBuffer vkEndCommandBuffer vkResetCommandBuffer vkCmdBindPipeline vkCmdSetViewport vkCmdSetBlendConstants vkCmdSetLineWidth vkCmdSetDepthBias vkCmdSetDepthBounds vkCmdSetStencilCompareMask vkCmdSetStencilWriteMask vkCmdSetStencilReference vkCmdBindDescriptorSets vkCmdBindIndexBuffer vkCmdBindVertexBuffers vkCmdDraw vkCmdDrawIndexed vkCmdDrawIndirect vkCmdDrawIndexedIndirect vkCmdDispatch vkCmdDispatchIndirect vkCmdCopyBuffer vkCmdCopyImage vkCmdBlitImage vkCmdCopyBufferToImage vkCmdCopyImageToBuffer vkCmdUpdateBuffer vkCmdFillBuffer vkCmdClearColorImage vkCmdClearDepthStencilImage vkCmdClearAttachments vkCmdResolveImage vkCmdSetEvent vkCmdResetEvent vkCmdWaitEvents vkCmdPipelineBarrier vkCmdBeginQuery vkCmdEndQuery vkCmdResetQueryPool vkCmdWriteTimestamp vkCmdCopyQueryPoolResults vkCmdBeginRenderPass vkCmdNextSubpass vkCmdPushConstants vkCmdEndRenderPass vkCmdExecuteCommands | ??? | NA |
| NA | Enum used for informational messages | NONE | | NA | None |
-### VK_LAYER_LUNARG_Threading Pending Work
+### VK_LAYER_LUNARG_threading Pending Work
Additional work to be done
-## VK_LAYER_LUNARG_DeviceLimits
+## VK_LAYER_LUNARG_device_limits
-### VK_LAYER_LUNARG_DeviceLimits Overview
+### VK_LAYER_LUNARG_device_limits Overview
-This layer is a work in progress. VK_LAYER_LUNARG_DeviceLimits layer is intended to capture two broad categories of errors:
+This layer is a work in progress. VK_LAYER_LUNARG_device_limits layer is intended to capture two broad categories of errors:
1. Incorrect use of APIs to query device capabilities
2. Attempt to use API functionality beyond the capability of the underlying device
For the first category, the layer tracks which calls are made and flags errors if calls are excluded that should not be, or if call sequencing is incorrect. An example is an app that assumes attempts to Query and use queues without ever having called vkGetPhysicalDeviceQueueFamilyProperties(). Also, if an app is calling vkGetPhysicalDeviceQueueFamilyProperties() to retrieve properties with some assumed count for array size instead of first calling vkGetPhysicalDeviceQueueFamilyProperties() w/ a NULL pQueueFamilyProperties parameter in order to query the actual count.
-For the second category of errors, VK_LAYER_LUNARG_DeviceLimits stores its own internal record of underlying device capabilities and flags errors if requests are made beyond those limits. Most (all?) of the limits are queried via vkGetPhysicalDevice* calls.
+For the second category of errors, VK_LAYER_LUNARG_device_limits stores its own internal record of underlying device capabilities and flags errors if requests are made beyond those limits. Most (all?) of the limits are queried via vkGetPhysicalDevice* calls.
-### VK_LAYER_LUNARG_DeviceLimits Details Table
+### VK_LAYER_LUNARG_device_limits Details Table
| Check | Overview | ENUM DEVLIMITS_* | Relevant API | Testname | Notes/TODO |
| ----- | -------- | ---------------- | ---------------- | -------- | ---------- |
-| Valid instance | If an invalid instance is used, this error will be flagged | INVALID_INSTANCE | vkEnumeratePhysicalDevices | NA | VK_LAYER_LUNARG_ObjectTracker should also catch this so if we made sure VK_LAYER_LUNARG_ObjectTracker was always on top, we could avoid this check |
-| Valid physical device | Enum used for informational messages | INVALID_PHYSICAL_DEVICE | vkEnumeratePhysicalDevices | NA | VK_LAYER_LUNARG_ObjectTracker should also catch this so if we made sure VK_LAYER_LUNARG_ObjectTracker was always on top, we could avoid this check |
+| Valid instance | If an invalid instance is used, this error will be flagged | INVALID_INSTANCE | vkEnumeratePhysicalDevices | NA | VK_LAYER_LUNARG_object_tracker should also catch this so if we made sure VK_LAYER_LUNARG_object_tracker was always on top, we could avoid this check |
+| Valid physical device | Enum used for informational messages | INVALID_PHYSICAL_DEVICE | vkEnumeratePhysicalDevices | NA | VK_LAYER_LUNARG_object_tracker should also catch this so if we made sure VK_LAYER_LUNARG_object_tracker was always on top, we could avoid this check |
| Querying array counts | For API calls where an array count should be queried with an initial call and a NULL array pointer, verify that such a call was made before making a call with non-null array pointer. | MUST_QUERY_COUNT | vkEnumeratePhysicalDevices vkGetPhysicalDeviceQueueFamilyProperties | NA | Create focused test |
| Array count value | For API calls where an array of details is queried, verify that the size of the requested array matches the size of the array supported by the device. | COUNT_MISMATCH | vkEnumeratePhysicalDevices vkGetPhysicalDeviceQueueFamilyProperties | NA | Create focused test |
| Queue Creation | When creating/requesting queues, make sure that QueueFamilyPropertiesIndex and index/count within that queue family are valid. | INVALID_QUEUE_CREATE_REQUEST | vkGetDeviceQueue vkCreateDevice | NA | Create focused test |
| Alignment | When filling a buffer, data should be aligned on 4 byte boundaries | LIMITS_VIOLATION | vkCmdFillBuffer | UpdateBufferAlignment | NA |
| NA | Enum used for informational messages | NONE | | NA | None |
-### VK_LAYER_LUNARG_DeviceLimits Pending Work
+### VK_LAYER_LUNARG_device_limits Pending Work
1. For all Formats, call vkGetPhysicalDeviceFormatProperties to pull their properties for the underlying device. After that point, if the app attempts to use any formats in violation of those properties, flag errors (this is done for Images).
-## VK_LAYER_LUNARG_Swapchain
+## VK_LAYER_LUNARG_swapchain
### Swapchain Overview
-This layer is a work in progress. VK_LAYER_LUNARG_Swapchain layer is intended to ...
+This layer is a work in progress. VK_LAYER_LUNARG_swapchain layer is intended to ...
-### VK_LAYER_LUNARG_Swapchain Details Table
+### VK_LAYER_LUNARG_swapchain Details Table
| Check | Overview | ENUM SWAPCHAIN_* | Relevant API | Testname | Notes/TODO |
| ----- | -------- | ---------------- | ------------ | -------- | ---------- |
| Index too large | Validates that an image index is within the number of images in a swapchain | INDEX_TOO_LARGE | vkQueuePresentKHR | NA | None |
| Can't present a non-owned image | Validates that application only presents images that it owns | INDEX_NOT_IN_USE | vkQueuePresentKHR | NA | None |
-### VK_LAYER_LUNARG_Swapchain Pending Work
-Additional checks to be added to VK_LAYER_LUNARG_Swapchain
+### VK_LAYER_LUNARG_swapchain Pending Work
+Additional checks to be added to VK_LAYER_LUNARG_swapchain
1. Check that the queue used for presenting was checked/valid during vkGetPhysicalDeviceSurfaceSupportKHR.
2. One issue that has already come up is correct UsageFlags for WSI SwapChains and SurfaceProperties.
# Non-validation Layer Details
-## VK_LAYER_LUNARG_APIDump
+## VK_LAYER_LUNARG_api_dump
-VK_LAYER_LUNARG_APIDump layer is used for dumping a stream of all the Vulkan API calls that are made, along with details of the parameters to those calls.
+VK_LAYER_LUNARG_api_dump layer is used for dumping a stream of all the Vulkan API calls that are made, along with details of the parameters to those calls.
-### VK_LAYER_LUNARG_APIDump Pending Work
+### VK_LAYER_LUNARG_api_dump Pending Work
1. vkAllocateDescriptorSets does not correctly print out all of the created DescriptorSets (no array printing following main API txt)
--- /dev/null
+{
+ "file_format_version" : "1.0.0",
+ "layer" : {
+ "name": "VK_LAYER_LUNARG_api_dump",
+ "type": "GLOBAL",
+ "library_path": ".\\VkLayer_api_dump.dll",
+ "api_version": "0.210.0",
+ "implementation_version": "1",
+ "description": "LunarG debug layer"
+ }
+}
--- /dev/null
+{
+ "file_format_version" : "1.0.0",
+ "layer" : {
+ "name": "VK_LAYER_LUNARG_basic",
+ "type": "GLOBAL",
+ "library_path": ".\\VkLayer_basic.dll",
+ "api_version": "0.210.0",
+ "implementation_version": "1",
+ "description": "LunarG Sample Layer",
+ "device_extensions": [
+ {
+ "name": "VK_LUNARG_LayerExtension1",
+ "spec_version": "0",
+ "entrypoints": ["vkLayerExtension1"]
+ }
+ ]
+ }
+}
--- /dev/null
+{
+ "file_format_version" : "1.0.0",
+ "layer" : {
+ "name": "VK_LAYER_LUNARG_device_limits",
+ "type": "GLOBAL",
+ "library_path": ".\\VkLayer_device_limits.dll",
+ "api_version": "0.210.0",
+ "implementation_version": "1",
+ "description": "LunarG Validation Layer",
+ "instance_extensions": [
+ {
+ "name": "VK_EXT_debug_report",
+ "spec_version": "2"
+ }
+ ]
+ }
+}
--- /dev/null
+{
+ "file_format_version" : "1.0.0",
+ "layer" : {
+ "name": "VK_LAYER_LUNARG_draw_state",
+ "type": "GLOBAL",
+ "library_path": ".\\VkLayer_draw_state.dll",
+ "api_version": "0.210.0",
+ "implementation_version": "1",
+ "description": "LunarG Validation Layer",
+ "instance_extensions": [
+ {
+ "name": "VK_EXT_debug_report",
+ "spec_version": "2"
+ }
+ ],
+ "device_extensions": [
+ {
+ "name": "VK_LUNARG_DEBUG_MARKER",
+ "spec_version": "0",
+ "entrypoints": ["vkCmdDbgMarkerBegin","vkCmdDbgMarkerEnd"]
+ }
+ ]
+ }
+}
--- /dev/null
+{
+ "file_format_version" : "1.0.0",
+ "layer" : {
+ "name": "VK_LAYER_LUNARG_generic",
+ "type": "GLOBAL",
+ "library_path": ".\\VkLayer_generic.dll",
+ "api_version": "0.210.0",
+ "implementation_version": "1",
+ "description": "LunarG sample layer"
+ }
+}
--- /dev/null
+{
+ "file_format_version" : "1.0.0",
+ "layer" : {
+ "name": "VK_LAYER_LUNARG_image",
+ "type": "GLOBAL",
+ "library_path": ".\\VkLayer_image.dll",
+ "api_version": "0.210.0",
+ "implementation_version": "1",
+ "description": "LunarG Validation Layer",
+ "instance_extensions": [
+ {
+ "name": "VK_EXT_debug_report",
+ "spec_version": "2"
+ }
+ ]
+ }
+}
--- /dev/null
+{
+ "file_format_version" : "1.0.0",
+ "layer" : {
+ "name": "VK_LAYER_LUNARG_mem_tracker",
+ "type": "GLOBAL",
+ "library_path": ".\\VkLayer_mem_tracker.dll",
+ "api_version": "0.210.0",
+ "implementation_version": "1",
+ "description": "LunarG Validation Layer",
+ "instance_extensions": [
+ {
+ "name": "VK_EXT_debug_report",
+ "spec_version": "2"
+ }
+ ]
+ }
+}
--- /dev/null
+{
+ "file_format_version" : "1.0.0",
+ "layer" : {
+ "name": "VK_LAYER_LUNARG_multi1",
+ "type": "DEVICE",
+ "library_path": ".\\VkLayer_multi.dll",
+ "api_version": "0.210.0",
+ "implementation_version": "1",
+ "description": "LunarG Sample multiple layer per library",
+ "functions" : {
+ "vkGetDeviceProcAddr" : "multi1GetDeviceProcAddr"
+ }
+ },
+ "layer" : {
+ "name": "VK_LAYER_LUNARG_multi2",
+ "type": "INSTANCE",
+ "library_path": ".\\VkLayer_multi.dll",
+ "api_version": "0.210.0",
+ "implementation_version": "1",
+ "description": "LunarG Sample multiple layer per library",
+ "functions" : {
+ "vkGetInstanceProcAddr" : "multi2GetInstanceProcAddr"
+ }
+ }
+}
--- /dev/null
+{
+ "file_format_version" : "1.0.0",
+ "layer" : {
+ "name": "VK_LAYER_LUNARG_object_tracker",
+ "type": "GLOBAL",
+ "library_path": ".\\VkLayer_object_tracker.dll",
+ "api_version": "0.210.0",
+ "implementation_version": "1",
+ "description": "LunarG Validation Layer",
+ "instance_extensions": [
+ {
+ "name": "VK_EXT_debug_report",
+ "spec_version": "2"
+ }
+ ]
+ }
+}
--- /dev/null
+{
+ "file_format_version" : "1.0.0",
+ "layer" : {
+ "name": "VK_LAYER_LUNARG_param_checker",
+ "type": "GLOBAL",
+ "library_path": ".\\VkLayer_param_checker.dll",
+ "api_version": "0.210.0",
+ "implementation_version": "1",
+ "description": "LunarG Validation Layer",
+ "instance_extensions": [
+ {
+ "name": "VK_EXT_debug_report",
+ "spec_version": "2"
+ }
+ ]
+ }
+}
--- /dev/null
+{
+ "file_format_version" : "1.0.0",
+ "layer" : {
+ "name": "VK_LAYER_LUNARG_screenshot",
+ "type": "GLOBAL",
+ "library_path": ".\\VkLayer_screenshot.dll",
+ "api_version": "0.210.0",
+ "implementation_version": "1",
+ "description": "LunarG image capture layer"
+ }
+}
--- /dev/null
+{
+ "file_format_version" : "1.0.0",
+ "layer" : {
+ "name": "VK_LAYER_LUNARG_swapchain",
+ "type": "GLOBAL",
+ "library_path": ".\\VkLayer_swapchain.dll",
+ "api_version": "0.210.0",
+ "implementation_version": "1",
+ "description": "LunarG Validation Layer",
+ "instance_extensions": [
+ {
+ "name": "VK_EXT_debug_report",
+ "spec_version": "2"
+ }
+ ]
+ }
+}
--- /dev/null
+{
+ "file_format_version" : "1.0.0",
+ "layer" : {
+ "name": "VK_LAYER_LUNARG_threading",
+ "type": "GLOBAL",
+ "library_path": ".\\VkLayer_threading.dll",
+ "api_version": "0.210.0",
+ "implementation_version": "1",
+ "description": "LunarG Validation Layer",
+ "instance_extensions": [
+ {
+ "name": "VK_EXT_debug_report",
+ "spec_version": "2"
+ }
+ ]
+ }
+}
+++ /dev/null
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_APIDump",
- "type": "GLOBAL",
- "library_path": ".\\VKLayerAPIDump.dll",
- "api_version": "0.210.0",
- "implementation_version": "1",
- "description": "LunarG debug layer"
- }
-}
+++ /dev/null
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_Basic",
- "type": "GLOBAL",
- "library_path": ".\\VKLayerBasic.dll",
- "api_version": "0.210.0",
- "implementation_version": "1",
- "description": "LunarG Sample Layer",
- "device_extensions": [
- {
- "name": "VK_LUNARG_LayerExtension1",
- "spec_version": "0",
- "entrypoints": ["vkLayerExtension1"]
- }
- ]
- }
-}
+++ /dev/null
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_DeviceLimits",
- "type": "GLOBAL",
- "library_path": ".\\VKLayerDeviceLimits.dll",
- "api_version": "0.210.0",
- "implementation_version": "1",
- "description": "LunarG Validation Layer",
- "instance_extensions": [
- {
- "name": "VK_EXT_debug_report",
- "spec_version": "2"
- }
- ]
- }
-}
+++ /dev/null
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_DrawState",
- "type": "GLOBAL",
- "library_path": ".\\VKLayerDrawState.dll",
- "api_version": "0.210.0",
- "implementation_version": "1",
- "description": "LunarG Validation Layer",
- "instance_extensions": [
- {
- "name": "VK_EXT_debug_report",
- "spec_version": "2"
- }
- ],
- "device_extensions": [
- {
- "name": "VK_LUNARG_DEBUG_MARKER",
- "spec_version": "0",
- "entrypoints": ["vkCmdDbgMarkerBegin","vkCmdDbgMarkerEnd"]
- }
- ]
- }
-}
+++ /dev/null
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_Generic",
- "type": "GLOBAL",
- "library_path": "./libVKLayerGeneric.so",
- "api_version": "0.210.0",
- "implementation_version": "1",
- "description": "LunarG Sample Layer"
- }
-}
+++ /dev/null
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_Image",
- "type": "GLOBAL",
- "library_path": ".\\VKLayerImage.dll",
- "api_version": "0.210.0",
- "implementation_version": "1",
- "description": "LunarG Validation Layer",
- "instance_extensions": [
- {
- "name": "VK_EXT_debug_report",
- "spec_version": "2"
- }
- ]
- }
-}
+++ /dev/null
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_MemTracker",
- "type": "GLOBAL",
- "library_path": ".\\VKLayerMemTracker.dll",
- "api_version": "0.210.0",
- "implementation_version": "1",
- "description": "LunarG Validation Layer",
- "instance_extensions": [
- {
- "name": "VK_EXT_debug_report",
- "spec_version": "2"
- }
- ]
- }
-}
+++ /dev/null
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_multi1",
- "type": "DEVICE",
- "library_path": ".\\VKLayerMulti.dll",
- "api_version": "0.210.0",
- "implementation_version": "1",
- "description": "LunarG Sample multiple layer per library",
- "functions" : {
- "vkGetDeviceProcAddr" : "multi1GetDeviceProcAddr"
- }
- },
- "layer" : {
- "name": "VK_LAYER_LUNARG_multi2",
- "type": "INSTANCE",
- "library_path": ".\\VKLayerMulti.dll",
- "api_version": "0.210.0",
- "implementation_version": "1",
- "description": "LunarG Sample multiple layer per library",
- "functions" : {
- "vkGetInstanceProcAddr" : "multi2GetInstanceProcAddr"
- }
- }
-}
+++ /dev/null
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_ObjectTracker",
- "type": "GLOBAL",
- "library_path": ".\\VKLayerObjectTracker.dll",
- "api_version": "0.210.0",
- "implementation_version": "1",
- "description": "LunarG Validation Layer",
- "instance_extensions": [
- {
- "name": "VK_EXT_debug_report",
- "spec_version": "2"
- }
- ]
- }
-}
+++ /dev/null
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_ParamChecker",
- "type": "GLOBAL",
- "library_path": ".\\VKLayerParamChecker.dll",
- "api_version": "0.210.0",
- "implementation_version": "1",
- "description": "LunarG Validation Layer",
- "instance_extensions": [
- {
- "name": "VK_EXT_debug_report",
- "spec_version": "2"
- }
- ]
- }
-}
+++ /dev/null
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_ScreenShot",
- "type": "GLOBAL",
- "library_path": ".\\VKLayerScreenShot.dll",
- "api_version": "0.210.0",
- "implementation_version": "1",
- "description": "LunarG image capture layer"
- }
-}
+++ /dev/null
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_Swapchain",
- "type": "GLOBAL",
- "library_path": ".\\VKLayerSwapchain.dll",
- "api_version": "0.210.0",
- "implementation_version": "1",
- "description": "LunarG Validation Layer",
- "instance_extensions": [
- {
- "name": "VK_EXT_debug_report",
- "spec_version": "2"
- }
- ]
- }
-}
+++ /dev/null
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_Threading",
- "type": "GLOBAL",
- "library_path": ".\\VKLayerThreading.dll",
- "api_version": "0.210.0",
- "implementation_version": "1",
- "description": "LunarG Validation Layer",
- "instance_extensions": [
- {
- "name": "VK_EXT_debug_report",
- "spec_version": "2"
- }
- ]
- }
-}
"vkEnumerateInstanceLayerProperties",
"vkEnumerateInstanceExtensionProperties"
],
- "layerMulti": [
+ "layer_multi": [
"multi2GetInstanceProcAddr",
"multi1GetDeviceProcAddr"
]
return
self.library = self.argv[0]
- if self.library == "VKLayerMulti":
- self.exports = library_exports["layerMulti"]
+ if self.library == "VkLayer_multi":
+ self.exports = library_exports["layer_multi"]
else:
self.exports = library_exports[self.argv[1]]
body.append("EXPORTS")
for proto in self.exports:
- if self.library != "VKLayerSwapchain" or proto != "vkEnumerateInstanceExtensionProperties" and proto != "vkEnumerateInstanceLayerProperties":
+ if self.library != "VkLayerSwapchain" or proto != "vkEnumerateInstanceExtensionProperties" and proto != "vkEnumerateInstanceLayerProperties":
body.append( proto)
return "\n".join(body)
r_body.append(' VkDebugReportCallbackEXT* pCallback)')
r_body.append('{')
# Switch to this code section for the new per-instance storage and debug callbacks
- if self.layer_name == 'ObjectTracker' or self.layer_name == 'Threading':
+ if self.layer_name == 'object_tracker' or self.layer_name == 'threading':
r_body.append(' VkLayerInstanceDispatchTable *pInstanceTable = get_dispatch_table(%s_instance_table_map, instance);' % self.layer_name )
r_body.append(' VkResult result = pInstanceTable->CreateDebugReportCallbackEXT(instance, pCreateInfo, pAllocator, pCallback);')
r_body.append(' if (VK_SUCCESS == result) {')
r_body.append('VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT msgCallback, const VkAllocationCallbacks *pAllocator)')
r_body.append('{')
# Switch to this code section for the new per-instance storage and debug callbacks
- if self.layer_name == 'ObjectTracker' or self.layer_name == 'Threading':
+ if self.layer_name == 'object_tracker' or self.layer_name == 'threading':
r_body.append(' VkLayerInstanceDispatchTable *pInstanceTable = get_dispatch_table(%s_instance_table_map, instance);' % self.layer_name )
else:
r_body.append(' VkLayerInstanceDispatchTable *pInstanceTable = instance_dispatch_table(instance);')
r_body.append('VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDebugReportMessageEXT(VkInstance instance, VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objType, uint64_t object, size_t location, int32_t msgCode, const char *pLayerPrefix, const char *pMsg)')
r_body.append('{')
# Switch to this code section for the new per-instance storage and debug callbacks
- if self.layer_name == 'ObjectTracker' or self.layer_name == 'Threading':
+ if self.layer_name == 'object_tracker' or self.layer_name == 'threading':
r_body.append(' VkLayerInstanceDispatchTable *pInstanceTable = get_dispatch_table(%s_instance_table_map, instance);' % self.layer_name )
else:
r_body.append(' VkLayerInstanceDispatchTable *pInstanceTable = instance_dispatch_table(instance);')
r_body.append('}')
return "\n".join(r_body)
- def _gen_layer_get_global_extension_props(self, layer="Generic"):
+ def _gen_layer_get_global_extension_props(self, layer="generic"):
ggep_body = []
# generated layers do not provide any global extensions
ggep_body.append('%s' % self.lineinfo.get())
ggep_body.append('')
- if self.layer_name == 'ObjectTracker' or self.layer_name == 'Threading':
+ if self.layer_name == 'object_tracker' or self.layer_name == 'threading':
ggep_body.append('static const VkExtensionProperties instance_extensions[] = {')
ggep_body.append(' {')
ggep_body.append(' VK_EXT_DEBUG_REPORT_EXTENSION_NAME,')
ggep_body.append('};')
ggep_body.append('VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pCount, VkExtensionProperties* pProperties)')
ggep_body.append('{')
- if self.layer_name == 'ObjectTracker' or self.layer_name == 'Threading':
+ if self.layer_name == 'object_tracker' or self.layer_name == 'threading':
ggep_body.append(' return util_GetExtensionProperties(1, instance_extensions, pCount, pProperties);')
else:
ggep_body.append(' return util_GetExtensionProperties(0, NULL, pCount, pProperties);')
ggep_body.append('}')
return "\n".join(ggep_body)
- def _gen_layer_get_global_layer_props(self, layer="Generic"):
+ def _gen_layer_get_global_layer_props(self, layer="generic"):
ggep_body = []
- if layer == 'Generic':
+ if layer == 'generic':
# Do nothing, extension definition part of generic.h
ggep_body.append('%s' % self.lineinfo.get())
else:
ggep_body.append('}')
return "\n".join(ggep_body)
- def _gen_layer_get_physical_device_layer_props(self, layer="Generic"):
+ def _gen_layer_get_physical_device_layer_props(self, layer="generic"):
gpdlp_body = []
- if layer == 'Generic':
+ if layer == 'generic':
# Do nothing, extension definition part of generic.h
gpdlp_body.append('%s' % self.lineinfo.get())
else:
#
# New style of GPA Functions for the new layer_data/layer_logging changes
#
- if self.layer_name == 'ObjectTracker' or self.layer_name == 'Threading':
+ if self.layer_name == 'object_tracker' or self.layer_name == 'threading':
func_body.append("VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice device, const char* funcName)\n"
"{\n"
" PFN_vkVoidFunction addr;\n"
" if (device == VK_NULL_HANDLE) {\n"
" return NULL;\n"
" }\n")
- if self.layer_name == 'Generic':
+ if self.layer_name == 'generic':
func_body.append("\n"
" /* loader uses this to force layer initialization; device object is wrapped */\n"
" if (!strcmp(\"vkGetDeviceProcAddr\", funcName)) {\n"
" if (instance == VK_NULL_HANDLE) {\n"
" return NULL;\n"
" }\n")
- if self.layer_name == 'Generic':
+ if self.layer_name == 'generic':
func_body.append("\n"
" /* loader uses this to force layer initialization; instance object is wrapped */\n"
" if (!strcmp(\"vkGetInstanceProcAddr\", funcName)) {\n"
def _generate_layer_initialization(self, init_opts=False, prefix='vk', lockname=None, condname=None):
func_body = ["#include \"vk_dispatch_table_helper.h\""]
func_body.append('%s' % self.lineinfo.get())
- func_body.append('static void init%s(layer_data *my_data, const VkAllocationCallbacks *pAllocator)\n'
+ func_body.append('static void init_%s(layer_data *my_data, const VkAllocationCallbacks *pAllocator)\n'
'{\n' % self.layer_name)
if init_opts:
func_body.append('%s' % self.lineinfo.get())
def _generate_new_layer_initialization(self, init_opts=False, prefix='vk', lockname=None, condname=None):
func_body = ["#include \"vk_dispatch_table_helper.h\""]
func_body.append('%s' % self.lineinfo.get())
- func_body.append('static void init%s(layer_data *my_data, const VkAllocationCallbacks *pAllocator)\n'
+ func_body.append('static void init_%s(layer_data *my_data, const VkAllocationCallbacks *pAllocator)\n'
'{\n' % self.layer_name)
if init_opts:
func_body.append('%s' % self.lineinfo.get())
' layer_data *my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map);\n'
' sprintf(str, "At start of Generic layered %s\\n");\n'
' log_msg(my_data->report_data, VK_DEBUG_REPORT_INFO_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT,'
- ' (uint64_t)physicalDevice, 0, 0, (char *) "Generic", "%%s", (char *) str);\n'
+ ' (uint64_t)physicalDevice, 0, 0, (char *) "generic", "%%s", (char *) str);\n'
' %sdevice_dispatch_table(*pDevice)->%s;\n'
' if (result == VK_SUCCESS) {\n'
' my_data->report_data = layer_debug_report_create_device(my_data->report_data, *pDevice);\n'
' createDeviceRegisterExtensions(pCreateInfo, *pDevice);\n'
' }\n'
- ' sprintf(str, "Completed Generic layered %s\\n");\n'
- ' log_msg(my_data->report_data, VK_DEBUG_REPORT_INFO_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, (uint64_t)physicalDevice, 0, 0, (char *) "Generic", "%%s", (char *) str);\n'
+ ' sprintf(str, "Completed generic layered %s\\n");\n'
+ ' log_msg(my_data->report_data, VK_DEBUG_REPORT_INFO_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, (uint64_t)physicalDevice, 0, 0, (char *) "generic", "%%s", (char *) str);\n'
' %s'
'}' % (qual, decl, proto.name, ret_val, proto.c_call(), proto.name, stmt))
elif proto.name == "DestroyDevice":
' *pInstance,\n'
' pCreateInfo->enabledExtensionNameCount,\n'
' pCreateInfo->ppEnabledExtensionNames);\n'
- ' initGeneric(my_data, pAllocator);\n'
- ' sprintf(str, "Completed Generic layered %s\\n");\n'
- ' log_msg(my_data->report_data, VK_DEBUG_REPORT_INFO_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, (uint64_t)*pInstance, 0, 0, (char *) "Generic", "%%s", (char *) str);\n'
+ ' init_generic(my_data, pAllocator);\n'
+ ' sprintf(str, "Completed generic layered %s\\n");\n'
+ ' log_msg(my_data->report_data, VK_DEBUG_REPORT_INFO_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, (uint64_t)*pInstance, 0, 0, (char *) "generic", "%%s", (char *) str);\n'
' }\n'
' return result;\n'
'}\n' % (qual, decl, ret_val, proto.c_call(), proto.name))
return "\n\n".join(funcs)
def generate_body(self):
- self.layer_name = "Generic"
+ self.layer_name = "generic"
instance_extensions=[('msg_callback_get_proc_addr', []),
('wsi_enabled',
['vkGetPhysicalDeviceSurfaceSupportKHR',
header_txt.append('#include "vk_layer_table.h"')
header_txt.append('#include "vk_layer_extension_utils.h"')
header_txt.append('#include <unordered_map>')
- header_txt.append('#include "apidump.h"')
+ header_txt.append('#include "api_dump.h"')
header_txt.append('')
header_txt.append('static std::ofstream fileStream;')
header_txt.append('static std::string fileName = "vk_apidump.txt";')
header_txt.append(' if (fileName == "stdout")')
header_txt.append(' {')
header_txt.append(' outputStream = &std::cout;')
- header_txt.append(' (*outputStream) << endl << "APIDump output filename \'stdout\' specified. Writing to STDOUT instead of a file." << endl << endl;')
+ header_txt.append(' (*outputStream) << endl << "api_dump output filename \'stdout\' specified. Writing to STDOUT instead of a file." << endl << endl;')
header_txt.append(' } else {')
header_txt.append(' fileStream.open(fileName);')
header_txt.append(' if ((fileStream.rdstate() & fileStream.failbit) != 0) {')
header_txt.append(' outputStream = &std::cout;')
- header_txt.append(' (*outputStream) << endl << "APIDump ERROR: Bad output filename specified: " << fileName << ". Writing to STDOUT instead" << endl << endl;')
+ header_txt.append(' (*outputStream) << endl << "api_dump ERROR: Bad output filename specified: " << fileName << ". Writing to STDOUT instead" << endl << endl;')
header_txt.append(' }')
header_txt.append(' else')
header_txt.append(' outputStream = &fileStream;')
return "\n\n".join(funcs)
def generate_body(self):
- self.layer_name = "APIDump"
+ self.layer_name = "api_dump"
if sys.platform.startswith('win32'):
instance_extensions=[('wsi_enabled',
['vkGetPhysicalDeviceSurfaceSupportKHR',
header_txt.append('#include "vk_layer_data.h"')
header_txt.append('#include "vk_layer_logging.h"')
header_txt.append('')
-# NOTE: The non-autoGenerated code is in the object_track.h header file
- header_txt.append('#include "object_track.h"')
+# NOTE: The non-autoGenerated code is in the object_tracker.h header file
+ header_txt.append('#include "object_tracker.h"')
header_txt.append('')
header_txt.append('static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(initOnce);')
header_txt.append('')
gedi_txt.append(' %sMap.clear();' % (o))
gedi_txt.append('')
gedi_txt.append(' dispatch_key key = get_dispatch_key(instance);')
- gedi_txt.append(' VkLayerInstanceDispatchTable *pInstanceTable = get_dispatch_table(ObjectTracker_instance_table_map, instance);')
+ gedi_txt.append(' VkLayerInstanceDispatchTable *pInstanceTable = get_dispatch_table(object_tracker_instance_table_map, instance);')
gedi_txt.append(' pInstanceTable->DestroyInstance(instance, pAllocator);')
gedi_txt.append('')
gedi_txt.append(' // Clean up logging callback, if any')
gedi_txt.append(' instanceExtMap.erase(pInstanceTable);')
gedi_txt.append(' loader_platform_thread_unlock_mutex(&objLock);')
# The loader holds a mutex that protects this from other threads
- gedi_txt.append(' ObjectTracker_instance_table_map.erase(key);')
- gedi_txt.append(' if (ObjectTracker_instance_table_map.empty()) {')
+ gedi_txt.append(' object_tracker_instance_table_map.erase(key);')
+ gedi_txt.append(' if (object_tracker_instance_table_map.empty()) {')
gedi_txt.append(' // Release mutex when destroying last instance.')
gedi_txt.append(' loader_platform_thread_delete_mutex(&objLock);')
gedi_txt.append(' objLockInitialized = 0;')
gedd_txt.append(' loader_platform_thread_unlock_mutex(&objLock);')
gedd_txt.append('')
gedd_txt.append(' dispatch_key key = get_dispatch_key(device);')
- gedd_txt.append(' VkLayerDispatchTable *pDisp = get_dispatch_table(ObjectTracker_device_table_map, device);')
+ gedd_txt.append(' VkLayerDispatchTable *pDisp = get_dispatch_table(object_tracker_device_table_map, device);')
gedd_txt.append(' pDisp->DestroyDevice(device, pAllocator);')
- gedd_txt.append(' ObjectTracker_device_table_map.erase(key);')
- gedd_txt.append(' assert(ObjectTracker_device_table_map.size() == 0 && "Should not have any instance mappings hanging around");')
+ gedd_txt.append(' object_tracker_device_table_map.erase(key);')
+ gedd_txt.append(' assert(object_tracker_device_table_map.size() == 0 && "Should not have any instance mappings hanging around");')
gedd_txt.append('')
gedd_txt.append('}')
gedd_txt.append('')
'{\n'
'%s'
'%s'
- ' %sget_dispatch_table(ObjectTracker_%s_table_map, %s)->%s;\n'
+ ' %sget_dispatch_table(object_tracker_%s_table_map, %s)->%s;\n'
'%s'
'%s'
'}' % (qual, decl, using_line, destroy_line, ret_val, table_type, dispatch_param, proto.c_call(), create_line, stmt))
return "\n\n".join(funcs)
def generate_body(self):
- self.layer_name = "ObjectTracker"
+ self.layer_name = "object_tracker"
extensions=[('wsi_enabled',
['vkCreateSwapchainKHR',
'vkDestroySwapchainKHR', 'vkGetSwapchainImagesKHR',
' for (uint32_t i=0; i<memoryRangeCount; i++) {\n'
' useVkDeviceMemory((const void *) %s, pMemoryRanges[i].memory);\n' % proto.params[0].name +
' }\n'
- ' VkLayerDispatchTable *pDeviceTable = get_dispatch_table(Threading_%s_table_map, %s);\n' % (table, proto.params[0].name) +
+ ' VkLayerDispatchTable *pDeviceTable = get_dispatch_table(threading_%s_table_map, %s);\n' % (table, proto.params[0].name) +
' %s pDeviceTable->%s;\n' % (ret_val, proto.c_call()) +
' for (uint32_t i=0; i<memoryRangeCount; i++) {\n'
' finishUsingVkDeviceMemory(pMemoryRanges[i].memory);\n'
funcs.append('%s' % self.lineinfo.get())
funcs.append('%s%s\n' % (qual, decl) +
'{\n'
- ' VkLayerDispatchTable *pDeviceTable = get_dispatch_table(Threading_device_table_map, (void *) *pDevice);\n'
+ ' VkLayerDispatchTable *pDeviceTable = get_dispatch_table(threading_device_table_map, (void *) *pDevice);\n'
' VkResult result = pDeviceTable->%s;\n' % (proto.c_call()) +
' if (result == VK_SUCCESS) {\n'
' layer_data *my_instance_data = get_my_data_ptr(get_dispatch_key(%s), layer_data_map);\n' % proto.params[0].name +
funcs.append('%s%s\n' % (qual, decl) +
'{\n'
' use%s((const void *) %s, %s);\n' % (proto.params[0].ty, proto.params[0].name, proto.params[0].name) +
- ' VkLayerDispatchTable *pDeviceTable = get_dispatch_table(Threading_%s_table_map, %s);\n' % (table, proto.params[0].name) +
+ ' VkLayerDispatchTable *pDeviceTable = get_dispatch_table(threading_%s_table_map, %s);\n' % (table, proto.params[0].name) +
' %spDeviceTable->%s;\n' % (ret_val, proto.c_call()) +
' finishUsing%s(%s);\n' % (proto.params[0].ty, proto.params[0].name) +
'%s' % stmt +
funcs.append('%s%s\n' % (qual, decl) +
'{\n'
' dispatch_key key = get_dispatch_key(device);\n'
- ' VkLayerDispatchTable *pDeviceTable = get_dispatch_table(Threading_%s_table_map, %s);\n' % (table, proto.params[0].name) +
+ ' VkLayerDispatchTable *pDeviceTable = get_dispatch_table(threading_%s_table_map, %s);\n' % (table, proto.params[0].name) +
' %spDeviceTable->%s;\n' % (ret_val, proto.c_call()) +
- ' Threading_device_table_map.erase(key);\n'
+ ' threading_device_table_map.erase(key);\n'
'}\n')
return "\n".join(funcs);
elif proto.name == "DestroyInstance":
funcs.append('%s%s\n' % (qual, decl) +
'{\n'
' dispatch_key key = get_dispatch_key(instance);\n'
- ' VkLayerInstanceDispatchTable *pInstanceTable = get_dispatch_table(Threading_instance_table_map, %s);\n' % proto.params[0].name +
+ ' VkLayerInstanceDispatchTable *pInstanceTable = get_dispatch_table(threading_instance_table_map, %s);\n' % proto.params[0].name +
' %spInstanceTable->%s;\n' % (ret_val, proto.c_call()) +
' destroy_instance_dispatch_table(key);\n'
'\n'
' layer_debug_report_destroy_instance(my_data->report_data);\n'
' layer_data_map.erase(pInstanceTable);\n'
'\n'
- ' Threading_instance_table_map.erase(key);\n'
+ ' threading_instance_table_map.erase(key);\n'
'}\n')
return "\n".join(funcs);
elif proto.name == "CreateInstance":
funcs.append('%s%s\n'
'{\n'
- ' VkLayerInstanceDispatchTable *pInstanceTable = get_dispatch_table(Threading_instance_table_map, *pInstance);\n'
+ ' VkLayerInstanceDispatchTable *pInstanceTable = get_dispatch_table(threading_instance_table_map, *pInstance);\n'
' VkResult result = pInstanceTable->CreateInstance(pCreateInfo, pAllocator, pInstance);\n'
'\n'
' if (result == VK_SUCCESS) {\n'
' *pInstance,\n'
' pCreateInfo->enabledExtensionNameCount,\n'
' pCreateInfo->ppEnabledExtensionNames);\n'
- ' initThreading(my_data, pAllocator);\n'
+ ' init_threading(my_data, pAllocator);\n'
' }\n'
' return result;\n'
'}\n' % (qual, decl))
funcs.append('{')
for param in checked_params:
funcs.append(' use%s((const void *) %s, %s);' % (param.ty, proto.params[0].name, param.name))
- funcs.append(' VkLayerDispatchTable *pDeviceTable = get_dispatch_table(Threading_%s_table_map, %s);' % (table, proto.params[0].name));
+ funcs.append(' VkLayerDispatchTable *pDeviceTable = get_dispatch_table(threading_%s_table_map, %s);' % (table, proto.params[0].name));
funcs.append(' %spDeviceTable->%s;' % (ret_val, proto.c_call()))
for param in checked_params:
funcs.append(' finishUsing%s(%s);' % (param.ty, param.name))
return "\n".join(funcs)
def generate_body(self):
- self.layer_name = "Threading"
+ self.layer_name = "threading"
body = [self._generate_new_layer_initialization(True, lockname='threading', condname='threading'),
self._generate_dispatch_entrypoints("VK_LAYER_EXPORT"),
self._generate_layer_gpa_function(extensions=[],
def main():
subcommands = {
"layer-funcs" : LayerFuncsSubcommand,
- "Generic" : GenericLayerSubcommand,
- "APIDump" : APIDumpSubcommand,
- "ObjectTracker" : ObjectTrackerSubcommand,
- "Threading" : ThreadingSubcommand,
+ "generic" : GenericLayerSubcommand,
+ "api_dump" : APIDumpSubcommand,
+ "object_tracker" : ObjectTrackerSubcommand,
+ "threading" : ThreadingSubcommand,
}
if len(sys.argv) < 3 or sys.argv[1] not in subcommands or not os.path.exists(sys.argv[2]):