From 6bdf3ab65a7c1e98595ad167479b94a82184a444 Mon Sep 17 00:00:00 2001 From: ladevieq Date: Sat, 24 Jul 2021 17:32:49 +0200 Subject: Clean up includes, scene class, simplify scene buffer access from main --- include/scene.hpp | 41 +++++++++++++++++++++++++++++++++++++++++ include/utils.hpp | 37 +++---------------------------------- include/vk-api.hpp | 1 - include/vk-renderer.hpp | 11 ++++++++--- 4 files changed, 52 insertions(+), 38 deletions(-) create mode 100644 include/scene.hpp (limited to 'include') diff --git a/include/scene.hpp b/include/scene.hpp new file mode 100644 index 0000000..b7e1100 --- /dev/null +++ b/include/scene.hpp @@ -0,0 +1,41 @@ +#ifndef __SCENE_HPP_ +#define __SCENE_HPP_ + +#include "vec3.hpp" +#include "sphere.hpp" +#include "camera.hpp" +#include "bvh-node.hpp" + + +class scene { +public: + scene(uint32_t width, uint32_t height); + + color sky_color = { 0.5, 0.7, 1.0 }; + color ground_color = { 1.0, 1.0, 1.0 }; + + camera cam; + + sphere spheres[512] = {}; + bvh_node nodes[1024] = {}; + + uint32_t max_bounce = 50; + + // Output image resolution + uint32_t width; + uint32_t height; + + uint32_t sample_index = 0; + + uint32_t spheres_count = 0; + uint32_t enable_dof = true; + uint32_t debug_bvh = false; + uint32_t padding; + +private: + + uint32_t random_scene(sphere* world); + +}; + +#endif // !__SCENE_HPP_ diff --git a/include/utils.hpp b/include/utils.hpp index 4683e86..b00db81 100644 --- a/include/utils.hpp +++ b/include/utils.hpp @@ -1,42 +1,11 @@ #ifndef __UTILS_HPP_ #define __UTILS_HPP_ -#include -#include +#include #include -#include "vec3.hpp" -#include "sphere.hpp" -#include "camera.hpp" -#include "bvh-node.hpp" - -struct input_data { - color sky_color; - color ground_color; - - camera cam; - - sphere spheres[512]; - bvh_node nodes[1024]; - - uint32_t max_bounce; - - // Output image resolution - uint32_t width; - uint32_t height; - - uint32_t sample_index; - - uint32_t spheres_count; - uint32_t enable_dof; - uint32_t debug_bvh; - uint32_t padding; -}; - -std::vector get_shader_code(const char* path); -std::vector get_shader_code(std::string& path); - -struct input_data create_inputs(uint32_t width, uint32_t height); +std::vector read_file(const char* path); +std::vector read_file(std::string& path); #define PI 3.14159265359 diff --git a/include/vk-api.hpp b/include/vk-api.hpp index 59d09b7..a9dc024 100644 --- a/include/vk-api.hpp +++ b/include/vk-api.hpp @@ -2,7 +2,6 @@ #define __VK_API_HPP_ #include -#include #include "vk-context.hpp" diff --git a/include/vk-renderer.hpp b/include/vk-renderer.hpp index 630588f..b478b25 100644 --- a/include/vk-renderer.hpp +++ b/include/vk-renderer.hpp @@ -6,12 +6,12 @@ #include "vk-api.hpp" #include "vulkan-loader.hpp" -class input_data; +class scene; class window; class vkrenderer { public: - vkrenderer(window& wnd, const input_data& inputs); + vkrenderer(window& wnd, size_t scene_buffer_size); ~vkrenderer(); @@ -27,7 +27,9 @@ class vkrenderer { void recreate_swapchain(); - Buffer compute_shader_buffer; + inline void* scene_buffer_ptr() { + return scene_buffer.alloc_info.pMappedData; + } private: @@ -49,6 +51,9 @@ class vkrenderer { std::vector compute_shader_sets; Pipeline compute_pipeline; + Buffer scene_buffer; + + std::vector tonemapping_sets_bindings; std::vector tonemapping_shader_sets; Pipeline tonemapping_pipeline; -- cgit v1.3