加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

TypeQualifier(GLSL)

(2023-03-23 12:34:46)
标签:

it

分类: 技术
A type qualifier is used in the OpenGL Shading Language (GLSL) to modify the storage or behavior of global and locally defined variables. These qualifiers change particular aspects of the variable, such as where they get their data from and so forth. They come in a number of different categories.

Storage qualifiers
- Default
- Constant qualifier
- Shader stage inputs and outputs
  * Interpolation qualifiers
- Uniforms
- Buffer
- Interface blocks
- Shared

Layout qualifiers

Precision qualifiers

Memory qualifiers

Invariance qualifiers

Precise qualifiers

Qualifier order

Unless you are in OpenGL 4.2 or ARB_shading_language_420pack, qualifiers always come in a particular order. For non-parameter values, the order is always this:

invariant-qualifier interpolation-qualifier layout-qualifier other-storage-qualifier precision-qualifier
The centroid qualifier, if present, must immediately precede in or out. For the purpose of ordering, it is considered part of the in or out storage qualifier, not part of the interpolation qualifier.

OpenGL 4.2 or ARB_shading_language_420pack removes the ordering restriction in most cases. centroid still has to immediate precede in or out. It also allows multiple layout qualifiers, but you can still only use one qualifier from most other groups (there can be multiple memory qualifiers). Also, all qualifiers must still come before the type specifier. The groups of qualifiers match the main headings above: storage, layout, precision, etc.

Built-in redeclaration
The GLSL defines a number of predefined variables at the various shader stages. These pre-defined variables are defined with a particular set of qualifiers, as stated in the above article. If you wish to use pre-defined variables with a different qualifier, you can re-declare the variable, but the re-declaration must use the same type. Some variables cannot be redeclared with a new qualifier. For example: gl_Position in the vertex shader cannot use an interpolation qualifier at all.

Removed qualifiers
The following qualifiers are deprecated as of GLSL 1.30 (OpenGL 3.0) and removed from GLSL 1.40 and above.

The attribute qualifier is effectively equivalent to an input qualifier in vertex shaders. It cannot be used in any other shader stage. It cannot be used in interface blocks.

The varying qualifier is equivalent to the input of a fragment shader or the output of a vertex shader. It cannot be used in any other shader stages. It cannot be used in interface blocks.

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有