Skip to content
Snippets Groups Projects
Commit f402639c authored by Alexander Gauggel's avatar Alexander Gauggel
Browse files

[#52] Add check to only reflect vertex input when reflecting vertex shader

parent fe9d5779
No related branches found
No related tags found
1 merge request!41Resolve "Pass additional vertex attributes to cube shader"
...@@ -110,22 +110,24 @@ namespace vkcv { ...@@ -110,22 +110,24 @@ namespace vkcv {
spirv_cross::Compiler comp(move(shaderCode)); spirv_cross::Compiler comp(move(shaderCode));
spirv_cross::ShaderResources resources = comp.get_shader_resources(); spirv_cross::ShaderResources resources = comp.get_shader_resources();
std::vector<VertexInputAttachment> inputVec; if (shaderStage == ShaderStage::VERTEX) {
uint32_t offset = 0; std::vector<VertexInputAttachment> inputVec;
uint32_t offset = 0;
for (uint32_t i = 0; i < resources.stage_inputs.size() ; i++){
auto &u = resources.stage_inputs[i]; for (uint32_t i = 0; i < resources.stage_inputs.size(); i++) {
const spirv_cross::SPIRType &base_type = comp.get_type(u.base_type_id); auto& u = resources.stage_inputs[i];
const spirv_cross::SPIRType& base_type = comp.get_type(u.base_type_id);
VertexInputAttachment input = VertexInputAttachment(comp.get_decoration(u.id,spv::DecorationLocation),
0, VertexInputAttachment input = VertexInputAttachment(comp.get_decoration(u.id, spv::DecorationLocation),
convertFormat(base_type.basetype, base_type.vecsize), 0,
offset); convertFormat(base_type.basetype, base_type.vecsize),
inputVec.push_back(input); offset);
offset += base_type.vecsize * base_type.width/8; inputVec.push_back(input);
} offset += base_type.vecsize * base_type.width / 8;
}
m_VertexLayout = VertexLayout(inputVec);
m_VertexLayout = VertexLayout(inputVec);
}
} }
const VertexLayout& ShaderProgram::getVertexLayout() const{ const VertexLayout& ShaderProgram::getVertexLayout() const{
......
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