microsoft / microsoft/DirectXShaderCompiler
[SPIR-V] Struct within Mesh Shader Vetex Output crashes spirv generation
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
Hello 🙂
We've got a crash when building mesh shaders for spirv related to how our output vertex setup is constructed. I've got a repro here showing the issue: https://godbolt.org/z/9jYY3z1eE - I took the DX12 sample project and simply moved a few attributes out of the VertexOut and in to another struct and the spirv generation now crashes.
// Adding this struct causes DXC to crash with SPIR-V
struct VertexAttributes
{
float3 PositionVS : POSITION0;
float3 Normal : NORMAL0;
};
struct VertexOut
{
float4 PositionHS : SV_Position;
VertexAttributes attributes;
uint MeshletIndex : COLOR0;
};
The original code looked like this, which does not crash:
struct VertexOut
{
float4 PositionHS : SV_Position;
float3 PositionVS : POSITION0;
float3 Normal : NORMAL0;
uint MeshletIndex : COLOR0;
};
I believe this is the callstack on the crash:
dxcompiler.dll!hlsl::NodeFlags::operator unsigned int(void)
dxcompiler.dll!clang::spirv::SpirvEmitter::assignToMSOutAttribute(class clang::DeclaratorDecl const *,class clang::spirv::SpirvInstruction *,class llvm::SmallVector<class clang::spirv::SpirvInstruction *,4> const &)
dxcompiler.dll!clang::spirv::SpirvEmitter::tryToAssignToMSOutAttrsOrIndices(class clang::Expr const *,class clang::spirv::SpirvInstruction *,class clang::spirv::SpirvInstruction *,bool)
dxcompiler.dll!clang::spirv::SpirvEmitter::processAssignment(class clang::Expr const *,class clang::spirv::SpirvInstruction *,bool,class clang::spirv::SpirvInstruction *,class clang::SourceRange)
dxcompiler.dll!clang::spirv::SpirvEmitter::doBinaryOperator(class clang::BinaryOperator const *)
dxcompiler.dll!clang::spirv::SpirvEmitter::doExpr(class clang::Expr const *,class clang::SourceRange)
dxcompiler.dll!clang::spirv::SpirvEmitter::doStmt(class clang::Stmt const *,class llvm::ArrayRef<class clang::Attr const *>)
dxcompiler.dll!clang::spirv::SpirvEmitter::doStmt(class clang::Stmt const *,class llvm::ArrayRef<class clang::Attr const *>)
dxcompiler.dll!clang::spirv::SpirvEmitter::doIfStmt(class clang::IfStmt const *,class llvm::ArrayRef<class clang::Attr const *>)
dxcompiler.dll!clang::spirv::SpirvEmitter::doStmt(class clang::Stmt const *,class llvm::ArrayRef<class clang::Attr const *>)
dxcompiler.dll!clang::spirv::SpirvEmitter::doStmt(class clang::Stmt const *,class llvm::ArrayRef<class clang::Attr const *>)
dxcompiler.dll!clang::spirv::SpirvEmitter::doFunctionDecl(class clang::FunctionDecl const *)
dxcompiler.dll!clang::spirv::SpirvEmitter::doDecl(class clang::Decl const *)
dxcompiler.dll!clang::spirv::SpirvEmitter::HandleTranslationUnit(class clang::ASTContext &)
dxcompiler.dll!clang::ParseAST(class clang::Sema &,bool,bool)
dxcompiler.dll!clang::ASTFrontendAction::ExecuteAction(void)
dxcompiler.dll!clang::FrontendAction::Execute(void)
As a workaround, we can attempt to try and move our additional vertex data out of the structure but it's a bit of a pain for us to do.
Any support would be greatly appreciated.
I'm running on PC on DXC version dxcompiler.dll: 1.9(5184-21d28f72)(1.9.2602.17) - 1.9.2602.17 (21d28f727)
Thanks!
Alex
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the SPIR-V emitter entry points named in the call stack, especially assignToMSOutAttribute and tryToAssignToMSOutAttrsOrIndices, then reproduce the crash using the Godbolt example. Done means the nested VertexAttributes mesh-shader output compiles to SPIR-V without crashing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100