From 6d23e59aa6a35bba84484572c7236a0a0eeb876e Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 29 Jun 2020 13:07:25 +0100 Subject: [PATCH] Support specifying next chain to instance creation, and inst extensions --- util/test/demos/vk/vk_helpers.h | 6 ++++++ util/test/demos/vk/vk_test.cpp | 16 ++++++++++++++-- util/test/demos/vk/vk_test.h | 3 +++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/util/test/demos/vk/vk_helpers.h b/util/test/demos/vk/vk_helpers.h index 4b36e2632..551dcb079 100644 --- a/util/test/demos/vk/vk_helpers.h +++ b/util/test/demos/vk/vk_helpers.h @@ -202,6 +202,12 @@ struct InstanceCreateInfo : public VkInstanceCreateInfo ppEnabledExtensionNames = exts.data(); } + InstanceCreateInfo &next(const void *next) + { + this->pNext = next; + return *this; + } + operator const VkInstanceCreateInfo *() const { return this; } }; diff --git a/util/test/demos/vk/vk_test.cpp b/util/test/demos/vk/vk_test.cpp index 4354c2245..d470ff676 100644 --- a/util/test/demos/vk/vk_test.cpp +++ b/util/test/demos/vk/vk_test.cpp @@ -85,6 +85,8 @@ void VulkanGraphicsTest::Prepare(int argc, char **argv) if(volk && spv) { + enabledInstExts = instExts; + enabledInstExts.push_back(VK_KHR_SURFACE_EXTENSION_NAME); #if defined(WIN32) @@ -137,6 +139,15 @@ void VulkanGraphicsTest::Prepare(int argc, char **argv) std::vector supportedExts; CHECK_VKR(vkh::enumerateInstanceExtensionProperties(supportedExts, NULL)); + for(const char *l : enabledLayers) + { + std::vector tmp; + CHECK_VKR(vkh::enumerateInstanceExtensionProperties(tmp, l)); + + for(const VkExtensionProperties &t : tmp) + supportedExts.push_back(t); + } + // strip any extensions that are not supported for(auto it = enabledInstExts.begin(); it != enabledInstExts.end();) { @@ -186,8 +197,9 @@ void VulkanGraphicsTest::Prepare(int argc, char **argv) TEST_LOG("Initialising Vulkan at VK%u.%u", VK_VERSION_MAJOR(vulkanVersion), VK_VERSION_MINOR(vulkanVersion)); - VkResult vkr = vkCreateInstance(vkh::InstanceCreateInfo(app, enabledLayers, enabledInstExts), - NULL, &inst); + VkResult vkr = vkCreateInstance( + vkh::InstanceCreateInfo(app, enabledLayers, enabledInstExts).next(instInfoNext), NULL, + &inst); if(vkr == VK_SUCCESS) { diff --git a/util/test/demos/vk/vk_test.h b/util/test/demos/vk/vk_test.h index f5a5fce89..d096c9dbe 100644 --- a/util/test/demos/vk/vk_test.h +++ b/util/test/demos/vk/vk_test.h @@ -234,6 +234,9 @@ struct VulkanGraphicsTest : public GraphicsTest // device version uint32_t devVersion; + // a custom struct to pass to vkInstanceCreateInfo::pNext + const void *instInfoNext = NULL; + // requested features VkPhysicalDeviceFeatures features = {};