Skip to content

Commit b996179

Browse files
authored
Unify vkb::PhysicalDevice and vkb::core::HPPPhysicalDevice into vkb::core::PhysicalDevice<bindingType> (#1404)
* Unify vkb::PhysicalDevice and vkb::core::HPPPhysicalDevice into vkb::core::PhysicalDevice<bindingType> * Add HPPType<VkPhysicalDevicePortabilitySubsetFeaturesKHR>, guarded by VKB_ENABLE_PORTABILITY * Fix assert in constructor of VulkanStatsProvider.
1 parent f44204c commit b996179

File tree

161 files changed

+1022
-1362
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+1022
-1362
lines changed

framework/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,6 @@ set(CORE_FILES
250250
core/hpp_framebuffer.h
251251
core/hpp_image.h
252252
core/hpp_image_view.h
253-
core/hpp_physical_device.h
254253
core/hpp_pipeline.h
255254
core/hpp_pipeline_layout.h
256255
core/hpp_query_pool.h
@@ -262,7 +261,6 @@ set(CORE_FILES
262261
core/vulkan_resource.h
263262
# Source Files
264263
core/command_pool_base.cpp
265-
core/physical_device.cpp
266264
core/debug.cpp
267265
core/image_core.cpp
268266
core/shader_module.cpp
@@ -285,7 +283,6 @@ set(CORE_FILES
285283
core/hpp_debug.cpp
286284
core/hpp_image_core.cpp
287285
core/hpp_image_view.cpp
288-
core/hpp_physical_device.cpp
289286
core/hpp_pipeline_layout.cpp
290287
core/hpp_queue.cpp
291288
core/hpp_sampler.cpp

framework/core/command_buffer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "core/device.h"
2323
#include "core/hpp_descriptor_set_layout.h"
2424
#include "core/hpp_framebuffer.h"
25-
#include "core/hpp_physical_device.h"
2625
#include "core/hpp_render_pass.h"
2726
#include "core/hpp_sampler.h"
2827
#include "core/image.h"

framework/core/descriptor_set_layout.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ inline bool validate_binding(const VkDescriptorSetLayoutBinding &binding, const
7575
return !(std::ranges::find_if(blacklist, [binding](const VkDescriptorType &type) { return type == binding.descriptorType; }) != blacklist.end());
7676
}
7777

78-
inline bool validate_flags(const PhysicalDevice &gpu, const std::vector<VkDescriptorSetLayoutBinding> &bindings, const std::vector<VkDescriptorBindingFlagsEXT> &flags)
78+
inline bool validate_flags(vkb::core::PhysicalDeviceC const &gpu,
79+
const std::vector<VkDescriptorSetLayoutBinding> &bindings,
80+
const std::vector<VkDescriptorBindingFlagsEXT> &flags)
7981
{
8082
// Assume bindings are valid if there are no flags
8183
if (flags.empty())

framework/core/device.h

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "common/hpp_vk_common.h"
2121
#include "common/vk_common.h"
2222
#include "core/buffer.h"
23-
#include "core/hpp_physical_device.h"
23+
#include "core/physical_device.h"
2424
#include "hpp_debug.h"
2525
#include "hpp_fence_pool.h"
2626
#include "hpp_queue.h"
@@ -70,11 +70,10 @@ class Device
7070
using SemaphoreType = typename std::conditional<bindingType == vkb::BindingType::Cpp, vk::Semaphore, VkSemaphore>::type;
7171
using SurfaceType = typename std::conditional<bindingType == vkb::BindingType::Cpp, vk::SurfaceKHR, VkSurfaceKHR>::type;
7272

73-
using DebugUtilsType = typename std::conditional<bindingType == vkb::BindingType::Cpp, vkb::core::HPPDebugUtils, vkb::DebugUtils>::type;
74-
using FencePoolType = typename std::conditional<bindingType == vkb::BindingType::Cpp, vkb::HPPFencePool, vkb::FencePool>::type;
75-
using PhysicalDeviceType = typename std::conditional<bindingType == vkb::BindingType::Cpp, vkb::core::HPPPhysicalDevice, vkb::PhysicalDevice>::type;
76-
using CoreQueueType = typename std::conditional<bindingType == vkb::BindingType::Cpp, vkb::core::HPPQueue, vkb::Queue>::type;
77-
using ResourceCacheType = typename std::conditional<bindingType == vkb::BindingType::Cpp, vkb::HPPResourceCache, vkb::ResourceCache>::type;
73+
using DebugUtilsType = typename std::conditional<bindingType == vkb::BindingType::Cpp, vkb::core::HPPDebugUtils, vkb::DebugUtils>::type;
74+
using FencePoolType = typename std::conditional<bindingType == vkb::BindingType::Cpp, vkb::HPPFencePool, vkb::FencePool>::type;
75+
using CoreQueueType = typename std::conditional<bindingType == vkb::BindingType::Cpp, vkb::core::HPPQueue, vkb::Queue>::type;
76+
using ResourceCacheType = typename std::conditional<bindingType == vkb::BindingType::Cpp, vkb::HPPResourceCache, vkb::ResourceCache>::type;
7877

7978
public:
8079
/**
@@ -84,7 +83,7 @@ class Device
8483
* @param debug_utils The debug utils to be associated to this device
8584
* @param requested_extensions (Optional) List of required device extensions and whether support is optional or not
8685
*/
87-
Device(PhysicalDeviceType &gpu,
86+
Device(PhysicalDevice<bindingType> &gpu,
8887
SurfaceType surface,
8988
std::unique_ptr<DebugUtilsType> &&debug_utils,
9089
std::unordered_map<const char *, bool> const &requested_extensions = {});
@@ -95,7 +94,7 @@ class Device
9594
* @param vulkan_device A valid Vulkan device
9695
* @param surface The surface
9796
*/
98-
Device(PhysicalDeviceType &gpu, DeviceType &vulkan_device, SurfaceType surface);
97+
Device(PhysicalDevice<bindingType> &gpu, DeviceType &vulkan_device, SurfaceType surface);
9998

10099
Device(const Device &) = delete;
101100
Device(Device &&) = delete;
@@ -117,7 +116,7 @@ class Device
117116
vkb::core::CommandPool<bindingType> &get_command_pool() const;
118117
DebugUtilsType const &get_debug_utils() const;
119118
FencePoolType &get_fence_pool() const;
120-
PhysicalDeviceType const &get_gpu() const;
119+
PhysicalDevice<bindingType> const &get_gpu() const;
121120
CoreQueueType const &get_queue(uint32_t queue_family_index, uint32_t queue_index) const;
122121
CoreQueueType const &get_queue_by_flags(QueueFlagsType queue_flags, uint32_t queue_index) const;
123122
CoreQueueType const &get_queue_by_present(uint32_t queue_index) const;
@@ -142,7 +141,7 @@ class Device
142141
std::unique_ptr<vkb::core::HPPDebugUtils> debug_utils;
143142
std::vector<const char *> enabled_extensions{};
144143
std::unique_ptr<vkb::HPPFencePool> fence_pool;
145-
vkb::core::HPPPhysicalDevice &gpu;
144+
vkb::core::PhysicalDeviceCpp &gpu;
146145
std::vector<std::vector<vkb::core::HPPQueue>> queues;
147146
vkb::HPPResourceCache resource_cache;
148147
vk::SurfaceKHR surface = nullptr;
@@ -162,7 +161,7 @@ namespace core
162161
{
163162

164163
template <>
165-
inline Device<vkb::BindingType::Cpp>::Device(vkb::core::HPPPhysicalDevice &gpu,
164+
inline Device<vkb::BindingType::Cpp>::Device(vkb::core::PhysicalDeviceCpp &gpu,
166165
vk::SurfaceKHR surface,
167166
std::unique_ptr<vkb::core::HPPDebugUtils> &&debug_utils,
168167
std::unordered_map<const char *, bool> const &requested_extensions) :
@@ -172,25 +171,25 @@ inline Device<vkb::BindingType::Cpp>::Device(vkb::core::HPPPhysicalDevice
172171
}
173172

174173
template <>
175-
inline Device<vkb::BindingType::C>::Device(vkb::PhysicalDevice &gpu,
174+
inline Device<vkb::BindingType::C>::Device(vkb::core::PhysicalDeviceC &gpu,
176175
VkSurfaceKHR surface,
177176
std::unique_ptr<vkb::DebugUtils> &&debug_utils,
178177
std::unordered_map<const char *, bool> const &requested_extensions) :
179-
vkb::core::VulkanResourceC<VkDevice>{VK_NULL_HANDLE, this}, debug_utils{reinterpret_cast<vkb::core::HPPDebugUtils *>(debug_utils.release())}, gpu{reinterpret_cast<vkb::core::HPPPhysicalDevice &>(gpu)}, resource_cache{*reinterpret_cast<vkb::core::DeviceCpp *>(this)}, surface(static_cast<vk::SurfaceKHR>(surface))
178+
vkb::core::VulkanResourceC<VkDevice>{VK_NULL_HANDLE, this}, debug_utils{reinterpret_cast<vkb::core::HPPDebugUtils *>(debug_utils.release())}, gpu{reinterpret_cast<vkb::core::PhysicalDeviceCpp &>(gpu)}, resource_cache{*reinterpret_cast<vkb::core::DeviceCpp *>(this)}, surface(static_cast<vk::SurfaceKHR>(surface))
180179
{
181180
init(requested_extensions);
182181
}
183182

184183
template <>
185-
inline Device<vkb::BindingType::Cpp>::Device(vkb::core::HPPPhysicalDevice &gpu, vk::Device &vulkan_device, vk::SurfaceKHR surface) :
184+
inline Device<vkb::BindingType::Cpp>::Device(vkb::core::PhysicalDeviceCpp &gpu, vk::Device &vulkan_device, vk::SurfaceKHR surface) :
186185
VulkanResource{vulkan_device}, gpu{gpu}, surface{surface}, resource_cache{*this}
187186
{
188187
debug_utils = std::make_unique<HPPDummyDebugUtils>();
189188
}
190189

191190
template <>
192-
inline Device<vkb::BindingType::C>::Device(vkb::PhysicalDevice &gpu, VkDevice &vulkan_device, VkSurfaceKHR surface) :
193-
VulkanResource{vulkan_device}, gpu{reinterpret_cast<vkb::core::HPPPhysicalDevice &>(gpu)}, resource_cache{*reinterpret_cast<vkb::core::DeviceCpp *>(this)}, surface{static_cast<vk::SurfaceKHR>(surface)}
191+
inline Device<vkb::BindingType::C>::Device(vkb::core::PhysicalDeviceC &gpu, VkDevice &vulkan_device, VkSurfaceKHR surface) :
192+
VulkanResource{vulkan_device}, gpu{reinterpret_cast<vkb::core::PhysicalDeviceCpp &>(gpu)}, resource_cache{*reinterpret_cast<vkb::core::DeviceCpp *>(this)}, surface{static_cast<vk::SurfaceKHR>(surface)}
194193
{
195194
debug_utils = std::make_unique<HPPDummyDebugUtils>();
196195
}
@@ -390,15 +389,15 @@ inline typename Device<bindingType>::FencePoolType &Device<bindingType>::get_fen
390389
}
391390

392391
template <vkb::BindingType bindingType>
393-
inline typename Device<bindingType>::PhysicalDeviceType const &Device<bindingType>::get_gpu() const
392+
inline PhysicalDevice<bindingType> const &Device<bindingType>::get_gpu() const
394393
{
395394
if constexpr (bindingType == vkb::BindingType::Cpp)
396395
{
397396
return gpu;
398397
}
399398
else
400399
{
401-
return reinterpret_cast<vkb::PhysicalDevice const &>(gpu);
400+
return reinterpret_cast<vkb::core::PhysicalDeviceC const &>(gpu);
402401
}
403402
}
404403

framework/core/hpp_physical_device.cpp

Lines changed: 0 additions & 160 deletions
This file was deleted.

0 commit comments

Comments
 (0)