diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/compute-renderpass.hpp | 116 | ||||
| -rw-r--r-- | include/vk-api.hpp | 16 | ||||
| -rw-r--r-- | include/vk-renderer.hpp | 2 |
3 files changed, 70 insertions, 64 deletions
diff --git a/include/compute-renderpass.hpp b/include/compute-renderpass.hpp index 5393032..39cbf79 100644 --- a/include/compute-renderpass.hpp +++ b/include/compute-renderpass.hpp @@ -1,57 +1,59 @@ -#pragma once
-
-#include "vk-api.hpp"
-#include <array>
-
-class Texture;
-class Renderpass {
- public:
-
- Renderpass(vkapi& api)
- :api(api)
- {};
-
- virtual ~Renderpass() {
- api.destroy_pipeline(pipeline);
- }
-
- void set_pipeline(pipeline pipeline) {
- this->pipeline = pipeline;
- }
-
- // TODO: Do not use vulkan api type
- virtual void execute(VkCommandBuffer command_buffer) = 0;
-
- protected:
- vkapi &api;
-
- pipeline pipeline;
-};
-
-class ComputeRenderpass : public Renderpass {
- public:
-
- ComputeRenderpass(vkapi& api)
- : Renderpass(api)
- {}
-
- void set_dispatch_size(size_t count_x, size_t count_y, size_t count_z);
-
- void set_ouput_texture(Texture* ouput_texture);
-
- void set_constant(off_t offset, uint64_t* constant);
- void set_constant(off_t offset, Texture* texture);
-
- // TODO: Do not use vulkan api type
- void execute(VkCommandBuffer command_buffer) override final;
-
- Texture* output_texture;
-
- private:
-
- std::array<uint8_t, 64> constants;
-
- size_t group_count_x;
- size_t group_count_y;
- size_t group_count_z;
-};
+#pragma once + +#include "vk-api.hpp" +#include <array> + +class Texture; +class Renderpass { + public: + + Renderpass(vkapi& api) + :api(api) + {}; + + virtual ~Renderpass() { + api.destroy_pipeline(pipeline); + } + + void set_pipeline(pipeline pipeline) { + this->pipeline = pipeline; + } + + // TODO: Do not use vulkan api type + virtual void execute(VkCommandBuffer command_buffer) = 0; + + protected: + vkapi &api; + + pipeline pipeline; +}; + +class ComputeRenderpass : public Renderpass { + public: + + ComputeRenderpass(vkapi& api) + : Renderpass(api) + {} + + void set_dispatch_size(size_t count_x, size_t count_y, size_t count_z); + + void set_ouput_texture(Texture* ouput_texture); + + void set_constant(off_t offset, uint64_t* constant); + void set_constant(off_t offset, Texture* texture); + + // TODO: Do not use vulkan api type + void execute(VkCommandBuffer command_buffer) override final; + + Texture* output_texture; + + private: + + std::vector<Texture*> input_textures; + + std::array<uint8_t, 64> constants; + + size_t group_count_x; + size_t group_count_y; + size_t group_count_z; +}; diff --git a/include/vk-api.hpp b/include/vk-api.hpp index 9cc7707..174d050 100644 --- a/include/vk-api.hpp +++ b/include/vk-api.hpp @@ -31,6 +31,10 @@ struct image { VkExtent3D size; uint32_t bindless_storage_index; uint32_t bindless_sampled_index; + + VkImageLayout previous_layout = VK_IMAGE_LAYOUT_UNDEFINED; + VkPipelineStageFlags previous_stage = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT; + VkAccessFlags previous_access = 0; }; struct swapchain { @@ -160,17 +164,17 @@ class vkapi { void start_record(VkCommandBuffer command_buffer); - void image_barrier(VkCommandBuffer command_buffer, VkImageLayout src_layout, VkImageLayout dst_layout, VkPipelineStageFlagBits src_stage, VkPipelineStageFlagBits dst_stage, VkAccessFlags src_access, VkAccessFlags dst_access, image image); + void image_barrier(VkCommandBuffer command_buffer, VkImageLayout dst_layout, VkPipelineStageFlagBits dst_stage, VkAccessFlags dst_access, image& image); - void begin_render_pass(VkCommandBuffer command_buffer, VkRenderPass render_pass, VkFramebuffer framebuffer, VkExtent2D size, pipeline pipeline); + void begin_render_pass(VkCommandBuffer command_buffer, VkRenderPass render_pass, VkFramebuffer framebuffer, VkExtent2D size, pipeline& pipeline); void end_render_pass(VkCommandBuffer command_buffer); - void run_compute_pipeline(VkCommandBuffer command_buffer, pipeline pipeline, size_t group_count_x, size_t group_count_y, size_t group_count_z); + void run_compute_pipeline(VkCommandBuffer command_buffer, pipeline& pipeline, size_t group_count_x, size_t group_count_y, size_t group_count_z); - void draw(VkCommandBuffer command_buffer, pipeline pipeline, uint32_t vertex_count, uint32_t vertex_offset); - void draw(VkCommandBuffer command_buffer, pipeline pipeline, buffer index_buffer, uint32_t primitive_count, uint32_t indices_offset, uint32_t vertices_offset); + void draw(VkCommandBuffer command_buffer, pipeline& pipeline, uint32_t vertex_count, uint32_t vertex_offset); + void draw(VkCommandBuffer command_buffer, pipeline& pipeline, buffer& index_buffer, uint32_t primitive_count, uint32_t indices_offset, uint32_t vertices_offset); - void blit_full(VkCommandBuffer command_buffer, image src_image, image dst_image); + void blit_full(VkCommandBuffer command_buffer, image& src_image, image& dst_image); void end_record(VkCommandBuffer command_buffer); diff --git a/include/vk-renderer.hpp b/include/vk-renderer.hpp index 2666b64..ba9b5a0 100644 --- a/include/vk-renderer.hpp +++ b/include/vk-renderer.hpp @@ -37,7 +37,7 @@ class vkrenderer { Texture* create_2d_texture(size_t width, size_t height); - void new_renderpass(Renderpass* renderpass); + ComputeRenderpass* create_compute_renderpass(); void render(); |
