Path: blob/main_old/extensions/ANGLE_base_vertex_base_instance.txt
1693 views
Name12ANGLE_base_vertex_base_instance34Name Strings56GL_ANGLE_base_vertex_base_instance78Contributors910Shrek Shao, Google Inc.11Contributors to the OES_draw_elements_base_vertex specification12Contributors to the EXT_draw_elements_base_vertex specification13Contributors to the EXT_multi_draw_arrays specification14Contributors to the ARB_shader_draw_parameters specification1516Contact1718Shrek Shao (shrekshao 'at' google.com)1920Status2122Incomplete2324Version2526Last Modified Date: July 14, 202027Author Revision: 22829Number3031OpenGL ES Extension XX3233Dependencies3435OpenGL ES 3.1 is required.3637This extension is written against the OpenGL ES 3.1 specification, the38OpenGL ES 3.2 specification, and the OpenGL ES Shading Language 3.039specification.4041GL_ANGLE_multi_draw is required.4243Overview4445This extension exposes the *BaseVertex* draw call in46OES_draw_elements_base_vertex/EXT_draw_elements_base_vertex together with47their newly added *BaseInstance and MultiDraw* variants in addition to the48vertex shader builtins <gl_BaseVertex> and <gl_BaseInstance> exposed by49ARB_shader_draw_parameters for OpenGL.5051*BaseInstance behaves identically to its counterpart draw calls except that52<instanceCount> instances of the range of elements are executed and the53value of <instance> advances for each iteration. Those attributes that have54non-zero values for <divisor>, as specified by VertexAttribDivisor, advance55once per <divisor> instances of the set(s) of vertices being rendered.56Additionally, <baseInstance> specifies the first element within the57instanced vertex attributes.5859*BaseVertex* is equivalent to its counterpart draw calls except that60the value of the base vertex passed into the driver is <baseVertex> instead61of zero, and that <instances> of the set of elements are executed and the62value of <instance> advances between each set.6364Additionally, <gl_BaseVertex> and <gl_BaseInstance> builtins are added65to the shading language.66For any *BaseVertex* draw call variant, the <baseVertex> of the draw may be67read by the vertex shader as <gl_BaseVertex>. For non *BaseVertex* calls,68the value of <gl_BaseVertex> is 0.69For any *BaseInstance draw call variant, the baseInstance of the draw may70be read by the vertex shader as <gl_BaseInstance>. For non *BaseInstance71calls, the value of <gl_BaseInstance> is 0.7273IP Status7475No known IP claims.7677New Procedures and Functions7879void DrawArraysInstancedBaseInstanceANGLE(enum mode,80GLint first,81GLsizei count,82GLsizei instanceCount,83GLuint baseInstance);8485void DrawElementsInstancedBaseVertexBaseInstanceANGLE(GLenum mode,86GLsizei count,87GLenum type,88const GLvoid *indices,89GLsizei instanceCount,90GLint baseVertex,91GLuint baseInstance);9293void MultiDrawArraysInstancedBaseInstanceANGLE(enum mode,94const GLint* firsts,95const GLsizei* counts,96const GLsizei* instanceCounts,97const GLuint* baseInstances,98const GLsizei drawcount);99100void MultiDrawElementsInstancedBaseVertexBaseInstanceANGLE(enum mode,101const GLint* counts,102GLenum type,103const GLvoid* const* indices,104const GLsizei* instanceCounts,105const GLint* baseVertices,106const GLuint* baseInstances,107const GLsizei drawcount);108109New Tokens110111None.112113Additions to Chapter 10 of the OpenGL ES 3.2 Specification114115Section 10.5 Drawing Commands Using Vertex Arrays:116117The command118119void DrawArraysInstancedBaseInstanceANGLE (GLenum mode,120GLint first,121GLsizei count,122GLsizei instanceCount,123GLuint baseInstance);124125Behaves identically to DrawArraysInstanced except that <baseInstance> is126passed down to DrawArraysOneInstance instead of zero.127128The base index of the instance may be read by a vertex shader as129<gl_BaseInstance>.130131The command132133void MultiDrawArraysInstancedBaseInstanceANGLE(GLenum mode,134const GLint* firsts,135const GLsizei* counts,136const GLsizei* instanceCounts,137const GLuint* baseInstances,138GLsizei drawcount);139140Behaves identically to DrawArraysInstancedBaseInstanceANGLE except that a141list of arrays is specified instead. The number of lists is specified in142the <drawcount> parameter. It has the same effect as:143144for(i=0; i<drawcount; i++) {145if (*(counts+i)>0) DrawArraysInstancedBaseInstance(146mode,147*(counts+i),148*(instanceCounts+i),149*(firsts+i),150*(baseInstance+i)151);152}153154The index of the draw (<i> in the above pseudo-code) may be read by155a vertex shader as <gl_DrawID> which is defined in GL_ANGLE_multi_draw.156157The command158159void DrawElementsInstancedBaseVertexBaseInstanceANGLE (GLenum mode,160GLsizei count,161GLenum type,162const GLvoid* indices,163GLsizei instanceCount,164GLint baseVertex,165GLuint baseInstance);166167Behaves identically to DrawElementsInstanced except that <baseVertex> and168<baseInstance> are passed down to DrawElementsOneInstance instead of zero.169170The base index of the vertex may be read by a vertex shader as171<gl_BaseVertex>. This value is also added to the <gl_VertexID>.172173The base index of the instance may be read by a vertex shader as174<gl_BaseInstance>. Note that this value is not added to the175<gl_InstanceID>.176177The command178179void MultiDrawElementsInstancedBaseVertexBaseInstanceANGLE(GLenum mode,180const GLsizei* counts,181GLenum type,182const GLvoid* const* indices,183const GLsizei* instanceCounts,184const GLint* baseVertices,185const GLuint* baseInstances,186GLsizei drawcount);187188Behaves identically to DrawElementsInstancedBaseVertexBaseInstanceANGLE189except that a list of arrays is specified instead. The number of lists is190specified in the <drawcount> parameter. It has the same effect as:191192for(i=0; i<drawcount; i++) {193if (*(counts+i)>0) DrawElementsInstancedBaseVertexBaseInstanceANGLE(194mode,195*(counts+i),196type,197*(instanceCounts+i),198*(indices+i),199*(baseVertices+i),200*(baseInstances+i)201);202}203204The index of the draw (<i> in the above pseudo-code) may be read by205a vertex shader as <gl_DrawID> which is defined in GL_ANGLE_multi_draw.206207Errors208209DrawArraysInstancedBaseInstanceANGLE and210DrawElementsInstancedBaseVertexBaseInstanceANGLE211generate the same errors as DrawArraysInstanced and DrawElementsInstanced.212213MultiDrawArraysInstancedBaseInstanceANGLE and214MultiDrawElementsInstancedBaseVertexBaseInstanceANGL215generate the same errors as DrawArraysInstanced and DrawElementsInstanced,216respectively, for any draw <i> where an error is generated. If any call217would produce an error, no drawing is performed.218219The error INVALID_VALUE is generated by the MultiDraw* functions if220<drawcount> is less than zero.221222Modifications to the OpenGL ES Shading Language Specification, Version 3.00223224Including the following line in a shader can be used to control the225language featured described in this extension:226227#extension GL_ANGLE_base_vertex_base_instance : <behavior>228229where <behavior> is as specified in section 3.5.230231A new preprocessor #define is added to the OpenGL ES Shading Language:232233#define GL_ANGLE_base_vertex_base_instance 1234235Dependencies on GL_OES_draw_elements_base_vertex and236GL_EXT_draw_elements_base_vertex237238If the OpenGL ES context version is less than 3.2, this extension is only239available when GL_OES_draw_elements_base_vertex or240GL_EXT_draw_elements_base_vertex are available.241242Issues243244None245246Revision History247248Rev. Date Author Changes249---- -------- ---------- --------------------------------------------2501 08/13/19 Shrek Shao First revision.2512 07/14/20 Shrek Shao Fix baseInstance type from GLint to GLuint.252253254