15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    NV_geometry_shader_passthrough
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_NV_geometry_shader_passthrough
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContact
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    Pat Brown, NVIDIA Corporation (pbrown 'at' nvidia.com)
125bd8deadSopenharmony_ci
135bd8deadSopenharmony_ciContributors
145bd8deadSopenharmony_ci
155bd8deadSopenharmony_ci    Jeff Bolz, NVIDIA Corporation
165bd8deadSopenharmony_ci    Piers Daniell, NVIDIA Corporation
175bd8deadSopenharmony_ci    Christoph Kubisch, NVIDIA Corporation
185bd8deadSopenharmony_ci    Mathias Heyer, NVIDIA Corporation
195bd8deadSopenharmony_ci    Mark Kilgard, NVIDIA Corporation
205bd8deadSopenharmony_ci
215bd8deadSopenharmony_ciStatus
225bd8deadSopenharmony_ci
235bd8deadSopenharmony_ci    Shipping
245bd8deadSopenharmony_ci
255bd8deadSopenharmony_ciVersion
265bd8deadSopenharmony_ci
275bd8deadSopenharmony_ci    Last Modified Date:         February 15, 2017
285bd8deadSopenharmony_ci    NVIDIA Revision:            4
295bd8deadSopenharmony_ci
305bd8deadSopenharmony_ciNumber
315bd8deadSopenharmony_ci
325bd8deadSopenharmony_ci    OpenGL Extension #470
335bd8deadSopenharmony_ci    OpenGL ES Extension #233
345bd8deadSopenharmony_ci
355bd8deadSopenharmony_ciDependencies
365bd8deadSopenharmony_ci
375bd8deadSopenharmony_ci    This extension is written against the OpenGL 4.3 Specification
385bd8deadSopenharmony_ci    (Compatibility Profile), dated February 14, 2013
395bd8deadSopenharmony_ci
405bd8deadSopenharmony_ci    This extension is written against the OpenGL Shading Language
415bd8deadSopenharmony_ci    Specification, version 4.30, revision 8.
425bd8deadSopenharmony_ci
435bd8deadSopenharmony_ci    OpenGL ES 3.1 and EXT_geometry_shader are required for an
445bd8deadSopenharmony_ci    implementation in OpenGL ES.
455bd8deadSopenharmony_ci
465bd8deadSopenharmony_ci    This extension interacts with OpenGL 4.4 and ARB_enhanced_layouts.
475bd8deadSopenharmony_ci
485bd8deadSopenharmony_ci    This extension interacts with NV_gpu_program4 and NV_gpu_program5.
495bd8deadSopenharmony_ci
505bd8deadSopenharmony_ci    This extension interacts with NV_geometry_shader4 and NV_gpu_shader4.
515bd8deadSopenharmony_ci
525bd8deadSopenharmony_ci    This extension interacts with NV_geometry_program4 and NV_gpu_program4.
535bd8deadSopenharmony_ci
545bd8deadSopenharmony_ci    This extension interacts with NV_transform_feedback.
555bd8deadSopenharmony_ci
565bd8deadSopenharmony_ci    This extension interacts with a combination of NV_gpu_program4,
575bd8deadSopenharmony_ci    NV_gpu_program5, NV_transform_feedback, EXT_transform_feedback, and OpenGL
585bd8deadSopenharmony_ci    3.0.
595bd8deadSopenharmony_ci
605bd8deadSopenharmony_ci    This extension interacts with NVX_shader_thread_group.
615bd8deadSopenharmony_ci
625bd8deadSopenharmony_ciOverview
635bd8deadSopenharmony_ci
645bd8deadSopenharmony_ci    Geometry shaders provide the ability for applications to process each
655bd8deadSopenharmony_ci    primitive sent through the GL using a programmable shader.  While geometry
665bd8deadSopenharmony_ci    shaders can be used to perform a number of different operations, including
675bd8deadSopenharmony_ci    subdividing primitives and changing primitive type, one common use case
685bd8deadSopenharmony_ci    treats geometry shaders as largely "passthrough".  In this use case, the
695bd8deadSopenharmony_ci    bulk of the geometry shader code simply copies inputs from each vertex of
705bd8deadSopenharmony_ci    the input primitive to corresponding outputs in the vertices of the output
715bd8deadSopenharmony_ci    primitive.  Such shaders might also compute values for additional built-in
725bd8deadSopenharmony_ci    or user-defined per-primitive attributes (e.g., gl_Layer) to be assigned
735bd8deadSopenharmony_ci    to all the vertices of the output primitive.
745bd8deadSopenharmony_ci
755bd8deadSopenharmony_ci    This extension provides a shading language abstraction to express such
765bd8deadSopenharmony_ci    shaders without requiring explicit logic to manually copy attributes from
775bd8deadSopenharmony_ci    input vertices to output vertices.  For example, consider the following
785bd8deadSopenharmony_ci    simple geometry shader in unextended OpenGL:
795bd8deadSopenharmony_ci
805bd8deadSopenharmony_ci      layout(triangles) in;
815bd8deadSopenharmony_ci      layout(triangle_strip) out;
825bd8deadSopenharmony_ci      layout(max_vertices=3) out;
835bd8deadSopenharmony_ci
845bd8deadSopenharmony_ci      in Inputs {
855bd8deadSopenharmony_ci        vec2 texcoord;
865bd8deadSopenharmony_ci        vec4 baseColor;
875bd8deadSopenharmony_ci      } v_in[];
885bd8deadSopenharmony_ci      out Outputs {
895bd8deadSopenharmony_ci        vec2 texcoord;
905bd8deadSopenharmony_ci        vec4 baseColor;
915bd8deadSopenharmony_ci      };
925bd8deadSopenharmony_ci
935bd8deadSopenharmony_ci      void main()
945bd8deadSopenharmony_ci      {
955bd8deadSopenharmony_ci        int layer = compute_layer();
965bd8deadSopenharmony_ci        for (int i = 0; i < 3; i++) {
975bd8deadSopenharmony_ci          gl_Position = gl_in[i].gl_Position;
985bd8deadSopenharmony_ci          texcoord = v_in[i].texcoord;
995bd8deadSopenharmony_ci          baseColor = v_in[i].baseColor;
1005bd8deadSopenharmony_ci          gl_Layer = layer;
1015bd8deadSopenharmony_ci          EmitVertex();
1025bd8deadSopenharmony_ci        }
1035bd8deadSopenharmony_ci      }
1045bd8deadSopenharmony_ci
1055bd8deadSopenharmony_ci    In this shader, the inputs "gl_Position", "Inputs.texcoord", and
1065bd8deadSopenharmony_ci    "Inputs.baseColor" are simply copied from the input vertex to the
1075bd8deadSopenharmony_ci    corresponding output vertex.  The only "interesting" work done by the
1085bd8deadSopenharmony_ci    geometry shader is computing and emitting a gl_Layer value for the
1095bd8deadSopenharmony_ci    primitive.
1105bd8deadSopenharmony_ci
1115bd8deadSopenharmony_ci    The following geometry shader, using this extension, is equivalent:
1125bd8deadSopenharmony_ci
1135bd8deadSopenharmony_ci      #extension GL_NV_geometry_shader_passthrough : require
1145bd8deadSopenharmony_ci
1155bd8deadSopenharmony_ci      layout(triangles) in;
1165bd8deadSopenharmony_ci      // No output primitive layout qualifiers required.
1175bd8deadSopenharmony_ci
1185bd8deadSopenharmony_ci      // Redeclare gl_PerVertex to pass through "gl_Position".
1195bd8deadSopenharmony_ci      layout(passthrough) in gl_PerVertex {
1205bd8deadSopenharmony_ci        vec4 gl_Position;
1215bd8deadSopenharmony_ci      } gl_in[];
1225bd8deadSopenharmony_ci
1235bd8deadSopenharmony_ci      // Declare "Inputs" with "passthrough" to automatically copy members.
1245bd8deadSopenharmony_ci      layout(passthrough) in Inputs {
1255bd8deadSopenharmony_ci        vec2 texcoord;
1265bd8deadSopenharmony_ci        vec4 baseColor;
1275bd8deadSopenharmony_ci      } v_in[];
1285bd8deadSopenharmony_ci
1295bd8deadSopenharmony_ci      // No output block declaration required.
1305bd8deadSopenharmony_ci
1315bd8deadSopenharmony_ci      void main()
1325bd8deadSopenharmony_ci      {
1335bd8deadSopenharmony_ci        // The shader simply computes and writes gl_Layer.  We don't
1345bd8deadSopenharmony_ci        // loop over three vertices or call EmitVertex().
1355bd8deadSopenharmony_ci        gl_Layer = compute_layer();
1365bd8deadSopenharmony_ci      }
1375bd8deadSopenharmony_ci
1385bd8deadSopenharmony_ciNew Procedures and Functions
1395bd8deadSopenharmony_ci
1405bd8deadSopenharmony_ci    None.
1415bd8deadSopenharmony_ci
1425bd8deadSopenharmony_ciNew Tokens
1435bd8deadSopenharmony_ci
1445bd8deadSopenharmony_ci    None.
1455bd8deadSopenharmony_ci
1465bd8deadSopenharmony_ciModifications to the OpenGL 4.3 Specification (Compatibility Profile)
1475bd8deadSopenharmony_ci
1485bd8deadSopenharmony_ci    Modify Section 11.3.4.5, Geometry Shader Outputs, p. 425
1495bd8deadSopenharmony_ci
1505bd8deadSopenharmony_ci    (add to the end of the section, p. 426):
1515bd8deadSopenharmony_ci
1525bd8deadSopenharmony_ci    For the purposes of component counting, passthrough geometry shaders count
1535bd8deadSopenharmony_ci    all active input variable components declared with the layout qualifier
1545bd8deadSopenharmony_ci    "passthrough" as output components as well, since their values will be
1555bd8deadSopenharmony_ci    copied to the output primitive produced by the geometry shader.
1565bd8deadSopenharmony_ci
1575bd8deadSopenharmony_ci
1585bd8deadSopenharmony_ciModifications to the OpenGL Shading Language Specification, Version 4.30
1595bd8deadSopenharmony_ci
1605bd8deadSopenharmony_ci    Including the following line in a shader can be used to control the
1615bd8deadSopenharmony_ci    language features described in this extension:
1625bd8deadSopenharmony_ci
1635bd8deadSopenharmony_ci      #extension GL_NV_geometry_shader_passthrough : <behavior>
1645bd8deadSopenharmony_ci
1655bd8deadSopenharmony_ci    where <behavior> is as specified in section 3.3.
1665bd8deadSopenharmony_ci
1675bd8deadSopenharmony_ci    New preprocessor #defines are added to the OpenGL Shading Language:
1685bd8deadSopenharmony_ci
1695bd8deadSopenharmony_ci      #define GL_NV_geometry_shader_passthrough         1
1705bd8deadSopenharmony_ci
1715bd8deadSopenharmony_ci    Modify Section 4.4.1.2, Geometry Shader Inputs (p. 57)
1725bd8deadSopenharmony_ci
1735bd8deadSopenharmony_ci    (add to the list of allowed layout qualifiers, p. 57)
1745bd8deadSopenharmony_ci
1755bd8deadSopenharmony_ci      layout-qualifier-id
1765bd8deadSopenharmony_ci        ...
1775bd8deadSopenharmony_ci        passthrough
1785bd8deadSopenharmony_ci
1795bd8deadSopenharmony_ci    (insert after discussion of the "invocations" layout qualifier, p. 57)
1805bd8deadSopenharmony_ci
1815bd8deadSopenharmony_ci    A geometry shader using the layout qualifier "passthrough" is considered a
1825bd8deadSopenharmony_ci    "passthrough geometry shader".  Output primitives in a passthrough
1835bd8deadSopenharmony_ci    geometry shader always have the same topology as the input primitive and
1845bd8deadSopenharmony_ci    are not produced by emitting vertices.  The vertices of the output
1855bd8deadSopenharmony_ci    primitive have two different types of attributes.  Geometry shader inputs
1865bd8deadSopenharmony_ci    qualified with "passthrough" are considered to produce per-vertex outputs,
1875bd8deadSopenharmony_ci    where values for each output vertex are copied from the corresponding
1885bd8deadSopenharmony_ci    input vertex.  Any built-in or user-defined geometry shader outputs are
1895bd8deadSopenharmony_ci    considered per-primitive in a passthrough geometry shader, where a single
1905bd8deadSopenharmony_ci    output value is copied to all output vertices.
1915bd8deadSopenharmony_ci
1925bd8deadSopenharmony_ci    The identifier "passthrough" can not be used to qualify "in", but can be
1935bd8deadSopenharmony_ci    used to qualify input variables, blocks, or block members.  It specifies
1945bd8deadSopenharmony_ci    that values of those inputs will be copied to the corresponding vertex of
1955bd8deadSopenharmony_ci    the output primitive.  Input variables and block members not qualified
1965bd8deadSopenharmony_ci    with "passthrough" will be consumed by the geometry shader without being
1975bd8deadSopenharmony_ci    passed through to subsequent stages.  For the purposes of matching
1985bd8deadSopenharmony_ci    passthrough geometry shader inputs with outputs of the previous pipeline
1995bd8deadSopenharmony_ci    stages, the "passthrough" qualifier itself is ignored.  For separable
2005bd8deadSopenharmony_ci    program objects (where geometry shader inputs and outputs may interface
2015bd8deadSopenharmony_ci    with inputs and outputs in other program objects), all inputs qualified
2025bd8deadSopenharmony_ci    with "passthrough" must also be assigned a location using the "location"
2035bd8deadSopenharmony_ci    layout qualifier.  It is a link-time error to specify a passthrough
2045bd8deadSopenharmony_ci    geometry shader input in a separable program without an explicitly
2055bd8deadSopenharmony_ci    assigned location.
2065bd8deadSopenharmony_ci
2075bd8deadSopenharmony_ci    For the purposes of matching the outputs of the geometry shader with
2085bd8deadSopenharmony_ci    subsequent pipeline stages, each input qualified with "passthrough" is
2095bd8deadSopenharmony_ci    considered to add an equivalent output with the same name, type, and
2105bd8deadSopenharmony_ci    qualification (except using "out" instead of "in") on the output
2115bd8deadSopenharmony_ci    interface.  The output declaration corresponding to an input variable
2125bd8deadSopenharmony_ci    qualified with "passthrough" will be identical to the input declaration,
2135bd8deadSopenharmony_ci    except that it will not be treated as arrayed.  The output block
2145bd8deadSopenharmony_ci    declaration corresponding to an input block qualified with "passthrough"
2155bd8deadSopenharmony_ci    or having members qualified with "passthrough" will be identical to the
2165bd8deadSopenharmony_ci    input declaration, except that it will not be treated as arrayed and will
2175bd8deadSopenharmony_ci    not have an instance name.  If an input block is qualified with
2185bd8deadSopenharmony_ci    "passthrough", the equivalent output block contains all the members of the
2195bd8deadSopenharmony_ci    input block.  Otherwise, the equivalent output block contains only those
2205bd8deadSopenharmony_ci    input block members qualified with "passthrough".  If such an input block
2215bd8deadSopenharmony_ci    is qualified with "location" or has members qualified with "location", all
2225bd8deadSopenharmony_ci    members of the corresponding output block members are assigned locations
2235bd8deadSopenharmony_ci    identical to those assigned to corresponding input block members.  All
2245bd8deadSopenharmony_ci    such outputs are associated with output vertex stream zero (section
2255bd8deadSopenharmony_ci    4.4.2.2).  Output variables and blocks generated from inputs qualified
2265bd8deadSopenharmony_ci    with "passthrough" will only be added to the name space of the output
2275bd8deadSopenharmony_ci    interface; these declarations will not be available to geometry shader
2285bd8deadSopenharmony_ci    code.  A program will fail to link if it contains a geometry shader output
2295bd8deadSopenharmony_ci    block with the same name as a geometry shader input block that is
2305bd8deadSopenharmony_ci    qualified with "passthrough" or contains a member qualified with
2315bd8deadSopenharmony_ci    "passthrough".
2325bd8deadSopenharmony_ci
2335bd8deadSopenharmony_ci    A compile-time error is generated if the non-arrayed input variables
2345bd8deadSopenharmony_ci    "gl_PrimitiveIDIn" or "gl_InvocationID" are redeclared with the
2355bd8deadSopenharmony_ci    "passthrough" layout qualifier.
2365bd8deadSopenharmony_ci
2375bd8deadSopenharmony_ci    A compile- or link-time error will be generated if a program contains a
2385bd8deadSopenharmony_ci    passthrough geometry shader and:
2395bd8deadSopenharmony_ci
2405bd8deadSopenharmony_ci      * declares a geometry shader input primitive type using layout
2415bd8deadSopenharmony_ci        qualifiers other than "points", "lines", or "triangles";
2425bd8deadSopenharmony_ci
2435bd8deadSopenharmony_ci      * declares a geometry shader output primitive type using the output
2445bd8deadSopenharmony_ci        layout qualifiers "points", "line_strip", or "triangle_strip" (section
2455bd8deadSopenharmony_ci        4.4.2.2);
2465bd8deadSopenharmony_ci
2475bd8deadSopenharmony_ci      * declares a geometry shader output primitive vertex count using the
2485bd8deadSopenharmony_ci        output layout qualifier "max_vertices";
2495bd8deadSopenharmony_ci
2505bd8deadSopenharmony_ci      * declares a geometry shader invocation count other than one using the
2515bd8deadSopenharmony_ci        input layout qualifier "invocations";
2525bd8deadSopenharmony_ci
2535bd8deadSopenharmony_ci      * declares a geometry shader output variable or block qualified with
2545bd8deadSopenharmony_ci        "stream" with an associated output vertex stream other than zero;
2555bd8deadSopenharmony_ci
2565bd8deadSopenharmony_ci      * includes geometry shader code calling the built-in functions
2575bd8deadSopenharmony_ci        EmitVertex(), EmitStreamVertex(), EndPrimitive(), or
2585bd8deadSopenharmony_ci        EndStreamPrimitive(); or
2595bd8deadSopenharmony_ci
2605bd8deadSopenharmony_ci      * is configured to use transform feedback, using either the geometry
2615bd8deadSopenharmony_ci        shader output layout qualifiers "xfb_offset", "xfb_stride", and
2625bd8deadSopenharmony_ci        "xfb_buffer", or using the OpenGL API command
2635bd8deadSopenharmony_ci        TransformFeedbackVaryings().
2645bd8deadSopenharmony_ci
2655bd8deadSopenharmony_ci    For the purposes of OpenGL API queries, passthrough geometry shaders are
2665bd8deadSopenharmony_ci    considered to include an output layout qualifier (section 4.4.2.2)
2675bd8deadSopenharmony_ci    specifying an output primitive type and maximum vertex count consistent
2685bd8deadSopenharmony_ci    with an equivalent non-passthrough geometry shader, as per the following
2695bd8deadSopenharmony_ci    table.
2705bd8deadSopenharmony_ci
2715bd8deadSopenharmony_ci        Input Layout            Output Layout
2725bd8deadSopenharmony_ci        ----------------        ------------------------------------------
2735bd8deadSopenharmony_ci        points                  layout(points, max_vertices=1) out;
2745bd8deadSopenharmony_ci        lines                   layout(line_strip, max_vertices=2) out;
2755bd8deadSopenharmony_ci        triangles               layout(triangle_strip, max_vertices=3) out;
2765bd8deadSopenharmony_ci
2775bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL Specifications
2785bd8deadSopenharmony_ci
2795bd8deadSopenharmony_ci    None.
2805bd8deadSopenharmony_ci
2815bd8deadSopenharmony_ciErrors
2825bd8deadSopenharmony_ci
2835bd8deadSopenharmony_ci    None.
2845bd8deadSopenharmony_ci
2855bd8deadSopenharmony_ciNew State
2865bd8deadSopenharmony_ci
2875bd8deadSopenharmony_ci    None.
2885bd8deadSopenharmony_ci
2895bd8deadSopenharmony_ciNew Implementation Dependent State
2905bd8deadSopenharmony_ci
2915bd8deadSopenharmony_ci    None.
2925bd8deadSopenharmony_ci
2935bd8deadSopenharmony_ci
2945bd8deadSopenharmony_ciInteractions with OpenGL ES 3.1
2955bd8deadSopenharmony_ci
2965bd8deadSopenharmony_ci    Unless made available by functionality similar to ARB_transform_feedback3
2975bd8deadSopenharmony_ci    and ARB_gpu_shader5, remove references to EmitStreamVertex() and
2985bd8deadSopenharmony_ci    EndStreamPrimitive(), the "stream = N" layout qualifier as well as
2995bd8deadSopenharmony_ci    the notion of multiple transform feedback streams.
3005bd8deadSopenharmony_ci
3015bd8deadSopenharmony_ciDependencies on OpenGL 4.4 and ARB_enhanced_layouts
3025bd8deadSopenharmony_ci
3035bd8deadSopenharmony_ci    If neither OpenGL 4.4 nor ARB_enhanced_layouts is supported, remove
3045bd8deadSopenharmony_ci    references to the use of the "xfb_offset", "xfb_buffer", and "xfb_stride"
3055bd8deadSopenharmony_ci    layout qualifiers for transform feedback.
3065bd8deadSopenharmony_ci
3075bd8deadSopenharmony_ciDependencies on NV_gpu_program4 and NV_geometry_program4
3085bd8deadSopenharmony_ci
3095bd8deadSopenharmony_ci    Modify Section 2.X.2, Program Grammar, of the NV_geometry_program4
3105bd8deadSopenharmony_ci    specification (which modifies the NV_gpu_program4 base grammar)
3115bd8deadSopenharmony_ci
3125bd8deadSopenharmony_ci    <declaration>               ::= "PASSTHROUGH" <resultUseD> <optWriteMask>
3135bd8deadSopenharmony_ci
3145bd8deadSopenharmony_ci    Modify Section 2.X.6, Program Options
3155bd8deadSopenharmony_ci
3165bd8deadSopenharmony_ci    + Passthrough Geometry Program (NV_geometry_program_passthrough)
3175bd8deadSopenharmony_ci
3185bd8deadSopenharmony_ci    If a geometry program specifies the "NV_geometry_program_passthrough"
3195bd8deadSopenharmony_ci    option, the program will be configured as a passthrough geometry program.
3205bd8deadSopenharmony_ci    A passthrough geometry program is configured to emit a new output
3215bd8deadSopenharmony_ci    primitive with the same type and vertex count as its input primitive.  For
3225bd8deadSopenharmony_ci    any result variable components written by a passthrough geometry program
3235bd8deadSopenharmony_ci    instruction, the values are broadcast to all vertices of the output
3245bd8deadSopenharmony_ci    primitive.  For any result binding components specified in PASSTHROUGH
3255bd8deadSopenharmony_ci    statements, the component values for each input primitive vertex are
3265bd8deadSopenharmony_ci    copied ("passed through") to their corresponding output primitive vertex
3275bd8deadSopenharmony_ci    without requiring geometry program code to copy attribute values and emit
3285bd8deadSopenharmony_ci    output primitive vertices.  A passthrough geometry program will fail to
3295bd8deadSopenharmony_ci    load if it contains an INVOCATIONS, PRIMITIVE_OUT, or VERTICES_OUT
3305bd8deadSopenharmony_ci    declaration, or an EMIT, EMITS, or ENDPRIM instruction.  A passthrough
3315bd8deadSopenharmony_ci    geometry program must declare an input primitive type of POINTS, LINES, or
3325bd8deadSopenharmony_ci    TRIANGLES, and the resulting output primitive produced will be a single
3335bd8deadSopenharmony_ci    point, line, or triangle, respectively.  The PASSTHROUGH declaration can
3345bd8deadSopenharmony_ci    be used only in programs using this option.
3355bd8deadSopenharmony_ci
3365bd8deadSopenharmony_ci
3375bd8deadSopenharmony_ci    Section 2.X.7.Y, Geometry Program Declarations
3385bd8deadSopenharmony_ci
3395bd8deadSopenharmony_ci    (modify the first paragraph of the section)
3405bd8deadSopenharmony_ci
3415bd8deadSopenharmony_ci    Geometry programs support three types of declaration statements specifying
3425bd8deadSopenharmony_ci    input and output primitive types, as described below. ....
3435bd8deadSopenharmony_ci
3445bd8deadSopenharmony_ci    (add to the end of the section)
3455bd8deadSopenharmony_ci
3465bd8deadSopenharmony_ci    Additionally, if the "NV_geometry_program_passthrough" option is
3475bd8deadSopenharmony_ci    specified, a geometry program can include zero or more instances of the
3485bd8deadSopenharmony_ci    following declaration statement:
3495bd8deadSopenharmony_ci
3505bd8deadSopenharmony_ci    - Passthrough Geometry Shader Attribute (PASSTHROUGH)
3515bd8deadSopenharmony_ci
3525bd8deadSopenharmony_ci    Each PASSTHROUGH declaration statement identifies a set of result binding
3535bd8deadSopenharmony_ci    components whose values for each vertex of the output primitive will be
3545bd8deadSopenharmony_ci    produced by copying the corresponding attribute binding components from
3555bd8deadSopenharmony_ci    the corresponding vertex of the input primitive.  The set of result
3565bd8deadSopenharmony_ci    bindings for which this copy is performed is identified by the
3575bd8deadSopenharmony_ci    <resultUseD> grammar rule.  For each such binding, the set of components
3585bd8deadSopenharmony_ci    to be copied is identified by the <optWriteMask> grammar rule.  If the
3595bd8deadSopenharmony_ci    write mask is omitted, all components of each binding are copied.  A
3605bd8deadSopenharmony_ci    program will fail to load if the binding identified by the <resultUseD>
3615bd8deadSopenharmony_ci    grammar rule does not have a corresponding attribute binding;
3625bd8deadSopenharmony_ci    "result.primid", "result.layer", and "result.viewport" may not be used.
3635bd8deadSopenharmony_ci    It is legal to specify an attribute binding more than once in a
3645bd8deadSopenharmony_ci    PASSTHROUGH declaration; a component will be passed through if and only if
3655bd8deadSopenharmony_ci    it is identified in one or more PASSTHROUGH declarations.  A program will
3665bd8deadSopenharmony_ci    fail to load if any result binding is both declared in a PASSTHROUGH
3675bd8deadSopenharmony_ci    statement and written by a program instruction, even if the set of
3685bd8deadSopenharmony_ci    components referenced is mutually exclusive.
3695bd8deadSopenharmony_ci
3705bd8deadSopenharmony_ci    Modify Section 13.2.2 of the OpenGL 4.3 Specification, p. 457
3715bd8deadSopenharmony_ci
3725bd8deadSopenharmony_ci    (insert before the errors section, p. 458)
3735bd8deadSopenharmony_ci
3745bd8deadSopenharmony_ci    Transform feedback can not be used with passthrough geometry programs.
3755bd8deadSopenharmony_ci    When transform back is active and not paused, an INVALID_OPERATION error
3765bd8deadSopenharmony_ci    is generated by any command that transfers vertices to the GL if the
3775bd8deadSopenharmony_ci    current geometry program was declared using the
3785bd8deadSopenharmony_ci    "NV_geometry_shader_passthrough" program option.
3795bd8deadSopenharmony_ci
3805bd8deadSopenharmony_ci
3815bd8deadSopenharmony_ciDependencies on NV_geometry_shader4 and NV_gpu_shader4
3825bd8deadSopenharmony_ci
3835bd8deadSopenharmony_ci    If NV_geometry_shader4 is supported, it is possible to change the maximum
3845bd8deadSopenharmony_ci    geometry shader output vertex count after linking a program.  The
3855bd8deadSopenharmony_ci    following language should be added to the end of the description of the
3865bd8deadSopenharmony_ci    the GEOMETRY_VERTICES_OUT_EXT <pname> for the ProgramParameteriEXT API in
3875bd8deadSopenharmony_ci    the NV_geometry_shader4 specification:
3885bd8deadSopenharmony_ci
3895bd8deadSopenharmony_ci      The error INVALID_OPERATION is generated by ProgramParameteriEXT if
3905bd8deadSopenharmony_ci      <program> identifies a program object that has been linked successfully
3915bd8deadSopenharmony_ci      and includes a passthrough geometry shader (one using the "passthrough"
3925bd8deadSopenharmony_ci      layout qualifier).
3935bd8deadSopenharmony_ci
3945bd8deadSopenharmony_ci    Note that NV_geometry_shader4 doesn't have its own extension string entry;
3955bd8deadSopenharmony_ci    it is considered present if and only if NV_gpu_shader4 is advertised.
3965bd8deadSopenharmony_ci
3975bd8deadSopenharmony_ciDependencies on NV_geometry_program4 and NV_gpu_program4
3985bd8deadSopenharmony_ci
3995bd8deadSopenharmony_ci    If NV_geometry_program4 is supported, it is possible to change the maximum
4005bd8deadSopenharmony_ci    output vertex count after compiling an assembly geometry program.  The
4015bd8deadSopenharmony_ci    following language should be added to the end of the description of the
4025bd8deadSopenharmony_ci    ProgramVertexLimitNV API:
4035bd8deadSopenharmony_ci
4045bd8deadSopenharmony_ci      The error INVALID_OPERATION is generated by ProgramVertexLimitNV if the
4055bd8deadSopenharmony_ci      current geometry program uses the NV_geometry_program_passthrough
4065bd8deadSopenharmony_ci      program option.
4075bd8deadSopenharmony_ci
4085bd8deadSopenharmony_ci    Note that NV_geometry_program4 doesn't have its own extension string
4095bd8deadSopenharmony_ci    entry; it is considered present if and only if NV_gpu_program4 is
4105bd8deadSopenharmony_ci    advertised.
4115bd8deadSopenharmony_ci
4125bd8deadSopenharmony_ciDependencies on NV_transform_feedback
4135bd8deadSopenharmony_ci
4145bd8deadSopenharmony_ci    If NV_transform_feedback is supported, the following language should be
4155bd8deadSopenharmony_ci    added to the end of the description of the TransformFeedbackVaryingsNV
4165bd8deadSopenharmony_ci    API:
4175bd8deadSopenharmony_ci
4185bd8deadSopenharmony_ci      The error INVALID_OPERATION is generated by TransformFeedbackVaryingsNV
4195bd8deadSopenharmony_ci      if <program> identifies a program containing a passthrough geometry
4205bd8deadSopenharmony_ci      shader (i.e., one using the "passthrough" layout qualifier).
4215bd8deadSopenharmony_ci
4225bd8deadSopenharmony_ciDependencies on NV_gpu_program4, NV_gpu_program5, NV_transform_feedback,
4235bd8deadSopenharmony_ciEXT_transform_feedback, and OpenGL 3.0:
4245bd8deadSopenharmony_ci
4255bd8deadSopenharmony_ci    If NV_gpu_program4 and/or NV_gpu_program5 is supported together with any
4265bd8deadSopenharmony_ci    of NV_transform_feedback, EXT_transform_feedback, or OpenGL 3.0 is
4275bd8deadSopenharmony_ci    supported, the following language should be added to the descriptions of
4285bd8deadSopenharmony_ci    BeginTransformFeedbackNV(), BeginTransformFeedbackEXT(), and
4295bd8deadSopenharmony_ci    BeginTransformFeedback() as applicable:
4305bd8deadSopenharmony_ci
4315bd8deadSopenharmony_ci      Transform feedback is not supported with passthrough geometry programs.
4325bd8deadSopenharmony_ci      The error INVALID_OPERATION error is generated if there is an active
4335bd8deadSopenharmony_ci      geometry program that uses the NV_geometry_program_passthrough program
4345bd8deadSopenharmony_ci      option.
4355bd8deadSopenharmony_ci
4365bd8deadSopenharmony_ci    Note that this issue doesn't apply to GLSL program objects, since we are
4375bd8deadSopenharmony_ci    making it impossible to successfully specify a program that uses transform
4385bd8deadSopenharmony_ci    feedback and a passthrough geometry shader concurrently.
4395bd8deadSopenharmony_ci
4405bd8deadSopenharmony_ciDependencies on NVX_shader_thread_group
4415bd8deadSopenharmony_ci
4425bd8deadSopenharmony_ci    If NVX_shader_thread_group is supported, the new built-in inputs provided
4435bd8deadSopenharmony_ci    by that extension should not be allowed as passthrough:
4445bd8deadSopenharmony_ci
4455bd8deadSopenharmony_ci      A compile-time error is generated if any of the non-arrayed input
4465bd8deadSopenharmony_ci      variables "gl_PrimitiveIDIn", "gl_InvocationID", "gl_ThreadInWarpNVX",
4475bd8deadSopenharmony_ci      "gl_ThreadEqMaskNVX", "gl_ThreadGeMaskNVX", "gl_ThreadGtMaskNVX",
4485bd8deadSopenharmony_ci      "gl_ThreadLeMaskNVX", "gl_ThreadLtMaskNVX", "gl_WarpIDNVX", or
4495bd8deadSopenharmony_ci      "gl_SMIDNVX" are redeclared with the "passthrough" layout qualifier.
4505bd8deadSopenharmony_ci
4515bd8deadSopenharmony_ci
4525bd8deadSopenharmony_ciIssues
4535bd8deadSopenharmony_ci
4545bd8deadSopenharmony_ci    (1) What should this extension be called?
4555bd8deadSopenharmony_ci
4565bd8deadSopenharmony_ci      RESOLVED:  NV_geometry_shader_passthrough.  The new layout qualifier
4575bd8deadSopenharmony_ci      specifies new semantics where primitives are largely "passed through" by
4585bd8deadSopenharmony_ci      the geometry shader, copying vertices of the input primitive to the
4595bd8deadSopenharmony_ci      output primitive.  The only operation performed by geometry shaders
4605bd8deadSopenharmony_ci      using this extension is to compute a collection of per-primitive
4615bd8deadSopenharmony_ci      attributes assigned to all vertices of the geometry shader.
4625bd8deadSopenharmony_ci
4635bd8deadSopenharmony_ci    (2) This extension is aimed at geometry shaders that show a specific
4645bd8deadSopenharmony_ci        pattern.  Why provide an explicit programming model in this extension,
4655bd8deadSopenharmony_ci        as opposed to automatically optimizing regular geometry shaders?
4665bd8deadSopenharmony_ci
4675bd8deadSopenharmony_ci      RESOLVED:  The hardware for which this extension was written provides
4685bd8deadSopenharmony_ci      explicit support for passing attributes of geometry shader input
4695bd8deadSopenharmony_ci      vertices through the geometry stage without an explicit copy.  While
4705bd8deadSopenharmony_ci      implementations supporting this extension may optimize geometry shaders
4715bd8deadSopenharmony_ci      to use this hardware, we provide an explicit programming model because
4725bd8deadSopenharmony_ci      (a) application developers may prefer to use this model for programming
4735bd8deadSopenharmony_ci      such shaders and (b) automatic optimization may fail to detect a
4745bd8deadSopenharmony_ci      "passthrough" pattern in some geometry shaders.
4755bd8deadSopenharmony_ci
4765bd8deadSopenharmony_ci    (3) How do passthrough geometry shaders interact with GLSL built-in
4775bd8deadSopenharmony_ci        variables?
4785bd8deadSopenharmony_ci
4795bd8deadSopenharmony_ci      RESOLVED:  Geometry shaders can redeclare the built-in input block
4805bd8deadSopenharmony_ci      "gl_PerVertex" with the "passthrough" layout qualifier to specify that
4815bd8deadSopenharmony_ci      built-in inputs like "gl_Position" should be passed through.  We allow
4825bd8deadSopenharmony_ci      the shader to qualify the entire redeclared block with "passthrough" to
4835bd8deadSopenharmony_ci      pass through all block members.  We also allow the shader to qualify
4845bd8deadSopenharmony_ci      individual block members with "passthrough" to pass through some, but
4855bd8deadSopenharmony_ci      not all, block members.
4865bd8deadSopenharmony_ci
4875bd8deadSopenharmony_ci    (4) How do passthrough geometry shaders interact with geometry shader
4885bd8deadSopenharmony_ci        instancing (using the "invocations=N" layout qualifier)?
4895bd8deadSopenharmony_ci
4905bd8deadSopenharmony_ci      RESOLVED:  We disallow the use of instancing in passthrough geometry
4915bd8deadSopenharmony_ci      shaders; it will result in a link error.
4925bd8deadSopenharmony_ci
4935bd8deadSopenharmony_ci      We considered specifying the features as orthogonal (with the
4945bd8deadSopenharmony_ci      passthrough geometry shader run N times), but consider the feature to be
4955bd8deadSopenharmony_ci      of limited utility.  Making N separate copies of the input primitive
4965bd8deadSopenharmony_ci      type isn't consistent with a model that largely passes through one
4975bd8deadSopenharmony_ci      single primitive.
4985bd8deadSopenharmony_ci
4995bd8deadSopenharmony_ci    (5) How do passthrough geometry shaders interact with transform feedback?
5005bd8deadSopenharmony_ci
5015bd8deadSopenharmony_ci      RESOLVED:  We disallow the use of transform feedback with programs with
5025bd8deadSopenharmony_ci      a passthrough geometry shader; it will result in a link error.
5035bd8deadSopenharmony_ci
5045bd8deadSopenharmony_ci      We considered specifying the features as orthogonal, but consider the
5055bd8deadSopenharmony_ci      feature to be of limited utility.  In particular, since inputs that are
5065bd8deadSopenharmony_ci      passed through the geometry shader don't have explicit output
5075bd8deadSopenharmony_ci      declarations, there is no way to control transform feedback using the
5085bd8deadSopenharmony_ci      "xfb_offset", "xfb_buffer", and "xfb_stride" layout qualifiers.  While
5095bd8deadSopenharmony_ci      it would still be possible to use the OpenGL API command
5105bd8deadSopenharmony_ci      TransformFeedbackVaryings() to specify passed through inputs to capture,
5115bd8deadSopenharmony_ci      we decided it wasn't worth the trouble.
5125bd8deadSopenharmony_ci
5135bd8deadSopenharmony_ci      For GLSL programs in unextended OpenGL 4.3, we can specify a link-time
5145bd8deadSopenharmony_ci      error to enforce this limitation.  For applications using GLSL programs
5155bd8deadSopenharmony_ci      and the NV_transform_feedback extension (where transform feedback
5165bd8deadSopenharmony_ci      varyings can be specified post-link), we throw an error when attempting
5175bd8deadSopenharmony_ci      to update transform feedback.  We will also prohibit the use of assembly
5185bd8deadSopenharmony_ci      programs with transform feedback for consistency, but need to specify a
5195bd8deadSopenharmony_ci      Draw-time error for that since transform feedback is completely
5205bd8deadSopenharmony_ci      decoupled from assembly program objects.
5215bd8deadSopenharmony_ci
5225bd8deadSopenharmony_ci    (6) How do passthrough geometry shaders interact with multi-stream
5235bd8deadSopenharmony_ci        geometry shader support (using the "stream=N" layout qualifier)?
5245bd8deadSopenharmony_ci
5255bd8deadSopenharmony_ci      RESOLVED:  All of the output vertices of a passthrough geometry shader
5265bd8deadSopenharmony_ci      are associated with output vertex stream zero.  Additionally, it is an
5275bd8deadSopenharmony_ci      error to declare a GLSL output variable with a stream other than zero.
5285bd8deadSopenharmony_ci
5295bd8deadSopenharmony_ci    (7) Do passthrough geometry shaders need to use layout qualifiers
5305bd8deadSopenharmony_ci        describing the output primitive type?
5315bd8deadSopenharmony_ci
5325bd8deadSopenharmony_ci      RESOLVED:  No.  We will not allow the use of these layout qualifiers
5335bd8deadSopenharmony_ci      with passthrough geometry shaders.  The output primitive type and vertex
5345bd8deadSopenharmony_ci      count will be taken directly from the input primitive type for such
5355bd8deadSopenharmony_ci      shaders.
5365bd8deadSopenharmony_ci
5375bd8deadSopenharmony_ci    (8) Inputs qualified with "passthrough" are copied to the vertices of the
5385bd8deadSopenharmony_ci        output primitive.  Do they show up on the PROGRAM_OUTPUT interface for
5395bd8deadSopenharmony_ci        program resource queries (e.g., GetProgramResourceiv)?
5405bd8deadSopenharmony_ci
5415bd8deadSopenharmony_ci      RESOLVED:  Yes, passed through variables, blocks, and block members
5425bd8deadSopenharmony_ci      appear on the output interface.
5435bd8deadSopenharmony_ci
5445bd8deadSopenharmony_ci    (9) How should geometry shaders indicate that they want to be
5455bd8deadSopenharmony_ci        "passthrough"?  Should we have some sort of declaration at global
5465bd8deadSopenharmony_ci        scope (e.g., "layout(passthrough) in") or infer it from the presence
5475bd8deadSopenharmony_ci        of one or more layout qualifiers on variables, blocks, or block
5485bd8deadSopenharmony_ci        members?
5495bd8deadSopenharmony_ci
5505bd8deadSopenharmony_ci      RESOLVED:  We consider a geometry shader to be passthrough if one or
5515bd8deadSopenharmony_ci      more input variables, blocks, or block members are qualified by
5525bd8deadSopenharmony_ci      "passthrough".  We won't require or allow the "passthrough" layout
5535bd8deadSopenharmony_ci      qualifier to be used on "in".
5545bd8deadSopenharmony_ci
5555bd8deadSopenharmony_ci      We considered requiring separate declarations for a global "passthrough"
5565bd8deadSopenharmony_ci      mode and passing through individual variables like this:
5575bd8deadSopenharmony_ci
5585bd8deadSopenharmony_ci        layout(passthrough) in;         // makes the shader passthrough
5595bd8deadSopenharmony_ci
5605bd8deadSopenharmony_ci        layout(passthrough) in Block {  // pass through the contents of <Block>
5615bd8deadSopenharmony_ci          ...
5625bd8deadSopenharmony_ci        } v_in[];
5635bd8deadSopenharmony_ci
5645bd8deadSopenharmony_ci      We decided not to do this in part because the inheritance semantics for
5655bd8deadSopenharmony_ci      other layout qualifiers might cause the casual programmer to expect that
5665bd8deadSopenharmony_ci      the applying the qualifier "passthrough" to in might cause all
5675bd8deadSopenharmony_ci      subsequent inputs to inherit "passthrough" behavior.
5685bd8deadSopenharmony_ci
5695bd8deadSopenharmony_ci        layout(passthrough) in;
5705bd8deadSopenharmony_ci        in Block {
5715bd8deadSopenharmony_ci          ...
5725bd8deadSopenharmony_ci        } v_in[];
5735bd8deadSopenharmony_ci
5745bd8deadSopenharmony_ci      We could have resolved this by using a second identifier (e.g.,
5755bd8deadSopenharmony_ci      "passthrough_shader") in the layout qualifier, but there don't seem to
5765bd8deadSopenharmony_ci      be any interesting cases where a passthrough geometry shader has no
5775bd8deadSopenharmony_ci      per-vertex outputs.  In particular, we expect pass-through geometry
5785bd8deadSopenharmony_ci      shaders to always pass through "gl_Position".
5795bd8deadSopenharmony_ci
5805bd8deadSopenharmony_ci    (10) Should we provide any query in the OpenGL API to determine whether a
5815bd8deadSopenharmony_ci         geometry shader is a "passthrough" shader?
5825bd8deadSopenharmony_ci
5835bd8deadSopenharmony_ci      RESOLVED:  We are not going to bother to do so in this extension; there
5845bd8deadSopenharmony_ci      are numerous other optional shader features lacking such query support.
5855bd8deadSopenharmony_ci
5865bd8deadSopenharmony_ci    (11) Should passthrough geometry shaders be allowed to write per-primitive
5875bd8deadSopenharmony_ci         values for arbitrary shader outputs or just the inherently
5885bd8deadSopenharmony_ci         per-primitive built-in outputs (e.g., gl_Layer, gl_ViewportIndex)?
5895bd8deadSopenharmony_ci
5905bd8deadSopenharmony_ci      RESOLVED:  We should allow passthrough geometry shaders to write to both
5915bd8deadSopenharmony_ci      built-in and user-defined outputs.  Any output variables declared in
5925bd8deadSopenharmony_ci      passthrough geometry shader without the "passthrough" layout qualifier
5935bd8deadSopenharmony_ci      are treated as per-primitive outputs and will be broadcast to all
5945bd8deadSopenharmony_ci      vertices in the output primitive.  For example, this shader
5955bd8deadSopenharmony_ci
5965bd8deadSopenharmony_ci        layout(passthrough) in;
5975bd8deadSopenharmony_ci        layout(passthrough) in gl_PerVertex {
5985bd8deadSopenharmony_ci          vec4 gl_Position;
5995bd8deadSopenharmony_ci        } gl_in[];
6005bd8deadSopenharmony_ci        out vec4 batman;
6015bd8deadSopenharmony_ci
6025bd8deadSopenharmony_ci        void main()
6035bd8deadSopenharmony_ci        {
6045bd8deadSopenharmony_ci          batman = compute_batman();
6055bd8deadSopenharmony_ci        }
6065bd8deadSopenharmony_ci
6075bd8deadSopenharmony_ci      will attach the value produced by compute_batman() to all the vertices
6085bd8deadSopenharmony_ci      of the output primitive.  The value of gl_Position for each vertex of
6095bd8deadSopenharmony_ci      the output primitive will be copied directly from the value of
6105bd8deadSopenharmony_ci      gl_Position for the corresponding input vertex.
6115bd8deadSopenharmony_ci
6125bd8deadSopenharmony_ci    (12) How do per-primitive outputs from passthrough geometry shaders
6135bd8deadSopenharmony_ci         interact with fragment shader inputs?
6145bd8deadSopenharmony_ci
6155bd8deadSopenharmony_ci      RESOLVED:  Per-primitive outputs will be broadcast to all the vertices
6165bd8deadSopenharmony_ci      of the output primitive, so reading the corresponding fragment shader
6175bd8deadSopenharmony_ci      input should yield the per-primitive output value.
6185bd8deadSopenharmony_ci
6195bd8deadSopenharmony_ci      We strongly recommend using the "flat" qualifier on all fragment shader
6205bd8deadSopenharmony_ci      inputs corresponding to per-primitive passthrough geometry shader
6215bd8deadSopenharmony_ci      outputs.  Using "flat" on such inputs may result in better performance
6225bd8deadSopenharmony_ci      when using passthrough geometry shaders.
6235bd8deadSopenharmony_ci
6245bd8deadSopenharmony_ci      We also recommend using the "flat" qualifier on such inputs to avoid
6255bd8deadSopenharmony_ci      possible arithmetic error that can result from evaluating
6265bd8deadSopenharmony_ci      perspective-correct interpolation equations.  For example,
6275bd8deadSopenharmony_ci      perspective-correct attribute interpolation for triangles uses the
6285bd8deadSopenharmony_ci      equation:
6295bd8deadSopenharmony_ci
6305bd8deadSopenharmony_ci        f = (a*f_a/w_a + b*f_b/w_b + c*f_c/w_c) / (a/w_a + b/w_b + c/w_c)
6315bd8deadSopenharmony_ci
6325bd8deadSopenharmony_ci      where a, b, and c are interpolation weights (adding to 1), f_a, f_b, and
6335bd8deadSopenharmony_ci      f_c are per-vertex attribute values, and w_a, w_b, and w_c are
6345bd8deadSopenharmony_ci      per-vertex clip w coordinates.  For per-primitive outputs, f_a == f_b ==
6355bd8deadSopenharmony_ci      f_c, which equals the per-primitive attribute value f_p, so the equation
6365bd8deadSopenharmony_ci      simplifies to:
6375bd8deadSopenharmony_ci
6385bd8deadSopenharmony_ci        f = (a*f_p/w_a + b*f_p/w_b + c*f_p/w_c) / (a/w_a + b/w_b + c/w_c)
6395bd8deadSopenharmony_ci          = f_p * (a/w_a + b/w_b + c/w_c) / (a/w_a + b/w_b + c/w_c)
6405bd8deadSopenharmony_ci
6415bd8deadSopenharmony_ci      At infinite precision, this computation will produce f_p, however there
6425bd8deadSopenharmony_ci      may be rounding error from the division operators that could result in
6435bd8deadSopenharmony_ci      low-order bit differences in the final interpolated value.
6445bd8deadSopenharmony_ci
6455bd8deadSopenharmony_ci    (13) What values are returned for queries of geometry shader-related
6465bd8deadSopenharmony_ci         program properties that are not specified passthrough geometry
6475bd8deadSopenharmony_ci         shaders (GEOMETRY_OUTPUT_TYPE, GEOMETRY_VERTICES_OUT)?
6485bd8deadSopenharmony_ci
6495bd8deadSopenharmony_ci      RESOLVED:  We will return values consistent with the input primitive
6505bd8deadSopenharmony_ci      type, as though a non-passthrough geometry shader were specified.  For
6515bd8deadSopenharmony_ci      example, if the input primitive type is "triangles", the shader will be
6525bd8deadSopenharmony_ci      treated as having declared:
6535bd8deadSopenharmony_ci
6545bd8deadSopenharmony_ci        layout(triangle_strip, max_vertices=3) out;
6555bd8deadSopenharmony_ci
6565bd8deadSopenharmony_ci    (14) Do passed through outputs count against the limit of total geometry
6575bd8deadSopenharmony_ci         shader output components?  What about the limit on the product of
6585bd8deadSopenharmony_ci         per-vertex components and vertices emitted?
6595bd8deadSopenharmony_ci
6605bd8deadSopenharmony_ci      RESOLVED:  Yes, we still want a limit on the total number of components
6615bd8deadSopenharmony_ci      in each output vertex.  Input components qualified by "passthrough" are
6625bd8deadSopenharmony_ci      also counted as output components for the purposes of both limit checks.
6635bd8deadSopenharmony_ci      We expect that the latter limit (on the product) will never be relevant
6645bd8deadSopenharmony_ci      because the total number of vertices in the output primitive can be at
6655bd8deadSopenharmony_ci      most three.
6665bd8deadSopenharmony_ci
6675bd8deadSopenharmony_ci    (15) How does this extension interact with the ability to change geometry
6685bd8deadSopenharmony_ci         shader output vertex counts, using ProgramParameteriEXT with
6695bd8deadSopenharmony_ci         GEOMETRY_VERTICES_OUT_EXT for GLSL programs (NV_geometry_shader4) or
6705bd8deadSopenharmony_ci         ProgramVertexLimitNV API for assembly programs
6715bd8deadSopenharmony_ci         (NV_geometry_program4)?
6725bd8deadSopenharmony_ci
6735bd8deadSopenharmony_ci      RESOLVED:  These commands allow applications to override the declared
6745bd8deadSopenharmony_ci      maximum output vertex counts for geometry shaders based on information
6755bd8deadSopenharmony_ci      known at runtime.  Given that passthrough geometry shaders (and assembly
6765bd8deadSopenharmony_ci      programs) will fail if they declare an output vertex count, it makes no
6775bd8deadSopenharmony_ci      sense to override a declaration that doesn't exist.  We will throw
6785bd8deadSopenharmony_ci      INVALID_OPERATION if you try to use these APIs with passthrough geometry
6795bd8deadSopenharmony_ci      shaders.
6805bd8deadSopenharmony_ci
6815bd8deadSopenharmony_ci    (16) Does this extension interact with separable program objects?
6825bd8deadSopenharmony_ci
6835bd8deadSopenharmony_ci      RESOLVED:  Yes.  All geometry shader inputs qualified with the
6845bd8deadSopenharmony_ci      "passthrough" layout qualifier must also have a location explicitly
6855bd8deadSopenharmony_ci      assigned using the "location" layout qualifier.  Failing to do so will
6865bd8deadSopenharmony_ci      result in a link-time error.
6875bd8deadSopenharmony_ci
6885bd8deadSopenharmony_ci      The reason for this restriction is that inputs/outputs of one separable
6895bd8deadSopenharmony_ci      program object may interface at run time with inputs/outputs of a
6905bd8deadSopenharmony_ci      different separable program object.  When linking one separable program
6915bd8deadSopenharmony_ci      object, the GL has no idea what other program objects it may be used
6925bd8deadSopenharmony_ci      with.  To avoid requiring GL implementations to dynamically link program
6935bd8deadSopenharmony_ci      objects X and Y at run time when they are used together, unextended
6945bd8deadSopenharmony_ci      OpenGL requires an "interface match" to get defined results passing
6955bd8deadSopenharmony_ci      values between stages.  Basically, the outputs of program X and inputs
6965bd8deadSopenharmony_ci      of program Y are considered to match:
6975bd8deadSopenharmony_ci
6985bd8deadSopenharmony_ci        * for entire programs, if the set of declared inputs and outputs in
6995bd8deadSopenharmony_ci          the programs are identical in name (or location, if assigned), type,
7005bd8deadSopenharmony_ci          and qualification; or
7015bd8deadSopenharmony_ci
7025bd8deadSopenharmony_ci        * for individual inputs, if the input has a matching output with
7035bd8deadSopenharmony_ci          compatible type and qualification, if both variables use the same
7045bd8deadSopenharmony_ci          location layout qualifier.
7055bd8deadSopenharmony_ci
7065bd8deadSopenharmony_ci      The idea behind the exact matching requirement is that if you have
7075bd8deadSopenharmony_ci      identical declarations on both sides of the interface, the
7085bd8deadSopenharmony_ci      compiler/linker can employ a deterministic algorithm to assign locations
7095bd8deadSopenharmony_ci      internally, based solely on the declared inputs/outputs.  For such an
7105bd8deadSopenharmony_ci      algorithm, the variables on both sides of the interface will naturally
7115bd8deadSopenharmony_ci      get the same locations.  For a program pipeline with separate vertex,
7125bd8deadSopenharmony_ci      geometry, and fragment programs with "entire program" matches, this
7135bd8deadSopenharmony_ci      implies that:
7145bd8deadSopenharmony_ci
7155bd8deadSopenharmony_ci        * vertex outputs and geometry inputs are declared identically, and so
7165bd8deadSopenharmony_ci          the compiler will assign the same locations; and
7175bd8deadSopenharmony_ci
7185bd8deadSopenharmony_ci        * geometry outputs and fragment inputs are declared identically, and
7195bd8deadSopenharmony_ci          so the compiler will assign the same locations.
7205bd8deadSopenharmony_ci
7215bd8deadSopenharmony_ci      The problem with this extension is that its implementation introduces
7225bd8deadSopenharmony_ci      one additional constraint -- the internal location assigned to a
7235bd8deadSopenharmony_ci      passthrough geometry shader input must match the location assigned to
7245bd8deadSopenharmony_ci      the matching implicitly-declared output.  Adding this constraint to the
7255bd8deadSopenharmony_ci      two bullets in the previous example implies that for any variable used
7265bd8deadSopenharmony_ci      as a passthrough input in a geometry shader, there is one additional
7275bd8deadSopenharmony_ci      rule:
7285bd8deadSopenharmony_ci
7295bd8deadSopenharmony_ci        * the vertex outputs and fragment inputs matching a passthrough
7305bd8deadSopenharmony_ci          geometry shader input must have the same locations.
7315bd8deadSopenharmony_ci
7325bd8deadSopenharmony_ci      However, when the vertex and fragment program are linked, they have no
7335bd8deadSopenharmony_ci      idea which variables might interface with a passthrough geometry shader
7345bd8deadSopenharmony_ci      input.  And there is clearly no constraint that the vertex outputs and
7355bd8deadSopenharmony_ci      fragment inputs be declared identically -- some vertex outputs may be
7365bd8deadSopenharmony_ci      consumed by the geometry shader, and some fragment inputs may be
7375bd8deadSopenharmony_ci      produced (not by copy) by the geometry shader.  Generating matching
7385bd8deadSopenharmony_ci      locations without more information is basically impossible.
7395bd8deadSopenharmony_ci
7405bd8deadSopenharmony_ci      As a result, we require that the passthrough geometry shader inputs in
7415bd8deadSopenharmony_ci      separable programs must be declared with a location.  Combining this
7425bd8deadSopenharmony_ci      restriction with normal shader interface matching rules, it implies that
7435bd8deadSopenharmony_ci      "matching" vertex outputs and fragment inputs must also be declared with
7445bd8deadSopenharmony_ci      identical locations to get a complete interface match.
7455bd8deadSopenharmony_ci
7465bd8deadSopenharmony_ci      This limitation doesn't apply to non-separable programs; the linker is
7475bd8deadSopenharmony_ci      able to see all program interfaces and can assign internal locations for
7485bd8deadSopenharmony_ci      all stages that satisfy the relevant constraints.  The linker could
7495bd8deadSopenharmony_ci      successfully assign internal locations for separable programs containing
7505bd8deadSopenharmony_ci      multiple stages (e.g., GS+FS with no VS), but we chose to apply this
7515bd8deadSopenharmony_ci      restriction to all separable programs for simplicity.
7525bd8deadSopenharmony_ci
7535bd8deadSopenharmony_ci    (17) When an input block or any of its members is qualified with
7545bd8deadSopenharmony_ci         "passthrough", this extension creates an implicitly declared
7555bd8deadSopenharmony_ci         corresponding output block containing all members to be passed
7565bd8deadSopenharmony_ci         through.  How does this feature interact with the "location" layout
7575bd8deadSopenharmony_ci         qualifier?
7585bd8deadSopenharmony_ci
7595bd8deadSopenharmony_ci      RESOLVED:  All members of the output block are treated as having
7605bd8deadSopenharmony_ci      explicitly assigned locations inherited from matching input block
7615bd8deadSopenharmony_ci      members.  For example, if you had a geometry shader input block declared
7625bd8deadSopenharmony_ci      as:
7635bd8deadSopenharmony_ci
7645bd8deadSopenharmony_ci        layout(location=0) in Block {
7655bd8deadSopenharmony_ci          layout(passthrough) vec4 a;  // assigned location 0
7665bd8deadSopenharmony_ci                              vec4 b;  // assigned location 1
7675bd8deadSopenharmony_ci          layout(passthrough) vec4 c;  // assigned location 2
7685bd8deadSopenharmony_ci        } v_in[];
7695bd8deadSopenharmony_ci
7705bd8deadSopenharmony_ci      the corresponding output block is treated as though it were declared as:
7715bd8deadSopenharmony_ci
7725bd8deadSopenharmony_ci        out Block {
7735bd8deadSopenharmony_ci          layout(location=0) vec4 a;
7745bd8deadSopenharmony_ci          layout(location=2) vec4 c;
7755bd8deadSopenharmony_ci        };
7765bd8deadSopenharmony_ci
7775bd8deadSopenharmony_ci      A fragment shader matching with such a shader must include a similar
7785bd8deadSopenharmony_ci      input block declaration to get a complete interface match.
7795bd8deadSopenharmony_ci
7805bd8deadSopenharmony_ci      To avoid the need to use location layout qualifiers on a
7815bd8deadSopenharmony_ci      member-by-member basis, a shader author using blocks with location
7825bd8deadSopenharmony_ci      qualifiers could choose to segregate passthrough and other inputs into
7835bd8deadSopenharmony_ci      separate blocks.  Alternately, all the passthrough inputs could be
7845bd8deadSopenharmony_ci      placed at the beginning of the geometry input block, which would result
7855bd8deadSopenharmony_ci      in a "normal" output block, except that the non-passthrough inputs would
7865bd8deadSopenharmony_ci      be dropped.
7875bd8deadSopenharmony_ci
7885bd8deadSopenharmony_ci    (18) Do built-in or user-defined inputs qualified with "passthrough" need
7895bd8deadSopenharmony_ci         to be "arrayed"?
7905bd8deadSopenharmony_ci
7915bd8deadSopenharmony_ci      RESOLVED:  Yes.  Normal geometry shader inputs must be declared in
7925bd8deadSopenharmony_ci      "arrayed" form, where each vertex has its own set of inputs.  Blocks
7935bd8deadSopenharmony_ci      must be declared as an array of instances:
7945bd8deadSopenharmony_ci
7955bd8deadSopenharmony_ci        in Block {
7965bd8deadSopenharmony_ci          vec4 a;
7975bd8deadSopenharmony_ci        } v_in[];
7985bd8deadSopenharmony_ci
7995bd8deadSopenharmony_ci      and non-block inputs must be declared as arrays:
8005bd8deadSopenharmony_ci
8015bd8deadSopenharmony_ci        in vec4 a[];  // <a> is indexed by input vertex number
8025bd8deadSopenharmony_ci
8035bd8deadSopenharmony_ci      It is illegal to declare non-arrayed geometry shader inputs, since it
8045bd8deadSopenharmony_ci      wouldn't be clear which vertex to use when accessing such inputs.
8055bd8deadSopenharmony_ci
8065bd8deadSopenharmony_ci      Passthrough geometry shaders don't change this requirement.
8075bd8deadSopenharmony_ci      Additionally, the requirement still applies even if no code in the
8085bd8deadSopenharmony_ci      passthrough geometry shader reads from the input.  Note that in older
8095bd8deadSopenharmony_ci      versions of this specification, some examples declared passthrough
8105bd8deadSopenharmony_ci      inputs that were missing the per-vertex array declaration.
8115bd8deadSopenharmony_ci
8125bd8deadSopenharmony_ciRevision History
8135bd8deadSopenharmony_ci
8145bd8deadSopenharmony_ci    Revision 4, 2017/02/15 (pbrown)
8155bd8deadSopenharmony_ci      - Fix syntax issues in various sample code, including the introduction.
8165bd8deadSopenharmony_ci        Passthrough inputs need to be declared as "arrayed" (with a separate
8175bd8deadSopenharmony_ci        block instance for each vertex).  Added issue (18) to clarify further.
8185bd8deadSopenharmony_ci
8195bd8deadSopenharmony_ci    Revision 3, 2015/04/06 (mjk)
8205bd8deadSopenharmony_ci      - Fix typos
8215bd8deadSopenharmony_ci
8225bd8deadSopenharmony_ci    Revision 2, 2015/03/27
8235bd8deadSopenharmony_ci      - Add ES interactions
8245bd8deadSopenharmony_ci
8255bd8deadSopenharmony_ci    Revision 1
8265bd8deadSopenharmony_ci      - Internal revisions.
8275bd8deadSopenharmony_ci
828