From fa990893ef842a0447522b15ec5f8b8e094ed603 Mon Sep 17 00:00:00 2001 From: Jaebaek Seo Date: Tue, 8 Jan 2019 15:26:25 -0500 Subject: Vulkan: reuse device using config (#205) If `VkPhysicalDevice`, `VkDevice`, `VkQueue`, queue family index, required features and extensions are given, Amber reuses them. Fixes #124 --- include/amber/amber_vulkan.h | 28 ++++++++++++++++++++++++++-- include/amber/recipe.h | 13 +++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/amber/amber_vulkan.h b/include/amber/amber_vulkan.h index 084a2c9..1f38ab1 100644 --- a/include/amber/amber_vulkan.h +++ b/include/amber/amber_vulkan.h @@ -15,14 +15,38 @@ #ifndef AMBER_AMBER_VULKAN_H_ #define AMBER_AMBER_VULKAN_H_ +#include +#include +#include + +#include "amber/amber.h" + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" #include "vulkan/vulkan.h" +#pragma clang diagnostic pop namespace amber { /// Configuration for the Vulkan Engine. struct VulkanEngineConfig : public EngineConfig { - /// The VkDevice to use for the tests. - VkDevice device; + /// The VkPhysicalDevice to use. + VkPhysicalDevice physical_device = VK_NULL_HANDLE; + + /// Physical device features available for |physical_device|. + VkPhysicalDeviceFeatures available_features = {}; + + /// Physical device extensions available for |physical_device|. + std::vector available_extensions; + + /// The given queue family index to use. + uint32_t queue_family_index = std::numeric_limits::max(); + + /// The VkDevice to use. + VkDevice device = VK_NULL_HANDLE; + + /// The VkQueue to use. + VkQueue queue = VK_NULL_HANDLE; }; } // namespace amber diff --git a/include/amber/recipe.h b/include/amber/recipe.h index 3dd932c..d33c479 100644 --- a/include/amber/recipe.h +++ b/include/amber/recipe.h @@ -16,6 +16,7 @@ #define AMBER_RECIPE_H_ #include +#include #include #include @@ -31,6 +32,12 @@ class RecipeImpl { /// Retrieves information on all the shaders in the given recipe. virtual std::vector GetShaderInfo() const = 0; + /// Returns required features in the given recipe. + virtual std::vector GetRequiredFeatures() const = 0; + + /// Returns required extensions in the given recipe. + virtual std::vector GetRequiredExtensions() const = 0; + protected: RecipeImpl(); }; @@ -47,6 +54,12 @@ class Recipe { RecipeImpl* GetImpl() const { return impl_.get(); } void SetImpl(std::unique_ptr impl) { impl_ = std::move(impl); } + /// Returns required features in the given recipe. + std::vector GetRequiredFeatures() const; + + /// Returns required extensions in the given recipe. + std::vector GetRequiredExtensions() const; + private: std::unique_ptr impl_; }; -- cgit v1.2.3