From 782741f0fea5b2a95aed9ad3673ecafb4b164885 Mon Sep 17 00:00:00 2001 From: ladevieq Date: Mon, 17 Aug 2026 02:20:13 +0200 Subject: Inital work on vulkan descriptor heap implementation --- include/vk-device.hpp | 67 ++++++++++++++++++--------------------------------- 1 file changed, 24 insertions(+), 43 deletions(-) (limited to 'include/vk-device.hpp') diff --git a/include/vk-device.hpp b/include/vk-device.hpp index e2e8c99..84a1a36 100644 --- a/include/vk-device.hpp +++ b/include/vk-device.hpp @@ -37,8 +37,6 @@ class vkdevice { handle create_surface(const surface_desc& desc); - handle create_semaphore(const semaphore_desc& desc, const char* name); - void destroy_texture(handle handle); void destroy_sampler(handle handle); @@ -47,8 +45,6 @@ class vkdevice { void destroy_pipeline(handle handle); - void destroy_semaphore(handle handle); - void destroy_surface(handle handle); template @@ -56,50 +52,34 @@ class vkdevice { allocate_command_buffers(static_cast(buffers), count, queue_type, name); } - [[nodiscard]] inline device_texture& get_texture(handle handle) { - return textures[handle]; - } - - [[nodiscard]] inline device_sampler& get_sampler(handle handle) { - return samplers[handle]; - } - - [[nodiscard]] inline device_buffer& get_buffer(handle handle) { - return buffers[handle]; + [[nodiscard]] inline device_texture* get_texture(handle handle) { + return &textures[handle]; } - [[nodiscard]] inline const device_pipeline& get_pipeline(handle handle) const { - return pipelines[handle]; + [[nodiscard]] inline device_sampler* get_sampler(handle handle) { + return &samplers[handle]; } - [[nodiscard]] inline device_surface& get_surface(handle handle) { - return surfaces[handle]; + [[nodiscard]] inline device_buffer* get_buffer(handle handle) { + return &buffers[handle]; } - [[nodiscard]] inline device_semaphore& get_semaphore(handle handle) { - return semaphores[handle]; + [[nodiscard]] inline const device_pipeline* get_pipeline(handle handle) const { + return &pipelines[handle]; } - [[nodiscard]] inline const bindless_model& get_bindingmodel() const { - return bindless; + [[nodiscard]] inline device_surface* get_surface(handle handle) { + return &surfaces[handle]; } - const freelist& get_textures() const { - return textures; + inline VmaAllocator get_allocator() const { + return gpu_allocator; } inline VkDevice get_device() const { return device; } - inline VmaAllocator get_allocator() { - return gpu_allocator; - } - - inline const VkPhysicalDeviceLimits& get_device_limits() const { - return physical_device_props.properties.limits; - } - // uint64_t submit(std::span buffers, handle wait_handle, handle signal_handle, handle fence_handle); uint32_t acquire_image_index(handle surface_handle); uint64_t submit_before_present(handle surface_handle, command_buffer* buffers, uint32_t count); @@ -109,6 +89,8 @@ class vkdevice { void wait(); + void wait_for_fence(u64 value); + private: vkdevice() = default; ~vkdevice() = default; @@ -122,16 +104,10 @@ class vkdevice { void create_device(); - void create_memory_allocator(); - - void create_command_pools(); - - void pick_physical_device(); + void create_heaps(VkPhysicalDeviceDescriptorHeapPropertiesEXT& descriptor_heap_props); bool device_support_features(VkPhysicalDevice physical_dev); - void create_debug_layer_callback(); - queue queues[static_cast(QueueType::MAX)]; VkInstance instance; @@ -139,9 +115,15 @@ class vkdevice { VkPhysicalDeviceProperties2 physical_device_props; VkDevice device; - VmaAllocator gpu_allocator; + handle image_heap; // TODO: Dont use handle for internally used resources + handle sampler_heap; + + static constexpr size_t max_images_count = UINT16_MAX; + static constexpr size_t max_samplers_count = 16U; - bindless_model bindless; + static size_t + + VmaAllocator gpu_allocator; static constexpr size_t max_allocable_command_buffers = 16; static constexpr size_t max_submitable_command_buffers = 16; @@ -151,9 +133,8 @@ class vkdevice { freelist buffers; freelist pipelines; freelist surfaces; - freelist semaphores; - device_semaphore timeline_semaphore; + device_semaphore fence; static vkdevice render_device; -- cgit v1.3