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

Target

Select target project
  • vulkan2021/vkcv-framework
1 result
Select Git revision
Show changes
Commits on Source (304)
Showing
with 231 additions and 37 deletions
Alexander Gauggel
Artur Wasmut
Josch Morgenstern
Katharina Krämer
Lars Hoerttrich
Leonie Franken
Mara Vogt
Mark O. Mints
Sebastian Gaida
Simeon Hermann
Susanne Dötsch
Tobias Frisch
Trevor Hollmann
Vanessa Karolek
......@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16)
project(vkcv)
# settings c++ standard for the framework
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# checking build type and setting up a variable
......@@ -42,9 +42,16 @@ if (vkcv_build_debug)
endif()
endif()
if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "11.0.0"))
list(APPEND vkcv_definitions __NO_SEMAPHORES__)
endif()
# configure everything to use the required dependencies
include(${vkcv_config}/Libraries.cmake)
# set macro to enable vulkan debug labels
list(APPEND vkcv_definitions VULKAN_DEBUG_LABELS)
# set the compile definitions aka preprocessor variables
add_compile_definitions(${vkcv_definitions})
......
MIT License
Copyright (c) 2021 Universität Koblenz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
......@@ -16,7 +16,7 @@ namespace vkcv {
friend class Core;
public:
// explicit destruction of default constructor
Buffer<T>() = delete;
Buffer() = delete;
[[nodiscard]]
const BufferHandle& getHandle() const {
......@@ -39,7 +39,7 @@ namespace vkcv {
}
[[nodiscard]]
const vk::Buffer getVulkanHandle() const {
vk::Buffer getVulkanHandle() const {
return m_manager->getBuffer(m_handle);
}
......@@ -67,7 +67,7 @@ namespace vkcv {
const size_t m_count;
const BufferMemoryType m_memoryType;
Buffer<T>(BufferManager* manager, BufferHandle handle, BufferType type, size_t count, BufferMemoryType memoryType) :
Buffer(BufferManager* manager, BufferHandle handle, BufferType type, size_t count, BufferMemoryType memoryType) :
m_manager(manager),
m_handle(handle),
m_type(type),
......
......@@ -13,7 +13,8 @@ namespace vkcv
VERTEX,
UNIFORM,
STORAGE,
STAGING
STAGING,
INDIRECT
};
enum class BufferMemoryType {
......
......@@ -331,6 +331,18 @@ namespace vkcv
const std::vector<ImageHandle> &renderTargets,
const WindowHandle &windowHandle);
void recordIndexedIndirectDrawcallsToCmdStream(
const CommandStreamHandle cmdStreamHandle,
const PassHandle renderpassHandle,
const GraphicsPipelineHandle &pipelineHandle,
const PushConstants &pushConstantData,
const vkcv::DescriptorSetHandle &compiledDescriptorSet,
const vkcv::Mesh &compiledMesh,
const std::vector<ImageHandle> &renderTargets,
const vkcv::Buffer<vk::DrawIndexedIndirectCommand> &indirectBuffer,
const uint32_t drawCount,
const WindowHandle &windowHandle);
void recordMeshShaderDrawcalls(
const CommandStreamHandle& cmdStreamHandle,
const PassHandle& renderpassHandle,
......@@ -339,6 +351,33 @@ namespace vkcv
const std::vector<MeshShaderDrawcall>& drawcalls,
const std::vector<ImageHandle>& renderTargets,
const WindowHandle& windowHandle);
/**
* Records the rtx ray generation to the @p cmdStreamHandle.
* Currently only supports @p closestHit, @p rayGen and @c miss shaderstages @c.
* @param cmdStreamHandle The command stream handle which receives relevant commands for drawing.
* @param rtxPipeline The raytracing pipeline from the RTXModule.
* @param rtxPipelineLayout The raytracing pipeline layout from the RTXModule.
* @param rgenRegion The shader binding table region for ray generation shaders.
* @param rmissRegion The shader binding table region for ray miss shaders.
* @param rchitRegion The shader binding table region for ray closest hit shaders.
* @param rcallRegion The shader binding table region for callable shaders.
* @param descriptorSetUsages The descriptor set usages.
* @param pushConstants The push constants.
* @param windowHandle The window handle defining in which window to render.
*/
void recordRayGenerationToCmdStream(
CommandStreamHandle cmdStreamHandle,
vk::Pipeline rtxPipeline,
vk::PipelineLayout rtxPipelineLayout,
vk::StridedDeviceAddressRegionKHR rgenRegion,
vk::StridedDeviceAddressRegionKHR rmissRegion,
vk::StridedDeviceAddressRegionKHR rchitRegion,
vk::StridedDeviceAddressRegionKHR rcallRegion,
const std::vector<DescriptorSetUsage>& descriptorSetUsages,
const PushConstants& pushConstants,
const WindowHandle windowHandle);
void recordComputeDispatchToCmdStream(
CommandStreamHandle cmdStream,
......
......@@ -19,7 +19,8 @@ namespace vkcv
IMAGE_SAMPLED,
IMAGE_STORAGE,
UNIFORM_BUFFER_DYNAMIC,
STORAGE_BUFFER_DYNAMIC
STORAGE_BUFFER_DYNAMIC,
ACCELERATION_STRUCTURE_KHR
};
/**
......@@ -44,6 +45,8 @@ namespace vkcv
return vk::DescriptorType::eSampledImage;
case DescriptorType::IMAGE_STORAGE:
return vk::DescriptorType::eStorageImage;
case DescriptorType::ACCELERATION_STRUCTURE_KHR:
return vk::DescriptorType::eAccelerationStructureKHR;
default:
return vk::DescriptorType::eMutableVALVE;
}
......@@ -58,17 +61,11 @@ namespace vkcv
*/
struct DescriptorBinding
{
DescriptorBinding(
uint32_t bindingID,
DescriptorType descriptorType,
uint32_t descriptorCount,
ShaderStages shaderStages
) noexcept;
uint32_t bindingID;
DescriptorType descriptorType;
uint32_t descriptorCount;
ShaderStages shaderStages;
bool variableCount;
bool operator ==(const DescriptorBinding &other) const;
};
......
......@@ -4,12 +4,13 @@
namespace vkcv {
struct SampledImageDescriptorWrite {
inline SampledImageDescriptorWrite(uint32_t binding, ImageHandle image, uint32_t mipLevel = 0, bool useGeneralLayout = false)
: binding(binding), image(image), mipLevel(mipLevel), useGeneralLayout(useGeneralLayout) {};
inline SampledImageDescriptorWrite(uint32_t binding, ImageHandle image, uint32_t mipLevel = 0, bool useGeneralLayout = false, uint32_t arrayIndex = 0)
: binding(binding), image(image), mipLevel(mipLevel), useGeneralLayout(useGeneralLayout), arrayIndex(arrayIndex) {};
uint32_t binding;
ImageHandle image;
uint32_t mipLevel;
bool useGeneralLayout;
uint32_t arrayIndex;
};
struct StorageImageDescriptorWrite {
......@@ -37,11 +38,20 @@ namespace vkcv {
SamplerHandle sampler;
};
/**
* @brief Only used for RTX. Used to bind the Acceleration Structure.
*/
struct AccelerationDescriptorWrite {
inline AccelerationDescriptorWrite(uint32_t binding) : binding(binding) {};
uint32_t binding;
};
struct DescriptorWrites {
std::vector<SampledImageDescriptorWrite> sampledImageWrites;
std::vector<StorageImageDescriptorWrite> storageImageWrites;
std::vector<BufferDescriptorWrite> uniformBufferWrites;
std::vector<BufferDescriptorWrite> storageBufferWrites;
std::vector<SamplerDescriptorWrite> samplerWrites;
std::vector<AccelerationDescriptorWrite> accelerationWrites;
};
}
\ No newline at end of file
......@@ -3,6 +3,7 @@
#include <vkcv/Handles.hpp>
#include <vkcv/DescriptorConfig.hpp>
#include <vkcv/PushConstants.hpp>
#include "Buffer.hpp"
namespace vkcv {
struct VertexBufferBinding {
......@@ -50,6 +51,8 @@ namespace vkcv {
};
vk::IndexType getIndexType(IndexBitCount indexByteCount);
struct DrawcallInfo {
inline DrawcallInfo(const Mesh& mesh, const std::vector<DescriptorSetUsage>& descriptorSets, const uint32_t instanceCount = 1)
: mesh(mesh), descriptorSets(descriptorSets), instanceCount(instanceCount){}
......@@ -66,6 +69,15 @@ namespace vkcv {
const PushConstants &pushConstants,
const size_t drawcallIndex);
void recordIndirectDrawcall(
const DrawcallInfo &drawcall,
vk::CommandBuffer cmdBuffer,
const vkcv::Buffer<vk::DrawIndexedIndirectCommand> &drawBuffer,
const uint32_t drawCount,
vk::PipelineLayout pipelineLayout,
const PushConstants &pushConstants,
const size_t drawcallIndex);
void InitMeshShaderDrawFunctions(vk::Device device);
struct MeshShaderDrawcall {
......
......@@ -3,7 +3,11 @@
#include <functional>
#ifndef __MINGW32__
#ifdef __NO_SEMAPHORES__
#include <mutex>
#else
#include <semaphore>
#endif
#endif
#include <vector>
......@@ -34,7 +38,11 @@ namespace vkcv {
uint32_t m_id_counter;
#ifndef __MINGW32__
#ifdef __NO_SEMAPHORES__
std::mutex m_mutex;
#else
std::binary_semaphore m_semaphore;
#endif
#endif
public:
......@@ -84,7 +92,11 @@ namespace vkcv {
*/
void lock() {
#ifndef __MINGW32__
#ifdef __NO_SEMAPHORES__
m_mutex.lock();
#else
m_semaphore.acquire();
#endif
#endif
}
......@@ -93,15 +105,27 @@ namespace vkcv {
*/
void unlock() {
#ifndef __MINGW32__
#ifdef __NO_SEMAPHORES__
m_mutex.unlock();
#else
m_semaphore.release();
#endif
#endif
}
explicit event(bool locked = false) {
if (locked) {
lock();
}
}
explicit event(bool locked = false)
#ifndef __MINGW32__
#ifndef __NO_SEMAPHORES__
: m_semaphore(locked? 1 : 0)
#endif
#endif
{
#ifndef __MINGW32__
#ifdef __NO_SEMAPHORES__
if (locked) m_mutex.lock();
#endif
#endif
}
event(const event &other) = delete;
......
......@@ -79,6 +79,42 @@ namespace vkcv {
[[nodiscard]]
bool checkSupport(const vk::PhysicalDeviceMeshShaderFeaturesNV& features, bool required) const;
/**
* @brief Currently used for RTX. Checks support of the @p vk::PhysicalDeviceVulkan12Features.
* @param features The features.
* @param required True, if the @p features are required, else false.
* @return @p True, if the @p features are supported, else @p false.
*/
[[nodiscard]]
bool checkSupport(const vk::PhysicalDeviceVulkan12Features& features, bool required) const;
/**
* @brief Currently used for RTX. Checks support of the @p vk::PhysicalDeviceVulkan11Features.
* @param features The features.
* @param required True, if the @p features are required, else false.
* @return @p True, if the @p features are supported, else @p false.
*/
[[nodiscard]]
bool checkSupport(const vk::PhysicalDeviceVulkan11Features& features, bool required) const;
/**
* @brief Only used for RTX. Checks support of the @p vk::PhysicalDeviceAccelerationStructureFeaturesKHR.
* @param features The features.
* @param required True, if the @p features are required, else false.
* @return @p True, if the @p features are supported, else @p false.
*/
[[nodiscard]]
bool checkSupport(const vk::PhysicalDeviceAccelerationStructureFeaturesKHR& features, bool required) const;
/**
* @brief Only used for RTX. Checks support of the @p vk::PhysicalDeviceRayTracingPipelineFeaturesKHR.
* @param features The features.
* @param required True, if the @p features are required, else false.
* @return @p True, if the @p features are supported, else @p false.
*/
[[nodiscard]]
bool checkSupport(const vk::PhysicalDeviceRayTracingPipelineFeaturesKHR& features, bool required) const;
vk::BaseOutStructure* findFeatureStructure(vk::StructureType type) const;
public:
......
......@@ -12,7 +12,13 @@ namespace vkcv {
FRAGMENT = static_cast<VkShaderStageFlags>(vk::ShaderStageFlagBits::eFragment),
COMPUTE = static_cast<VkShaderStageFlags>(vk::ShaderStageFlagBits::eCompute),
TASK = static_cast<VkShaderStageFlags>(vk::ShaderStageFlagBits::eTaskNV),
MESH = static_cast<VkShaderStageFlags>(vk::ShaderStageFlagBits::eMeshNV)
MESH = static_cast<VkShaderStageFlags>(vk::ShaderStageFlagBits::eMeshNV),
RAY_GEN = static_cast<VkShaderStageFlags>(vk::ShaderStageFlagBits::eRaygenKHR), // RTX
RAY_ANY_HIT = static_cast<VkShaderStageFlags>(vk::ShaderStageFlagBits::eAnyHitKHR), // RTX
RAY_CLOSEST_HIT = static_cast<VkShaderStageFlags>(vk::ShaderStageFlagBits::eClosestHitKHR), // RTX
RAY_MISS = static_cast<VkShaderStageFlags>(vk::ShaderStageFlagBits::eMissKHR), // RTX
RAY_INTERSECTION = static_cast<VkShaderStageFlags>(vk::ShaderStageFlagBits::eIntersectionKHR), // RTX
RAY_CALLABLE = static_cast<VkShaderStageFlags>(vk::ShaderStageFlagBits::eCallableKHR) // RTX
};
using ShaderStages = vk::Flags<ShaderStage>;
......
......@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16)
project(vkcv_asset_loader)
# setting c++ standard for the module
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(vkcv_asset_loader_source ${PROJECT_SOURCE_DIR}/src)
......
......@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16)
project(vkcv_camera)
# setting c++ standard for the project
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(vkcv_camera_source ${PROJECT_SOURCE_DIR}/src)
......
......@@ -4,6 +4,7 @@
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/matrix_access.hpp>
#include <glm/vec3.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <glm/mat4x4.hpp>
namespace vkcv::camera {
......
......@@ -117,7 +117,7 @@ namespace vkcv::camera {
* @brief The constructor of the #CameraManager.
* @param[in] window The window.
*/
CameraManager(Window &window);
explicit CameraManager(Window &window);
/**
* @brief The destructor of the #CameraManager. Destroying the #CameraManager leads to deletion of all stored
......
......@@ -164,4 +164,4 @@ namespace vkcv::camera {
setAngles(glm::radians(getPitch()), glm::radians(yaw));
}
}
\ No newline at end of file
}
......@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16)
project(vkcv_gui)
# setting c++ standard for the module
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(vkcv_gui_source ${PROJECT_SOURCE_DIR}/src)
......
......@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16)
project(vkcv_material)
# setting c++ standard for the module
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(vkcv_material_source ${PROJECT_SOURCE_DIR}/src)
......
......@@ -36,16 +36,36 @@ namespace vkcv::material {
case MaterialType::PBR_MATERIAL:
if (pbr_bindings.empty())
{
pbr_bindings.insert(std::make_pair(0, DescriptorBinding(0, DescriptorType::IMAGE_SAMPLED, 1, ShaderStage::FRAGMENT)));
pbr_bindings.insert(std::make_pair(1, DescriptorBinding(1, DescriptorType::SAMPLER, 1, ShaderStage::FRAGMENT)));
pbr_bindings.insert(std::make_pair(2, DescriptorBinding(2, DescriptorType::IMAGE_SAMPLED, 1, ShaderStage::FRAGMENT)));
pbr_bindings.insert(std::make_pair(3, DescriptorBinding(3, DescriptorType::SAMPLER, 1, ShaderStage::FRAGMENT)));
pbr_bindings.insert(std::make_pair(4, DescriptorBinding(4, DescriptorType::IMAGE_SAMPLED, 1, ShaderStage::FRAGMENT)));
pbr_bindings.insert(std::make_pair(5, DescriptorBinding(5, DescriptorType::SAMPLER, 1, ShaderStage::FRAGMENT)));
pbr_bindings.insert(std::make_pair(6, DescriptorBinding(6, DescriptorType::IMAGE_SAMPLED, 1, ShaderStage::FRAGMENT)));
pbr_bindings.insert(std::make_pair(7, DescriptorBinding(7, DescriptorType::SAMPLER, 1, ShaderStage::FRAGMENT)));
pbr_bindings.insert(std::make_pair(8, DescriptorBinding(8, DescriptorType::IMAGE_SAMPLED, 1, ShaderStage::FRAGMENT)));
pbr_bindings.insert(std::make_pair(9, DescriptorBinding(9, DescriptorType::SAMPLER, 1, ShaderStage::FRAGMENT)));
pbr_bindings.insert(std::make_pair(0, DescriptorBinding {
0, DescriptorType::IMAGE_SAMPLED, 1, ShaderStage::FRAGMENT, false
}));
pbr_bindings.insert(std::make_pair(1, DescriptorBinding {
1, DescriptorType::SAMPLER, 1, ShaderStage::FRAGMENT, false
}));
pbr_bindings.insert(std::make_pair(2, DescriptorBinding {
2, DescriptorType::IMAGE_SAMPLED, 1, ShaderStage::FRAGMENT, false
}));
pbr_bindings.insert(std::make_pair(3, DescriptorBinding {
3, DescriptorType::SAMPLER, 1, ShaderStage::FRAGMENT, false
}));
pbr_bindings.insert(std::make_pair(4, DescriptorBinding {
4, DescriptorType::IMAGE_SAMPLED, 1, ShaderStage::FRAGMENT, false
}));
pbr_bindings.insert(std::make_pair(5, DescriptorBinding {
5, DescriptorType::SAMPLER, 1, ShaderStage::FRAGMENT, false
}));
pbr_bindings.insert(std::make_pair(6, DescriptorBinding {
6, DescriptorType::IMAGE_SAMPLED, 1, ShaderStage::FRAGMENT, false
}));
pbr_bindings.insert(std::make_pair(7, DescriptorBinding {
7, DescriptorType::SAMPLER, 1, ShaderStage::FRAGMENT, false
}));
pbr_bindings.insert(std::make_pair(8, DescriptorBinding {
8, DescriptorType::IMAGE_SAMPLED, 1, ShaderStage::FRAGMENT, false
}));
pbr_bindings.insert(std::make_pair(9, DescriptorBinding {
9, DescriptorType::SAMPLER, 1, ShaderStage::FRAGMENT, false
}));
}
return pbr_bindings;
......