15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci NV_viewport_array2 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_NV_viewport_array2 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContact 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Jeff Bolz, NVIDIA Corporation (jbolz 'at' nvidia.com) 125bd8deadSopenharmony_ci Pat Brown, NVIDIA Corporation (pbrown 'at' nvidia.com) 135bd8deadSopenharmony_ci 145bd8deadSopenharmony_ciContributors 155bd8deadSopenharmony_ci 165bd8deadSopenharmony_ci Pat Brown, NVIDIA 175bd8deadSopenharmony_ci Mathias Heyer, NVIDIA 185bd8deadSopenharmony_ci 195bd8deadSopenharmony_ciStatus 205bd8deadSopenharmony_ci 215bd8deadSopenharmony_ci Shipping 225bd8deadSopenharmony_ci 235bd8deadSopenharmony_ciVersion 245bd8deadSopenharmony_ci 255bd8deadSopenharmony_ci Last Modified Date: March 27, 2015 265bd8deadSopenharmony_ci Revision: 2 275bd8deadSopenharmony_ci 285bd8deadSopenharmony_ciNumber 295bd8deadSopenharmony_ci 305bd8deadSopenharmony_ci OpenGL Extension #476 315bd8deadSopenharmony_ci OpenGL ES Extension #237 325bd8deadSopenharmony_ci 335bd8deadSopenharmony_ciDependencies 345bd8deadSopenharmony_ci 355bd8deadSopenharmony_ci This extension is written against the OpenGL 4.3 specification 365bd8deadSopenharmony_ci (Compatibility Profile). 375bd8deadSopenharmony_ci 385bd8deadSopenharmony_ci This extension interacts with the OpenGL ES 3.1 (March 17, 2014) 395bd8deadSopenharmony_ci specification. 405bd8deadSopenharmony_ci 415bd8deadSopenharmony_ci If implemented in OpenGL ES, NV_viewport_array, EXT_geometry_shader 425bd8deadSopenharmony_ci and EXT_shader_io_blocks are required. 435bd8deadSopenharmony_ci 445bd8deadSopenharmony_ci This extension interacts with EXT_tessellation_shader. 455bd8deadSopenharmony_ci 465bd8deadSopenharmony_ci This extension interacts with NV_geometry_shader_passthrough. 475bd8deadSopenharmony_ci 485bd8deadSopenharmony_ci This extension interacts with NV_gpu_program4. 495bd8deadSopenharmony_ci 505bd8deadSopenharmony_ciOverview 515bd8deadSopenharmony_ci 525bd8deadSopenharmony_ci This extension provides new support allowing a single primitive to be 535bd8deadSopenharmony_ci broadcast to multiple viewports and/or multiple layers. A shader output 545bd8deadSopenharmony_ci gl_ViewportMask[] is provided, allowing a single primitive to be output to 555bd8deadSopenharmony_ci multiple viewports simultaneously. Also, a new shader option is provided 565bd8deadSopenharmony_ci to control whether the effective viewport index is added into gl_Layer. 575bd8deadSopenharmony_ci These capabilities allow a single primitive to be output to multiple 585bd8deadSopenharmony_ci layers simultaneously. 595bd8deadSopenharmony_ci 605bd8deadSopenharmony_ci The gl_ViewportMask[] output is available in vertex, tessellation 615bd8deadSopenharmony_ci control, tessellation evaluation, and geometry shaders. gl_ViewportIndex 625bd8deadSopenharmony_ci and gl_Layer are also made available in all these shader stages. The 635bd8deadSopenharmony_ci actual viewport index or mask and render target layer values are taken 645bd8deadSopenharmony_ci from the last active shader stage from this set of stages. 655bd8deadSopenharmony_ci 665bd8deadSopenharmony_ci This extension is a superset of the GL_AMD_vertex_shader_layer and 675bd8deadSopenharmony_ci GL_AMD_vertex_shader_viewport_index extensions, and thus those extension 685bd8deadSopenharmony_ci strings are expected to be exported if GL_NV_viewport_array2 is 695bd8deadSopenharmony_ci supported. This extension includes the edits for those extensions, recast 705bd8deadSopenharmony_ci against the reorganized OpenGL 4.3 specification. 715bd8deadSopenharmony_ci 725bd8deadSopenharmony_ciNew Procedures and Functions 735bd8deadSopenharmony_ci 745bd8deadSopenharmony_ci None. 755bd8deadSopenharmony_ci 765bd8deadSopenharmony_ciNew Tokens 775bd8deadSopenharmony_ci 785bd8deadSopenharmony_ci None. 795bd8deadSopenharmony_ci 805bd8deadSopenharmony_ciAdditions to Chapter 11 of the OpenGL 4.3 (Compatibility Profile) Specification 815bd8deadSopenharmony_ci(Programmable Vertex Processing) 825bd8deadSopenharmony_ci 835bd8deadSopenharmony_ci Add to Section 11.1.3.10 (Shader Outputs) 845bd8deadSopenharmony_ci 855bd8deadSopenharmony_ci The built-in output variables gl_ViewportIndex, gl_ViewportMask[], and 865bd8deadSopenharmony_ci gl_Layer hold the viewport index/mask and render target layer, as described 875bd8deadSopenharmony_ci in Section 11.4 (Viewport Index and Layer). 885bd8deadSopenharmony_ci 895bd8deadSopenharmony_ci Add to Section 11.2.1.2.3 (Tessellation Control Shader Outputs) 905bd8deadSopenharmony_ci 915bd8deadSopenharmony_ci The built-in output variables gl_ViewportIndex, gl_ViewportMask[], and 925bd8deadSopenharmony_ci gl_Layer hold the viewport index/mask and render target layer, as described 935bd8deadSopenharmony_ci in Section 11.4 (Viewport Index and Layer). 945bd8deadSopenharmony_ci 955bd8deadSopenharmony_ci Add to Section 11.2.3.4 (Tessellation Evaluation Shader Outputs) 965bd8deadSopenharmony_ci 975bd8deadSopenharmony_ci The built-in output variables gl_ViewportIndex, gl_ViewportMask[], and 985bd8deadSopenharmony_ci gl_Layer hold the viewport index/mask and render target layer, as described 995bd8deadSopenharmony_ci in Section 11.4 (Viewport Index and Layer). 1005bd8deadSopenharmony_ci 1015bd8deadSopenharmony_ci Modify Section 11.3.4.5 (Geometry Shader Outputs) 1025bd8deadSopenharmony_ci 1035bd8deadSopenharmony_ci Replace the paragraph about gl_ViewportIndex: 1045bd8deadSopenharmony_ci 1055bd8deadSopenharmony_ci The built-in output variables gl_ViewportIndex, gl_ViewportMask[], and 1065bd8deadSopenharmony_ci gl_Layer hold the viewport index/mask and render target layer, as described 1075bd8deadSopenharmony_ci in Section 11.4 (Viewport Index and Layer). 1085bd8deadSopenharmony_ci 1095bd8deadSopenharmony_ci Replace Section 11.3.4.6 (Layer and Viewport Selection) with new Section 1105bd8deadSopenharmony_ci 11.4 (Layer and Viewport Selection) 1115bd8deadSopenharmony_ci 1125bd8deadSopenharmony_ci Geometry may be rendered to one of several different layers of cube map 1135bd8deadSopenharmony_ci textures, three-dimensional textures, or one- or two-dimensional texture 1145bd8deadSopenharmony_ci arrays. This functionality allows an application to bind an entire complex 1155bd8deadSopenharmony_ci texture to a framebuffer object, and render primitives to arbitrary layers 1165bd8deadSopenharmony_ci computed at run time. For example, it can be used render a scene into 1175bd8deadSopenharmony_ci multiple layers of an array texture in one pass, or to select a particular 1185bd8deadSopenharmony_ci layer to render to in shader code. The layer to render to is specified by 1195bd8deadSopenharmony_ci writing to the built-in output variable gl_Layer. Layered rendering 1205bd8deadSopenharmony_ci requires the use of framebuffer objects (see section 9.8). 1215bd8deadSopenharmony_ci 1225bd8deadSopenharmony_ci Shaders may also direct each primitive to zero or more viewports. The 1235bd8deadSopenharmony_ci destination viewports for a primitive may be selected in the shader by 1245bd8deadSopenharmony_ci writing to the built-in output variable gl_ViewportIndex (selecting a 1255bd8deadSopenharmony_ci single viewport) or gl_ViewportMask[] (selecting multiple viewports). 1265bd8deadSopenharmony_ci This functionality allows a shader to direct its output to different 1275bd8deadSopenharmony_ci viewports for each primitive, or to draw multiple versions of a primitive 1285bd8deadSopenharmony_ci into several different viewports. 1295bd8deadSopenharmony_ci 1305bd8deadSopenharmony_ci The specific vertex of a primitive used to select the rendering layer or 1315bd8deadSopenharmony_ci viewport index/mask is implementation-dependent and thus portable 1325bd8deadSopenharmony_ci applications will assign the same layer and viewport index for all 1335bd8deadSopenharmony_ci vertices in a primitive. The vertex conventions followed for gl_Layer and 1345bd8deadSopenharmony_ci gl_ViewportIndex/gl_ViewportMask[] may be determined by calling 1355bd8deadSopenharmony_ci GetIntegerv with the symbolic constants LAYER_PROVOKING_VERTEX and 1365bd8deadSopenharmony_ci VIEWPORT_INDEX_PROVOKING_VERTEX, respectively. For either query, if the 1375bd8deadSopenharmony_ci value returned is PROVOKING_VERTEX, then vertex selection follows the 1385bd8deadSopenharmony_ci convention specified by ProvokingVertex (see section 13.4). If the value 1395bd8deadSopenharmony_ci returned is FIRST_VERTEX_CONVENTION, selection is always taken from the 1405bd8deadSopenharmony_ci first vertex of a primitive. If the value returned is 1415bd8deadSopenharmony_ci LAST_VERTEX_CONVENTION, the selection is always taken from the last vertex 1425bd8deadSopenharmony_ci of a primitive. If the value returned is UNDEFINED_VERTEX, the selection 1435bd8deadSopenharmony_ci is not guaranteed to be taken from any specific vertex in the 1445bd8deadSopenharmony_ci primitive. The vertex considered the provoking vertex for particular 1455bd8deadSopenharmony_ci primitive types is given in table 13.2. 1465bd8deadSopenharmony_ci 1475bd8deadSopenharmony_ci The layer selection may be made a function of the viewport index, as 1485bd8deadSopenharmony_ci described in Section 7.1 of the GLSL specification. 1495bd8deadSopenharmony_ci 1505bd8deadSopenharmony_ci The viewport index, viewport mask, and layer outputs are available in 1515bd8deadSopenharmony_ci vertex, tessellation control, tessellation evaluation, and geometry 1525bd8deadSopenharmony_ci shaders. Only the last active shader stage (in pipeline order) from this 1535bd8deadSopenharmony_ci list controls the viewport index/mask and layer; outputs in previous 1545bd8deadSopenharmony_ci shader stages are not used, even if the last stage fails to write one of 1555bd8deadSopenharmony_ci the outputs. 1565bd8deadSopenharmony_ci 1575bd8deadSopenharmony_ci 1585bd8deadSopenharmony_ciAdditions to Chapter 13 of the OpenGL 4.3 (Compatibility Profile) Specification 1595bd8deadSopenharmony_ci(Fixed-Function Vertex Post-Processing) 1605bd8deadSopenharmony_ci 1615bd8deadSopenharmony_ci Modify Section 13.2 (Transform Feedback), p. 453 1625bd8deadSopenharmony_ci 1635bd8deadSopenharmony_ci Modify the first paragraph: 1645bd8deadSopenharmony_ci 1655bd8deadSopenharmony_ci ...The vertices are fed back after vertex color clamping, but before 1665bd8deadSopenharmony_ci viewport mask expansion, flatshading, and clipping. ... 1675bd8deadSopenharmony_ci 1685bd8deadSopenharmony_ci 1695bd8deadSopenharmony_ci Modify Section 13.6.1 (Controlling the Viewport) 1705bd8deadSopenharmony_ci 1715bd8deadSopenharmony_ci Multiple viewports are available and are numbered zero through the value 1725bd8deadSopenharmony_ci of MAX_VIEWPORTS minus one. If last active vertex, tessellation, or 1735bd8deadSopenharmony_ci geometry shader writes to gl_ViewportIndex, the primitive is emitted to 1745bd8deadSopenharmony_ci the viewport corresponding to the value assigned to gl_ViewportIndex, as 1755bd8deadSopenharmony_ci taken from an implementation-dependent provoking vertex. The primitive is 1765bd8deadSopenharmony_ci then transformed using the state of the selected viewport. If the value 1775bd8deadSopenharmony_ci of the viewport index is outside the range zero to the value of 1785bd8deadSopenharmony_ci MAX_VIEWPORTS minus one, the results of the viewport transformation are 1795bd8deadSopenharmony_ci undefined. 1805bd8deadSopenharmony_ci 1815bd8deadSopenharmony_ci If last active vertex, tessellation, or geometry shader writes to 1825bd8deadSopenharmony_ci gl_ViewportMask[], the primitive is emitted to zero or more viewports. If 1835bd8deadSopenharmony_ci bit <i> is set in the mask, the primitive is emitted to viewport <i> and 1845bd8deadSopenharmony_ci transformed using the state of viewport <i>. However, each primitive will 1855bd8deadSopenharmony_ci still be captured by transform feedback and counted by primitive queries 1865bd8deadSopenharmony_ci only once. If bits of gl_ViewportMask[] greater than or equal to the 1875bd8deadSopenharmony_ci value of MAX_VIEWPORTS are set, the number of times the primitive is 1885bd8deadSopenharmony_ci emitted and which viewport transformations are used are undefined. 1895bd8deadSopenharmony_ci 1905bd8deadSopenharmony_ci If neither gl_ViewportIndex nor gl_ViewportMask[] are written, the 1915bd8deadSopenharmony_ci viewport numbered zero is used by the viewport transformation. 1925bd8deadSopenharmony_ci 1935bd8deadSopenharmony_ci 1945bd8deadSopenharmony_ci Modify Section 14.5.2.1 (Line Stipple) 1955bd8deadSopenharmony_ci 1965bd8deadSopenharmony_ci (add to the end of the section) 1975bd8deadSopenharmony_ci 1985bd8deadSopenharmony_ci When rasterizing line segments that could be sent to multiple viewports 1995bd8deadSopenharmony_ci via the gl_ViewportMask[] built-in geometry shader output (section 2005bd8deadSopenharmony_ci 13.6.1), the line stipple pattern is not guaranteed to be continuous if 2015bd8deadSopenharmony_ci segments are sent to multiple viewports. If a line segment is not an 2025bd8deadSopenharmony_ci independent line segment and is not the first in a series of connected 2035bd8deadSopenharmony_ci segments (where the stipple counter <s> is reset to 0), the initial value 2045bd8deadSopenharmony_ci of <s> for the segment is undefined unless that line segment and all 2055bd8deadSopenharmony_ci previous segments in the series were sent to the same single viewport. 2065bd8deadSopenharmony_ci 2075bd8deadSopenharmony_ciNew Implementation Dependent State 2085bd8deadSopenharmony_ci 2095bd8deadSopenharmony_ci None. 2105bd8deadSopenharmony_ci 2115bd8deadSopenharmony_ciNew State 2125bd8deadSopenharmony_ci 2135bd8deadSopenharmony_ci None. 2145bd8deadSopenharmony_ci 2155bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL Specifications 2165bd8deadSopenharmony_ci 2175bd8deadSopenharmony_ci None. 2185bd8deadSopenharmony_ci 2195bd8deadSopenharmony_ciGLX Protocol 2205bd8deadSopenharmony_ci 2215bd8deadSopenharmony_ci None. 2225bd8deadSopenharmony_ci 2235bd8deadSopenharmony_ciModifications to the OpenGL Shading Language Specification, Version 4.30 2245bd8deadSopenharmony_ci 2255bd8deadSopenharmony_ci Including the following line in a shader can be used to control the 2265bd8deadSopenharmony_ci language features described in this extension: 2275bd8deadSopenharmony_ci 2285bd8deadSopenharmony_ci #extension GL_NV_viewport_array2 : <behavior> 2295bd8deadSopenharmony_ci 2305bd8deadSopenharmony_ci where <behavior> is as specified in section 3.3. 2315bd8deadSopenharmony_ci 2325bd8deadSopenharmony_ci New preprocessor #defines are added to the OpenGL Shading Language: 2335bd8deadSopenharmony_ci 2345bd8deadSopenharmony_ci #define GL_NV_viewport_array2 1 2355bd8deadSopenharmony_ci 2365bd8deadSopenharmony_ci Modify Section 7.1 (Built-In Language Variables), p. 116 2375bd8deadSopenharmony_ci 2385bd8deadSopenharmony_ci Add to the list of vertex shader built-ins: 2395bd8deadSopenharmony_ci 2405bd8deadSopenharmony_ci out gl_PerVertex { 2415bd8deadSopenharmony_ci highp int gl_ViewportIndex; 2425bd8deadSopenharmony_ci highp int gl_ViewportMask[]; 2435bd8deadSopenharmony_ci highp int gl_Layer; 2445bd8deadSopenharmony_ci }; 2455bd8deadSopenharmony_ci 2465bd8deadSopenharmony_ci Add to the list of geometry shader built-ins: 2475bd8deadSopenharmony_ci 2485bd8deadSopenharmony_ci out highp int gl_ViewportMask[]; 2495bd8deadSopenharmony_ci 2505bd8deadSopenharmony_ci Add to the list of tessellation control shader built-ins: 2515bd8deadSopenharmony_ci 2525bd8deadSopenharmony_ci out gl_PerVertex { 2535bd8deadSopenharmony_ci highp int gl_ViewportIndex; 2545bd8deadSopenharmony_ci highp int gl_ViewportMask[]; 2555bd8deadSopenharmony_ci highp int gl_Layer; 2565bd8deadSopenharmony_ci } gl_out[]; 2575bd8deadSopenharmony_ci 2585bd8deadSopenharmony_ci Add to the list of tessellation evaluation shader built-ins: 2595bd8deadSopenharmony_ci 2605bd8deadSopenharmony_ci out gl_PerVertex { 2615bd8deadSopenharmony_ci highp int gl_ViewportIndex; 2625bd8deadSopenharmony_ci highp int gl_ViewportMask[]; 2635bd8deadSopenharmony_ci highp int gl_Layer; 2645bd8deadSopenharmony_ci }; 2655bd8deadSopenharmony_ci 2665bd8deadSopenharmony_ci Modify descriptions of gl_Layer and gl_ViewportIndex as follows: 2675bd8deadSopenharmony_ci 2685bd8deadSopenharmony_ci The variable gl_Layer is available as an output variable in the vertex, 2695bd8deadSopenharmony_ci tessellation, and geometry (VTG) languages and an input variable in the 2705bd8deadSopenharmony_ci fragment language. In the VTG languages, it is used to select a specific 2715bd8deadSopenharmony_ci layer (or face and layer of a cube map) of a multi-layer framebuffer 2725bd8deadSopenharmony_ci attachment. The actual layer used will come from one of the vertices in 2735bd8deadSopenharmony_ci the primitive being shaded. Which vertex the layer comes from is undefined, 2745bd8deadSopenharmony_ci so it is best to write the same layer value for all vertices of a 2755bd8deadSopenharmony_ci primitive. If a shader statically assigns a value to gl_Layer, layered 2765bd8deadSopenharmony_ci rendering mode is enabled. See section 11.4 "Layer and Viewport Selection" 2775bd8deadSopenharmony_ci and section 9.4.9 "Layered Framebuffers" of the OpenGL Graphics System 2785bd8deadSopenharmony_ci Specification for more information. If a shader statically assigns a value 2795bd8deadSopenharmony_ci to gl_Layer, and there is an execution path through the shader that does 2805bd8deadSopenharmony_ci not set gl_Layer, then the value of gl_Layer is undefined for executions 2815bd8deadSopenharmony_ci of the shader that take that path. 2825bd8deadSopenharmony_ci 2835bd8deadSopenharmony_ci ... 2845bd8deadSopenharmony_ci 2855bd8deadSopenharmony_ci The input variable gl_Layer in the fragment language will have the same 2865bd8deadSopenharmony_ci value that was written to the output variable gl_Layer in the VTG 2875bd8deadSopenharmony_ci languages. If the final VTG stage does not dynamically assign a value to 2885bd8deadSopenharmony_ci gl_Layer, the value of gl_Layer in the fragment stage will be undefined. 2895bd8deadSopenharmony_ci If the final VTG stage makes no static assignment to gl_Layer, the input 2905bd8deadSopenharmony_ci gl_Value in the fragment stage will be zero. Otherwise, the fragment stage 2915bd8deadSopenharmony_ci will read the same value written by the final VTG stage, even if that value 2925bd8deadSopenharmony_ci is out of range. If a fragment shader contains a static access to gl_Layer, 2935bd8deadSopenharmony_ci it will count against the implementation defined limit for the maximum 2945bd8deadSopenharmony_ci number of inputs to the fragment stage. 2955bd8deadSopenharmony_ci 2965bd8deadSopenharmony_ci The variable gl_ViewportIndex is available as an output variable in the 2975bd8deadSopenharmony_ci VTG languages and an input variable in the fragment language. In the 2985bd8deadSopenharmony_ci geometry language, it provides the index of the viewport to which the next 2995bd8deadSopenharmony_ci primitive emitted from the geometry shader should be drawn. In the vertex 3005bd8deadSopenharmony_ci and tessellation languages, it provides the index of the viewport 3015bd8deadSopenharmony_ci associated with the vertex being shaded. Primitives will undergo viewport 3025bd8deadSopenharmony_ci transformation and scissor testing using the viewport transformation and 3035bd8deadSopenharmony_ci scissor rectangle selected by the value of gl_ViewportIndex. The viewport 3045bd8deadSopenharmony_ci index used will come from one of the vertices in the primitive being 3055bd8deadSopenharmony_ci shaded. However, which vertex the viewport index comes from is 3065bd8deadSopenharmony_ci implementation-dependent, so it is best to use the same viewport index for 3075bd8deadSopenharmony_ci all vertices of the primitive. If the final VTG stage does not assign a 3085bd8deadSopenharmony_ci value to gl_ViewportIndex or gl_ViewportMask[], viewport transform and 3095bd8deadSopenharmony_ci scissor rectangle zero will be used. If a shader statically assigns a value 3105bd8deadSopenharmony_ci to gl_ViewportIndex and there is a path through the shader that does not 3115bd8deadSopenharmony_ci assign a value to gl_ViewportIndex, the value of gl_ViewportIndex is 3125bd8deadSopenharmony_ci undefined for executions of the shader that take that path. See section 3135bd8deadSopenharmony_ci 11.4 "Layer and Viewport Selection" of the OpenGL Graphics System 3145bd8deadSopenharmony_ci Specification for more information. 3155bd8deadSopenharmony_ci 3165bd8deadSopenharmony_ci The input variable gl_ViewportIndex in the fragment stage will have the 3175bd8deadSopenharmony_ci same value that was written to the output variable gl_ViewportIndex in the 3185bd8deadSopenharmony_ci final VTG stage. If the final VTG stage does not dynamically assign to 3195bd8deadSopenharmony_ci gl_ViewportIndex, the value of gl_ViewportIndex in the fragment shader will 3205bd8deadSopenharmony_ci be undefined. If the final VTG stage makes no static assignment to 3215bd8deadSopenharmony_ci gl_ViewportIndex, the fragment stage will read zero. Otherwise, the 3225bd8deadSopenharmony_ci fragment stage will read the same value written by the final VTG stage, 3235bd8deadSopenharmony_ci even if that value is out of range. If a fragment shader contains a static 3245bd8deadSopenharmony_ci access to gl_ViewportIndex, it will count against the implementation 3255bd8deadSopenharmony_ci defined limit for the maximum number of inputs to the fragment stage. 3265bd8deadSopenharmony_ci 3275bd8deadSopenharmony_ci The variable gl_ViewportMask[] is available as an output variable in the 3285bd8deadSopenharmony_ci VTG languages. The array has ceil(v/32) elements where v is the maximum 3295bd8deadSopenharmony_ci number of viewports supported by the implementation. When a shader writes 3305bd8deadSopenharmony_ci this variable, bit B of element M controls whether the primitive is 3315bd8deadSopenharmony_ci emitted to viewport 32*M+B. If gl_ViewportIndex is written by the final 3325bd8deadSopenharmony_ci VTG stage, then gl_ViewportIndex in the fragment stage will have the same 3335bd8deadSopenharmony_ci value. If gl_ViewportMask[] is written by the final VTG stage, then 3345bd8deadSopenharmony_ci gl_ViewportIndex in the fragment stage will have the index of the viewport 3355bd8deadSopenharmony_ci that was used in generating that fragment. 3365bd8deadSopenharmony_ci 3375bd8deadSopenharmony_ci If a shader statically assigns a value to gl_ViewportIndex, it may not 3385bd8deadSopenharmony_ci assign a value to any element of gl_ViewportMask[]. If a shader 3395bd8deadSopenharmony_ci statically writes a value to any element of gl_ViewportMask[], it may 3405bd8deadSopenharmony_ci not assign a value to gl_ViewportIndex. That is, a shader may assign 3415bd8deadSopenharmony_ci values to either gl_ViewportIndex or gl_ViewportMask[], but not 3425bd8deadSopenharmony_ci both. Multiple shaders linked together must also consistently write just 3435bd8deadSopenharmony_ci one of these variables. These incorrect usages all generate compile-time 3445bd8deadSopenharmony_ci or link-time errors. 3455bd8deadSopenharmony_ci 3465bd8deadSopenharmony_ci The shader output gl_Layer may be redeclared with a layout qualifer 3475bd8deadSopenharmony_ci <viewport_relative> as follows: 3485bd8deadSopenharmony_ci 3495bd8deadSopenharmony_ci layout (viewport_relative) out highp int gl_Layer; 3505bd8deadSopenharmony_ci 3515bd8deadSopenharmony_ci If gl_Layer is <viewport_relative>, then the viewport index is added to 3525bd8deadSopenharmony_ci the layer used for rendering (and available in the fragment shader). If 3535bd8deadSopenharmony_ci the shader writes gl_ViewportMask[], then gl_Layer has a different value 3545bd8deadSopenharmony_ci for each viewport the primitive is rendered to. If gl_Layer is 3555bd8deadSopenharmony_ci <viewport_relative> and the shader writes neither gl_ViewportIndex nor 3565bd8deadSopenharmony_ci gl_ViewportMask[], a link-error will result. 3575bd8deadSopenharmony_ci 3585bd8deadSopenharmony_ci Modify Section 8.15 (Geometry Shader Functions) 3595bd8deadSopenharmony_ci 3605bd8deadSopenharmony_ci The function EmitStreamVertex() specifies that a vertex is completed. A 3615bd8deadSopenharmony_ci vertex is added to the current output primitive in vertex stream <stream> 3625bd8deadSopenharmony_ci using the current values of all output variables associated with <stream>. 3635bd8deadSopenharmony_ci These include gl_PointSize, gl_ClipDistance, gl_Layer, gl_Position, 3645bd8deadSopenharmony_ci gl_PrimitiveID, gl_ViewportIndex, and gl_ViewportMask[]. The values of 3655bd8deadSopenharmony_ci all output variables for all output streams are undefined after a call to 3665bd8deadSopenharmony_ci EmitStreamVertex(). 3675bd8deadSopenharmony_ci 3685bd8deadSopenharmony_ciErrors 3695bd8deadSopenharmony_ci 3705bd8deadSopenharmony_ci None. 3715bd8deadSopenharmony_ci 3725bd8deadSopenharmony_ciInteractions with OpenGL ES 3.1 3735bd8deadSopenharmony_ci 3745bd8deadSopenharmony_ci Unless functionality similar to ARB_provoking_vertex is supported, remove 3755bd8deadSopenharmony_ci references to PROVOKING_VERTEX and ProvokingVertex(). Also remove 3765bd8deadSopenharmony_ci reference to 'vertex color clamping'. The modifications to Line Stippling 3775bd8deadSopenharmony_ci don't apply. 3785bd8deadSopenharmony_ci 3795bd8deadSopenharmony_ciInteractions with EXT_tessellation_shader 3805bd8deadSopenharmony_ci 3815bd8deadSopenharmony_ci If implemented on OpenGL ES and EXT_tessellation_shader is not supported, 3825bd8deadSopenharmony_ci remove all language referring to the tesselation control and tessellation 3835bd8deadSopenharmony_ci evaluation pipeline stages. 3845bd8deadSopenharmony_ci 3855bd8deadSopenharmony_ciInteractions with NV_geometry_shader_passthrough 3865bd8deadSopenharmony_ci 3875bd8deadSopenharmony_ci If NV_geometry_shader_passthrough is supported, the NV_gpu_program4 and 3885bd8deadSopenharmony_ci NV_geometry_program4 language describing the PASSTHROUGH declaration 3895bd8deadSopenharmony_ci statement should be modified to state that "result.viewportmask" may not 3905bd8deadSopenharmony_ci be used in such a declaration. 3915bd8deadSopenharmony_ci 3925bd8deadSopenharmony_ciInteractions with NV_gpu_program4 3935bd8deadSopenharmony_ci 3945bd8deadSopenharmony_ci If NV_gpu_program4 is supported and the "NV_viewport_array2" program 3955bd8deadSopenharmony_ci option is specified, vertex, tessellation control/evaluation, and geometry 3965bd8deadSopenharmony_ci program result variable "result.viewportmask" can be used to specify the 3975bd8deadSopenharmony_ci mask of viewports that the primitive will be emitted to, "result.viewport" 3985bd8deadSopenharmony_ci can be used to specify the index of the viewport that the primitive will 3995bd8deadSopenharmony_ci be emitted to, and "result.layer" can be used to specify the layer of a 4005bd8deadSopenharmony_ci layered framebuffer attachment that the primitive will be emitted to. 4015bd8deadSopenharmony_ci 4025bd8deadSopenharmony_ci (add the following rule to the NV_gpu_program4 grammar) 4035bd8deadSopenharmony_ci 4045bd8deadSopenharmony_ci <resultBasic> ::= ... 4055bd8deadSopenharmony_ci | <resPrefix> "viewportmask" arrayMemAbs 4065bd8deadSopenharmony_ci | <resPrefix> "viewport" 4075bd8deadSopenharmony_ci | <resPrefix> "layer" 4085bd8deadSopenharmony_ci 4095bd8deadSopenharmony_ci (add the following to the tables of Vertex, Geometry, and Tessellation 4105bd8deadSopenharmony_ci Control/Eval Program Result Variable Bindings) 4115bd8deadSopenharmony_ci 4125bd8deadSopenharmony_ci Binding Components Description 4135bd8deadSopenharmony_ci ----------------------------- ---------- ---------------------------- 4145bd8deadSopenharmony_ci result.viewportmask[] (v,*,*,*) viewport array mask 4155bd8deadSopenharmony_ci result.viewport (v,*,*,*) viewport array index 4165bd8deadSopenharmony_ci result.layer (l,*,*,*) layer for cube/array/3D FBOs 4175bd8deadSopenharmony_ci 4185bd8deadSopenharmony_ci (add the following to Section 2.X.2, Program Grammar) 4195bd8deadSopenharmony_ci 4205bd8deadSopenharmony_ci If a result variable binding matches "result.viewportmask", updates to the 4215bd8deadSopenharmony_ci "x" component of the result variable provide a single integer that serves 4225bd8deadSopenharmony_ci as a mask of viewport indices. The mask must be written as an integer 4235bd8deadSopenharmony_ci value; writing a floating-point value will produce undefined results. 4245bd8deadSopenharmony_ci If the value has bits greater than or equal to MAX_VIEWPORTS set, the 4255bd8deadSopenharmony_ci number of viewports the primitive is emitted to and which viewports are 4265bd8deadSopenharmony_ci used are undefined. If the "NV_viewport_array2" program option is not 4275bd8deadSopenharmony_ci specified, the "result.viewportmask" binding is unavailable. 4285bd8deadSopenharmony_ci 4295bd8deadSopenharmony_ci If both "result.viewport" and "result.viewportmask" are written, 4305bd8deadSopenharmony_ci compilation will fail. 4315bd8deadSopenharmony_ci 4325bd8deadSopenharmony_ci (add the following to Section 2.X.6.Y, Program Options) 4335bd8deadSopenharmony_ci 4345bd8deadSopenharmony_ci + Viewport Mask (NV_viewport_array2) 4355bd8deadSopenharmony_ci 4365bd8deadSopenharmony_ci If a vertex, geometry, tessellation control, or tessellation evaluation 4375bd8deadSopenharmony_ci program specifies the "NV_viewport_array2" option, the result binding 4385bd8deadSopenharmony_ci "result.viewportmask" will be available to specify the mask of viewports 4395bd8deadSopenharmony_ci to use for primitive viewport transformations and scissoring as described 4405bd8deadSopenharmony_ci in section 2.X.2. Additionally, the "result.viewport" and "result.layer" 4415bd8deadSopenharmony_ci result bindings will be available in these same shader stages. 4425bd8deadSopenharmony_ci 4435bd8deadSopenharmony_ci If a program specifies the "NV_layer_viewport_relative" option, the 4445bd8deadSopenharmony_ci result.layer will have the viewport index automatically added to it. If 4455bd8deadSopenharmony_ci the result.viewportmask is used, the result.layer will be different for 4465bd8deadSopenharmony_ci each viewport the primitive is emitted to. 4475bd8deadSopenharmony_ci 4485bd8deadSopenharmony_ciIssues 4495bd8deadSopenharmony_ci 4505bd8deadSopenharmony_ci (1) Where does the viewport mask broadcast occur? 4515bd8deadSopenharmony_ci 4525bd8deadSopenharmony_ci RESOLVED: This operation could potentially be performed before or after 4535bd8deadSopenharmony_ci transform feedback, but feeding back several viewports worth of primitives 4545bd8deadSopenharmony_ci doesn't seem particularly useful. This specification applies the viewport 4555bd8deadSopenharmony_ci mask after transform feedback, and makes primitive queries only count each 4565bd8deadSopenharmony_ci primitive once. 4575bd8deadSopenharmony_ci 4585bd8deadSopenharmony_ci Note that it is possible to capture viewport mask shader outputs when 4595bd8deadSopenharmony_ci transform feedback is active. 4605bd8deadSopenharmony_ci 4615bd8deadSopenharmony_ci (2) How does the gl_ViewportIndex fragment input behave? 4625bd8deadSopenharmony_ci 4635bd8deadSopenharmony_ci RESOLVED: Whether viewport mask or viewport indices are used in VTG 4645bd8deadSopenharmony_ci shaders, the fragment shader input gl_ViewportIndex will contain the 4655bd8deadSopenharmony_ci viewport number for the primitive generating each fragment. If the 4665bd8deadSopenharmony_ci viewport mask is used to broadcast a single primitive to multiple 4675bd8deadSopenharmony_ci viewports, and the same pixel is covered by the primitive in each 4685bd8deadSopenharmony_ci viewport, multiple fragment shader invocations for that pixel will be 4695bd8deadSopenharmony_ci generated, each with a different value of gl_ViewportIndex. 4705bd8deadSopenharmony_ci 4715bd8deadSopenharmony_ci This extension provides no gl_ViewportMask[] input, so a fragment shader 4725bd8deadSopenharmony_ci is not able to see the original viewport mask for the primitive generating 4735bd8deadSopenharmony_ci the fragment. If necessary, this value could be passed by a separate 4745bd8deadSopenharmony_ci shader variable qualified with "flat". 4755bd8deadSopenharmony_ci 4765bd8deadSopenharmony_ci (3) How does the viewport mask interact with line stipple? 4775bd8deadSopenharmony_ci 4785bd8deadSopenharmony_ci RESOLVED: With viewport mask, it's possible to broadcast line strips to 4795bd8deadSopenharmony_ci multiple viewports. If line stipple is enabled in the OpenGL 4805bd8deadSopenharmony_ci compatibility profile, implementations are required to maintain a 4815bd8deadSopenharmony_ci continuous stipple pattern across the strip. When primitives are 4825bd8deadSopenharmony_ci broadcast via viewport mask, implementations will not always be able to 4835bd8deadSopenharmony_ci buffer an entire strip and send it to each viewport in turn. So it will 4845bd8deadSopenharmony_ci often be necessary to break up a long strip, and send segments to 4855bd8deadSopenharmony_ci alternating viewports. An implementation could handle this by breaking up 4865bd8deadSopenharmony_ci the strip and keeping N independent stipple counters, but that seems like 4875bd8deadSopenharmony_ci overkill. 4885bd8deadSopenharmony_ci 4895bd8deadSopenharmony_ci We relax normal spec requirements and require a continuous stipple pattern 4905bd8deadSopenharmony_ci only if the entire strip if sent to exactly one viewport. If any segment 4915bd8deadSopenharmony_ci in the strip is sent to multiple viewports, no viewports, or a different 4925bd8deadSopenharmony_ci viewport than previous segments, the stipple counter for that segment and 4935bd8deadSopenharmony_ci subsequent segments in the strip is undefined. 4945bd8deadSopenharmony_ci 4955bd8deadSopenharmony_ci (4) Can a viewport index or mask written by vertex or tessellation shader 4965bd8deadSopenharmony_ci be read by downstream tessellation or geometry shaders? 4975bd8deadSopenharmony_ci 4985bd8deadSopenharmony_ci RESOLVED: No. The fragment shader is able to read the viewport index, but 4995bd8deadSopenharmony_ci this extension provides no built-in input allowing VTG shaders to see a 5005bd8deadSopenharmony_ci viewport index or mask written by a previous shader stage. 5015bd8deadSopenharmony_ci 5025bd8deadSopenharmony_ci (5) Can this extension be used to "kill" primitives in a passthrough 5035bd8deadSopenharmony_ci geometry shader (NV_geometry_shader_passthrough)? 5045bd8deadSopenharmony_ci 5055bd8deadSopenharmony_ci RESOLVED: Yes. In regular geometry shaders, input primitives can be 5065bd8deadSopenharmony_ci killed by returning without emitting any vertices. That's not possible 5075bd8deadSopenharmony_ci with passthrough geometry shaders, however it is possible to code a 5085bd8deadSopenharmony_ci passthrough geometry shader like: 5095bd8deadSopenharmony_ci 5105bd8deadSopenharmony_ci void main() 5115bd8deadSopenharmony_ci { 5125bd8deadSopenharmony_ci if (shouldKillPrimitive()) { 5135bd8deadSopenharmony_ci // Set the viewport mask to zero. A primitive will still be 5145bd8deadSopenharmony_ci // emitted from the geometry shader stage, however it will be sent 5155bd8deadSopenharmony_ci // to no viewports and thus be discarded. Any other per-primitive 5165bd8deadSopenharmony_ci // outputs will be undefined. 5175bd8deadSopenharmony_ci gl_ViewportMask[0] = 0; 5185bd8deadSopenharmony_ci return; 5195bd8deadSopenharmony_ci } 5205bd8deadSopenharmony_ci 5215bd8deadSopenharmony_ci // Since the shader writes the viewport mask in the "kill" path, it 5225bd8deadSopenharmony_ci // also needs to write it in the non-"kill" path; otherwise, its 5235bd8deadSopenharmony_ci // value would be undefined and the primitive will be sent to an 5245bd8deadSopenharmony_ci // undefined set of viewports. Setting the mask to 1 will always 5255bd8deadSopenharmony_ci // send a primitive to viewport zero. 5265bd8deadSopenharmony_ci gl_ViewportMask[0] = 1; 5275bd8deadSopenharmony_ci 5285bd8deadSopenharmony_ci ... 5295bd8deadSopenharmony_ci } 5305bd8deadSopenharmony_ci 5315bd8deadSopenharmony_ci Without the viewport mask or a similar feature, it is not possible to kill 5325bd8deadSopenharmony_ci primitives in a passthrough geometry shader. 5335bd8deadSopenharmony_ci 5345bd8deadSopenharmony_ciRevision History 5355bd8deadSopenharmony_ci 5365bd8deadSopenharmony_ci Revision 2, 2015/03/27 5375bd8deadSopenharmony_ci - Add ES interactions 5385bd8deadSopenharmony_ci 5395bd8deadSopenharmony_ci Revision 1 5405bd8deadSopenharmony_ci - Internal revisions. 541