Skip to content

Commit 22ddda4

Browse files
committed
fix: attempt fix at CI on mac/windows
1 parent b6d137d commit 22ddda4

5 files changed

Lines changed: 82 additions & 4 deletions

File tree

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ compile_commands.json
44
.cache
55
logs/
66
CMakeFiles/
7-
7+
latex
8+
html
89
# macOS
910
.DS_Store
10-
11+
.idea
12+
# i was trying jet brains lol
1113
# vcpkg
1214
vcpkg/buildtrees/
1315
vcpkg/downloads/

include/quark/vk/device/details/device.hpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,29 @@ class Device final {
1313
// NOLINTNEXTLINE(performance-enum-size)
1414
enum class Features : uint64_t {
1515
TimelineSemaphore = 1ULL << 0,
16+
DynamicRendering = 1ULL << 1,
17+
Synchronization2 = 1ULL << 2,
1618
};
1719
using FeatureFlags = uint64_t;
1820

21+
struct Capabilities {
22+
uint32_t api_version = VK_API_VERSION_1_0;
23+
FeatureFlags enabled_features = 0;
24+
25+
[[nodiscard]] bool has_feature(Features feature) const noexcept {
26+
return (enabled_features & static_cast<FeatureFlags>(feature)) != 0;
27+
}
28+
};
29+
1930
struct CreateInfo {
2031
VkInstance instance = VK_NULL_HANDLE;
2132
VkSurfaceKHR surface = VK_NULL_HANDLE;
2233
const VkAllocationCallbacks *allocator = nullptr;
2334

2435
std::vector<const char *> required_extensions;
2536

26-
FeatureFlags requested_features = 0;
37+
FeatureFlags required_features = 0;
38+
FeatureFlags preferred_features = 0;
2739
};
2840

2941
Device() = default;
@@ -60,6 +72,10 @@ class Device final {
6072
return present_queue_family_index_;
6173
}
6274

75+
[[nodiscard]] const Capabilities &capabilities() const noexcept {
76+
return capabilities_;
77+
}
78+
6379
private:
6480
struct DeviceSelection {
6581
VkPhysicalDevice physical_device{VK_NULL_HANDLE};
@@ -96,6 +112,7 @@ class Device final {
96112
uint32_t graphics_queue_family_index_ = 0;
97113
uint32_t present_queue_family_index_ = 0;
98114
const VkAllocationCallbacks *alloc_ = nullptr;
115+
Capabilities capabilities_{};
99116
};
100117

101118
} // namespace quark::vk::details

include/quark/vk/device/device_bundle.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class DeviceBundle final {
4343
[[nodiscard]] VkQueue present_queue() const noexcept;
4444
[[nodiscard]] uint32_t graphics_queue_family_index() const noexcept;
4545
[[nodiscard]] uint32_t present_queue_family_index() const noexcept;
46+
[[nodiscard]] details::Device::Capabilities capabilities() const noexcept;
4647

4748
private:
4849
details::DeviceRegistry registry_;

include/quark/vk/presentation/details/swapchain.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ class Swapchain final {
3030
Swapchain() = default;
3131
~Swapchain() { reset(); }
3232

33-
QUARK_MOVE_ONLY(Swapchain);
33+
QUARK_NO_COPY(Swapchain);
34+
Swapchain(Swapchain &&other) noexcept;
35+
Swapchain &operator=(Swapchain &&other) noexcept;
3436

3537
void create(const CreateInfo &ci);
3638
void reset() noexcept;
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#pragma once
2+
3+
#include <quark/utils/raii.hpp>
4+
#include <quark/utils/result.hpp>
5+
#include <quark/vk/presentation/details/swapchain.hpp>
6+
#include <vulkan/vulkan_core.h>
7+
8+
namespace quark::vk {
9+
10+
class PresenterBundle final {
11+
public:
12+
struct CreateInfo {
13+
VkInstance instance = VK_NULL_HANDLE;
14+
VkPhysicalDevice physical_device = VK_NULL_HANDLE;
15+
VkDevice device = VK_NULL_HANDLE;
16+
17+
uint32_t graphics_queue_family_index = 0;
18+
uint32_t present_queue_family_index = 0;
19+
20+
const platform::IWindow *window = nullptr;
21+
22+
VkPresentModeKHR preferred_present_mode = VK_PRESENT_MODE_MAILBOX_KHR;
23+
VkFormat preferred_format = VK_FORMAT_B8G8R8A8_SRGB;
24+
VkColorSpaceKHR preferred_color_space = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
25+
};
26+
27+
PresenterBundle() = default;
28+
~PresenterBundle() { destroy(); }
29+
30+
QUARK_MOVE_ONLY(PresenterBundle);
31+
32+
[[nodiscard]] util::Status create(const CreateInfo &ci);
33+
[[nodiscard]] util::Status recreate_swapchain();
34+
void destroy_swapchain() noexcept;
35+
void destroy() noexcept;
36+
37+
[[nodiscard]] bool valid() const noexcept {
38+
return surface_ != VK_NULL_HANDLE && swapchain_.handle() != VK_NULL_HANDLE;
39+
}
40+
41+
[[nodiscard]] VkSurfaceKHR surface() const noexcept { return surface_; }
42+
[[nodiscard]] const Swapchain &swapchain() const noexcept {
43+
return swapchain_;
44+
}
45+
[[nodiscard]] Swapchain &swapchain() noexcept { return swapchain_; }
46+
47+
private:
48+
[[nodiscard]] util::Result<Swapchain>
49+
create_swapchain_(VkSwapchainKHR old_swapchain) const;
50+
51+
CreateInfo create_info_{};
52+
VkSurfaceKHR surface_{VK_NULL_HANDLE};
53+
Swapchain swapchain_;
54+
};
55+
56+
} // namespace quark::vk

0 commit comments

Comments
 (0)