KhronosGroup / KhronosGroup/glslang
ARB_gpu_shader5 and some other extensions can't be declared under 'written against' versions.
- Dominant language
- C++
- Stars
- 3.6k
- Forks
- 989
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 31
Description
Hi,
I met some confused settings (related to versions and extensions) within current glslang (**summary: we can't declare extension under its specified version**):
For example, according to [Khronos extensions registry](https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_gpu_shader5.txt),
The extension **ARB_gpu_shader5**
"is written against the OpenGL 3.2 (Compatibility Profile)
Specification.
This extension is written against Version 1.50 (Revision 09) of the OpenGL
Shading Language Specification."
**=====> 1.** So that I think it is **legal** to **declare** this extension **under version 150**.
Then, we could also found that this extension is introduced into [OpenGL 3.3 core specification](https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.3.30.pdf) (according to **P1.2.1**, **ARB_shader_bit_encoding** is based on **ARB_gpu_shader5**).
**=====> 2.** Which means if the declared version is **>= 330**, this extension would be opened **automatically**.
**=====> 3.** But currently, glslang would **only check the version** declaration to initialize **symbol table** and **extension behavior states**. Which means the following shader pattern will meet 2 compile errors:
========Test Case=====
#version 150 core
#extension GL_ARB_gpu_shader5 : enable
.....
**uintBitsToFloat**(...);
.....
=======Test Case end===
**Compile errors:**
- **GL_ARB_gpu_shader5** is **not supported**.
- (After we fix error 1) **uintBitsToFloat** is **not defined** ([uintBitsToFloat is defined in ARB_gpu_shader5](https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_gpu_shader5.txt)).
=======Possible Solutions to be discussed=====
1. **uintBitsToFloat** is **registered during initialization** which is only based on **version** and **profile**. So in this example, we could set version for symbols within ARB_gpu_shader5 from 330 to 150. (This common builtin initialization runs only once.)
2. We could then use **setFunctionExtensions** to bind the usage/dependency of **uintBitsToFloat** to our extension under version 150.
3. We may also need to check **extensionBehavior** state machine and other settings to register some existed extensions ( Like "GL_ARB_texture_multisample") when we need to use them.
Would this be right? Or I miss something.
@johnkslang
Best Regards,
Shchchow.
Contributor guide
Research direction
Reproduce the #version 150 core test case with GL_ARB_gpu_shader5 and inspect the common builtin initialization, setFunctionExtensions, and extensionBehavior state machine described in the issue. Determine the intended version and extension handling, then add coverage showing that the extension declaration and uintBitsToFloat are handled consistently.
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
- Needs clarification
- Newbie friendliness
- 25/100