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 (78)
Showing
with 117 additions and 28 deletions
...@@ -44,6 +44,9 @@ endif() ...@@ -44,6 +44,9 @@ endif()
# configure everything to use the required dependencies # configure everything to use the required dependencies
include(${vkcv_config}/Libraries.cmake) include(${vkcv_config}/Libraries.cmake)
# set the compile definitions aka preprocessor variables
add_compile_definitions(${vkcv_definitions})
# add modules as targets # add modules as targets
add_subdirectory(modules) add_subdirectory(modules)
...@@ -56,9 +59,6 @@ message("-- Flags: [ ${vkcv_flags} ]") ...@@ -56,9 +59,6 @@ message("-- Flags: [ ${vkcv_flags} ]")
# set the compiler flags for the framework # set the compiler flags for the framework
set(CMAKE_CXX_FLAGS ${vkcv_flags}) set(CMAKE_CXX_FLAGS ${vkcv_flags})
# set the compile definitions aka preprocessor variables
add_compile_definitions(${vkcv_definitions})
# create VkCV framework as static library using all source files # create VkCV framework as static library using all source files
add_library(vkcv STATIC ${vkcv_sources}) add_library(vkcv STATIC ${vkcv_sources})
......
...@@ -10,6 +10,8 @@ if(NOT WIN32) ...@@ -10,6 +10,8 @@ if(NOT WIN32)
list(APPEND vkcv_flags -fopenmp) list(APPEND vkcv_flags -fopenmp)
endif() endif()
list(APPEND vkcv_definitions _USE_MATH_DEFINES)
# some formatted printing # some formatted printing
set(vkcv_config_msg " - Library: ") set(vkcv_config_msg " - Library: ")
......
...@@ -223,6 +223,11 @@ namespace vkcv ...@@ -223,6 +223,11 @@ namespace vkcv
bool supportStorage = false, bool supportStorage = false,
bool supportColorAttachment = false); bool supportColorAttachment = false);
[[nodiscard]]
const uint32_t getImageWidth(ImageHandle imageHandle);
[[nodiscard]]
const uint32_t getImageHeight(ImageHandle imageHandle);
/** TODO: /** TODO:
* @param setDescriptions * @param setDescriptions
* @return * @return
......
...@@ -4,9 +4,12 @@ ...@@ -4,9 +4,12 @@
namespace vkcv { namespace vkcv {
struct SampledImageDescriptorWrite { struct SampledImageDescriptorWrite {
inline SampledImageDescriptorWrite(uint32_t binding, ImageHandle image) : binding(binding), image(image) {}; inline SampledImageDescriptorWrite(uint32_t binding, ImageHandle image, uint32_t mipLevel = 0, bool useGeneralLayout = false)
: binding(binding), image(image), mipLevel(mipLevel), useGeneralLayout(useGeneralLayout) {};
uint32_t binding; uint32_t binding;
ImageHandle image; ImageHandle image;
uint32_t mipLevel;
bool useGeneralLayout;
}; };
struct StorageImageDescriptorWrite { struct StorageImageDescriptorWrite {
...@@ -38,8 +41,8 @@ namespace vkcv { ...@@ -38,8 +41,8 @@ namespace vkcv {
struct DescriptorWrites { struct DescriptorWrites {
std::vector<SampledImageDescriptorWrite> sampledImageWrites; std::vector<SampledImageDescriptorWrite> sampledImageWrites;
std::vector<StorageImageDescriptorWrite> storageImageWrites; std::vector<StorageImageDescriptorWrite> storageImageWrites;
std::vector<UniformBufferDescriptorWrite> uniformBufferWrites; std::vector<UniformBufferDescriptorWrite> uniformBufferWrites;
std::vector<StorageBufferDescriptorWrite> storageBufferWrites; std::vector<StorageBufferDescriptorWrite> storageBufferWrites;
std::vector<SamplerDescriptorWrite> samplerWrites; std::vector<SamplerDescriptorWrite> samplerWrites;
}; };
} }
\ No newline at end of file
#pragma once #pragma once
#include <functional> #include <functional>
#include <mutex>
namespace vkcv { namespace vkcv {
...@@ -26,6 +27,7 @@ namespace vkcv { ...@@ -26,6 +27,7 @@ namespace vkcv {
private: private:
std::vector< event_function<T...> > m_functions; std::vector< event_function<T...> > m_functions;
uint32_t m_id_counter; uint32_t m_id_counter;
std::mutex m_mutex;
public: public:
...@@ -34,9 +36,13 @@ namespace vkcv { ...@@ -34,9 +36,13 @@ namespace vkcv {
* @param arguments of the given function * @param arguments of the given function
*/ */
void operator()(T... arguments) { void operator()(T... arguments) {
lock();
for (auto &function : this->m_functions) { for (auto &function : this->m_functions) {
function.callback(arguments...); function.callback(arguments...);
} }
unlock();
} }
/** /**
...@@ -64,8 +70,26 @@ namespace vkcv { ...@@ -64,8 +70,26 @@ namespace vkcv {
this->m_functions.end() this->m_functions.end()
); );
} }
/**
* locks the event so its function handles won't be called
*/
void lock() {
m_mutex.lock();
}
/**
* unlocks the event so its function handles can be called after locking
*/
void unlock() {
m_mutex.unlock();
}
event() = default; explicit event(bool locked = false) {
if (locked) {
lock();
}
}
event(const event &other) = delete; event(const event &other) = delete;
......
...@@ -42,8 +42,10 @@ namespace vkcv { ...@@ -42,8 +42,10 @@ namespace vkcv {
void generateMipChainImmediate(); void generateMipChainImmediate();
void recordMipChainGeneration(const vkcv::CommandStreamHandle& cmdStream); void recordMipChainGeneration(const vkcv::CommandStreamHandle& cmdStream);
private: private:
ImageManager* const m_manager; // TODO: const qualifier removed, very hacky!!!
const ImageHandle m_handle; // Else you cannot recreate an image. Pls fix.
ImageManager* m_manager;
ImageHandle m_handle;
Image(ImageManager* manager, const ImageHandle& handle); Image(ImageManager* manager, const ImageHandle& handle);
......
#pragma once #pragma once
#include <iostream> #include <stdio.h>
namespace vkcv { namespace vkcv {
...@@ -45,12 +45,12 @@ namespace vkcv { ...@@ -45,12 +45,12 @@ namespace vkcv {
char output_message [ \ char output_message [ \
VKCV_DEBUG_MESSAGE_LEN \ VKCV_DEBUG_MESSAGE_LEN \
]; \ ]; \
std::snprintf( \ snprintf( \
output_message, \ output_message, \
VKCV_DEBUG_MESSAGE_LEN, \ VKCV_DEBUG_MESSAGE_LEN, \
__VA_ARGS__ \ __VA_ARGS__ \
); \ ); \
std::fprintf( \ fprintf( \
getLogOutput(level), \ getLogOutput(level), \
"[%s]: %s [%s, line %d: %s]\n", \ "[%s]: %s [%s, line %d: %s]\n", \
vkcv::getLogName(level), \ vkcv::getLogName(level), \
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#define NOMINMAX #define NOMINMAX
#include <algorithm> #include <algorithm>
#include "Event.hpp" #include "Event.hpp"
struct GLFWwindow; struct GLFWwindow;
...@@ -23,8 +24,6 @@ namespace vkcv { ...@@ -23,8 +24,6 @@ namespace vkcv {
*/ */
explicit Window(GLFWwindow *window); explicit Window(GLFWwindow *window);
static GLFWwindow* createGLFWWindow(const char *windowTitle, int width, int height, bool resizable);
private: private:
/** /**
* mouse callback for moving the mouse on the screen * mouse callback for moving the mouse on the screen
...@@ -42,6 +41,12 @@ namespace vkcv { ...@@ -42,6 +41,12 @@ namespace vkcv {
*/ */
static void onMouseButtonEvent(GLFWwindow *callbackWindow, int button, int action, int mods); static void onMouseButtonEvent(GLFWwindow *callbackWindow, int button, int action, int mods);
/**
* @brief A callback function for handling mouse scrolling events.
* @param[in] callbackWindow The window that received the event.
* @param[in] xoffset The extent of horizontal scrolling.
* @param[in] yoffset The extent of vertical scrolling.
*/
static void onMouseScrollEvent(GLFWwindow *callbackWindow, double xoffset, double yoffset); static void onMouseScrollEvent(GLFWwindow *callbackWindow, double xoffset, double yoffset);
/** /**
...@@ -69,6 +74,12 @@ namespace vkcv { ...@@ -69,6 +74,12 @@ namespace vkcv {
*/ */
static void onCharEvent(GLFWwindow *callbackWindow, unsigned int c); static void onCharEvent(GLFWwindow *callbackWindow, unsigned int c);
/**
* @brief A callback function for gamepad input events.
* @param gamepadIndex The gamepad index.
*/
static void onGamepadEvent(int gamepadIndex);
public: public:
/** /**
* creates a GLFWwindow with the parameters in the function * creates a GLFWwindow with the parameters in the function
...@@ -87,11 +98,6 @@ namespace vkcv { ...@@ -87,11 +98,6 @@ namespace vkcv {
[[nodiscard]] [[nodiscard]]
bool isWindowOpen() const; bool isWindowOpen() const;
/**
* binds windowEvents to lambda events
*/
void initEvents();
/** /**
* polls all events on the GLFWwindow * polls all events on the GLFWwindow
*/ */
...@@ -106,6 +112,7 @@ namespace vkcv { ...@@ -106,6 +112,7 @@ namespace vkcv {
event< int, int > e_resize; event< int, int > e_resize;
event< int, int, int, int > e_key; event< int, int, int, int > e_key;
event< unsigned int > e_char; event< unsigned int > e_char;
event< int > e_gamepad;
/** /**
* returns the current window * returns the current window
...@@ -152,4 +159,4 @@ namespace vkcv { ...@@ -152,4 +159,4 @@ namespace vkcv {
virtual ~Window(); virtual ~Window();
}; };
} }
\ No newline at end of file
# Add new modules here: # Add new modules here:
add_subdirectory(asset_loader) add_subdirectory(asset_loader)
add_subdirectory(material)
add_subdirectory(camera) add_subdirectory(camera)
add_subdirectory(gui) add_subdirectory(gui)
add_subdirectory(shader_compiler) add_subdirectory(shader_compiler)
......
...@@ -38,3 +38,5 @@ target_include_directories(vkcv_asset_loader SYSTEM BEFORE PRIVATE ${vkcv_asset_ ...@@ -38,3 +38,5 @@ target_include_directories(vkcv_asset_loader SYSTEM BEFORE PRIVATE ${vkcv_asset_
# add the own include directory for public headers # add the own include directory for public headers
target_include_directories(vkcv_asset_loader BEFORE PUBLIC ${vkcv_asset_loader_include}) target_include_directories(vkcv_asset_loader BEFORE PUBLIC ${vkcv_asset_loader_include})
target_compile_definitions(vkcv_asset_loader PUBLIC ${vkcv_asset_loader_definitions})
if (EXISTS "${vkcv_asset_loader_lib_path}/stb") if (EXISTS "${vkcv_asset_loader_lib_path}/stb")
list(APPEND vkcv_asset_loader_includes ${vkcv_asset_loader_lib}/stb) list(APPEND vkcv_asset_loader_includes ${vkcv_asset_loader_lib}/stb)
list(APPEND vkcv_asset_loader_definitions STB_IMAGE_IMPLEMENTATION)
list(APPEND vkcv_asset_loader_definitions STBI_ONLY_JPEG)
list(APPEND vkcv_asset_loader_definitions STBI_ONLY_PNG)
else() else()
message(WARNING "STB is required..! Update the submodules!") message(WARNING "STB is required..! Update the submodules!")
endif () endif ()
...@@ -3,9 +3,6 @@ ...@@ -3,9 +3,6 @@
#include <string.h> // memcpy(3) #include <string.h> // memcpy(3)
#include <stdlib.h> // calloc(3) #include <stdlib.h> // calloc(3)
#include <fx/gltf.h> #include <fx/gltf.h>
#define STB_IMAGE_IMPLEMENTATION
#define STBI_ONLY_JPEG
#define STBI_ONLY_PNG
#include <stb_image.h> #include <stb_image.h>
#include <vkcv/Logger.hpp> #include <vkcv/Logger.hpp>
#include <algorithm> #include <algorithm>
......
...@@ -36,3 +36,4 @@ target_include_directories(vkcv_camera SYSTEM BEFORE PRIVATE ${vkcv_camera_inclu ...@@ -36,3 +36,4 @@ target_include_directories(vkcv_camera SYSTEM BEFORE PRIVATE ${vkcv_camera_inclu
# add the own include directory for public headers # add the own include directory for public headers
target_include_directories(vkcv_camera BEFORE PUBLIC ${vkcv_camera_include} ${vkcv_camera_includes}) target_include_directories(vkcv_camera BEFORE PUBLIC ${vkcv_camera_include} ${vkcv_camera_includes})
target_compile_definitions(vkcv_camera PUBLIC ${vkcv_camera_definitions})
...@@ -4,11 +4,17 @@ find_package(glm QUIET) ...@@ -4,11 +4,17 @@ find_package(glm QUIET)
if (glm_FOUND) if (glm_FOUND)
list(APPEND vkcv_camera_includes ${GLM_INCLUDE_DIRS}) list(APPEND vkcv_camera_includes ${GLM_INCLUDE_DIRS})
list(APPEND vkcv_camera_libraries 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() else()
if (EXISTS "${vkcv_camera_lib_path}/glm") if (EXISTS "${vkcv_camera_lib_path}/glm")
add_subdirectory(${vkcv_camera_lib}/glm) add_subdirectory(${vkcv_camera_lib}/glm)
list(APPEND vkcv_camera_libraries 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() else()
message(WARNING "GLM is required..! Update the submodules!") message(WARNING "GLM is required..! Update the submodules!")
endif () endif ()
......
#pragma once #pragma once
#define GLM_DEPTH_ZERO_TO_ONE
#define GLM_FORCE_LEFT_HANDED
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/matrix_access.hpp> #include <glm/gtc/matrix_access.hpp>
......
...@@ -59,6 +59,14 @@ namespace vkcv::camera { ...@@ -59,6 +59,14 @@ namespace vkcv::camera {
* @param[in] camera The camera object. * @param[in] camera The camera object.
*/ */
virtual void mouseButtonCallback(int button, int action, int mods, Camera &camera) = 0; virtual void mouseButtonCallback(int button, int action, int mods, Camera &camera) = 0;
/**
* @brief A callback function for gamepad input events.
* @param gamepadIndex The gamepad index.
* @param camera The camera object.
* @param frametime The current frametime.
*/
virtual void gamepadCallback(int gamepadIndex, Camera &camera, double frametime) = 0;
}; };
} }
\ No newline at end of file
...@@ -30,6 +30,7 @@ namespace vkcv::camera { ...@@ -30,6 +30,7 @@ namespace vkcv::camera {
event_handle<double, double> m_mouseScrollHandle; event_handle<double, double> m_mouseScrollHandle;
event_handle<int, int, int> m_mouseButtonHandle; event_handle<int, int, int> m_mouseButtonHandle;
event_handle<int, int> m_resizeHandle; event_handle<int, int> m_resizeHandle;
event_handle<int> m_gamepadHandle;
Window& m_window; Window& m_window;
std::vector<Camera> m_cameras; std::vector<Camera> m_cameras;
...@@ -42,6 +43,9 @@ namespace vkcv::camera { ...@@ -42,6 +43,9 @@ namespace vkcv::camera {
double m_lastX; double m_lastX;
double m_lastY; double m_lastY;
double m_inputDelayTimer;
double m_frameTime;
/** /**
* @brief Binds the camera object to the window event handles. * @brief Binds the camera object to the window event handles.
*/ */
...@@ -86,6 +90,13 @@ namespace vkcv::camera { ...@@ -86,6 +90,13 @@ namespace vkcv::camera {
* @param[in] height The new height of the window. * @param[in] height The new height of the window.
*/ */
void resizeCallback(int width, int height); void resizeCallback(int width, int height);
/**
* @brief A callback function for gamepad input events. Currently, inputs are handled only for the first
* connected gamepad!
* @param gamepadIndex The gamepad index.
*/
void gamepadCallback(int gamepadIndex);
/** /**
* @brief Gets a camera controller object of specified @p controllerType. * @brief Gets a camera controller object of specified @p controllerType.
......
...@@ -17,6 +17,10 @@ namespace vkcv::camera { ...@@ -17,6 +17,10 @@ namespace vkcv::camera {
bool m_left; bool m_left;
bool m_right; bool m_right;
float m_gamepadX;
float m_gamepadY;
float m_gamepadZ;
bool m_rotationActive; bool m_rotationActive;
float m_cameraSpeed; float m_cameraSpeed;
...@@ -133,6 +137,14 @@ namespace vkcv::camera { ...@@ -133,6 +137,14 @@ namespace vkcv::camera {
* @param[in] camera The camera object. * @param[in] camera The camera object.
*/ */
void mouseButtonCallback(int button, int action, int mods, Camera &camera); void mouseButtonCallback(int button, int action, int mods, Camera &camera);
/**
* @brief A callback function for gamepad input events.
* @param gamepadIndex The gamepad index.
* @param camera The camera object.
* @param frametime The current frametime.
*/
void gamepadCallback(int gamepadIndex, Camera &camera, double frametime);
}; };
} }
\ No newline at end of file
...@@ -95,6 +95,13 @@ namespace vkcv::camera { ...@@ -95,6 +95,13 @@ namespace vkcv::camera {
*/ */
void mouseButtonCallback(int button, int action, int mods, Camera &camera); void mouseButtonCallback(int button, int action, int mods, Camera &camera);
/**
* @brief A callback function for gamepad input events.
* @param gamepadIndex The gamepad index.
* @param camera The camera object.
* @param frametime The current frametime.
*/
void gamepadCallback(int gamepadIndex, Camera &camera, double frametime);
}; };
} }
\ No newline at end of file
#include "vkcv/camera/Camera.hpp" #include "vkcv/camera/Camera.hpp"
#define _USE_MATH_DEFINES
#include <math.h> #include <math.h>
namespace vkcv::camera { namespace vkcv::camera {
......