Loading vulkan/include/vulkan/vk_layer_interface.h +7 −31 Original line number Diff line number Diff line Loading @@ -14,10 +14,6 @@ * The above copyright notice(s) and this permission notice shall be included in * all copies or substantial portions of the Materials. * * The Materials are Confidential Information as defined by the Khronos * Membership Agreement until designated non-confidential by Khronos, at which * point this condition clause shall be removed. * * THE MATERIALS ARE 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. Loading @@ -37,38 +33,18 @@ typedef enum VkLayerFunction_ { VK_LAYER_FUNCTION_LINK = 0, VK_LAYER_FUNCTION_DEVICE = 1, VK_LAYER_FUNCTION_INSTANCE = 2 VK_LAYER_FUNCTION_DATA_CALLBACK = 1 } VkLayerFunction; /* * When creating the device chain the loader needs to pass * down information about it's device structure needed at * the end of the chain. Passing the data via the * VkLayerInstanceInfo avoids issues with finding the * exact instance being used. */ typedef struct VkLayerInstanceInfo_ { void* instance_info; PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr; } VkLayerInstanceInfo; typedef struct VkLayerInstanceLink_ { struct VkLayerInstanceLink_* pNext; PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr; } VkLayerInstanceLink; /* * When creating the device chain the loader needs to pass * down information about it's device structure needed at * the end of the chain. Passing the data via the * VkLayerDeviceInfo avoids issues with finding the * exact instance being used. */ typedef struct VkLayerDeviceInfo_ { void* device_info; PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr; } VkLayerDeviceInfo; typedef VkResult(VKAPI_PTR* PFN_vkSetInstanceLoaderData)(VkInstance instance, void* object); typedef VkResult(VKAPI_PTR* PFN_vkSetDeviceLoaderData)(VkDevice device, void* object); typedef struct { VkStructureType sType; // VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO Loading @@ -76,7 +52,7 @@ typedef struct { VkLayerFunction function; union { VkLayerInstanceLink* pLayerInfo; VkLayerInstanceInfo instanceInfo; PFN_vkSetInstanceLoaderData pfnSetInstanceLoaderData; } u; } VkLayerInstanceCreateInfo; Loading @@ -92,6 +68,6 @@ typedef struct { VkLayerFunction function; union { VkLayerDeviceLink* pLayerInfo; VkLayerDeviceInfo deviceInfo; PFN_vkSetDeviceLoaderData pfnSetDeviceLoaderData; } u; } VkLayerDeviceCreateInfo; vulkan/libvulkan/api.cpp +51 −25 Original line number Diff line number Diff line Loading @@ -431,6 +431,11 @@ class LayerChain { uint32_t count, const VkAllocationCallbacks& allocator); static VKAPI_ATTR VkResult SetInstanceLoaderData(VkInstance instance, void* object); static VKAPI_ATTR VkResult SetDeviceLoaderData(VkDevice device, void* object); static VKAPI_ATTR VkBool32 DebugReportCallback(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT obj_type, Loading @@ -454,8 +459,8 @@ class LayerChain { PFN_vkGetDeviceProcAddr get_device_proc_addr_; union { VkLayerInstanceCreateInfo instance_chain_info_; VkLayerDeviceCreateInfo device_chain_info_; VkLayerInstanceCreateInfo instance_chain_info_[2]; VkLayerDeviceCreateInfo device_chain_info_[2]; }; VkExtensionProperties* driver_extensions_; Loading Loading @@ -616,18 +621,19 @@ bool LayerChain::Empty() const { void LayerChain::ModifyCreateInfo(VkInstanceCreateInfo& info) { if (layer_count_) { const ActiveLayer& layer = layers_[0]; auto& link_info = instance_chain_info_[1]; link_info.sType = VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO; link_info.pNext = info.pNext; link_info.function = VK_LAYER_FUNCTION_LINK; link_info.u.pLayerInfo = &layers_[0].instance_link; instance_chain_info_.sType = VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO; instance_chain_info_.function = VK_LAYER_FUNCTION_LINK; // TODO fix vk_layer_interface.h and get rid of const_cast? instance_chain_info_.u.pLayerInfo = const_cast<VkLayerInstanceLink*>(&layer.instance_link); auto& cb_info = instance_chain_info_[0]; cb_info.sType = VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO; cb_info.pNext = &link_info; cb_info.function = VK_LAYER_FUNCTION_DATA_CALLBACK; cb_info.u.pfnSetInstanceLoaderData = SetInstanceLoaderData; // insert layer info instance_chain_info_.pNext = info.pNext; info.pNext = &instance_chain_info_; info.pNext = &cb_info; } if (override_layers_.Count()) { Loading @@ -643,17 +649,19 @@ void LayerChain::ModifyCreateInfo(VkInstanceCreateInfo& info) { void LayerChain::ModifyCreateInfo(VkDeviceCreateInfo& info) { if (layer_count_) { const ActiveLayer& layer = layers_[0]; auto& link_info = device_chain_info_[1]; link_info.sType = VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO; link_info.pNext = info.pNext; link_info.function = VK_LAYER_FUNCTION_LINK; link_info.u.pLayerInfo = &layers_[0].device_link; device_chain_info_.sType = VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO; device_chain_info_.function = VK_LAYER_FUNCTION_LINK; // TODO fix vk_layer_interface.h and get rid of const_cast? device_chain_info_.u.pLayerInfo = const_cast<VkLayerDeviceLink*>(&layer.device_link); auto& cb_info = device_chain_info_[0]; cb_info.sType = VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO; cb_info.pNext = &link_info; cb_info.function = VK_LAYER_FUNCTION_DATA_CALLBACK; cb_info.u.pfnSetDeviceLoaderData = SetDeviceLoaderData; // insert layer info device_chain_info_.pNext = info.pNext; info.pNext = &device_chain_info_; info.pNext = &cb_info; } if (override_layers_.Count()) { Loading Loading @@ -890,6 +898,24 @@ void LayerChain::DestroyLayers(ActiveLayer* layers, allocator.pfnFree(allocator.pUserData, layers); } VkResult LayerChain::SetInstanceLoaderData(VkInstance instance, void* object) { driver::InstanceDispatchable dispatchable = reinterpret_cast<driver::InstanceDispatchable>(object); return (driver::SetDataInternal(dispatchable, &driver::GetData(instance))) ? VK_SUCCESS : VK_ERROR_INITIALIZATION_FAILED; } VkResult LayerChain::SetDeviceLoaderData(VkDevice device, void* object) { driver::DeviceDispatchable dispatchable = reinterpret_cast<driver::DeviceDispatchable>(object); return (driver::SetDataInternal(dispatchable, &driver::GetData(device))) ? VK_SUCCESS : VK_ERROR_INITIALIZATION_FAILED; } VkBool32 LayerChain::DebugReportCallback(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT obj_type, uint64_t obj, Loading vulkan/libvulkan/driver.h +29 −6 Original line number Diff line number Diff line Loading @@ -64,6 +64,9 @@ struct DeviceData { namespace driver { VK_DEFINE_HANDLE(InstanceDispatchable) VK_DEFINE_HANDLE(DeviceDispatchable) struct InstanceData { InstanceData(const VkAllocationCallbacks& alloc) : opaque_api_data(), Loading Loading @@ -127,11 +130,14 @@ VKAPI_ATTR VkResult AllocateCommandBuffers(VkDevice device, const VkCommandBuffe template <typename DispatchableType> void StaticAssertDispatchable(DispatchableType) { static_assert(std::is_same<DispatchableType, VkInstance>::value || static_assert( std::is_same<DispatchableType, VkInstance>::value || std::is_same<DispatchableType, VkPhysicalDevice>::value || std::is_same<DispatchableType, VkDevice>::value || std::is_same<DispatchableType, InstanceDispatchable>::value || std::is_same<DispatchableType, VkQueue>::value || std::is_same<DispatchableType, VkCommandBuffer>::value, std::is_same<DispatchableType, VkCommandBuffer>::value || std::is_same<DispatchableType, DeviceDispatchable>::value, "unrecognized dispatchable type"); } Loading Loading @@ -170,6 +176,11 @@ inline bool SetData(VkPhysicalDevice physical_dev, const InstanceData& data) { return SetDataInternal(physical_dev, &data); } inline bool SetData(InstanceDispatchable dispatchable, const InstanceData& data) { return SetDataInternal(dispatchable, &data); } inline bool SetData(VkDevice dev, const DeviceData& data) { return SetDataInternal(dev, &data); } Loading @@ -182,6 +193,10 @@ inline bool SetData(VkCommandBuffer cmd, const DeviceData& data) { return SetDataInternal(cmd, &data); } inline bool SetData(DeviceDispatchable dispatchable, const DeviceData& data) { return SetDataInternal(dispatchable, &data); } inline InstanceData& GetData(VkInstance instance) { return *reinterpret_cast<InstanceData*>(GetDataInternal(instance)); } Loading @@ -190,6 +205,10 @@ inline InstanceData& GetData(VkPhysicalDevice physical_dev) { return *reinterpret_cast<InstanceData*>(GetDataInternal(physical_dev)); } inline InstanceData& GetData(InstanceDispatchable dispatchable) { return *reinterpret_cast<InstanceData*>(GetDataInternal(dispatchable)); } inline DeviceData& GetData(VkDevice dev) { return *reinterpret_cast<DeviceData*>(GetDataInternal(dev)); } Loading @@ -202,6 +221,10 @@ inline DeviceData& GetData(VkCommandBuffer cmd) { return *reinterpret_cast<DeviceData*>(GetDataInternal(cmd)); } inline DeviceData& GetData(DeviceDispatchable dispatchable) { return *reinterpret_cast<DeviceData*>(GetDataInternal(dispatchable)); } } // namespace driver } // namespace vulkan Loading Loading
vulkan/include/vulkan/vk_layer_interface.h +7 −31 Original line number Diff line number Diff line Loading @@ -14,10 +14,6 @@ * The above copyright notice(s) and this permission notice shall be included in * all copies or substantial portions of the Materials. * * The Materials are Confidential Information as defined by the Khronos * Membership Agreement until designated non-confidential by Khronos, at which * point this condition clause shall be removed. * * THE MATERIALS ARE 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. Loading @@ -37,38 +33,18 @@ typedef enum VkLayerFunction_ { VK_LAYER_FUNCTION_LINK = 0, VK_LAYER_FUNCTION_DEVICE = 1, VK_LAYER_FUNCTION_INSTANCE = 2 VK_LAYER_FUNCTION_DATA_CALLBACK = 1 } VkLayerFunction; /* * When creating the device chain the loader needs to pass * down information about it's device structure needed at * the end of the chain. Passing the data via the * VkLayerInstanceInfo avoids issues with finding the * exact instance being used. */ typedef struct VkLayerInstanceInfo_ { void* instance_info; PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr; } VkLayerInstanceInfo; typedef struct VkLayerInstanceLink_ { struct VkLayerInstanceLink_* pNext; PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr; } VkLayerInstanceLink; /* * When creating the device chain the loader needs to pass * down information about it's device structure needed at * the end of the chain. Passing the data via the * VkLayerDeviceInfo avoids issues with finding the * exact instance being used. */ typedef struct VkLayerDeviceInfo_ { void* device_info; PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr; } VkLayerDeviceInfo; typedef VkResult(VKAPI_PTR* PFN_vkSetInstanceLoaderData)(VkInstance instance, void* object); typedef VkResult(VKAPI_PTR* PFN_vkSetDeviceLoaderData)(VkDevice device, void* object); typedef struct { VkStructureType sType; // VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO Loading @@ -76,7 +52,7 @@ typedef struct { VkLayerFunction function; union { VkLayerInstanceLink* pLayerInfo; VkLayerInstanceInfo instanceInfo; PFN_vkSetInstanceLoaderData pfnSetInstanceLoaderData; } u; } VkLayerInstanceCreateInfo; Loading @@ -92,6 +68,6 @@ typedef struct { VkLayerFunction function; union { VkLayerDeviceLink* pLayerInfo; VkLayerDeviceInfo deviceInfo; PFN_vkSetDeviceLoaderData pfnSetDeviceLoaderData; } u; } VkLayerDeviceCreateInfo;
vulkan/libvulkan/api.cpp +51 −25 Original line number Diff line number Diff line Loading @@ -431,6 +431,11 @@ class LayerChain { uint32_t count, const VkAllocationCallbacks& allocator); static VKAPI_ATTR VkResult SetInstanceLoaderData(VkInstance instance, void* object); static VKAPI_ATTR VkResult SetDeviceLoaderData(VkDevice device, void* object); static VKAPI_ATTR VkBool32 DebugReportCallback(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT obj_type, Loading @@ -454,8 +459,8 @@ class LayerChain { PFN_vkGetDeviceProcAddr get_device_proc_addr_; union { VkLayerInstanceCreateInfo instance_chain_info_; VkLayerDeviceCreateInfo device_chain_info_; VkLayerInstanceCreateInfo instance_chain_info_[2]; VkLayerDeviceCreateInfo device_chain_info_[2]; }; VkExtensionProperties* driver_extensions_; Loading Loading @@ -616,18 +621,19 @@ bool LayerChain::Empty() const { void LayerChain::ModifyCreateInfo(VkInstanceCreateInfo& info) { if (layer_count_) { const ActiveLayer& layer = layers_[0]; auto& link_info = instance_chain_info_[1]; link_info.sType = VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO; link_info.pNext = info.pNext; link_info.function = VK_LAYER_FUNCTION_LINK; link_info.u.pLayerInfo = &layers_[0].instance_link; instance_chain_info_.sType = VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO; instance_chain_info_.function = VK_LAYER_FUNCTION_LINK; // TODO fix vk_layer_interface.h and get rid of const_cast? instance_chain_info_.u.pLayerInfo = const_cast<VkLayerInstanceLink*>(&layer.instance_link); auto& cb_info = instance_chain_info_[0]; cb_info.sType = VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO; cb_info.pNext = &link_info; cb_info.function = VK_LAYER_FUNCTION_DATA_CALLBACK; cb_info.u.pfnSetInstanceLoaderData = SetInstanceLoaderData; // insert layer info instance_chain_info_.pNext = info.pNext; info.pNext = &instance_chain_info_; info.pNext = &cb_info; } if (override_layers_.Count()) { Loading @@ -643,17 +649,19 @@ void LayerChain::ModifyCreateInfo(VkInstanceCreateInfo& info) { void LayerChain::ModifyCreateInfo(VkDeviceCreateInfo& info) { if (layer_count_) { const ActiveLayer& layer = layers_[0]; auto& link_info = device_chain_info_[1]; link_info.sType = VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO; link_info.pNext = info.pNext; link_info.function = VK_LAYER_FUNCTION_LINK; link_info.u.pLayerInfo = &layers_[0].device_link; device_chain_info_.sType = VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO; device_chain_info_.function = VK_LAYER_FUNCTION_LINK; // TODO fix vk_layer_interface.h and get rid of const_cast? device_chain_info_.u.pLayerInfo = const_cast<VkLayerDeviceLink*>(&layer.device_link); auto& cb_info = device_chain_info_[0]; cb_info.sType = VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO; cb_info.pNext = &link_info; cb_info.function = VK_LAYER_FUNCTION_DATA_CALLBACK; cb_info.u.pfnSetDeviceLoaderData = SetDeviceLoaderData; // insert layer info device_chain_info_.pNext = info.pNext; info.pNext = &device_chain_info_; info.pNext = &cb_info; } if (override_layers_.Count()) { Loading Loading @@ -890,6 +898,24 @@ void LayerChain::DestroyLayers(ActiveLayer* layers, allocator.pfnFree(allocator.pUserData, layers); } VkResult LayerChain::SetInstanceLoaderData(VkInstance instance, void* object) { driver::InstanceDispatchable dispatchable = reinterpret_cast<driver::InstanceDispatchable>(object); return (driver::SetDataInternal(dispatchable, &driver::GetData(instance))) ? VK_SUCCESS : VK_ERROR_INITIALIZATION_FAILED; } VkResult LayerChain::SetDeviceLoaderData(VkDevice device, void* object) { driver::DeviceDispatchable dispatchable = reinterpret_cast<driver::DeviceDispatchable>(object); return (driver::SetDataInternal(dispatchable, &driver::GetData(device))) ? VK_SUCCESS : VK_ERROR_INITIALIZATION_FAILED; } VkBool32 LayerChain::DebugReportCallback(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT obj_type, uint64_t obj, Loading
vulkan/libvulkan/driver.h +29 −6 Original line number Diff line number Diff line Loading @@ -64,6 +64,9 @@ struct DeviceData { namespace driver { VK_DEFINE_HANDLE(InstanceDispatchable) VK_DEFINE_HANDLE(DeviceDispatchable) struct InstanceData { InstanceData(const VkAllocationCallbacks& alloc) : opaque_api_data(), Loading Loading @@ -127,11 +130,14 @@ VKAPI_ATTR VkResult AllocateCommandBuffers(VkDevice device, const VkCommandBuffe template <typename DispatchableType> void StaticAssertDispatchable(DispatchableType) { static_assert(std::is_same<DispatchableType, VkInstance>::value || static_assert( std::is_same<DispatchableType, VkInstance>::value || std::is_same<DispatchableType, VkPhysicalDevice>::value || std::is_same<DispatchableType, VkDevice>::value || std::is_same<DispatchableType, InstanceDispatchable>::value || std::is_same<DispatchableType, VkQueue>::value || std::is_same<DispatchableType, VkCommandBuffer>::value, std::is_same<DispatchableType, VkCommandBuffer>::value || std::is_same<DispatchableType, DeviceDispatchable>::value, "unrecognized dispatchable type"); } Loading Loading @@ -170,6 +176,11 @@ inline bool SetData(VkPhysicalDevice physical_dev, const InstanceData& data) { return SetDataInternal(physical_dev, &data); } inline bool SetData(InstanceDispatchable dispatchable, const InstanceData& data) { return SetDataInternal(dispatchable, &data); } inline bool SetData(VkDevice dev, const DeviceData& data) { return SetDataInternal(dev, &data); } Loading @@ -182,6 +193,10 @@ inline bool SetData(VkCommandBuffer cmd, const DeviceData& data) { return SetDataInternal(cmd, &data); } inline bool SetData(DeviceDispatchable dispatchable, const DeviceData& data) { return SetDataInternal(dispatchable, &data); } inline InstanceData& GetData(VkInstance instance) { return *reinterpret_cast<InstanceData*>(GetDataInternal(instance)); } Loading @@ -190,6 +205,10 @@ inline InstanceData& GetData(VkPhysicalDevice physical_dev) { return *reinterpret_cast<InstanceData*>(GetDataInternal(physical_dev)); } inline InstanceData& GetData(InstanceDispatchable dispatchable) { return *reinterpret_cast<InstanceData*>(GetDataInternal(dispatchable)); } inline DeviceData& GetData(VkDevice dev) { return *reinterpret_cast<DeviceData*>(GetDataInternal(dev)); } Loading @@ -202,6 +221,10 @@ inline DeviceData& GetData(VkCommandBuffer cmd) { return *reinterpret_cast<DeviceData*>(GetDataInternal(cmd)); } inline DeviceData& GetData(DeviceDispatchable dispatchable) { return *reinterpret_cast<DeviceData*>(GetDataInternal(dispatchable)); } } // namespace driver } // namespace vulkan Loading