aboutsummaryrefslogtreecommitdiffstats
path: root/include/api-test/vk-command-buffer.hpp
diff options
context:
space:
mode:
authorQuentin LADEVIE <qladevie@wanadev.fr>2025-01-26 22:27:10 +0100
committerQuentin LADEVIE <qladevie@wanadev.fr>2025-01-26 22:27:10 +0100
commitc29105b461135f3909cca0308fb05715cee45763 (patch)
tree49c6c41bb88377f6af73ebdf39821038b88b05cf /include/api-test/vk-command-buffer.hpp
parent3490db941ea16e67da72f60ebda75ec0f8bb8051 (diff)
DX12 command buffers and resourcesapi-proto
Diffstat (limited to 'include/api-test/vk-command-buffer.hpp')
-rw-r--r--include/api-test/vk-command-buffer.hpp103
1 files changed, 103 insertions, 0 deletions
diff --git a/include/api-test/vk-command-buffer.hpp b/include/api-test/vk-command-buffer.hpp
new file mode 100644
index 0000000..08652fd
--- /dev/null
+++ b/include/api-test/vk-command-buffer.hpp
@@ -0,0 +1,103 @@
+#pragma once
+
+#include <cstdint>
+#include <span>
+
+#include <vulkan/vulkan_core.h>
+
+#include "handle.hpp"
+
+#include "vec3.hpp"
+
+#include "vk-device-types.hpp"
+
+struct device_texture;
+struct device_buffer;
+struct device_pipeline;
+
+struct dispatch_params {
+ enum class PARAM_BINDING : uint32_t {
+ PARAM1,
+ PARAM2,
+ PARAM3,
+ PARAM4,
+ PARAM5,
+ PARAM6,
+ PARAM7,
+ PARAM8,
+ MAX
+ };
+
+ handle<device_pipeline> pipeline;
+ vec3u group_size;
+ vec3u local_group_size;
+ uint64_t params[static_cast<uint32_t>(PARAM_BINDING::MAX)];
+};
+
+struct renderpass_params {
+private:
+ struct rect {
+ int32_t x;
+ int32_t y;
+ uint32_t width;
+ uint32_t height;
+ };
+
+public:
+ rect render_area;
+ std::span<handle<device_texture>> color_attachments;
+};
+
+struct draw_params {
+ handle<device_pipeline> pipeline;
+ handle<device_buffer> index_buffer;
+ uint32_t vertex_count;
+ uint32_t vertex_offset;
+ uint32_t instance_count;
+ uint64_t globals_address = 0U; // TODO: This is probably stupid and should be set elsewhere once ???
+ uint64_t instances_address = 0U;
+ uint64_t uniforms_address = 0U;
+ uint64_t vertex_address = 0U;
+};
+
+struct draw_indexed_params {
+ handle<device_pipeline> pipeline;
+ handle<device_buffer> index_buffer;
+ uint32_t vertex_count;
+ uint32_t vertex_offset;
+ uint32_t index_offset;
+ uint32_t instance_count;
+ uint64_t globals_address = 0U; // TODO: This is probably stupid and should be set elsewhere once ???
+ uint64_t instances_address = 0U;
+ uint64_t uniforms_address = 0U;
+ uint64_t vertex_address = 0U;
+};
+
+struct command_buffer {
+ void start() const;
+ void stop() const;
+
+ void barrier(handle<device_texture> texture_handle, VkPipelineStageFlags2 stage, VkAccessFlags2 access, VkImageLayout layout) const;
+
+ void copy(handle<device_buffer> buffer_handle, handle<device_texture> texture_handle, uint64_t offset = 0) const;
+
+ VkCommandBuffer vk_command_buffer;
+ QueueType queue_type;
+};
+
+// General purpose queue
+struct graphics_command_buffer: public command_buffer {
+ void dispatch(const dispatch_params& params) const;
+
+ void begin_renderpass(const renderpass_params& params) const;
+ void draw(const draw_params& params) const;
+ void draw_indexed(const draw_indexed_params& params) const;
+ void end_renderpass() const;
+};
+
+struct compute_command_buffer: public command_buffer {
+ void dispatch(const dispatch_params& params);
+};
+
+struct transfer_command_buffer: public command_buffer {
+};