diff options
Diffstat (limited to 'include/api-test')
| -rw-r--r-- | include/api-test/command-buffer.hpp | 44 | ||||
| -rw-r--r-- | include/api-test/handle.hpp | 2 | ||||
| -rw-r--r-- | include/api-test/vk-command-buffer.hpp | 14 | ||||
| -rw-r--r-- | include/api-test/vk-device.hpp | 65 |
4 files changed, 71 insertions, 54 deletions
diff --git a/include/api-test/command-buffer.hpp b/include/api-test/command-buffer.hpp new file mode 100644 index 0000000..140a291 --- /dev/null +++ b/include/api-test/command-buffer.hpp @@ -0,0 +1,44 @@ +#pragma once + +#include <cstdint> + +#include <vulkan/vulkan_core.h> + +#include "handle.hpp" + +enum class QueueType : uint32_t { + GRAPHICS, + ASYNC_COMPUTE, + TRANSFER, + MAX, +}; + + +struct device_buffer; +struct device_texture; + +struct command_buffer { + void start() const; + void stop() const; + + void barrier(); + + VkCommandBuffer handle; + QueueType queue_type; +}; + +struct graphics_command_buffer : public command_buffer { + void set_pipeline(); + + void dispatch(); +}; + +struct compute_command_buffer : public command_buffer { + void set_pipeline(); + + void dispatch(); +}; + +struct transfer_command_buffer : public command_buffer { + void copy(::handle<device_buffer> buffer_handle, ::handle<device_texture> texture_handle); +}; diff --git a/include/api-test/handle.hpp b/include/api-test/handle.hpp index 90c1ade..c14e212 100644 --- a/include/api-test/handle.hpp +++ b/include/api-test/handle.hpp @@ -4,5 +4,5 @@ template<typename T> struct handle { - const uint32_t handle; + const uint32_t id; }; diff --git a/include/api-test/vk-command-buffer.hpp b/include/api-test/vk-command-buffer.hpp deleted file mode 100644 index c1f1899..0000000 --- a/include/api-test/vk-command-buffer.hpp +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include <vulkan/vulkan_core.h> - -class command_buffer { - void start(); - void stop(); - - VkCommandBuffer handle; -}; - -class graphics_command_buffer : command_buffer { - -}; diff --git a/include/api-test/vk-device.hpp b/include/api-test/vk-device.hpp index f931c70..f010cc5 100644 --- a/include/api-test/vk-device.hpp +++ b/include/api-test/vk-device.hpp @@ -8,28 +8,11 @@ #include "freelist.hpp" #include "texture.hpp" #include "buffer.hpp" +#include "command-buffer.hpp" using VmaAllocator = struct VmaAllocator_T*; using VmaAllocation = struct VmaAllocation_T*; -// typedef struct VkInstance_T* VkInstance; -// typedef struct VkDevice_T* VkDevice; -// typedef struct VkPhysicalDevice_T* VkPhysicalDevice; -// typedef struct VkQueue_T* VkQueue; -// typedef uint32_t VkFlags; -// typedef VkFlags VkQueueUsageFlags; -// typedef struct VkImage_T* VkImage; -// typedef struct VkImageView_T* VkImageView; -// typedef struct VkBuffer_T* VkBuffer; -// typedef enum VkImageType VkImageType; -// typedef enum VkFormat VkFormat; -// typedef VkFlags VkImageUsageFlags; -// -// #ifdef _DEBUG -// typedef struct VkDebugUtilsMessengerEXT_T* VkDebugUtilsMessengerEXT; -// #endif // _DEBUG - - struct device_texture { VkImage handle; VkImageView whole_view; @@ -51,6 +34,13 @@ struct device_buffer { class window; class vkdevice { + struct queue { + VkQueue handle; + uint32_t index; + VkQueueFlags usages; + VkCommandPool command_pool; + }; + public: vkdevice(const window& window); @@ -59,18 +49,25 @@ public: handle<device_buffer> create_buffer(const buffer_desc& desc); + template<typename cmd_buf_type> + void allocate_command_buffers(cmd_buf_type* buffers, size_t count, QueueType queue_type) { + allocate_command_buffers(buffers, count, queue_type); + } + const device_texture& get_texture(handle<device_texture> handle) { - return textures[handle.handle]; + return textures[handle.id]; } const device_buffer& get_buffer(handle<device_buffer> handle) { - return buffers[handle.handle]; + return buffers[handle.id]; } - void submit(/*std::span<command_buffer>*/); + void submit(command_buffer* buffers, size_t count); private: + void allocate_command_buffers(command_buffer* buffers, size_t count, QueueType type); + void create_views(device_texture& texture); void create_surface(const window& window); @@ -98,29 +95,19 @@ private: void create_debug_layer_callback(); - enum QueueTypes : uint32_t { - GRAPHICS, - // COPY, - MAX, - }; - - struct queue { - VkQueue handle; - uint32_t index; - VkQueueFlags usages; - VkCommandPool command_pool; - }; + queue queues[static_cast<uint32_t>(QueueType::MAX)]; - queue queues[QueueTypes::MAX]; + VkInstance instance; + VkPhysicalDevice physical_device; + VkDevice device; - VkInstance instance; - VkPhysicalDevice physical_device; - VkDevice device; + VmaAllocator gpu_allocator; - VmaAllocator gpu_allocator; + static constexpr size_t max_allocable_command_buffers = 16; + static constexpr size_t max_submitable_command_buffers = 16; #ifdef _DEBUG - VkDebugUtilsMessengerEXT debug_messenger; + VkDebugUtilsMessengerEXT debug_messenger; #endif // _DEBUG freelist<device_texture> textures; |
