KhronosGroup / KhronosGroup/glslang
HLSL: structured buffer getter generates broken spirv
- Dominant language
- C++
- Stars
- 3.6k
- Forks
- 989
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 31
Description
Hello,
I'm using a small helper function to retrieve the exposure buffer to read.
```
struct AutoExposureInfos
{
float luminanceFactor;
float targetLuminance;
float minLuminanceLDR;
float maxLuminanceLDR;
float mgLuminanceLDR;
float ev;
float fStop;
uint maxHistogramValue;
};
inline AutoExposureInfos GetAutoExposureParameters( StructuredBuffer buffer )
{
return buffer[0];
}
```
Example:
```
AutoExposureInfos currentExposure = GetAutoExposureParameters( AutoExposureBuffer );
float currentEV = computeEV100FromAvgLuminance( currentExposure.luminanceFactor );
```
It seems to generate broken bytecode, making my vkCreateComputePipelines call to crash in some random assembly code.
I have tried to hardcode the buffer index in the shader ( AutoExposureBuffer[0] ) and it seems to solve the problem.
[Shader Disassembly](https://github.com/KhronosGroup/glslang/files/3030754/FinalPost.vkps.txt)
Contributor guide
Research direction
Start by reproducing the HLSL structured-buffer getter example and comparing its generated shader disassembly with the version that uses AutoExposureBuffer[0] directly. Inspect the generated SPIR-V around the helper's buffer access, then verify that the corrected output can be consumed by vkCreateComputePipelines without crashing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100