Skip to content

Alignment error compiling HLSL to SPIR-V. #334

Answered by TheMostDiligent
bill-call asked this question in Q&A
Discussion options

You must be logged in to vote

First of all, in this line:

shaderCI.Desc.Name = (std::string("Shader CS - ") + entryPoints[stageIdx]).c_str();

You create a temporary string on stack, which is immediately destroyed, so shaderCI.Desc.Name is a pointer to dead memory.
Note that Core Diligent API is c-compatible, so shaderCI.Desc.Name is a pointer, not std::string
There is GraphicsTypesX.hpp header that contains C++ wrappers, which are easier and safer to use.

As to the topic, this appears to be an issue in GLSLang - it generates the code that does not pass validation by SPIRV-Tools.
Note that indexing in Shaders can only be done on 4-vectors (e.g. float4, uint4). As a rule of thumb, always align you struct members by 4-ve…

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by bill-call
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@bill-call
Comment options

@TheMostDiligent
Comment options

@bill-call
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants