From 4ae9a520d97dcaf69f4a0cd044a4fc3fe689924d Mon Sep 17 00:00:00 2001 From: ladevieq Date: Mon, 7 Feb 2022 21:53:14 +0100 Subject: Compute shader render pass api --- include/compute-renderpass.hpp | 57 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 include/compute-renderpass.hpp (limited to 'include/compute-renderpass.hpp') diff --git a/include/compute-renderpass.hpp b/include/compute-renderpass.hpp new file mode 100644 index 0000000..5393032 --- /dev/null +++ b/include/compute-renderpass.hpp @@ -0,0 +1,57 @@ +#pragma once + +#include "vk-api.hpp" +#include + +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 constants; + + size_t group_count_x; + size_t group_count_y; + size_t group_count_z; +}; -- cgit v1.3