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
......@@ -51,12 +51,6 @@ namespace vkcv
* @return vk flag of the DescriptorType
*/
static vk::DescriptorType convertDescriptorTypeFlag(DescriptorType type);
/**
* Converts the flags of the shader stages from VulkanCV (vkcv) to Vulkan (vk).
* @param[in] vkcv flag of the ShaderStage (see ShaderProgram.hpp)
* @return vk flag of the ShaderStage
*/
static vk::ShaderStageFlagBits convertShaderStageFlag(ShaderStage stage);
/**
* Destroys a specific resource description
......
......@@ -52,8 +52,6 @@ namespace vkcv {
}
}
struct MeshShaderFunctions
{
PFN_vkCmdDrawMeshTasksNV cmdDrawMeshTasks = nullptr;
......
#include "vkcv/FeatureManager.hpp"
#include <stddef.h>
#include <string.h>
#include <type_traits>
namespace vkcv {
#ifdef _MSVC_LANG
#define typeof(var) std::decay<decltype((var))>::type
#endif
#define vkcv_check_init_features2(type)\
type supported; \
vk::PhysicalDeviceFeatures2 query; \
query.setPNext(&supported); \
m_physicalDevice.getFeatures2(&query)
#define vkcv_check_feature(attribute) { \
const char *f = reinterpret_cast<const char*>(&(features)); \
const char *s = reinterpret_cast<const char*>(&(supported)); \
const vk::Bool32* fb = reinterpret_cast<const vk::Bool32*>(f + offsetof(typeof((features)), attribute)); \
const vk::Bool32* sb = reinterpret_cast<const vk::Bool32*>(s + offsetof(typeof((features)), attribute)); \
if ((*fb) && (!*sb)) { \
vkcv_log(((required)? LogLevel::ERROR : LogLevel::WARNING), \
"Feature '" #attribute "' is not supported"); \
return false; \
} \
}
bool FeatureManager::checkSupport(const vk::PhysicalDeviceFeatures &features, bool required) const {
const auto& supported = m_physicalDevice.getFeatures();
vkcv_check_feature(alphaToOne);
vkcv_check_feature(depthBiasClamp);
vkcv_check_feature(depthBounds);
vkcv_check_feature(depthClamp);
vkcv_check_feature(drawIndirectFirstInstance);
vkcv_check_feature(dualSrcBlend);
vkcv_check_feature(fillModeNonSolid);
vkcv_check_feature(fragmentStoresAndAtomics);
vkcv_check_feature(fullDrawIndexUint32);
vkcv_check_feature(geometryShader);
vkcv_check_feature(imageCubeArray);
vkcv_check_feature(independentBlend);
vkcv_check_feature(inheritedQueries);
vkcv_check_feature(largePoints);
vkcv_check_feature(logicOp);
vkcv_check_feature(multiDrawIndirect);
vkcv_check_feature(multiViewport);
vkcv_check_feature(occlusionQueryPrecise);
vkcv_check_feature(pipelineStatisticsQuery);
vkcv_check_feature(robustBufferAccess);
vkcv_check_feature(sampleRateShading);
vkcv_check_feature(samplerAnisotropy);
vkcv_check_feature(shaderClipDistance);
vkcv_check_feature(shaderCullDistance);
vkcv_check_feature(shaderFloat64);
vkcv_check_feature(shaderImageGatherExtended);
vkcv_check_feature(shaderInt16);
vkcv_check_feature(shaderInt64);
vkcv_check_feature(shaderResourceMinLod);
vkcv_check_feature(shaderResourceResidency);
vkcv_check_feature(shaderSampledImageArrayDynamicIndexing);
vkcv_check_feature(shaderStorageBufferArrayDynamicIndexing);
vkcv_check_feature(shaderStorageImageArrayDynamicIndexing);
vkcv_check_feature(shaderStorageImageExtendedFormats);
vkcv_check_feature(shaderStorageImageMultisample);
vkcv_check_feature(shaderStorageImageReadWithoutFormat);
vkcv_check_feature(shaderStorageImageWriteWithoutFormat);
vkcv_check_feature(shaderTessellationAndGeometryPointSize);
vkcv_check_feature(shaderUniformBufferArrayDynamicIndexing);
vkcv_check_feature(sparseBinding);
vkcv_check_feature(sparseResidency2Samples);
vkcv_check_feature(sparseResidency4Samples);
vkcv_check_feature(sparseResidency8Samples);
vkcv_check_feature(sparseResidency16Samples);
vkcv_check_feature(sparseResidencyAliased);
vkcv_check_feature(sparseResidencyBuffer);
vkcv_check_feature(sparseResidencyImage2D);
vkcv_check_feature(sparseResidencyImage3D);
vkcv_check_feature(tessellationShader);
vkcv_check_feature(textureCompressionASTC_LDR);
vkcv_check_feature(textureCompressionBC);
vkcv_check_feature(textureCompressionETC2);
vkcv_check_feature(variableMultisampleRate);
vkcv_check_feature(vertexPipelineStoresAndAtomics);
vkcv_check_feature(wideLines);
return true;
}
bool FeatureManager::checkSupport(const vk::PhysicalDevice16BitStorageFeatures &features, bool required) const {
vkcv_check_init_features2(vk::PhysicalDevice16BitStorageFeatures);
vkcv_check_feature(storageBuffer16BitAccess);
vkcv_check_feature(storageInputOutput16);
vkcv_check_feature(storagePushConstant16);
vkcv_check_feature(uniformAndStorageBuffer16BitAccess);
return true;
}
bool FeatureManager::checkSupport(const vk::PhysicalDevice8BitStorageFeatures &features, bool required) const {
vkcv_check_init_features2(vk::PhysicalDevice8BitStorageFeatures);
vkcv_check_feature(storageBuffer8BitAccess);
vkcv_check_feature(storagePushConstant8);
vkcv_check_feature(uniformAndStorageBuffer8BitAccess);
return true;
}
bool FeatureManager::checkSupport(const vk::PhysicalDeviceBufferDeviceAddressFeatures &features,
bool required) const {
vkcv_check_init_features2(vk::PhysicalDeviceBufferDeviceAddressFeatures);
vkcv_check_feature(bufferDeviceAddress);
vkcv_check_feature(bufferDeviceAddressCaptureReplay);
vkcv_check_feature(bufferDeviceAddressMultiDevice);
return true;
}
bool FeatureManager::checkSupport(const vk::PhysicalDeviceDescriptorIndexingFeatures &features,
bool required) const {
vkcv_check_init_features2(vk::PhysicalDeviceDescriptorIndexingFeatures);
vkcv_check_feature(shaderInputAttachmentArrayDynamicIndexing);
vkcv_check_feature(shaderInputAttachmentArrayNonUniformIndexing);
vkcv_check_feature(shaderSampledImageArrayNonUniformIndexing);
vkcv_check_feature(shaderStorageBufferArrayNonUniformIndexing);
vkcv_check_feature(shaderStorageImageArrayNonUniformIndexing);
vkcv_check_feature(shaderStorageTexelBufferArrayDynamicIndexing);
vkcv_check_feature(shaderStorageTexelBufferArrayNonUniformIndexing);
vkcv_check_feature(shaderUniformBufferArrayNonUniformIndexing);
vkcv_check_feature(shaderUniformTexelBufferArrayDynamicIndexing);
vkcv_check_feature(shaderUniformTexelBufferArrayNonUniformIndexing);
vkcv_check_feature(descriptorBindingPartiallyBound);
vkcv_check_feature(descriptorBindingSampledImageUpdateAfterBind);
vkcv_check_feature(descriptorBindingStorageBufferUpdateAfterBind);
vkcv_check_feature(descriptorBindingStorageImageUpdateAfterBind);
vkcv_check_feature(descriptorBindingStorageTexelBufferUpdateAfterBind);
vkcv_check_feature(descriptorBindingUniformBufferUpdateAfterBind);
vkcv_check_feature(descriptorBindingUniformTexelBufferUpdateAfterBind);
vkcv_check_feature(descriptorBindingUpdateUnusedWhilePending);
vkcv_check_feature(descriptorBindingVariableDescriptorCount);
vkcv_check_feature(runtimeDescriptorArray);
return true;
}
bool FeatureManager::checkSupport(const vk::PhysicalDeviceHostQueryResetFeatures &features,
bool required) const {
vkcv_check_init_features2(vk::PhysicalDeviceHostQueryResetFeatures);
vkcv_check_feature(hostQueryReset);
return true;
}
bool FeatureManager::checkSupport(const vk::PhysicalDeviceImagelessFramebufferFeatures &features,
bool required) const {
vkcv_check_init_features2(vk::PhysicalDeviceImagelessFramebufferFeatures);
vkcv_check_feature(imagelessFramebuffer);
return true;
}
bool FeatureManager::checkSupport(const vk::PhysicalDeviceMultiviewFeatures &features,
bool required) const {
vkcv_check_init_features2(vk::PhysicalDeviceMultiviewFeatures);
vkcv_check_feature(multiview);
vkcv_check_feature(multiviewGeometryShader);
vkcv_check_feature(multiviewTessellationShader);
return true;
}
bool FeatureManager::checkSupport(const vk::PhysicalDeviceProtectedMemoryFeatures &features,
bool required) const {
vkcv_check_init_features2(vk::PhysicalDeviceProtectedMemoryFeatures);
vkcv_check_feature(protectedMemory);
return true;
}
bool FeatureManager::checkSupport(const vk::PhysicalDeviceSamplerYcbcrConversionFeatures &features,
bool required) const {
vkcv_check_init_features2(vk::PhysicalDeviceSamplerYcbcrConversionFeatures);
vkcv_check_feature(samplerYcbcrConversion);
return true;
}
bool FeatureManager::checkSupport(const vk::PhysicalDeviceScalarBlockLayoutFeatures &features,
bool required) const {
vkcv_check_init_features2(vk::PhysicalDeviceScalarBlockLayoutFeatures);
vkcv_check_feature(scalarBlockLayout);
return true;
}
bool FeatureManager::checkSupport(const vk::PhysicalDeviceSeparateDepthStencilLayoutsFeatures &features,
bool required) const {
vkcv_check_init_features2(vk::PhysicalDeviceSeparateDepthStencilLayoutsFeatures);
vkcv_check_feature(separateDepthStencilLayouts);
return true;
}
bool FeatureManager::checkSupport(const vk::PhysicalDeviceShaderAtomicInt64Features &features,
bool required) const {
vkcv_check_init_features2(vk::PhysicalDeviceShaderAtomicInt64Features);
vkcv_check_feature(shaderBufferInt64Atomics);
vkcv_check_feature(shaderSharedInt64Atomics);
return true;
}
bool FeatureManager::checkSupport(const vk::PhysicalDeviceShaderFloat16Int8Features &features, bool required) const {
vkcv_check_init_features2(vk::PhysicalDeviceShaderFloat16Int8Features);
vkcv_check_feature(shaderFloat16);
vkcv_check_feature(shaderInt8);
return true;
}
bool FeatureManager::checkSupport(const vk::PhysicalDeviceShaderSubgroupExtendedTypesFeatures &features,
bool required) const {
vkcv_check_init_features2(vk::PhysicalDeviceShaderSubgroupExtendedTypesFeatures);
vkcv_check_feature(shaderSubgroupExtendedTypes);
return true;
}
bool FeatureManager::checkSupport(const vk::PhysicalDeviceTimelineSemaphoreFeatures &features,
bool required) const {
vkcv_check_init_features2(vk::PhysicalDeviceTimelineSemaphoreFeatures);
vkcv_check_feature(timelineSemaphore);
return true;
}
bool FeatureManager::checkSupport(const vk::PhysicalDeviceUniformBufferStandardLayoutFeatures &features,
bool required) const {
vkcv_check_init_features2(vk::PhysicalDeviceUniformBufferStandardLayoutFeatures);
vkcv_check_feature(uniformBufferStandardLayout);
return true;
}
bool FeatureManager::checkSupport(const vk::PhysicalDeviceVariablePointersFeatures &features,
bool required) const {
vkcv_check_init_features2(vk::PhysicalDeviceVariablePointersFeatures);
vkcv_check_feature(variablePointers);
vkcv_check_feature(variablePointersStorageBuffer);
return true;
}
bool FeatureManager::checkSupport(const vk::PhysicalDeviceVulkanMemoryModelFeatures &features,
bool required) const {
vkcv_check_init_features2(vk::PhysicalDeviceVulkanMemoryModelFeatures);
vkcv_check_feature(vulkanMemoryModel);
vkcv_check_feature(vulkanMemoryModelDeviceScope);
vkcv_check_feature(vulkanMemoryModelAvailabilityVisibilityChains);
return true;
}
bool FeatureManager::checkSupport(const vk::PhysicalDeviceMeshShaderFeaturesNV &features, bool required) const {
vkcv_check_init_features2(vk::PhysicalDeviceMeshShaderFeaturesNV);
vkcv_check_feature(taskShader);
vkcv_check_feature(meshShader);
return true;
}
vk::BaseOutStructure* FeatureManager::findFeatureStructure(vk::StructureType type) const {
for (auto& base : m_featuresExtensions) {
if (base->sType == type) {
return base;
}
}
return nullptr;
}
const char* strclone(const char* str) {
if (!str) {
return nullptr;
}
const size_t length = strlen(str) + 1;
if (length <= 1) {
return nullptr;
}
char* clone = new char[length];
strcpy(clone, str);
return clone;
}
FeatureManager::FeatureManager(vk::PhysicalDevice &physicalDevice) :
m_physicalDevice(physicalDevice),
m_supportedExtensions(),
m_activeExtensions(),
m_featuresBase(),
m_featuresExtensions() {
for (const auto& extension : m_physicalDevice.enumerateDeviceExtensionProperties()) {
const char* clone = strclone(extension.extensionName);
if (clone) {
m_supportedExtensions.push_back(clone);
}
}
}
FeatureManager::FeatureManager(FeatureManager &&other) noexcept :
m_physicalDevice(other.m_physicalDevice),
m_supportedExtensions(std::move(other.m_supportedExtensions)),
m_activeExtensions(std::move(other.m_activeExtensions)),
m_featuresBase(other.m_featuresBase),
m_featuresExtensions(std::move(other.m_featuresExtensions)) {
other.m_featuresExtensions.clear();
other.m_activeExtensions.clear();
other.m_supportedExtensions.clear();
}
FeatureManager::~FeatureManager() {
for (auto& features : m_featuresExtensions) {
delete features;
}
for (auto& extension : m_activeExtensions) {
delete[] extension;
}
for (auto& extension : m_supportedExtensions) {
delete[] extension;
}
}
FeatureManager &FeatureManager::operator=(FeatureManager &&other) noexcept {
m_physicalDevice = other.m_physicalDevice;
m_supportedExtensions = std::move(other.m_supportedExtensions);
m_activeExtensions = std::move(other.m_activeExtensions);
m_featuresBase = other.m_featuresBase;
m_featuresExtensions = std::move(other.m_featuresExtensions);
other.m_featuresExtensions.clear();
other.m_activeExtensions.clear();
other.m_supportedExtensions.clear();
return *this;
}
bool FeatureManager::isExtensionSupported(const std::string& extension) const {
for (const auto& supported : m_supportedExtensions) {
if (0 == strcmp(supported, extension.c_str())) {
return true;
}
}
return false;
}
bool FeatureManager::useExtension(const std::string& extension, bool required) {
const char* clone = strclone(extension.c_str());
if (!clone) {
vkcv_log(LogLevel::WARNING, "Extension '%s' is not valid", extension.c_str());
return false;
}
if (!isExtensionSupported(extension)) {
vkcv_log((required? LogLevel::ERROR : LogLevel::WARNING), "Extension '%s' is not supported",
extension.c_str());
delete[] clone;
return false;
}
m_activeExtensions.push_back(clone);
return true;
}
bool FeatureManager::isExtensionActive(const std::string& extension) const {
for (const auto& supported : m_activeExtensions) {
if (0 == strcmp(supported, extension.c_str())) {
return true;
}
}
return false;
}
const std::vector<const char*>& FeatureManager::getActiveExtensions() const {
return m_activeExtensions;
}
bool FeatureManager::useFeatures(const std::function<void(vk::PhysicalDeviceFeatures &)> &featureFunction,
bool required) {
vk::PhysicalDeviceFeatures features = m_featuresBase.features;
featureFunction(features);
if (!checkSupport(features, required)) {
return false;
}
m_featuresBase.features = features;
return true;
}
const vk::PhysicalDeviceFeatures2& FeatureManager::getFeatures() const {
return m_featuresBase;
}
}
#include "vkcv/Features.hpp"
namespace vkcv {
Features::Features(const std::initializer_list<std::string>& list) : m_features() {
for (const auto& extension : list) {
requireExtension(extension);
}
}
void Features::requireExtension(const std::string& extension) {
m_features.emplace_back([extension](FeatureManager& featureManager) {
return featureManager.useExtension(extension, true);
});
}
void Features::requireExtensionFeature(const std::string &extension,
const std::function<void(vk::PhysicalDeviceFeatures &)> &featureFunction) {
m_features.emplace_back([extension, featureFunction](FeatureManager& featureManager) {
if (featureManager.useExtension(extension, true)) {
return featureManager.useFeatures(featureFunction, true);
} else {
return false;
}
});
}
void Features::requireFeature(const std::function<void(vk::PhysicalDeviceFeatures &)> &featureFunction) {
m_features.emplace_back([featureFunction](FeatureManager& featureManager) {
return featureManager.useFeatures(featureFunction, true);
});
}
void Features::tryExtension(const std::string& extension) {
m_features.emplace_back([extension](FeatureManager& featureManager) {
return featureManager.useExtension(extension, false);
});
}
void Features::tryExtensionFeature(const std::string &extension,
const std::function<void(vk::PhysicalDeviceFeatures &)> &featureFunction) {
m_features.emplace_back([extension, featureFunction](FeatureManager& featureManager) {
if (featureManager.useExtension(extension, false)) {
return featureManager.useFeatures(featureFunction, false);
} else {
return false;
}
});
}
void Features::tryFeature(const std::function<void(vk::PhysicalDeviceFeatures &)> &featureFunction) {
m_features.emplace_back([featureFunction](FeatureManager& featureManager) {
return featureManager.useFeatures(featureFunction, false);
});
}
const std::vector<Feature>& Features::getList() const {
return m_features;
}
}
......@@ -387,7 +387,7 @@ namespace vkcv {
const size_t max_size = std::min(size, image_size);
BufferHandle bufferHandle = m_bufferManager.createBuffer(
BufferType::STAGING, max_size, BufferMemoryType::HOST_VISIBLE
BufferType::STAGING, max_size, BufferMemoryType::HOST_VISIBLE, false
);
m_bufferManager.fillBuffer(bufferHandle, data, max_size, 0);
......
......@@ -44,7 +44,7 @@ namespace vkcv {
std::vector<int> prios;
for(auto flag: queueFlags) {
int prioCount = 0;
for (int i = 0; i < qFamilyProperties.size(); i++) {
for (size_t i = 0; i < qFamilyProperties.size(); i++) {
prioCount += (static_cast<uint32_t>(flag & qFamilyProperties[i].queueFlags) != 0) * qFamilyProperties[i].queueCount;
}
prios.push_back(prioCount);
......@@ -65,10 +65,14 @@ namespace vkcv {
std::vector<std::vector<int>> queueFamilyStatus, initialQueueFamilyStatus;
for (auto qFamily : qFamilyProperties) {
int graphicsCount = int(static_cast<uint32_t>(qFamily.queueFlags & vk::QueueFlagBits::eGraphics) != 0) * qFamily.queueCount;
int computeCount = int(static_cast<uint32_t>(qFamily.queueFlags & vk::QueueFlagBits::eCompute) != 0) * qFamily.queueCount;
int transferCount = int(static_cast<uint32_t>(qFamily.queueFlags & vk::QueueFlagBits::eTransfer) != 0) * qFamily.queueCount;
queueFamilyStatus.push_back({graphicsCount, computeCount, transferCount});
auto graphicsCount = static_cast<uint32_t>(qFamily.queueFlags & vk::QueueFlagBits::eGraphics) != 0? qFamily.queueCount : 0;
auto computeCount = static_cast<uint32_t>(qFamily.queueFlags & vk::QueueFlagBits::eCompute) != 0? qFamily.queueCount : 0;
auto transferCount = static_cast<uint32_t>(qFamily.queueFlags & vk::QueueFlagBits::eTransfer) != 0? qFamily.queueCount : 0;
queueFamilyStatus.push_back({
static_cast<int>(graphicsCount),
static_cast<int>(computeCount),
static_cast<int>(transferCount)
});
}
initialQueueFamilyStatus = queueFamilyStatus;
......
......@@ -195,7 +195,25 @@ namespace vkcv {
if (maxSetID != -1) {
if((int32_t)m_DescriptorSets.size() <= maxSetID) m_DescriptorSets.resize(maxSetID + 1);
for (const auto &binding : bindings) {
m_DescriptorSets[binding.first].push_back(binding.second);
//checking if descriptor has already been reflected in another shader stage
bool bindingFound = false;
uint32_t pos = 0;
for (const auto& descriptor : m_DescriptorSets[binding.first]) {
if (binding.second.bindingID == descriptor.bindingID) {
if (binding.second.descriptorType == descriptor.descriptorType && binding.second.descriptorCount == descriptor.descriptorCount) {
//updating descriptor binding with another shader stage
ShaderStages updatedShaders = descriptor.shaderStages | shaderStage;
DescriptorBinding newBinding = DescriptorBinding(binding.second.bindingID, binding.second.descriptorType, binding.second.descriptorCount, updatedShaders);
m_DescriptorSets[binding.first][pos] = newBinding;
bindingFound = true;
break;
}
else vkcv_log(LogLevel::ERROR, "Included shaders contain resources with same identifier but different type or count");
}
pos++;
}
//append new descriptor if it has not been reflected yet
if(!bindingFound) m_DescriptorSets[binding.first].push_back(binding.second);
}
}
......
......@@ -4,6 +4,7 @@
* @brief Window class to handle a basic rendering surface and input
*/
#include <thread>
#include <vector>
#include <GLFW/glfw3.h>
......@@ -80,12 +81,17 @@ namespace vkcv {
window->e_key.unlock();
window->e_char.unlock();
window->e_gamepad.unlock();
}
}
glfwPollEvents();
// fixes subtle mouse stutter, which is made visible by motion blur
// FIXME: proper solution
// probably caused by main thread locking events before glfw callbacks are executed
std::this_thread::sleep_for(std::chrono::milliseconds(1));
glfwPollEvents();
for (int gamepadIndex = GLFW_JOYSTICK_1; gamepadIndex <= GLFW_JOYSTICK_LAST; gamepadIndex++) {
if (glfwJoystickPresent(gamepadIndex)) {
for (int gamepadIndex = GLFW_JOYSTICK_1; gamepadIndex <= GLFW_JOYSTICK_LAST; gamepadIndex++) {
if (glfwJoystickPresent(gamepadIndex)) {
onGamepadEvent(gamepadIndex);
}
}
......