The OpenGL® Shading Language, Version 4.60.7 翻译第一章

Chapter 1. Introduction
This document specifies only version 4.60 of the OpenGL Shading Language (GLSL). It requires
__VERSION__ to substitute 460, and requires #version to accept only 460. If #version is declared
with a smaller number, the language accepted is a previous version of the shading language, which
will be supported depending on the version and type of context in the API. See the normative
references for details on what language versions are supported.
Previous versions of the OpenGL Shading Language, as well as the OpenGL ES Shading Language,
are not strict subsets of the version specified here, particularly with respect to precision, namehiding
rules, and treatment of interface variables. See the specification corresponding to a
particular language version for details specific to that version of the language.
Throughout, when generating SPIR-V for consumption by the Vulkan API (see normative
references), this will be said to be targeting Vulkan.
While this specification and the OpenGL Specification are normative for OpenGL Shading
Language, for SPIR-V generation it is still the SPIR-V specification and the SPIR-V client API
specification that are normative for the generated SPIR-V. See the normative references for further
detail.
For SPIR-V generation, the SPIR-V client API specifies the commands used to manipulate SPIR-V
shaders.
Independent offline tool chains will compile GLSL down to the SPIR-V intermediate language. SPIRV
generation is not enabled with a #extension, #version, or a profile. Instead, use of GLSL for SPIRV
is determined by offline tool-chain use. See the documentation of such tools to see how to request
generation of SPIR-V for its client API.
GLSL → SPIR-V compilers must be directed as to what SPIR-V Capabilities are legal at run-time and
give errors for GLSL feature use outside those capabilities. This is also true for implementationdependent
limits that can be error checked by the front-end against built-in constants present in
the GLSL source: the front-end can be informed of such limits, and report errors when they are
exceeded.
SPIR-V features that are not controlled by a SPIR-V capability, but do have an equivalent GLSL
counterpart (stages, built-in functions, types, limits, etc.) are only expected to work on OpenGL
drivers that support the GLSL counterpart.
All references in this specification to the OpenGL Specification are to the Core profile of version 4.6,
unless a different profile is specified.
1.1. Changes
1.1.1. Changes from Revision 6 of GLSL 4.6
• Incorporated the GL_KHR_vulkan_glsl specification.
• Add note in the introduction about presence in drivers of SPIR-V features, as they relate to GLSL

features.
• Clarify it is same location that triggers default-uniform block matching rules. See Uniform
Variable Layout Qualifiers.
1.1.2. Changes from Revision 5 of GLSL 4.6
• Private GLSL issue #34: Clarify/consolidate implicit conversion rules from int → uint to be the
same as explicit construction.
• Private GLSL issue #24: Clarify that barrier() by itself is enough to synchronize both control
flow and memory accesses to shared variables and tessellation control output variables. For
other memory accesses an additional memory barrier is still required.
• Normatively reference IEEE-754 for definitions of floating-point formats.
• Private GLSL issue 36: refract function on double types requires eta argument to have type
double.
• Clarify restrictions on input variables in tessellation and geometry stages.
• Private GLSL issue 15: Clarify the ordering of bindings for arrays of arrays.
• Private GLSL issue 14: Uniform variables need only match at link time if they are statically used.
• For precise computations, the controlling expressions for control flow and ternary operators (
?:) are not included.
1.1.3. Changes from Revision 4 of GLSL 4.6
• Private bug 13012: Clarified that builtin uniform variables might only be available in the
fragment stage.
• Private bug 13837: Ternary and sequence operators may operate on void types.
• Clarified that errors arising from preprocessing must be returned at compile time.
• Clarified that access to any part of a variable constitutes a static use.
• Private GLSL issue 19: A statement is required following any label at the end of a switch.
• Private GLSL issue 26: noise is not valid when compiling for SPIR-V.
• Private GLSL issue 20: length() expressions returning a constant value may not contain side
effects.
• Public OpenGL-API issue 7: Variables can be declared as both readonly and writeonly.
• Private GLSL issue 16: Use of constant expressions within #line directives is undefined.
• Corrected return type of imageAtomicExchange on float images.
• Private GLSL issue 32: Remove length() method contradiction: Non runtime-sized arrays only
support length() on explicitly sized arrays.
• Private GLSL issue 21: Clarified the l-value restriction on interpolateAt.
• Private OpenGL-API issue 53: Clarified bit-width requirements for location aliasing.
• Public GLSL issue 15: gl_in can be redeclared using unsized-array syntax.
• Clarification of the formats needed for DEPTH_COMPONENT and STENCIL_COMPONENT for

depth/stencil textures.
• Added image formats to the layout-qualifier table in the Layout Qualifiers section.
1.1.4. Changes from Revision 3 of GLSL 4.6
• Private GLSL issue 13: Fix misspelling of allInvocationsEqual(). (The one in the table was
incorrectly listed as anyInvocationsEqual(), other spellings were correct.)
1.1.5. Summary of Changes from Revision 7 of GLSL Version 4.50
• Incorporated the GL_ARB_shader_atomic_counter_ops extension.
• Incorporated the GL_ARB_shader_draw_parameters extension.
• Incorporated the GL_ARB_shader_group_vote extension.
• Incorporated the GL_ARB_gl_spirv extension.
• Private Bug 16070: Allow extra semi-colons at global scope.
• Private GLSL Issue 5: Be explicit that “fail to link” is really “compile-time or link-time error”, for
some forms of error.
• Private GLSL Issue 7: Change gl_MaxComputeUniformComponents to 1024.
• Private OpenGL API Issue 35: Require location on transparent individual uniform variables for
SPIR-V.
• Private GLSL Issue 8: Be more clear an interpolateAt() interpolant can be a structure member.
• Private GLSL Issue 9: Specify how xfb_buffer interacts with a block array: the capturing buffer
increments for each block array element.
1.2. Overview
This document describes The OpenGL Shading Language, version 4.60.
Independent compilation units written in this language are called shaders. A program is a set of
shaders that are compiled and linked together, completely creating one or more of the
programmable stages of the API pipeline. All the shaders for a single programmable stage must be
within the same program. A complete set of programmable stages can be put into a single program
or the stages can be partitioned across multiple programs. The aim of this document is to
thoroughly specify the programming language. The normative references will specify the API entry
points used to manipulate and communicate with programs and shaders.
1.3. Error Handling
Compilers, in general, accept programs that are ill-formed, due to the impossibility of detecting all
ill-formed programs. Portability is only ensured for well-formed programs, which this specification
describes. Compilers are encouraged to detect ill-formed programs and issue diagnostic messages,
but are not required to do so for all cases. Compile-time errors must be returned for lexically or
grammatically incorrect shaders. Other errors are reported at compile time or link time as
indicated. Code that is “dead” must still be error checked. For example:

if (false) // changing false to true cannot uncover additional errors
statement; // statement must be error checked regardless

1.4. Typographical Conventions
Italic, bold, and font choices have been used in this specification primarily to improve readability.
Code fragments use a fixed width font. Identifiers embedded in text are italicized. Keywords
embedded in text are bold. Operators are called by their name, followed by their symbol in bold in
parentheses. The clarifying grammar fragments in the text use bold for literals and italics for nonterminals.
The official grammar in “Shading Language Grammar” uses all capitals for terminals
and lower case for non-terminals.
1.5. Deprecation
The OpenGL Shading Language has deprecated some features. These are clearly called out in this
specification as “deprecated”. They are still present in this version of the language, but are targeted
for potential removal in a future version of the shading language. The OpenGL API has a forward
compatibility mode that will disallow use of deprecated features. If compiling in a mode where use
of deprecated features is disallowed, their use causes compile-time or link-time errors. See the
OpenGL Specification for details on what causes deprecated language features to be accepted or to
return an error.

翻译

第1章。介绍

本文档仅指定了OpenGL着色语言(GLSL)的4.60版本。它需要

__VERSION__来替代460,并且只需要#version来接受460。如果声明了#version

如果数字较小,则接受的语言是阴影语言的前一个版本,它

将根据API中上下文的版本和类型提供支持。看规范

有关支持哪些语言版本的详细信息,请参阅参考资料。

先前版本的OpenGL阴影语言,以及OpenGL ES阴影语言,

不是这里指定的版本的严格子集,特别是关于精度,名称隐藏

规则和接口变量的处理。参见a对应的规范

特定语言版本,以获取特定于该语言版本的详细信息。

在整个过程中,当生产螺旋- v供Vulkan API使用时(见规范)

引用),据说这是针对瓦肯人的。

而这个规范和OpenGL规范是OpenGL着色的规范

语言,对于生成螺旋- v仍然是螺旋- v规范和螺旋- v客户端API

所生成的螺旋- v的规范。请参阅进一步的标准参考

细节。

对于生成螺旋- v,螺旋- v客户端API指定用于操作螺旋- v的命令

着色器。

独立的离线工具链将编译GLSL直至spirv中间语言。SPIRV

没有使用#扩展名、#版本或概要文件来启用生成。相反,使用GLSL治疗SPIRV

由离线工具链的使用决定。请参阅此类工具的文档,了解如何请求

为其客户端API生成spirv。

GLSL→螺旋- v编译器必须明确哪些螺旋- v功能在运行时是合法的

给出在这些功能之外使用GLSL特性的错误。依赖于实现的情况也是如此

中存在的由前端对内置常量进行错误检查的限制

GLSL来源:前端可以被告知此类限制,并在它们出现时报告错误

超过了。

螺旋- v功能不受螺旋- v功能控制,但有一个等效的GLSL

对等物(阶段、内置函数、类型、限制等)只能在OpenGL上工作

支持GLSL对等物的驱动程序。

本规范中所有对OpenGL规范的引用都是对4.6版核心概要的引用,

除非指定了不同的配置文件。

1.1。变化

1.1.1。GLSL 4.6第6版的变更

•合并了GL_KHR_vulkan_glsl规范。

•在介绍中增加了关于出现在spirv特性的驱动程序中的注意事项,因为它们与GLSL有关

特性。

阐明触发default-uniform块匹配规则的位置是相同的。看到制服

变量布局限定符。

1.1.2。GLSL 4.6第5版的变更

•私有GLSL问题#34:澄清/巩固从int到uint的隐式转换规则

与显式结构相同。

•私有GLSL问题#24:澄清barrier()本身足以同步两个控制

流和内存访问共享变量和镶嵌控制输出变量。为

其他内存访问仍然需要一个额外的内存屏障。

•浮点格式定义的规范引用IEEE-754。

•私有GLSL问题36:双类型的折射函数需要eta参数来拥有类型

翻倍。

•阐明在镶嵌和几何阶段输入变量的限制。

•私有GLSL问题15:澄清数组的数组绑定的顺序。

•私有GLSL问题14:统一变量只需要在链接时匹配,如果它们是静态使用的。

•为了精确计算,控制流的控制表达式和三元操作符(

不包括在内。

1.1.3。GLSL 4.6第4版的变更

私人bug 13012:澄清了内置统一变量可能只在

片段的阶段。

•Private bug 13837:三元操作符和序列操作符可以操作void类型。

阐明了由预处理引起的错误必须在编译时返回。

阐明访问变量的任何部分构成静态使用。

•私有GLSL问题19:在交换机的任何标签后面都需要有一个声明。

•Private GLSL issue 26: noise is not valid when compile for spirv

•Private GLSL issue 20: length()表达式返回的常量值可能不包含side

效果。

Public OpenGL-API issue 7:变量可以声明为只读和只读。

没有定义在#line指令中使用常量表达式。

修正了浮动图像的imageAtomicExchange返回类型。

•Private GLSL issue 32:移除length()方法的矛盾:只有非运行时大小的数组

对显式大小的数组支持length()。

•私有GLSL问题21:明确了插值时的l值限制。

•私有OpenGL-API问题53:澄清位置别名的位宽要求。

•公共GLSL问题15:gl_in可以使用无大小数组语法重新声明。

•澄清DEPTH_COMPONENT和STENCIL_COMPONENT的格式

深度/模板纹理。

•在布局限定符部分的布局限定符表中增加了图像格式。

1.1.4。GLSL 4.6第3版的变更

•私有GLSL问题13:修复allInvocationsEqual()的拼写错误。(桌子上的那张是

错误地列出为anyInvocationsEqual(),其他拼写是正确的。)

1.1.5。GLSL版本4.50第7版的变更摘要

•合并了GL_ARB_shader_atomic_counter_ops扩展。

•合并了GL_ARB_shader_draw_parameters扩展名。

•合并了GL_ARB_shader_group_vote扩展名。

•合并了GL_ARB_gl_spirv扩展。

•私有错误16070:允许额外的分号在全局范围。

•私有GLSL问题5:明确“链接失败”是真正的“编译时或链接时错误”,为

一些形式的错误。

•私有GLSL问题7:修改“gl_MaxComputeUniformComponents”为“1024”。

•私有OpenGL API问题35:要求位置在透明的个体统一变量

SPIR-V。

一个interpolateAt()可以是一个结构成员。

•私有GLSL问题9:指定xfb_buffer如何与块数组交互:捕获缓冲区

对每个块数组元素递增。

1.2。概述

本文档描述了OpenGL着色语言,版本4.60。

用这种语言编写的独立编译单元称为着色器。一个程序是一组

编译并链接在一起的着色器,完全创建一个或多个

可编程阶段的API管道。所有的着色器为一个单一的可编程阶段必须

在同一个程序中。一套完整的可编程阶段可以放入一个单独的程序

或者阶段可以跨多个程序进行划分。这个文件的目的是

彻底地指定编程语言。标准引用将指定API条目

用于操作和与程序和着色器通信的点。

1.3。错误处理

通常,编译器接受格式不良的程序,因为不可能检测所有的程序

不规范的程序。可移植性只保证格式良好的程序,这也是本规范的要求

描述了。鼓励编译器检测格式不良的程序并发出诊断信息,

但并不是所有情况都需要这样做。必须返回lexically or的编译时错误

语法不正确的着色器。其他错误在编译时或链接时报告为

表示。“死”的代码仍然必须进行错误检查。例如:

if (false) // changing false to true cannot uncover additional errors
statement; // statement must be error checked regardless

1.4。排版约定

本规范中使用斜体、粗体和字体选择主要是为了提高可读性。

代码片段使用固定宽度的字体。文本中嵌入的标识符是斜体的。关键字

嵌入文本的是粗体。操作符通过其名称和加粗的符号来调用

括号。文本中的澄清语法片段使用粗体表示字面量,斜体表示非终结符。

“阴影语言语法”中的官方语法使用终端的所有大写字母

小写表示非终结符。

1.5。弃用

OpenGL阴影语言已经弃用了一些特性。这些在这里都清楚地标注出来了

规范“弃用”。它们仍然存在于该语言的这个版本中,但是有针对性的

用于在阴影语言的未来版本中进行可能的删除。OpenGL API有一个forward

不允许使用弃用特性的兼容模式。如果在使用的模式下编译

不允许使用已弃用的特性,使用它们会导致编译时或链接时错误。看到

OpenGL规范详细说明了什么导致弃用的语言特性被接受

返回一个错误。

The OpenGL® Shading Language, Version 4.60.7 翻译第一章相关推荐

  1. OpenGL Shading Language 汇总

    overview 用glCreateShader创建一个shader,可以指定shader的类型等信息. 通过glShaderSource导入shader的源文件. 通过glCompileShader ...

  2. [OpenGL红宝书]第一章 OpenGL概述

    第一章 OpenGL概述 标签(空格分隔): OpenGL 第一章 OpenGL概述 1 什么是OpenGL 2 初识OpenGL程序 3 OpenGL语法 4 OpenGL渲染管线 41 准备向Op ...

  3. OpenGL 4.0 Shading Language Cookbook-中文版问世了

    OpenGL 4.0 Shading Language Cookbook-中文版问世了, http://item.taobao.com/item.htm?spm=a230r.1.14.13.K3kTO ...

  4. css画钟表_纯Shading Language绘制HTML5时钟

    今天是2014年的最后一天,这个时刻总会让人想起时钟,再过几个小时地球人都要再老了一岁,于是搞个HTML5版的时钟就是我们今天要完成的任务,实现HTML5的时钟绘制一般会采用三种方式,第一种采用CSS ...

  5. 纯Shading Language绘制飞机火焰效果

    为什么80%的码农都做不了架构师?>>>    上篇<纯Shading Language绘制HTML5时钟>体现了GLSL可编程性特点,但没有体现GLSL可编程出各种酷炫 ...

  6. FPI(公共标识符): owner//class description//language//version

    owner//class description//language//version ISO|+//|-//  DTD|DOCUMENT|... 拥有者        类别     描述      ...

  7. LLMs:《PaLM: Scaling Language Modeling with Pathways》翻译与解读

    LLMs:<PaLM: Scaling Language Modeling with Pathways>翻译与解读 导读:这项工作介绍了Pathways Language Model(Pa ...

  8. 《The C Programming Language》(2nd Ed) Introduction 翻译

    <The C Programming Language>(2nd Ed) Introduction 翻译 说明: 1.       本人非专业翻译人员,信达雅三种境界,可以达到" ...

  9. 《The C Programming Language》答案(第一章)

    <The C Programming Language>答案(第一章) P1 #include <stdio.h> main() {printf("hello, wo ...

最新文章

  1. Ecplise SVN 配置和使用
  2. golang channel 管道
  3. python 变量转字符串_[Python Basic] 字符串处理以及类型转换 2
  4. Mysql使用kill命令解决死锁问题(杀死某条正在执行的sql语句)
  5. 路由器的基本配置实验报告_上了全屋智能,家里路由器不给力,更换路由器时要注意什么...
  6. tomcat默认连接数_Tomcat的默认连接器
  7. Perl,Python,Ruby,Javascript 四种脚本语言比较
  8. Tomcat Caused by java lang OutOfMemoryError PermGen space
  9. 《LabVIEW 虚拟仪器程序设计从入门到精通(第二版)》一导读
  10. Octotree在GitHub中出错
  11. win10您的计算机配置文件,Win10系统开机登录提示无法加载用户配置文件如何解决...
  12. linux安装rtl8192cu网卡驱动,编译并安装rtl8192cu驱动程序
  13. windows查看office软件激活信息
  14. 免费网店系统下载地址
  15. ゼルダの伝説:ブレスオブザワイルド游戏手账
  16. 俄罗斯方块人工智能 [ AI ]
  17. Standard EVB硬件开发指南(1)——LCD接口电路
  18. 【Python】胡渊鸣的99行代码——冰雪奇缘
  19. 容斥定理与鸽巢定理(抽屉定理)
  20. Macbook Apple Silicon 环境及常用软件安装

热门文章

  1. Hadoop实例学习(八)全排序和区排序
  2. 微信前台WEUI前台实例+EXCEL导出,SSM框架完整流程
  3. AI 助力智慧城市发展 | 腾讯视觉峰会回顾
  4. 试用期程序员应该了解的事儿
  5. idea弹窗 Placing the unmodified important.txt in the zip file with the agent jar in the same directo
  6. 西电java实验报告 界面_西电计算机Java上机实验报告.docx
  7. uniapp微信小程序生成带个人二维码的海报
  8. 【OPENCV】运行opencv时找不到Qt库
  9. 高并发高负载网站系统架构
  10. android studio 插入SVG图片