Skip to content

Commit

Permalink
fix!: use the new vulkan-utility-libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
jiriks74 committed Nov 8, 2023
1 parent df15b9d commit 2eecb26
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
20 changes: 10 additions & 10 deletions layer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "vulkan/vulkan.h"
#include "vulkan/vk_layer.h"
#include "vulkan/vk_layer_dispatch_table.h"
#include "vulkan/utility/vk_dispatch_table.h"

#include <cstdio>
#include <cstdlib>
Expand All @@ -11,8 +11,8 @@
#undef VK_LAYER_EXPORT
#define VK_LAYER_EXPORT extern "C"

static std::map<void*, VkLayerInstanceDispatchTable> gInstanceDispatch;
static std::map<void*, VkLayerDispatchTable> gDeviceDispatch;
static std::map<void*, VkuInstanceDispatchTable> gInstanceDispatch;
static std::map<void*, VkuDeviceDispatchTable> gDeviceDispatch;

static constexpr char kEnvVariable[] = "VULKAN_DEVICE_INDEX";

Expand All @@ -23,19 +23,19 @@ inline void* GetKey(DispatchableType object)
}

template <typename DispatchableType>
inline VkLayerInstanceDispatchTable& GetInstanceDispatch(DispatchableType object)
inline VkuInstanceDispatchTable& GetInstanceDispatch(DispatchableType object)
{
return gInstanceDispatch[GetKey(object)];
}

template <typename DispatchableType>
inline VkLayerDispatchTable& GetDeviceDispatch(DispatchableType object)
inline VkuDeviceDispatchTable& GetDeviceDispatch(DispatchableType object)
{
return gDeviceDispatch[GetKey(object)];
}

static VkResult ChooseDevice(VkInstance instance,
const VkLayerInstanceDispatchTable& dispatch,
const VkuInstanceDispatchTable& dispatch,
const char* const env,
VkPhysicalDevice& outDevice)
{
Expand Down Expand Up @@ -84,7 +84,7 @@ DeviceChooserLayer_EnumeratePhysicalDevices(VkInstance instance,
uint32_t* pPhysicalDeviceCount,
VkPhysicalDevice* pPhysicalDevices)
{
const VkLayerInstanceDispatchTable& dispatch = GetInstanceDispatch(instance);
const VkuInstanceDispatchTable& dispatch = GetInstanceDispatch(instance);

const char* const env = getenv(kEnvVariable);
if (!env)
Expand Down Expand Up @@ -121,7 +121,7 @@ DeviceChooserLayer_EnumeratePhysicalDeviceGroupsKHR(VkInstance
uint32_t* pPhysicalDeviceGroupCount,
VkPhysicalDeviceGroupPropertiesKHR* pPhysicalDeviceGroups)
{
const VkLayerInstanceDispatchTable& dispatch = GetInstanceDispatch(instance);
const VkuInstanceDispatchTable& dispatch = GetInstanceDispatch(instance);

const char* const env = getenv(kEnvVariable);
if (!env)
Expand Down Expand Up @@ -198,7 +198,7 @@ DeviceChooserLayer_CreateInstance(const VkInstanceCreateInfo* pCreateInfo,
#define GET(func) \
dispatchTable.func = (PFN_vk##func)gpa(*pInstance, "vk" #func);

VkLayerInstanceDispatchTable dispatchTable;
VkuInstanceDispatchTable dispatchTable;
dispatchTable.GetInstanceProcAddr = gpa;
GET(EnumerateDeviceExtensionProperties);
GET(DestroyInstance);
Expand Down Expand Up @@ -259,7 +259,7 @@ DeviceChooserLayer_CreateDevice(VkPhysicalDevice physicalDevice,
#define GET(func) \
dispatchTable.func = (PFN_vk##func)gdpa(*pDevice, "vk" #func);

VkLayerDispatchTable dispatchTable;
VkuDeviceDispatchTable dispatchTable;
dispatchTable.GetDeviceProcAddr = gdpa;
GET(DestroyDevice);

Expand Down
4 changes: 2 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ endif
if not cpp.has_header('vulkan/vk_layer.h')
error('Vulkan development files not present (vulkan/vk_layer.h)')
endif
if not cpp.has_header('vulkan/vk_layer_dispatch_table.h')
error('Vulkan development files not present (vulkan/vk_layer_dispatch_table.h)')
if not cpp.has_header('vulkan/utility/vk_dispatch_table.h')
error('vulkan/utility/vk_dispatch_table.h')
endif

libdir = get_option('libdir')
Expand Down
2 changes: 1 addition & 1 deletion vkdevicechooser.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "VK_LAYER_AEJS_DeviceChooserLayer",
"type": "GLOBAL",
"library_path": "libvkdevicechooser.so",
"api_version": "1.2.131",
"api_version": "1.3",
"implementation_version": "1",
"description": "Device chooser layer",
"functions": {
Expand Down

0 comments on commit 2eecb26

Please sign in to comment.