diff options
| author | ladevieq <ladevie.quentin@gmail.com> | 2022-07-11 00:50:27 +0200 |
|---|---|---|
| committer | ladevieq <ladevie.quentin@gmail.com> | 2022-07-11 00:50:27 +0200 |
| commit | 23e6a58d59b7a11cb8bdb7aa61d3c534c02027e7 (patch) | |
| tree | aa62fe9d75f4b82a0caee70d3bf14fa1e0b617b2 /include | |
| parent | d676e9a2fb533494d1558483e8266605b1d5b632 (diff) | |
Refactor includes & improve compile time
Add platform defined to CMakeLists.txt
Diffstat (limited to 'include')
| -rw-r--r-- | include/camera.hpp | 4 | ||||
| -rw-r--r-- | include/compute-renderpass.hpp | 5 | ||||
| -rw-r--r-- | include/defines.hpp | 12 | ||||
| -rw-r--r-- | include/utils.hpp | 8 | ||||
| -rw-r--r-- | include/vec3.hpp | 5 | ||||
| -rw-r--r-- | include/vk-api.hpp | 10 | ||||
| -rw-r--r-- | include/vk-context.hpp | 11 | ||||
| -rw-r--r-- | include/vk-renderer.hpp | 1 | ||||
| -rw-r--r-- | include/vulkan-loader.hpp | 11 | ||||
| -rw-r--r-- | include/window.hpp | 2 |
10 files changed, 25 insertions, 44 deletions
diff --git a/include/camera.hpp b/include/camera.hpp index 60ca5b5..5c1db61 100644 --- a/include/camera.hpp +++ b/include/camera.hpp @@ -14,9 +14,9 @@ class camera { float focus_dist ); - void set_aspect_ratio(float aspect_ratio); + void set_aspect_ratio(float ratio); - void move(vec3 v); + void move(const vec3& v); void rotate_y(float theta); diff --git a/include/compute-renderpass.hpp b/include/compute-renderpass.hpp index 14c3147..60a1e05 100644 --- a/include/compute-renderpass.hpp +++ b/include/compute-renderpass.hpp @@ -9,10 +9,7 @@ class Buffer; class ComputeRenderpass : public Renderpass { public: - ComputeRenderpass(vkapi& api) - : Renderpass(api) - {} - + ComputeRenderpass(vkapi& api); ~ComputeRenderpass() override; void set_pipeline(const char* shader_name); diff --git a/include/defines.hpp b/include/defines.hpp deleted file mode 100644 index 2b56c7a..0000000 --- a/include/defines.hpp +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef __DEFINES_HPP_ -#define __DEFINES_HPP_ - -#if defined(__linux__) -#define LINUX -#elif defined(_WIN32) || defined(_WIN64) -#define WINDOWS -#elif defined(__APPLE__) -#define MACOS -#endif - -#endif // !__DEFINES_HPP_ diff --git a/include/utils.hpp b/include/utils.hpp index 6e39098..52f3297 100644 --- a/include/utils.hpp +++ b/include/utils.hpp @@ -1,8 +1,8 @@ #ifndef __UTILS_HPP_ #define __UTILS_HPP_ -#include <thread> #include <vector> +#include <functional> std::vector<uint8_t> read_file(const char* path); std::vector<uint8_t> read_file(std::string& path); @@ -10,6 +10,10 @@ std::vector<uint8_t> read_file(std::string& path); #define PI 3.14159265359 #define EPSILON 0.000001 +namespace std::filesystem { + class path; +} + inline float deg_to_rad(float deg) { return deg * PI / 180.f; } @@ -32,4 +36,6 @@ inline float clamp(float x, float min, float max) { return x; } +void watch_file(std::filesystem::path&& filepath, std::function<void()>&& callback); + #endif // !__UTILS_HPP_ diff --git a/include/vec3.hpp b/include/vec3.hpp index 673bd83..e3be2a4 100644 --- a/include/vec3.hpp +++ b/include/vec3.hpp @@ -1,7 +1,6 @@ #ifndef __VEC3_HPP_ #define __VEC3_HPP_ -#include <ostream> #include <xmmintrin.h> class vec3 { @@ -43,6 +42,8 @@ class vec3 { bool near_zero() const; + void print() const; + static vec3 random(); static vec3 random(float min, float max); @@ -68,8 +69,6 @@ vec3 reflect(const vec3& v, const vec3& n); vec3 refract(const vec3& uv, const vec3& n, float etai_over_etat); -std::ostream& operator<<(std::ostream& out, vec3 vec); - using point3 = vec3; using color = vec3; diff --git a/include/vk-api.hpp b/include/vk-api.hpp index c2ed9bd..2c00b40 100644 --- a/include/vk-api.hpp +++ b/include/vk-api.hpp @@ -4,11 +4,14 @@ #include <vector> #include <cassert> -#include "vk-context.hpp" +#include <vulkan/vulkan.h> + +using VmaAllocation = struct VmaAllocation_T*; +using VmaMemoryUsage = enum VmaMemoryUsage; struct buffer { VmaAllocation alloc; - VmaAllocationInfo alloc_info; + void* device_ptr; VkBuffer handle; size_t size; VkDeviceAddress device_address; @@ -27,7 +30,7 @@ struct image { VkImage handle; VkImageView view; VmaAllocation alloc; - VmaAllocationInfo alloc_info; + void* device_ptr; VkImageSubresourceRange subresource_range; VkFormat format; VkExtent3D size; @@ -102,6 +105,7 @@ struct global_descriptor { }; class window; +class vkcontext; class vkapi { public: diff --git a/include/vk-context.hpp b/include/vk-context.hpp index 29e17d2..7638d07 100644 --- a/include/vk-context.hpp +++ b/include/vk-context.hpp @@ -2,10 +2,9 @@ #define __VK_CONTEXT_HPP_ #include <vector> +#include <vulkan/vulkan.h> -#include "vulkan-loader.hpp" - -#include <vk_mem_alloc.h> +using VmaAllocator = struct VmaAllocator_T*; class vkcontext { public: @@ -36,11 +35,11 @@ class vkcontext { void select_queue(VkQueueFlags queueUsage); - void check_available_instance_layers(std::vector<const char*>& needed_layers); + static void check_available_instance_layers(std::vector<const char*>& needed_layers); - void check_available_instance_extensions(std::vector<const char*>& available_layers, std::vector<const char*>& needed_extensions); + static void check_available_instance_extensions(std::vector<const char*>& available_layers, std::vector<const char*>& needed_extensions); - bool support_required_features(VkPhysicalDevice physical_device); + static bool support_required_features(VkPhysicalDevice physical_device); VkDebugUtilsMessengerEXT debugMessenger; diff --git a/include/vk-renderer.hpp b/include/vk-renderer.hpp index b0a34f5..a6107cd 100644 --- a/include/vk-renderer.hpp +++ b/include/vk-renderer.hpp @@ -3,6 +3,7 @@ #include <vector> +#include "vk-context.hpp" #include "vk-api.hpp" diff --git a/include/vulkan-loader.hpp b/include/vulkan-loader.hpp index d8c1082..e15a447 100644 --- a/include/vulkan-loader.hpp +++ b/include/vulkan-loader.hpp @@ -1,17 +1,6 @@ #ifndef __VULKAN_LOADER_HPP_ #define __VULKAN_LOADER_HPP_ -#include "defines.hpp" - -#if defined(WINDOWS) -#define VK_USE_PLATFORM_WIN32_KHR -#elif defined(LINUX) -#define VK_USE_PLATFORM_XCB_KHR -#elif defined(MACOS) -#define VK_USE_PLATFORM_METAL_EXT -#endif - -#define VK_NO_PROTOTYPES #include <vulkan/vulkan.h> #define VULKAN_EXPORTED_FUNCTIONS \ diff --git a/include/window.hpp b/include/window.hpp index cab215f..3f0fa01 100644 --- a/include/window.hpp +++ b/include/window.hpp @@ -3,8 +3,6 @@ #include <vector> -#include "defines.hpp" - class vkrenderer; #if defined(LINUX) |
