From c4a6f4bbaaf86d50d5da103894469a9bc12a1323 Mon Sep 17 00:00:00 2001 From: ladevieq Date: Sat, 18 Jan 2025 23:48:11 +0100 Subject: Working api prototype --- include/api-test/vk-device.hpp | 72 ++++++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 28 deletions(-) (limited to 'include/api-test/vk-device.hpp') diff --git a/include/api-test/vk-device.hpp b/include/api-test/vk-device.hpp index 1ece366..7f86cbb 100644 --- a/include/api-test/vk-device.hpp +++ b/include/api-test/vk-device.hpp @@ -31,9 +31,13 @@ class vkdevice { handle create_texture(const texture_desc& desc); + handle create_sampler(const sampler_desc& desc); + handle create_buffer(const buffer_desc& desc); - handle create_pipeline(const pipeline_desc& desc); + handle create_graphics_pipeline(const graphics_pipeline_desc& desc); + + handle create_compute_pipeline(const compute_pipeline_desc& desc); handle create_surface(const surface_desc& desc); @@ -41,6 +45,8 @@ class vkdevice { void destroy_texture(handle handle); + void destroy_sampler(handle handle); + void destroy_buffer(handle handle); void destroy_pipeline(handle handle); @@ -49,16 +55,20 @@ class vkdevice { void destroy_surface(handle handle); - template - void allocate_command_buffers(array_type& buffers, QueueType queue_type) { - allocate_command_buffers(static_cast(buffers.data()), buffers.size(), queue_type); + template + void allocate_command_buffers(buffer_type* buffers, size_t count, QueueType queue_type) { + allocate_command_buffers(static_cast(buffers), count, queue_type); } [[nodiscard]] inline device_texture& get_texture(handle handle) { return textures[handle]; } - [[nodiscard]] inline const device_buffer& get_buffer(handle handle) const { + [[nodiscard]] inline device_sampler& get_sampler(handle handle) { + return samplers[handle]; + } + + [[nodiscard]] inline device_buffer& get_buffer(handle handle) { return buffers[handle]; } @@ -86,11 +96,14 @@ class vkdevice { return gpu_allocator; } - void wait(handle semaphore_handle); + // uint64_t submit(std::span buffers, handle wait_handle, handle signal_handle, handle fence_handle); + uint32_t acquire_image_index(handle surface_handle); + uint32_t submit_before_present(handle surface_handle, command_buffer* buffers, uint32_t count); + uint32_t submit(command_buffer* buffers, uint32_t count); - void submit(std::span buffers, handle wait_handle, handle signal_handle); + void present(handle surface_handle); - void present(handle surface_handle, handle semaphore_handle); + void wait(); private: vkdevice() = default; @@ -103,38 +116,41 @@ class vkdevice { void create_swapchain(const surface_desc& desc, device_surface& surface); // TODO: Wrap in a struct called adapter ? - void create_instance(); + void create_instance(); + + void create_device(); - void create_device(); + void create_memory_allocator(); - void create_memory_allocator(); + void create_command_pools(); - void create_command_pools(); + void pick_physical_device(); - void pick_physical_device(); + static bool device_support_features(VkPhysicalDevice physical_dev); - static bool device_support_features(VkPhysicalDevice physical_dev); + void create_debug_layer_callback(); - void create_debug_layer_callback(); + queue queues[static_cast(QueueType::MAX)]; - queue queues[static_cast(QueueType::MAX)]; + VkInstance instance; + VkPhysicalDevice physical_device; + VkDevice device; - VkInstance instance; - VkPhysicalDevice physical_device; - VkDevice device; + VmaAllocator gpu_allocator; - VmaAllocator gpu_allocator; + bindless_model bindless; - bindless_model bindless; + static constexpr size_t max_allocable_command_buffers = 16; + static constexpr size_t max_submitable_command_buffers = 16; - static constexpr size_t max_allocable_command_buffers = 16; - static constexpr size_t max_submitable_command_buffers = 16; + freelist textures; + freelist samplers; + freelist buffers; + freelist pipelines; + freelist surfaces; + freelist semaphores; - freelist textures; - freelist buffers; - freelist pipelines; - freelist surfaces; - freelist semaphores; + device_semaphore timeline_semaphore; static vkdevice render_device; -- cgit v1.3