KhronosGroup / KhronosGroup/glslang
Add multi-thread safety testing for AST linking and SPIR-V generation
- Dominant language
- C++
- Stars
- 3.6k
- Forks
- 989
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 31
Description
Hello,
I'm looking for documentation/examples regarding multi-threaded shader compilation using the C++ API in in order to compile from GLSL -> SPIRV. In the standalone app there is a use case with the legacy API only.
From early tests I didn't have issues, but I wonder what is the correct/intended way to achieve this. And most importantly, whether it is safe to use the new C++ API in such a multi-threaded way.
e.g., something like
```
parallel_for(0, incomingShaderCode.size(), [](int index)
{
... do setup of the shader (single shader)
TShader* shader = new TShader;
shader->setStringsWithLengthsAndNames(incomingShaderCode[index].code, ...)
shader->parse(...);
... create the program and generate SPIRV
glslang::TProgram& program = *new glslang::TProgram;
program.addShader(shader);
glslang::GlslangToSpv(program.getIntermediate(), ...)
... cleanup
}
````
Thank you in advance.
Contributor guide
Research direction
Begin with the C++ API entry points named in the report—TShader, TProgram, and GlslangToSpv—and compare them with the legacy API path used by the standalone app. Define the intended thread-safety behavior for parallel GLSL-to-SPIR-V compilation and add focused multi-thread coverage for AST linking and SPIR-V generation; the issue does not name files or existing tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers, testing-qa
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100