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

Target

Select target project
  • vulkan2021/vkcv-framework
1 result
Show changes
Commits on Source (108)
Showing
with 316 additions and 54 deletions
......@@ -18,3 +18,8 @@ cmake-build-release/
# GUI configuration files
imgui.ini
# Generated source and header files for shaders
*.hxx
*.cxx
variables:
RUN:
value: "all"
description: "The tests that should run. Possible values: ubuntu, win, all."
GIT_DEPTH: 1
description: "The tests that should run. Possible values: ubuntu, win-msvc, win-mingw, mac, all."
GIT_DEPTH: 15
stages:
- build
......@@ -17,7 +17,7 @@ build_ubuntu_gcc:
- ubuntu-gcc-cached
variables:
GIT_SUBMODULE_STRATEGY: recursive
timeout: 10m
timeout: 15m
retry: 1
script:
- mkdir debug
......@@ -34,13 +34,13 @@ build_ubuntu_gcc:
build_win10_msvc:
only:
variables:
- $RUN =~ /\bwin.*/i || $RUN =~ /\ball.*/i
- $RUN =~ /\bwin-msvc.*/i || $RUN =~ /\ball.*/i
stage: build
tags:
- win10-msvc-cached
variables:
GIT_SUBMODULE_STRATEGY: recursive
timeout: 10m
timeout: 15m
retry: 0
script:
- cd 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\'
......@@ -51,6 +51,42 @@ build_win10_msvc:
- cmake -DCMAKE_BUILD_TYPE=Debug ..
- cmake --build .
build_win10_mingw:
only:
variables:
- $RUN =~ /\bwin-mingw.*/i || $RUN =~ /\ball.*/i
stage: build
tags:
- win10-mingw-cached
variables:
GIT_SUBMODULE_STRATEGY: recursive
timeout: 15m
retry: 0
script:
- mkdir debug
- cd debug
- cmake --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_C_COMPILER:FILEPATH=C:\msys64\mingw64\bin\x86_64-w64-mingw32-gcc.exe -DCMAKE_CXX_COMPILER:FILEPATH=C:\msys64\mingw64\bin\x86_64-w64-mingw32-g++.exe .. -G "Unix Makefiles"
- cmake --build . -j 8
build_mac_clang:
only:
variables:
- $RUN =~ /\bmac.*/i || $RUN =~ /\ball.*/i
stage: build
tags:
- catalina-clang-cached
variables:
GIT_SUBMODULE_STRATEGY: recursive
timeout: 15m
retry: 1
script:
- mkdir debug
- cd debug
- export LDFLAGS="-L/usr/local/opt/llvm/lib"
- export CPPFLAGS="-I/usr/local/opt/llvm/include"
- cmake -DCMAKE_C_COMPILER="/usr/local/opt/llvm/bin/clang" -DCMAKE_CXX_COMPILER="/usr/local/opt/llvm/bin/clang++" -DCMAKE_BUILD_TYPE=Debug ..
- cmake --build .
deploy_doc_develop:
only:
variables:
......
......@@ -28,3 +28,6 @@
[submodule "lib/VulkanMemoryAllocator-Hpp"]
path = lib/VulkanMemoryAllocator-Hpp
url = https://github.com/malte-v/VulkanMemoryAllocator-Hpp.git
[submodule "modules/upscaling/lib/FidelityFX-FSR"]
path = modules/upscaling/lib/FidelityFX-FSR
url = https://github.com/GPUOpen-Effects/FidelityFX-FSR.git
......@@ -33,7 +33,8 @@ set(vkcv_flags ${CMAKE_CXX_FLAGS})
# enabling warnings in the debug build
if (vkcv_build_debug)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(vkcv_flags ${vkcv_flags} " -Weverything")
#set(vkcv_flags ${vkcv_flags} " -Weverything")
set(vkcv_flags ${vkcv_flags} " -Wextra -Wall")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(vkcv_flags ${vkcv_flags} " -Wextra -Wall -pedantic")
else()
......
......@@ -3,7 +3,13 @@ set(vkcv_config_lib ${vkcv_config}/lib)
set(vkcv_lib_path ${PROJECT_SOURCE_DIR}/${vkcv_lib})
if(NOT WIN32)
set(vkcv_libraries stdc++fs)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(vkcv_libraries stdc++fs)
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
list(APPEND vkcv_flags -Xpreprocessor)
endif()
# optimization for loading times
list(APPEND vkcv_flags -pthread)
......@@ -34,6 +40,9 @@ endif ()
# fix dependencies for different Linux distros (looking at you Ubuntu)
include(${vkcv_config_ext}/CheckLibraries.cmake)
# add custom function to include a file like a shader as string
include(${vkcv_config_ext}/IncludeShader.cmake)
# cleanup of compiler definitions aka preprocessor variables
if (vkcv_definitions)
list(REMOVE_DUPLICATES vkcv_definitions)
......
......@@ -6,6 +6,9 @@ set(vkcv_sources
${vkcv_include}/vkcv/Core.hpp
${vkcv_source}/vkcv/Core.cpp
${vkcv_include}/vkcv/File.hpp
${vkcv_source}/vkcv/File.cpp
${vkcv_include}/vkcv/PassConfig.hpp
${vkcv_source}/vkcv/PassConfig.cpp
......
function(include_shader shader include_dir source_dir)
if (NOT EXISTS ${shader})
message(WARNING "Shader file does not exist: ${shader}")
else()
get_filename_component(filename ${shader} NAME)
file(SIZE ${shader} filesize)
set(include_target_file ${include_dir}/${filename}.hxx)
set(source_target_file ${source_dir}/${filename}.cxx)
if ((EXISTS ${source_target_file}) AND (EXISTS ${include_target_file}))
file(TIMESTAMP ${shader} shader_timestamp "%Y-%m-%dT%H:%M:%S")
file(TIMESTAMP ${source_target_file} source_timestamp "%Y-%m-%dT%H:%M:%S")
string(COMPARE GREATER ${shader_timestamp} ${source_timestamp} shader_update)
else()
set(shader_update true)
endif()
if (shader_update)
string(TOUPPER ${filename} varname)
string(REPLACE "." "_" varname ${varname})
set(shader_header "#pragma once\n")
string(APPEND shader_header "// This file is auto-generated via cmake, so don't touch it!\n")
string(APPEND shader_header "extern unsigned char ${varname} [${filesize}]\;\n")
string(APPEND shader_header "extern unsigned int ${varname}_LEN\;\n")
string(APPEND shader_header "const std::string ${varname}_SHADER (reinterpret_cast<const char*>(${varname}), ${varname}_LEN)\;")
file(WRITE ${include_target_file} ${shader_header})
find_program(xxd_program "xxd")
if (EXISTS ${xxd_program})
get_filename_component(shader_directory ${shader} DIRECTORY)
add_custom_command(
OUTPUT ${source_target_file}
WORKING_DIRECTORY "${shader_directory}"
COMMAND xxd -i -C "${filename}" "${source_target_file}"
COMMENT "Processing shader into source files: ${shader}"
)
else()
set(shader_source "// This file is auto-generated via cmake, so don't touch it!\n")
string(APPEND shader_source "unsigned char ${varname}[] = {")
math(EXPR max_fileoffset "${filesize} - 1" OUTPUT_FORMAT DECIMAL)
message(STATUS "Processing shader into source files: ${shader}")
foreach(fileoffset RANGE ${max_fileoffset})
file(READ ${shader} shader_source_byte OFFSET ${fileoffset} LIMIT 1 HEX)
math(EXPR offset_modulo "${fileoffset} % 12" OUTPUT_FORMAT DECIMAL)
if (${offset_modulo} EQUAL 0)
string(APPEND shader_source "\n ")
endif()
if (${fileoffset} LESS ${max_fileoffset})
string(APPEND shader_source "0x${shader_source_byte}, ")
else()
string(APPEND shader_source "0x${shader_source_byte}\n")
endif()
endforeach()
string(APPEND shader_source "}\;\n")
string(APPEND shader_source "unsigned int ${varname}_LEN = ${filesize}\;")
file(WRITE ${source_target_file} ${shader_source})
endif()
endif()
endif()
endfunction()
......@@ -3,5 +3,56 @@
#define _DEBUG
#endif
#ifndef _MSVC_LANG
#ifdef __MINGW32__
#include <stdint.h>
#include <stdlib.h>
class VmaMutex {
public:
VmaMutex() : m_locked(false) {}
void Lock() {
while (m_locked);
m_locked = true;
}
void Unlock() {
m_locked = false;
}
private:
bool m_locked;
};
#define VMA_MUTEX VmaMutex
template <typename T>
T* custom_overestimate_malloc(size_t size) {
return new T[size + (sizeof(T) - 1) / sizeof(T)];
}
void* custom_aligned_malloc(size_t alignment, size_t size) {
if (alignment > 4) {
return custom_overestimate_malloc<uint64_t>(size);
} else
if (alignment > 2) {
return custom_overestimate_malloc<uint32_t>(size);
} else
if (alignment > 1) {
return custom_overestimate_malloc<uint16_t>(size);
} else {
return custom_overestimate_malloc<uint8_t>(size);
}
}
void custom_free(void *ptr) {
delete[] reinterpret_cast<uint8_t*>(ptr);
}
#define VMA_SYSTEM_ALIGNED_MALLOC(size, alignment) (custom_aligned_malloc(alignment, size))
#define VMA_SYSTEM_FREE(ptr) (custom_free(ptr))
#endif
#endif
#define VMA_IMPLEMENTATION
#include "vk_mem_alloc.hpp"
......@@ -4,6 +4,7 @@
#include <vk_mem_alloc.hpp>
#include "QueueManager.hpp"
#include "DrawcallRecording.hpp"
namespace vkcv
{
......@@ -39,9 +40,9 @@ namespace vkcv
static Context create(const char *applicationName,
uint32_t applicationVersion,
std::vector<vk::QueueFlagBits> queueFlags,
std::vector<const char *> instanceExtensions,
std::vector<const char *> deviceExtensions);
const std::vector<vk::QueueFlagBits>& queueFlags,
const std::vector<const char *>& instanceExtensions,
const std::vector<const char *>& deviceExtensions);
private:
/**
......
......@@ -138,9 +138,9 @@ namespace vkcv
static Core create(Window &window,
const char *applicationName,
uint32_t applicationVersion,
std::vector<vk::QueueFlagBits> queueFlags = {},
std::vector<const char*> instanceExtensions = {},
std::vector<const char*> deviceExtensions = {});
const std::vector<vk::QueueFlagBits>& queueFlags = {},
const std::vector<const char*>& instanceExtensions = {},
const std::vector<const char*>& deviceExtensions = {});
/**
* Creates a basic vulkan graphics pipeline using @p config from the pipeline config class and returns it using the @p handle.
......@@ -163,7 +163,7 @@ namespace vkcv
*/
[[nodiscard]]
PipelineHandle createComputePipeline(
const ShaderProgram &config,
const ShaderProgram &shaderProgram,
const std::vector<vk::DescriptorSetLayout> &descriptorSetLayouts);
/**
......@@ -196,11 +196,13 @@ namespace vkcv
* @param minFilter Minimizing filter
* @param mipmapMode Mipmapping filter
* @param addressMode Address mode
* @param mipLodBias Mip level of detail bias
* @return Sampler handle
*/
[[nodiscard]]
SamplerHandle createSampler(SamplerFilterType magFilter, SamplerFilterType minFilter,
SamplerMipmapMode mipmapMode, SamplerAddressMode addressMode);
SamplerMipmapMode mipmapMode, SamplerAddressMode addressMode,
float mipLodBias = 0.0f);
/**
* Creates an #Image with a given format, width, height and depth.
......@@ -223,9 +225,13 @@ namespace vkcv
Multisampling multisampling = Multisampling::None);
[[nodiscard]]
uint32_t getImageWidth(ImageHandle imageHandle);
uint32_t getImageWidth(const ImageHandle& image);
[[nodiscard]]
uint32_t getImageHeight(ImageHandle imageHandle);
uint32_t getImageHeight(const ImageHandle& image);
[[nodiscard]]
vk::Format getImageFormat(const ImageHandle& image);
/** TODO:
* @param setDescriptions
......@@ -243,13 +249,21 @@ namespace vkcv
bool beginFrame(uint32_t& width, uint32_t& height);
void recordDrawcallsToCmdStream(
const CommandStreamHandle cmdStreamHandle,
const CommandStreamHandle cmdStreamHandle,
const PassHandle renderpassHandle,
const PipelineHandle pipelineHandle,
const PushConstants &pushConstants,
const std::vector<DrawcallInfo> &drawcalls,
const std::vector<ImageHandle> &renderTargets);
void recordMeshShaderDrawcalls(
const CommandStreamHandle cmdStreamHandle,
const PassHandle renderpassHandle,
const PipelineHandle pipelineHandle,
const PushConstants& pushConstantData,
const std::vector<MeshShaderDrawcall>& drawcalls,
const std::vector<ImageHandle>& renderTargets);
void recordComputeDispatchToCmdStream(
CommandStreamHandle cmdStream,
PipelineHandle computePipeline,
......@@ -283,15 +297,21 @@ namespace vkcv
const RecordCommandFunction &record,
const FinishCommandFunction &finish);
void submitCommandStream(const CommandStreamHandle handle);
void prepareSwapchainImageForPresent(const CommandStreamHandle handle);
void prepareImageForSampling(const CommandStreamHandle cmdStream, const ImageHandle image);
void prepareImageForStorage(const CommandStreamHandle cmdStream, const ImageHandle image);
void recordImageMemoryBarrier(const CommandStreamHandle cmdStream, const ImageHandle image);
void recordBufferMemoryBarrier(const CommandStreamHandle cmdStream, const BufferHandle buffer);
void resolveMSAAImage(CommandStreamHandle cmdStream, ImageHandle src, ImageHandle dst);
void submitCommandStream(const CommandStreamHandle& handle);
void prepareSwapchainImageForPresent(const CommandStreamHandle& handle);
void prepareImageForSampling(const CommandStreamHandle& cmdStream, const ImageHandle& image);
void prepareImageForStorage(const CommandStreamHandle& cmdStream, const ImageHandle& image);
void recordImageMemoryBarrier(const CommandStreamHandle& cmdStream, const ImageHandle& image);
void recordBufferMemoryBarrier(const CommandStreamHandle& cmdStream, const BufferHandle& buffer);
void resolveMSAAImage(const CommandStreamHandle& cmdStream, const ImageHandle& src, const ImageHandle& dst);
[[nodiscard]]
vk::ImageView getSwapchainImageView() const;
void recordMemoryBarrier(const CommandStreamHandle& cmdStream);
void recordBlitImage(const CommandStreamHandle& cmdStream, const ImageHandle& src, const ImageHandle& dst,
SamplerFilterType filterType);
};
}
......@@ -23,7 +23,9 @@ namespace vkcv
STORAGE_BUFFER,
SAMPLER,
IMAGE_SAMPLED,
IMAGE_STORAGE
IMAGE_STORAGE,
UNIFORM_BUFFER_DYNAMIC,
STORAGE_BUFFER_DYNAMIC
};
/*
......
......@@ -20,16 +20,15 @@ namespace vkcv {
uint32_t mipLevel;
};
struct UniformBufferDescriptorWrite {
inline UniformBufferDescriptorWrite(uint32_t binding, BufferHandle buffer) : binding(binding), buffer(buffer) {};
uint32_t binding;
BufferHandle buffer;
};
struct StorageBufferDescriptorWrite {
inline StorageBufferDescriptorWrite(uint32_t binding, BufferHandle buffer) : binding(binding), buffer(buffer) {};
struct BufferDescriptorWrite {
inline BufferDescriptorWrite(uint32_t binding, BufferHandle buffer, bool dynamic = false,
uint32_t offset = 0, uint32_t size = 0) :
binding(binding), buffer(buffer), dynamic(dynamic), offset(offset), size(size) {};
uint32_t binding;
BufferHandle buffer;
bool dynamic;
uint32_t offset;
uint32_t size;
};
struct SamplerDescriptorWrite {
......@@ -41,8 +40,8 @@ namespace vkcv {
struct DescriptorWrites {
std::vector<SampledImageDescriptorWrite> sampledImageWrites;
std::vector<StorageImageDescriptorWrite> storageImageWrites;
std::vector<UniformBufferDescriptorWrite> uniformBufferWrites;
std::vector<StorageBufferDescriptorWrite> storageBufferWrites;
std::vector<BufferDescriptorWrite> uniformBufferWrites;
std::vector<BufferDescriptorWrite> storageBufferWrites;
std::vector<SamplerDescriptorWrite> samplerWrites;
};
}
\ No newline at end of file
......@@ -13,21 +13,30 @@ namespace vkcv {
vk::Buffer buffer;
};
enum class IndexBitCount{
Bit16,
Bit32
};
struct DescriptorSetUsage {
inline DescriptorSetUsage(uint32_t setLocation, vk::DescriptorSet vulkanHandle) noexcept
: setLocation(setLocation), vulkanHandle(vulkanHandle) {}
inline DescriptorSetUsage(uint32_t setLocation, vk::DescriptorSet vulkanHandle,
const std::vector<uint32_t>& dynamicOffsets = {}) noexcept
: setLocation(setLocation), vulkanHandle(vulkanHandle), dynamicOffsets(dynamicOffsets) {}
const uint32_t setLocation;
const vk::DescriptorSet vulkanHandle;
const uint32_t setLocation;
const vk::DescriptorSet vulkanHandle;
const std::vector<uint32_t> dynamicOffsets;
};
struct Mesh {
inline Mesh(std::vector<VertexBufferBinding> vertexBufferBindings, vk::Buffer indexBuffer, size_t indexCount) noexcept
: vertexBufferBindings(vertexBufferBindings), indexBuffer(indexBuffer), indexCount(indexCount){}
inline Mesh(std::vector<VertexBufferBinding> vertexBufferBindings, vk::Buffer indexBuffer, size_t indexCount, IndexBitCount indexBitCount = IndexBitCount::Bit16) noexcept
: vertexBufferBindings(vertexBufferBindings), indexBuffer(indexBuffer), indexCount(indexCount), indexBitCount(indexBitCount){}
std::vector<VertexBufferBinding> vertexBufferBindings;
vk::Buffer indexBuffer;
size_t indexCount;
IndexBitCount indexBitCount;
};
struct DrawcallInfo {
......@@ -46,4 +55,21 @@ namespace vkcv {
const PushConstants &pushConstants,
const size_t drawcallIndex);
}
\ No newline at end of file
void InitMeshShaderDrawFunctions(vk::Device device);
struct MeshShaderDrawcall {
inline MeshShaderDrawcall(const std::vector<DescriptorSetUsage> descriptorSets, uint32_t taskCount)
: descriptorSets(descriptorSets), taskCount(taskCount) {}
std::vector<DescriptorSetUsage> descriptorSets;
uint32_t taskCount;
};
void recordMeshShaderDrawcall(
vk::CommandBuffer cmdBuffer,
vk::PipelineLayout pipelineLayout,
const PushConstants& pushConstantData,
const uint32_t pushConstantOffset,
const MeshShaderDrawcall& drawcall,
const uint32_t firstTask);
}
#pragma once
#include <functional>
#ifndef __MINGW32__
#include <mutex>
#endif
#include <vector>
namespace vkcv {
......@@ -27,7 +32,10 @@ namespace vkcv {
private:
std::vector< event_function<T...> > m_functions;
uint32_t m_id_counter;
#ifndef __MINGW32__
std::mutex m_mutex;
#endif
public:
......@@ -75,14 +83,18 @@ namespace vkcv {
* locks the event so its function handles won't be called
*/
void lock() {
#ifndef __MINGW32__
m_mutex.lock();
#endif
}
/**
* unlocks the event so its function handles can be called after locking
*/
void unlock() {
#ifndef __MINGW32__
m_mutex.unlock();
#endif
}
explicit event(bool locked = false) {
......
#pragma once
#include <filesystem>
namespace vkcv {
std::filesystem::path generateTemporaryFilePath();
std::filesystem::path generateTemporaryDirectoryPath();
}
......@@ -32,8 +32,8 @@ namespace vkcv {
const std::vector<Queue> &getTransferQueues() const;
static void queueCreateInfosQueueHandles(vk::PhysicalDevice &physicalDevice,
std::vector<float> &queuePriorities,
std::vector<vk::QueueFlagBits> &queueFlags,
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,
......
......@@ -9,7 +9,11 @@ namespace vkcv {
TESS_EVAL,
GEOMETRY,
FRAGMENT,
COMPUTE
COMPUTE,
TASK,
MESH
};
}
Subproject commit eae6e8d3bd4593e0d7071c85fba2a8f33fbe5dab
Subproject commit 3a61240a5354ce56c222969a69825aabb6ba0a21
......@@ -4,6 +4,8 @@ add_subdirectory(asset_loader)
add_subdirectory(camera)
add_subdirectory(gui)
add_subdirectory(material)
add_subdirectory(meshlet)
add_subdirectory(scene)
add_subdirectory(shader_compiler)
add_subdirectory(testing)
add_subdirectory(upscaling)
......@@ -4,18 +4,20 @@ find_package(glm QUIET)
if (glm_FOUND)
list(APPEND vkcv_camera_includes ${GLM_INCLUDE_DIRS})
list(APPEND vkcv_camera_libraries glm)
list(APPEND vkcv_camera_definitions GLM_DEPTH_ZERO_TO_ONE)
list(APPEND vkcv_camera_definitions GLM_FORCE_LEFT_HANDED)
else()
if (EXISTS "${vkcv_camera_lib_path}/glm")
add_subdirectory(${vkcv_camera_lib}/glm)
list(APPEND vkcv_camera_includes ${vkcv_camera_lib_path}/glm)
list(APPEND vkcv_camera_libraries glm)
list(APPEND vkcv_camera_definitions GLM_DEPTH_ZERO_TO_ONE)
list(APPEND vkcv_camera_definitions GLM_FORCE_LEFT_HANDED)
else()
message(WARNING "GLM is required..! Update the submodules!")
endif ()
endif ()
list(APPEND vkcv_camera_definitions GLM_DEPTH_ZERO_TO_ONE)
list(APPEND vkcv_camera_definitions GLM_FORCE_LEFT_HANDED)
if ((WIN32) AND (${CMAKE_SIZEOF_VOID_P} MATCHES 4))
list(APPEND vkcv_camera_definitions GLM_ENABLE_EXPERIMENTAL)
endif()