Commit 827a2edf authored by Leonie Charlotte Franken's avatar Leonie Charlotte Franken
Browse files

[#36] basic DescriptorSet Reflection

parent ff713793
Pipeline #25386 passed with stages
in 3 minutes and 36 seconds
......@@ -72,4 +72,6 @@ set(vkcv_sources
${vkcv_source}/vkcv/SamplerManager.cpp
${vkcv_include}/vkcv/DescriptorWrites.hpp
${vkcv_include}/vkcv/DescriptorSetLayout.hpp
)
#pragma once
#include <unordered_map>
#include <vector>
#include <iostream>
namespace vkcv{
struct DescriptorSetLayout{
inline DescriptorSetLayout() noexcept: sampledImages(),
storageImages(),
uniformBuffers(),
storageBuffers(),
samplers() {};
inline DescriptorSetLayout(std::vector<uint32_t> sampledImageVec,
std::vector<uint32_t> storageImageVec,
std::vector<uint32_t> uniformBufferVec,
std::vector<uint32_t> storageBufferVec,
std::vector<uint32_t> samplerVec) noexcept:
sampledImages(sampledImageVec),
storageImages(storageImageVec),
uniformBuffers(uniformBufferVec),
storageBuffers(storageBufferVec),
samplers(samplerVec) {};
std::vector<uint32_t> sampledImages;
std::vector<uint32_t> storageImages;
std::vector<uint32_t> uniformBuffers;
std::vector<uint32_t> storageBuffers;
std::vector<uint32_t> samplers;
};
}
......@@ -12,6 +12,7 @@
#include <vulkan/vulkan.hpp>
#include <spirv_cross.hpp>
#include "vkcv/VertexLayout.hpp"
#include "vkcv/DescriptorSetLayout.hpp"
namespace vkcv {
......@@ -59,9 +60,12 @@ namespace vkcv {
const VertexLayout &getVertexLayout() const;
const DescriptorSetLayout &getDescriptorSetLayout() const;
private:
std::unordered_map<ShaderStage, Shader> m_Shaders;
VertexLayout m_VertexLayout;
DescriptorSetLayout m_DescriptorSetLayout;
};
}
......@@ -66,7 +66,8 @@ namespace vkcv {
ShaderProgram::ShaderProgram() noexcept :
m_Shaders{},
m_VertexLayout{}
m_VertexLayout{},
m_DescriptorSetLayout{}
{}
bool ShaderProgram::addShader(ShaderStage shaderStage, const std::filesystem::path &shaderPath)
......@@ -125,12 +126,50 @@ namespace vkcv {
inputVec.push_back(input);
offset += base_type.vecsize * base_type.width / 8;
}
m_VertexLayout = VertexLayout(inputVec);
}
//Descriptor Sets
//Storage buffer, uniform Buffer, storage image, sampled image, sampler (?)
std::vector<uint32_t> sampledImageVec;
for (uint32_t i = 0; i < resources.sampled_images.size(); i++) {
auto &u = resources.sampled_images[i];
sampledImageVec.push_back(comp.get_decoration(u.id, spv::DecorationDescriptorSet));
}
std::vector<uint32_t> storageImageVec;
for (uint32_t i = 0; i < resources.storage_images.size(); i++) {
auto &u = resources.storage_images[i];
storageImageVec.push_back(comp.get_decoration(u.id, spv::DecorationDescriptorSet));
}
std::vector<uint32_t> uniformBufferVec;
for (uint32_t i = 0; i < resources.uniform_buffers.size(); i++) {
auto &u = resources.uniform_buffers[i];
uniformBufferVec.push_back(comp.get_decoration(u.id, spv::DecorationDescriptorSet));
}
std::vector<uint32_t> storageBufferVec;
for (uint32_t i = 0; i < resources.storage_buffers.size(); i++) {
auto &u = resources.storage_buffers[i];
storageBufferVec.push_back(comp.get_decoration(u.id, spv::DecorationDescriptorSet));
}
std::vector<uint32_t> samplerVec;
for (uint32_t i = 0; i < resources.separate_samplers.size(); i++) {
auto &u = resources.separate_samplers[i];
samplerVec.push_back(comp.get_decoration(u.id, spv::DecorationDescriptorSet));
}
m_DescriptorSetLayout = DescriptorSetLayout(sampledImageVec, storageImageVec, uniformBufferVec, storageBufferVec, samplerVec);
}
const VertexLayout& ShaderProgram::getVertexLayout() const{
return m_VertexLayout;
}
const DescriptorSetLayout& ShaderProgram::getDescriptorSetLayout() const {
return m_DescriptorSetLayout;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment