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 (153)
Showing
with 164 additions and 55 deletions
...@@ -80,4 +80,7 @@ set(vkcv_sources ...@@ -80,4 +80,7 @@ set(vkcv_sources
${vkcv_source}/vkcv/CommandStreamManager.cpp ${vkcv_source}/vkcv/CommandStreamManager.cpp
${vkcv_include}/vkcv/CommandRecordingFunctionTypes.hpp ${vkcv_include}/vkcv/CommandRecordingFunctionTypes.hpp
${vkcv_include}/vkcv/ImageConfig.hpp
${vkcv_source}/vkcv/ImageConfig.cpp
) )
...@@ -78,8 +78,6 @@ namespace vkcv ...@@ -78,8 +78,6 @@ namespace vkcv
event_handle<int,int> e_resizeHandle; event_handle<int,int> e_resizeHandle;
static std::vector<vk::ImageView> createSwapchainImageViews( Context &context, Swapchain& swapChain);
public: public:
/** /**
* Destructor of #Core destroys the Vulkan objects contained in the core's context. * Destructor of #Core destroys the Vulkan objects contained in the core's context.
...@@ -215,13 +213,14 @@ namespace vkcv ...@@ -215,13 +213,14 @@ namespace vkcv
*/ */
[[nodiscard]] [[nodiscard]]
Image createImage( Image createImage(
vk::Format format, vk::Format format,
uint32_t width, uint32_t width,
uint32_t height, uint32_t height,
uint32_t depth = 1, uint32_t depth = 1,
bool createMipChain = false, bool createMipChain = false,
bool supportStorage = false, bool supportStorage = false,
bool supportColorAttachment = false); bool supportColorAttachment = false,
Multisampling multisampling = Multisampling::None);
[[nodiscard]] [[nodiscard]]
const uint32_t getImageWidth(ImageHandle imageHandle); const uint32_t getImageWidth(ImageHandle imageHandle);
...@@ -290,7 +289,8 @@ namespace vkcv ...@@ -290,7 +289,8 @@ namespace vkcv
void prepareImageForStorage(const CommandStreamHandle cmdStream, const ImageHandle image); void prepareImageForStorage(const CommandStreamHandle cmdStream, const ImageHandle image);
void recordImageMemoryBarrier(const CommandStreamHandle cmdStream, const ImageHandle image); void recordImageMemoryBarrier(const CommandStreamHandle cmdStream, const ImageHandle image);
void recordBufferMemoryBarrier(const CommandStreamHandle cmdStream, const BufferHandle buffer); void recordBufferMemoryBarrier(const CommandStreamHandle cmdStream, const BufferHandle buffer);
void resolveMSAAImage(CommandStreamHandle cmdStream, ImageHandle src, ImageHandle dst);
vk::ImageView getSwapchainImageView() const; vk::ImageView getSwapchainImageView() const;
}; };
......
...@@ -37,11 +37,12 @@ namespace vkcv { ...@@ -37,11 +37,12 @@ namespace vkcv {
}; };
struct DrawcallInfo { struct DrawcallInfo {
inline DrawcallInfo(const Mesh& mesh, const std::vector<DescriptorSetUsage>& descriptorSets) inline DrawcallInfo(const Mesh& mesh, const std::vector<DescriptorSetUsage>& descriptorSets, const uint32_t instanceCount = 1)
: mesh(mesh), descriptorSets(descriptorSets) {} : mesh(mesh), descriptorSets(descriptorSets), instanceCount(instanceCount){}
Mesh mesh; Mesh mesh;
std::vector<DescriptorSetUsage> descriptorSets; std::vector<DescriptorSetUsage> descriptorSets;
uint32_t instanceCount;
}; };
void recordDrawcall( void recordDrawcall(
......
...@@ -7,11 +7,11 @@ ...@@ -7,11 +7,11 @@
#include "vulkan/vulkan.hpp" #include "vulkan/vulkan.hpp"
#include "Handles.hpp" #include "Handles.hpp"
#include "vkcv/ImageConfig.hpp"
namespace vkcv { namespace vkcv {
// forward declares class ImageManager;
class ImageManager;
bool isDepthFormat(const vk::Format format); bool isDepthFormat(const vk::Format format);
...@@ -50,15 +50,16 @@ namespace vkcv { ...@@ -50,15 +50,16 @@ namespace vkcv {
Image(ImageManager* manager, const ImageHandle& handle); Image(ImageManager* manager, const ImageHandle& handle);
static Image create( static Image create(
ImageManager* manager, ImageManager* manager,
vk::Format format, vk::Format format,
uint32_t width, uint32_t width,
uint32_t height, uint32_t height,
uint32_t depth, uint32_t depth,
uint32_t mipCount, uint32_t mipCount,
bool supportStorage, bool supportStorage,
bool supportColorAttachment); bool supportColorAttachment,
Multisampling msaa);
}; };
} }
#pragma once
#include <vulkan/vulkan.hpp>
namespace vkcv {
enum class Multisampling { None, MSAA2X, MSAA4X, MSAA8X };
vk::SampleCountFlagBits msaaToVkSampleCountFlag(Multisampling msaa);
uint32_t msaaToSampleCount(Multisampling msaa);
}
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include <vector> #include <vector>
#include <vulkan/vulkan.hpp> #include <vulkan/vulkan.hpp>
#include "ImageConfig.hpp"
namespace vkcv namespace vkcv
{ {
...@@ -45,7 +46,8 @@ namespace vkcv ...@@ -45,7 +46,8 @@ namespace vkcv
struct PassConfig struct PassConfig
{ {
explicit PassConfig(std::vector<AttachmentDescription> attachments) noexcept; explicit PassConfig(std::vector<AttachmentDescription> attachments, Multisampling msaa = Multisampling::None) noexcept;
std::vector<AttachmentDescription> attachments{}; std::vector<AttachmentDescription> attachments{};
Multisampling msaa;
}; };
} }
\ No newline at end of file
...@@ -10,21 +10,35 @@ ...@@ -10,21 +10,35 @@
#include "Handles.hpp" #include "Handles.hpp"
#include "ShaderProgram.hpp" #include "ShaderProgram.hpp"
#include "VertexLayout.hpp" #include "VertexLayout.hpp"
#include "ImageConfig.hpp"
namespace vkcv { namespace vkcv {
enum class PrimitiveTopology{PointList, LineList, TriangleList }; enum class PrimitiveTopology{PointList, LineList, TriangleList };
enum class CullMode{ None, Front, Back };
enum class DepthTest { None, Less, LessEqual, Greater, GreatherEqual, Equal };
// add more as needed
// alternatively we could expose the blend factors directly
enum class BlendMode{ None, Additive };
struct PipelineConfig { struct PipelineConfig {
ShaderProgram m_ShaderProgram; ShaderProgram m_ShaderProgram;
uint32_t m_Width; uint32_t m_Width;
uint32_t m_Height; uint32_t m_Height;
PassHandle m_PassHandle; PassHandle m_PassHandle;
VertexLayout m_VertexLayout; VertexLayout m_VertexLayout;
std::vector<vk::DescriptorSetLayout> m_DescriptorLayouts; std::vector<vk::DescriptorSetLayout> m_DescriptorLayouts;
bool m_UseDynamicViewport; bool m_UseDynamicViewport;
bool m_UseConservativeRasterization = false; bool m_UseConservativeRasterization = false;
PrimitiveTopology m_PrimitiveTopology = PrimitiveTopology::TriangleList; PrimitiveTopology m_PrimitiveTopology = PrimitiveTopology::TriangleList;
BlendMode m_blendMode = BlendMode::None;
bool m_EnableDepthClamping = false;
Multisampling m_multisampling = Multisampling::None;
CullMode m_culling = CullMode::None;
DepthTest m_depthTest = DepthTest::LessEqual;
bool m_depthWrite = true;
bool m_alphaToCoverage = false;
}; };
} }
\ No newline at end of file
...@@ -7,6 +7,9 @@ ...@@ -7,6 +7,9 @@
namespace vkcv namespace vkcv
{ {
const uint32_t MIN_SWAPCHAIN_SIZE = 2;
class Swapchain final { class Swapchain final {
private: private:
friend class Core; friend class Core;
...@@ -119,4 +122,5 @@ namespace vkcv ...@@ -119,4 +122,5 @@ namespace vkcv
const vk::Extent2D& getExtent() const; const vk::Extent2D& getExtent() const;
}; };
} }
...@@ -157,6 +157,13 @@ namespace vkcv { ...@@ -157,6 +157,13 @@ namespace vkcv {
* Destructor of #Window, terminates GLFW * Destructor of #Window, terminates GLFW
*/ */
virtual ~Window(); virtual ~Window();
/**
* gets the windows framebuffer size
* @param width
* @param height
*/
void getFramebufferSize(int& width, int& height) const;
}; };
} }
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <vector> #include <vector>
#include <array> #include <array>
#include <cstdint> #include <cstdint>
#include <filesystem>
/** These macros define limits of the following structs. Implementations can /** These macros define limits of the following structs. Implementations can
* test against these limits when performing sanity checks. The main constraint * test against these limits when performing sanity checks. The main constraint
...@@ -114,7 +115,8 @@ enum class PrimitiveType : uint32_t { ...@@ -114,7 +115,8 @@ enum class PrimitiveType : uint32_t {
POSITION = 1, POSITION = 1,
NORMAL = 2, NORMAL = 2,
TEXCOORD_0 = 3, TEXCOORD_0 = 3,
TEXCOORD_1 = 4 TEXCOORD_1 = 4,
TANGENT = 5
}; };
/** These integer values are used the same way in OpenGL, Vulkan and glTF. This /** These integer values are used the same way in OpenGL, Vulkan and glTF. This
...@@ -189,5 +191,12 @@ typedef struct { ...@@ -189,5 +191,12 @@ typedef struct {
* */ * */
int loadScene(const std::string &path, Scene &scene); int loadScene(const std::string &path, Scene &scene);
struct TextureData {
int width;
int height;
int componentCount;
std::vector<char*> data;
};
TextureData loadTexture(const std::filesystem::path& path);
} }
...@@ -63,8 +63,7 @@ enum IndexType getIndexType(const enum fx::gltf::Accessor::ComponentType &t) ...@@ -63,8 +63,7 @@ enum IndexType getIndexType(const enum fx::gltf::Accessor::ComponentType &t)
case fx::gltf::Accessor::ComponentType::UnsignedInt: case fx::gltf::Accessor::ComponentType::UnsignedInt:
return IndexType::UINT32; return IndexType::UINT32;
default: default:
std::cerr << "ERROR: Index type not supported: " << vkcv_log(LogLevel::ERROR, "Index type not supported: %u", static_cast<uint16_t>(t));
static_cast<uint16_t>(t) << std::endl;
return IndexType::UNDEFINED; return IndexType::UNDEFINED;
} }
} }
...@@ -174,8 +173,11 @@ int loadScene(const std::string &path, Scene &scene){ ...@@ -174,8 +173,11 @@ int loadScene(const std::string &path, Scene &scene){
attribute.type = PrimitiveType::NORMAL; attribute.type = PrimitiveType::NORMAL;
} else if (attrib.first == "TEXCOORD_0") { } else if (attrib.first == "TEXCOORD_0") {
attribute.type = PrimitiveType::TEXCOORD_0; attribute.type = PrimitiveType::TEXCOORD_0;
} else if (attrib.first == "TEXCOORD_1") { }
else if (attrib.first == "TEXCOORD_1") {
attribute.type = PrimitiveType::TEXCOORD_1; attribute.type = PrimitiveType::TEXCOORD_1;
} else if (attrib.first == "TANGENT") {
attribute.type = PrimitiveType::TANGENT;
} else { } else {
return 0; return 0;
} }
...@@ -363,4 +365,23 @@ int loadScene(const std::string &path, Scene &scene){ ...@@ -363,4 +365,23 @@ int loadScene(const std::string &path, Scene &scene){
return 1; return 1;
} }
TextureData loadTexture(const std::filesystem::path& path) {
TextureData texture;
uint8_t* data = stbi_load(path.string().c_str(), &texture.width, &texture.height, &texture.componentCount, 4);
if (!data) {
vkcv_log(LogLevel::ERROR, "Texture could not be loaded from '%s'", path.c_str());
texture.width = 0;
texture.height = 0;
texture.componentCount = 0;
return texture;
}
texture.data.resize(texture.width * texture.height * 4);
memcpy(texture.data.data(), data, texture.data.size());
return texture;
}
} }
...@@ -75,7 +75,7 @@ namespace vkcv::camera { ...@@ -75,7 +75,7 @@ namespace vkcv::camera {
* @brief Gets the current projection of the camera * @brief Gets the current projection of the camera
* @return The current projection matrix * @return The current projection matrix
*/ */
const glm::mat4& getProjection() const; glm::mat4 getProjection() const;
/** /**
* @brief Gets the model-view-projection matrix of the camera with y-axis-correction applied * @brief Gets the model-view-projection matrix of the camera with y-axis-correction applied
......
...@@ -37,22 +37,22 @@ namespace vkcv::camera { ...@@ -37,22 +37,22 @@ namespace vkcv::camera {
m_view = view; m_view = view;
} }
const glm::mat4& Camera::getProjection() const { const glm::mat4 y_correction(
return m_projection; 1.0f, 0.0f, 0.0f, 0.0f,
0.0f, -1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
);
glm::mat4 Camera::getProjection() const {
return y_correction * m_projection;
} }
void Camera::setProjection(const glm::mat4& projection) { void Camera::setProjection(const glm::mat4& projection) {
m_projection = projection; m_projection = glm::inverse(y_correction) * projection;
} }
glm::mat4 Camera::getMVP() const { glm::mat4 Camera::getMVP() const {
const glm::mat4 y_correction (
1.0f, 0.0f, 0.0f, 0.0f,
0.0f, -1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
);
return y_correction * m_projection * m_view; return y_correction * m_projection * m_view;
} }
......
...@@ -3,5 +3,6 @@ ...@@ -3,5 +3,6 @@
add_subdirectory(bloom) add_subdirectory(bloom)
add_subdirectory(first_triangle) add_subdirectory(first_triangle)
add_subdirectory(first_mesh) add_subdirectory(first_mesh)
add_subdirectory(particle_simulation)
add_subdirectory(first_scene) add_subdirectory(first_scene)
add_subdirectory(voxelization) add_subdirectory(voxelization)
\ No newline at end of file
...@@ -175,8 +175,8 @@ int main(int argc, const char** argv) { ...@@ -175,8 +175,8 @@ int main(int argc, const char** argv) {
std::vector<vkcv::DrawcallInfo> shadowDrawcalls; std::vector<vkcv::DrawcallInfo> shadowDrawcalls;
for (const auto& position : instancePositions) { for (const auto& position : instancePositions) {
modelMatrices.push_back(glm::translate(glm::mat4(1.f), position)); modelMatrices.push_back(glm::translate(glm::mat4(1.f), position));
drawcalls.push_back(vkcv::DrawcallInfo(loadedMesh, { descriptorUsage })); drawcalls.push_back(vkcv::DrawcallInfo(loadedMesh, { descriptorUsage },1));
shadowDrawcalls.push_back(vkcv::DrawcallInfo(loadedMesh, {})); shadowDrawcalls.push_back(vkcv::DrawcallInfo(loadedMesh, {},1));
} }
modelMatrices.back() *= glm::scale(glm::mat4(1.f), glm::vec3(10.f, 1.f, 10.f)); modelMatrices.back() *= glm::scale(glm::mat4(1.f), glm::vec3(10.f, 1.f, 10.f));
......
...@@ -83,6 +83,7 @@ int main(int argc, const char** argv) { ...@@ -83,6 +83,7 @@ int main(int argc, const char** argv) {
firstMeshProgram.addShader(vkcv::ShaderStage::FRAGMENT, std::filesystem::path("resources/shaders/frag.spv")); firstMeshProgram.addShader(vkcv::ShaderStage::FRAGMENT, std::filesystem::path("resources/shaders/frag.spv"));
auto& attributes = mesh.vertexGroups[0].vertexBuffer.attributes; auto& attributes = mesh.vertexGroups[0].vertexBuffer.attributes;
std::sort(attributes.begin(), attributes.end(), [](const vkcv::asset::VertexAttribute& x, const vkcv::asset::VertexAttribute& y) { std::sort(attributes.begin(), attributes.end(), [](const vkcv::asset::VertexAttribute& x, const vkcv::asset::VertexAttribute& y) {
return static_cast<uint32_t>(x.type) < static_cast<uint32_t>(y.type); return static_cast<uint32_t>(x.type) < static_cast<uint32_t>(y.type);
...@@ -149,7 +150,7 @@ int main(int argc, const char** argv) { ...@@ -149,7 +150,7 @@ int main(int argc, const char** argv) {
const vkcv::Mesh renderMesh(vertexBufferBindings, indexBuffer.getVulkanHandle(), mesh.vertexGroups[0].numIndices); const vkcv::Mesh renderMesh(vertexBufferBindings, indexBuffer.getVulkanHandle(), mesh.vertexGroups[0].numIndices);
vkcv::DescriptorSetUsage descriptorUsage(0, core.getDescriptorSet(descriptorSet).vulkanHandle); vkcv::DescriptorSetUsage descriptorUsage(0, core.getDescriptorSet(descriptorSet).vulkanHandle);
vkcv::DrawcallInfo drawcall(renderMesh, { descriptorUsage }); vkcv::DrawcallInfo drawcall(renderMesh, { descriptorUsage },1);
vkcv::camera::CameraManager cameraManager(window); vkcv::camera::CameraManager cameraManager(window);
uint32_t camIndex0 = cameraManager.addCamera(vkcv::camera::ControllerType::PILOT); uint32_t camIndex0 = cameraManager.addCamera(vkcv::camera::ControllerType::PILOT);
......
...@@ -199,7 +199,7 @@ int main(int argc, const char** argv) { ...@@ -199,7 +199,7 @@ int main(int argc, const char** argv) {
vkcv::DescriptorSetUsage descriptorUsage(0, core.getDescriptorSet(descriptorSets[i]).vulkanHandle); vkcv::DescriptorSetUsage descriptorUsage(0, core.getDescriptorSet(descriptorSets[i]).vulkanHandle);
drawcalls.push_back(vkcv::DrawcallInfo(renderMesh, {descriptorUsage})); drawcalls.push_back(vkcv::DrawcallInfo(renderMesh, {descriptorUsage},1));
} }
std::vector<glm::mat4> modelMatrices; std::vector<glm::mat4> modelMatrices;
......
...@@ -167,7 +167,7 @@ int main(int argc, const char** argv) { ...@@ -167,7 +167,7 @@ int main(int argc, const char** argv) {
vkcv::ImageHandle swapchainImageHandle = vkcv::ImageHandle::createSwapchainImageHandle(); vkcv::ImageHandle swapchainImageHandle = vkcv::ImageHandle::createSwapchainImageHandle();
const vkcv::Mesh renderMesh({}, triangleIndexBuffer.getVulkanHandle(), 3); const vkcv::Mesh renderMesh({}, triangleIndexBuffer.getVulkanHandle(), 3);
vkcv::DrawcallInfo drawcall(renderMesh, {}); vkcv::DrawcallInfo drawcall(renderMesh, {},1);
const vkcv::ImageHandle swapchainInput = vkcv::ImageHandle::createSwapchainImageHandle(); const vkcv::ImageHandle swapchainInput = vkcv::ImageHandle::createSwapchainImageHandle();
......
particle_simulation
\ No newline at end of file
cmake_minimum_required(VERSION 3.16)
project(particle_simulation)
# setting c++ standard for the project
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# this should fix the execution path to load local files from the project
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
# adding source files to the project
add_executable(particle_simulation
src/main.cpp
src/ParticleSystem.hpp
src/ParticleSystem.cpp
src/Particle.hpp
src/Particle.cpp
src/BloomAndFlares.hpp
src/BloomAndFlares.cpp)
# this should fix the execution path to load local files from the project (for MSVC)
if(MSVC)
set_target_properties(particle_simulation PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set_target_properties(particle_simulation PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
# in addition to setting the output directory, the working directory has to be set
# by default visual studio sets the working directory to the build directory, when using the debugger
set_target_properties(particle_simulation PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif()
# including headers of dependencies and the VkCV framework
target_include_directories(particle_simulation SYSTEM BEFORE PRIVATE ${vkcv_include} ${vkcv_includes} ${vkcv_testing_include} ${vkcv_camera_include} ${vkcv_shader_compiler_include})
# linking with libraries from all dependencies and the VkCV framework
target_link_libraries(particle_simulation vkcv vkcv_testing vkcv_camera vkcv_shader_compiler)