15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci AMD_vertex_shader_tessellator 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_AMD_vertex_shader_tessellator 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContact 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Bill Licea-Kane, AMD ( Bill.Licea-Kane 'at' amd.com ) 125bd8deadSopenharmony_ci 135bd8deadSopenharmony_ciStatus 145bd8deadSopenharmony_ci 155bd8deadSopenharmony_ci Complete 165bd8deadSopenharmony_ci 175bd8deadSopenharmony_ciVersion 185bd8deadSopenharmony_ci 195bd8deadSopenharmony_ci Last Modified Date: 2009-03-06 205bd8deadSopenharmony_ci Author Revision: 8 215bd8deadSopenharmony_ci 225bd8deadSopenharmony_ciNumber 235bd8deadSopenharmony_ci 245bd8deadSopenharmony_ci 363 255bd8deadSopenharmony_ci 265bd8deadSopenharmony_ciDependencies 275bd8deadSopenharmony_ci 285bd8deadSopenharmony_ci 295bd8deadSopenharmony_ci OpenGL 2.0 is required. 305bd8deadSopenharmony_ci 315bd8deadSopenharmony_ci EXT_gpu_shader4 affects the definition of this extension. 325bd8deadSopenharmony_ci 335bd8deadSopenharmony_ci EXT_geometry_shader4 affects the definition of this extension. 345bd8deadSopenharmony_ci 355bd8deadSopenharmony_ci This extension interracts with AMDX_vertex_shader_tesselator. 365bd8deadSopenharmony_ci 375bd8deadSopenharmony_ci This extension is written against the OpenGL Shading Language 385bd8deadSopenharmony_ci 1.20 Specification. 395bd8deadSopenharmony_ci 405bd8deadSopenharmony_ci The extension is written against the OpenGL 2.1 Specification. 415bd8deadSopenharmony_ci 425bd8deadSopenharmony_ciOverview 435bd8deadSopenharmony_ci 445bd8deadSopenharmony_ci The vertex shader tessellator gives new flexibility to the shader 455bd8deadSopenharmony_ci author to shade at a tessellated vertex, rather than just at a 465bd8deadSopenharmony_ci provided vertex. 475bd8deadSopenharmony_ci 485bd8deadSopenharmony_ci In unextended vertex shading, the built-in attributes such as 495bd8deadSopenharmony_ci gl_Vertex, gl_Normal, and gl_MultiTexcoord0, together with the 505bd8deadSopenharmony_ci user defined attributes, are system provided values which are 515bd8deadSopenharmony_ci initialized prior to vertex shader invocation. 525bd8deadSopenharmony_ci 535bd8deadSopenharmony_ci With vertex shading tessellation, additional vertex shader special 545bd8deadSopenharmony_ci values are available: 555bd8deadSopenharmony_ci 565bd8deadSopenharmony_ci ivec3 gl_VertexTriangleIndex; // indices of the three control 575bd8deadSopenharmony_ci // points for the vertex 585bd8deadSopenharmony_ci vec3 gl_BarycentricCoord; // barycentric coordinates 595bd8deadSopenharmony_ci // of the vertex 605bd8deadSopenharmony_ci 615bd8deadSopenharmony_ci i o 625bd8deadSopenharmony_ci |\ 635bd8deadSopenharmony_ci | \ 645bd8deadSopenharmony_ci *--* 655bd8deadSopenharmony_ci |\ |\ 665bd8deadSopenharmony_ci | \| \ 675bd8deadSopenharmony_ci *--*--* 685bd8deadSopenharmony_ci |\ |\ |\ 695bd8deadSopenharmony_ci | \| \| \ 705bd8deadSopenharmony_ci j o--*--*--o k 715bd8deadSopenharmony_ci 725bd8deadSopenharmony_ci Figure 1 A Tessellated Triangle 735bd8deadSopenharmony_ci o = control point (and tessellated vertex) 745bd8deadSopenharmony_ci * = tessellated vertex 755bd8deadSopenharmony_ci 765bd8deadSopenharmony_ci ivec4 gl_VertexQuadIndex; // indices for the four control 775bd8deadSopenharmony_ci // points for the vertex 785bd8deadSopenharmony_ci vec2 gl_UVCoord; // UV coordinates of the vertex 795bd8deadSopenharmony_ci 805bd8deadSopenharmony_ci i o--*--*--o k 815bd8deadSopenharmony_ci |\ |\ |\ | 825bd8deadSopenharmony_ci | \| \| \| 835bd8deadSopenharmony_ci *--*--*--* 845bd8deadSopenharmony_ci |\ |\ |\ | 855bd8deadSopenharmony_ci | \| \| \| 865bd8deadSopenharmony_ci *--*--*--* 875bd8deadSopenharmony_ci |\ |\ |\ | 885bd8deadSopenharmony_ci | \| \| \| 895bd8deadSopenharmony_ci j o--*--*--o l 905bd8deadSopenharmony_ci 915bd8deadSopenharmony_ci Figure 2 A Tessellated Quad 925bd8deadSopenharmony_ci o = control point (and tessellated vertex) 935bd8deadSopenharmony_ci * = tessellated vertex 945bd8deadSopenharmony_ci 955bd8deadSopenharmony_ci When this extension is enabled, conventional built-in attributes 965bd8deadSopenharmony_ci and user defined attributes are uninitialized. The shader writer 975bd8deadSopenharmony_ci is responsible for explicitly fetching all other vertex data either 985bd8deadSopenharmony_ci from textures, uniform buffers, or vertex buffers. 995bd8deadSopenharmony_ci 1005bd8deadSopenharmony_ci The shader writer is further responsible for interpolating 1015bd8deadSopenharmony_ci the vertex data at the given barycentric coordinates or uv 1025bd8deadSopenharmony_ci coordinates of the vertex. 1035bd8deadSopenharmony_ci 1045bd8deadSopenharmony_ciIP Status 1055bd8deadSopenharmony_ci 1065bd8deadSopenharmony_ci No known claims. 1075bd8deadSopenharmony_ci 1085bd8deadSopenharmony_ciNew Procedures and Functions 1095bd8deadSopenharmony_ci 1105bd8deadSopenharmony_ci void TessellationFactorAMD( float factor ); 1115bd8deadSopenharmony_ci void TessellationModeAMD( enum mode ); 1125bd8deadSopenharmony_ci 1135bd8deadSopenharmony_ciNew Types 1145bd8deadSopenharmony_ci 1155bd8deadSopenharmony_ci (None.) 1165bd8deadSopenharmony_ci 1175bd8deadSopenharmony_ciNew Tokens 1185bd8deadSopenharmony_ci 1195bd8deadSopenharmony_ci Returned by the <type> parameter of GetActiveUniform: 1205bd8deadSopenharmony_ci 1215bd8deadSopenharmony_ci SAMPLER_BUFFER_AMD 0x9001 1225bd8deadSopenharmony_ci INT_SAMPLER_BUFFER_AMD 0x9002 1235bd8deadSopenharmony_ci UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 1245bd8deadSopenharmony_ci 1255bd8deadSopenharmony_ci Accepted by TessellationModeAMD 1265bd8deadSopenharmony_ci 1275bd8deadSopenharmony_ci DISCRETE_AMD 0x9006 1285bd8deadSopenharmony_ci CONTINUOUS_AMD 0x9007 1295bd8deadSopenharmony_ci 1305bd8deadSopenharmony_ci Accepted by GetIntegerv 1315bd8deadSopenharmony_ci 1325bd8deadSopenharmony_ci TESSELLATION_MODE_AMD 0x9004 1335bd8deadSopenharmony_ci 1345bd8deadSopenharmony_ci Accepted by GetFloatv 1355bd8deadSopenharmony_ci 1365bd8deadSopenharmony_ci TESSELLATION_FACTOR_AMD 0x9005 1375bd8deadSopenharmony_ci 1385bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL 2.1 Specification 1395bd8deadSopenharmony_ci(OpenGL Operation) 1405bd8deadSopenharmony_ci 1415bd8deadSopenharmony_ci Modify section 2.15.3, "Shader Variables", page 75 1425bd8deadSopenharmony_ci 1435bd8deadSopenharmony_ci Add the following new return types to the description of 1445bd8deadSopenharmony_ci GetActiveUniform on p. 81. 1455bd8deadSopenharmony_ci 1465bd8deadSopenharmony_ci SAMPLER_BUFFER_AMD, 1475bd8deadSopenharmony_ci INT_SAMPLER_BUFFER_AMD, 1485bd8deadSopenharmony_ci UNSIGNED_INT_SAMPLER_BUFFER_AMD. 1495bd8deadSopenharmony_ci 1505bd8deadSopenharmony_ci Replace section "Samplers" p. 83 with: 1515bd8deadSopenharmony_ci 1525bd8deadSopenharmony_ci Samplers 1535bd8deadSopenharmony_ci 1545bd8deadSopenharmony_ci Samplers are special uniforms used in the OpenGL Shading Language 1555bd8deadSopenharmony_ci to identify the texture object or vertex buffer object used for 1565bd8deadSopenharmony_ci each lookup. 1575bd8deadSopenharmony_ci 1585bd8deadSopenharmony_ci Samplers and Texture objects 1595bd8deadSopenharmony_ci 1605bd8deadSopenharmony_ci If the sampler is one of the texture types, the value of a sampler 1615bd8deadSopenharmony_ci indicates the texture image unit being accessed. Setting a 1625bd8deadSopenharmony_ci sampler's value to i selects texture image unit number i. The values 1635bd8deadSopenharmony_ci of i range from zero to the implementation dependent maximum 1645bd8deadSopenharmony_ci supported number of texture image units. 1655bd8deadSopenharmony_ci 1665bd8deadSopenharmony_ci The type of the sampler identifies the target on the texture image 1675bd8deadSopenharmony_ci unit. The texture object bound to that texture image unit's target 1685bd8deadSopenharmony_ci is then used for the texture lookup. For example, a variable of type 1695bd8deadSopenharmony_ci sampler2D selects target TEXTURE 2D on its texture image unit. 1705bd8deadSopenharmony_ci Binding of texture objects to targets is done as usual with 1715bd8deadSopenharmony_ci BindTexture. Selecting the texture image unit to bind to is done as 1725bd8deadSopenharmony_ci usual with ActiveTexture. 1735bd8deadSopenharmony_ci 1745bd8deadSopenharmony_ci It is not allowed to have variables of different sampler types 1755bd8deadSopenharmony_ci pointing to the same texture image unit within a program object. 1765bd8deadSopenharmony_ci This situation can only be detected at the next rendering command 1775bd8deadSopenharmony_ci issued, and an INVALID OPERATION error will then be generated. 1785bd8deadSopenharmony_ci 1795bd8deadSopenharmony_ci Samplers and vertex buffer objects 1805bd8deadSopenharmony_ci 1815bd8deadSopenharmony_ci If the sampler is one of the vertex types, the value of a sampler 1825bd8deadSopenharmony_ci indicates the vertex array being accessed. Setting a sampler's 1835bd8deadSopenharmony_ci value to i selects vertex array i. The values of i range from zero 1845bd8deadSopenharmony_ci to the implementation dependent maximum supported max vertex 1855bd8deadSopenharmony_ci attributes. Binding of vertex buffer objects to vertex arrays is 1865bd8deadSopenharmony_ci done as usual with BindBuffer. 1875bd8deadSopenharmony_ci 1885bd8deadSopenharmony_ci It is not allowed to have multiple variables of samplers to the same 1895bd8deadSopenharmony_ci vertex array within a program object. This situation can only be 1905bd8deadSopenharmony_ci detected at the next rendering command issued, and an INVALID 1915bd8deadSopenharmony_ci OPERATION error will then be generated. 1925bd8deadSopenharmony_ci 1935bd8deadSopenharmony_ci All samplers 1945bd8deadSopenharmony_ci 1955bd8deadSopenharmony_ci The location of a sampler needs to be queried with 1965bd8deadSopenharmony_ci GetUniformLocation, just like any uniform variable. Sampler values 1975bd8deadSopenharmony_ci need to be set by calling Uniform1i{v}. Loading samplers with any 1985bd8deadSopenharmony_ci of the other Uniform* entry points is not allowed and will result 1995bd8deadSopenharmony_ci in an INVALID OPERATION error. 2005bd8deadSopenharmony_ci 2015bd8deadSopenharmony_ci Active samplers are samplers actually being used in a program 2025bd8deadSopenharmony_ci object. The LinkProgram command determines if a sampler is active or 2035bd8deadSopenharmony_ci not. The LinkProgram command will attempt to determine if the active 2045bd8deadSopenharmony_ci samplers in the shader(s) contained in the program object exceed the 2055bd8deadSopenharmony_ci maximum allowable limits. If it determines that the count of active 2065bd8deadSopenharmony_ci samplers exceeds the allowable limits, then the link fails (these 2075bd8deadSopenharmony_ci limits can be different for different types of shaders). Each active 2085bd8deadSopenharmony_ci sampler variable counts against the limit, even if multiple samplers 2095bd8deadSopenharmony_ci refer to the same texture image unit. If this cannot be determined 2105bd8deadSopenharmony_ci at link time, for example if the program object only contains a 2115bd8deadSopenharmony_ci vertex shader, then it will be determined at the next rendering 2125bd8deadSopenharmony_ci command issued, and an INVALID OPERATION error will then be 2135bd8deadSopenharmony_ci generated. 2145bd8deadSopenharmony_ci 2155bd8deadSopenharmony_ci Insert section prior to "Validation" on p. 87 2165bd8deadSopenharmony_ci 2175bd8deadSopenharmony_ci Tessellation 2185bd8deadSopenharmony_ci 2195bd8deadSopenharmony_ci If a vertex shader enables GL_AMD_vertex_shader_tessellation, then 2205bd8deadSopenharmony_ci the shader writer is responsible for fetching and evaluating the 2215bd8deadSopenharmony_ci vertex attributes at the barycentric coordinates of the vertex. 2225bd8deadSopenharmony_ci (See the shading language specification.) 2235bd8deadSopenharmony_ci 2245bd8deadSopenharmony_ci Only indexed triangles or indexed quads may be drawn with such a 2255bd8deadSopenharmony_ci shader. Each triangle or quad will introduce generated vertices 2265bd8deadSopenharmony_ci (including the original vertices of the triangle or quad) 2275bd8deadSopenharmony_ci controlled by: 2285bd8deadSopenharmony_ci 2295bd8deadSopenharmony_ci void TessellationFactorAMD( float factor ); 2305bd8deadSopenharmony_ci 2315bd8deadSopenharmony_ci where the factor is a value between 1.0 and 15.0 inclusive 2325bd8deadSopenharmony_ci 2335bd8deadSopenharmony_ci The introduction of generated vertices is further controlled by: 2345bd8deadSopenharmony_ci 2355bd8deadSopenharmony_ci void TessellationModeAMD( enum mode ); 2365bd8deadSopenharmony_ci 2375bd8deadSopenharmony_ci where mode is either DISCRETE_AMD or CONTINUOUS_AMD. 2385bd8deadSopenharmony_ci 2395bd8deadSopenharmony_ci Add to the list of "begin errors": 2405bd8deadSopenharmony_ci 2415bd8deadSopenharmony_ci * any two samplers of vertex type refer to the same vertex array. 2425bd8deadSopenharmony_ci 2435bd8deadSopenharmony_ci * Any sampler bound to a vertex array has vertex buffer object 0 2445bd8deadSopenharmony_ci bound. 2455bd8deadSopenharmony_ci 2465bd8deadSopenharmony_ci * A vertex shader enables GL_AMD_vertex_shader_tessellation, 2475bd8deadSopenharmony_ci statically reads gl_VertexTriangleIndex or gl_BarycentricCoord 2485bd8deadSopenharmony_ci and the Implicit Begin mode is NOT GL_TRIANGLES 2495bd8deadSopenharmony_ci 2505bd8deadSopenharmony_ci * A vertex shader enables GL_AMD_vertex_shader_tessellation, 2515bd8deadSopenharmony_ci statically reads gl_VertexQuadIndex or gl_UVCoord and 2525bd8deadSopenharmony_ci the Implicit Begin mode is NOT GL_QUADS 2535bd8deadSopenharmony_ci 2545bd8deadSopenharmony_ci * A vertex shader enables GL_AMD_vertex_shader_tessellation and 2555bd8deadSopenharmony_ci the command is RasterPos. 2565bd8deadSopenharmony_ci 2575bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL 2.1 Specification (Rasterization) 2585bd8deadSopenharmony_ci 2595bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL 2.1 Specification (Per-Fragment 2605bd8deadSopenharmony_ciOperations and the Frame Buffer) 2615bd8deadSopenharmony_ci 2625bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL 2.1 Specification 2635bd8deadSopenharmony_ci(Special Functions) 2645bd8deadSopenharmony_ci 2655bd8deadSopenharmony_ci 2665bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL 2.1 Specification (State and State 2675bd8deadSopenharmony_ciRequests) 2685bd8deadSopenharmony_ci 2695bd8deadSopenharmony_ci 2705bd8deadSopenharmony_ciAdditions to Appendix A of the OpenGL 2.1 Specification (Invariance) 2715bd8deadSopenharmony_ci 2725bd8deadSopenharmony_ciModifications to The OpenGL Shading Language 1.20 Specification 2735bd8deadSopenharmony_ci 2745bd8deadSopenharmony_ci Including the following line in a shader can be used to control the 2755bd8deadSopenharmony_ci language features described in this extension: 2765bd8deadSopenharmony_ci 2775bd8deadSopenharmony_ci #extension GL_AMD_vertex_shader_tessellator : <behavior> 2785bd8deadSopenharmony_ci 2795bd8deadSopenharmony_ci where <behavior> is as specified in section 3.3. 2805bd8deadSopenharmony_ci 2815bd8deadSopenharmony_ci A new preprocessor #define is added to the OpenGL Shading Language: 2825bd8deadSopenharmony_ci 2835bd8deadSopenharmony_ci #define GL_AMD_vertex_shader_tessellator 1 2845bd8deadSopenharmony_ci 2855bd8deadSopenharmony_ciAdditions to Chapter 1 of the OpenGL Shading Language 1.20 Specification 2865bd8deadSopenharmony_ci(Introduction) 2875bd8deadSopenharmony_ci 2885bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL Shading Language 1.20 Specification 2895bd8deadSopenharmony_ci(Overview of OpenGL Shading) 2905bd8deadSopenharmony_ci 2915bd8deadSopenharmony_ci 2.1 Vertex Processor 2925bd8deadSopenharmony_ci 2935bd8deadSopenharmony_ci Change 2nd paragraph to: 2945bd8deadSopenharmony_ci 2955bd8deadSopenharmony_ci The vertex processor operates on one vertex at a time. It does not 2965bd8deadSopenharmony_ci replace graphics operations that require knowledge of several 2975bd8deadSopenharmony_ci vertices at a time. While a tessellated vertex however has LIMITED 2985bd8deadSopenharmony_ci knowledge of the immediately adjacent control points (three for a 2995bd8deadSopenharmony_ci triangle, four for a quad), the vertex processor is still operating 3005bd8deadSopenharmony_ci on one tessellated vertex at a time. The vertex shaders running on 3015bd8deadSopenharmony_ci the vertex processor must compute the homogeneous position 3025bd8deadSopenharmony_ci of the incoming vertex. 3035bd8deadSopenharmony_ci 3045bd8deadSopenharmony_ci 3055bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL Shading Language 1.20 Specification 3065bd8deadSopenharmony_ci(Basics) 3075bd8deadSopenharmony_ci 3085bd8deadSopenharmony_ci 3.6 Keywords 3095bd8deadSopenharmony_ci 3105bd8deadSopenharmony_ci Add the keywords 3115bd8deadSopenharmony_ci 3125bd8deadSopenharmony_ci __samplerVertexAMD 3135bd8deadSopenharmony_ci __isamplerVertexAMD 3145bd8deadSopenharmony_ci __usamplerVertexAMD 3155bd8deadSopenharmony_ci 3165bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL Shading Language 1.20 Specification 3175bd8deadSopenharmony_ci(Variables and Types) 3185bd8deadSopenharmony_ci 3195bd8deadSopenharmony_ci4.3.4 Attribute, Change third sentence: 3205bd8deadSopenharmony_ci 3215bd8deadSopenharmony_ci "Attribute values are read-only as far as the vertex shader is 3225bd8deadSopenharmony_ci concerned, unless GL_AMD_vertex_shader_tessellator is enabled. If 3235bd8deadSopenharmony_ci GL_AMD_vertex_shader is enabled, they are read-write with undefined 3245bd8deadSopenharmony_ci initial values." 3255bd8deadSopenharmony_ci 3265bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL Shading Language 1.20 Specification 3275bd8deadSopenharmony_ci(Operators and Expressions) 3285bd8deadSopenharmony_ci 3295bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL Shading Language 1.20 Specification 3305bd8deadSopenharmony_ci(Statements and Structure) 3315bd8deadSopenharmony_ci 3325bd8deadSopenharmony_ciAdditions to Chapter 7 of the OpenGL Shading Language 1.20 Specification 3335bd8deadSopenharmony_ci(Built-in Variables) 3345bd8deadSopenharmony_ci 3355bd8deadSopenharmony_ci7.1 Vertex Shader Special Variables 3365bd8deadSopenharmony_ci 3375bd8deadSopenharmony_ciAdd the list of intrinsically declared with the following types: 3385bd8deadSopenharmony_ci 3395bd8deadSopenharmony_ci // if GL_AMD_vertex_shader_tessellator enabled 3405bd8deadSopenharmony_ci 3415bd8deadSopenharmony_ci ivec3 gl_VertexTriangleIndex; // may be read 3425bd8deadSopenharmony_ci // indices of the three control 3435bd8deadSopenharmony_ci // points for the vertex 3445bd8deadSopenharmony_ci vec3 gl_BarycentricCoord; // may be read 3455bd8deadSopenharmony_ci // barycentric coordinates of the 3465bd8deadSopenharmony_ci // vertex 3475bd8deadSopenharmony_ci 3485bd8deadSopenharmony_ci ivec4 gl_VertexQuadIndex; // may be read 3495bd8deadSopenharmony_ci vec2 gl_UVCoord; // may be read 3505bd8deadSopenharmony_ci 3515bd8deadSopenharmony_ci 3525bd8deadSopenharmony_ci If gl_VertexTriangleIndex and/or gl_BarycentricCoord is statically 3535bd8deadSopenharmony_ci read by the shader, the shader is a Triangle Tessellator shader. 3545bd8deadSopenharmony_ci 3555bd8deadSopenharmony_ci If gl_VertexQuadIndex and/or gl_UVCoord is statically read by the 3565bd8deadSopenharmony_ci shader, the shader is a Quad Tessellator shader. 3575bd8deadSopenharmony_ci 3585bd8deadSopenharmony_ci It is a link error if both a Triangle Tessellator shader and a Quad 3595bd8deadSopenharmony_ci Tessellator shader are attached to a program. 3605bd8deadSopenharmony_ci 3615bd8deadSopenharmony_ci7.3 Vertex Shader Built-In Attributes 3625bd8deadSopenharmony_ci 3635bd8deadSopenharmony_ciAdd the following paragraph. 3645bd8deadSopenharmony_ci 3655bd8deadSopenharmony_ci If GL_AMD_vertex_shader_tessellator is enabled, the values of the 3665bd8deadSopenharmony_ci built-in Attributes are undefined. 3675bd8deadSopenharmony_ci 3685bd8deadSopenharmony_ciAdditions to Chapter 8 of the OpenGL Shading Language 1.20 Specification 3695bd8deadSopenharmony_ci(Built-in Functions) 3705bd8deadSopenharmony_ci 3715bd8deadSopenharmony_ci8.7 Texture Lookup Functions 3725bd8deadSopenharmony_ci 3735bd8deadSopenharmony_ciRename section to "Lookup Functions" 3745bd8deadSopenharmony_ci 3755bd8deadSopenharmony_ciAdd in front of first sentence: 3765bd8deadSopenharmony_ci 3775bd8deadSopenharmony_ci Vertex lookup functions are available to the vertex shader. 3785bd8deadSopenharmony_ci 3795bd8deadSopenharmony_ciAdd to the front of the table of functions: 3805bd8deadSopenharmony_ci 3815bd8deadSopenharmony_ci Syntax: 3825bd8deadSopenharmony_ci vec4 vertexFetchAMD( __samplerVertexAMD sampler, int i ); 3835bd8deadSopenharmony_ci ivec4 vertexFetchAMD( __isamplerVertexAMD sampler, int i ); 3845bd8deadSopenharmony_ci uvec4 vertexFetchAMD( __usamplerVertexAMD sampler, int i ); 3855bd8deadSopenharmony_ci 3865bd8deadSopenharmony_ci Description: 3875bd8deadSopenharmony_ci 3885bd8deadSopenharmony_ci If GL_AMD_vertex_shader_tessellator is enabled, fetch the "ith" 3895bd8deadSopenharmony_ci element from the vertex buffer bound to the vertex array bound to 3905bd8deadSopenharmony_ci the sampler. 3915bd8deadSopenharmony_ci 3925bd8deadSopenharmony_ciAdditions to Chapter 9 of the OpenGL Shading Language 1.20 Specification 3935bd8deadSopenharmony_ci(Shading Language Grammar) 3945bd8deadSopenharmony_ci 3955bd8deadSopenharmony_ciAdditions to Chapter 10 of the OpenGL Shading Language 1.20 3965bd8deadSopenharmony_ciSpecification (Issues) 3975bd8deadSopenharmony_ci 3985bd8deadSopenharmony_ciAdditions to the AGL/EGL/GLX/WGL Specifications 3995bd8deadSopenharmony_ci 4005bd8deadSopenharmony_ci None 4015bd8deadSopenharmony_ci 4025bd8deadSopenharmony_ci 4035bd8deadSopenharmony_ciDependencies on ARB_vertex_shader 4045bd8deadSopenharmony_ci 4055bd8deadSopenharmony_ci ARB_vertex_shader is required. 4065bd8deadSopenharmony_ci 4075bd8deadSopenharmony_ciInteractions with EXT_gpu_shader4 4085bd8deadSopenharmony_ci 4095bd8deadSopenharmony_ci If EXT_gpu_shader4 is not supported, remove all references to: 4105bd8deadSopenharmony_ci 4115bd8deadSopenharmony_ci __isamplerVertexAMD 4125bd8deadSopenharmony_ci __usamplerVertexAMD 4135bd8deadSopenharmony_ci ivec4 vertexFetchAMD 4145bd8deadSopenharmony_ci uvec4 vertexFetchAMD 4155bd8deadSopenharmony_ci 4165bd8deadSopenharmony_ciInteractions with EXT_geometry_shader4 4175bd8deadSopenharmony_ci 4185bd8deadSopenharmony_ci If EXT_geometry_shader4 is supported, change the last 4195bd8deadSopenharmony_ci paragraph of Section 2.16, Geometry Shaders to: 4205bd8deadSopenharmony_ci 4215bd8deadSopenharmony_ci A program object that includes a geometry shader must also include 4225bd8deadSopenharmony_ci a vertex shader; otherwise a link error will occur. If a program 4235bd8deadSopenharmony_ci object that includes a geometry shader also includes a vertex shader 4245bd8deadSopenharmony_ci with that has enabled GL_AMD_vertex_shader_tessellator, a link error 4255bd8deadSopenharmony_ci will occur. 4265bd8deadSopenharmony_ci 4275bd8deadSopenharmony_ciInteractions with AMDX_vertex_shader_tessellator 4285bd8deadSopenharmony_ci 4295bd8deadSopenharmony_ci This extension is symantically identical to the experimental 4305bd8deadSopenharmony_ci AMDX_vertex_shader_tessellator. (It has been "promoted" to 4315bd8deadSopenharmony_ci non-experimental status.) 4325bd8deadSopenharmony_ci 4335bd8deadSopenharmony_ci Only the prefix AMDX has been changed to AMD. 4345bd8deadSopenharmony_ci Only the suffix AMDX has been changed to AMD. 4355bd8deadSopenharmony_ci 4365bd8deadSopenharmony_ci We encourage applications and shader writers to migrate from 4375bd8deadSopenharmony_ci AMDX to AMD. However, the AMDX entry points, enums, keywords 4385bd8deadSopenharmony_ci and function names are not yet deprecated. 4395bd8deadSopenharmony_ci 4405bd8deadSopenharmony_ciErrors 4415bd8deadSopenharmony_ci 4425bd8deadSopenharmony_ciNew State 4435bd8deadSopenharmony_ci 4445bd8deadSopenharmony_ciAdd to Table 6.5 Vertex Array Data 4455bd8deadSopenharmony_ci 4465bd8deadSopenharmony_ci Get Value Type Get Command Value Description Sec. Attribute 4475bd8deadSopenharmony_ci --------- ---- --------------- ------- -------------------- ---- --------- 4485bd8deadSopenharmony_ci TESSELLATION_FACTOR_AMD R GetFloatv 1.0 tessellation factor 2.8 vertex-array 4495bd8deadSopenharmony_ci TESSELLATION_MODE_AMD Z_2 GetIntegerv DISCRETE_AMD tessellation mode 2.8 vertex-array 4505bd8deadSopenharmony_ci 4515bd8deadSopenharmony_ciNew Implementation Dependent State 4525bd8deadSopenharmony_ci 4535bd8deadSopenharmony_ci None. 4545bd8deadSopenharmony_ci 4555bd8deadSopenharmony_ciSample Code 4565bd8deadSopenharmony_ci 4575bd8deadSopenharmony_ci#extension GL_AMD_vertex_shader_tessellator : require 4585bd8deadSopenharmony_ci 4595bd8deadSopenharmony_ci__samplerVertexAMD Vertex; 4605bd8deadSopenharmony_ci__samplerVertexAMD Normal; 4615bd8deadSopenharmony_ci__samplerVertexAMD Texcoord0; 4625bd8deadSopenharmony_ci__samplerVertexAMD Temperature; 4635bd8deadSopenharmony_ci__samplerVertexAMD Pressure; 4645bd8deadSopenharmony_ci 4655bd8deadSopenharmony_ciattribute float myTemperature; 4665bd8deadSopenharmony_ci 4675bd8deadSopenharmony_civoid main ( void ) 4685bd8deadSopenharmony_ci{ 4695bd8deadSopenharmony_ci gl_Vertex = vec4( 0.0 ); 4705bd8deadSopenharmony_ci gl_Normal = vec4( 0.0 ); 4715bd8deadSopenharmony_ci gl_MultiTexCoord0 = vec4( 0.0 ); 4725bd8deadSopenharmony_ci myTemperature = 0.0; 4735bd8deadSopenharmony_ci float myPressure = 0.0; // Don't have to interpolate to attribute 4745bd8deadSopenharmony_ci 4755bd8deadSopenharmony_ci for ( int i=0; i<3; i++ ) 4765bd8deadSopenharmony_ci { 4775bd8deadSopenharmony_ci float weight = gl_BarycentricCoord[i]; 4785bd8deadSopenharmony_ci 4795bd8deadSopenharmony_ci gl_Vertex += weight*vertexFetchAMD( Vertex, gl_VertexTriangleIndex[i] ); 4805bd8deadSopenharmony_ci gl_Normal += weight*vertexFetchAMD( Normal, gl_VertexTriangleIndex[i] ); 4815bd8deadSopenharmony_ci gl_MultiTexCoord0 += weight*vertexFetchAMD( Texcoord0, gl_VertexTriangleIndex[i] ); 4825bd8deadSopenharmony_ci myTemperature += weight*vertexFetchAMD( Temperature, gl_VertexTriangleIndex[i] ).x; 4835bd8deadSopenharmony_ci myPressure += weight*vertexFetchAMD( Pressure, gl_VertexTriangleIndex[i] ).x; 4845bd8deadSopenharmony_ci 4855bd8deadSopenharmony_ci } 4865bd8deadSopenharmony_ci // Rest of vertex shader goes here.... 4875bd8deadSopenharmony_ci} 4885bd8deadSopenharmony_ci 4895bd8deadSopenharmony_ciIssues 4905bd8deadSopenharmony_ci 4915bd8deadSopenharmony_ci1) Does this belong conceptually in the pipe as subsuming geometry 4925bd8deadSopenharmony_ci shader (after primitive combine) or vertex unpack. 4935bd8deadSopenharmony_ci 4945bd8deadSopenharmony_ci Vertex unpack. Even though there is "primitive information" it 4955bd8deadSopenharmony_ci is limited to the immediate neighborhood. 4965bd8deadSopenharmony_ci 4975bd8deadSopenharmony_ci2) Do we need a new stage? 4985bd8deadSopenharmony_ci 4995bd8deadSopenharmony_ci If we add a "tessellation" stage: 5005bd8deadSopenharmony_ci 5015bd8deadSopenharmony_ci Input to the tessellator is the unpacked vertex attributes, but 5025bd8deadSopenharmony_ci each attribute is now an array of size 3, the "superprim" attributes, 5035bd8deadSopenharmony_ci plus a barycentric coordinate. 5045bd8deadSopenharmony_ci 5055bd8deadSopenharmony_ci The output of the tessellator is the varying. 5065bd8deadSopenharmony_ci 5075bd8deadSopenharmony_ci The varying output of the tessellator then becomes the attributes 5085bd8deadSopenharmony_ci input to the vertex shader. 5095bd8deadSopenharmony_ci 5105bd8deadSopenharmony_ci Alternatively, we can make the "unpack" part of the vertex shader 5115bd8deadSopenharmony_ci responsibility. 5125bd8deadSopenharmony_ci 5135bd8deadSopenharmony_ci No. We'll just make the attributes undefined, and the 5145bd8deadSopenharmony_ci "vertex unpack" stage naturally collapses into the vertex shader. 5155bd8deadSopenharmony_ci 5165bd8deadSopenharmony_ci3) Why make attributes undefined but writable? 5175bd8deadSopenharmony_ci 5185bd8deadSopenharmony_ci This is the easiest way to have an unpack shader merged into 5195bd8deadSopenharmony_ci existing shaders. 5205bd8deadSopenharmony_ci 5215bd8deadSopenharmony_ci4) What variants of vertexFetch do we need. 5225bd8deadSopenharmony_ci 5235bd8deadSopenharmony_ci 1D is probably all we need, and probably all we will ever need. 5245bd8deadSopenharmony_ci The return types should be vec4, ivec4 and uvec4. 5255bd8deadSopenharmony_ci So, we need: 5265bd8deadSopenharmony_ci 5275bd8deadSopenharmony_ci vec4 vertexFetchAMD( __samplerVertexAMD sampler, int i ); 5285bd8deadSopenharmony_ci ivec4 vertexFetchAMD( __isamplerVertexAMD sampler, int i ); 5295bd8deadSopenharmony_ci uvec4 vertexFetchAMD( __usamplerVertexAMD sampler, int i ); 5305bd8deadSopenharmony_ci 5315bd8deadSopenharmony_ci5) How does __samplerVertexAMD and vertexFetchAMD interact with vertex arrays? 5325bd8deadSopenharmony_ci 5335bd8deadSopenharmony_ci The __samplerVertexAMD becomes an active uniform. As existing 5345bd8deadSopenharmony_ci samplers are bound to texture units, the samplerVertex is bound to a 5355bd8deadSopenharmony_ci VertexAttrib array, and similarly, the "enable" of the 5365bd8deadSopenharmony_ci VertexAttribArray is ignored. vertexFetchAMD will use the size, 5375bd8deadSopenharmony_ci type, normalized and stride to fetch the "ith" element from the array 5385bd8deadSopenharmony_ci as the following pseudocode: 5395bd8deadSopenharmony_ci 5405bd8deadSopenharmony_ci if (generic vertex attribute j array normalization flag is set, and 5415bd8deadSopenharmony_ci type is not FLOAT or DOUBLE) 5425bd8deadSopenharmony_ci VertexAttrib[size]N[type]v 5435bd8deadSopenharmony_ci (j, generic vertex attribute j array element i); 5445bd8deadSopenharmony_ci else 5455bd8deadSopenharmony_ci VertexAttrib[size][type]v 5465bd8deadSopenharmony_ci (j, generic vertex attribute j array element i); 5475bd8deadSopenharmony_ci 5485bd8deadSopenharmony_ci6) What happens if a buffer object is not bound to an array? 5495bd8deadSopenharmony_ci 5505bd8deadSopenharmony_ci There is no reason why it shouldn't work, but there's also no good 5515bd8deadSopenharmony_ci reason to make it work. Undefined. 5525bd8deadSopenharmony_ci 5535bd8deadSopenharmony_ci7) What about "conventional" OpenGL array state (Vertex, Color, Normal, 5545bd8deadSopenharmony_ci TexCoord, etc....)? 5555bd8deadSopenharmony_ci 5565bd8deadSopenharmony_ci By binding the buffer objects to the appropriate vertexAttrib array, 5575bd8deadSopenharmony_ci and setting appropriate size, type, normalized and stride, the 5585bd8deadSopenharmony_ci application programmer can access all "conventional" OpenGL array 5595bd8deadSopenharmony_ci state? 5605bd8deadSopenharmony_ci 5615bd8deadSopenharmony_ci8) Are attributes declared or used in the shader "active?" 5625bd8deadSopenharmony_ci 5635bd8deadSopenharmony_ci For the purposes of GetActiveAttrib, GetAttribLocation and 5645bd8deadSopenharmony_ci BindAttribLocation, no. 5655bd8deadSopenharmony_ci 5665bd8deadSopenharmony_ci9) What about geometry shaders and tessellation? 5675bd8deadSopenharmony_ci 5685bd8deadSopenharmony_ci Future hardware may relax this restriction, but you can not 5695bd8deadSopenharmony_ci successfully link a program that includes a vertex shader that has 5705bd8deadSopenharmony_ci enabled GL_AMD_vertex_shader_tessellator and a geometry shader. 5715bd8deadSopenharmony_ci 5725bd8deadSopenharmony_ci10) What draw calls do we support? 5735bd8deadSopenharmony_ci 5745bd8deadSopenharmony_ci To the shader writer, everything looks like indexed triangles or 5755bd8deadSopenharmony_ci indexed quads, with discrete and continuous tessellation. These 5765bd8deadSopenharmony_ci indexed triangles result from a polygon Begin/End object, a 5775bd8deadSopenharmony_ci triangle resulting from a triangle strip, triangle fan, or series 5785bd8deadSopenharmony_ci of separate triangles, or a quadrilateral arising from a 5795bd8deadSopenharmony_ci quadrilateral strip, series of separate quadrilaterals, or a Rect 5805bd8deadSopenharmony_ci command. 5815bd8deadSopenharmony_ci 5825bd8deadSopenharmony_ci Points, Lines and pixel rectangles and bitmaps are unsupported by 5835bd8deadSopenharmony_ci a tessellation shader. 5845bd8deadSopenharmony_ci 5855bd8deadSopenharmony_ci11) Do we need additional enables? 5865bd8deadSopenharmony_ci 5875bd8deadSopenharmony_ci Lets first see how "implicit" enable of vertex arrays and 5885bd8deadSopenharmony_ci tessellation draw calls works. The first follows precedent (samplers 5895bd8deadSopenharmony_ci override texture enable hierarchy.) The second seems to follow. 5905bd8deadSopenharmony_ci 5915bd8deadSopenharmony_ci11) What about begin errors? 5925bd8deadSopenharmony_ci 5935bd8deadSopenharmony_ci They are evil, but I don't see how they can be avoided. 5945bd8deadSopenharmony_ci Clearly sampler validation needs to follow precedent. 5955bd8deadSopenharmony_ci 5965bd8deadSopenharmony_ci12) What about quads? 5975bd8deadSopenharmony_ci 5985bd8deadSopenharmony_ci Quads are necessary for subdivision surfaces such as Catmull-Clark. 5995bd8deadSopenharmony_ci We have received several significant requests to support subdivision 6005bd8deadSopenharmony_ci surfaces. 6015bd8deadSopenharmony_ci 6025bd8deadSopenharmony_ciRevision History 6035bd8deadSopenharmony_ci 6045bd8deadSopenharmony_ci Revision 1, 2007-06-26 wwlk 6055bd8deadSopenharmony_ci Preliminary review document 6065bd8deadSopenharmony_ci 6075bd8deadSopenharmony_ci Revision 2, 2007-08-16 wwlk 6085bd8deadSopenharmony_ci Review document 6095bd8deadSopenharmony_ci 6105bd8deadSopenharmony_ci Correct spelling of "tessellate" throughout. Blush. 6115bd8deadSopenharmony_ci Rename special variables. 6125bd8deadSopenharmony_ci Add additional sampler types. 6135bd8deadSopenharmony_ci Remove "1D" from sampler types and vertex fetches. 6145bd8deadSopenharmony_ci Add core OpenGL api spec changes. 6155bd8deadSopenharmony_ci Add interactions with EXT_gpu_shader4. 6165bd8deadSopenharmony_ci Add many issues. 6175bd8deadSopenharmony_ci Expanded example shader. 6185bd8deadSopenharmony_ci 6195bd8deadSopenharmony_ci Revision 3, 2007-08-17 wwlk 6205bd8deadSopenharmony_ci Correct edit headers 6215bd8deadSopenharmony_ci (OpenGL 1.5 -> OpenGL 2.0) 6225bd8deadSopenharmony_ci (Shading Language 1.10 -> Shading Language 1.20) 6235bd8deadSopenharmony_ci 6245bd8deadSopenharmony_ci Revision 4, 2007-09-21 wwlk 6255bd8deadSopenharmony_ci Fix typo in reserved keywords (remove "1D") 6265bd8deadSopenharmony_ci Added support for all polygon calls, explicitly disallowing points 6275bd8deadSopenharmony_ci lines and RasterPos, 6285bd8deadSopenharmony_ci List additional BEGIN errors - yes they are evil. 6295bd8deadSopenharmony_ci 6305bd8deadSopenharmony_ci Revision 5, 2008-05-22 wwlk 6315bd8deadSopenharmony_ci Add quad support 6325bd8deadSopenharmony_ci 6335bd8deadSopenharmony_ci Revision 6, 2009-03-05 wwlk 6345bd8deadSopenharmony_ci General cleanup to ready for posting to repository 6355bd8deadSopenharmony_ci 6365bd8deadSopenharmony_ci Revision 7, 2009-03-05 wwlk 6375bd8deadSopenharmony_ci Promote from AMDX to AMD. 6385bd8deadSopenharmony_ci 6395bd8deadSopenharmony_ci Revision 8, 2009-03-06 wwlk 6405bd8deadSopenharmony_ci Minor update to enums section. 6415bd8deadSopenharmony_ci Cleaned up typos and <cr><lf>. 642