Skip to content
Snippets Groups Projects
Commit 42123b1c authored by Sebastian Gaida's avatar Sebastian Gaida
Browse files

Merge branch 'develop' into 89-mehrere-fenster-abhangigkeiten-von-core-zu-fenster-swapchain-etc

parents fb55e5cd d5765a0e
No related branches found
No related tags found
1 merge request!90Resolve "Mehrere Fenster, Abhängigkeiten von Core zu Fenster+Swapchain etc"
Pipeline #26923 failed
#pragma once #pragma once
#include <vulkan/vulkan.hpp>
#include "vkcv/Handles.hpp" #include "vkcv/Handles.hpp"
#include "vkcv/ShaderStage.hpp" #include "vkcv/ShaderStage.hpp"
...@@ -41,12 +39,12 @@ namespace vkcv ...@@ -41,12 +39,12 @@ namespace vkcv
uint32_t bindingID, uint32_t bindingID,
DescriptorType descriptorType, DescriptorType descriptorType,
uint32_t descriptorCount, uint32_t descriptorCount,
ShaderStage shaderStage ShaderStages shaderStages
) noexcept; ) noexcept;
uint32_t bindingID; uint32_t bindingID;
DescriptorType descriptorType; DescriptorType descriptorType;
uint32_t descriptorCount; uint32_t descriptorCount;
ShaderStage shaderStage; ShaderStages shaderStages;
}; };
} }
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
#include <vulkan/vulkan.hpp> #include <vulkan/vulkan.hpp>
#include <spirv_cross.hpp> #include <spirv_cross.hpp>
#include "VertexLayout.hpp" #include "VertexLayout.hpp"
#include "ShaderStage.hpp"
#include "DescriptorConfig.hpp" #include "DescriptorConfig.hpp"
#include "ShaderStage.hpp"
namespace vkcv { namespace vkcv {
......
#pragma once #pragma once
namespace vkcv { #include <vulkan/vulkan.hpp>
enum class ShaderStage
{
VERTEX,
TESS_CONTROL,
TESS_EVAL,
GEOMETRY,
FRAGMENT,
COMPUTE,
TASK,
MESH
};
namespace vkcv {
enum class ShaderStage : VkShaderStageFlags {
VERTEX = static_cast<VkShaderStageFlags>(vk::ShaderStageFlagBits::eVertex),
TESS_CONTROL = static_cast<VkShaderStageFlags>(vk::ShaderStageFlagBits::eTessellationControl),
TESS_EVAL = static_cast<VkShaderStageFlags>(vk::ShaderStageFlagBits::eTessellationEvaluation),
GEOMETRY = static_cast<VkShaderStageFlags>(vk::ShaderStageFlagBits::eGeometry),
FRAGMENT = static_cast<VkShaderStageFlags>(vk::ShaderStageFlagBits::eFragment),
COMPUTE = static_cast<VkShaderStageFlags>(vk::ShaderStageFlagBits::eCompute),
TASK = static_cast<VkShaderStageFlags>(vk::ShaderStageFlagBits::eTaskNV),
MESH = static_cast<VkShaderStageFlags>(vk::ShaderStageFlagBits::eMeshNV)
};
using ShaderStages = vk::Flags<ShaderStage>;
constexpr vk::ShaderStageFlags getShaderStageFlags(ShaderStages shaderStages) noexcept {
return vk::ShaderStageFlags(static_cast<VkShaderStageFlags>(shaderStages));
}
constexpr ShaderStages operator|(ShaderStage stage0, ShaderStage stage1) noexcept {
return ShaderStages(stage0) | stage1;
}
constexpr ShaderStages operator&(ShaderStage stage0, ShaderStage stage1) noexcept {
return ShaderStages(stage0) & stage1;
}
constexpr ShaderStages operator^(ShaderStage stage0, ShaderStage stage1) noexcept {
return ShaderStages(stage0) ^ stage1;
}
constexpr ShaderStages operator~(ShaderStage stage) noexcept {
return ~(ShaderStages(stage));
}
} }
...@@ -31,7 +31,7 @@ include(config/GLSLANG.cmake) ...@@ -31,7 +31,7 @@ include(config/GLSLANG.cmake)
target_link_libraries(vkcv_shader_compiler ${vkcv_shader_compiler_libraries} vkcv) target_link_libraries(vkcv_shader_compiler ${vkcv_shader_compiler_libraries} vkcv)
# including headers of dependencies and the VkCV framework # including headers of dependencies and the VkCV framework
target_include_directories(vkcv_shader_compiler SYSTEM BEFORE PRIVATE ${vkcv_shader_compiler_includes} ${vkcv_include}) target_include_directories(vkcv_shader_compiler SYSTEM BEFORE PRIVATE ${vkcv_shader_compiler_includes} ${vkcv_include} ${vkcv_includes})
# add the own include directory for public headers # add the own include directory for public headers
target_include_directories(vkcv_shader_compiler BEFORE PUBLIC ${vkcv_shader_compiler_include}) target_include_directories(vkcv_shader_compiler BEFORE PUBLIC ${vkcv_shader_compiler_include})
...@@ -5,11 +5,11 @@ namespace vkcv { ...@@ -5,11 +5,11 @@ namespace vkcv {
uint32_t bindingID, uint32_t bindingID,
DescriptorType descriptorType, DescriptorType descriptorType,
uint32_t descriptorCount, uint32_t descriptorCount,
ShaderStage shaderStage) noexcept ShaderStages shaderStages) noexcept
: :
bindingID(bindingID), bindingID(bindingID),
descriptorType(descriptorType), descriptorType(descriptorType),
descriptorCount(descriptorCount), descriptorCount(descriptorCount),
shaderStage(shaderStage) {} shaderStages(shaderStages) {}
} }
...@@ -54,7 +54,7 @@ namespace vkcv ...@@ -54,7 +54,7 @@ namespace vkcv
binding.bindingID, binding.bindingID,
convertDescriptorTypeFlag(binding.descriptorType), convertDescriptorTypeFlag(binding.descriptorType),
binding.descriptorCount, binding.descriptorCount,
convertShaderStageFlag(binding.shaderStage)); getShaderStageFlags(binding.shaderStages));
setBindings.push_back(descriptorSetLayoutBinding); setBindings.push_back(descriptorSetLayoutBinding);
} }
...@@ -273,26 +273,6 @@ namespace vkcv ...@@ -273,26 +273,6 @@ namespace vkcv
return vk::DescriptorType::eUniformBuffer; return vk::DescriptorType::eUniformBuffer;
} }
} }
vk::ShaderStageFlagBits DescriptorManager::convertShaderStageFlag(ShaderStage stage) {
switch (stage)
{
case ShaderStage::VERTEX:
return vk::ShaderStageFlagBits::eVertex;
case ShaderStage::FRAGMENT:
return vk::ShaderStageFlagBits::eFragment;
case ShaderStage::TESS_CONTROL:
return vk::ShaderStageFlagBits::eTessellationControl;
case ShaderStage::TESS_EVAL:
return vk::ShaderStageFlagBits::eTessellationEvaluation;
case ShaderStage::GEOMETRY:
return vk::ShaderStageFlagBits::eGeometry;
case ShaderStage::COMPUTE:
return vk::ShaderStageFlagBits::eCompute;
default:
return vk::ShaderStageFlagBits::eAll;
}
}
void DescriptorManager::destroyDescriptorSetById(uint64_t id) { void DescriptorManager::destroyDescriptorSetById(uint64_t id) {
if (id >= m_DescriptorSets.size()) { if (id >= m_DescriptorSets.size()) {
......
...@@ -51,12 +51,6 @@ namespace vkcv ...@@ -51,12 +51,6 @@ namespace vkcv
* @return vk flag of the DescriptorType * @return vk flag of the DescriptorType
*/ */
static vk::DescriptorType convertDescriptorTypeFlag(DescriptorType type); 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 * Destroys a specific resource description
......
...@@ -195,7 +195,25 @@ namespace vkcv { ...@@ -195,7 +195,25 @@ namespace vkcv {
if (maxSetID != -1) { if (maxSetID != -1) {
if((int32_t)m_DescriptorSets.size() <= maxSetID) m_DescriptorSets.resize(maxSetID + 1); if((int32_t)m_DescriptorSets.size() <= maxSetID) m_DescriptorSets.resize(maxSetID + 1);
for (const auto &binding : bindings) { 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);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment