aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/api-test/freelist.hpp2
-rw-r--r--include/api-test/vk-device-types.hpp21
-rw-r--r--include/api-test/vk-device.hpp11
3 files changed, 23 insertions, 11 deletions
diff --git a/include/api-test/freelist.hpp b/include/api-test/freelist.hpp
index cfe8903..3cdd55d 100644
--- a/include/api-test/freelist.hpp
+++ b/include/api-test/freelist.hpp
@@ -18,7 +18,7 @@ class freelist {
const auto id = free.back();
free.pop_back();
- items[id] = item;
+ items[id] = std::move(item);
return id;
}
diff --git a/include/api-test/vk-device-types.hpp b/include/api-test/vk-device-types.hpp
index bd2274a..86eb22b 100644
--- a/include/api-test/vk-device-types.hpp
+++ b/include/api-test/vk-device-types.hpp
@@ -4,6 +4,8 @@
#include <span>
+#include "freelist.hpp"
+
using VmaAllocation = struct VmaAllocation_T*;
struct texture_desc {
@@ -14,15 +16,21 @@ struct texture_desc {
VkImageUsageFlags usages;
VkFormat format;
VkImageType type;
+ VkImage vk_image = nullptr;
static constexpr auto max_mips = 16U;
};
struct device_texture {
+ device_texture() = default;
+ device_texture(const texture_desc& desc);
+
+ void create_views();
+
VkImage vk_image;
VkImageView whole_view;
- VkImageView mips_views[texture_desc::max_mips] = { VK_NULL_HANDLE };
- VkImageLayout layout;
+ VkImageView mips_views[texture_desc::max_mips] = { nullptr };
+ VkImageLayout layout = VK_IMAGE_LAYOUT_UNDEFINED;
VkPipelineStageFlags2 stage = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
VkAccessFlags2 access = VK_ACCESS_2_NONE;
VkFormat format;
@@ -37,6 +45,10 @@ struct device_texture {
uint32_t sampled_index = -1;
VmaAllocation alloc;
+
+private:
+ static freelist<device_texture*> storage_indices;
+ static freelist<device_texture*> sampled_indices;
};
struct buffer_desc {
@@ -97,11 +109,12 @@ struct surface_desc {
struct device_surface {
VkSurfaceKHR vk_surface;
VkSwapchainKHR vk_swapchain;
+ VkSurfaceFormatKHR surface_format;
- // handle<device_texture> swapchain_images;
+ handle<device_texture> swapchain_images[surface_desc::max_image_count];
uint32_t image_index;
uint32_t image_count;
void acquire_image_index(handle<device_semaphore> signal_handle);
- handle<device_texture> get_backbuffer_image();
+ handle<device_texture> get_backbuffer_image() const;
};
diff --git a/include/api-test/vk-device.hpp b/include/api-test/vk-device.hpp
index fd69d60..9e42b38 100644
--- a/include/api-test/vk-device.hpp
+++ b/include/api-test/vk-device.hpp
@@ -72,7 +72,7 @@ class vkdevice {
return pipelines[handle.id];
}
- [[nodiscard]] inline const device_surface& get_surface(handle<device_surface> handle) const {
+ [[nodiscard]] inline device_surface& get_surface(handle<device_surface> handle) {
return surfaces[handle.id];
}
@@ -88,6 +88,10 @@ class vkdevice {
return device;
}
+ inline VmaAllocator get_allocator() {
+ return gpu_allocator;
+ }
+
void wait(handle<device_semaphore> semaphore_handle);
void submit(std::span<command_buffer> buffers, handle<device_semaphore> wait_handle, handle<device_semaphore> signal_handle);
@@ -102,8 +106,6 @@ class vkdevice {
VkShaderModule create_shader_module(const std::span<uint8_t>& shader_code);
- void create_views(const texture_desc& desc, device_texture& texture);
-
void create_swapchain(const surface_desc& desc, device_surface& surface);
// TODO: Wrap in a struct called adapter ?
@@ -134,9 +136,6 @@ class vkdevice {
static constexpr size_t max_allocable_command_buffers = 16;
static constexpr size_t max_submitable_command_buffers = 16;
- freelist<device_texture*> storage_indices;
- freelist<device_texture*> sampled_indices;
-
freelist<device_texture> textures;
freelist<device_buffer> buffers;
freelist<device_pipeline> pipelines;