diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 1c6db85586e1e4d090deb81914a1fa97a6bead9d..5585f795d7192fd0b620dd99d6ba4bdf5e961a20 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -13,6 +13,7 @@ jobs: - name: Initialize LFS run: | + sudo apt-get -qq install git-lfs git lfs install - name: Load submodules @@ -23,6 +24,7 @@ jobs: - name: Install dependencies run: | sudo apt-get -qq update + sudo apt-get -qq install cmake g++ sudo apt-get -qq install libvulkan-dev xorg-dev - name: Build framework diff --git a/config/Sources.cmake b/config/Sources.cmake index b693dea53180ac1f9499403e16a2f6aeb3f975d2..1770ef32d214b03409a8e677b10bb4ee200f8631 100644 --- a/config/Sources.cmake +++ b/config/Sources.cmake @@ -9,7 +9,9 @@ set(vkcv_sources ${vkcv_include}/vkcv/Context.hpp ${vkcv_source}/vkcv/Context.cpp - + + ${vkcv_include}/vkcv/Container.hpp + ${vkcv_include}/vkcv/Core.hpp ${vkcv_source}/vkcv/Core.cpp diff --git a/include/vkcv/Buffer.hpp b/include/vkcv/Buffer.hpp index a7dba97ef5eb02af48a6d2ee33f4cf9a410243a3..0fd085ec607017d463320fae7c2f78d78e7f5e53 100644 --- a/include/vkcv/Buffer.hpp +++ b/include/vkcv/Buffer.hpp @@ -5,9 +5,8 @@ * @brief Template buffer class for type security with buffers. */ -#include <vector> - #include "BufferTypes.hpp" +#include "Container.hpp" #include "Core.hpp" #include "Handles.hpp" @@ -112,7 +111,7 @@ namespace vkcv { * @param vector Vector of type T to be copied into the #Buffer * @param offset The offset into the #Buffer where the data is copied into */ - void fill(const std::vector<T> &vector, size_t offset = 0) { + void fill(const Vector<T> &vector, size_t offset = 0) { fill(static_cast<const T*>(vector.data()), static_cast<size_t>(vector.size()), offset); } @@ -146,7 +145,7 @@ namespace vkcv { * @param vector Vector of type T to be copied into from the #Buffer * @param offset The offset into the #Buffer where the data is copied from */ - void read(std::vector<T> &vector, size_t offset = 0) { + void read(Vector<T> &vector, size_t offset = 0) { read(static_cast<T*>(vector.data()), static_cast<size_t>(vector.size()), offset); } diff --git a/include/vkcv/Container.hpp b/include/vkcv/Container.hpp new file mode 100644 index 0000000000000000000000000000000000000000..20c79557e6faa6d4e6d735cec8d89159357ddfd3 --- /dev/null +++ b/include/vkcv/Container.hpp @@ -0,0 +1,23 @@ +#pragma once +/** + * @authors Tobias Frisch + * @file vkcv/Container.hpp + * @brief A header to define container types for the framework. + */ + +#include <vector> +#include <unordered_map> +#include <unordered_set> + +namespace vkcv { + + template<typename K, typename V> + using Dictionary = std::unordered_map<K, V>; + + template<typename T> + using Vector = std::vector<T>; + + template<typename T> + using Set = std::unordered_set<T>; + +} diff --git a/include/vkcv/Context.hpp b/include/vkcv/Context.hpp index ce56589d1d90b5b49eb9128dfa5e0d11f9cfa5e4..82090760ade9c4a4190d3a163c6688035b3e4100 100644 --- a/include/vkcv/Context.hpp +++ b/include/vkcv/Context.hpp @@ -100,9 +100,9 @@ namespace vkcv { * @return New context */ static Context create(const std::string &applicationName, uint32_t applicationVersion, - const std::vector<vk::QueueFlagBits> &queueFlags, + const Vector<vk::QueueFlagBits> &queueFlags, const Features &features, - const std::vector<const char*> &instanceExtensions = {}); + const Vector<const char*> &instanceExtensions = {}); private: /** diff --git a/include/vkcv/Core.hpp b/include/vkcv/Core.hpp index 7d562d766600f02f0041b75260caf01ee2138f0c..5939988c3dc41f4ea4c640ed1bb30795fec8a36c 100644 --- a/include/vkcv/Core.hpp +++ b/include/vkcv/Core.hpp @@ -13,6 +13,7 @@ #include "BlitDownsampler.hpp" #include "BufferTypes.hpp" #include "ComputePipelineConfig.hpp" +#include "Container.hpp" #include "Context.hpp" #include "DescriptorWrites.hpp" #include "DispatchSize.hpp" @@ -85,8 +86,8 @@ namespace vkcv { std::unique_ptr<CommandStreamManager> m_CommandStreamManager; std::unique_ptr<WindowManager> m_WindowManager; std::unique_ptr<SwapchainManager> m_SwapchainManager; - - std::vector<vk::CommandPool> m_CommandPools; + + Vector<vk::CommandPool> m_CommandPools; vk::Semaphore m_RenderFinished; vk::Semaphore m_SwapchainImageAcquired; uint32_t m_currentSwapchainImageIndex; @@ -160,9 +161,9 @@ namespace vkcv { * @return New instance of #Context */ static Core create(const std::string &applicationName, uint32_t applicationVersion, - const std::vector<vk::QueueFlagBits> &queueFlags = {}, + const Vector<vk::QueueFlagBits> &queueFlags = {}, const Features &features = {}, - const std::vector<const char*> &instanceExtensions = {}); + const Vector<const char*> &instanceExtensions = {}); /** * Creates a basic vulkan graphics pipeline using @p config from the pipeline config class @@ -536,8 +537,8 @@ namespace vkcv { void recordDrawcallsToCmdStream(const CommandStreamHandle &cmdStreamHandle, const GraphicsPipelineHandle &pipelineHandle, const PushConstants &pushConstants, - const std::vector<InstanceDrawcall> &drawcalls, - const std::vector<ImageHandle> &renderTargets, + const Vector<InstanceDrawcall> &drawcalls, + const Vector<ImageHandle> &renderTargets, const WindowHandle &windowHandle); /** @@ -555,8 +556,8 @@ namespace vkcv { void recordIndirectDrawcallsToCmdStream(const CommandStreamHandle cmdStreamHandle, const GraphicsPipelineHandle &pipelineHandle, const PushConstants &pushConstantData, - const std::vector<IndirectDrawcall> &drawcalls, - const std::vector<ImageHandle> &renderTargets, + const Vector<IndirectDrawcall> &drawcalls, + const Vector<ImageHandle> &renderTargets, const WindowHandle &windowHandle); /** @@ -574,8 +575,8 @@ namespace vkcv { void recordMeshShaderDrawcalls(const CommandStreamHandle &cmdStreamHandle, const GraphicsPipelineHandle &pipelineHandle, const PushConstants &pushConstantData, - const std::vector<TaskDrawcall> &drawcalls, - const std::vector<ImageHandle> &renderTargets, + const Vector<TaskDrawcall> &drawcalls, + const Vector<ImageHandle> &renderTargets, const WindowHandle &windowHandle); /** @@ -592,7 +593,7 @@ namespace vkcv { void recordRayGenerationToCmdStream(const CommandStreamHandle &cmdStreamHandle, const RayTracingPipelineHandle &rayTracingPipeline, const DispatchSize &dispatchSize, - const std::vector<DescriptorSetUsage> + const Vector<DescriptorSetUsage> &descriptorSetUsages, const PushConstants &pushConstants, const vkcv::WindowHandle &windowHandle); @@ -610,7 +611,7 @@ namespace vkcv { recordComputeDispatchToCmdStream(const CommandStreamHandle &cmdStream, const ComputePipelineHandle &computePipeline, const DispatchSize &dispatchSize, - const std::vector<DescriptorSetUsage> &descriptorSetUsages, + const Vector<DescriptorSetUsage> &descriptorSetUsages, const PushConstants &pushConstants); /** @@ -643,7 +644,7 @@ namespace vkcv { void recordComputeIndirectDispatchToCmdStream( const CommandStreamHandle cmdStream, const ComputePipelineHandle computePipeline, const vkcv::BufferHandle buffer, const size_t bufferArgOffset, - const std::vector<DescriptorSetUsage> &descriptorSetUsages, + const Vector<DescriptorSetUsage> &descriptorSetUsages, const PushConstants &pushConstants); /** @@ -968,7 +969,7 @@ namespace vkcv { * @return Acceleration structure handle */ AccelerationStructureHandle createAccelerationStructure( - const std::vector<GeometryData> &geometryData, + const Vector<GeometryData> &geometryData, const BufferHandle &transformBuffer = {}, bool compaction = false); @@ -980,7 +981,7 @@ namespace vkcv { * @return Acceleration structure handle */ AccelerationStructureHandle createAccelerationStructure( - const std::vector<AccelerationStructureHandle> &handles); + const Vector<AccelerationStructureHandle> &handles); /** * @brief the underlying vulkan handle for an acceleration structure diff --git a/include/vkcv/DescriptorBinding.hpp b/include/vkcv/DescriptorBinding.hpp index c97d1dfebc6d4415c04f51a761ddcdbc34ba6d68..4591618d381d4127607a31a07c4fc90dcc4c1522 100644 --- a/include/vkcv/DescriptorBinding.hpp +++ b/include/vkcv/DescriptorBinding.hpp @@ -5,8 +5,7 @@ * @brief Structures to handle descriptor bindings. */ -#include <unordered_map> - +#include "Container.hpp" #include "DescriptorTypes.hpp" #include "ShaderStage.hpp" @@ -26,6 +25,6 @@ namespace vkcv { bool operator==(const DescriptorBinding &other) const; }; - typedef std::unordered_map<uint32_t, DescriptorBinding> DescriptorBindings; + typedef Dictionary<uint32_t, DescriptorBinding> DescriptorBindings; } // namespace vkcv diff --git a/include/vkcv/DescriptorSetUsage.hpp b/include/vkcv/DescriptorSetUsage.hpp index 098d1846c35b3724fb2540ebb41a1b6cd61d62fc..d4316116be3d4cbc54136c9ede51053bfab4c988 100644 --- a/include/vkcv/DescriptorSetUsage.hpp +++ b/include/vkcv/DescriptorSetUsage.hpp @@ -5,8 +5,7 @@ * @brief Structures to handle descriptor usages. */ -#include <vector> - +#include "Container.hpp" #include "Handles.hpp" namespace vkcv { @@ -17,10 +16,10 @@ namespace vkcv { struct DescriptorSetUsage { uint32_t location; DescriptorSetHandle descriptorSet; - std::vector<uint32_t> dynamicOffsets; + Vector<uint32_t> dynamicOffsets; }; DescriptorSetUsage useDescriptorSet(uint32_t location, const DescriptorSetHandle &descriptorSet, - const std::vector<uint32_t> &dynamicOffsets = {}); + const Vector<uint32_t> &dynamicOffsets = {}); } // namespace vkcv diff --git a/include/vkcv/DescriptorWrites.hpp b/include/vkcv/DescriptorWrites.hpp index 4bc306bcb3d50bab5683f2599d04807987cc11ae..ca50b915ba677bf0b129e017f2b7ef35ba15831b 100644 --- a/include/vkcv/DescriptorWrites.hpp +++ b/include/vkcv/DescriptorWrites.hpp @@ -5,9 +5,9 @@ * @brief Structures to handle descriptor writes. */ -#include <vector> #include <vulkan/vulkan.hpp> +#include "Container.hpp" #include "Handles.hpp" namespace vkcv { @@ -61,7 +61,7 @@ namespace vkcv { */ struct AccelerationDescriptorWrite { uint32_t binding; - std::vector<AccelerationStructureHandle> structures; + Vector<AccelerationStructureHandle> structures; }; /** @@ -70,12 +70,12 @@ namespace vkcv { */ class DescriptorWrites { private: - std::vector<SampledImageDescriptorWrite> m_sampledImageWrites; - std::vector<StorageImageDescriptorWrite> m_storageImageWrites; - std::vector<BufferDescriptorWrite> m_uniformBufferWrites; - std::vector<BufferDescriptorWrite> m_storageBufferWrites; - std::vector<SamplerDescriptorWrite> m_samplerWrites; - std::vector<AccelerationDescriptorWrite> m_accelerationWrites; + Vector<SampledImageDescriptorWrite> m_sampledImageWrites; + Vector<StorageImageDescriptorWrite> m_storageImageWrites; + Vector<BufferDescriptorWrite> m_uniformBufferWrites; + Vector<BufferDescriptorWrite> m_storageBufferWrites; + Vector<SamplerDescriptorWrite> m_samplerWrites; + Vector<AccelerationDescriptorWrite> m_accelerationWrites; public: /** @@ -159,49 +159,49 @@ namespace vkcv { */ DescriptorWrites & writeAcceleration(uint32_t binding, - const std::vector<AccelerationStructureHandle> &structures); + const Vector<AccelerationStructureHandle> &structures); /** * @brief Returns the list of stored write entries for sampled images. * * @return Sampled image write details */ - [[nodiscard]] const std::vector<SampledImageDescriptorWrite> &getSampledImageWrites() const; + [[nodiscard]] const Vector<SampledImageDescriptorWrite> &getSampledImageWrites() const; /** * @brief Returns the list of stored write entries for storage images. * * @return Storage image write details */ - [[nodiscard]] const std::vector<StorageImageDescriptorWrite> &getStorageImageWrites() const; + [[nodiscard]] const Vector<StorageImageDescriptorWrite> &getStorageImageWrites() const; /** * @brief Returns the list of stored write entries for uniform buffers. * * @return Uniform buffers write details */ - [[nodiscard]] const std::vector<BufferDescriptorWrite> &getUniformBufferWrites() const; + [[nodiscard]] const Vector<BufferDescriptorWrite> &getUniformBufferWrites() const; /** * @brief Returns the list of stored write entries for storage buffers. * * @return Storage buffers write details */ - [[nodiscard]] const std::vector<BufferDescriptorWrite> &getStorageBufferWrites() const; + [[nodiscard]] const Vector<BufferDescriptorWrite> &getStorageBufferWrites() const; /** * @brief Returns the list of stored write entries for samplers. * * @return Samplers write details */ - [[nodiscard]] const std::vector<SamplerDescriptorWrite> &getSamplerWrites() const; + [[nodiscard]] const Vector<SamplerDescriptorWrite> &getSamplerWrites() const; /** * @brief Returns the list of stored write entries for accelerations. * * @return Accelerations write details */ - [[nodiscard]] const std::vector<AccelerationDescriptorWrite> &getAccelerationWrites() const; + [[nodiscard]] const Vector<AccelerationDescriptorWrite> &getAccelerationWrites() const; }; } // namespace vkcv \ No newline at end of file diff --git a/include/vkcv/Drawcall.hpp b/include/vkcv/Drawcall.hpp index 5b2298149e84bd3af6eed574b4ccd838e38df3da..ca4b8165bd22cfdd263ef9622e1a462b76b31afa 100644 --- a/include/vkcv/Drawcall.hpp +++ b/include/vkcv/Drawcall.hpp @@ -5,8 +5,7 @@ * @brief Classes to define different drawcalls. */ -#include <vector> - +#include "Container.hpp" #include "DescriptorSetUsage.hpp" #include "DispatchSize.hpp" #include "Handles.hpp" @@ -19,7 +18,7 @@ namespace vkcv { */ class Drawcall { private: - std::vector<DescriptorSetUsage> m_usages; + Vector<DescriptorSetUsage> m_usages; public: Drawcall() = default; @@ -32,10 +31,10 @@ namespace vkcv { Drawcall &operator=(const Drawcall &other) = default; Drawcall &operator=(Drawcall &&other) noexcept = default; - [[nodiscard]] const std::vector<DescriptorSetUsage> &getDescriptorSetUsages() const; + [[nodiscard]] const Vector<DescriptorSetUsage> &getDescriptorSetUsages() const; void useDescriptorSet(uint32_t location, const DescriptorSetHandle &descriptorSet, - const std::vector<uint32_t> &dynamicOffsets = {}); + const Vector<uint32_t> &dynamicOffsets = {}); }; /** diff --git a/include/vkcv/Event.hpp b/include/vkcv/Event.hpp index 3bba94b20afb56dd185751e8cafc787076822c2a..328b0e51ff4b3c78c3926083b71dbdcb6b98afa0 100644 --- a/include/vkcv/Event.hpp +++ b/include/vkcv/Event.hpp @@ -15,7 +15,7 @@ #endif #endif -#include <vector> +#include "Container.hpp" namespace vkcv { @@ -50,7 +50,7 @@ namespace vkcv { template <typename... T> struct event { private: - std::vector< event_function<T...> > m_functions; + Vector< event_function<T...> > m_functions; uint32_t m_id_counter; #ifndef __MINGW32__ diff --git a/include/vkcv/FeatureManager.hpp b/include/vkcv/FeatureManager.hpp index 4b0d4560e49b7168fafbea93190b85cd025eadbb..741d49a53ca5d55a2c0b386b181390ff8cb2319d 100644 --- a/include/vkcv/FeatureManager.hpp +++ b/include/vkcv/FeatureManager.hpp @@ -6,10 +6,9 @@ */ #include <functional> -#include <unordered_set> -#include <vector> #include <vulkan/vulkan.hpp> +#include "Container.hpp" #include "Logger.hpp" namespace vkcv { @@ -27,12 +26,12 @@ namespace vkcv { /** * List of supported extensions. */ - std::vector<const char*> m_supportedExtensions; + Vector<const char*> m_supportedExtensions; /** * List of activated extensions for usage. */ - std::vector<const char*> m_activeExtensions; + Vector<const char*> m_activeExtensions; /** * Feature structure chain to request activated features. @@ -42,7 +41,7 @@ namespace vkcv { /** * List of base structures allocated to request extension specific features. */ - std::vector<vk::BaseOutStructure*> m_featuresExtensions; + Vector<vk::BaseOutStructure*> m_featuresExtensions; /** * @brief Checks support of the @p vk::PhysicalDeviceFeatures. @@ -445,7 +444,7 @@ namespace vkcv { * * @return List of activated extensions */ - [[nodiscard]] const std::vector<const char*> &getActiveExtensions() const; + [[nodiscard]] const Vector<const char*> &getActiveExtensions() const; /** * @brief Request specific features for optional or required usage ( only core Vulkan 1.0 ). diff --git a/include/vkcv/Features.hpp b/include/vkcv/Features.hpp index 8b39de4f8f1183664f163d8add7f135102dab631..04830490301dd1b36bac7c257a52ccbed6fc55d1 100644 --- a/include/vkcv/Features.hpp +++ b/include/vkcv/Features.hpp @@ -7,8 +7,8 @@ #include <functional> #include <initializer_list> -#include <vector> +#include "Container.hpp" #include "FeatureManager.hpp" namespace vkcv { @@ -26,7 +26,7 @@ namespace vkcv { /** * List of feature requests. */ - std::vector<Feature> m_features; + Vector<Feature> m_features; public: /** @@ -197,7 +197,7 @@ namespace vkcv { * * @return List of feature requests */ - [[nodiscard]] const std::vector<Feature> &getList() const; + [[nodiscard]] const Vector<Feature> &getList() const; }; } // namespace vkcv diff --git a/include/vkcv/File.hpp b/include/vkcv/File.hpp index f6895d41bbefbedd2d6e9ac2c012c4f2a5ae3bb1..4f68d685eaf86cc6672c460a9dd47dd05f3e4e91 100644 --- a/include/vkcv/File.hpp +++ b/include/vkcv/File.hpp @@ -6,7 +6,8 @@ */ #include <filesystem> -#include <vector> + +#include "Container.hpp" namespace vkcv { @@ -33,7 +34,7 @@ namespace vkcv { * @return True on success, false otherwise */ bool writeContentToFile(const std::filesystem::path &path, - const std::vector<char>& content); + const Vector<char>& content); /** * @brief Write binary data from a vector to a file at @@ -44,7 +45,7 @@ namespace vkcv { * @return True on success, false otherwise */ bool writeBinaryToFile(const std::filesystem::path &path, - const std::vector<uint32_t>& binary); + const Vector<uint32_t>& binary); /** * @brief Write text to a file at a given path. @@ -65,7 +66,7 @@ namespace vkcv { * @return True on success, false otherwise */ bool readContentFromFile(const std::filesystem::path &path, - std::vector<char>& content); + Vector<char>& content); /** * @brief Read binary data from a file at a given path @@ -76,7 +77,7 @@ namespace vkcv { * @return True on success, false otherwise */ bool readBinaryFromFile(const std::filesystem::path &path, - std::vector<uint32_t>& binary); + Vector<uint32_t>& binary); /** * @brief Read text from a file at a given path. diff --git a/include/vkcv/GraphicsPipelineConfig.hpp b/include/vkcv/GraphicsPipelineConfig.hpp index 2d67501b8bbef138a80e845bd0b4938321d6d12d..3473ed0edba9d242627d63e736cd8132e6a0b7e5 100644 --- a/include/vkcv/GraphicsPipelineConfig.hpp +++ b/include/vkcv/GraphicsPipelineConfig.hpp @@ -6,8 +6,8 @@ */ #include <cstdint> -#include <vector> +#include "Container.hpp" #include "Multisampling.hpp" #include "PipelineConfig.hpp" #include "VertexLayout.hpp" @@ -83,7 +83,7 @@ namespace vkcv { GraphicsPipelineConfig(const ShaderProgram &program, const PassHandle &pass, const VertexLayout &vertexLayout, - const std::vector<DescriptorSetLayoutHandle> &layouts); + const Vector<DescriptorSetLayoutHandle> &layouts); GraphicsPipelineConfig(const GraphicsPipelineConfig &other) = default; GraphicsPipelineConfig(GraphicsPipelineConfig &&other) = default; diff --git a/include/vkcv/Interpolation.hpp b/include/vkcv/Interpolation.hpp index c38a7aa746e36a3a58a0c3dd1c94db549ba101e7..a851c9cf0e36d074930eefc9976f0cadefd6d5c7 100644 --- a/include/vkcv/Interpolation.hpp +++ b/include/vkcv/Interpolation.hpp @@ -8,7 +8,8 @@ #include <algorithm> #include <cmath> #include <functional> -#include <vector> + +#include "Container.hpp" namespace vkcv { @@ -31,7 +32,7 @@ namespace vkcv { struct interpolation { private: typename interpolation_function<V, T>::type m_function; - std::vector< interpolation_state<V, T> > m_states; + Vector< interpolation_state<V, T> > m_states; public: interpolation(const typename interpolation_function<V, T>::type& function) diff --git a/include/vkcv/Pass.hpp b/include/vkcv/Pass.hpp index c5299d391c0c3760441a15740a68719d6e480bd4..2a819f30c61119ed6eea9a8d5750d4a99845d46a 100644 --- a/include/vkcv/Pass.hpp +++ b/include/vkcv/Pass.hpp @@ -5,20 +5,21 @@ * @brief Support functions for basic pass creation. */ +#include "Container.hpp" #include "Core.hpp" #include "Handles.hpp" #include "PassConfig.hpp" namespace vkcv { - PassHandle passFormats(Core &core, const std::vector<vk::Format> &formats, bool clear = true, + PassHandle passFormats(Core &core, const Vector<vk::Format> &formats, bool clear = true, Multisampling multisampling = Multisampling::None); PassHandle passFormat(Core &core, vk::Format format, bool clear = true, Multisampling multisampling = Multisampling::None); PassHandle passSwapchain(Core &core, const SwapchainHandle &swapchain, - const std::vector<vk::Format> &formats, bool clear = true, + const Vector<vk::Format> &formats, bool clear = true, Multisampling multisampling = Multisampling::None); } // namespace vkcv diff --git a/include/vkcv/PassConfig.hpp b/include/vkcv/PassConfig.hpp index efe741d07fd731a2c71fd6bf706cda7e39d43a50..4aade8e4f370e5bf7b1ecd1d6cc28692f10be632 100644 --- a/include/vkcv/PassConfig.hpp +++ b/include/vkcv/PassConfig.hpp @@ -5,9 +5,9 @@ * @brief Enums and structures to handle render pass configuration. */ -#include <vector> #include <vulkan/vulkan.hpp> +#include "Container.hpp" #include "Multisampling.hpp" namespace vkcv { @@ -60,7 +60,7 @@ namespace vkcv { [[nodiscard]] const vk::ClearValue &getClearValue() const; }; - using AttachmentDescriptions = std::vector<AttachmentDescription>; + using AttachmentDescriptions = Vector<AttachmentDescription>; /** * @brief Class to configure a pass for usage. diff --git a/include/vkcv/PipelineConfig.hpp b/include/vkcv/PipelineConfig.hpp index 575f17057ed1f0a8588fcf141a11a0e539aca178..79f558b75256f19b11632e39d41253ed6e770b73 100644 --- a/include/vkcv/PipelineConfig.hpp +++ b/include/vkcv/PipelineConfig.hpp @@ -5,8 +5,7 @@ * @brief Pipeline config class to hand over required information to pipeline creation */ -#include <vector> - +#include "Container.hpp" #include "Handles.hpp" #include "ShaderProgram.hpp" @@ -18,13 +17,13 @@ namespace vkcv { class PipelineConfig { private: ShaderProgram m_ShaderProgram; - std::vector<DescriptorSetLayoutHandle> m_DescriptorSetLayouts; + Vector<DescriptorSetLayoutHandle> m_DescriptorSetLayouts; public: PipelineConfig(); PipelineConfig(const ShaderProgram &program, - const std::vector<DescriptorSetLayoutHandle> &layouts); + const Vector<DescriptorSetLayoutHandle> &layouts); PipelineConfig(const PipelineConfig &other) = default; PipelineConfig(PipelineConfig &&other) = default; @@ -40,9 +39,9 @@ namespace vkcv { void addDescriptorSetLayout(const DescriptorSetLayoutHandle &layout); - void addDescriptorSetLayouts(const std::vector<DescriptorSetLayoutHandle> &layouts); + void addDescriptorSetLayouts(const Vector<DescriptorSetLayoutHandle> &layouts); - [[nodiscard]] const std::vector<DescriptorSetLayoutHandle> &getDescriptorSetLayouts() const; + [[nodiscard]] const Vector<DescriptorSetLayoutHandle> &getDescriptorSetLayouts() const; }; } // namespace vkcv diff --git a/include/vkcv/PushConstants.hpp b/include/vkcv/PushConstants.hpp index 4c577acbe09cd6b19d82213526bc4b7d498a6ede..d3d9736e62e89729d9e9384f4ecab6737fb2fb5d 100644 --- a/include/vkcv/PushConstants.hpp +++ b/include/vkcv/PushConstants.hpp @@ -5,9 +5,9 @@ * @brief Class to manage push constants for pipeline recording. */ -#include <vector> #include <vulkan/vulkan.hpp> +#include "Container.hpp" #include "Logger.hpp" #include "TypeGuard.hpp" @@ -19,7 +19,7 @@ namespace vkcv { class PushConstants final { private: TypeGuard m_typeGuard; - std::vector<uint8_t> m_data; + Vector<uint8_t> m_data; public: explicit PushConstants(size_t sizePerDrawcall); @@ -142,7 +142,7 @@ namespace vkcv { } template <typename T> - PushConstants pushConstants(const std::vector<T> &values) { + PushConstants pushConstants(const Vector<T> &values) { auto pc = pushConstants<T>(); for (const T &value : values) { diff --git a/include/vkcv/QueueManager.hpp b/include/vkcv/QueueManager.hpp index 5bdf64dd2ac10f9cbfb4a03d58a3ed27d827a755..7ddd727560a83e8dfb746922917cafc1a809cc1a 100644 --- a/include/vkcv/QueueManager.hpp +++ b/include/vkcv/QueueManager.hpp @@ -7,6 +7,8 @@ #include <vulkan/vulkan.hpp> +#include "Container.hpp" + namespace vkcv { /** @@ -44,9 +46,9 @@ namespace vkcv { * @return New queue manager with the specified queue pairs */ static QueueManager create(vk::Device device, - const std::vector<std::pair<int, int>> &queuePairsGraphics, - const std::vector<std::pair<int, int>> &queuePairsCompute, - const std::vector<std::pair<int, int>> &queuePairsTransfer); + const Vector<std::pair<int, int>> &queuePairsGraphics, + const Vector<std::pair<int, int>> &queuePairsCompute, + const Vector<std::pair<int, int>> &queuePairsTransfer); /** * @brief Returns the default queue with present support. @@ -61,21 +63,21 @@ namespace vkcv { * * @return Vector of graphics queues */ - [[nodiscard]] const std::vector<Queue> &getGraphicsQueues() const; + [[nodiscard]] const Vector<Queue> &getGraphicsQueues() const; /** * @brief Returns all queues with the compute flag. * * @return Vector of compute queues */ - [[nodiscard]] const std::vector<Queue> &getComputeQueues() const; + [[nodiscard]] const Vector<Queue> &getComputeQueues() const; /** * @brief Returns all queues with the transfer flag. * * @return Vector of transfer queues */ - [[nodiscard]] const std::vector<Queue> &getTransferQueues() const; + [[nodiscard]] const Vector<Queue> &getTransferQueues() const; /** * @brief Checks for presenting support of a given surface @@ -90,13 +92,13 @@ namespace vkcv { const vk::SurfaceKHR &surface); private: - std::vector<Queue> m_graphicsQueues; - std::vector<Queue> m_computeQueues; - std::vector<Queue> m_transferQueues; + Vector<Queue> m_graphicsQueues; + Vector<Queue> m_computeQueues; + Vector<Queue> m_transferQueues; size_t m_presentIndex; - QueueManager(std::vector<Queue> &&graphicsQueues, std::vector<Queue> &&computeQueues, - std::vector<Queue> &&transferQueues, size_t presentIndex); + QueueManager(Vector<Queue> &&graphicsQueues, Vector<Queue> &&computeQueues, + Vector<Queue> &&transferQueues, size_t presentIndex); }; } // namespace vkcv diff --git a/include/vkcv/RayTracingPipelineConfig.hpp b/include/vkcv/RayTracingPipelineConfig.hpp index 37ca1c4e418d1049a8faa668b8dea17a577b52e7..572eb5af5b4aa2d82a9ca75de5e232f6e824b25b 100644 --- a/include/vkcv/RayTracingPipelineConfig.hpp +++ b/include/vkcv/RayTracingPipelineConfig.hpp @@ -4,7 +4,8 @@ * @file vkcv/RayTracingPipelineConfig.hpp * @brief Ray tracing pipeline config struct to hand over required information to pipeline creation. */ - + +#include "Container.hpp" #include "PipelineConfig.hpp" namespace vkcv { @@ -17,7 +18,7 @@ namespace vkcv { RayTracingPipelineConfig(); RayTracingPipelineConfig(const ShaderProgram &program, - const std::vector<DescriptorSetLayoutHandle> &layouts); + const Vector<DescriptorSetLayoutHandle> &layouts); RayTracingPipelineConfig(const RayTracingPipelineConfig &other) = default; RayTracingPipelineConfig(RayTracingPipelineConfig &&other) = default; diff --git a/include/vkcv/ShaderProgram.hpp b/include/vkcv/ShaderProgram.hpp index c14a36310ad7170251764e47f113df8869038da6..a88597b087d63f47d528a69b731a2ef1826b7b45 100644 --- a/include/vkcv/ShaderProgram.hpp +++ b/include/vkcv/ShaderProgram.hpp @@ -10,9 +10,9 @@ #include <filesystem> #include <iostream> #include <spirv_cross.hpp> -#include <unordered_map> #include <vulkan/vulkan.hpp> +#include "Container.hpp" #include "DescriptorBinding.hpp" #include "ShaderStage.hpp" #include "VertexLayout.hpp" @@ -50,7 +50,7 @@ namespace vkcv { * @param[in] stage The stage of the shader * @return Shader code binary of the given stage */ - const std::vector<uint32_t> &getShaderBinary(ShaderStage stage) const; + const Vector<uint32_t> &getShaderBinary(ShaderStage stage) const; /** * @brief Returns whether a shader exists in the program for a @@ -67,7 +67,7 @@ namespace vkcv { * * @return Vertex attachments */ - const std::vector<VertexAttachment> &getVertexAttachments() const; + const Vector<VertexAttachment> &getVertexAttachments() const; /** * @brief Returns the size of the programs push constants. @@ -82,7 +82,7 @@ namespace vkcv { * * @return Reflected descriptor set bindings */ - const std::unordered_map<uint32_t, DescriptorBindings> &getReflectedDescriptors() const; + const Dictionary<uint32_t, DescriptorBindings> &getReflectedDescriptors() const; private: /** @@ -93,11 +93,11 @@ namespace vkcv { */ void reflectShader(ShaderStage shaderStage); - std::unordered_map<ShaderStage, std::vector<uint32_t> > m_Shaders; + Dictionary<ShaderStage, Vector<uint32_t> > m_Shaders; // contains all vertex input attachments used in the vertex buffer VertexAttachments m_VertexAttachments; - std::unordered_map<uint32_t, DescriptorBindings> m_DescriptorSets; + Dictionary<uint32_t, DescriptorBindings> m_DescriptorSets; size_t m_pushConstantsSize = 0; }; diff --git a/include/vkcv/VertexData.hpp b/include/vkcv/VertexData.hpp index a9928a4dc66779d3747b74d54269fff731776c94..881ca7c17a9a103ae283229c8331ac537fe343b0 100644 --- a/include/vkcv/VertexData.hpp +++ b/include/vkcv/VertexData.hpp @@ -5,8 +5,7 @@ * @brief Types to configure vertex data for drawcalls. */ -#include <vector> - +#include "Container.hpp" #include "Handles.hpp" namespace vkcv { @@ -33,7 +32,7 @@ namespace vkcv { size_t stride, size_t offset = 0); - typedef std::vector<VertexBufferBinding> VertexBufferBindings; + typedef Vector<VertexBufferBinding> VertexBufferBindings; /** * @brief Enum class to specify the size of indexes. diff --git a/include/vkcv/VertexLayout.hpp b/include/vkcv/VertexLayout.hpp index 2c6cfb486348dea7f255c4fbdc26a27b3bfdda56..0e3c872ff0b0dfb0de5600c67acadd5e4cf420a8 100644 --- a/include/vkcv/VertexLayout.hpp +++ b/include/vkcv/VertexLayout.hpp @@ -8,7 +8,8 @@ #include <iostream> #include <string> -#include <vector> + +#include "Container.hpp" namespace vkcv { @@ -48,7 +49,7 @@ namespace vkcv { uint32_t offset; }; - typedef std::vector<VertexAttachment> VertexAttachments; + typedef Vector<VertexAttachment> VertexAttachments; /** * @brief Structure to store the details of a vertex buffer binding. @@ -75,7 +76,7 @@ namespace vkcv { VertexBinding createVertexBinding(uint32_t bindingLocation, const VertexAttachments &attachments); - typedef std::vector<VertexBinding> VertexBindings; + typedef Vector<VertexBinding> VertexBindings; /** * Creates vertex bindings in a very simplified way with one vertex binding for diff --git a/include/vkcv/Window.hpp b/include/vkcv/Window.hpp index 3d157b98220f17752d6b109401c3d21899299f18..799dd8481bb9d1d4cd51f465de5730340afb53e3 100644 --- a/include/vkcv/Window.hpp +++ b/include/vkcv/Window.hpp @@ -12,6 +12,7 @@ #include <algorithm> #include <string> +#include "Container.hpp" #include "Event.hpp" #include "Handles.hpp" @@ -100,7 +101,7 @@ namespace vkcv { * * @return Required surface extensions */ - static const std::vector<std::string> &getExtensions(); + static const Vector<std::string> &getExtensions(); event< int, int, int> e_mouseButton; event< double, double > e_mouseMove; diff --git a/modules/shader_compiler/src/vkcv/shader/Compiler.cpp b/modules/shader_compiler/src/vkcv/shader/Compiler.cpp index c7935f8905bb86b5f93c9f5fe98f2f6e3a6e85c2..194faee90b6e8156c663ddabbffec509bf6a0451 100644 --- a/modules/shader_compiler/src/vkcv/shader/Compiler.cpp +++ b/modules/shader_compiler/src/vkcv/shader/Compiler.cpp @@ -1,6 +1,7 @@ #include "vkcv/shader/Compiler.hpp" +#include <vkcv/Container.hpp> #include <vkcv/File.hpp> #include <vkcv/Logger.hpp> @@ -8,7 +9,7 @@ namespace vkcv::shader { bool Compiler::compileSourceWithHeaders(ShaderStage shaderStage, const std::string &shaderSource, - const std::unordered_map<std::filesystem::path, std::string> &shaderHeaders, + const Dictionary<std::filesystem::path, std::string> &shaderHeaders, const ShaderCompiledFunction &compiled) { const std::filesystem::path directory = generateTemporaryDirectoryPath(); @@ -42,7 +43,7 @@ namespace vkcv::shader { } void Compiler::compileProgram(ShaderProgram& program, - const std::unordered_map<ShaderStage, const std::filesystem::path>& stages, + const Dictionary<ShaderStage, const std::filesystem::path>& stages, const ShaderProgramCompiledFunction& compiled, const std::filesystem::path& includePath, bool update) { std::vector<std::pair<ShaderStage, const std::filesystem::path>> stageList; diff --git a/projects/bindless_textures/src/main.cpp b/projects/bindless_textures/src/main.cpp index 5021de5ca081f009ab39806c5648662f86482418..2a922747c7e16766f240fc807c6c8abe0153c61c 100644 --- a/projects/bindless_textures/src/main.cpp +++ b/projects/bindless_textures/src/main.cpp @@ -140,9 +140,9 @@ int main(int argc, const char** argv) { ); const vkcv::VertexLayout firstMeshLayout { bindings }; - const std::unordered_map<uint32_t, vkcv::DescriptorBinding> &descriptorBindings = firstMeshProgram.getReflectedDescriptors().at(0); + const vkcv::DescriptorBindings &descriptorBindings = firstMeshProgram.getReflectedDescriptors().at(0); - std::unordered_map<uint32_t, vkcv::DescriptorBinding> adjustedBindings = descriptorBindings; + vkcv::DescriptorBindings adjustedBindings = descriptorBindings; adjustedBindings[1].descriptorCount = 6; vkcv::DescriptorSetLayoutHandle descriptorSetLayout = core.createDescriptorSetLayout(adjustedBindings); diff --git a/src/vkcv/AccelerationStructureManager.cpp b/src/vkcv/AccelerationStructureManager.cpp index 18ab457ed0e44beb290bfe293c95e19b21b983df..02d3e65be5211948d1159c7a3f7b2116c58b2dca 100644 --- a/src/vkcv/AccelerationStructureManager.cpp +++ b/src/vkcv/AccelerationStructureManager.cpp @@ -118,8 +118,8 @@ namespace vkcv { static AccelerationStructureEntry buildAccelerationStructure( Core& core, BufferManager& bufferManager, - std::vector<vk::AccelerationStructureBuildGeometryInfoKHR> &geometryInfos, - const std::vector<vk::AccelerationStructureBuildRangeInfoKHR> &rangeInfos, + Vector<vk::AccelerationStructureBuildGeometryInfoKHR> &geometryInfos, + const Vector<vk::AccelerationStructureBuildRangeInfoKHR> &rangeInfos, vk::AccelerationStructureTypeKHR accelerationStructureType, size_t accelerationStructureSize, size_t scratchBufferSize, @@ -187,7 +187,7 @@ namespace vkcv { geometryInfo.setScratchData(scratchBufferAddress); } - std::vector<const vk::AccelerationStructureBuildRangeInfoKHR*> pRangeInfos; + Vector<const vk::AccelerationStructureBuildRangeInfoKHR*> pRangeInfos; pRangeInfos.resize(rangeInfos.size()); for (size_t i = 0; i < rangeInfos.size(); i++) { @@ -336,12 +336,12 @@ namespace vkcv { } AccelerationStructureHandle AccelerationStructureManager::createAccelerationStructure( - const std::vector<GeometryData> &geometryData, + const Vector<GeometryData> &geometryData, const BufferHandle &transformBuffer, bool compaction) { - std::vector<vk::AccelerationStructureGeometryKHR> geometries; - std::vector<vk::AccelerationStructureBuildGeometryInfoKHR> geometryInfos; - std::vector<vk::AccelerationStructureBuildRangeInfoKHR> rangeInfos; + Vector<vk::AccelerationStructureGeometryKHR> geometries; + Vector<vk::AccelerationStructureBuildGeometryInfoKHR> geometryInfos; + Vector<vk::AccelerationStructureBuildRangeInfoKHR> rangeInfos; if (geometryData.empty()) { return {}; @@ -371,7 +371,7 @@ namespace vkcv { geometries.reserve(geometryData.size()); rangeInfos.reserve(geometryData.size()); - std::vector<uint32_t> maxPrimitiveCount; + Vector<uint32_t> maxPrimitiveCount; maxPrimitiveCount.reserve(geometryData.size()); @@ -522,8 +522,8 @@ namespace vkcv { } AccelerationStructureHandle AccelerationStructureManager::createAccelerationStructure( - const std::vector<AccelerationStructureHandle> &accelerationStructures) { - std::vector<vk::AccelerationStructureInstanceKHR> asInstances; + const Vector<AccelerationStructureHandle> &accelerationStructures) { + Vector<vk::AccelerationStructureInstanceKHR> asInstances; if (accelerationStructures.empty()) { return {}; @@ -624,7 +624,7 @@ namespace vkcv { {} ); - std::vector<vk::AccelerationStructureBuildGeometryInfoKHR> asBuildGeometryInfos = { + Vector<vk::AccelerationStructureBuildGeometryInfoKHR> asBuildGeometryInfos = { vk::AccelerationStructureBuildGeometryInfoKHR( vk::AccelerationStructureTypeKHR::eTopLevel, vk::BuildAccelerationStructureFlagBitsKHR::ePreferFastTrace, diff --git a/src/vkcv/AccelerationStructureManager.hpp b/src/vkcv/AccelerationStructureManager.hpp index 041b4acf323184dee0197cf57caedc15cb282aa5..2a8a6901288f942fb015fc8f76fd89c2586e73e3 100644 --- a/src/vkcv/AccelerationStructureManager.hpp +++ b/src/vkcv/AccelerationStructureManager.hpp @@ -6,13 +6,13 @@ */ #include <memory> -#include <vector> #include <vk_mem_alloc.hpp> #include <vulkan/vulkan.hpp> #include "BufferManager.hpp" +#include "vkcv/Container.hpp" #include "vkcv/Handles.hpp" #include "vkcv/GeometryData.hpp" @@ -22,7 +22,7 @@ namespace vkcv { vk::AccelerationStructureTypeKHR m_type; vk::DeviceSize m_size; vk::AccelerationStructureKHR m_accelerationStructure; - std::vector<AccelerationStructureHandle> m_children; + Vector<AccelerationStructureHandle> m_children; BufferHandle m_storageBuffer; }; @@ -79,12 +79,12 @@ namespace vkcv { const AccelerationStructureHandle &handle) const; [[nodiscard]] AccelerationStructureHandle createAccelerationStructure( - const std::vector<GeometryData> &geometryData, + const Vector<GeometryData> &geometryData, const BufferHandle &transformBuffer, bool compaction); [[nodiscard]] AccelerationStructureHandle createAccelerationStructure( - const std::vector<AccelerationStructureHandle> &accelerationStructures); + const Vector<AccelerationStructureHandle> &accelerationStructures); }; diff --git a/src/vkcv/BufferManager.cpp b/src/vkcv/BufferManager.cpp index 466ca064eb12b7e1c55dadebb2d41705fd097c71..6678270f4f1a08835fcdfd83807c97d86f43f3c1 100644 --- a/src/vkcv/BufferManager.cpp +++ b/src/vkcv/BufferManager.cpp @@ -21,7 +21,7 @@ namespace vkcv { const auto& memoryProperties = allocator.getMemoryProperties(); const auto& heaps = memoryProperties->memoryHeaps; - std::vector<vk::MemoryPropertyFlags> heapMemoryFlags; + Vector<vk::MemoryPropertyFlags> heapMemoryFlags; heapMemoryFlags.resize(heaps.size()); for (const auto& type : memoryProperties->memoryTypes) { diff --git a/src/vkcv/BufferManager.hpp b/src/vkcv/BufferManager.hpp index 891b59fc476adbdbebc65eea4c1bb33c33fe2ef2..f26dbfe47ecaee7095eb09b288d37dba658c357f 100644 --- a/src/vkcv/BufferManager.hpp +++ b/src/vkcv/BufferManager.hpp @@ -6,12 +6,12 @@ */ #include <memory> -#include <vector> #include <vk_mem_alloc.hpp> #include <vulkan/vulkan.hpp> #include "vkcv/BufferTypes.hpp" +#include "vkcv/Container.hpp" #include "vkcv/TypeGuard.hpp" #include "HandleManager.hpp" diff --git a/src/vkcv/CommandStreamManager.cpp b/src/vkcv/CommandStreamManager.cpp index b93cf0a812933ef3f1ea3f62689a5c03062e6e80..87703e3791ace680ecf4d58b49f40050c63707f6 100644 --- a/src/vkcv/CommandStreamManager.cpp +++ b/src/vkcv/CommandStreamManager.cpp @@ -73,15 +73,15 @@ namespace vkcv { } void CommandStreamManager::submitCommandStreamSynchronous( - const CommandStreamHandle &handle, std::vector<vk::Semaphore> &waitSemaphores, - std::vector<vk::Semaphore> &signalSemaphores) { + const CommandStreamHandle &handle, Vector<vk::Semaphore> &waitSemaphores, + Vector<vk::Semaphore> &signalSemaphores) { auto &stream = (*this) [handle]; stream.cmdBuffer.end(); const auto device = getCore().getContext().getDevice(); const vk::Fence waitFence = device.createFence({}); - const std::vector<vk::PipelineStageFlags> waitDstStageMasks( + const Vector<vk::PipelineStageFlags> waitDstStageMasks( waitSemaphores.size(), vk::PipelineStageFlagBits::eAllCommands); const vk::SubmitInfo queueSubmitInfo(waitSemaphores, waitDstStageMasks, stream.cmdBuffer, diff --git a/src/vkcv/CommandStreamManager.hpp b/src/vkcv/CommandStreamManager.hpp index 898f170c08494b941f58632443261afee6134f75..b2321cbcfdc63b98177662b424b8b3ce1af00c2e 100644 --- a/src/vkcv/CommandStreamManager.hpp +++ b/src/vkcv/CommandStreamManager.hpp @@ -1,8 +1,8 @@ #pragma once -#include <vector> #include <vulkan/vulkan.hpp> +#include "vkcv/Container.hpp" #include "vkcv/Event.hpp" #include "vkcv/EventFunctionTypes.hpp" @@ -19,7 +19,7 @@ namespace vkcv { vk::CommandBuffer cmdBuffer; vk::CommandPool cmdPool; vk::Queue queue; - std::vector<FinishCommandFunction> callbacks; + Vector<FinishCommandFunction> callbacks; }; /** @@ -79,8 +79,8 @@ namespace vkcv { * commands is finished */ void submitCommandStreamSynchronous(const CommandStreamHandle &handle, - std::vector<vk::Semaphore> &waitSemaphores, - std::vector<vk::Semaphore> &signalSemaphores); + Vector<vk::Semaphore> &waitSemaphores, + Vector<vk::Semaphore> &signalSemaphores); /** * @brief Returns the underlying vulkan handle of a #CommandStream to be used for manual diff --git a/src/vkcv/ComputePipelineManager.cpp b/src/vkcv/ComputePipelineManager.cpp index 453dddd1baf93337280fe381b7f77e88bd2e3517..12d3e673738cc9d22ae84cc894aac40467a46258 100644 --- a/src/vkcv/ComputePipelineManager.cpp +++ b/src/vkcv/ComputePipelineManager.cpp @@ -33,7 +33,7 @@ namespace vkcv { vk::Result ComputePipelineManager::createShaderModule(vk::ShaderModule &module, const ShaderProgram &shaderProgram, const ShaderStage stage) { - std::vector<uint32_t> code = shaderProgram.getShaderBinary(stage); + Vector<uint32_t> code = shaderProgram.getShaderBinary(stage); vk::ShaderModuleCreateInfo moduleInfo({}, code.size() * sizeof(uint32_t), code.data()); return getCore().getContext().getDevice().createShaderModule(&moduleInfo, nullptr, &module); } @@ -55,7 +55,7 @@ namespace vkcv { ComputePipelineHandle ComputePipelineManager::createComputePipeline( const ShaderProgram &shaderProgram, - const std::vector<vk::DescriptorSetLayout> &descriptorSetLayouts) { + const Vector<vk::DescriptorSetLayout> &descriptorSetLayouts) { // Temporally handing over the Shader Program instead of a pipeline config vk::ShaderModule computeModule {}; if (createShaderModule(computeModule, shaderProgram, ShaderStage::COMPUTE) diff --git a/src/vkcv/ComputePipelineManager.hpp b/src/vkcv/ComputePipelineManager.hpp index 32fdc57943bff8d6b8194b9167a067de9a61f8b8..c6833eac5f55ea1ef3002c7d85de2076d8811b7d 100644 --- a/src/vkcv/ComputePipelineManager.hpp +++ b/src/vkcv/ComputePipelineManager.hpp @@ -6,12 +6,12 @@ * @brief Creation and handling of Compute Pipelines */ -#include <vector> #include <vulkan/vulkan.hpp> #include "HandleManager.hpp" #include "vkcv/ComputePipelineConfig.hpp" +#include "vkcv/Container.hpp" #include "vkcv/ShaderProgram.hpp" namespace vkcv { @@ -74,7 +74,7 @@ namespace vkcv { */ ComputePipelineHandle createComputePipeline(const ShaderProgram &shaderProgram, - const std::vector<vk::DescriptorSetLayout> &descriptorSetLayouts); + const Vector<vk::DescriptorSetLayout> &descriptorSetLayouts); }; } // namespace vkcv diff --git a/src/vkcv/Context.cpp b/src/vkcv/Context.cpp index 9a3ef1ffe3df2e094fab4dc4e2d2bee9036b439f..56229cd92cab3e4788970dfd81f1f70ccf5e70e4 100644 --- a/src/vkcv/Context.cpp +++ b/src/vkcv/Context.cpp @@ -95,7 +95,7 @@ namespace vkcv { */ static bool pickPhysicalDevice(const vk::Instance &instance, vk::PhysicalDevice &physicalDevice) { - const std::vector<vk::PhysicalDevice> &devices = instance.enumeratePhysicalDevices(); + const Vector<vk::PhysicalDevice> &devices = instance.enumeratePhysicalDevices(); if (devices.empty()) { vkcv_log(LogLevel::ERROR, "Failed to find GPUs with Vulkan support"); @@ -147,8 +147,8 @@ namespace vkcv { * @param check The const vector const char* reference elements to be checked by "supported" * @return True, if all elements in "check" are supported (contained in supported) */ - bool checkSupport(const std::vector<const char*> &supported, - const std::vector<const char*> &check) { + bool checkSupport(const Vector<const char*> &supported, + const Vector<const char*> &check) { for (auto checkElem : check) { bool found = false; for (auto supportedElem : supported) { @@ -163,8 +163,8 @@ namespace vkcv { return true; } - std::vector<std::string> getRequiredExtensions() { - std::vector<std::string> extensions = Window::getExtensions(); + Vector<std::string> getRequiredExtensions() { + Vector<std::string> extensions = Window::getExtensions(); #ifdef VULKAN_DEBUG_LABELS extensions.emplace_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME); @@ -196,21 +196,21 @@ namespace vkcv { */ static void queueCreateInfosQueueHandles(vk::PhysicalDevice &physicalDevice, - const std::vector<float> &queuePriorities, - const std::vector<vk::QueueFlagBits> &queueFlags, - std::vector<vk::DeviceQueueCreateInfo> &queueCreateInfos, - std::vector<std::pair<int, int>> &queuePairsGraphics, - std::vector<std::pair<int, int>> &queuePairsCompute, - std::vector<std::pair<int, int>> &queuePairsTransfer) { + const Vector<float> &queuePriorities, + const Vector<vk::QueueFlagBits> &queueFlags, + Vector<vk::DeviceQueueCreateInfo> &queueCreateInfos, + Vector<std::pair<int, int>> &queuePairsGraphics, + Vector<std::pair<int, int>> &queuePairsCompute, + Vector<std::pair<int, int>> &queuePairsTransfer) { queueCreateInfos = {}; queuePairsGraphics = {}; queuePairsCompute = {}; queuePairsTransfer = {}; - std::vector<vk::QueueFamilyProperties> qFamilyProperties = + Vector<vk::QueueFamilyProperties> qFamilyProperties = physicalDevice.getQueueFamilyProperties(); // check priorities of flags -> the lower prioCount the higher the priority - std::vector<int> prios; + Vector<int> prios; for (auto flag : queueFlags) { int prioCount = 0; for (size_t i = 0; i < qFamilyProperties.size(); i++) { @@ -220,7 +220,7 @@ namespace vkcv { prios.push_back(prioCount); } // resort flags with heighest priority before allocating the queues - std::vector<vk::QueueFlagBits> newFlags; + Vector<vk::QueueFlagBits> newFlags; for (size_t i = 0; i < prios.size(); i++) { auto minElem = std::min_element(prios.begin(), prios.end()); int index = minElem - prios.begin(); @@ -232,7 +232,7 @@ namespace vkcv { // herefore: create vector that updates available queues in each queue family // structure: [qFamily_0, ..., qFamily_n] where // - qFamily_i = [GraphicsCount, ComputeCount, TransferCount], 0 <= i <= n - std::vector<std::vector<int>> queueFamilyStatus, initialQueueFamilyStatus; + Vector<Vector<int>> queueFamilyStatus, initialQueueFamilyStatus; for (auto qFamily : qFamilyProperties) { auto graphicsCount = @@ -349,15 +349,15 @@ namespace vkcv { } Context Context::create(const std::string &applicationName, uint32_t applicationVersion, - const std::vector<vk::QueueFlagBits> &queueFlags, + const Vector<vk::QueueFlagBits> &queueFlags, const Features &features, - const std::vector<const char*> &instanceExtensions) { + const Vector<const char*> &instanceExtensions) { // check for layer support - const std::vector<vk::LayerProperties> &layerProperties = + const Vector<vk::LayerProperties> &layerProperties = vk::enumerateInstanceLayerProperties(); - std::vector<const char*> supportedLayers; + Vector<const char*> supportedLayers; supportedLayers.reserve(layerProperties.size()); for (auto &elem : layerProperties) { @@ -366,7 +366,7 @@ namespace vkcv { // if in debug mode, check if validation layers are supported. Enable them if supported #ifdef VULKAN_VALIDATION_LAYERS - std::vector<const char*> validationLayers = { "VK_LAYER_KHRONOS_validation" }; + Vector<const char*> validationLayers = { "VK_LAYER_KHRONOS_validation" }; if (!checkSupport(supportedLayers, validationLayers)) { vkcv_log_throw_error("Validation layers requested but not available!"); @@ -374,10 +374,10 @@ namespace vkcv { #endif // check for instance extension support - std::vector<vk::ExtensionProperties> instanceExtensionProperties = + Vector<vk::ExtensionProperties> instanceExtensionProperties = vk::enumerateInstanceExtensionProperties(); - std::vector<const char*> supportedExtensions; + Vector<const char*> supportedExtensions; supportedExtensions.reserve(instanceExtensionProperties.size()); for (auto &elem : instanceExtensionProperties) { @@ -386,7 +386,7 @@ namespace vkcv { // for GLFW: get all required extensions auto requiredStrings = getRequiredExtensions(); - std::vector<const char*> requiredExtensions; + Vector<const char*> requiredExtensions; for (const auto &extension : requiredStrings) { requiredExtensions.push_back(extension.c_str()); @@ -414,7 +414,7 @@ namespace vkcv { vk::Instance instance = vk::createInstance(instanceCreateInfo); - std::vector<vk::PhysicalDevice> physicalDevices = instance.enumeratePhysicalDevices(); + Vector<vk::PhysicalDevice> physicalDevices = instance.enumeratePhysicalDevices(); vk::PhysicalDevice physicalDevice; if (!pickPhysicalDevice(instance, physicalDevice)) { @@ -433,10 +433,10 @@ namespace vkcv { const auto &extensions = featureManager.getActiveExtensions(); - std::vector<vk::DeviceQueueCreateInfo> qCreateInfos; - std::vector<float> qPriorities; + Vector<vk::DeviceQueueCreateInfo> qCreateInfos; + Vector<float> qPriorities; qPriorities.resize(queueFlags.size(), 1.f); - std::vector<std::pair<int, int>> queuePairsGraphics, queuePairsCompute, queuePairsTransfer; + Vector<std::pair<int, int>> queuePairsGraphics, queuePairsCompute, queuePairsTransfer; queueCreateInfosQueueHandles(physicalDevice, qPriorities, queueFlags, qCreateInfos, queuePairsGraphics, queuePairsCompute, queuePairsTransfer); diff --git a/src/vkcv/Core.cpp b/src/vkcv/Core.cpp index d31a9ff3c47cc8717f89861b27f2c0dc3af37f42..9f1274b2532fbea3da59466bf42360d83c9a0ec0 100644 --- a/src/vkcv/Core.cpp +++ b/src/vkcv/Core.cpp @@ -19,7 +19,9 @@ #include "RayTracingPipelineManager.hpp" #include "SamplerManager.hpp" #include "WindowManager.hpp" + #include "vkcv/BlitDownsampler.hpp" +#include "vkcv/Container.hpp" #include "vkcv/Core.hpp" #include "vkcv/Image.hpp" #include "vkcv/Logger.hpp" @@ -33,8 +35,8 @@ namespace vkcv { * @param[in] queueManager Queue manager * @return Set of queue family indices */ - static std::unordered_set<int> generateQueueFamilyIndexSet(const QueueManager &queueManager) { - std::unordered_set<int> indexSet; + static Set<int> generateQueueFamilyIndexSet(const QueueManager &queueManager) { + Set<int> indexSet; for (const auto &queue : queueManager.getGraphicsQueues()) { indexSet.insert(queue.familyIndex); @@ -60,9 +62,9 @@ namespace vkcv { * @param[in] familyIndexSet Set of queue family indices * @return New command pools */ - static std::vector<vk::CommandPool> - createCommandPools(const vk::Device &device, const std::unordered_set<int> &familyIndexSet) { - std::vector<vk::CommandPool> commandPoolsPerQueueFamily; + static Vector<vk::CommandPool> + createCommandPools(const vk::Device &device, const Set<int> &familyIndexSet) { + Vector<vk::CommandPool> commandPoolsPerQueueFamily; commandPoolsPerQueueFamily.resize(familyIndexSet.size()); const vk::CommandPoolCreateFlags poolFlags = vk::CommandPoolCreateFlagBits::eTransient; @@ -76,8 +78,8 @@ namespace vkcv { } Core Core::create(const std::string &applicationName, uint32_t applicationVersion, - const std::vector<vk::QueueFlagBits> &queueFlags, const Features &features, - const std::vector<const char*> &instanceExtensions) { + const Vector<vk::QueueFlagBits> &queueFlags, const Features &features, + const Vector<const char*> &instanceExtensions) { Context context = Context::create(applicationName, applicationVersion, queueFlags, features, instanceExtensions); @@ -141,7 +143,7 @@ namespace vkcv { } ComputePipelineHandle Core::createComputePipeline(const ComputePipelineConfig &config) { - std::vector<vk::DescriptorSetLayout> layouts; + Vector<vk::DescriptorSetLayout> layouts; layouts.resize(config.getDescriptorSetLayouts().size()); for (size_t i = 0; i < layouts.size(); i++) { @@ -283,7 +285,7 @@ namespace vkcv { } static std::array<uint32_t, 2> - getWidthHeightFromRenderTargets(const std::vector<ImageHandle> &renderTargets, + getWidthHeightFromRenderTargets(const Vector<ImageHandle> &renderTargets, const vk::Extent2D &swapchainExtent, const ImageManager &imageManager) { @@ -306,13 +308,13 @@ namespace vkcv { return widthHeight; } - static vk::Framebuffer createFramebuffer(const std::vector<ImageHandle> &renderTargets, + static vk::Framebuffer createFramebuffer(const Vector<ImageHandle> &renderTargets, const ImageManager &imageManager, const vk::Extent2D &renderExtent, const vk::RenderPass &renderpass, const vk::Device &device) { - std::vector<vk::ImageView> attachmentsViews; + Vector<vk::ImageView> attachmentsViews; for (const ImageHandle &handle : renderTargets) { attachmentsViews.push_back(imageManager.getVulkanImageView(handle)); } @@ -324,7 +326,7 @@ namespace vkcv { return device.createFramebuffer(createInfo); } - void transitionRendertargetsToAttachmentLayout(const std::vector<ImageHandle> &renderTargets, + void transitionRendertargetsToAttachmentLayout(const Vector<ImageHandle> &renderTargets, ImageManager &imageManager, const vk::CommandBuffer cmdBuffer) { @@ -337,9 +339,9 @@ namespace vkcv { } } - std::vector<vk::ClearValue> - createAttachmentClearValues(const std::vector<AttachmentDescription> &attachments) { - std::vector<vk::ClearValue> clearValues; + Vector<vk::ClearValue> + createAttachmentClearValues(const Vector<AttachmentDescription> &attachments) { + Vector<vk::ClearValue> clearValues; for (const auto &attachment : attachments) { if (attachment.getLoadOperation() == AttachmentOperation::CLEAR) { clearValues.push_back(attachment.getClearValue()); @@ -421,7 +423,7 @@ namespace vkcv { const CommandStreamHandle &cmdStreamHandle, const GraphicsPipelineHandle &pipelineHandle, const PushConstants &pushConstants, - const std::vector<ImageHandle> &renderTargets, + const Vector<ImageHandle> &renderTargets, const WindowHandle &windowHandle, const RecordCommandFunction &record) { @@ -467,7 +469,7 @@ namespace vkcv { } auto submitFunction = [&](const vk::CommandBuffer &cmdBuffer) { - const std::vector<vk::ClearValue> clearValues = + const Vector<vk::ClearValue> clearValues = createAttachmentClearValues(attachments); const vk::RenderPassBeginInfo beginInfo(renderPass, framebuffer, renderArea, @@ -500,8 +502,8 @@ namespace vkcv { void Core::recordDrawcallsToCmdStream(const CommandStreamHandle &cmdStreamHandle, const GraphicsPipelineHandle &pipelineHandle, const PushConstants &pushConstantData, - const std::vector<InstanceDrawcall> &drawcalls, - const std::vector<ImageHandle> &renderTargets, + const Vector<InstanceDrawcall> &drawcalls, + const Vector<ImageHandle> &renderTargets, const WindowHandle &windowHandle) { if (m_currentSwapchainImageIndex == std::numeric_limits<uint32_t>::max()) { @@ -569,8 +571,8 @@ namespace vkcv { void Core::recordIndirectDrawcallsToCmdStream( const vkcv::CommandStreamHandle cmdStreamHandle, const vkcv::GraphicsPipelineHandle &pipelineHandle, - const vkcv::PushConstants &pushConstantData, const std::vector<IndirectDrawcall> &drawcalls, - const std::vector<ImageHandle> &renderTargets, const vkcv::WindowHandle &windowHandle) { + const vkcv::PushConstants &pushConstantData, const Vector<IndirectDrawcall> &drawcalls, + const Vector<ImageHandle> &renderTargets, const vkcv::WindowHandle &windowHandle) { if (m_currentSwapchainImageIndex == std::numeric_limits<uint32_t>::max()) { return; @@ -632,8 +634,8 @@ namespace vkcv { void Core::recordMeshShaderDrawcalls(const CommandStreamHandle &cmdStreamHandle, const GraphicsPipelineHandle &pipelineHandle, const PushConstants &pushConstantData, - const std::vector<TaskDrawcall> &drawcalls, - const std::vector<ImageHandle> &renderTargets, + const Vector<TaskDrawcall> &drawcalls, + const Vector<ImageHandle> &renderTargets, const WindowHandle &windowHandle) { if (m_currentSwapchainImageIndex == std::numeric_limits<uint32_t>::max()) { @@ -659,7 +661,7 @@ namespace vkcv { const CommandStreamHandle &cmdStreamHandle, const RayTracingPipelineHandle &rayTracingPipeline, const DispatchSize &dispatchSize, - const std::vector<DescriptorSetUsage> &descriptorSetUsages, + const Vector<DescriptorSetUsage> &descriptorSetUsages, const PushConstants &pushConstants, const vkcv::WindowHandle &windowHandle) { @@ -731,7 +733,7 @@ namespace vkcv { const CommandStreamHandle &cmdStreamHandle, const ComputePipelineHandle &computePipeline, const DispatchSize &dispatchSize, - const std::vector<DescriptorSetUsage> &descriptorSetUsages, + const Vector<DescriptorSetUsage> &descriptorSetUsages, const PushConstants &pushConstants) { auto submitFunction = [&](const vk::CommandBuffer &cmdBuffer) { const auto pipelineLayout = @@ -800,7 +802,7 @@ namespace vkcv { void Core::recordComputeIndirectDispatchToCmdStream( const CommandStreamHandle cmdStream, const ComputePipelineHandle computePipeline, const vkcv::BufferHandle buffer, const size_t bufferArgOffset, - const std::vector<DescriptorSetUsage> &descriptorSetUsages, + const Vector<DescriptorSetUsage> &descriptorSetUsages, const PushConstants &pushConstants) { auto submitFunction = [&](const vk::CommandBuffer &cmdBuffer) { @@ -906,10 +908,10 @@ namespace vkcv { } void Core::submitCommandStream(const CommandStreamHandle &stream, bool signalRendering) { - std::vector<vk::Semaphore> waitSemaphores; + Vector<vk::Semaphore> waitSemaphores; // FIXME: add proper user controllable sync - std::vector<vk::Semaphore> signalSemaphores; + Vector<vk::Semaphore> signalSemaphores; if (signalRendering) { signalSemaphores.push_back(m_RenderFinished); } @@ -1367,7 +1369,7 @@ namespace vkcv { } AccelerationStructureHandle Core::createAccelerationStructure( - const std::vector<GeometryData> &geometryData, + const Vector<GeometryData> &geometryData, const BufferHandle &transformBuffer, bool compaction) { return m_AccelerationStructureManager->createAccelerationStructure( @@ -1378,7 +1380,7 @@ namespace vkcv { } AccelerationStructureHandle Core::createAccelerationStructure( - const std::vector<AccelerationStructureHandle> &handles) { + const Vector<AccelerationStructureHandle> &handles) { return m_AccelerationStructureManager->createAccelerationStructure(handles); } diff --git a/src/vkcv/DescriptorSetLayoutManager.cpp b/src/vkcv/DescriptorSetLayoutManager.cpp index 14fe4d519f0587d6ef3febf256de83f9f5428f42..6bbdb099ffbfe63bfaa6cead742d815202720b88 100644 --- a/src/vkcv/DescriptorSetLayoutManager.cpp +++ b/src/vkcv/DescriptorSetLayoutManager.cpp @@ -58,8 +58,8 @@ namespace vkcv { } // create the descriptor set's layout and binding flags by iterating over its bindings - std::vector<vk::DescriptorSetLayoutBinding> bindingsVector = {}; - std::vector<vk::DescriptorBindingFlags> bindingsFlags = {}; + Vector<vk::DescriptorSetLayoutBinding> bindingsVector = {}; + Vector<vk::DescriptorBindingFlags> bindingsFlags = {}; for (auto bindingElem : bindings) { DescriptorBinding binding = bindingElem.second; diff --git a/src/vkcv/DescriptorSetManager.cpp b/src/vkcv/DescriptorSetManager.cpp index 605e5d3c05e032770a2d38ad569b42564c6f20ba..5304031fc3639967fc628821b812d3188ed81a6d 100644 --- a/src/vkcv/DescriptorSetManager.cpp +++ b/src/vkcv/DescriptorSetManager.cpp @@ -144,22 +144,22 @@ namespace vkcv { const SamplerManager &samplerManager) { auto &set = (*this) [handle]; - std::vector<vk::DescriptorImageInfo> imageInfos; - std::vector<vk::DescriptorBufferInfo> bufferInfos; + Vector<vk::DescriptorImageInfo> imageInfos; + Vector<vk::DescriptorBufferInfo> bufferInfos; bufferInfos.reserve( writes.getUniformBufferWrites().size() + writes.getStorageBufferWrites().size() ); - std::vector<vk::AccelerationStructureKHR> accelerationStructures; - std::vector<size_t> accelerationStructureOffsets; + Vector<vk::AccelerationStructureKHR> accelerationStructures; + Vector<size_t> accelerationStructureOffsets; accelerationStructureOffsets.reserve(writes.getAccelerationWrites().size()); - std::vector<vk::WriteDescriptorSetAccelerationStructureKHR> writeStructures; + Vector<vk::WriteDescriptorSetAccelerationStructureKHR> writeStructures; - std::vector<WriteDescriptorSetInfo> writeInfos; + Vector<WriteDescriptorSetInfo> writeInfos; writeInfos.reserve( writes.getSampledImageWrites().size() + writes.getStorageImageWrites().size() + @@ -311,7 +311,7 @@ namespace vkcv { writeInfos.push_back(vulkanWrite); } - std::vector<vk::WriteDescriptorSet> vulkanWrites; + Vector<vk::WriteDescriptorSet> vulkanWrites; vulkanWrites.reserve(writeInfos.size()); for (const auto &write : writeInfos) { diff --git a/src/vkcv/DescriptorSetManager.hpp b/src/vkcv/DescriptorSetManager.hpp index 06ea6dd78313627bb2fc77ea6b8e5f3f992db7cb..5dbdc954fcdfa7c927b50618f7c8bfcd64b02c9c 100644 --- a/src/vkcv/DescriptorSetManager.hpp +++ b/src/vkcv/DescriptorSetManager.hpp @@ -35,8 +35,8 @@ namespace vkcv { private: DescriptorSetLayoutManager* m_DescriptorSetLayoutManager; - std::vector<vk::DescriptorPool> m_Pools; - std::vector<vk::DescriptorPoolSize> m_PoolSizes; + Vector<vk::DescriptorPool> m_Pools; + Vector<vk::DescriptorPoolSize> m_PoolSizes; vk::DescriptorPoolCreateInfo m_PoolInfo; bool init(Core &core, DescriptorSetLayoutManager &descriptorSetLayoutManager); diff --git a/src/vkcv/DescriptorSetUsage.cpp b/src/vkcv/DescriptorSetUsage.cpp index cfa2ba1998e124cec0f1fc851356d28009288e1b..dcd283e9cf4a9672f5f393c18d4047647458d8b7 100644 --- a/src/vkcv/DescriptorSetUsage.cpp +++ b/src/vkcv/DescriptorSetUsage.cpp @@ -4,7 +4,7 @@ namespace vkcv { DescriptorSetUsage useDescriptorSet(uint32_t location, const DescriptorSetHandle &descriptorSet, - const std::vector<uint32_t> &dynamicOffsets) { + const Vector<uint32_t> &dynamicOffsets) { DescriptorSetUsage usage; usage.location = location; usage.descriptorSet = descriptorSet; diff --git a/src/vkcv/DescriptorWrites.cpp b/src/vkcv/DescriptorWrites.cpp index b4be5958e977e9c61e4d2169ff98748ba0892682..2e9d567c652554c88e0c8baf3752f4c191f4b7c5 100644 --- a/src/vkcv/DescriptorWrites.cpp +++ b/src/vkcv/DescriptorWrites.cpp @@ -77,7 +77,7 @@ namespace vkcv { } DescriptorWrites &DescriptorWrites::writeAcceleration( - uint32_t binding, const std::vector<AccelerationStructureHandle> &structures) { + uint32_t binding, const Vector<AccelerationStructureHandle> &structures) { AccelerationDescriptorWrite write; write.binding = binding; write.structures = structures; @@ -85,29 +85,29 @@ namespace vkcv { return *this; } - const std::vector<SampledImageDescriptorWrite> & + const Vector<SampledImageDescriptorWrite> & DescriptorWrites::getSampledImageWrites() const { return m_sampledImageWrites; } - const std::vector<StorageImageDescriptorWrite> & + const Vector<StorageImageDescriptorWrite> & DescriptorWrites::getStorageImageWrites() const { return m_storageImageWrites; } - const std::vector<BufferDescriptorWrite> &DescriptorWrites::getUniformBufferWrites() const { + const Vector<BufferDescriptorWrite> &DescriptorWrites::getUniformBufferWrites() const { return m_uniformBufferWrites; } - const std::vector<BufferDescriptorWrite> &DescriptorWrites::getStorageBufferWrites() const { + const Vector<BufferDescriptorWrite> &DescriptorWrites::getStorageBufferWrites() const { return m_storageBufferWrites; } - const std::vector<SamplerDescriptorWrite> &DescriptorWrites::getSamplerWrites() const { + const Vector<SamplerDescriptorWrite> &DescriptorWrites::getSamplerWrites() const { return m_samplerWrites; } - const std::vector<AccelerationDescriptorWrite> & + const Vector<AccelerationDescriptorWrite> & DescriptorWrites::getAccelerationWrites() const { return m_accelerationWrites; } diff --git a/src/vkcv/Drawcall.cpp b/src/vkcv/Drawcall.cpp index 73142b5545a7485e62e8e26e36e9d1f494960aa4..cc93d74f315cbe59a6222ec9ab240a7ab9fb5bc0 100644 --- a/src/vkcv/Drawcall.cpp +++ b/src/vkcv/Drawcall.cpp @@ -7,12 +7,12 @@ namespace vkcv { - const std::vector<DescriptorSetUsage> &Drawcall::getDescriptorSetUsages() const { + const Vector<DescriptorSetUsage> &Drawcall::getDescriptorSetUsages() const { return m_usages; } void Drawcall::useDescriptorSet(uint32_t location, const DescriptorSetHandle &descriptorSet, - const std::vector<uint32_t> &dynamicOffsets) { + const Vector<uint32_t> &dynamicOffsets) { DescriptorSetUsage usage; usage.location = location; usage.descriptorSet = descriptorSet; diff --git a/src/vkcv/FeatureManager.cpp b/src/vkcv/FeatureManager.cpp index 51e86f6c8552441278f2a57a412e5cd25ef5757d..10980c278fd8e6d64f1302a22a44190df3fb29b8 100644 --- a/src/vkcv/FeatureManager.cpp +++ b/src/vkcv/FeatureManager.cpp @@ -648,7 +648,7 @@ namespace vkcv { return false; } - const std::vector<const char*> &FeatureManager::getActiveExtensions() const { + const Vector<const char*> &FeatureManager::getActiveExtensions() const { return m_activeExtensions; } diff --git a/src/vkcv/Features.cpp b/src/vkcv/Features.cpp index fcfdd7b9435b7f9ab9ad230fa8d77a9a0d66b80e..33ed9bb63f3dd88e0c06c22d5a92b7f24f9cf7a2 100644 --- a/src/vkcv/Features.cpp +++ b/src/vkcv/Features.cpp @@ -59,7 +59,7 @@ namespace vkcv { }); } - const std::vector<Feature> &Features::getList() const { + const Vector<Feature> &Features::getList() const { return m_features; } diff --git a/src/vkcv/File.cpp b/src/vkcv/File.cpp index 32ded3e5dba876ed0c973f80ac3eb4203d0d68b2..702ae899b77a963719e7921ba2625704c205ba81 100644 --- a/src/vkcv/File.cpp +++ b/src/vkcv/File.cpp @@ -58,7 +58,7 @@ namespace vkcv { } bool writeContentToFile(const std::filesystem::path &path, - const std::vector<char>& content) { + const Vector<char>& content) { std::ofstream file (path.string(), std::ios::out); if (!file.is_open()) { @@ -74,7 +74,7 @@ namespace vkcv { } bool writeBinaryToFile(const std::filesystem::path &path, - const std::vector<uint32_t>& binary) { + const Vector<uint32_t>& binary) { std::ofstream file (path.string(), std::ios::out); if (!file.is_open()) { @@ -109,7 +109,7 @@ namespace vkcv { } bool readContentFromFile(const std::filesystem::path &path, - std::vector<char>& content) { + Vector<char>& content) { std::ifstream file (path.string(), std::ios::ate); if (!file.is_open()) { @@ -128,7 +128,7 @@ namespace vkcv { } bool readBinaryFromFile(const std::filesystem::path &path, - std::vector<uint32_t>& binary) { + Vector<uint32_t>& binary) { std::ifstream file (path.string(), std::ios::ate); if (!file.is_open()) { @@ -165,7 +165,7 @@ namespace vkcv { } const std::streamsize fileSize = file.tellg(); - std::vector<char> buffer (fileSize); + Vector<char> buffer (fileSize); buffer.resize(fileSize); file.seekg(0); diff --git a/src/vkcv/GraphicsPipelineConfig.cpp b/src/vkcv/GraphicsPipelineConfig.cpp index 383c0de18dd401711665227250bce98a8bdf3b39..7a669bbf9b96cddda2a7ede3f7cdfb55717a9f85 100644 --- a/src/vkcv/GraphicsPipelineConfig.cpp +++ b/src/vkcv/GraphicsPipelineConfig.cpp @@ -12,7 +12,7 @@ namespace vkcv { const ShaderProgram &program, const PassHandle &pass, const VertexLayout &vertexLayout, - const std::vector<DescriptorSetLayoutHandle> &layouts) : + const Vector<DescriptorSetLayoutHandle> &layouts) : PipelineConfig(program, layouts), m_PassHandle(pass), m_VertexLayout(vertexLayout), diff --git a/src/vkcv/GraphicsPipelineManager.cpp b/src/vkcv/GraphicsPipelineManager.cpp index 4f8a217dc36441ad001762f5360705b04313f8bf..be8e0bfb497c2621a6e193ea5c850f14b706d853 100644 --- a/src/vkcv/GraphicsPipelineManager.cpp +++ b/src/vkcv/GraphicsPipelineManager.cpp @@ -131,7 +131,7 @@ namespace vkcv { vk::PipelineShaderStageCreateInfo* outCreateInfo) { assert(outCreateInfo); - std::vector<uint32_t> code = shaderProgram.getShaderBinary(stage); + Vector<uint32_t> code = shaderProgram.getShaderBinary(stage); vk::ShaderModuleCreateInfo vertexModuleInfo( {}, code.size() * sizeof(uint32_t), @@ -162,8 +162,8 @@ namespace vkcv { * @param config */ static void fillVertexInputDescription( - std::vector<vk::VertexInputAttributeDescription> &vertexAttributeDescriptions, - std::vector<vk::VertexInputBindingDescription> &vertexBindingDescriptions, + Vector<vk::VertexInputAttributeDescription> &vertexAttributeDescriptions, + Vector<vk::VertexInputBindingDescription> &vertexBindingDescriptions, const bool existsVertexShader, const GraphicsPipelineConfig &config) { @@ -197,8 +197,8 @@ namespace vkcv { * @return Pipeline Vertex Input State Create Info Struct */ static vk::PipelineVertexInputStateCreateInfo createPipelineVertexInputStateCreateInfo( - std::vector<vk::VertexInputAttributeDescription> &vertexAttributeDescriptions, - std::vector<vk::VertexInputBindingDescription> &vertexBindingDescriptions) { + Vector<vk::VertexInputAttributeDescription> &vertexAttributeDescriptions, + Vector<vk::VertexInputBindingDescription> &vertexBindingDescriptions) { vk::PipelineVertexInputStateCreateInfo pipelineVertexInputStateCreateInfo( {}, vertexBindingDescriptions.size(), vertexBindingDescriptions.data(), @@ -346,7 +346,7 @@ namespace vkcv { static vk::PipelineColorBlendStateCreateInfo createPipelineColorBlendStateCreateInfo(const GraphicsPipelineConfig &config, const PassConfig &passConfig) { - static std::vector<vk::PipelineColorBlendAttachmentState> colorBlendAttachmentStates; + static Vector<vk::PipelineColorBlendAttachmentState> colorBlendAttachmentStates; colorBlendAttachmentStates.clear(); colorBlendAttachmentStates.reserve(passConfig.getAttachments().size()); @@ -397,7 +397,7 @@ namespace vkcv { */ static vk::PipelineLayoutCreateInfo createPipelineLayoutCreateInfo( const GraphicsPipelineConfig &config, - const std::vector<vk::DescriptorSetLayout> &descriptorSetLayouts) { + const Vector<vk::DescriptorSetLayout> &descriptorSetLayouts) { static vk::PushConstantRange pushConstantRange; const size_t pushConstantsSize = config.getShaderProgram().getPushConstantsSize(); @@ -450,7 +450,7 @@ namespace vkcv { */ static vk::PipelineDynamicStateCreateInfo createPipelineDynamicStateCreateInfo(const GraphicsPipelineConfig &config) { - static std::vector<vk::DynamicState> dynamicStates; + static Vector<vk::DynamicState> dynamicStates; dynamicStates.clear(); if (config.isViewportDynamic()) { @@ -497,7 +497,7 @@ namespace vkcv { return {}; } - std::vector<vk::PipelineShaderStageCreateInfo> shaderStages; + Vector<vk::PipelineShaderStageCreateInfo> shaderStages; auto destroyShaderModules = [&shaderStages, this] { for (auto stage : shaderStages) { getCore().getContext().getDevice().destroyShaderModule(stage.module); @@ -601,8 +601,8 @@ namespace vkcv { // vertex input state // Fill up VertexInputBindingDescription and VertexInputAttributeDescription Containers - std::vector<vk::VertexInputAttributeDescription> vertexAttributeDescriptions; - std::vector<vk::VertexInputBindingDescription> vertexBindingDescriptions; + Vector<vk::VertexInputAttributeDescription> vertexAttributeDescriptions; + Vector<vk::VertexInputBindingDescription> vertexBindingDescriptions; fillVertexInputDescription(vertexAttributeDescriptions, vertexBindingDescriptions, existsVertexShader, config); @@ -644,7 +644,7 @@ namespace vkcv { vk::PipelineDynamicStateCreateInfo dynamicStateCreateInfo = createPipelineDynamicStateCreateInfo(config); - std::vector<vk::DescriptorSetLayout> descriptorSetLayouts; + Vector<vk::DescriptorSetLayout> descriptorSetLayouts; descriptorSetLayouts.reserve(config.getDescriptorSetLayouts().size()); for (const auto &handle : config.getDescriptorSetLayouts()) { descriptorSetLayouts.push_back( diff --git a/src/vkcv/GraphicsPipelineManager.hpp b/src/vkcv/GraphicsPipelineManager.hpp index 867bd46f25fb8da91ff399bed173c6e3d2b9529f..d557465327024e955c177952ec8e00af03af0851 100644 --- a/src/vkcv/GraphicsPipelineManager.hpp +++ b/src/vkcv/GraphicsPipelineManager.hpp @@ -6,12 +6,14 @@ * @brief Creation and handling of graphic pipelines */ +#include <vulkan/vulkan.hpp> + #include "DescriptorSetLayoutManager.hpp" #include "HandleManager.hpp" #include "PassManager.hpp" + +#include "vkcv/Container.hpp" #include "vkcv/GraphicsPipelineConfig.hpp" -#include <vector> -#include <vulkan/vulkan.hpp> namespace vkcv { diff --git a/src/vkcv/HandleManager.hpp b/src/vkcv/HandleManager.hpp index a7b4b7aab30f4ce29d1f91c04336e733aba17b1b..0bca3076fba4bc7370acef63ef806117541beb17 100644 --- a/src/vkcv/HandleManager.hpp +++ b/src/vkcv/HandleManager.hpp @@ -1,8 +1,8 @@ #pragma once #include <optional> -#include <vector> +#include "vkcv/Container.hpp" #include "vkcv/Handles.hpp" #include "vkcv/Logger.hpp" @@ -16,7 +16,7 @@ namespace vkcv { private: Core* m_core; - std::vector<T> m_entries; + Vector<T> m_entries; protected: HandleManager() noexcept : m_core(nullptr), m_entries() {} diff --git a/src/vkcv/ImageManager.cpp b/src/vkcv/ImageManager.cpp index 5ecbd70f93e47c7e4a0a1a85dc0eef8e4cc00279..e46a267c3aeec950e721c680b4adb4ff0130da12 100644 --- a/src/vkcv/ImageManager.cpp +++ b/src/vkcv/ImageManager.cpp @@ -289,8 +289,8 @@ namespace vkcv { const vk::Device &device = getCore().getContext().getDevice(); - std::vector<vk::ImageView> views; - std::vector<vk::ImageView> arrayViews; + Vector<vk::ImageView> views; + Vector<vk::ImageView> arrayViews; for (uint32_t mip = 0; mip < mipCount; mip++) { const vk::ImageViewCreateInfo imageViewCreateInfo( @@ -340,7 +340,7 @@ namespace vkcv { arrayViews.push_back(device.createImageView(imageViewCreateInfo)); } - std::vector<vk::ImageLayout> layers; + Vector<vk::ImageLayout> layers; layers.resize(arrayLayers, vk::ImageLayout::eUndefined); return add({ @@ -707,8 +707,8 @@ namespace vkcv { m_currentSwapchainInputImage = index; } - void ImageManager::setSwapchainImages(const std::vector<vk::Image> &images, - const std::vector<vk::ImageView> &views, uint32_t width, + void ImageManager::setSwapchainImages(const Vector<vk::Image> &images, + const Vector<vk::ImageView> &views, uint32_t width, uint32_t height, vk::Format format) { // destroy old views diff --git a/src/vkcv/ImageManager.hpp b/src/vkcv/ImageManager.hpp index 7d9c278d7c85fbfb5f8206ad52f99913e5b58d7e..d334c59b2344771c72bf44f7eb7cda72c9f3c43c 100644 --- a/src/vkcv/ImageManager.hpp +++ b/src/vkcv/ImageManager.hpp @@ -4,12 +4,14 @@ * @file vkcv/ImageManager.hpp * @brief class creating and managing images */ -#include <vector> + #include <vk_mem_alloc.hpp> #include <vulkan/vulkan.hpp> #include "BufferManager.hpp" #include "HandleManager.hpp" + +#include "vkcv/Container.hpp" #include "vkcv/ImageConfig.hpp" namespace vkcv { @@ -27,15 +29,15 @@ namespace vkcv { vk::Image m_handle; vma::Allocation m_allocation; - std::vector<vk::ImageView> m_viewPerMip; - std::vector<vk::ImageView> m_arrayViewPerMip; + Vector<vk::ImageView> m_viewPerMip; + Vector<vk::ImageView> m_arrayViewPerMip; uint32_t m_width; uint32_t m_height; uint32_t m_depth; vk::Format m_format; - std::vector<vk::ImageLayout> m_layers; + Vector<vk::ImageLayout> m_layers; bool m_storage; }; @@ -49,7 +51,7 @@ namespace vkcv { private: BufferManager* m_bufferManager; - std::vector<ImageEntry> m_swapchainImages; + Vector<ImageEntry> m_swapchainImages; int m_currentSwapchainInputImage; bool init(Core &core, BufferManager &bufferManager); @@ -133,8 +135,8 @@ namespace vkcv { void setCurrentSwapchainImageIndex(int index); - void setSwapchainImages(const std::vector<vk::Image> &images, - const std::vector<vk::ImageView> &views, uint32_t width, + void setSwapchainImages(const Vector<vk::Image> &images, + const Vector<vk::ImageView> &views, uint32_t width, uint32_t height, vk::Format format); // if manual vulkan work, e.g. ImGui integration, changes an image layout this function must diff --git a/src/vkcv/Pass.cpp b/src/vkcv/Pass.cpp index 147d715110b6a20bf1035ddd4f05270916a03d3f..d88b26822aba9c523d93a358d9c8e100615d74b5 100644 --- a/src/vkcv/Pass.cpp +++ b/src/vkcv/Pass.cpp @@ -3,7 +3,7 @@ namespace vkcv { - PassHandle passFormats(Core &core, const std::vector<vk::Format> &formats, bool clear, + PassHandle passFormats(Core &core, const Vector<vk::Format> &formats, bool clear, Multisampling multisampling) { AttachmentDescriptions attachments; @@ -22,9 +22,9 @@ namespace vkcv { } PassHandle passSwapchain(Core &core, const SwapchainHandle &swapchain, - const std::vector<vk::Format> &formats, bool clear, + const Vector<vk::Format> &formats, bool clear, Multisampling multisampling) { - std::vector<vk::Format> swapchainFormats (formats); + Vector<vk::Format> swapchainFormats (formats); for (auto &format : swapchainFormats) { if (vk::Format::eUndefined == format) { diff --git a/src/vkcv/PassManager.cpp b/src/vkcv/PassManager.cpp index 9b160bcf8c62eb5e3fe829a49d2e43d3f0eef1cb..944df1b695c7c42310fa9f1d1ba21bc083cc828b 100644 --- a/src/vkcv/PassManager.cpp +++ b/src/vkcv/PassManager.cpp @@ -49,10 +49,10 @@ namespace vkcv { PassHandle PassManager::createPass(const PassConfig &config) { // description of all {color, input, depth/stencil} attachments of the render pass - std::vector<vk::AttachmentDescription> attachmentDescriptions {}; + Vector<vk::AttachmentDescription> attachmentDescriptions {}; // individual references to color attachments (of a subpass) - std::vector<vk::AttachmentReference> colorAttachmentReferences {}; + Vector<vk::AttachmentReference> colorAttachmentReferences {}; // individual reference to depth attachment (of a subpass) vk::AttachmentReference depthStencilAttachmentRef; @@ -70,7 +70,7 @@ namespace vkcv { const auto &attachments = config.getAttachments(); - std::vector<vk::ImageLayout> layouts; + Vector<vk::ImageLayout> layouts; layouts.reserve(attachments.size()); for (uint32_t i = 0; i < attachments.size(); i++) { @@ -137,7 +137,7 @@ namespace vkcv { return pass.m_Config; } - const std::vector<vk::ImageLayout> &PassManager::getLayouts(const PassHandle &handle) const { + const Vector<vk::ImageLayout> &PassManager::getLayouts(const PassHandle &handle) const { auto &pass = (*this) [handle]; return pass.m_Layouts; } diff --git a/src/vkcv/PassManager.hpp b/src/vkcv/PassManager.hpp index fefbffaedc2b98da88b7ce625dbfc6f3ae448b48..227d936ebfbf554c60d5547ac50635a3a790b09d 100644 --- a/src/vkcv/PassManager.hpp +++ b/src/vkcv/PassManager.hpp @@ -1,9 +1,10 @@ #pragma once -#include <vector> #include <vulkan/vulkan.hpp> #include "HandleManager.hpp" + +#include "vkcv/Container.hpp" #include "vkcv/PassConfig.hpp" namespace vkcv { @@ -11,7 +12,7 @@ namespace vkcv { struct PassEntry { vk::RenderPass m_Handle; PassConfig m_Config; - std::vector<vk::ImageLayout> m_Layouts; + Vector<vk::ImageLayout> m_Layouts; }; /** @@ -45,7 +46,7 @@ namespace vkcv { [[nodiscard]] const PassConfig &getPassConfig(const PassHandle &handle) const; - [[nodiscard]] const std::vector<vk::ImageLayout> & + [[nodiscard]] const Vector<vk::ImageLayout> & getLayouts(const PassHandle &handle) const; }; diff --git a/src/vkcv/PipelineConfig.cpp b/src/vkcv/PipelineConfig.cpp index e6fb1ceb9ead48369e8f944725a139bb3b7428a1..a7a8f612b1101f910436e8b988ea9097d1c0b72d 100644 --- a/src/vkcv/PipelineConfig.cpp +++ b/src/vkcv/PipelineConfig.cpp @@ -6,7 +6,7 @@ namespace vkcv { PipelineConfig::PipelineConfig() : m_ShaderProgram(), m_DescriptorSetLayouts() {} PipelineConfig::PipelineConfig(const ShaderProgram &program, - const std::vector<DescriptorSetLayoutHandle> &layouts) : + const Vector<DescriptorSetLayoutHandle> &layouts) : m_ShaderProgram(program), m_DescriptorSetLayouts(layouts) {} @@ -23,7 +23,7 @@ namespace vkcv { } void - PipelineConfig::addDescriptorSetLayouts(const std::vector<DescriptorSetLayoutHandle> &layouts) { + PipelineConfig::addDescriptorSetLayouts(const Vector<DescriptorSetLayoutHandle> &layouts) { m_DescriptorSetLayouts.reserve(m_DescriptorSetLayouts.size() + layouts.size()); for (const auto &layout : layouts) { @@ -31,7 +31,7 @@ namespace vkcv { } } - const std::vector<DescriptorSetLayoutHandle> &PipelineConfig::getDescriptorSetLayouts() const { + const Vector<DescriptorSetLayoutHandle> &PipelineConfig::getDescriptorSetLayouts() const { return m_DescriptorSetLayouts; } diff --git a/src/vkcv/QueueManager.cpp b/src/vkcv/QueueManager.cpp index d292383ab58ff1e34343382828e7a5f43b6b6a33..711087eb95975dfe3e6cd97af4471d162d0701d0 100644 --- a/src/vkcv/QueueManager.cpp +++ b/src/vkcv/QueueManager.cpp @@ -15,9 +15,9 @@ namespace vkcv { * vk::QueueFlagBits::eGraphics) * @return An array of queue handles based on the @p queuePairs */ - std::vector<Queue> getQueues(const vk::Device &device, - const std::vector<std::pair<int, int>> &queuePairs) { - std::vector<Queue> queues; + Vector<Queue> getQueues(const vk::Device &device, + const Vector<std::pair<int, int>> &queuePairs) { + Vector<Queue> queues; for (auto q : queuePairs) { const int queueFamilyIndex = q.first; // the queueIndex of the queue family @@ -31,13 +31,13 @@ namespace vkcv { } QueueManager QueueManager::create(vk::Device device, - const std::vector<std::pair<int, int>> &queuePairsGraphics, - const std::vector<std::pair<int, int>> &queuePairsCompute, - const std::vector<std::pair<int, int>> &queuePairsTransfer) { + const Vector<std::pair<int, int>> &queuePairsGraphics, + const Vector<std::pair<int, int>> &queuePairsCompute, + const Vector<std::pair<int, int>> &queuePairsTransfer) { - std::vector<Queue> graphicsQueues = getQueues(device, queuePairsGraphics); - std::vector<Queue> computeQueues = getQueues(device, queuePairsCompute); - std::vector<Queue> transferQueues = getQueues(device, queuePairsTransfer); + Vector<Queue> graphicsQueues = getQueues(device, queuePairsGraphics); + Vector<Queue> computeQueues = getQueues(device, queuePairsCompute); + Vector<Queue> transferQueues = getQueues(device, queuePairsTransfer); return QueueManager(std::move(graphicsQueues), std::move(computeQueues), std::move(transferQueues), 0); @@ -45,7 +45,7 @@ namespace vkcv { uint32_t QueueManager::checkSurfaceSupport(const vk::PhysicalDevice &physicalDevice, const vk::SurfaceKHR &surface) { - std::vector<vk::QueueFamilyProperties> qFamilyProperties = + Vector<vk::QueueFamilyProperties> qFamilyProperties = physicalDevice.getQueueFamilyProperties(); for (uint32_t i = 0; i < qFamilyProperties.size(); i++) { @@ -62,9 +62,9 @@ namespace vkcv { return 0; } - QueueManager::QueueManager(std::vector<Queue> &&graphicsQueues, - std::vector<Queue> &&computeQueues, - std::vector<Queue> &&transferQueues, size_t presentIndex) : + QueueManager::QueueManager(Vector<Queue> &&graphicsQueues, + Vector<Queue> &&computeQueues, + Vector<Queue> &&transferQueues, size_t presentIndex) : m_graphicsQueues(graphicsQueues), m_computeQueues(computeQueues), m_transferQueues(transferQueues), m_presentIndex(presentIndex) {} @@ -73,15 +73,15 @@ namespace vkcv { return m_graphicsQueues [m_presentIndex]; } - const std::vector<Queue> &QueueManager::getGraphicsQueues() const { + const Vector<Queue> &QueueManager::getGraphicsQueues() const { return m_graphicsQueues; } - const std::vector<Queue> &QueueManager::getComputeQueues() const { + const Vector<Queue> &QueueManager::getComputeQueues() const { return m_computeQueues; } - const std::vector<Queue> &QueueManager::getTransferQueues() const { + const Vector<Queue> &QueueManager::getTransferQueues() const { return m_transferQueues; } diff --git a/src/vkcv/RayTracingPipelineConfig.cpp b/src/vkcv/RayTracingPipelineConfig.cpp index cec0bdec42c90d06b661def1150b8cb02b04d8de..776340eac9125b8591dffe0ebd192fe1f001a375 100644 --- a/src/vkcv/RayTracingPipelineConfig.cpp +++ b/src/vkcv/RayTracingPipelineConfig.cpp @@ -8,7 +8,7 @@ namespace vkcv { RayTracingPipelineConfig::RayTracingPipelineConfig( const ShaderProgram &program, - const std::vector<DescriptorSetLayoutHandle> &layouts) : + const Vector<DescriptorSetLayoutHandle> &layouts) : PipelineConfig(program, layouts) {} } diff --git a/src/vkcv/RayTracingPipelineManager.cpp b/src/vkcv/RayTracingPipelineManager.cpp index 147c216db6b5f0b4cf48be19ac68cdbc9fe4a5f5..aae73acf3ef0012bf72ea027674487fc9c280dfc 100644 --- a/src/vkcv/RayTracingPipelineManager.cpp +++ b/src/vkcv/RayTracingPipelineManager.cpp @@ -66,7 +66,7 @@ namespace vkcv { vk::PipelineShaderStageCreateInfo* outCreateInfo) { assert(outCreateInfo); - std::vector<uint32_t> code = shaderProgram.getShaderBinary(stage); + Vector<uint32_t> code = shaderProgram.getShaderBinary(stage); vk::ShaderModuleCreateInfo vertexModuleInfo( {}, code.size() * sizeof(uint32_t), @@ -98,7 +98,7 @@ namespace vkcv { */ static vk::PipelineLayoutCreateInfo createPipelineLayoutCreateInfo( const RayTracingPipelineConfig &config, - const std::vector<vk::DescriptorSetLayout> &descriptorSetLayouts) { + const Vector<vk::DescriptorSetLayout> &descriptorSetLayouts) { static vk::PushConstantRange pushConstantRange; const size_t pushConstantsSize = config.getShaderProgram().getPushConstantsSize(); @@ -142,7 +142,7 @@ namespace vkcv { uint32_t closestHitStageIndex = VK_SHADER_UNUSED_KHR; uint32_t intersectionStageIndex = VK_SHADER_UNUSED_KHR; - std::vector<vk::PipelineShaderStageCreateInfo> shaderStages; + Vector<vk::PipelineShaderStageCreateInfo> shaderStages; shaderStages.reserve( (existsRayGenShader? 1 : 0) + (existsRayAnyHitShader? 1 : 0) @@ -159,7 +159,7 @@ namespace vkcv { shaderStages.clear(); }; - std::vector<vk::RayTracingShaderGroupCreateInfoKHR> shaderGroups; + Vector<vk::RayTracingShaderGroupCreateInfoKHR> shaderGroups; shaderGroups.reserve( (existsRayGenShader? 1 : 0) + (existsRayMissShader? 1 : 0) @@ -312,7 +312,7 @@ namespace vkcv { ); } - std::vector<vk::DescriptorSetLayout> descriptorSetLayouts; + Vector<vk::DescriptorSetLayout> descriptorSetLayouts; descriptorSetLayouts.reserve(config.getDescriptorSetLayouts().size()); for (const auto &handle : config.getDescriptorSetLayouts()) { descriptorSetLayouts.push_back( @@ -374,7 +374,7 @@ namespace vkcv { rayTracingPipelineProperties.shaderGroupHandleSize * shaderGroups.size() ); - std::vector<uint8_t> shaderGroupHandleEntries; + Vector<uint8_t> shaderGroupHandleEntries; shaderGroupHandleEntries.resize(shaderGroupHandlesSize); if (getCore().getContext().getDevice().getRayTracingShaderGroupHandlesKHR( diff --git a/src/vkcv/RayTracingPipelineManager.hpp b/src/vkcv/RayTracingPipelineManager.hpp index f2b9da8bf509c5401b06853e674e81ce4ec35342..84097bd0b546a017b749c44cdd7f2620a1e32809 100644 --- a/src/vkcv/RayTracingPipelineManager.hpp +++ b/src/vkcv/RayTracingPipelineManager.hpp @@ -6,13 +6,15 @@ * @brief Creation and handling of ray tracing pipelines */ +#include <vulkan/vulkan.hpp> + #include "BufferManager.hpp" #include "DescriptorSetLayoutManager.hpp" #include "HandleManager.hpp" #include "PassManager.hpp" + +#include "vkcv/Container.hpp" #include "vkcv/RayTracingPipelineConfig.hpp" -#include <vector> -#include <vulkan/vulkan.hpp> namespace vkcv { diff --git a/src/vkcv/SamplerManager.hpp b/src/vkcv/SamplerManager.hpp index 5ac033037f401ca97a658f2bec2d818110d2aa6a..e9b0734740475dfadb917d78951b516e1f2d5cbc 100644 --- a/src/vkcv/SamplerManager.hpp +++ b/src/vkcv/SamplerManager.hpp @@ -1,10 +1,10 @@ #pragma once -#include <vector> #include <vulkan/vulkan.hpp> #include "HandleManager.hpp" +#include "vkcv/Container.hpp" #include "vkcv/Sampler.hpp" namespace vkcv { diff --git a/src/vkcv/ShaderProgram.cpp b/src/vkcv/ShaderProgram.cpp index 099af639a798938cf6de7a128b72bf9dbe7f7660..2deeeb813ad51e60b98a0c74f78b0cb0afa73039 100644 --- a/src/vkcv/ShaderProgram.cpp +++ b/src/vkcv/ShaderProgram.cpp @@ -58,7 +58,7 @@ namespace vkcv { vkcv_log(LogLevel::WARNING, "Overwriting existing shader stage"); } - std::vector<uint32_t> shaderCode; + Vector<uint32_t> shaderCode; if ((!readBinaryFromFile(path, shaderCode)) || (shaderCode.empty())) { return false; } @@ -68,7 +68,7 @@ namespace vkcv { return true; } - const std::vector<uint32_t> &ShaderProgram::getShaderBinary(ShaderStage stage) const { + const Vector<uint32_t> &ShaderProgram::getShaderBinary(ShaderStage stage) const { return m_Shaders.at(stage); } @@ -109,7 +109,7 @@ namespace vkcv { // reflect descriptor sets (uniform buffer, storage buffer, sampler, sampled image, storage // image) - std::vector<std::pair<uint32_t, DescriptorBinding>> bindings; + Vector<std::pair<uint32_t, DescriptorBinding>> bindings; for (uint32_t i = 0; i < resources.uniform_buffers.size(); i++) { auto &u = resources.uniform_buffers [i]; @@ -318,7 +318,7 @@ namespace vkcv { return m_VertexAttachments; } - const std::unordered_map<uint32_t, DescriptorBindings> & + const Dictionary<uint32_t, DescriptorBindings> & ShaderProgram::getReflectedDescriptors() const { return m_DescriptorSets; } diff --git a/src/vkcv/SwapchainManager.cpp b/src/vkcv/SwapchainManager.cpp index 7586f9ada50c03997ede4b8db542e247785d54b1..c89845302c408faf05d38bc356f648ce822f2cd3 100644 --- a/src/vkcv/SwapchainManager.cpp +++ b/src/vkcv/SwapchainManager.cpp @@ -114,7 +114,7 @@ namespace vkcv { */ static vk::SurfaceFormatKHR chooseSurfaceFormat(vk::PhysicalDevice physicalDevice, vk::SurfaceKHR surface) { - std::vector<vk::SurfaceFormatKHR> availableFormats = + Vector<vk::SurfaceFormatKHR> availableFormats = physicalDevice.getSurfaceFormatsKHR(surface); for (const auto &availableFormat : availableFormats) { @@ -137,7 +137,7 @@ namespace vkcv { */ static vk::PresentModeKHR choosePresentMode(vk::PhysicalDevice physicalDevice, vk::SurfaceKHR surface) { - std::vector<vk::PresentModeKHR> availablePresentModes = + Vector<vk::PresentModeKHR> availablePresentModes = physicalDevice.getSurfacePresentModesKHR(surface); for (const auto &availablePresentMode : availablePresentModes) { @@ -301,18 +301,18 @@ namespace vkcv { return (*this) [handle].m_ColorSpace; } - std::vector<vk::Image> + Vector<vk::Image> SwapchainManager::getSwapchainImages(const SwapchainHandle &handle) const { return getCore().getContext().getDevice().getSwapchainImagesKHR( (*this) [handle].m_Swapchain); } - std::vector<vk::ImageView> + Vector<vk::ImageView> SwapchainManager::createSwapchainImageViews(SwapchainHandle &handle) { - std::vector<vk::Image> images = getSwapchainImages(handle); + Vector<vk::Image> images = getSwapchainImages(handle); auto &swapchain = (*this) [handle]; - std::vector<vk::ImageView> imageViews; + Vector<vk::ImageView> imageViews; imageViews.reserve(images.size()); // here can be swizzled with vk::ComponentSwizzle if needed vk::ComponentMapping componentMapping(vk::ComponentSwizzle::eR, vk::ComponentSwizzle::eG, diff --git a/src/vkcv/SwapchainManager.hpp b/src/vkcv/SwapchainManager.hpp index 27262ec65da2b841597347c965fa462fae6a0d4c..6cd6f21f171bf21c146954e1f1e4f804af042e5e 100644 --- a/src/vkcv/SwapchainManager.hpp +++ b/src/vkcv/SwapchainManager.hpp @@ -6,13 +6,13 @@ */ #include <atomic> -#include <vector> #include <vulkan/vulkan.hpp> -#include "vkcv/Window.hpp" - #include "HandleManager.hpp" +#include "vkcv/Container.hpp" +#include "vkcv/Window.hpp" + namespace vkcv { const uint32_t MIN_SURFACE_SIZE = 2; @@ -145,7 +145,7 @@ namespace vkcv { * @param handle of the swapchain * @return a vector of the swapchain images */ - [[nodiscard]] std::vector<vk::Image> + [[nodiscard]] Vector<vk::Image> getSwapchainImages(const SwapchainHandle &handle) const; /** @@ -153,7 +153,7 @@ namespace vkcv { * @param handle of the swapchain which ImageViews should be created * @return a ov ImageViews of the swapchain */ - [[nodiscard]] std::vector<vk::ImageView> createSwapchainImageViews(SwapchainHandle &handle); + [[nodiscard]] Vector<vk::ImageView> createSwapchainImageViews(SwapchainHandle &handle); }; } // namespace vkcv \ No newline at end of file diff --git a/src/vkcv/VertexData.cpp b/src/vkcv/VertexData.cpp index 70c99059b8063f8307e4ba48c98776b5025de443..ac1600e1fc0e6261d2686bb701e6896e93f9da8b 100644 --- a/src/vkcv/VertexData.cpp +++ b/src/vkcv/VertexData.cpp @@ -13,10 +13,10 @@ namespace vkcv { return binding; } - VertexData::VertexData(const std::vector<VertexBufferBinding> &bindings) : + VertexData::VertexData(const Vector<VertexBufferBinding> &bindings) : m_bindings(bindings), m_indices(), m_indexBitCount(IndexBitCount::Bit16), m_count(0) {} - const std::vector<VertexBufferBinding> &VertexData::getVertexBufferBindings() const { + const Vector<VertexBufferBinding> &VertexData::getVertexBufferBindings() const { return m_bindings; } diff --git a/src/vkcv/Window.cpp b/src/vkcv/Window.cpp index f989f1b84014aaca0a703e57d27151faa960a8bd..78afe0f2175e6b3c7355e5f7863ae425069adacd 100644 --- a/src/vkcv/Window.cpp +++ b/src/vkcv/Window.cpp @@ -1,8 +1,8 @@ #include <GLFW/glfw3.h> #include <thread> -#include <vector> +#include "vkcv/Container.hpp" #include "vkcv/Window.hpp" namespace vkcv { @@ -56,7 +56,7 @@ namespace vkcv { } } - static std::vector<GLFWwindow*> s_Windows; + static Vector<GLFWwindow*> s_Windows; void Window_onGamepadEvent(int gamepadIndex) { Window::getFocusedWindow().e_gamepad(gamepadIndex); @@ -181,8 +181,8 @@ namespace vkcv { } } - const std::vector<std::string> &Window::getExtensions() { - static std::vector<std::string> extensions; + const Vector<std::string> &Window::getExtensions() { + static Vector<std::string> extensions; if (extensions.empty()) { if (s_Windows.empty()) { diff --git a/src/vkcv/WindowManager.cpp b/src/vkcv/WindowManager.cpp index 077b9ec3cc200003c5f5ee5c7a90d523e80c8b66..331826e68915c9a9b5dc0d12e24c2980a5d8e9b0 100644 --- a/src/vkcv/WindowManager.cpp +++ b/src/vkcv/WindowManager.cpp @@ -56,8 +56,8 @@ namespace vkcv { return *(*this) [handle]; } - std::vector<WindowHandle> WindowManager::getWindowHandles() const { - std::vector<WindowHandle> handles; + Vector<WindowHandle> WindowManager::getWindowHandles() const { + Vector<WindowHandle> handles; for (size_t id = 0; id < getCount(); id++) { if (getById(id)->isOpen()) { diff --git a/src/vkcv/WindowManager.hpp b/src/vkcv/WindowManager.hpp index 71b107c71baca467b035cc326abc7e2d488ad586..51b45f63a5bf469d570b2149b93950c801264367 100644 --- a/src/vkcv/WindowManager.hpp +++ b/src/vkcv/WindowManager.hpp @@ -3,13 +3,13 @@ #include <GLFW/glfw3.h> #include <memory> #include <string> -#include <vector> - -#include "vkcv/Window.hpp" #include "HandleManager.hpp" #include "SwapchainManager.hpp" +#include "vkcv/Container.hpp" +#include "vkcv/Window.hpp" + namespace vkcv { /** @@ -64,7 +64,7 @@ namespace vkcv { * * @return List of window handles */ - [[nodiscard]] std::vector<WindowHandle> getWindowHandles() const; + [[nodiscard]] Vector<WindowHandle> getWindowHandles() const; }; } // namespace vkcv \ No newline at end of file