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 (5)
......@@ -29,6 +29,8 @@ set(vkcv_sources
${vkcv_source}/vkcv/ImageManager.hpp
${vkcv_source}/vkcv/ImageManager.cpp
${vkcv_include}/vkcv/Logger.hpp
${vkcv_include}/vkcv/SwapChain.hpp
${vkcv_source}/vkcv/SwapChain.cpp
......
......@@ -6,9 +6,20 @@ if (spirv-cross_FOUND)
message(${vkcv_config_msg} " SPIRV Cross - " ${SPIRV_CROSS_VERSION})
else()
if (EXISTS "${vkcv_lib_path}/SPIRV-Cross")
set(SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS OFF CACHE INTERNAL "")
set(SPIRV_CROSS_SHARED OFF CACHE INTERNAL "")
set(SPIRV_CROSS_STATIC ON CACHE INTERNAL "")
set(SPIRV_CROSS_CLI OFF CACHE INTERNAL "")
set(SPIRV_CROSS_ENABLE_TESTS OFF CACHE INTERNAL "")
set(SPIRV_CROSS_ENABLE_GLSL ON CACHE INTERNAL "")
set(SPIRV_CROSS_ENABLE_HLSL OFF CACHE INTERNAL "")
set(SPIRV_CROSS_ENABLE_MSL OFF CACHE INTERNAL "")
set(SPIRV_CROSS_ENABLE_CPP ON CACHE INTERNAL "")
set(SPIRV_CROSS_ENABLE_REFLECT OFF CACHE INTERNAL "")
set(SPIRV_CROSS_ENABLE_C_API OFF CACHE INTERNAL "")
set(SPIRV_CROSS_ENABLE_UTIL OFF CACHE INTERNAL "")
set(SPIRV_CROSS_SKIP_INSTALL ON CACHE INTERNAL "")
add_subdirectory(${vkcv_lib}/SPIRV-Cross)
......
#pragma once
#include <iostream>
namespace vkcv {
enum class LogLevel {
INFO,
WARNING,
ERROR
};
constexpr auto getLogOutput(LogLevel level) {
switch (level) {
case LogLevel::INFO:
return stdout;
default:
return stderr;
}
}
constexpr const char* getLogName(LogLevel level) {
switch (level) {
case LogLevel::INFO:
return "INFO";
case LogLevel::WARNING:
return "WARNING";
case LogLevel::ERROR:
return "ERROR";
default:
return "UNKNOWN";
}
}
#ifndef NDEBUG
#ifndef VKCV_DEBUG_MESSAGE_LEN
#define VKCV_DEBUG_MESSAGE_LEN 1024
#endif
#ifdef _MSC_VER
#define __PRETTY_FUNCTION__ __FUNCSIG__
#endif
#define vkcv_log(level, ...) { \
char output_message [ \
VKCV_DEBUG_MESSAGE_LEN \
]; \
std::snprintf( \
output_message, \
VKCV_DEBUG_MESSAGE_LEN, \
__VA_ARGS__ \
); \
std::fprintf( \
getLogOutput(level), \
"[%s]: %s [%s, line %d: %s]\n", \
vkcv::getLogName(level), \
output_message, \
__FILE__, \
__LINE__, \
__PRETTY_FUNCTION__ \
); \
}
#else
#define vkcv_log(level, ...) {}
#endif
}
......@@ -7,6 +7,8 @@
#define STBI_ONLY_JPEG
#include <stb_image.h>
#include <vkcv/Logger.hpp>
namespace vkcv::asset {
/**
......@@ -39,11 +41,12 @@ uint8_t convertTypeToInt(const fx::gltf::Accessor::Type type) {
* @param path path to file that is responsible for error
*/
void print_what (const std::exception& e, const std::string &path) {
fprintf(stderr, "ERROR loading file %s: %s\n", path.c_str(), e.what());
vkcv_log(LogLevel::ERROR, "Loading file %s: %s",
path.c_str(), e.what());
try {
std::rethrow_if_nested(e);
} catch (const std::exception& nested) {
std::cerr << "nested: ";
print_what(nested, path);
}
}
......@@ -121,7 +124,7 @@ int loadMesh(const std::string &path, Mesh &mesh) {
const size_t off = indexBufferView.byteOffset;
const void *const ptr = ((char*)indexBuffer.data.data()) + off;
if (!memcpy(indexBufferData.data(), ptr, indexBufferView.byteLength)) {
std::cerr << "ERROR copying index buffer data.\n";
vkcv_log(LogLevel::ERROR, "Copying index buffer data");
return 0;
}
}
......@@ -136,7 +139,7 @@ int loadMesh(const std::string &path, Mesh &mesh) {
const size_t off = 0;
const void *const ptr = ((char*)vertexBuffer.data.data()) + off;
if (!memcpy(vertexBufferData.data(), ptr, vertexBuffer.byteLength)) {
std::cerr << "ERROR copying vertex buffer data.\n";
vkcv_log(LogLevel::ERROR, "Copying vertex buffer data");
return 0;
}
}
......@@ -150,9 +153,8 @@ int loadMesh(const std::string &path, Mesh &mesh) {
case fx::gltf::Accessor::ComponentType::UnsignedInt:
indexType = UINT32; break;
default:
std::cerr << "ERROR: Index type not supported: " <<
static_cast<uint16_t>(indexAccessor.componentType) <<
std::endl;
vkcv_log(LogLevel::ERROR, "Index type (%u) not supported",
static_cast<uint16_t>(indexAccessor.componentType));
return 0;
}
......
#include "vkcv/CommandResources.hpp"
#include <iostream>
#include "vkcv/Logger.hpp"
namespace vkcv {
......@@ -62,7 +63,7 @@ namespace vkcv {
return queueManager.getPresentQueue();
}
else {
std::cerr << "getQueueForSubmit error: unknown queue type" << std::endl;
vkcv_log(LogLevel::ERROR, "Unknown queue type");
return queueManager.getGraphicsQueues().front(); // graphics is the most general queue
}
}
......
#include "vkcv/CommandStreamManager.hpp"
#include "vkcv/Core.hpp"
#include "vkcv/Logger.hpp"
namespace vkcv {
CommandStreamManager::CommandStreamManager() noexcept : m_core(nullptr){}
......@@ -14,7 +16,7 @@ namespace vkcv {
void CommandStreamManager::init(Core* core) {
if (!core) {
std::cerr << "Error: CommandStreamManager::init requires valid core pointer" << std::endl;
vkcv_log(LogLevel::ERROR, "Requires valid core pointer");
}
m_core = core;
}
......@@ -57,7 +59,7 @@ namespace vkcv {
const size_t id = handle.getId();
if (id >= m_commandStreams.size()) {
std::cerr << "Error: CommandStreamManager::recordCommandsToStream requires valid handle" << std::endl;
vkcv_log(LogLevel::ERROR, "Requires valid handle");
return;
}
......@@ -71,7 +73,7 @@ namespace vkcv {
const size_t id = handle.getId();
if (id >= m_commandStreams.size()) {
std::cerr << "Error: CommandStreamManager::addFinishCallbackToStream requires valid handle" << std::endl;
vkcv_log(LogLevel::ERROR, "Requires valid handle");
return;
}
......@@ -86,7 +88,7 @@ namespace vkcv {
const size_t id = handle.getId();
if (id >= m_commandStreams.size()) {
std::cerr << "Error: CommandStreamManager::submitCommandStreamSynchronous requires valid handle" << std::endl;
vkcv_log(LogLevel::ERROR, "Requires valid handle");
return;
}
CommandStream& stream = m_commandStreams[id];
......@@ -111,7 +113,7 @@ namespace vkcv {
vk::CommandBuffer CommandStreamManager::getStreamCommandBuffer(const CommandStreamHandle handle) {
const size_t id = handle.getId();
if (id >= m_commandStreams.size()) {
std::cerr << "Error: CommandStreamManager::submitCommandStreamSynchronous requires valid handle" << std::endl;
vkcv_log(LogLevel::ERROR, "Requires valid handle");
return nullptr;
}
return m_commandStreams[id].cmdBuffer;
......
......@@ -16,6 +16,8 @@
#include "ImageLayoutTransitions.hpp"
#include "vkcv/CommandStreamManager.hpp"
#include "vkcv/Logger.hpp"
namespace vkcv
{
......@@ -125,7 +127,7 @@ namespace vkcv
}
if (result != vk::Result::eSuccess) {
std::cerr << vk::to_string(result) << std::endl;
vkcv_log(LogLevel::ERROR, "%s", vk::to_string(result).c_str());
return Result::ERROR;
}
......@@ -149,7 +151,7 @@ namespace vkcv
}
if (acquireSwapchainImage() != Result::SUCCESS) {
std::cerr << "Acquire failed!" << std::endl;
vkcv_log(LogLevel::ERROR, "Acquire failed");
m_currentSwapchainImageIndex = std::numeric_limits<uint32_t>::max();
}
......@@ -234,7 +236,7 @@ namespace vkcv
1);
if(m_Context.m_Device.createFramebuffer(&createInfo, nullptr, &framebuffer) != vk::Result::eSuccess)
{
std::cout << "FAILED TO CREATE TEMPORARY FRAMEBUFFER!" << std::endl;
vkcv_log(LogLevel::ERROR, "Failed to create temporary framebuffer");
return;
}
......@@ -325,7 +327,7 @@ namespace vkcv
}
if (result != vk::Result::eSuccess) {
std::cout << "Error: swapchain present failed... " << vk::to_string(result) << std::endl;
vkcv_log(LogLevel::ERROR, "Swapchain present failed (%s)", vk::to_string(result).c_str());
}
}
......
#include "DescriptorManager.hpp"
#include "vkcv/Logger.hpp"
namespace vkcv
{
DescriptorManager::DescriptorManager(vk::Device device) noexcept:
......@@ -53,7 +55,7 @@ namespace vkcv
vk::DescriptorSetLayoutCreateInfo layoutInfo({}, setBindings);
if(m_Device.createDescriptorSetLayout(&layoutInfo, nullptr, &set.layout) != vk::Result::eSuccess)
{
std::cout << "FAILED TO CREATE DESCRIPTOR SET LAYOUT" << std::endl;
vkcv_log(LogLevel::ERROR, "Failed to create descriptor set layout");
return DescriptorSetHandle();
};
......@@ -69,10 +71,10 @@ namespace vkcv
result = m_Device.allocateDescriptorSets(&allocInfo, &set.vulkanHandle);
}
if (result != vk::Result::eSuccess) {
std::cout << "FAILED TO ALLOCATE DESCRIPTOR SET" << std::endl;
std::cout << vk::to_string(result) << std::endl;
vkcv_log(LogLevel::ERROR, "Failed to create descriptor set (%s)",
vk::to_string(result).c_str());
m_Device.destroy(set.layout);
return DescriptorSetHandle();
}
};
......@@ -239,7 +241,7 @@ namespace vkcv
case DescriptorType::IMAGE_STORAGE:
return vk::DescriptorType::eStorageImage;
default:
std::cerr << "Error: DescriptorManager::convertDescriptorTypeFlag, unknown DescriptorType" << std::endl;
vkcv_log(LogLevel::ERROR, "Unknown DescriptorType");
return vk::DescriptorType::eUniformBuffer;
}
}
......@@ -266,7 +268,7 @@ namespace vkcv
void DescriptorManager::destroyDescriptorSetById(uint64_t id) {
if (id >= m_DescriptorSets.size()) {
std::cerr << "Error: DescriptorManager::destroyResourceDescriptionById invalid id" << std::endl;
vkcv_log(LogLevel::ERROR, "Invalid id");
return;
}
......@@ -282,7 +284,7 @@ namespace vkcv
vk::DescriptorPool pool;
if (m_Device.createDescriptorPool(&m_PoolInfo, nullptr, &pool) != vk::Result::eSuccess)
{
std::cout << "FAILED TO ALLOCATE DESCRIPTOR POOL." << std::endl;
vkcv_log(LogLevel::WARNING, "Failed to allocate descriptor pool");
pool = nullptr;
};
m_Pools.push_back(pool);
......
......@@ -6,6 +6,7 @@
#include "ImageManager.hpp"
#include "vkcv/Core.hpp"
#include "ImageLayoutTransitions.hpp"
#include "vkcv/Logger.hpp"
#include <algorithm>
......@@ -206,7 +207,7 @@ namespace vkcv {
const uint64_t id = handle.getId();
if (id >= m_images.size()) {
std::cerr << "Error: ImageManager::getVulkanImage invalid handle" << std::endl;
vkcv_log(LogLevel::ERROR, "Invalid handle");
return nullptr;
}
......@@ -219,7 +220,7 @@ namespace vkcv {
const uint64_t id = handle.getId();
if (id >= m_images.size()) {
std::cerr << "Error: ImageManager::getVulkanDeviceMemory invalid handle" << std::endl;
vkcv_log(LogLevel::ERROR, "Invalid handle");
return nullptr;
}
......@@ -232,7 +233,7 @@ namespace vkcv {
const uint64_t id = handle.getId();
if (id >= m_images.size()) {
std::cerr << "Error: ImageManager::getVulkanImageView invalid handle" << std::endl;
vkcv_log(LogLevel::ERROR, "Invalid handle");
return nullptr;
}
......@@ -245,7 +246,7 @@ namespace vkcv {
const uint64_t id = handle.getId();
if (id >= m_images.size()) {
std::cerr << "Error: ImageManager::switchImageLayout invalid handle" << std::endl;
vkcv_log(LogLevel::ERROR, "Invalid handle");
return;
}
......@@ -280,7 +281,7 @@ namespace vkcv {
const uint64_t id = handle.getId();
if (id >= m_images.size()) {
std::cerr << "Error: ImageManager::switchImageLayout invalid handle" << std::endl;
vkcv_log(LogLevel::ERROR, "Invalid handle");
return;
}
......@@ -295,7 +296,7 @@ namespace vkcv {
const uint64_t id = handle.getId();
if (id >= m_images.size()) {
std::cerr << "Error: ImageManager::fillImage invalid handle" << std::endl;
vkcv_log(LogLevel::ERROR, "Invalid handle");
return;
}
......@@ -369,7 +370,7 @@ namespace vkcv {
const uint64_t id = handle.getId();
if (id >= m_images.size()) {
std::cerr << "Error: ImageManager::getImageWidth invalid handle" << std::endl;
vkcv_log(LogLevel::ERROR, "Invalid handle");
return 0;
}
......@@ -382,7 +383,7 @@ namespace vkcv {
const uint64_t id = handle.getId();
if (id >= m_images.size()) {
std::cerr << "Error: ImageManager::getImageHeight invalid handle" << std::endl;
vkcv_log(LogLevel::ERROR, "Invalid handle");
return 0;
}
......@@ -395,7 +396,7 @@ namespace vkcv {
const uint64_t id = handle.getId();
if (id >= m_images.size()) {
std::cerr << "Error: ImageManager::getImageDepth invalid handle" << std::endl;
vkcv_log(LogLevel::ERROR, "Invalid handle");
return 0;
}
......@@ -407,7 +408,7 @@ namespace vkcv {
void ImageManager::destroyImageById(uint64_t id)
{
if (id >= m_images.size()) {
std::cerr << "Error: ImageManager::destroyImageById invalid handle" << std::endl;
vkcv_log(LogLevel::ERROR, "Invalid handle");
return;
}
......@@ -436,7 +437,7 @@ namespace vkcv {
const uint64_t id = handle.getId();
if (id >= m_images.size()) {
std::cerr << "Error: ImageManager::destroyImageById invalid handle" << std::endl;
vkcv_log(LogLevel::ERROR, "Invalid handle");
return vk::Format::eUndefined;
}
......
#include "PipelineManager.hpp"
#include "vkcv/Image.hpp"
#include "vkcv/Logger.hpp"
namespace vkcv
{
......@@ -20,15 +21,25 @@ namespace vkcv
// currently assuming default 32 bit formats, no lower precision or normalized variants supported
vk::Format vertexFormatToVulkanFormat(const VertexFormat format) {
switch (format) {
case VertexFormat::FLOAT: return vk::Format::eR32Sfloat;
case VertexFormat::FLOAT2: return vk::Format::eR32G32Sfloat;
case VertexFormat::FLOAT3: return vk::Format::eR32G32B32Sfloat;
case VertexFormat::FLOAT4: return vk::Format::eR32G32B32A32Sfloat;
case VertexFormat::INT: return vk::Format::eR32Sint;
case VertexFormat::INT2: return vk::Format::eR32G32Sint;
case VertexFormat::INT3: return vk::Format::eR32G32B32Sint;
case VertexFormat::INT4: return vk::Format::eR32G32B32A32Sint;
default: std::cerr << "Warning: Unknown vertex format" << std::endl; return vk::Format::eUndefined;
case VertexFormat::FLOAT:
return vk::Format::eR32Sfloat;
case VertexFormat::FLOAT2:
return vk::Format::eR32G32Sfloat;
case VertexFormat::FLOAT3:
return vk::Format::eR32G32B32Sfloat;
case VertexFormat::FLOAT4:
return vk::Format::eR32G32B32A32Sfloat;
case VertexFormat::INT:
return vk::Format::eR32Sint;
case VertexFormat::INT2:
return vk::Format::eR32G32Sint;
case VertexFormat::INT3:
return vk::Format::eR32G32B32Sint;
case VertexFormat::INT4:
return vk::Format::eR32G32B32A32Sint;
default:
vkcv_log(LogLevel::WARNING, "Unknown vertex format");
return vk::Format::eUndefined;
}
}
......@@ -40,7 +51,7 @@ namespace vkcv
const bool existsFragmentShader = config.m_ShaderProgram.existsShader(ShaderStage::FRAGMENT);
if (!(existsVertexShader && existsFragmentShader))
{
std::cout << "Core::createGraphicsPipeline requires vertex and fragment shader code" << std::endl;
vkcv_log(LogLevel::ERROR, "Requires vertex and fragment shader code");
return PipelineHandle();
}
......
......@@ -4,7 +4,7 @@
#include <iostream>
#include "vkcv/QueueManager.hpp"
#include "vkcv/Logger.hpp"
namespace vkcv {
......@@ -95,7 +95,8 @@ namespace vkcv {
found = true;
}
}
std::cerr << "Warning: not enough \"" << vk::to_string(qFlag) << "\"-Queues." << std::endl;
vkcv_log(LogLevel::WARNING, "Not enough %s queues", vk::to_string(qFlag).c_str());
}
break;
case vk::QueueFlagBits::eCompute:
......@@ -116,7 +117,8 @@ namespace vkcv {
found = true;
}
}
std::cerr << "Warning: not enough \"" << vk::to_string(qFlag) << "\"-Queues." << std::endl;
vkcv_log(LogLevel::WARNING, "Not enough %s queues", vk::to_string(qFlag).c_str());
}
break;
case vk::QueueFlagBits::eTransfer:
......@@ -137,7 +139,8 @@ namespace vkcv {
found = true;
}
}
std::cerr << "Warning: not enough \"" << vk::to_string(qFlag) << "\"-Queues." << std::endl;
vkcv_log(LogLevel::WARNING, "Not enough %s queues", vk::to_string(qFlag).c_str());
}
break;
default:
......
......@@ -5,6 +5,7 @@
*/
#include "vkcv/ShaderProgram.hpp"
#include "vkcv/Logger.hpp"
namespace vkcv {
/**
......@@ -17,7 +18,7 @@ namespace vkcv {
{
std::ifstream file(shaderPath.string(), std::ios::ate | std::ios::binary);
if (!file.is_open()) {
std::cout << "The file could not be opened." << std::endl;
vkcv_log(LogLevel::ERROR, "The file could not be opened");
return std::vector<char>{};
}
size_t fileSize = (size_t)file.tellg();
......@@ -60,7 +61,8 @@ namespace vkcv {
default:
break;
}
std::cout << "Shader Program Reflection: unknown Vertex Format" << std::endl;
vkcv_log(LogLevel::WARNING, "Unknown vertex format");
return VertexFormat::FLOAT;
}
......@@ -72,14 +74,15 @@ namespace vkcv {
bool ShaderProgram::addShader(ShaderStage shaderStage, const std::filesystem::path &shaderPath)
{
if(m_Shaders.find(shaderStage) != m_Shaders.end())
std::cout << "Found existing shader stage. Overwriting." << std::endl;
if(m_Shaders.find(shaderStage) != m_Shaders.end()) {
vkcv_log(LogLevel::WARNING, "Overwriting existing shader stage");
}
const std::vector<char> shaderCode = readShaderCode(shaderPath);
if (shaderCode.empty())
return false;
else
{
if (shaderCode.empty()) {
return false;
} else {
Shader shader{shaderCode, shaderStage};
m_Shaders.insert(std::make_pair(shaderStage, shader));
return true;
......
......@@ -3,6 +3,7 @@
//
#include "vkcv/VertexLayout.hpp"
#include "vkcv/Logger.hpp"
namespace vkcv {
uint32_t getFormatSize(VertexFormat format) {
......@@ -24,10 +25,9 @@ namespace vkcv {
case VertexFormat::INT4:
return 16;
default:
break;
vkcv_log(LogLevel::WARNING, "No format given");
return 0;
}
std::cout << "VertexLayout: No format given" << std::endl;
return 0;
}
VertexInputAttachment::VertexInputAttachment(uint32_t location, uint32_t binding, std::string name, VertexFormat format, uint32_t offset) noexcept:
......