1. 内建变量gl_Position,gl_PointSize, gl_FrontFacing,
2. 内建uniform gl_DepthRange
3. built-in constants :
gl_MaxVertexAttribs
gl_MaxVertexUniformVectors vertex shader中最大以vec4为计数单位的uniform变量个数,当你在使用某一个内建函数时,有可能已经使用了某个内建uniform,这时,uniform使用计数为+1.当前没有一个机制,在vertex shader中查找到你可以使用的uniform变量个数
gl_MaxVaryingVectors
gl_MaxVertexTextureImageUnits
gl_MaxCombinedTextureImageUnits 最大纹理单元个数,vertex shader ,fragment shader总和
4.vertex shader中,如果未指定,int float的数度都 为highp
5.遵循以下考虑,可以写出更加兼容的代码
.Length of Vertex Shader:没有一个方法 可以查询这个,epengl es 工作组希望有一个兼容性测试,包含对这个的测试
.Temporary Variables 函数中临时变量个数
.Flow Control for循环有以下限制:
- Only one loop index can be used in a for loop.
- The loop index must be initialized to a constant integral expression
- The condition expression declared in the for loop must be one of the
following:
loop_indx < constant_expression
loop_indx <= constant_expression
loop_indx > constant_expression
loop_indx >= constant_expression
loop_indx != constant_expression
loop_indx == constant_expression
- The loop index can be modified in the for loop statement using one of
the following expressions only:
loop_index--
loop_index++
loop_index -= constant_expression
loop_index += constant_expression
- The loop index can be passed as a read-only argument to functions
inside the for loop (i.e., the loop index can be used with arguments
declared using the in parameter qualifier).
do-while 非必须支持
.条件表达式,以下表达式被支持
if(bool_expression)
{
…
}
if(bool_expression)
{
…
}
else
{
…
}
bool_expression必须是bool value,通常GPU可以同时对多个顶点进行运算,如果bool_expression的值因顶点不同而值不同,那会影响并行计算的效率,因些,bool_expression最好是顶点坐标无关的表达式,This will be the case if a uniform expression is used.
.Array Indexing Array indexing of uniforms (excluding samplers) is fully supported. The
array index can be a constant, uniform, or computed value. Samplers can
only be indexed using a constant integral expression. A constant integral
expression is a literal value (e.g., 4), a const integer variable (e.g., const int
sampler_indx = 3;), or a constant expression (e.g., 3 + sampler_indx).
Attribute matrices and vectors用一个变量做为索引可能不被支持。强制支持的只是constant integral expression
Counting Number of Uniforms Used in a Vertex Shader
所有下面的类型都存储在uniform存储区中:声明为uniform型的变量,const常量,字面量,内建常量,
字面量有可能被计数多次,从而浪费uniform存储区,好的做法是声明一个const常量