Commit 2d2a35ed authored by Leonie Charlotte Franken's avatar Leonie Charlotte Franken
Browse files

shader reflection attempt throws error Invalid SPIRV format

parent c0d144a2
Pipeline #25139 passed with stages
in 1 minute and 55 seconds
......@@ -10,7 +10,7 @@
#include <iostream>
#include <filesystem>
#include <vulkan/vulkan.hpp>
#include <spirv_glsl.hpp>
#include <spirv_cross.hpp>
namespace vkcv {
......
......@@ -72,6 +72,8 @@ int main(int argc, const char** argv) {
vkcv::ShaderProgram triangleShaderProgram{};
triangleShaderProgram.addShader(vkcv::ShaderStage::VERTEX, std::filesystem::path("shaders/vert.spv"));
triangleShaderProgram.addShader(vkcv::ShaderStage::FRAGMENT, std::filesystem::path("shaders/frag.spv"));
triangleShaderProgram.reflectShader(vkcv::ShaderStage::VERTEX);
triangleShaderProgram.reflectShader(vkcv::ShaderStage::FRAGMENT);
const vkcv::PipelineConfig trianglePipelineDefinition(triangleShaderProgram, windowWidth, windowHeight, trianglePass);
vkcv::PipelineHandle trianglePipeline = core.createGraphicsPipeline(trianglePipelineDefinition);
......
......@@ -62,7 +62,25 @@ namespace vkcv {
void ShaderProgram::reflectShader(ShaderStage shaderStage) const
{
auto shaderCode = m_Shaders.at(shaderStage).shaderCode;
//TODO
auto shaderCodeChar = m_Shaders.at(shaderStage).shaderCode;
std::vector<uint32_t> shaderCode; //convert from char to uint 32. Is this the best way? Prob not.
for (uint32_t i = 0; i < shaderCodeChar.size(); i++) {
shaderCode.push_back((uint32_t) shaderCodeChar[i]);
}
//spirv_cross::Compiler comp(move(shaderCode));
/*
spirv_cross::ShaderResources resources = comp.get_shader_resources();
//testprint
for (auto &u : resources.uniform_buffers)
{
uint32_t set = comp.get_decoration(u.id, spv::DecorationDescriptorSet);
uint32_t binding = comp.get_decoration(u.id, spv::DecorationBinding);
std::cout << 'Found UBO ' << &u << ' at set = ' << set << ', binding = ' << binding << std::endl;
}
*/
}
}
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