aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--layers/CMakeLists.txt12
-rw-r--r--layers/README.md39
-rw-r--r--layers/api_dump.h158
-rw-r--r--layers/basic.cpp238
-rw-r--r--layers/generic.h111
-rw-r--r--layers/linux/VkLayer_api_dump.json11
-rw-r--r--layers/linux/VkLayer_basic.json18
-rw-r--r--layers/linux/VkLayer_basic_implicit.json20
-rw-r--r--layers/linux/VkLayer_generic.json11
-rw-r--r--layers/linux/VkLayer_multi.json25
-rw-r--r--layers/linux/VkLayer_screenshot.json11
-rw-r--r--layers/multi.cpp174
-rw-r--r--layers/screenshot.cpp842
-rw-r--r--layers/vk_layer_settings.txt14
-rw-r--r--layers/vk_validation_layer_details.md11
-rw-r--r--layers/windows/VkLayer_api_dump.json11
-rw-r--r--layers/windows/VkLayer_basic.json18
-rw-r--r--layers/windows/VkLayer_generic.json11
-rw-r--r--layers/windows/VkLayer_multi.json25
-rw-r--r--layers/windows/VkLayer_screenshot.json11
-rwxr-xr-xvk-layer-generate.py662
21 files changed, 29 insertions, 2404 deletions
diff --git a/layers/CMakeLists.txt b/layers/CMakeLists.txt
index cec169022..0406a572f 100644
--- a/layers/CMakeLists.txt
+++ b/layers/CMakeLists.txt
@@ -15,17 +15,12 @@ macro(run_vk_layer_generate subcmd output)
endmacro()
set(LAYER_JSON_FILES
- VkLayer_api_dump
- VkLayer_basic
VkLayer_draw_state
- VkLayer_generic
VkLayer_image
VkLayer_mem_tracker
- VkLayer_multi
VkLayer_object_tracker
VkLayer_unique_objects
VkLayer_param_checker
- VkLayer_screenshot
VkLayer_swapchain
VkLayer_threading
VkLayer_device_limits
@@ -139,8 +134,6 @@ add_custom_target(generate_vk_layer_helpers DEPENDS
vk_struct_wrappers.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)
run_vk_layer_generate(unique_objects unique_objects.cpp)
@@ -154,18 +147,13 @@ else()
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(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(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)
add_vk_layer(unique_objects unique_objects.cpp vk_layer_table.cpp)
diff --git a/layers/README.md b/layers/README.md
index 8c7411ad9..7bea75c6f 100644
--- a/layers/README.md
+++ b/layers/README.md
@@ -30,22 +30,9 @@ Note that some layers are code-generated and will therefore exist in the directo
-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:
-- 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.
-
### 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_api_dump) - print out API calls along with parameter values
-
### Print Object Stats
(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.
@@ -72,10 +59,10 @@ layers/device_limits.cpp (name=VK_LAYER_LUNARG_device_limits) - This layer is in
## Using Layers
-1. Build VK loader and i965 icd driver using normal steps (cmake and make)
+1. Build VK loader using normal steps (cmake and make)
2. Place libVkLayer_<name>.so in the same directory as your VK test or app:
- cp build/layer/libVkLayer_basic.so build/layer/libVkLayer_generic.so build/tests
+ cp build/layer/libVkLayer_threading.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.
@@ -87,31 +74,13 @@ layers/device_limits.cpp (name=VK_LAYER_LUNARG_device_limits) - This layer is in
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_param_checker:VK_LAYER_LUNARG_draw_state
+ export VK\_DEVICE\_LAYERS=VK_LAYER_LUNARG_param_checker:VK_LAYER_LUNARG_draw_state
cd build/tests; ./vkinfo
-## Tips for writing new layers
-
-1. Must implement vkGetInstanceProcAddr() (aka GIPA) and vkGetDeviceProcAddr() (aka GDPA);
-2. Must have a local dispatch table to call next layer (see vk_layer.h);
-3. Must have a layer manifest file for each Layer library for Loader to find layer properties (see loader/README.md)
-4. Next layers GXPA can be found in the wrapped instance or device object;
-5. Loader calls a layer's GXPA first so initialization should occur here;
-6. all entrypoints can be wrapped but only will be called after layer is activated
- via the first vkCreatDevice or vkCreateInstance;
-7. entrypoint names can be any name as specified by the layers vkGetXXXXXProcAddr
- 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
-10. For multiple layers in one library the manifest file can specify each layer.
## Status
### Current known issues
-- Layers with multiple layers per library: the manifest file parsing in Loader doesn't yet handle this
-- multi.cpp Layer needs rewrite to allow manifest file to specify multiple layers
-- multi1 and multi2 layers from multi.cpp: only multi1 layer working
diff --git a/layers/api_dump.h b/layers/api_dump.h
deleted file mode 100644
index 73c6a491e..000000000
--- a/layers/api_dump.h
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- *
- * 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->enabledExtensionCount; 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->enabledExtensionCount; i++) {
- if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SURFACE_EXTENSION_NAME) == 0)
- instanceExtMap[pDisp].wsi_enabled = true;
-
- }
-}
-
-VkResult
-explicit_CreateDevice(
- VkPhysicalDevice gpu,
- const VkDeviceCreateInfo *pCreateInfo,
- const VkAllocationCallbacks *pAllocator,
- VkDevice *pDevice)
-{
- VkLayerDeviceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO);
-
- assert(chain_info->u.pLayerInfo);
- PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr;
- PFN_vkGetDeviceProcAddr fpGetDeviceProcAddr = chain_info->u.pLayerInfo->pfnNextGetDeviceProcAddr;
- PFN_vkCreateDevice fpCreateDevice = (PFN_vkCreateDevice) fpGetInstanceProcAddr(NULL, "vkCreateDevice");
- if (fpCreateDevice == NULL) {
- return VK_ERROR_INITIALIZATION_FAILED;
- }
-
- // Advance the link info for the next element on the chain
- chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext;
-
- VkResult result = fpCreateDevice(gpu, pCreateInfo, pAllocator, pDevice);
- if (result != VK_SUCCESS) {
- return result;
- }
-
- initDeviceTable(*pDevice, fpGetDeviceProcAddr);
-
- createDeviceRegisterExtensions(pCreateInfo, *pDevice);
-
- return result;
-}
diff --git a/layers/basic.cpp b/layers/basic.cpp
deleted file mode 100644
index 45cb9998b..000000000
--- a/layers/basic.cpp
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- *
- * 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: David Pinedo <david@lunarg.com>
- * Author: Jon Ashburn <jon@lunarg.com>
- */
-#include <string.h>
-#include <stdlib.h>
-#include <assert.h>
-#include "vk_dispatch_table_helper.h"
-#include "vulkan/vk_layer.h"
-#include "vk_layer_table.h"
-#include "vk_layer_extension_utils.h"
-
-static const VkLayerProperties globalLayerProps[] = {
- {
- "VK_LAYER_LUNARG_basic",
- VK_API_VERSION, // specVersion
- 1, // implementationVersion
- "LunarG Sample Layer",
- }
-};
-
-
-VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkLayerExtension1(VkDevice device)
-{
- printf("In vkLayerExtension1() call w/ device: %p\n", (void*)device);
- printf("vkLayerExtension1 returning SUCCESS\n");
- return VK_SUCCESS;
-}
-
-static const VkLayerProperties basic_physicaldevice_layers[] = {
- {
- "VK_LAYER_LUNARG_basic",
- VK_API_VERSION,
- VK_MAKE_VERSION(0, 1, 0),
- "Sample layer: basic, implements vkLayerExtension1",
- }
-};
-
-/* Must use Vulkan name so that loader finds it */
-VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(
- VkPhysicalDevice physicalDevice,
- uint32_t* pCount,
- VkLayerProperties* pProperties)
-{
- /* Mem tracker's physical device layers are the same as global */
- return util_GetLayerProperties(ARRAY_SIZE(basic_physicaldevice_layers), basic_physicaldevice_layers,
- pCount, pProperties);
-}
-
-static const VkExtensionProperties basic_physicaldevice_extensions[] = {
- {
- "vkLayerExtension1",
- VK_MAKE_VERSION(0, 1, 0),
- }
-};
-
-VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties(
- VkPhysicalDevice physicalDevice,
- const char *pLayerName,
- uint32_t *pCount,
- VkExtensionProperties *pProperties)
-{
- if (pLayerName == NULL) {
- return instance_dispatch_table(physicalDevice)->EnumerateDeviceExtensionProperties(
- physicalDevice,
- NULL,
- pCount,
- pProperties);
- } else {
- return util_GetExtensionProperties(ARRAY_SIZE(basic_physicaldevice_extensions),
- basic_physicaldevice_extensions,
- pCount, pProperties);
- }
-}
-
-VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL basic_CreateInstance(
- const VkInstanceCreateInfo* pCreateInfo,
- const VkAllocationCallbacks* pAllocator,
- VkInstance* pInstance)
-{
- VkLayerInstanceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO);
-
- assert(chain_info->u.pLayerInfo);
- PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr;
- PFN_vkCreateInstance fpCreateInstance = (PFN_vkCreateInstance) fpGetInstanceProcAddr(NULL, "vkCreateInstance");
- if (fpCreateInstance == NULL) {
- return VK_ERROR_INITIALIZATION_FAILED;
- }
-
- // Advance the link info for the next element on the chain
- chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext;
-
- VkResult result = fpCreateInstance(pCreateInfo, pAllocator, pInstance);
- if (result != VK_SUCCESS)
- return result;
-
- initInstanceTable(*pInstance, fpGetInstanceProcAddr);
-
- return result;
-}
-
-VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL basic_EnumeratePhysicalDevices(
- VkInstance instance,
- uint32_t* pPhysicalDeviceCount,
- VkPhysicalDevice* pPhysicalDevices)
-{
- printf("At start of wrapped vkEnumeratePhysicalDevices() call w/ inst: %p\n", (void*)instance);
- VkResult result = instance_dispatch_table(instance)->EnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices);
- printf("Completed wrapped vkEnumeratePhysicalDevices() call w/ count %u\n", *pPhysicalDeviceCount);
- return result;
-}
-
-VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL basic_CreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDevice* pDevice)
-{
- printf("VK_LAYER_LUNARG_Basic: At start of vkCreateDevice() call w/ gpu: %p\n", (void*)physicalDevice);
-
- VkLayerDeviceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO);
-
- assert(chain_info->u.pLayerInfo);
- PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr;
- PFN_vkGetDeviceProcAddr fpGetDeviceProcAddr = chain_info->u.pLayerInfo->pfnNextGetDeviceProcAddr;
- PFN_vkCreateDevice fpCreateDevice = (PFN_vkCreateDevice) fpGetInstanceProcAddr(NULL, "vkCreateDevice");
- if (fpCreateDevice == NULL) {
- return VK_ERROR_INITIALIZATION_FAILED;
- }
-
- // Advance the link info for the next element on the chain
- chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext;
-
- VkResult result = fpCreateDevice(physicalDevice, pCreateInfo, pAllocator, pDevice);
- if (result != VK_SUCCESS) {
- return result;
- }
-
- initDeviceTable(*pDevice, fpGetDeviceProcAddr);
-
- printf("VK_LAYER_LUNARG_Basic: Completed vkCreateDevice() call w/ pDevice, Device %p: %p\n", (void*)pDevice, (void *) *pDevice);
- return result;
-}
-
-/* hook DestroyDevice to remove tableMap entry */
-VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL basic_DestroyDevice(VkDevice device, const VkAllocationCallbacks* pAllocator)
-{
- dispatch_key key = get_dispatch_key(device);
- device_dispatch_table(device)->DestroyDevice(device, pAllocator);
- destroy_device_dispatch_table(key);
-}
-
-/* hook DestroyInstance to remove tableInstanceMap entry */
-VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL basic_DestroyInstance(VkInstance instance, const VkAllocationCallbacks* pAllocator)
-{
- dispatch_key key = get_dispatch_key(instance);
- instance_dispatch_table(instance)->DestroyInstance(instance, pAllocator);
- destroy_instance_dispatch_table(key);
-}
-
-VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL basic_GetPhysicalDeviceFormatProperties(VkPhysicalDevice gpu, VkFormat format, VkFormatProperties *pFormatInfo)
-{
- printf("At start of wrapped vkGetPhysicalDeviceFormatProperties() call w/ gpu: %p\n", (void*)gpu);
- instance_dispatch_table(gpu)->GetPhysicalDeviceFormatProperties(gpu, format, pFormatInfo);
- printf("Completed wrapped vkGetPhysicalDeviceFormatProperties() call w/ gpu: %p\n", (void*)gpu);
-}
-
-VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice device, const char* pName)
-{
- if (!strcmp("vkGetDeviceProcAddr", pName))
- return (PFN_vkVoidFunction) vkGetDeviceProcAddr;
- if (!strcmp("vkDestroyDevice", pName))
- return (PFN_vkVoidFunction) basic_DestroyDevice;
- if (!strcmp("vkLayerExtension1", pName))
- return (PFN_vkVoidFunction) vkLayerExtension1;
-
- if (device == NULL)
- return NULL;
-
- if (device_dispatch_table(device)->GetDeviceProcAddr == NULL)
- return NULL;
- return device_dispatch_table(device)->GetDeviceProcAddr(device, pName);
-}
-
-VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char* pName)
-{
- if (!strcmp("vkGetInstanceProcAddr", pName))
- return (PFN_vkVoidFunction) vkGetInstanceProcAddr;
- if (!strcmp("vkEnumerateDeviceLayerProperties", pName))
- return (PFN_vkVoidFunction) vkEnumerateDeviceLayerProperties;
- if (!strcmp("vkEnumerateDeviceExtensionProperties", pName))
- return (PFN_vkVoidFunction) vkEnumerateDeviceExtensionProperties;
- if (!strcmp("vkGetPhysicalDeviceFormatProperties", pName))
- return (PFN_vkVoidFunction) basic_GetPhysicalDeviceFormatProperties;
- if (!strcmp("vkCreateInstance", pName))
- return (PFN_vkVoidFunction) basic_CreateInstance;
- if (!strcmp("vkDestroyInstance", pName))
- return (PFN_vkVoidFunction) basic_DestroyInstance;
- if (!strcmp("vkCreateDevice", pName))
- return (PFN_vkVoidFunction) basic_CreateDevice;
- if (!strcmp("vkEnumeratePhysicalDevices", pName))
- return (PFN_vkVoidFunction) basic_EnumeratePhysicalDevices;
-
- if (instance == NULL)
- return NULL;
-
- if (instance_dispatch_table(instance)->GetInstanceProcAddr == NULL)
- return NULL;
- return instance_dispatch_table(instance)->GetInstanceProcAddr(instance, pName);
-}
-
-VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pCount, VkExtensionProperties* pProperties)
-{
- return util_GetExtensionProperties(0, NULL, pCount, pProperties);
-}
-
-VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(uint32_t *pCount, VkLayerProperties* pProperties)
-{
- return util_GetLayerProperties(ARRAY_SIZE(globalLayerProps), globalLayerProps, pCount, pProperties);
-}
diff --git a/layers/generic.h b/layers/generic.h
deleted file mode 100644
index 32a78ef33..000000000
--- a/layers/generic.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- *
- * 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>
- *
- */
-
-#ifndef GENERIC_H
-#define GENERIC_H
-#include "vulkan/vk_layer.h"
-
-/*
- * This file contains static functions for the generated layer generic
- */
-
-// The following is for logging error messages:
-struct layer_data {
- debug_report_data *report_data;
- VkDebugReportCallbackEXT logging_callback;
-
- layer_data() :
- report_data(nullptr),
- logging_callback(VK_NULL_HANDLE)
- {};
-};
-
-static const VkLayerProperties globalLayerProps[] = {
- {
- "VK_LAYER_LUNARG_generic",
- VK_API_VERSION, // specVersion
- VK_MAKE_VERSION(0, 1, 0), // implementationVersion
- "layer: generic",
- }
-};
-
-static const VkLayerProperties deviceLayerProps[] = {
- {
- "VK_LAYER_LUNARG_generic",
- VK_API_VERSION, // specVersion
- VK_MAKE_VERSION(0, 1, 0), // implementationVersion
- "layer: generic",
- }
-};
-
-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->enabledExtensionCount; 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");
- instanceExtMap[pDisp].wsi_enabled = false;
- for (i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
- if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SURFACE_EXTENSION_NAME) == 0)
- instanceExtMap[pDisp].wsi_enabled = true;
-
- }
-}
-#endif // GENERIC_H
-
diff --git a/layers/linux/VkLayer_api_dump.json b/layers/linux/VkLayer_api_dump.json
deleted file mode 100644
index 7ece89d97..000000000
--- a/layers/linux/VkLayer_api_dump.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_api_dump",
- "type": "GLOBAL",
- "library_path": "./libVkLayer_api_dump.so",
- "api_version": "1.0.1",
- "implementation_version": "1",
- "description": "LunarG debug layer"
- }
-}
diff --git a/layers/linux/VkLayer_basic.json b/layers/linux/VkLayer_basic.json
deleted file mode 100644
index 488937074..000000000
--- a/layers/linux/VkLayer_basic.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_basic",
- "type": "GLOBAL",
- "library_path": "./libVkLayer_basic.so",
- "api_version": "1.0.1",
- "implementation_version": "1",
- "description": "LunarG Sample Layer",
- "device_extensions": [
- {
- "name": "VK_LUNARG_LayerExtension1",
- "spec_version": "0",
- "entrypoints": ["vkLayerExtension1"]
- }
- ]
- }
-}
diff --git a/layers/linux/VkLayer_basic_implicit.json b/layers/linux/VkLayer_basic_implicit.json
deleted file mode 100644
index c26bff659..000000000
--- a/layers/linux/VkLayer_basic_implicit.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "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": "1.0.1",
- "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"}
- }
-}
diff --git a/layers/linux/VkLayer_generic.json b/layers/linux/VkLayer_generic.json
deleted file mode 100644
index 25f3c3728..000000000
--- a/layers/linux/VkLayer_generic.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_generic",
- "type": "GLOBAL",
- "library_path": "./libVkLayer_generic.so",
- "api_version": "1.0.1",
- "implementation_version": "1",
- "description": "LunarG Sample Layer"
- }
-}
diff --git a/layers/linux/VkLayer_multi.json b/layers/linux/VkLayer_multi.json
deleted file mode 100644
index e5b3b49f1..000000000
--- a/layers/linux/VkLayer_multi.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_multi1",
- "type": "DEVICE",
- "library_path": "./libVkLayer_multi.so",
- "api_version": "1.0.1",
- "implementation_version": "1",
- "description": "LunarG Sample multiple layer per library",
- "functions" : {
- "vkGetDeviceProcAddr" : "multi1GetDeviceProcAddr"
- }
- },
- "layer" : {
- "name": "VK_LAYER_LUNARG_multi2",
- "type": "INSTANCE",
- "library_path": "./libVkLayer_multi.so",
- "api_version": "1.0.1",
- "implementation_version": "1",
- "description": "LunarG Sample multiple layer per library",
- "functions" : {
- "vkGetInstanceProcAddr" : "multi2GetInstanceProcAddr"
- }
- }
-}
diff --git a/layers/linux/VkLayer_screenshot.json b/layers/linux/VkLayer_screenshot.json
deleted file mode 100644
index cace59520..000000000
--- a/layers/linux/VkLayer_screenshot.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_screenshot",
- "type": "GLOBAL",
- "library_path": "./libVkLayer_screenshot.so",
- "api_version": "1.0.1",
- "implementation_version": "1",
- "description": "LunarG image capture layer"
- }
-}
diff --git a/layers/multi.cpp b/layers/multi.cpp
deleted file mode 100644
index 3bbea8c55..000000000
--- a/layers/multi.cpp
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- *
- * Copyright (C) 2015 Valve Corporation
- *
- * 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>
- *
- */
-
-#include <string.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <unordered_map>
-#include "vk_loader_platform.h"
-#include "vulkan/vk_layer.h"
-#include "vk_layer_table.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-static device_table_map multi1_device_table_map;
-/******************************** Layer multi1 functions **************************/
-
-/* hook DestroyDevice to remove tableMap entry */
-VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL multi1DestroyDevice(VkDevice device, const VkAllocationCallbacks* pAllocator)
-{
- VkLayerDispatchTable *pDisp = get_dispatch_table(multi1_device_table_map, device);
- dispatch_key key = get_dispatch_key(device);
-
- printf("At start of multi1 layer vkDestroyDevice()\n");
- pDisp->DestroyDevice(device, pAllocator);
- multi1_device_table_map.erase(key);
- printf("Completed multi1 layer vkDestroyDevice()\n");
-}
-
-VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL multi1CreateSampler(VkDevice device, const VkSamplerCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSampler* pSampler)
-{
- VkLayerDispatchTable *pDisp = get_dispatch_table(multi1_device_table_map, device);
-
- printf("At start of multi1 layer vkCreateSampler()\n");
- VkResult result = pDisp->CreateSampler(device, pCreateInfo, pAllocator, pSampler);
- printf("Completed multi1 layer vkCreateSampler()\n");
- return result;
-}
-
-VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL multi1CreateGraphicsPipelines(
- VkDevice device,
- VkPipelineCache pipelineCache,
- uint32_t count,
- const VkGraphicsPipelineCreateInfo* pCreateInfos,
- const VkAllocationCallbacks* pAllocator,
- VkPipeline* pPipelines)
-{
- VkLayerDispatchTable *pDisp = get_dispatch_table(multi1_device_table_map, device);
-
- printf("At start of multi1 layer vkCreateGraphicsPipeline()\n");
- VkResult result = pDisp->CreateGraphicsPipelines(device, pipelineCache, count, pCreateInfos, pAllocator, pPipelines);
- printf("Completed multi1 layer vkCreateGraphicsPipeline()\n");
- return result;
-}
-
-VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL multi1GetDeviceProcAddr(VkDevice device, const char* pName)
-{
- if (!strcmp(pName, "multi1GetDeviceProcAddr") || !strcmp(pName, "vkGetDeviceProcAddr"))
- return (PFN_vkVoidFunction) multi1GetDeviceProcAddr;
- if (!strcmp("vkDestroyDevice", pName))
- return (PFN_vkVoidFunction) multi1DestroyDevice;
- if (!strcmp("vkCreateSampler", pName))
- return (PFN_vkVoidFunction) multi1CreateSampler;
- if (!strcmp("vkCreateGraphicsPipelines", pName))
- return (PFN_vkVoidFunction) multi1CreateGraphicsPipelines;
-
- if (device == NULL)
- return NULL;
-
- VkLayerDispatchTable *pTable = get_dispatch_table(multi1_device_table_map, device);
- if (pTable->GetDeviceProcAddr == NULL)
- return NULL;
- return pTable->GetDeviceProcAddr(device, pName);
-}
-
-
-static instance_table_map multi2_instance_table_map;
-/******************************** Layer multi2 functions **************************/
-VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL multi2EnumeratePhysicalDevices(
- VkInstance instance,
- uint32_t* pPhysicalDeviceCount,
- VkPhysicalDevice* pPhysicalDevices)
-{
- VkLayerInstanceDispatchTable *pDisp = get_dispatch_table(multi2_instance_table_map, instance);
-
- printf("At start of wrapped multi2 vkEnumeratePhysicalDevices()\n");
- VkResult result = pDisp->EnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices);
- printf("Completed multi2 layer vkEnumeratePhysicalDevices()\n");
- return result;
-}
-
-VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL multi2GetPhysicalDeviceProperties(
- VkPhysicalDevice physicalDevice,
- VkPhysicalDeviceProperties* pProperties)
-{
- VkLayerInstanceDispatchTable *pDisp = get_dispatch_table(multi2_instance_table_map, physicalDevice);
- printf("At start of wrapped multi2 vkGetPhysicalDeviceProperties()\n");
- pDisp->GetPhysicalDeviceProperties(physicalDevice, pProperties);
- printf("Completed multi2 layer vkGetPhysicalDeviceProperties()\n");
-}
-
-VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL multi2GetPhysicalDeviceFeatures(
- VkPhysicalDevice physicalDevice,
- VkPhysicalDeviceFeatures* pFeatures)
-{
- VkLayerInstanceDispatchTable *pDisp = get_dispatch_table(multi2_instance_table_map, physicalDevice);
- printf("At start of wrapped multi2 vkGetPhysicalDeviceFeatures()\n");
- pDisp->GetPhysicalDeviceFeatures(physicalDevice, pFeatures);
- printf("Completed multi2 layer vkGetPhysicalDeviceFeatures()\n");
-}
-
-/* hook DestroyInstance to remove tableInstanceMap entry */
-VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL multi2DestroyInstance(VkInstance instance, const VkAllocationCallbacks* pAllocator)
-{
- VkLayerInstanceDispatchTable *pDisp = get_dispatch_table(multi2_instance_table_map, instance);
- dispatch_key key = get_dispatch_key(instance);
-
- printf("At start of wrapped multi2 vkDestroyInstance()\n");
- pDisp->DestroyInstance(instance, pAllocator);
- multi2_instance_table_map.erase(key);
- printf("Completed multi2 layer vkDestroyInstance()\n");
-}
-
-VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL multi2GetInstanceProcAddr(VkInstance inst, const char* pName)
-{
- if (!strcmp(pName, "multi2GetInstanceProcAddr") || !strcmp(pName, "vkGetInstanceProcAddr"))
- return (PFN_vkVoidFunction) multi2GetInstanceProcAddr;
- if (!strcmp("vkEnumeratePhysicalDevices", pName))
- return (PFN_vkVoidFunction) multi2EnumeratePhysicalDevices;
- if (!strcmp("GetPhysicalDeviceProperties", pName))
- return (PFN_vkVoidFunction) multi2GetPhysicalDeviceProperties;
- if (!strcmp("GetPhysicalDeviceFeatures", pName))
- return (PFN_vkVoidFunction) multi2GetPhysicalDeviceFeatures;
- if (!strcmp("vkDestroyInstance", pName))
- return (PFN_vkVoidFunction) multi2DestroyInstance;
-
- if (inst == NULL)
- return NULL;
-
- VkLayerInstanceDispatchTable *pTable = get_dispatch_table(multi2_instance_table_map, inst);
- if (pTable->GetInstanceProcAddr == NULL)
- return NULL;
- return pTable->GetInstanceProcAddr(inst, pName);
-}
-
-#ifdef __cplusplus
-} //extern "C"
-#endif
-
diff --git a/layers/screenshot.cpp b/layers/screenshot.cpp
deleted file mode 100644
index 107c7dee2..000000000
--- a/layers/screenshot.cpp
+++ /dev/null
@@ -1,842 +0,0 @@
-/*
- *
- * Copyright (C) 2015 Valve Corporation
- *
- * 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: Cody Northrop <cody@lunarg.com>
- * Author: David Pinedo <david@lunarg.com>
- * Author: Jon Ashburn <jon@lunarg.com>
- */
-
-#include <inttypes.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <unordered_map>
-#include <iostream>
-#include <algorithm>
-#include <list>
-#include <map>
-#include <vector>
-#include <fstream>
-
-using namespace std;
-
-#include "vk_loader_platform.h"
-#include "vk_dispatch_table_helper.h"
-#include "vk_struct_string_helper_cpp.h"
-#include "vk_layer_config.h"
-#include "vk_layer_table.h"
-#include "vk_layer_extension_utils.h"
-
-
-struct devExts {
- bool wsi_enabled;
-};
-static std::unordered_map<void *, struct devExts> deviceExtMap;
-static device_table_map screenshot_device_table_map;
-//TODO convert over to the new interface using locally defiend maps
-//static instance_table_map screenshot_instance_table_map;
-
-static int globalLockInitialized = 0;
-static loader_platform_thread_mutex globalLock;
-
-// unordered map: associates a swap chain with a device, image extent, format, and
-// list of images
-typedef struct
-{
- VkDevice device;
- VkExtent2D imageExtent;
- VkFormat format;
- VkImage *imageList;
-} SwapchainMapStruct;
-static unordered_map<VkSwapchainKHR, SwapchainMapStruct *> swapchainMap;
-
-// unordered map: associates an image with a device, image extent, and format
-typedef struct
-{
- VkDevice device;
- VkExtent2D imageExtent;
- VkFormat format;
-} ImageMapStruct;
-static unordered_map<VkImage, ImageMapStruct *> imageMap;
-
-// unordered map: associates a device with a queue, commandPool, and physical device
-typedef struct
-{
- VkQueue queue;
- VkCommandPool commandPool;
- VkPhysicalDevice physicalDevice;
-} DeviceMapStruct;
-static unordered_map<VkDevice, DeviceMapStruct *> deviceMap;
-
-// unordered map: associates a physical device with an instance
-typedef struct
-{
- VkInstance instance;
-} PhysDeviceMapStruct;
-static unordered_map<VkPhysicalDevice, PhysDeviceMapStruct *> physDeviceMap;
-
-// List of frames to we will get a screenshot of
-static vector<int> screenshotFrames;
-
-// Flag indicating we have queried _VK_SCREENSHOT env var
-static bool screenshotEnvQueried = false;
-
-static bool memory_type_from_properties(
- VkPhysicalDeviceMemoryProperties *memory_properties,
- uint32_t typeBits,
- VkFlags requirements_mask,
- uint32_t *typeIndex)
-{
- // Search memtypes to find first index with those properties
- for (uint32_t i = 0; i < 32; i++) {
- if ((typeBits & 1) == 1) {
- // Type is available, does it match user properties?
- if ((memory_properties->memoryTypes[i].propertyFlags & requirements_mask) == requirements_mask) {
- *typeIndex = i;
- return true;
- }
- }
- typeBits >>= 1;
- }
- // No memory types matched, return failure
- return false;
-}
-
-static void init_screenshot()
-{
- if (!globalLockInitialized)
- {
- // 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(&globalLock);
- globalLockInitialized = 1;
- }
-}
-
-static void writePPM( const char *filename, VkImage image1)
-{
- VkImage image2;
- VkResult err;
- bool pass;
- uint32_t x, y;
- const char *ptr;
- VkDeviceMemory mem2;
- VkCommandBuffer commandBuffer;
-
- if (imageMap.empty() || imageMap.find(image1) == imageMap.end())
- return;
-
- VkDevice device = imageMap[image1]->device;
- VkPhysicalDevice physicalDevice = deviceMap[device]->physicalDevice;
- VkInstance instance = physDeviceMap[physicalDevice]->instance;
- VkQueue queue = deviceMap[device]->queue;
- uint32_t width = imageMap[image1]->imageExtent.width;
- uint32_t height = imageMap[image1]->imageExtent.height;
- VkFormat format = imageMap[image1]->format;
- const VkImageSubresource sr = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0};
- VkSubresourceLayout sr_layout;
- const VkImageCreateInfo imgCreateInfo = {
- VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
- NULL,
- 0,
- VK_IMAGE_TYPE_2D,
- format,
- {width, height, 1},
- 1,
- 1,
- VK_SAMPLE_COUNT_1_BIT,
- VK_IMAGE_TILING_LINEAR,
- VK_IMAGE_USAGE_TRANSFER_DST_BIT,
- VK_SHARING_MODE_EXCLUSIVE,
- 0,
- NULL,
- VK_IMAGE_LAYOUT_UNDEFINED,
- };
- VkMemoryAllocateInfo memAllocInfo = {
- VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
- NULL,
- 0, // allocationSize, queried later
- 0 // memoryTypeIndex, queried later
- };
- const VkCommandBufferAllocateInfo allocCommandBufferInfo = {
- VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
- NULL,
- deviceMap[device]->commandPool,
- VK_COMMAND_BUFFER_LEVEL_PRIMARY,
- 1
- };
- const VkCommandBufferBeginInfo commandBufferBeginInfo = {
- VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
- NULL,
- VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT,
- };
- const VkImageCopy imageCopyRegion = {
- {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1},
- {0, 0, 0},
- {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1},
- {0, 0, 0},
- {width, height, 1}
- };
- VkMemoryRequirements memRequirements;
- VkLayerDispatchTable* pTableDevice = get_dispatch_table(screenshot_device_table_map, device);
- VkLayerDispatchTable* pTableQueue = get_dispatch_table(screenshot_device_table_map, queue);
- VkLayerInstanceDispatchTable* pInstanceTable;
- VkLayerDispatchTable* pTableCommandBuffer;
- VkPhysicalDeviceMemoryProperties memory_properties;
-
- // The VkImage image1 we are going to dump may not be mappable,
- // and/or it may have a tiling mode of optimal rather than linear.
- // To make sure we have an image that we can map and read linearly, we:
- // create image2 that is mappable and linear
- // copy image1 to image2
- // map image2
- // read from image2's mapped memory.
-
- err = pTableDevice->CreateImage(device, &imgCreateInfo, NULL, &image2);
- assert(!err);
-
- pTableDevice->GetImageMemoryRequirements(device, image2, &memRequirements);
-
- memAllocInfo.allocationSize = memRequirements.size;
- pInstanceTable = instance_dispatch_table(instance);
- pInstanceTable->GetPhysicalDeviceMemoryProperties(physicalDevice, &memory_properties);
-
- pass = memory_type_from_properties(&memory_properties,
- memRequirements.memoryTypeBits,
- VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
- &memAllocInfo.memoryTypeIndex);
- assert(pass);
-
- err = pTableDevice->AllocateMemory(device, &memAllocInfo, NULL, &mem2);
- assert(!err);
-
- err = pTableQueue->BindImageMemory(device, image2, mem2, 0);
- assert(!err);
-
- err = pTableDevice->AllocateCommandBuffers(device, &allocCommandBufferInfo, &commandBuffer);
- assert(!err);
-
- screenshot_device_table_map.emplace(commandBuffer, pTableDevice);
- pTableCommandBuffer = screenshot_device_table_map[commandBuffer];
-
- // We have just created a dispatchable object, but the dispatch table has not been placed
- // in the object yet. When a "normal" application creates a command buffer, the dispatch
- // table is installed by the top-level api binding (trampoline.c).
- // But here, we have to do it ourselves.
- *((const void**)commandBuffer) = *(void**)device;
-
- err = pTableCommandBuffer->BeginCommandBuffer(commandBuffer, &commandBufferBeginInfo);
- assert(!err);
-
- // Transition the source image layout to prepare it for the copy.
-
- VkImageMemoryBarrier image1_memory_barrier = {
- VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
- NULL,
- 0,
- VK_ACCESS_TRANSFER_READ_BIT,
- VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,
- VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
- 0,
- 0,
- image1,
- { VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 }
- };
-
- VkImageMemoryBarrier image2_memory_barrier = {
- VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
- NULL,
- 0,
- VK_ACCESS_TRANSFER_READ_BIT,
- VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
- VK_IMAGE_LAYOUT_GENERAL,
- 0,
- 0,
- image2,
- { VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 }
- };
-
- VkPipelineStageFlags src_stages = VK_PIPELINE_STAGE_TRANSFER_BIT;
- VkPipelineStageFlags dst_stages = VK_PIPELINE_STAGE_TRANSFER_BIT;
-
- pTableCommandBuffer->CmdPipelineBarrier(commandBuffer, src_stages, dst_stages,
- 0, 0, NULL, 0, NULL, 1, &image1_memory_barrier);
-
- pTableCommandBuffer->CmdCopyImage(commandBuffer,
- image1, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
- image2, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
- 1, &imageCopyRegion);
-
- pTableCommandBuffer->CmdPipelineBarrier(commandBuffer, src_stages, dst_stages,
- 0, 0, NULL, 0, NULL, 1, &image2_memory_barrier);
-
- err = pTableCommandBuffer->EndCommandBuffer(commandBuffer);
- assert(!err);
-
- VkFence nullFence = { VK_NULL_HANDLE };
- VkSubmitInfo submit_info;
- submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
- submit_info.pNext = NULL;
- submit_info.waitSemaphoreCount = 0;
- submit_info.pWaitSemaphores = NULL;
- submit_info.pWaitDstStageMask = NULL;
- submit_info.commandBufferCount = 1;
- submit_info.pCommandBuffers = &commandBuffer;
- submit_info.signalSemaphoreCount = 0;
- submit_info.pSignalSemaphores = NULL;
-
- err = pTableQueue->QueueSubmit(queue, 1, &submit_info, nullFence);
- assert(!err);
-
- err = pTableQueue->QueueWaitIdle(queue);
- assert(!err);
-
- err = pTableDevice->DeviceWaitIdle(device);
- assert(!err);
-
- pTableDevice->GetImageSubresourceLayout(device, image2, &sr, &sr_layout);
-
- err = pTableDevice->MapMemory(device, mem2, 0, 0, 0, (void **) &ptr );
- assert(!err);
-
- ptr += sr_layout.offset;
-
- ofstream file(filename, ios::binary);
-
- file << "P6\n";
- file << width << "\n";
- file << height << "\n";
- file << 255 << "\n";
-
- for (y = 0; y < height; y++) {
- const unsigned int *row = (const unsigned int*) ptr;
- if (format == VK_FORMAT_B8G8R8A8_UNORM)
- {
- for (x = 0; x < width; x++) {
- unsigned int swapped;
- swapped = (*row & 0xff00ff00) | (*row & 0x000000ff) << 16 | (*row & 0x00ff0000) >> 16;
- file.write((char *)&swapped, 3);
- row++;
- }
- }
- else if (format == VK_FORMAT_R8G8B8A8_UNORM)
- {
- for (x = 0; x < width; x++) {
- file.write((char *)row, 3);
- row++;
- }
- }
- else
- {
- // TODO: add support for additional formats
- printf("Unrecognized image format\n");
- break;
- }
- ptr += sr_layout.rowPitch;
- }
- file.close();
- pTableDevice->UnmapMemory(device, mem2);
-
- // Restore the swap chain image layout to what it was before.
- // This may not be strictly needed, but it is generally good to restore things to original state.
- err = pTableCommandBuffer->BeginCommandBuffer(commandBuffer, &commandBufferBeginInfo);
- assert(!err);
- image1_memory_barrier.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
- image1_memory_barrier.newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
-
- pTableCommandBuffer->CmdPipelineBarrier(commandBuffer, src_stages, dst_stages,
- 0, 0, NULL, 0, NULL, 1, &image1_memory_barrier);
- err = pTableCommandBuffer->EndCommandBuffer(commandBuffer);
- assert(!err);
-
- err = pTableQueue->QueueSubmit(queue, 1, &submit_info, nullFence);
- assert(!err);
-
- err = pTableQueue->QueueWaitIdle(queue);
- assert(!err);
-
- err = pTableDevice->DeviceWaitIdle(device);
- assert(!err);
-
- // Clean up
- pTableDevice->FreeMemory(device, mem2, NULL);
- pTableDevice->FreeCommandBuffers(device, deviceMap[device]->commandPool, 1, &commandBuffer);
-}
-
-VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(
- const VkInstanceCreateInfo* pCreateInfo,
- const VkAllocationCallbacks* pAllocator,
- VkInstance* pInstance)
-{
- VkLayerInstanceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO);
-
- assert(chain_info->u.pLayerInfo);
- PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr;
- assert(fpGetInstanceProcAddr);
- PFN_vkCreateInstance fpCreateInstance = (PFN_vkCreateInstance) fpGetInstanceProcAddr(*pInstance, "vkCreateInstance");
- if (fpCreateInstance == NULL) {
- return VK_ERROR_INITIALIZATION_FAILED;
- }
-
- // Advance the link info for the next element on the chain
- chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext;
-
- VkResult result = fpCreateInstance(pCreateInfo, pAllocator, pInstance);
- if (result != VK_SUCCESS)
- return result;
-
- initInstanceTable(*pInstance, fpGetInstanceProcAddr);
-
- init_screenshot();
-
- return result;
-}
-
-//TODO hook DestroyInstance to cleanup
-
-static void createDeviceRegisterExtensions(const VkDeviceCreateInfo* pCreateInfo, VkDevice device)
-{
- uint32_t i;
- VkLayerDispatchTable *pDisp = get_dispatch_table(screenshot_device_table_map, device);
- PFN_vkGetDeviceProcAddr gpa = pDisp->GetDeviceProcAddr;
- pDisp->CreateSwapchainKHR = (PFN_vkCreateSwapchainKHR) gpa(device, "vkCreateSwapchainKHR");
- 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->enabledExtensionCount; i++) {
- if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SWAPCHAIN_EXTENSION_NAME) == 0)
- deviceExtMap[pDisp].wsi_enabled = true;
- }
-}
-
-VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(
- VkPhysicalDevice gpu,
- const VkDeviceCreateInfo *pCreateInfo,
- const VkAllocationCallbacks* pAllocator,
- VkDevice *pDevice)
-{
- VkLayerDeviceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO);
-
- assert(chain_info->u.pLayerInfo);
- PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr;
- PFN_vkGetDeviceProcAddr fpGetDeviceProcAddr = chain_info->u.pLayerInfo->pfnNextGetDeviceProcAddr;
- PFN_vkCreateDevice fpCreateDevice = (PFN_vkCreateDevice) fpGetInstanceProcAddr(NULL, "vkCreateDevice");
- if (fpCreateDevice == NULL) {
- return VK_ERROR_INITIALIZATION_FAILED;
- }
-
- // Advance the link info for the next element on the chain
- chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext;
-
- VkResult result = fpCreateDevice(gpu, pCreateInfo, pAllocator, pDevice);
- if (result != VK_SUCCESS) {
- return result;
- }
-
- initDeviceTable(*pDevice, fpGetDeviceProcAddr, screenshot_device_table_map);
-
- createDeviceRegisterExtensions(pCreateInfo, *pDevice);
- // Create a mapping from a device to a physicalDevice
- if (deviceMap[*pDevice] == NULL)
- {
- DeviceMapStruct *deviceMapElem = new DeviceMapStruct;
- deviceMap[*pDevice] = deviceMapElem;
- }
- deviceMap[*pDevice]->physicalDevice = gpu;
-
- return result;
-}
-
-VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDevices(
- VkInstance instance,
- uint32_t* pPhysicalDeviceCount,
- VkPhysicalDevice* pPhysicalDevices)
-{
- VkResult result;
-
- VkLayerInstanceDispatchTable* pTable = instance_dispatch_table(instance);
- result = pTable->EnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices);
- if (result==VK_SUCCESS && *pPhysicalDeviceCount > 0 && pPhysicalDevices)
- {
- for (uint32_t i=0; i<*pPhysicalDeviceCount ; i++)
- {
- // Create a mapping from a physicalDevice to an instance
- if (physDeviceMap[pPhysicalDevices[i]] == NULL)
- {
- PhysDeviceMapStruct *physDeviceMapElem = new PhysDeviceMapStruct;
- physDeviceMap[pPhysicalDevices[i]] = physDeviceMapElem;
- }
- physDeviceMap[pPhysicalDevices[i]]->instance = instance;
- }
- }
- return result;
-}
-
-/* TODO: Probably need a DestroyDevice as well */
-
-static const VkLayerProperties ss_device_layers[] = {
- {
- "screenshot",
- VK_API_VERSION,
- VK_MAKE_VERSION(0, 1, 0),
- "Layer: screenshot",
- }
-};
-
-VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(
- const char *pLayerName,
- uint32_t *pCount,
- VkExtensionProperties* pProperties)
-{
- /* ScreenShot does not have any global extensions */
- return util_GetExtensionProperties(0, NULL, pCount, pProperties);
-}
-
-VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(
- uint32_t *pCount,
- VkLayerProperties* pProperties)
-{
- /* ScreenShot does not have any global layers */
- return util_GetLayerProperties(0, NULL,
- pCount, pProperties);
-}
-
-VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties(
- VkPhysicalDevice physicalDevice,
- const char* pLayerName,
- uint32_t* pCount,
- VkExtensionProperties* pProperties)
-{
- /* ScreenShot does not have any physical device extensions */
- if (pLayerName == NULL) {
- VkLayerInstanceDispatchTable* pTable = instance_dispatch_table(physicalDevice);
- return pTable->EnumerateDeviceExtensionProperties(
- physicalDevice,
- NULL,
- pCount,
- pProperties);
- } else {
- return util_GetExtensionProperties(0, NULL, pCount, pProperties);
- }
-}
-
-VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(
- VkPhysicalDevice physicalDevice,
- uint32_t* pCount,
- VkLayerProperties* pProperties)
-{
- return util_GetLayerProperties(ARRAY_SIZE(ss_device_layers),
- ss_device_layers,
- pCount, pProperties);
-}
-
-VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetDeviceQueue(
- VkDevice device,
- uint32_t queueNodeIndex,
- uint32_t queueIndex,
- VkQueue *pQueue)
-{
- VkLayerDispatchTable* pTable = screenshot_device_table_map[device];
- get_dispatch_table(screenshot_device_table_map, device)->GetDeviceQueue(device, queueNodeIndex, queueIndex, pQueue);
-
- loader_platform_thread_lock_mutex(&globalLock);
- if (screenshotEnvQueried && screenshotFrames.empty()) {
- // We are all done taking screenshots, so don't do anything else
- loader_platform_thread_unlock_mutex(&globalLock);
- return;
- }
-
- screenshot_device_table_map.emplace(*pQueue, pTable);
-
- // Create a mapping from a device to a queue
- if (deviceMap[device] == NULL)
- {
- DeviceMapStruct *deviceMapElem = new DeviceMapStruct;
- deviceMap[device] = deviceMapElem;
- }
- deviceMap[device]->queue = *pQueue;
- loader_platform_thread_unlock_mutex(&globalLock);
-}
-
-VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateCommandPool(
- VkDevice device,
- const VkCommandPoolCreateInfo *pCreateInfo,
- const VkAllocationCallbacks* pAllocator,
- VkCommandPool *pCommandPool)
-{
- VkLayerDispatchTable* pTable = screenshot_device_table_map[device];
- VkResult result = get_dispatch_table(screenshot_device_table_map, device)->CreateCommandPool(device, pCreateInfo, pAllocator, pCommandPool);
-
- loader_platform_thread_lock_mutex(&globalLock);
- if (screenshotEnvQueried && screenshotFrames.empty()) {
- // We are all done taking screenshots, so don't do anything else
- loader_platform_thread_unlock_mutex(&globalLock);
- return result;
- }
-
- // Create a mapping from a device to a commandPool
- if (deviceMap[device] == NULL)
- {
- DeviceMapStruct *deviceMapElem = new DeviceMapStruct;
- deviceMap[device] = deviceMapElem;
- }
- deviceMap[device]->commandPool = *pCommandPool;
- loader_platform_thread_unlock_mutex(&globalLock);
- return result;
-}
-
-VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR(
- VkDevice device,
- const VkSwapchainCreateInfoKHR *pCreateInfo,
- const VkAllocationCallbacks *pAllocator,
- VkSwapchainKHR *pSwapchain)
-{
- VkLayerDispatchTable* pTable = screenshot_device_table_map[device];
- VkResult result = get_dispatch_table(screenshot_device_table_map, device)->CreateSwapchainKHR(device, pCreateInfo, pAllocator, pSwapchain);
-
- loader_platform_thread_lock_mutex(&globalLock);
- if (screenshotEnvQueried && screenshotFrames.empty()) {
- // We are all done taking screenshots, so don't do anything else
- loader_platform_thread_unlock_mutex(&globalLock);
- return result;
- }
-
- if (result == VK_SUCCESS)
- {
- // Create a mapping for a swapchain to a device, image extent, and format
- SwapchainMapStruct *swapchainMapElem = new SwapchainMapStruct;
- swapchainMapElem->device = device;
- swapchainMapElem->imageExtent = pCreateInfo->imageExtent;
- swapchainMapElem->format = pCreateInfo->imageFormat;
- swapchainMap.insert(make_pair(*pSwapchain, swapchainMapElem));
-
- // Create a mapping for the swapchain object into the dispatch table
- screenshot_device_table_map.emplace((void *)pSwapchain, pTable);
- }
- loader_platform_thread_unlock_mutex(&globalLock);
-
- return result;
-}
-
-VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainImagesKHR(
- VkDevice device,
- VkSwapchainKHR swapchain,
- uint32_t* pCount,
- VkImage* pSwapchainImages)
-{
- VkResult result = get_dispatch_table(screenshot_device_table_map, device)->GetSwapchainImagesKHR(device, swapchain, pCount, pSwapchainImages);
-
- loader_platform_thread_lock_mutex(&globalLock);
- if (screenshotEnvQueried && screenshotFrames.empty()) {
- // We are all done taking screenshots, so don't do anything else
- loader_platform_thread_unlock_mutex(&globalLock);
- return result;
- }
-
- if (result == VK_SUCCESS &&
- pSwapchainImages &&
- !swapchainMap.empty() && swapchainMap.find(swapchain) != swapchainMap.end())
- {
- unsigned i;
-
- for (i=0; i<*pCount; i++)
- {
- // Create a mapping for an image to a device, image extent, and format
- if (imageMap[pSwapchainImages[i]] == NULL)
- {
- ImageMapStruct *imageMapElem = new ImageMapStruct;
- imageMap[pSwapchainImages[i]] = imageMapElem;
- }
- imageMap[pSwapchainImages[i]]->device = swapchainMap[swapchain]->device;
- imageMap[pSwapchainImages[i]]->imageExtent = swapchainMap[swapchain]->imageExtent;
- imageMap[pSwapchainImages[i]]->format = swapchainMap[swapchain]->format;
- }
-
- // Add list of images to swapchain to image map
- SwapchainMapStruct *swapchainMapElem = swapchainMap[swapchain];
- if (i >= 1 && swapchainMapElem)
- {
- VkImage *imageList = new VkImage[i];
- swapchainMapElem->imageList = imageList;
- for (unsigned j=0; j<i; j++)
- {
- swapchainMapElem->imageList[j] = pSwapchainImages[j];
- }
- }
-
- }
- loader_platform_thread_unlock_mutex(&globalLock);
- return result;
-}
-
-VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR* pPresentInfo)
-{
- static int frameNumber = 0;
- if (frameNumber == 10) {fflush(stdout); /* *((int*)0)=0; */ }
- VkResult result = get_dispatch_table(screenshot_device_table_map, queue)->QueuePresentKHR(queue, pPresentInfo);
-
- loader_platform_thread_lock_mutex(&globalLock);
-
- if (!screenshotEnvQueried)
- {
- const char *_vk_screenshot = loader_getenv("_VK_SCREENSHOT");
- if (_vk_screenshot && *_vk_screenshot)
- {
- string spec(_vk_screenshot), word;
- size_t start = 0, comma = 0;
-
- while (start < spec.size()) {
- int frameToAdd;
- comma = spec.find(',', start);
- if (comma == string::npos)
- word = string(spec, start);
- else
- word = string(spec, start, comma - start);
- frameToAdd=atoi(word.c_str());
- // Add the frame number to list, but only do it if the word started with a digit and if
- // it's not already in the list
- if (*(word.c_str()) >= '0' && *(word.c_str()) <= '9' &&
- find(screenshotFrames.begin(), screenshotFrames.end(), frameToAdd) == screenshotFrames.end())
- {
- screenshotFrames.push_back(frameToAdd);
- }
- if (comma == string::npos)
- break;
- start = comma + 1;
- }
- }
- loader_free_getenv(_vk_screenshot);
- screenshotEnvQueried = true;
- }
-
-
- if (result == VK_SUCCESS && !screenshotFrames.empty())
- {
- vector<int>::iterator it;
- it = find(screenshotFrames.begin(), screenshotFrames.end(), frameNumber);
- if (it != screenshotFrames.end())
- {
- string fileName;
- fileName = to_string(frameNumber) + ".ppm";
-
- VkImage image;
- VkSwapchainKHR swapchain;
- // We'll dump only one image: the first
- swapchain = pPresentInfo->pSwapchains[0];
- image = swapchainMap[swapchain]->imageList[pPresentInfo->pImageIndices[0]];
- writePPM(fileName.c_str(), image);
- screenshotFrames.erase(it);
-
- if (screenshotFrames.empty())
- {
- // Free all our maps since we are done with them.
- for (auto it = swapchainMap.begin(); it != swapchainMap.end(); it++)
- {
- SwapchainMapStruct *swapchainMapElem = it->second;
- delete swapchainMapElem;
- }
- for (auto it = imageMap.begin(); it != imageMap.end(); it++)
- {
- ImageMapStruct *imageMapElem = it->second;
- delete imageMapElem;
- }
- for (auto it = deviceMap.begin(); it != deviceMap.end(); it++)
- {
- DeviceMapStruct *deviceMapElem = it->second;
- delete deviceMapElem;
- }
- for (auto it = physDeviceMap.begin(); it != physDeviceMap.end(); it++)
- {
- PhysDeviceMapStruct *physDeviceMapElem = it->second;
- delete physDeviceMapElem;
- }
- swapchainMap.clear();
- imageMap.clear();
- deviceMap.clear();
- physDeviceMap.clear();
- }
- }
- }
- frameNumber++;
- loader_platform_thread_unlock_mutex(&globalLock);
- return result;
-}
-
-VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(
- VkDevice dev,
- const char *funcName)
-{
- if (!strcmp(funcName, "vkGetDeviceProcAddr"))
- return (PFN_vkVoidFunction)vkGetDeviceProcAddr;
- if (!strcmp(funcName, "vkGetDeviceQueue"))
- return (PFN_vkVoidFunction) vkGetDeviceQueue;
- if (!strcmp(funcName, "vkCreateCommandPool"))
- return (PFN_vkVoidFunction) vkCreateCommandPool;
-
- if (dev == NULL) {
- return NULL;
- }
-
- VkLayerDispatchTable *pDisp = get_dispatch_table(screenshot_device_table_map, dev);
- if (deviceExtMap.size() != 0 && deviceExtMap[pDisp].wsi_enabled)
- {
- if (!strcmp(funcName, "vkCreateSwapchainKHR"))
- return (PFN_vkVoidFunction) vkCreateSwapchainKHR;
- if (!strcmp(funcName, "vkGetSwapchainImagesKHR"))
- return (PFN_vkVoidFunction) vkGetSwapchainImagesKHR;
- if (!strcmp(funcName, "vkQueuePresentKHR"))
- return (PFN_vkVoidFunction) vkQueuePresentKHR;
- }
-
- if (pDisp->GetDeviceProcAddr == NULL)
- return NULL;
- return pDisp->GetDeviceProcAddr(dev, funcName);
-}
-
-
-VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char* funcName)
-{
-
- if (!strcmp("vkGetInstanceProcAddr", funcName))
- return (PFN_vkVoidFunction) vkGetInstanceProcAddr;
- if (!strcmp(funcName, "vkCreateInstance"))
- return (PFN_vkVoidFunction) vkCreateInstance;
- if (!strcmp(funcName, "vkCreateDevice"))
- return (PFN_vkVoidFunction) vkCreateDevice;
- if (!strcmp(funcName, "vkEnumeratePhysicalDevices"))
- return (PFN_vkVoidFunction)vkEnumeratePhysicalDevices;
- if (!strcmp(funcName, "vkEnumerateDeviceExtensionProperties"))
- return (PFN_vkVoidFunction)vkEnumerateDeviceExtensionProperties;
-
- if (instance == VK_NULL_HANDLE) {
- return NULL;
- }
- VkLayerInstanceDispatchTable* pTable = instance_dispatch_table(instance);
- if (pTable->GetInstanceProcAddr == NULL)
- return NULL;
- return pTable->GetInstanceProcAddr(instance, funcName);
-}
diff --git a/layers/vk_layer_settings.txt b/layers/vk_layer_settings.txt
index ae02457ee..48dcff2b0 100644
--- a/layers/vk_layer_settings.txt
+++ b/layers/vk_layer_settings.txt
@@ -73,17 +73,3 @@ ThreadingDebugAction = VK_DBG_LAYER_ACTION_LOG_MSG
ThreadingReportFlags = error,warn,perf
ThreadingLogFilename = stdout
-# 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
-# NoAddr TRUE causes "address" to be dumped in place of hex addresses
-ApiDumpNoAddr = FALSE
-# File = TRUE indicates that output should be written to file instead of STDOUT
-ApiDumpFile = FALSE
-# LogFilename is file to dump to when "File = TRUE" default is "vk_apidump.txt"
-ApiDumpLogFilename = stdout
-# Flush = TRUE causes IO to be flushed after each line that's written
-ApiDumpFlush = FALSE
-
diff --git a/layers/vk_validation_layer_details.md b/layers/vk_validation_layer_details.md
index 20cbe446e..fa3d6fa91 100644
--- a/layers/vk_validation_layer_details.md
+++ b/layers/vk_validation_layer_details.md
@@ -399,17 +399,6 @@ Additional checks to be added to VK_LAYER_LUNARG_swapchain
2. One issue that has already come up is correct UsageFlags for WSI SwapChains and SurfaceProperties.
3. Tons of other stuff including semaphore and synchronization validation.
-# Non-validation Layer Details
-
-## VK_LAYER_LUNARG_api_dump
-
-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_api_dump Pending Work
-
- 1. vkAllocateDescriptorSets does not correctly print out all of the created DescriptorSets (no array printing following main API txt)
-
-
## General Pending Work
A place to capture general validation work to be done. This includes new checks that don't clearly fit into the above layers.
diff --git a/layers/windows/VkLayer_api_dump.json b/layers/windows/VkLayer_api_dump.json
deleted file mode 100644
index 3aaae0d2b..000000000
--- a/layers/windows/VkLayer_api_dump.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_api_dump",
- "type": "GLOBAL",
- "library_path": ".\\VkLayer_api_dump.dll",
- "api_version": "1.0.1",
- "implementation_version": "1",
- "description": "LunarG debug layer"
- }
-}
diff --git a/layers/windows/VkLayer_basic.json b/layers/windows/VkLayer_basic.json
deleted file mode 100644
index 97b78a441..000000000
--- a/layers/windows/VkLayer_basic.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_basic",
- "type": "GLOBAL",
- "library_path": ".\\VkLayer_basic.dll",
- "api_version": "1.0.1",
- "implementation_version": "1",
- "description": "LunarG Sample Layer",
- "device_extensions": [
- {
- "name": "VK_LUNARG_LayerExtension1",
- "spec_version": "0",
- "entrypoints": ["vkLayerExtension1"]
- }
- ]
- }
-}
diff --git a/layers/windows/VkLayer_generic.json b/layers/windows/VkLayer_generic.json
deleted file mode 100644
index fb003923a..000000000
--- a/layers/windows/VkLayer_generic.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_generic",
- "type": "GLOBAL",
- "library_path": ".\\VkLayer_generic.dll",
- "api_version": "1.0.1",
- "implementation_version": "1",
- "description": "LunarG sample layer"
- }
-}
diff --git a/layers/windows/VkLayer_multi.json b/layers/windows/VkLayer_multi.json
deleted file mode 100644
index fa1d94ce8..000000000
--- a/layers/windows/VkLayer_multi.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_multi1",
- "type": "DEVICE",
- "library_path": ".\\VkLayer_multi.dll",
- "api_version": "1.0.1",
- "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": "1.0.1",
- "implementation_version": "1",
- "description": "LunarG Sample multiple layer per library",
- "functions" : {
- "vkGetInstanceProcAddr" : "multi2GetInstanceProcAddr"
- }
- }
-}
diff --git a/layers/windows/VkLayer_screenshot.json b/layers/windows/VkLayer_screenshot.json
deleted file mode 100644
index c857d6640..000000000
--- a/layers/windows/VkLayer_screenshot.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "file_format_version" : "1.0.0",
- "layer" : {
- "name": "VK_LAYER_LUNARG_screenshot",
- "type": "GLOBAL",
- "library_path": ".\\VkLayer_screenshot.dll",
- "api_version": "1.0.1",
- "implementation_version": "1",
- "description": "LunarG image capture layer"
- }
-}
diff --git a/vk-layer-generate.py b/vk-layer-generate.py
index b0235f0f7..ea44ceef6 100755
--- a/vk-layer-generate.py
+++ b/vk-layer-generate.py
@@ -343,7 +343,7 @@ class Subcommand(object):
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="object_tracker"):
ggep_body = []
# generated layers do not provide any global extensions
ggep_body.append('%s' % self.lineinfo.get())
@@ -365,23 +365,19 @@ class Subcommand(object):
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="object_tracker"):
ggep_body = []
- if layer == 'generic':
- # Do nothing, extension definition part of generic.h
- ggep_body.append('%s' % self.lineinfo.get())
- else:
- layer_name = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', layer)
- layer_name = re.sub('([a-z0-9])([A-Z])', r'\1_\2', layer_name).lower()
- ggep_body.append('%s' % self.lineinfo.get())
- ggep_body.append('static const VkLayerProperties globalLayerProps[] = {')
- ggep_body.append(' {')
- ggep_body.append(' "VK_LAYER_LUNARG_%s",' % layer_name)
- ggep_body.append(' VK_API_VERSION, // specVersion')
- ggep_body.append(' VK_MAKE_VERSION(0, 1, 0), // implementationVersion')
- ggep_body.append(' "layer: %s",' % layer)
- ggep_body.append(' }')
- ggep_body.append('};')
+ layer_name = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', layer)
+ layer_name = re.sub('([a-z0-9])([A-Z])', r'\1_\2', layer_name).lower()
+ ggep_body.append('%s' % self.lineinfo.get())
+ ggep_body.append('static const VkLayerProperties globalLayerProps[] = {')
+ ggep_body.append(' {')
+ ggep_body.append(' "VK_LAYER_LUNARG_%s",' % layer_name)
+ ggep_body.append(' VK_API_VERSION, // specVersion')
+ ggep_body.append(' VK_MAKE_VERSION(0, 1, 0), // implementationVersion')
+ ggep_body.append(' "layer: %s",' % layer)
+ ggep_body.append(' }')
+ ggep_body.append('};')
ggep_body.append('')
ggep_body.append('%s' % self.lineinfo.get())
ggep_body.append('')
@@ -391,21 +387,17 @@ class Subcommand(object):
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="object_tracker"):
gpdlp_body = []
- if layer == 'generic':
- # Do nothing, extension definition part of generic.h
- gpdlp_body.append('%s' % self.lineinfo.get())
- else:
- gpdlp_body.append('%s' % self.lineinfo.get())
- gpdlp_body.append('static const VkLayerProperties deviceLayerProps[] = {')
- gpdlp_body.append(' {')
- gpdlp_body.append(' "VK_LAYER_LUNARG_%s",' % layer)
- gpdlp_body.append(' VK_API_VERSION,')
- gpdlp_body.append(' VK_MAKE_VERSION(0, 1, 0),')
- gpdlp_body.append(' "layer: %s",' % layer)
- gpdlp_body.append(' }')
- gpdlp_body.append('};')
+ gpdlp_body.append('%s' % self.lineinfo.get())
+ gpdlp_body.append('static const VkLayerProperties deviceLayerProps[] = {')
+ gpdlp_body.append(' {')
+ gpdlp_body.append(' "VK_LAYER_LUNARG_%s",' % layer)
+ gpdlp_body.append(' VK_API_VERSION,')
+ gpdlp_body.append(' VK_MAKE_VERSION(0, 1, 0),')
+ gpdlp_body.append(' "layer: %s",' % layer)
+ gpdlp_body.append(' }')
+ gpdlp_body.append('};')
gpdlp_body.append('VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pCount, VkLayerProperties* pProperties)')
gpdlp_body.append('{')
gpdlp_body.append(' return util_GetLayerProperties(ARRAY_SIZE(deviceLayerProps), deviceLayerProps, pCount, pProperties);')
@@ -593,16 +585,7 @@ class Subcommand(object):
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 self.layer_name == 'generic':
- func_body.append("\n"
- " if (!strcmp(\"vkGetDeviceProcAddr\", funcName)) {\n"
- " return (PFN_vkVoidFunction) vkGetDeviceProcAddr;\n"
- " }\n\n"
- " addr = layer_intercept_proc(funcName);\n"
- " if (addr)\n"
- " return addr;")
- else:
- func_body.append("\n"
+ func_body.append("\n"
" loader_platform_thread_once(&initOnce, init%s);\n\n"
" if (!strcmp(\"vkGetDeviceProcAddr\", funcName)) {\n"
" return (PFN_vkVoidFunction) vkGetDeviceProcAddr;\n"
@@ -645,13 +628,7 @@ class Subcommand(object):
" if (!strcmp(funcName, \"vkCreateDevice\"))\n"
" return (PFN_vkVoidFunction) vkCreateDevice;\n"
)
- if self.layer_name == 'generic':
- func_body.append("\n"
- " addr = layer_intercept_instance_proc(funcName);\n"
- " if (addr)\n"
- " return addr;")
- else:
- func_body.append(
+ func_body.append(
" loader_platform_thread_once(&initOnce, init%s);\n\n"
" addr = layer_intercept_instance_proc(funcName);\n"
" if (addr)\n"
@@ -778,592 +755,6 @@ class Subcommand(object):
func_body.append('')
return "\n".join(func_body)
-class LayerFuncsSubcommand(Subcommand):
- def generate_header(self):
- return '#include <vulkan/vk_layer.h>\n#include "loader.h"'
-
- def generate_body(self):
- return self._generate_dispatch_entrypoints("static")
-
-class GenericLayerSubcommand(Subcommand):
- def generate_header(self):
- gen_header = []
- gen_header.append('%s' % self.lineinfo.get())
- gen_header.append('#include <stdio.h>')
- gen_header.append('#include <stdlib.h>')
- gen_header.append('#include <string.h>')
- gen_header.append('#include <unordered_map>')
- gen_header.append('#include "vk_loader_platform.h"')
- gen_header.append('#include "vulkan/vk_layer.h"')
- gen_header.append('#include "vk_layer_config.h"')
- gen_header.append('#include "vk_layer_logging.h"')
- gen_header.append('#include "vk_layer_table.h"')
- gen_header.append('#include "vk_layer_extension_utils.h"')
- gen_header.append('')
- gen_header.append('#include "generic.h"')
- gen_header.append('')
- gen_header.append('%s' % self.lineinfo.get())
- gen_header.append('#define LAYER_EXT_ARRAY_SIZE 1')
- gen_header.append('#define LAYER_DEV_EXT_ARRAY_SIZE 1')
- gen_header.append('//static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(initOnce);')
- gen_header.append('static std::unordered_map<void *, layer_data *> layer_data_map;\n')
- gen_header.append('template layer_data *get_my_data_ptr<layer_data>(')
- gen_header.append(' void *data_key,')
- gen_header.append(' std::unordered_map<void *, layer_data *> &data_map);\n')
- gen_header.append('')
- return "\n".join(gen_header)
-
- def generate_intercept(self, proto, qual):
- if proto.name in [ 'EnumerateInstanceLayerProperties', 'EnumerateInstanceExtensionProperties', 'EnumerateDeviceLayerProperties', 'EnumerateDeviceExtensionProperties' ]:
- # use default version
- return None
- decl = proto.c_func(prefix="vk", attr="VKAPI")
- ret_val = ''
- stmt = ''
- funcs = []
- table = ''
- if proto_is_global(proto):
- table = 'Instance'
- if proto.ret != "void":
- funcs.append('%s' % self.lineinfo.get())
- ret_val = "%s result = " % proto.ret
- stmt = " return result;\n"
- if proto.name == "CreateDevice":
- funcs.append('%s' % self.lineinfo.get())
- funcs.append('%s%s\n'
- '{\n'
- ' layer_data *my_instance_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map);\n'
- ' char str[1024];\n'
- ' sprintf(str, "At start of Generic layered %s\\n");\n'
- ' log_msg(my_instance_data->report_data, VK_DEBUG_REPORT_INFO_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT,'
- ' (uint64_t)physicalDevice, __LINE__, 0, (char *) "generic", "%%s", (char *) str);\n'
- ' VkLayerDeviceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO);\n'
- ' PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr;\n'
- ' PFN_vkGetDeviceProcAddr fpGetDeviceProcAddr = chain_info->u.pLayerInfo->pfnNextGetDeviceProcAddr;\n'
- ' PFN_vkCreateDevice fpCreateDevice = (PFN_vkCreateDevice) fpGetInstanceProcAddr(NULL, "vkCreateDevice");\n'
- ' if (fpCreateDevice == NULL) {\n'
- ' return VK_ERROR_INITIALIZATION_FAILED;\n'
- ' }\n'
- ' // Advance the link info for the next element on the chain\n'
- ' chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext;\n'
- ' VkResult result = fpCreateDevice(physicalDevice, pCreateInfo, pAllocator, pDevice);\n'
- ' if (result != VK_SUCCESS) {\n'
- ' return result;\n'
- ' }\n'
- ' layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(*pDevice), layer_data_map);\n'
- ' initDeviceTable(*pDevice, fpGetDeviceProcAddr);\n'
- ' my_device_data->report_data = layer_debug_report_create_device(my_instance_data->report_data, *pDevice);\n'
- ' createDeviceRegisterExtensions(pCreateInfo, *pDevice);\n'
- ' sprintf(str, "Completed generic layered %s\\n");\n'
- ' log_msg(my_device_data->report_data, VK_DEBUG_REPORT_INFO_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, (uint64_t)physicalDevice, __LINE__, 0, (char *) "generic", "%%s", (char *) str);\n'
- ' %s'
- '}' % (qual, decl, proto.name, proto.name, stmt))
- elif proto.name == "DestroyDevice":
- funcs.append('%s' % self.lineinfo.get())
- funcs.append('%s%s\n'
- '{\n'
- ' dispatch_key key = get_dispatch_key(device);\n'
- ' VkLayerDispatchTable *pDisp = device_dispatch_table(device);\n'
- ' pDisp->DestroyDevice(device, pAllocator);\n'
- ' deviceExtMap.erase(pDisp);\n'
- ' destroy_device_dispatch_table(key);\n'
- '}\n' % (qual, decl))
- elif proto.name == "DestroyInstance":
- funcs.append('%s' % self.lineinfo.get())
- funcs.append('%s%s\n'
- '{\n'
- ' dispatch_key key = get_dispatch_key(instance);\n'
- ' VkLayerInstanceDispatchTable *pDisp = instance_dispatch_table(instance);\n'
- ' pDisp->DestroyInstance(instance, pAllocator);\n'
- ' // Clean up logging callback, if any\n'
- ' layer_data *my_data = get_my_data_ptr(key, layer_data_map);\n'
- ' if (my_data->logging_callback) {\n'
- ' layer_destroy_msg_callback(my_data->report_data, my_data->logging_callback, pAllocator);\n'
- ' }\n\n'
- ' layer_debug_report_destroy_instance(my_data->report_data);\n'
- ' layer_data_map.erase(key);\n'
- ' instanceExtMap.erase(pDisp);\n'
- ' destroy_instance_dispatch_table(key);\n'
- '}\n' % (qual, decl))
- elif proto.name == "CreateInstance":
- funcs.append('%s' % self.lineinfo.get())
- # CreateInstance needs to use the second parm instead of the first to set the correct dispatch table
- funcs.append('%s%s\n'
- '{\n'
- ' char str[1024];\n'
- ' VkLayerInstanceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO);\n'
- ' PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr;\n'
- ' PFN_vkCreateInstance fpCreateInstance = (PFN_vkCreateInstance) fpGetInstanceProcAddr(NULL, "vkCreateInstance");\n'
- ' if (fpCreateInstance == NULL) {\n'
- ' return VK_ERROR_INITIALIZATION_FAILED;\n'
- ' }\n'
- ' // Advance the link info for the next element on the chain\n'
- ' chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext;\n'
- ' VkResult result = fpCreateInstance(pCreateInfo, pAllocator, pInstance);\n'
- ' if (result != VK_SUCCESS) {\n'
- ' return result;\n'
- ' }\n'
- ' VkLayerInstanceDispatchTable *pTable = initInstanceTable(*pInstance, fpGetInstanceProcAddr);\n'
- ' createInstanceRegisterExtensions(pCreateInfo, *pInstance);\n'
- ' layer_data *my_data = get_my_data_ptr(get_dispatch_key(*pInstance), layer_data_map);\n'
- ' my_data->report_data = debug_report_create_instance(\n'
- ' pTable,\n'
- ' *pInstance,\n'
- ' pCreateInfo->enabledExtensionCount,\n'
- ' pCreateInfo->ppEnabledExtensionNames);\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, __LINE__, 0, (char *) "generic", "%%s", (char *) str);\n'
- ' return result;\n'
- '}\n' % (qual, decl, proto.name))
- else:
- if wsi_name(proto.name):
- funcs.append('%s' % wsi_ifdef(proto.name))
- funcs.append('%s' % self.lineinfo.get())
- dispatch_param = proto.params[0].name
- # Must use 'instance' table for these APIs, 'device' table otherwise
- table_type = ""
- if proto_is_global(proto):
- table_type = "instance"
- else:
- table_type = "device"
- funcs.append('%s%s\n'
- '{\n'
- ' %s%s_dispatch_table(%s)->%s;\n'
- '%s'
- '}' % (qual, decl, ret_val, table_type, dispatch_param, proto.c_call(), stmt))
- if wsi_name(proto.name):
- funcs.append('%s' % wsi_endif(proto.name))
- return "\n\n".join(funcs)
-
- def generate_body(self):
- self.layer_name = "generic"
- instance_extensions=[('msg_callback_get_proc_addr', []),
- ('wsi_enabled',
- ['vkGetPhysicalDeviceSurfaceSupportKHR',
- 'vkGetPhysicalDeviceSurfaceCapabilitiesKHR',
- 'vkGetPhysicalDeviceSurfaceFormatsKHR',
- 'vkGetPhysicalDeviceSurfacePresentModesKHR'])]
- extensions=[('wsi_enabled',
- ['vkCreateSwapchainKHR',
- 'vkDestroySwapchainKHR', 'vkGetSwapchainImagesKHR',
- 'vkAcquireNextImageKHR', 'vkQueuePresentKHR'])]
- body = [self._generate_layer_initialization(True),
- self._generate_dispatch_entrypoints("VK_LAYER_EXPORT"),
- self._gen_create_msg_callback(),
- self._gen_destroy_msg_callback(),
- self._gen_debug_report_msg(),
- self._generate_layer_gpa_function(extensions, instance_extensions)]
-
- return "\n\n".join(body)
-
-class ApiDumpSubcommand(Subcommand):
- def generate_header(self):
- header_txt = []
- header_txt.append('%s' % self.lineinfo.get())
- header_txt.append('#include <fstream>')
- header_txt.append('#include <iostream>')
- header_txt.append('#include <string>')
- header_txt.append('#include <string.h>')
- header_txt.append('')
- header_txt.append('#include "vk_loader_platform.h"')
- header_txt.append('#include "vulkan/vk_layer.h"')
- header_txt.append('#include "vk_struct_string_helper_cpp.h"')
- 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 "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('std::ostream* outputStream = NULL;')
- header_txt.append('void ConfigureOutputStream(bool writeToFile, bool flushAfterWrite)')
- header_txt.append('{')
- header_txt.append(' if(writeToFile)')
- header_txt.append(' {')
- header_txt.append(' if (fileName == "stdout")')
- header_txt.append(' {')
- header_txt.append(' outputStream = &std::cout;')
- 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 << "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;')
- header_txt.append(' }')
- header_txt.append(' }')
- header_txt.append(' else')
- header_txt.append(' {')
- header_txt.append(' outputStream = &std::cout;')
- header_txt.append(' }')
- header_txt.append('')
- header_txt.append(' if(flushAfterWrite)')
- header_txt.append(' {')
- header_txt.append(' outputStream->sync_with_stdio(true);')
- header_txt.append(' }')
- header_txt.append(' else')
- header_txt.append(' {')
- header_txt.append(' outputStream->sync_with_stdio(false);')
- header_txt.append(' }')
- header_txt.append('}')
- header_txt.append('')
- header_txt.append('%s' % self.lineinfo.get())
- header_txt.append('static bool g_ApiDumpDetailed = true;')
- header_txt.append('')
- header_txt.append('static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(initOnce);')
- header_txt.append('')
- header_txt.append('static int printLockInitialized = 0;')
- header_txt.append('static loader_platform_thread_mutex printLock;')
- header_txt.append('')
- header_txt.append('%s' % self.lineinfo.get())
- header_txt.append('#define LAYER_EXT_ARRAY_SIZE 1')
- header_txt.append('#define LAYER_DEV_EXT_ARRAY_SIZE 1')
- header_txt.append('#define MAX_TID 513')
- header_txt.append('static loader_platform_thread_id tidMapping[MAX_TID] = {0};')
- header_txt.append('static uint32_t maxTID = 0;')
- header_txt.append('// Map actual TID to an index value and return that index')
- header_txt.append('// This keeps TIDs in range from 0-MAX_TID and simplifies compares between runs')
- header_txt.append('static uint32_t getTIDIndex() {')
- header_txt.append(' loader_platform_thread_id tid = loader_platform_get_thread_id();')
- header_txt.append(' for (uint32_t i = 0; i < maxTID; i++) {')
- header_txt.append(' if (tid == tidMapping[i])')
- header_txt.append(' return i;')
- header_txt.append(' }')
- header_txt.append(" // Don't yet have mapping, set it and return newly set index")
- header_txt.append(' uint32_t retVal = (uint32_t) maxTID;')
- header_txt.append(' tidMapping[maxTID++] = tid;')
- header_txt.append(' assert(maxTID < MAX_TID);')
- header_txt.append(' return retVal;')
- header_txt.append('}')
- header_txt.append('')
- return "\n".join(header_txt)
-
- def generate_init(self):
- func_body = []
- func_body.append('%s' % self.lineinfo.get())
- func_body.append('#include "vk_dispatch_table_helper.h"')
- func_body.append('#include "vk_layer_config.h"')
- func_body.append('')
- func_body.append('static void init%s(void)' % self.layer_name)
- func_body.append('{')
- func_body.append(' using namespace StreamControl;')
- func_body.append('')
- func_body.append(' char const*const logName = getLayerOption("ApiDumpLogFilename");')
- func_body.append(' if(logName != NULL)')
- func_body.append(' {')
- func_body.append(' fileName = logName;')
- func_body.append(' }')
- func_body.append('')
- func_body.append(' char const*const detailedStr = getLayerOption("ApiDumpDetailed");')
- func_body.append(' if(detailedStr != NULL)')
- func_body.append(' {')
- func_body.append(' if(strcmp(detailedStr, "TRUE") == 0)')
- func_body.append(' {')
- func_body.append(' g_ApiDumpDetailed = true;')
- func_body.append(' }')
- func_body.append(' else if(strcmp(detailedStr, "FALSE") == 0)')
- func_body.append(' {')
- func_body.append(' g_ApiDumpDetailed = false;')
- func_body.append(' }')
- func_body.append(' }')
- func_body.append('')
- func_body.append(' char const*const writeToFileStr = getLayerOption("ApiDumpFile");')
- func_body.append(' bool writeToFile = false;')
- func_body.append(' if(writeToFileStr != NULL)')
- func_body.append(' {')
- func_body.append(' if(strcmp(writeToFileStr, "TRUE") == 0)')
- func_body.append(' {')
- func_body.append(' writeToFile = true;')
- func_body.append(' }')
- func_body.append(' else if(strcmp(writeToFileStr, "FALSE") == 0)')
- func_body.append(' {')
- func_body.append(' writeToFile = false;')
- func_body.append(' }')
- func_body.append(' }')
- func_body.append('')
- func_body.append('%s' % self.lineinfo.get())
- func_body.append(' char const*const noAddrStr = getLayerOption("ApiDumpNoAddr");')
- func_body.append(' if(noAddrStr != NULL)')
- func_body.append(' {')
- func_body.append(' if(strcmp(noAddrStr, "FALSE") == 0)')
- func_body.append(' {')
- func_body.append(' StreamControl::writeAddress = true;')
- func_body.append(' }')
- func_body.append(' else if(strcmp(noAddrStr, "TRUE") == 0)')
- func_body.append(' {')
- func_body.append(' StreamControl::writeAddress = false;')
- func_body.append(' }')
- func_body.append(' }')
- func_body.append('')
- func_body.append(' char const*const flushAfterWriteStr = getLayerOption("ApiDumpFlush");')
- func_body.append(' bool flushAfterWrite = false;')
- func_body.append(' if(flushAfterWriteStr != NULL)')
- func_body.append(' {')
- func_body.append(' if(strcmp(flushAfterWriteStr, "TRUE") == 0)')
- func_body.append(' {')
- func_body.append(' flushAfterWrite = true;')
- func_body.append(' }')
- func_body.append(' else if(strcmp(flushAfterWriteStr, "FALSE") == 0)')
- func_body.append(' {')
- func_body.append(' flushAfterWrite = false;')
- func_body.append(' }')
- func_body.append(' }')
- func_body.append('')
- func_body.append('%s' % self.lineinfo.get())
- func_body.append(' ConfigureOutputStream(writeToFile, flushAfterWrite);')
- func_body.append('')
- func_body.append(' if (!printLockInitialized)')
- func_body.append(' {')
- func_body.append(' // TODO/TBD: Need to delete this mutex sometime. How???')
- func_body.append(' loader_platform_thread_create_mutex(&printLock);')
- func_body.append(' printLockInitialized = 1;')
- func_body.append(' }')
- func_body.append('}')
- func_body.append('')
- return "\n".join(func_body)
-
- def generate_intercept(self, proto, qual):
- if proto.name in [ 'EnumerateInstanceLayerProperties','EnumerateInstanceExtensionProperties','EnumerateDeviceLayerProperties','EnumerateDeviceExtensionProperties']:
- return None
- decl = proto.c_func(prefix="vk", attr="VKAPI")
- ret_val = ''
- stmt = ''
- funcs = []
- sp_param_dict = {} # Store 'index' for struct param to print, or an name of binding "Count" param for array to print
- create_params = 0 # Num of params at end of function that are created and returned as output values
- if 'AllocateDescriptorSets' in proto.name:
- create_params = -1
- elif 'Create' in proto.name or 'Alloc' in proto.name or 'MapMemory' in proto.name:
- create_params = -1
- if proto.ret != "void":
- ret_val = "%s result = " % proto.ret
- stmt = " return result;\n"
- f_open = 'loader_platform_thread_lock_mutex(&printLock);\n '
- log_func = '%s\n' % self.lineinfo.get()
- log_func += ' if (StreamControl::writeAddress == true) {'
- log_func += '\n (*outputStream) << "t{" << getTIDIndex() << "} vk%s(' % proto.name
- log_func_no_addr = '\n (*outputStream) << "t{" << getTIDIndex() << "} vk%s(' % proto.name
- f_close = '\n loader_platform_thread_unlock_mutex(&printLock);'
- pindex = 0
- prev_count_name = ''
- for p in proto.params:
- cp = False
- if 0 != create_params:
- # If this is any of the N last params of the func, treat as output
- for y in range(-1, create_params-1, -1):
- if p.name == proto.params[y].name:
- cp = True
- (pft, pfi) = self._get_printf_params(p.ty, p.name, cp, cpp=True)
- if p.name == "pSwapchain" or p.name == "pSwapchainImages":
- log_func += '%s = " << %s << ", ' % (p.name, p.name)
- elif p.name == "swapchain" or p.name == "visual_id":
- log_func += '%s = " << %s << ", ' % (p.name, p.name)
- else:
- log_func += '%s = " << %s << ", ' % (p.name, pfi)
- if "%p" == pft:
- log_func_no_addr += '%s = address, ' % (p.name)
- else:
- log_func_no_addr += '%s = " << %s << ", ' % (p.name, pfi)
- if prev_count_name != '' and (prev_count_name.replace('Count', '')[1:] in p.name):
- sp_param_dict[pindex] = prev_count_name
- prev_count_name = ''
- elif vk_helper.is_type(p.ty.strip('*').replace('const ', ''), 'struct'):
- sp_param_dict[pindex] = 'index'
- if p.name.endswith('Count'):
- if '*' in p.ty:
- prev_count_name = "*%s" % p.name
- else:
- prev_count_name = p.name
- else:
- prev_count_name = ''
- pindex += 1
- log_func = log_func.strip(', ')
- log_func_no_addr = log_func_no_addr.strip(', ')
- if proto.ret == "VkResult":
- log_func += ') = " << string_VkResult((VkResult)result) << endl'
- log_func_no_addr += ') = " << string_VkResult((VkResult)result) << endl'
- elif proto.ret == "void*":
- log_func += ') = " << result << endl'
- log_func_no_addr += ') = " << result << endl'
- else:
- log_func += ')\\n"'
- log_func_no_addr += ')\\n"'
- log_func += ';'
- log_func_no_addr += ';'
- log_func += '\n }\n else {%s\n }' % log_func_no_addr;
- log_func += '\n%s' % self.lineinfo.get()
- # log_func += '\n// Proto %s has param_dict: %s' % (proto.name, sp_param_dict)
- if len(sp_param_dict) > 0:
- indent = ' '
- log_func += '\n%sif (g_ApiDumpDetailed) {' % indent
- indent += ' '
- i_decl = False
- log_func += '\n%s' % self.lineinfo.get()
- log_func += '\n%sstring tmp_str;' % indent
- for sp_index in sp_param_dict:
- # log_func += '\n// sp_index: %s' % str(sp_index)
- if 'index' == sp_param_dict[sp_index]:
- cis_print_func = 'vk_print_%s' % (proto.params[sp_index].ty.replace('const ', '').strip('*').lower())
- local_name = proto.params[sp_index].name
- if '*' not in proto.params[sp_index].ty:
- local_name = '&%s' % proto.params[sp_index].name
- log_func += '\n%s' % self.lineinfo.get()
- log_func += '\n%sif (%s) {' % (indent, local_name)
- indent += ' '
- log_func += '\n%stmp_str = %s(%s, " ");' % (indent, cis_print_func, local_name)
- log_func += '\n%s(*outputStream) << " %s (" << %s << ")" << endl << tmp_str << endl;' % (indent, local_name, local_name)
- indent = indent[4:]
- log_func += '\n%s}' % (indent)
- else: # We have a count value stored to iterate over an array
- print_cast = ''
- print_func = ''
- if vk_helper.is_type(proto.params[sp_index].ty.strip('*').replace('const ', ''), 'struct'):
- print_cast = '&'
- print_func = 'vk_print_%s' % proto.params[sp_index].ty.replace('const ', '').strip('*').lower()
- else:
- print_cast = ''
- print_func = 'string_convert_helper'
- #cis_print_func = 'tmp_str = string_convert_helper((void*)%s[i], " ");' % proto.params[sp_index].name
- cis_print_func = 'tmp_str = %s(%s%s[i], " ");' % (print_func, print_cast, proto.params[sp_index].name)
- if not i_decl:
- log_func += '\n%suint32_t i;' % (indent)
- i_decl = True
- log_func += '\n%sif (%s) {' % (indent, proto.params[sp_index].name)
- indent += ' '
- log_func += '\n%s' % self.lineinfo.get()
- log_func += '\n%sfor (i = 0; i < %s; i++) {' % (indent, sp_param_dict[sp_index])
- indent += ' '
- log_func += '\n%s%s' % (indent, cis_print_func)
- log_func += '\n%sif (StreamControl::writeAddress == true) {' % (indent)
- indent += ' '
- log_func += '\n%s(*outputStream) << " %s[" << i << "] (" << %s%s[i] << ")" << endl << tmp_str << endl;' % (indent, proto.params[sp_index].name, '&', proto.params[sp_index].name)
- indent = indent[4:]
- log_func += '\n%s} else {' % (indent)
- indent += ' '
- log_func += '\n%s(*outputStream) << " %s[" << i << "] (address)" << endl << " address" << endl;' % (indent, proto.params[sp_index].name)
- indent = indent[4:]
- log_func += '\n%s}' % (indent)
- indent = indent[4:]
- log_func += '\n%s}' % (indent)
- indent = indent[4:]
- log_func += '\n%s}' % (indent)
- indent = indent[4:]
- log_func += '\n%s}' % (indent)
- table_type = ''
- if proto_is_global(proto):
- table_type = 'instance'
- else:
- table_type = 'device'
- dispatch_param = proto.params[0].name
-
- if proto.name == "CreateInstance":
- dispatch_param = '*' + proto.params[1].name
- funcs.append('%s%s\n'
- '{\n'
- ' using namespace StreamControl;\n'
- ' loader_platform_thread_once(&initOnce, initapi_dump);\n'
- ' VkLayerInstanceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO);\n'
- ' PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr;\n'
- ' PFN_vkCreateInstance fpCreateInstance = (PFN_vkCreateInstance) fpGetInstanceProcAddr(NULL, "vkCreateInstance");\n'
- ' if (fpCreateInstance == NULL) {\n'
- ' return VK_ERROR_INITIALIZATION_FAILED;\n'
- ' }\n'
- ' // Advance the link info for the next element on the chain\n'
- ' assert(chain_info->u.pLayerInfo);\n'
- ' chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext;\n'
- ' VkResult result = fpCreateInstance(pCreateInfo, pAllocator, pInstance);\n'
- ' if (result != VK_SUCCESS)\n'
- ' return result;\n'
- ' initInstanceTable(*pInstance, fpGetInstanceProcAddr);\n'
- ' createInstanceRegisterExtensions(pCreateInfo, *pInstance);\n'
- ' %s%s%s\n'
- '%s'
- '}\n' % (qual, decl, f_open, log_func, f_close, stmt))
-
- elif proto.name == "CreateDevice":
- funcs.append('%s\n' % self.lineinfo.get())
- funcs.append('%s%s\n'
- '{\n'
- ' using namespace StreamControl;\n'
- ' %sexplicit_CreateDevice(physicalDevice, pCreateInfo, pAllocator, pDevice);\n'
- ' %s%s%s\n'
- '%s'
- '}' % (qual, decl, ret_val, f_open, log_func, f_close, stmt))
- elif proto.name == "DestroyDevice":
- funcs.append('%s%s\n'
- '{\n'
- ' using namespace StreamControl;\n'
- ' dispatch_key key = get_dispatch_key(device);\n'
- ' VkLayerDispatchTable *pDisp = %s_dispatch_table(%s);\n'
- ' %spDisp->%s;\n'
- ' deviceExtMap.erase(pDisp);\n'
- ' destroy_device_dispatch_table(key);\n'
- ' %s%s%s\n'
- '%s'
- '}' % (qual, decl, table_type, dispatch_param, ret_val, proto.c_call(), f_open, log_func, f_close, stmt))
- elif proto.name == "DestroyInstance":
- funcs.append('%s%s\n'
- '{\n'
- ' using namespace StreamControl;\n'
- ' dispatch_key key = get_dispatch_key(instance);\n'
- ' VkLayerInstanceDispatchTable *pDisp = %s_dispatch_table(%s);\n'
- ' %spDisp->%s;\n'
- ' instanceExtMap.erase(pDisp);\n'
- ' destroy_instance_dispatch_table(key);\n'
- ' %s%s%s\n'
- '%s'
- '}' % (qual, decl, table_type, dispatch_param, ret_val, proto.c_call(), f_open, log_func, f_close, stmt))
- else:
- if wsi_name(decl):
- funcs.append('%s' % wsi_ifdef(decl))
- funcs.append('%s%s\n'
- '{\n'
- ' using namespace StreamControl;\n'
- ' %s%s_dispatch_table(%s)->%s;\n'
- ' %s%s%s\n'
- '%s'
- '}' % (qual, decl, ret_val, table_type, dispatch_param, proto.c_call(), f_open, log_func, f_close, stmt))
- if wsi_name(decl):
- funcs.append('%s' % wsi_endif(decl))
- return "\n\n".join(funcs)
-
- def generate_body(self):
- self.layer_name = "api_dump"
- if sys.platform.startswith('win32'):
- instance_extensions=[('wsi_enabled',
- ['vkGetPhysicalDeviceSurfaceSupportKHR',
- 'vkGetPhysicalDeviceSurfaceCapabilitiesKHR',
- 'vkGetPhysicalDeviceSurfaceFormatsKHR',
- 'vkGetPhysicalDeviceSurfacePresentModesKHR',
- 'vkCreateWin32SurfaceKHR',
- 'vkGetPhysicalDeviceWin32PresentationSupportKHR'])]
- elif sys.platform.startswith('linux'):
- instance_extensions=[('wsi_enabled',
- ['vkGetPhysicalDeviceSurfaceSupportKHR',
- 'vkGetPhysicalDeviceSurfaceCapabilitiesKHR',
- 'vkGetPhysicalDeviceSurfaceFormatsKHR',
- 'vkGetPhysicalDeviceSurfacePresentModesKHR',
- 'vkCreateXcbSurfaceKHR',
- 'vkGetPhysicalDeviceXcbPresentationSupportKHR'])]
- # TODO: Add cases for Mir, Xlib, Wayland
- else:
- instance_extensions=[('wsi_enabled',
- ['vkGetPhysicalDeviceSurfaceSupportKHR',
- 'vkGetPhysicalDeviceSurfaceCapabilitiesKHR',
- 'vkGetPhysicalDeviceSurfaceFormatsKHR',
- 'vkGetPhysicalDeviceSurfacePresentModesKHR'])]
- extensions=[('wsi_enabled',
- ['vkCreateSwapchainKHR',
- 'vkDestroySwapchainKHR', 'vkGetSwapchainImagesKHR',
- 'vkAcquireNextImageKHR', 'vkQueuePresentKHR'])]
- body = [self.generate_init(),
- self._generate_dispatch_entrypoints("VK_LAYER_EXPORT"),
- self._generate_layer_gpa_function(extensions, instance_extensions)]
- return "\n\n".join(body)
-
class ObjectTrackerSubcommand(Subcommand):
def generate_header(self):
header_txt = []
@@ -2570,9 +1961,6 @@ class ThreadingSubcommand(Subcommand):
def main():
subcommands = {
- "layer-funcs" : LayerFuncsSubcommand,
- "generic" : GenericLayerSubcommand,
- "api_dump" : ApiDumpSubcommand,
"object_tracker" : ObjectTrackerSubcommand,
"threading" : ThreadingSubcommand,
"unique_objects" : UniqueObjectsSubcommand,