Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 119-graphicspipeline-refactoring
  • 129-projekte-und-assets-auslagern
  • 132-denoising-module
  • 143-ar-vr-support-via-openxr
  • 43-multi-threading
  • 91-compute-first-network
  • 95-arm64-raspberry-pi-4-support
  • develop
  • master
  • optimizations
  • 0.1.0
  • 0.2.0
12 results

Target

Select target project
  • vulkan2021/vkcv-framework
1 result
Select Git revision
  • 119-graphicspipeline-refactoring
  • 129-projekte-und-assets-auslagern
  • 132-denoising-module
  • 143-ar-vr-support-via-openxr
  • 43-multi-threading
  • 91-compute-first-network
  • 95-arm64-raspberry-pi-4-support
  • develop
  • master
  • optimizations
  • 0.1.0
  • 0.2.0
12 results
Show changes
Commits on Source (116)
Showing
with 345 additions and 39 deletions
*.blend filter=lfs diff=lfs merge=lfs -text
*.blend1 filter=lfs diff=lfs merge=lfs -text
*.bin filter=lfs diff=lfs merge=lfs -text
*.glb filter=lfs diff=lfs merge=lfs -text
*.jpg filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.tif filter=lfs diff=lfs merge=lfs -text
*.psd filter=lfs diff=lfs merge=lfs -text
*.gltf filter=lfs diff=lfs merge=lfs
<<<<<<< HEAD
=======
>>>>>>> develop
# IDE specific files
.project
.cproject
......
variables:
RUN:
value: "all"
description: "The tests that should run. Possible values: ubuntu, win, all."
GIT_DEPTH: 1
stages:
- build
- deploy
build_ubuntu_gcc:
only:
variables:
- $RUN =~ /\bubuntu.*/i || $RUN =~ /\ball.*/i
stage: build
tags:
- ubuntu-gcc
variables:
GIT_SUBMODULE_STRATEGY: recursive
timeout: 10m
retry: 1
script:
- mkdir debug
- cd debug
......@@ -21,11 +32,16 @@ build_ubuntu_gcc:
expire_in: never
build_win10_msvc:
only:
variables:
- $RUN =~ /\bwin.*/i || $RUN =~ /\ball.*/i
stage: build
tags:
- win10-msvc
variables:
GIT_SUBMODULE_STRATEGY: recursive
timeout: 10m
retry: 1
script:
- cd 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\'
- .\Launch-VsDevShell.ps1
......@@ -37,6 +53,8 @@ build_win10_msvc:
deploy_doc_develop:
only:
variables:
- $RUN =~ /\bubuntu.*/i || $RUN =~ /\ball.*/i
refs:
- develop
stage: deploy
......@@ -52,6 +70,9 @@ deploy_doc_develop:
- echo "Check it out at https://vkcv.de/develop"
deploy_doc_branch:
only:
variables:
- $RUN =~ /\bubuntu.*/i || $RUN =~ /\ball.*/i
except:
refs:
- develop
......
[submodule "lib/glfw"]
path = lib/glfw
url = https://github.com/glfw/glfw.git
[submodule "lib/SPIRV-Cross"]
path = lib/SPIRV-Cross
url = https://github.com/KhronosGroup/SPIRV-Cross.git
[submodule "modules/asset_loader/lib/fx-gltf"]
path = modules/asset_loader/lib/fx-gltf
url = https://github.com/jessey-git/fx-gltf.git
[submodule "modules/asset_loader/lib/json"]
path = modules/asset_loader/lib/json
url = https://github.com/nlohmann/json.git
[submodule "modules/asset_loader/lib/stb"]
path = modules/asset_loader/lib/stb
url = https://github.com/nothings/stb.git
[submodule "modules/camera/lib/glm"]
path = modules/camera/lib/glm
url = https://github.com/g-truc/glm.git
\ No newline at end of file
......@@ -72,12 +72,15 @@ endif()
# add include directories from dependencies as system includes
target_include_directories(vkcv SYSTEM BEFORE PRIVATE ${vkcv_includes})
message(STATUS ${vkcv_includes})
# add the own include directory for public headers
target_include_directories(vkcv BEFORE PUBLIC ${vkcv_include})
message(STATUS ${vkcv_include})
# link the framework using all required libraries
target_link_libraries(vkcv ${vkcv_libraries})
message(STATUS ${vkcv_libraries})
# add sub-projects/examples as targets
add_subdirectory(projects)
......
......@@ -3,7 +3,25 @@
![Vulkan-Chan](https://gitlab.uni-koblenz.de/uploads/-/system/project/avatar/3712/VulkanChan.jpg)
## Repository
Git LFS is used for bigger resource files like meshes and textures. So you need to install Git LFS and use `git lfs install` after cloning.
More information about Git LFS [here](https://git-lfs.github.com/).
## Build
[![pipeline status](https://gitlab.uni-koblenz.de/vulkan2021/vkcv-framework/badges/develop/pipeline.svg)](https://gitlab.uni-koblenz.de/vulkan2021/vkcv-framework/-/commits/develop)
Git submodules are used for libraries.
To download the submodules either clone using `git clone --recurse-submodules` or after `git clone` use `git submodule init` and `git submodule update`.
## Documentation
The documentation for the develop-branch can be found here:
https://vkcv.de/develop/
The documentation concerning the respective merge request is listed here:
https://vkcv.de/branch/
It is automatically generated and uploaded using the CI pipeline.
......@@ -16,6 +16,7 @@ set(vkcv_config_msg " - Library: ")
# load dependencies via separate cmake file
include(${vkcv_config_lib}/GLFW.cmake) # glfw-x11 / glfw-wayland # libglfw3-dev
include(${vkcv_config_lib}/Vulkan.cmake) # vulkan-intel / vulkan-radeon / nvidia # libvulkan-dev
include(${vkcv_config_lib}/SPIRV_Cross.cmake) # SPIRV-Cross # libspirv_cross_c_shared
# cleanup of compiler flags
if (vkcv_flags)
......
......@@ -54,5 +54,14 @@ set(vkcv_sources
${vkcv_source}/vkcv/Framebuffer.hpp
${vkcv_source}/vkcv/Framebuffer.cpp
${vkcv_include}/vkcv/VertexLayout.hpp
${vkcv_source}/vkcv/VertexLayout.cpp
${vkcv_include}/vkcv/Event.hpp
${vkcv_source}/vkcv/DescriptorManager.hpp
${vkcv_source}/vkcv/DescriptorManager.cpp
${vkcv_include}/vkcv/DescriptorConfig.hpp
${vkcv_source}/vkcv/DescriptorConfig.cpp
)
find_package(spirv_cross_c_shared QUIET)
if (spirv-cross_FOUND)
list(APPEND vkcv_libraries spirv-cross-cpp)
message(${vkcv_config_msg} " SPIRV Cross - " ${SPIRV_CROSS_VERSION})
else()
if (EXISTS "${vkcv_lib_path}/SPIRV-Cross")
set(SPIRV_CROSS_CLI OFF CACHE INTERNAL "")
set(SPIRV_CROSS_ENABLE_TESTS OFF CACHE INTERNAL "")
set(SPIRV_CROSS_ENABLE_C_API OFF CACHE INTERNAL "")
set(SPIRV_CROSS_SKIP_INSTALL ON CACHE INTERNAL "")
add_subdirectory(${vkcv_lib}/SPIRV-Cross)
list(APPEND vkcv_libraries spirv-cross-cpp)
message(${vkcv_config_msg} " SPIRV Cross - " ${SPIRV_CROSS_VERSION})
else()
message(WARNING "SPIRV-Cross is required..! Update the submodules!")
endif ()
endif ()
\ No newline at end of file
......@@ -4,58 +4,70 @@
* @file vkcv/Buffer.hpp
* @brief template buffer class, template for type security, implemented here because template classes can't be written in .cpp
*/
#include "Handles.hpp"
#include "BufferManager.hpp"
namespace vkcv {
template<typename T>
class Buffer {
friend class Core;
public:
// explicit destruction of default constructor
Buffer<T>() = delete;
BufferType getType() {
[[nodiscard]]
const BufferHandle& getHandle() const {
return m_handle;
}
[[nodiscard]]
BufferType getType() const {
return m_type;
};
size_t getCount() {
[[nodiscard]]
size_t getCount() const {
return m_count;
}
size_t getSize() {
[[nodiscard]]
size_t getSize() const {
return m_count * sizeof(T);
}
void fill(T* data, size_t count = 0, size_t offset = 0) {
m_manager->fillBuffer(m_handle_id, data, count * sizeof(T), offset * sizeof(T));
m_manager->fillBuffer(m_handle, data, count * sizeof(T), offset * sizeof(T));
}
[[nodiscard]]
T* map(size_t offset = 0, size_t count = 0) {
return reinterpret_cast<T*>(m_manager->mapBuffer(m_handle_id, offset * sizeof(T), count * sizeof(T)));
return reinterpret_cast<T*>(m_manager->mapBuffer(m_handle, offset * sizeof(T), count * sizeof(T)));
}
void unmap() {
m_manager->unmapBuffer(m_handle_id);
}
static Buffer<T> create(BufferManager* manager, BufferType type, size_t count, BufferMemoryType memoryType) {
return Buffer<T>(manager, manager->createBuffer(type, count * sizeof(T), memoryType), type, count, memoryType);
m_manager->unmapBuffer(m_handle);
}
private:
BufferManager* const m_manager;
const uint64_t m_handle_id;
const BufferHandle m_handle;
const BufferType m_type;
const size_t m_count;
const BufferMemoryType m_memoryType;
Buffer<T>(BufferManager* manager, uint64_t id, BufferType type, size_t count, BufferMemoryType memoryType) :
Buffer<T>(BufferManager* manager, BufferHandle handle, BufferType type, size_t count, BufferMemoryType memoryType) :
m_manager(manager),
m_handle_id(id),
m_handle(handle),
m_type(type),
m_count(count),
m_memoryType(memoryType)
{}
[[nodiscard]]
static Buffer<T> create(BufferManager* manager, BufferType type, size_t count, BufferMemoryType memoryType) {
return Buffer<T>(manager, manager->createBuffer(type, count * sizeof(T), memoryType), type, count, memoryType);
}
};
}
......@@ -3,9 +3,12 @@
#include <vector>
#include <vulkan/vulkan.hpp>
#include "Handles.hpp"
namespace vkcv
{
enum class BufferType {
INDEX,
VERTEX,
UNIFORM,
STORAGE,
......@@ -35,7 +38,7 @@ namespace vkcv
Core* m_core;
std::vector<Buffer> m_buffers;
uint64_t m_stagingBuffer;
BufferHandle m_stagingBuffer;
BufferManager() noexcept;
......@@ -57,47 +60,67 @@ namespace vkcv
* @param type Type of buffer
* @param size Size of buffer in bytes
* @param memoryType Type of buffers memory
* @return New buffer handle id
* @return New buffer handle
*/
BufferHandle createBuffer(BufferType type, size_t size, BufferMemoryType memoryType);
/**
* Returns the Vulkan buffer handle of a buffer
* represented by a given buffer handle id.
*
* @param handle Buffer handle
* @return Vulkan buffer handle
*/
[[nodiscard]]
vk::Buffer getBuffer(const BufferHandle& handle) const;
/**
* Returns the Vulkan device memory handle of a buffer
* represented by a given buffer handle id.
*
* @param handle Buffer handle
* @return Vulkan device memory handle
*/
uint64_t createBuffer(BufferType type, size_t size, BufferMemoryType memoryType);
[[nodiscard]]
vk::DeviceMemory getDeviceMemory(const BufferHandle& handle) const;
/**
* Fills a buffer represented by a given buffer
* handle id with custom data.
*
* @param id Buffer handle id
* @param handle Buffer handle
* @param data Pointer to data
* @param size Size of data in bytes
* @param offset Offset to fill in data in bytes
*/
void fillBuffer(uint64_t id, void* data, size_t size, size_t offset);
void fillBuffer(const BufferHandle& handle, void* data, size_t size, size_t offset);
/**
* Maps memory to a buffer represented by a given
* buffer handle id and returns it.
*
* @param id Buffer handle id
* @param handle Buffer handle
* @param offset Offset of mapping in bytes
* @param size Size of mapping in bytes
* @return Pointer to mapped memory
*/
void* mapBuffer(uint64_t id, size_t offset, size_t size);
void* mapBuffer(const BufferHandle& handle, size_t offset, size_t size);
/**
* Unmaps memory from a buffer represented by a given
* buffer handle id.
*
* @param id Buffer handle id
* @param handle Buffer handle
*/
void unmapBuffer(uint64_t id);
void unmapBuffer(const BufferHandle& handle);
/**
* Destroys and deallocates buffer represented by a given
* buffer handle id.
*
* @param id Buffer handle id
* @param handle Buffer handle
*/
void destroyBuffer(uint64_t id);
void destroyBuffer(const BufferHandle& handle);
};
......
......@@ -17,12 +17,14 @@
#include "CommandResources.hpp"
#include "SyncResources.hpp"
#include "Result.hpp"
#include "vkcv/DescriptorConfig.hpp"
namespace vkcv
{
// forward declarations
class PassManager;
class PipelineManager;
class DescriptorManager;
class BufferManager;
struct SubmitInfo {
......@@ -59,7 +61,9 @@ namespace vkcv
std::unique_ptr<PassManager> m_PassManager;
std::unique_ptr<PipelineManager> m_PipelineManager;
std::unique_ptr<DescriptorManager> m_DescriptorManager;
std::unique_ptr<BufferManager> m_BufferManager;
CommandResources m_CommandResources;
SyncResources m_SyncResources;
uint32_t m_currentSwapchainImageIndex;
......@@ -167,6 +171,13 @@ namespace vkcv
return Buffer<T>::create(m_BufferManager.get(), type, count, memoryType);
}
/** TODO:
* @param setDescriptions
* @return
*/
[[nodiscard]]
ResourcesHandle createResourceDescription(const std::vector<DescriptorSet> &descriptorSets);
/**
* @brief start recording command buffers and increment frame index
*/
......@@ -175,8 +186,9 @@ namespace vkcv
/**
* @brief render a beautiful triangle
*/
void renderTriangle(const PassHandle renderpassHandle, const PipelineHandle pipelineHandle,
const int width, const int height);
void renderMesh(const PassHandle renderpassHandle, const PipelineHandle pipelineHandle,
const int width, const int height, const size_t pushConstantSize, const void* pushConstantData,
const BufferHandle vertexBuffer, const BufferHandle indexBuffer, const size_t indexCount);
/**
* @brief end recording and present image
......
#pragma once
#include <vkcv/ShaderProgram.hpp>
namespace vkcv
{
/*
* All the types of descriptors (resources) that can be retrieved by the shaders
*/
enum class DescriptorType
{
UNIFORM_BUFFER,
STORAGE_BUFFER,
SAMPLER,
IMAGE
};
/*
* One binding for a descriptor set
* @param[in] a unique binding ID
* @param[in] a descriptor type
* @param[in] the number of descriptors of this type (arrays of the same type possible)
* @param[in] the shader stage where the descriptor is supposed to be retrieved
*/
struct DescriptorBinding
{
DescriptorBinding() = delete;
DescriptorBinding(
DescriptorType descriptorType,
uint32_t descriptorCount,
ShaderStage shaderStage
) noexcept;
DescriptorType descriptorType;
uint32_t descriptorCount;
ShaderStage shaderStage;
};
/*
* One descriptor set struct that contains all the necessary information for the actual creation.
* @param[in] a number of bindings that were created beforehand
* @param[in] the number of (identical) sets that should be created from the attached bindings
*/
struct DescriptorSet
{
DescriptorSet() = delete;
explicit DescriptorSet(std::vector<DescriptorBinding> bindings) noexcept;
std::vector<DescriptorBinding> bindings;
};
}
......@@ -34,8 +34,9 @@ namespace vkcv {
* adds a function handle to the event to be called
* @param handle of the function
*/
void add(typename event_function<T...>::type handle) {
typename event_function<T...>::type add(typename event_function<T...>::type handle) {
this->m_handles.push_back(handle);
return handle;
}
/**
......
......@@ -5,12 +5,63 @@
* @brief Central header file for all possible handles that the framework will hand out.
*/
#include <cstdint>
#include <iostream>
namespace vkcv
{
class Handle {
friend std::ostream& operator << (std::ostream& out, const Handle& handle);
private:
uint64_t m_id;
protected:
Handle();
explicit Handle(uint64_t id);
[[nodiscard]]
uint64_t getId() const;
public:
virtual ~Handle() = default;
Handle(const Handle& other) = default;
Handle(Handle&& other) = default;
Handle& operator=(const Handle& other) = default;
Handle& operator=(Handle&& other) = default;
explicit operator bool() const;
bool operator!() const;
};
std::ostream& operator << (std::ostream& out, const Handle& handle);
// Handle returned for any buffer created with the core/context objects
struct BufferHandle {uint64_t id;};
struct PassHandle {uint64_t id;};
struct PipelineHandle {uint64_t id;};
class BufferHandle : public Handle {
friend class BufferManager;
private:
using Handle::Handle;
};
class PassHandle : public Handle {
friend class PassManager;
private:
using Handle::Handle;
};
class PipelineHandle : public Handle {
friend class PipelineManager;
private:
using Handle::Handle;
};
class ResourcesHandle : public Handle {
friend class DescriptorManager;
private:
using Handle::Handle;
};
}
#pragma once
/**
* @authors Mara Vogt, Mark Mints
* @file src/vkcv/Pipeline.hpp
* @brief Pipeline class to handle shader stages
*/
#ifndef VKCV_PIPELINECONFIG_HPP
#define VKCV_PIPELINECONFIG_HPP
#include <vector>
#include <cstdint>
#include "vkcv/Handles.hpp"
......@@ -39,5 +37,4 @@ namespace vkcv {
PassHandle m_PassHandle;
};
}
#endif //VKCV_PIPELINECONFIG_HPP
}
\ No newline at end of file
......@@ -10,6 +10,8 @@
#include <iostream>
#include <filesystem>
#include <vulkan/vulkan.hpp>
#include <spirv_cross.hpp>
#include "vkcv/VertexLayout.hpp"
namespace vkcv {
......@@ -53,8 +55,13 @@ namespace vkcv {
bool existsShader(ShaderStage shaderStage) const;
void reflectShader(ShaderStage shaderStage);
const VertexLayout &getVertexLayout() const;
private:
std::unordered_map<ShaderStage, Shader> m_Shaders;
VertexLayout m_VertexLayout;
};
}
#pragma once
#include <unordered_map>
#include <vector>
#include <iostream>
#include <vulkan/vulkan.hpp>
namespace vkcv{
enum class VertexFormat{
FLOAT,
FLOAT2,
FLOAT3,
FLOAT4,
INT,
INT2,
INT3,
INT4
};
struct VertexInputAttachment{
VertexInputAttachment() = delete;
VertexInputAttachment(uint32_t location, uint32_t binding, VertexFormat format, uint32_t offset) noexcept;
uint32_t location;
uint32_t binding;
VertexFormat format;
uint32_t offset;
};
struct VertexLayout{
VertexLayout() noexcept;
VertexLayout(const std::vector<VertexInputAttachment> &inputs) noexcept;
std::unordered_map<uint32_t, VertexInputAttachment> attachmentMap;
uint32_t stride;
};
// currently assuming default 32 bit formats, no lower precision or normalized variants supported
vk::Format vertexFormatToVulkanFormat(const VertexFormat format);
}
\ No newline at end of file
......@@ -12,7 +12,7 @@
struct GLFWwindow;
namespace vkcv {
class Window final {
private:
GLFWwindow *m_window;
......@@ -32,6 +32,16 @@ namespace vkcv {
*/
static void onMouseMoveEvent(GLFWwindow *window, double x, double y);
/**
* mouseButton callback for mouse buttons
* @param[in] button The [mouse button](@ref buttons) that was pressed or released.
* @param[in] action One of `GLFW_PRESS` or `GLFW_RELEASE`. Future releases may add more actions.
* @param[in] mods Bit field describing which [modifier keys](@ref mods) were held down.
*/
static void onMouseButtonEvent(GLFWwindow *callbackWindow, int button, int action, int mods);
static void onMouseScrollEvent(GLFWwindow *callbackWindow, double xoffset, double yoffset);
/**
* resize callback for the resize option of the window
* @param[in] window The window that was resized.
......@@ -81,7 +91,9 @@ namespace vkcv {
/**
* basic events of the window
*/
event< int, int, int> e_mouseButton;
event< double, double > e_mouseMove;
event< double, double > e_mouseScroll;
event< int, int > e_resize;
event< int, int, int, int > e_key;
......@@ -129,5 +141,5 @@ namespace vkcv {
*/
virtual ~Window();
};
}
\ No newline at end of file
Subproject commit ff61890722a91e97c44940494be5b6eed0d5ff5b