diff options
| author | ladevieq <ladevie.quentin@gmail.com> | 2022-08-04 23:35:13 +0200 |
|---|---|---|
| committer | ladevieq <ladevie.quentin@gmail.com> | 2022-08-04 23:35:13 +0200 |
| commit | 8279a357f6f35d58a4c81d84c3c44a7da687b170 (patch) | |
| tree | 20e4dae3824bb485e34a43e44f6e468ed0afffd0 /include | |
| parent | 969dd101a08997dc318207b6994201d5161d0bd3 (diff) | |
Fix most warnings
Diffstat (limited to 'include')
| -rw-r--r-- | include/compute-renderpass.hpp | 2 | ||||
| -rw-r--r-- | include/material.hpp | 2 | ||||
| -rw-r--r-- | include/primitive-renderpass.hpp | 4 | ||||
| -rw-r--r-- | include/scene.hpp | 19 | ||||
| -rw-r--r-- | include/utils.hpp | 10 | ||||
| -rw-r--r-- | include/vk-api.hpp | 19 | ||||
| -rw-r--r-- | include/vk-context.hpp | 2 | ||||
| -rw-r--r-- | include/vk-renderer.hpp | 3 |
8 files changed, 28 insertions, 33 deletions
diff --git a/include/compute-renderpass.hpp b/include/compute-renderpass.hpp index 60a1e05..6799171 100644 --- a/include/compute-renderpass.hpp +++ b/include/compute-renderpass.hpp @@ -16,7 +16,7 @@ class ComputeRenderpass : public Renderpass { 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_ouput_texture(Texture* out_texture); void set_constant(off_t offset, uint64_t* constant); void set_constant(off_t offset, Texture* texture); diff --git a/include/material.hpp b/include/material.hpp index 780e68d..efa6141 100644 --- a/include/material.hpp +++ b/include/material.hpp @@ -1,6 +1,8 @@ #ifndef __MATERIAL_HPP_ #define __MATERIAL_HPP_ +#include <cstdint> + #include "vec3.hpp" struct texture { diff --git a/include/primitive-renderpass.hpp b/include/primitive-renderpass.hpp index 8dda772..4d90d3c 100644 --- a/include/primitive-renderpass.hpp +++ b/include/primitive-renderpass.hpp @@ -68,7 +68,7 @@ class Primitive { void set_scissor(int32_t x, int32_t y, uint32_t width, uint32_t height); - void set_draw_info(size_t vertex_count, off_t first_vertex, off_t vertex_offset); + void set_draw_info(size_t vertex_count, off_t indices_off, off_t vertex_off); void render(VkCommandBuffer command_buffer); @@ -84,7 +84,7 @@ private: Buffer* index_buffer; size_t element_count; - off_t first_vertex; + off_t indices_offset; off_t vertex_offset; off_t constant_offset; diff --git a/include/scene.hpp b/include/scene.hpp index c0b0344..257b8c9 100644 --- a/include/scene.hpp +++ b/include/scene.hpp @@ -1,11 +1,10 @@ #ifndef __SCENE_HPP_
#define __SCENE_HPP_
+#include <cstdint>
+
#include "camera.hpp"
-#include "bvh.hpp"
-#include "material.hpp"
-class vkrenderer;
class Buffer;
class scene {
struct metadata {
@@ -23,24 +22,16 @@ class scene { uint32_t debug_bvh = (uint32_t)false;
int32_t downscale_factor = 1;
- metadata(camera cam, uint32_t width, uint32_t height)
- : cam(std::move(cam)), width(width), height(height) {}
+ metadata(const camera &cam, uint32_t width, uint32_t height);
};
// void random_scene();
public:
- scene(camera cam, uint32_t width, uint32_t height, vkrenderer &renderer);
+ scene(const camera& cam, uint32_t width, uint32_t height);
metadata meta;
- // Geometry & BVH
- std::vector<uint32_t> indices;
- std::vector<float> positions;
- std::vector<float> normals;
- std::vector<float> uvs;
- std::vector<material> materials;
-
Buffer* scene_buffer;
Buffer* indices_buffer;
Buffer* positions_buffer;
@@ -48,8 +39,6 @@ public: Buffer* uvs_buffer;
Buffer* bvh_buffer;
Buffer* materials_buffer;
-
- std::vector<packed_bvh_node> packed_nodes;
};
#endif // !__SCENE_HPP_
diff --git a/include/utils.hpp b/include/utils.hpp index cbc92b3..83a867f 100644 --- a/include/utils.hpp +++ b/include/utils.hpp @@ -31,16 +31,17 @@ inline int32_t randi(int32_t min, int32_t max) { } inline float clamp(float x, float min, float max) { - if (x < min) return min; - if (x > max) return max; + if (x < min) { return min; } + if (x > max) { return max; } return x; } -#include <windows.h> #if defined(WINDOWS) + +#include <windows.h> + void log_last_error(); -#endif class watcher { public: @@ -61,3 +62,4 @@ private: inline static std::unordered_map<std::string, std::function<void()>> callbacks; inline static std::unordered_map<std::string, watch_data> watched_dirs; }; +#endif diff --git a/include/vk-api.hpp b/include/vk-api.hpp index 2391b60..2b88e42 100644 --- a/include/vk-api.hpp +++ b/include/vk-api.hpp @@ -7,7 +7,6 @@ #include "vulkan-loader.hpp" using VmaAllocation = struct VmaAllocation_T*; -using VmaMemoryUsage = enum VmaMemoryUsage; struct buffer { VmaAllocation alloc; @@ -68,8 +67,10 @@ struct global_descriptor { std::vector<uint32_t> index_pool[3]; + static constexpr uint32_t pool_size = 1024U; + global_descriptor() { - for (int32_t index = 1024; index > 0; index--) { + for (int32_t index = pool_size; index > 0; index--) { index_pool[0].push_back((uint32_t)index); index_pool[1].push_back((uint32_t)index); index_pool[2].push_back((uint32_t)index); @@ -112,7 +113,7 @@ class vkapi { vkapi(vkcontext& context); ~vkapi(); - handle create_buffer(size_t data_size, VkBufferUsageFlags buffer_usage, VmaMemoryUsage mem_usage); + handle create_buffer(size_t data_size, VkBufferUsageFlags buffer_usage, uint32_t mem_usage); void copy_buffer(VkCommandBuffer cmd_buf, handle src, handle dst, size_t size); void copy_buffer(VkCommandBuffer cmd_buf, handle src, handle dst); void destroy_buffer(handle buffer); @@ -121,7 +122,7 @@ class vkapi { handle create_image(VkExtent3D size, VkFormat format, VkImageUsageFlags usages); void destroy_image(handle image); std::vector<handle> create_images(VkExtent3D size, VkFormat format, VkImageUsageFlags usages, size_t image_count); - void destroy_images(std::vector<handle>& images); + void destroy_images(std::vector<handle>& imgs); [[nodiscard]] VkFence create_fence() const; @@ -150,13 +151,13 @@ class vkapi { framebuffer create_framebuffer(VkRenderPass render_pass, std::vector<VkFormat>& formats, VkExtent2D size); std::vector<framebuffer> create_framebuffers(VkRenderPass render_pass, std::vector<VkFormat>& formats, VkExtent2D size, uint32_t framebuffer_count); - void destroy_framebuffer(framebuffer framebuffer); - void destroy_framebuffers(std::vector<framebuffer>& framebuffers); + void destroy_framebuffer(framebuffer framebuffer) const; + void destroy_framebuffers(std::vector<framebuffer>& framebuffers) const; - pipeline create_compute_pipeline(const char* shader_name); - pipeline create_graphics_pipeline(const char* shader_name, VkShaderStageFlagBits shader_stages, VkRenderPass render_pass, std::vector<VkDynamicState>& dynamic_states); - void destroy_pipeline(pipeline &pipeline); + pipeline create_compute_pipeline(const char* shader_name) const; + pipeline create_graphics_pipeline(const char* shader_name, VkShaderStageFlagBits shader_stages, VkRenderPass render_pass, std::vector<VkDynamicState>& dynamic_states) const; + void destroy_pipeline(pipeline &pipeline) const; std::vector<VkDescriptorSet> create_descriptor_sets(VkDescriptorSetLayout descriptor_sets_layout, size_t descriptor_sets_count); diff --git a/include/vk-context.hpp b/include/vk-context.hpp index 078b3c0..8d0b91f 100644 --- a/include/vk-context.hpp +++ b/include/vk-context.hpp @@ -37,7 +37,7 @@ class vkcontext { static void check_available_instance_layers(std::vector<const char*>& needed_layers); - static 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*>& needed_extensions); static bool support_required_features(VkPhysicalDevice physical_device); diff --git a/include/vk-renderer.hpp b/include/vk-renderer.hpp index 5efb7d6..57ebb31 100644 --- a/include/vk-renderer.hpp +++ b/include/vk-renderer.hpp @@ -31,7 +31,7 @@ class vkrenderer { void update_image(Texture* texture, void* data); - void update_buffer(Buffer* buffer, void* data, off_t offset, size_t size); + void update_buffer(Buffer* buffer, void* data, off_t offset, size_t size) const; Buffer* create_buffer(size_t size, bool isStatic); @@ -116,6 +116,7 @@ class Buffer { handle device_buffer; size_t size; + size_t element_size; bool isStatic; }; |
