KhronosGroup / KhronosGroup/glslang
auto-map-bindings generate bindings for non-opaque uniform variables
- Dominant language
- C++
- Stars
- 3.6k
- Forks
- 989
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 31
Description
Inputting the following code `test.vert.glsl`
```
#version 460
uniform float f;
void main()
{
gl_Position = vec4(f, f, f, 1.0);
}
```
glslang generate binding for `uniform float f` with `auto-map-bindings` option.
`OpDecorate %f Binding 0`
But non-opaque uniform variables can't have binding in OpenGL.
Is it a bug?
The command I used:
`glslangValidator.exe --client opengl100 --auto-map-bindings --auto-map-locations test.vert.glsl -o test.spv`
`spirv-dis test.spv -o test.dis`
```
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 10
; Bound: 28
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %main "main" %_ %gl_VertexID %gl_InstanceID
OpSource GLSL 460
OpName %main "main"
OpName %gl_PerVertex "gl_PerVertex"
OpMemberName %gl_PerVertex 0 "gl_Position"
OpMemberName %gl_PerVertex 1 "gl_PointSize"
OpMemberName %gl_PerVertex 2 "gl_ClipDistance"
OpMemberName %gl_PerVertex 3 "gl_CullDistance"
OpName %_ ""
OpName %f "f"
OpName %gl_VertexID "gl_VertexID"
OpName %gl_InstanceID "gl_InstanceID"
OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize
OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance
OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance
OpDecorate %gl_PerVertex Block
OpDecorate %f Location 0
OpDecorate %f DescriptorSet 0
OpDecorate %f Binding 0
OpDecorate %gl_VertexID BuiltIn VertexId
OpDecorate %gl_InstanceID BuiltIn InstanceId
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%uint = OpTypeInt 32 0
%uint_1 = OpConstant %uint 1
%_arr_float_uint_1 = OpTypeArray %float %uint_1
%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1
%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex
%_ = OpVariable %_ptr_Output_gl_PerVertex Output
%int = OpTypeInt 32 1
%int_0 = OpConstant %int 0
%_ptr_UniformConstant_float = OpTypePointer UniformConstant %float
%f = OpVariable %_ptr_UniformConstant_float UniformConstant
%float_1 = OpConstant %float 1
%_ptr_Output_v4float = OpTypePointer Output %v4float
%_ptr_Input_int = OpTypePointer Input %int
%gl_VertexID = OpVariable %_ptr_Input_int Input
%gl_InstanceID = OpVariable %_ptr_Input_int Input
%main = OpFunction %void None %3
%5 = OpLabel
%18 = OpLoad %float %f
%19 = OpLoad %float %f
%20 = OpLoad %float %f
%22 = OpCompositeConstruct %v4float %18 %19 %20 %float_1
%24 = OpAccessChain %_ptr_Output_v4float %_ %int_0
OpStore %24 %22
OpReturn
OpFunctionEnd
```
Contributor guide
Research direction
Start with the `test.vert.glsl` reproducer and run the reported `glslangValidator.exe --client opengl100 --auto-map-bindings --auto-map-locations` command, then inspect the output with `spirv-dis`. Trace how `auto-map-bindings` handles the non-opaque `uniform float f`. Done means determining whether the generated `Binding 0` decoration is incorrect for OpenGL and covering the behavior with an appropriate regression test.
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
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100