aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/compute-renderpass.hpp57
-rw-r--r--include/scene.hpp2
-rw-r--r--include/vk-api.hpp2
-rw-r--r--include/vk-renderer.hpp27
4 files changed, 75 insertions, 13 deletions
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 <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;
+};
diff --git a/include/scene.hpp b/include/scene.hpp
index 0638387..e24e65f 100644
--- a/include/scene.hpp
+++ b/include/scene.hpp
@@ -23,7 +23,7 @@ class scene {
uint32_t enable_dof = false;
uint32_t debug_bvh = false;
- int32_t downscale_factor = 4;
+ int32_t downscale_factor = 1;
metadata(camera cam, uint32_t width, uint32_t height)
: cam(cam), width(width), height(height) {}
diff --git a/include/vk-api.hpp b/include/vk-api.hpp
index 864632e..9cc7707 100644
--- a/include/vk-api.hpp
+++ b/include/vk-api.hpp
@@ -3,6 +3,7 @@
#include <vector>
#include <map>
+#include <iostream>
#include "vk-context.hpp"
@@ -152,6 +153,7 @@ class vkapi {
swapchain create_swapchain(VkSurfaceKHR surface, size_t min_image_count, VkImageUsageFlags usages, VkSwapchainKHR old_swapchain);
void destroy_swapchain(swapchain& swapchain);
+ void update_descriptor_image(image &img, VkDescriptorType type);
void update_descriptor_images(std::vector<image> &images, VkDescriptorType type);
void update_descriptor_samplers(std::vector<sampler> &samplers);
diff --git a/include/vk-renderer.hpp b/include/vk-renderer.hpp
index 2ec9ef8..2666b64 100644
--- a/include/vk-renderer.hpp
+++ b/include/vk-renderer.hpp
@@ -6,9 +6,17 @@
#include "vk-api.hpp"
#include "vulkan-loader.hpp"
+#include "compute-renderpass.hpp"
+
class scene;
class window;
+class Texture {
+ public:
+
+ image device_image;
+};
+
class vkrenderer {
public:
vkrenderer(window& wnd);
@@ -17,8 +25,6 @@ class vkrenderer {
void begin_frame();
- void reset_accumulation();
-
void ui();
void compute(uint32_t width, uint32_t height);
@@ -29,15 +35,15 @@ class vkrenderer {
void update_image(image img, void* data, size_t size);
+ Texture* create_2d_texture(size_t width, size_t height);
+
+ void new_renderpass(Renderpass* renderpass);
+
+ void render();
+
vkapi api;
- VkDeviceAddress scene_buffer_addr;
- VkDeviceAddress indices_buffer_addr;
- VkDeviceAddress positions_buffer_addr;
- VkDeviceAddress normals_buffer_addr;
- VkDeviceAddress uvs_buffer_addr;
- VkDeviceAddress bvh_buffer_addr;
- VkDeviceAddress materials_buffer_addr;
+ std::vector<Renderpass*> renderpasses;
private:
@@ -48,14 +54,11 @@ class vkrenderer {
uint32_t virtual_frame_index = 0;
uint32_t swapchain_image_index = 0;
- std::vector<image> accumulation_images;
sampler ui_texture_sampler;
image ui_texture;
std::vector<VkCommandBuffer> command_buffers;
- pipeline compute_pipeline;
-
buffer staging_buffer;