diff --git a/layer_example/source/device.cpp b/layer_example/source/device.cpp index 580e339..3371cff 100644 --- a/layer_example/source/device.cpp +++ b/layer_example/source/device.cpp @@ -34,6 +34,9 @@ #include "device.hpp" #include "instance.hpp" +/** + * @brief The dispatch lookup for all of the created Vulkan instances. + */ static std::unordered_map> g_devices; /* See header for documentation. */ @@ -47,8 +50,8 @@ void Device::store( /* See header for documentation. */ Device* Device::retrieve( - VkDevice handle) -{ + VkDevice handle +) { void* key = getDispatchKey(handle); assert(isInMap(key, g_devices)); return g_devices.at(key).get(); @@ -56,8 +59,8 @@ Device* Device::retrieve( /* See header for documentation. */ Device* Device::retrieve( - VkQueue handle) -{ + VkQueue handle +) { void* key = getDispatchKey(handle); assert(isInMap(key, g_devices)); return g_devices.at(key).get(); @@ -65,8 +68,8 @@ Device* Device::retrieve( /* See header for documentation. */ Device* Device::retrieve( - VkCommandBuffer handle) -{ + VkCommandBuffer handle +) { void* key = getDispatchKey(handle); assert(isInMap(key, g_devices)); return g_devices.at(key).get(); @@ -85,15 +88,10 @@ Device::Device( VkPhysicalDevice _physicalDevice, VkDevice _device, PFN_vkGetDeviceProcAddr nlayerGetProcAddress -): instance(_instance), +): + instance(_instance), physicalDevice(_physicalDevice), device(_device) { initDriverDeviceDispatchTable(device, nlayerGetProcAddress, driver); } - -/* See header for documentation. */ -Device::~Device() -{ - -} diff --git a/layer_example/source/device.hpp b/layer_example/source/device.hpp index d6ecad7..c0e1f0a 100644 --- a/layer_example/source/device.hpp +++ b/layer_example/source/device.hpp @@ -24,8 +24,7 @@ */ /** - * @file - * Declares the root class for layer management of VkDevice objects. + * @file Declares the root class for layer management of VkDevice objects. * * Role summary * ============ @@ -41,10 +40,9 @@ * Key properties * ============== * - * Unlike EGL contexts, Vulkan devices are designed to be used concurrently by - * multiple application threads. An application can have multiple concurrent - * devices (although this is less common than with OpenGL ES applications), and - * use each device from multiple threads. + * Vulkan devices are designed to be used concurrently by multiple application + * threads. An application can have multiple concurrent devices, and use each + * device from multiple threads. * * Access to the layer driver structures must therefore be kept thread-safe. * For sake of simplicity, we generally implement this by: @@ -80,6 +78,8 @@ class Device * @brief Fetch a device from the global store of dispatchable devices. * * @param handle The dispatchable device handle to use as an indirect lookup. + * + * @return The layer device context. */ static Device* retrieve( VkDevice handle); @@ -88,6 +88,8 @@ class Device * @brief Fetch a device from the global store of dispatchable devices. * * @param handle The dispatchable queue handle to use as an indirect lookup. + * + * @return The layer device context. */ static Device* retrieve( VkQueue handle); @@ -96,6 +98,8 @@ class Device * @brief Fetch a device from the global store of dispatchable devices. * * @param handle The dispatchable command buffer handle to use as an indirect lookup. + * + * @return The layer device context. */ static Device* retrieve( VkCommandBuffer handle); @@ -125,7 +129,7 @@ class Device /** * @brief Destroy this layer device object. */ - ~Device(); + ~Device() = default; public: /** diff --git a/layer_example/source/instance.cpp b/layer_example/source/instance.cpp index 6ac278e..0b62857 100644 --- a/layer_example/source/instance.cpp +++ b/layer_example/source/instance.cpp @@ -29,6 +29,9 @@ #include "instance.hpp" +/** + * @brief The dispatch lookup for all of the created Vulkan instances. + */ static std::unordered_map> g_instances; /* See header for documentation. */ @@ -42,8 +45,8 @@ void Instance::store( /* See header for documentation. */ Instance* Instance::retrieve( - VkInstance handle) -{ + VkInstance handle +) { void* key = getDispatchKey(handle); assert(isInMap(key, g_instances)); return g_instances.at(key).get(); @@ -51,8 +54,8 @@ Instance* Instance::retrieve( /* See header for documentation. */ Instance* Instance::retrieve( - VkPhysicalDevice handle) -{ + VkPhysicalDevice handle +) { void* key = getDispatchKey(handle); assert(isInMap(key, g_instances)); return g_instances.at(key).get(); @@ -68,7 +71,8 @@ void Instance::destroy( /* See header for documentation. */ Instance::Instance( VkInstance _instance, - PFN_vkGetInstanceProcAddr _nlayerGetProcAddress) : + PFN_vkGetInstanceProcAddr _nlayerGetProcAddress +) : instance(_instance), nlayerGetProcAddress(_nlayerGetProcAddress) { diff --git a/layer_example/source/instance.hpp b/layer_example/source/instance.hpp index cfda54e..fc6af6b 100644 --- a/layer_example/source/instance.hpp +++ b/layer_example/source/instance.hpp @@ -42,9 +42,8 @@ * Key properties * ============== * - * Unlike EGL contexts, Vulkan instances are designed to be used concurrently - * by multiple application threads. An application can have multiple concurrent - * instances (although this is less common than with OpenGL ES applications), + * Vulkan instances are designed to be used concurrently by multiple + * application threads. An application can have multiple concurrent instances, * and use each instance from multiple threads. * * Access to the layer driver structures must therefore be kept thread-safe. @@ -65,10 +64,6 @@ /** * @brief This class implements the layer state tracker for a single instance. - * - * These objects are relatively light-weight, as they are rarely used once a VkDevice has been - * created, but we need to track the chain-of-ownership as the instance is the root object that - * the application creates when initializing a rendering context. */ class Instance { @@ -87,6 +82,8 @@ class Instance * @brief Fetch an instance from the global store of dispatchable instances. * * @param handle The dispatchable instance handle to use as an indirect lookup. + * + * @return The layer instance context. */ static Instance* retrieve( VkInstance handle); @@ -95,6 +92,8 @@ class Instance * @brief Fetch an instance from the global store of dispatchable instances. * * @param handle The dispatchable physical device handle to use as an indirect lookup. + * + * @return The layer instance context. */ static Instance* retrieve( VkPhysicalDevice handle); diff --git a/layer_example/source/version.hpp.in b/layer_example/source/version.hpp.in index 50c30b9..5fcb9c3 100644 --- a/layer_example/source/version.hpp.in +++ b/layer_example/source/version.hpp.in @@ -24,9 +24,7 @@ */ /** - * @file - * This header implements placeholder templates that are populated by CMake - * during configure. + * @file Placeholder templates that are populated by CMake during configure. */ #pragma once