15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    EXT_separate_shader_objects
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_EXT_separate_shader_objects
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContact
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    Mark Kilgard, NVIDIA (mjk 'at' nvidia.com)
125bd8deadSopenharmony_ci
135bd8deadSopenharmony_ciContributors
145bd8deadSopenharmony_ci
155bd8deadSopenharmony_ci    Pat Brown
165bd8deadSopenharmony_ci    Eric Werness
175bd8deadSopenharmony_ci    Robert Ohannessian
185bd8deadSopenharmony_ci    Jason Green, TransGaming
195bd8deadSopenharmony_ci    Kevin Rogovin 
205bd8deadSopenharmony_ci    Greg Roth
215bd8deadSopenharmony_ci
225bd8deadSopenharmony_ciStatus
235bd8deadSopenharmony_ci
245bd8deadSopenharmony_ci    Shipping in NVIDIA 190.00 release drivers
255bd8deadSopenharmony_ci
265bd8deadSopenharmony_ci    NOTE: there is an unrelated OpenGL ES extension also named
275bd8deadSopenharmony_ci    "GL_EXT_separate_shader_objects", found in the OpenGL ES extension
285bd8deadSopenharmony_ci    registry at http://www.khronos.org/registry/gles/ . These two extensions
295bd8deadSopenharmony_ci    have similar purposes, but completely different interfaces.
305bd8deadSopenharmony_ci
315bd8deadSopenharmony_ciVersion
325bd8deadSopenharmony_ci
335bd8deadSopenharmony_ci    Last Modified Date:  March 7, 2013
345bd8deadSopenharmony_ci    Version:             11
355bd8deadSopenharmony_ci
365bd8deadSopenharmony_ciNumber
375bd8deadSopenharmony_ci
385bd8deadSopenharmony_ci    377
395bd8deadSopenharmony_ci
405bd8deadSopenharmony_ciDependencies
415bd8deadSopenharmony_ci
425bd8deadSopenharmony_ci    Written based on the wording of the OpenGL 3.0 (August 11, 2008)
435bd8deadSopenharmony_ci    specification.
445bd8deadSopenharmony_ci
455bd8deadSopenharmony_ci    This extension requires OpenGL 2.0 or ARB_shader_objects.
465bd8deadSopenharmony_ci
475bd8deadSopenharmony_ci    This extension depends on ARB_geometry_shader4, EXT_geometry_shader4,
485bd8deadSopenharmony_ci    and/or NV_geometry_shader4.
495bd8deadSopenharmony_ci
505bd8deadSopenharmony_ciOverview
515bd8deadSopenharmony_ci
525bd8deadSopenharmony_ci    Prior to this extension, GLSL requires multiple shader domains
535bd8deadSopenharmony_ci    (vertex, fragment, geometry) to be linked into a single monolithic
545bd8deadSopenharmony_ci    program object to specify a GLSL shader for each domain.
555bd8deadSopenharmony_ci
565bd8deadSopenharmony_ci    While GLSL's monolithic approach has some advantages for
575bd8deadSopenharmony_ci    optimizing shaders as a unit that span multiple domains, all
585bd8deadSopenharmony_ci    existing GPU hardware supports the more flexible mix-and-match
595bd8deadSopenharmony_ci    approach.
605bd8deadSopenharmony_ci
615bd8deadSopenharmony_ci    HLSL9, Cg, the prior OpenGL assembly program extensions, and game
625bd8deadSopenharmony_ci    console programmers favor a more flexible "mix-and-match" approach to
635bd8deadSopenharmony_ci    specifying shaders independently for these different shader domains.
645bd8deadSopenharmony_ci    Many developers build their shader content around the mix-and-match
655bd8deadSopenharmony_ci    approach where they can use a single vertex shader with multiple
665bd8deadSopenharmony_ci    fragment shaders (or vice versa).
675bd8deadSopenharmony_ci
685bd8deadSopenharmony_ci    This keep-it-simple extension adapts the "mix-and-match" shader
695bd8deadSopenharmony_ci    domain model for GLSL so different GLSL program objects can be bound
705bd8deadSopenharmony_ci    to different shader domains.
715bd8deadSopenharmony_ci
725bd8deadSopenharmony_ci    This extension redefines the operation of glUseProgram(GLenum program)
735bd8deadSopenharmony_ci    to be equivalent to:
745bd8deadSopenharmony_ci
755bd8deadSopenharmony_ci        glUseShaderProgramEXT(GL_VERTEX_SHADER, program);
765bd8deadSopenharmony_ci        glUseShaderProgramEXT(GL_GEOMETRY_SHADER_EXT, program);
775bd8deadSopenharmony_ci        glUseShaderProgramEXT(GL_FRAGMENT_SHADER, program);
785bd8deadSopenharmony_ci        glActiveProgramEXT(program);
795bd8deadSopenharmony_ci
805bd8deadSopenharmony_ci    You can also call these commands separately to bind each respective
815bd8deadSopenharmony_ci    domain.  The GL_VERTEX_SHADER, GL_GEOMETRY_SHADER_EXT, and
825bd8deadSopenharmony_ci    GL_FRAGMENT_SHADER tokens refer to the conventional vertex, geometry,
835bd8deadSopenharmony_ci    and fragment domains respectively.  glActiveProgramEXT specifies
845bd8deadSopenharmony_ci    the program that glUniform* commands will update.
855bd8deadSopenharmony_ci
865bd8deadSopenharmony_ci    Separate linking creates the possibility that certain output varyings
875bd8deadSopenharmony_ci    of a shader may go unread by the subsequent shader inputting varyings.
885bd8deadSopenharmony_ci    In this case, the output varyings are simply ignored.  It is also
895bd8deadSopenharmony_ci    possible input varyings from a shader may not be written as output
905bd8deadSopenharmony_ci    varyings of a preceding shader.  In this case, the unwritten input
915bd8deadSopenharmony_ci    varying values are undefined.  Implementations are encouraged to
925bd8deadSopenharmony_ci    zero these undefined input varying values.
935bd8deadSopenharmony_ci
945bd8deadSopenharmony_ci    This extension is a proof-of-concept that separate shader objects
955bd8deadSopenharmony_ci    can work for GLSL and a response to repeated requests for this
965bd8deadSopenharmony_ci    functionality.  There are various loose ends, particularly when
975bd8deadSopenharmony_ci    dealing with user-defined varyings.  The hope is a future extension
985bd8deadSopenharmony_ci    will improve this situation.
995bd8deadSopenharmony_ci
1005bd8deadSopenharmony_ciNew Procedures and Functions
1015bd8deadSopenharmony_ci
1025bd8deadSopenharmony_ci    void UseShaderProgramEXT(enum type, uint program);
1035bd8deadSopenharmony_ci
1045bd8deadSopenharmony_ci    void ActiveProgramEXT(uint program);
1055bd8deadSopenharmony_ci
1065bd8deadSopenharmony_ci    uint CreateShaderProgramEXT(enum type, const char *string);
1075bd8deadSopenharmony_ci
1085bd8deadSopenharmony_ciNew Tokens
1095bd8deadSopenharmony_ci
1105bd8deadSopenharmony_ci    Accepted by <type> parameter to GetIntegerv and GetFloatv:
1115bd8deadSopenharmony_ci
1125bd8deadSopenharmony_ci        ACTIVE_PROGRAM_EXT                     0x8B8D (alias for CURRENT_PROGRAM)
1135bd8deadSopenharmony_ci
1145bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL 3.0 Specification (OpenGL Operation)
1155bd8deadSopenharmony_ci
1165bd8deadSopenharmony_ci -- Section 2.20.2 "Program Objects" (page 91) 
1175bd8deadSopenharmony_ci
1185bd8deadSopenharmony_ci    Add this paragraph after the 6th paragraph:
1195bd8deadSopenharmony_ci
1205bd8deadSopenharmony_ci    "The command
1215bd8deadSopenharmony_ci
1225bd8deadSopenharmony_ci        uint CreateShaderProgramEXT(enum type, const char *sting);
1235bd8deadSopenharmony_ci
1245bd8deadSopenharmony_ci    creates a stand-alone program from a source code string for a single
1255bd8deadSopenharmony_ci    shader type.  This command is equivalent to the following command
1265bd8deadSopenharmony_ci    sequence:
1275bd8deadSopenharmony_ci
1285bd8deadSopenharmony_ci        const uint shader = CreateShader(type);
1295bd8deadSopenharmony_ci        if (shader) {
1305bd8deadSopenharmony_ci            const int len = (int) strlen(string);
1315bd8deadSopenharmony_ci            ShaderSource(shader, 1, &string, &len);
1325bd8deadSopenharmony_ci            CompileShader(shader);
1335bd8deadSopenharmony_ci            const uint program = CreateProgram();
1345bd8deadSopenharmony_ci            if (program) {
1355bd8deadSopenharmony_ci                int compiled = FALSE;
1365bd8deadSopenharmony_ci                GetShaderiv(shader, COMPILE_STATUS, &compiled);
1375bd8deadSopenharmony_ci                if (compiled) {
1385bd8deadSopenharmony_ci                    AttachShader(program, shader);
1395bd8deadSopenharmony_ci                    LinkProgram(program);
1405bd8deadSopenharmony_ci                    DetachShader(program, shader);
1415bd8deadSopenharmony_ci                }
1425bd8deadSopenharmony_ci
1435bd8deadSopenharmony_ci                // Possibly...
1445bd8deadSopenharmony_ci                if (active-user-defined-varyings-in-linked-program) {
1455bd8deadSopenharmony_ci                    append-error-to-info-log
1465bd8deadSopenharmony_ci                    set-program-link-status-false
1475bd8deadSopenharmony_ci                }
1485bd8deadSopenharmony_ci
1495bd8deadSopenharmony_ci                append-shader-info-log-to-program-info-log
1505bd8deadSopenharmony_ci            }
1515bd8deadSopenharmony_ci            DeleteShader(shader);
1525bd8deadSopenharmony_ci            return program;
1535bd8deadSopenharmony_ci        } else {
1545bd8deadSopenharmony_ci            return 0;
1555bd8deadSopenharmony_ci        }
1565bd8deadSopenharmony_ci
1575bd8deadSopenharmony_ci    Notice the program may not actually link if the linked program would
1585bd8deadSopenharmony_ci    contain active user-defined varyings (because such varyings would
1595bd8deadSopenharmony_ci    not be well-defined for a single shader domain).  If this situation
1605bd8deadSopenharmony_ci    arises, the info log may explain this.
1615bd8deadSopenharmony_ci
1625bd8deadSopenharmony_ci    Because no shader is returned by CreateShaderProgramEXT and the shader
1635bd8deadSopenharmony_ci    that is created is deleted in the course of the command sequence,
1645bd8deadSopenharmony_ci    the info log of the shader object is copied to the program so the
1655bd8deadSopenharmony_ci    shader's failed info log for the failed compilation is accessible
1665bd8deadSopenharmony_ci    to the application."
1675bd8deadSopenharmony_ci
1685bd8deadSopenharmony_ci    Replace the 7th paragraph with:
1695bd8deadSopenharmony_ci
1705bd8deadSopenharmony_ci    "If a valid executable is created, it can be made part of the current
1715bd8deadSopenharmony_ci    rendering state with the command:
1725bd8deadSopenharmony_ci
1735bd8deadSopenharmony_ci           void UseShaderProgramEXT(enum type, uint program);
1745bd8deadSopenharmony_ci
1755bd8deadSopenharmony_ci    where type is one of VERTEX_SHADER, GEOMETRY_SHADER_ARB, or
1765bd8deadSopenharmony_ci    FRAGMENT_SHADER program shader types, and program is the program
1775bd8deadSopenharmony_ci    object program containing valid executable code, i.e. has been linked
1785bd8deadSopenharmony_ci    successfully.  Based on the type, the program becomes the current
1795bd8deadSopenharmony_ci    vertex, fragment, or geometry shader program respectively and the
1805bd8deadSopenharmony_ci    command installs the executable code as part of the respective current
1815bd8deadSopenharmony_ci    rendering state.  If UseShaderProgramEXT is called with program set
1825bd8deadSopenharmony_ci    to zero, it is as if the GL has no respective (vertex, geometry,
1835bd8deadSopenharmony_ci    or fragment) programmable stage configured and the corresponding
1845bd8deadSopenharmony_ci    fixed-function path will be used instead.  If program has not been
1855bd8deadSopenharmony_ci    successfully linked, the error INVALID_OPERATION is generated and
1865bd8deadSopenharmony_ci    the respective current shader state is not modified.
1875bd8deadSopenharmony_ci
1885bd8deadSopenharmony_ci    The command
1895bd8deadSopenharmony_ci
1905bd8deadSopenharmony_ci        void ActiveProgramEXT(uint program);
1915bd8deadSopenharmony_ci
1925bd8deadSopenharmony_ci    sets the linked program named by program to be the active program
1935bd8deadSopenharmony_ci    (discussed later in the "Uniform Variables" subsection of section
1945bd8deadSopenharmony_ci    2.20.3).  If program has not been successfully linked, the error
1955bd8deadSopenharmony_ci    INVALID_OPERATION is generated and active program is not modified.
1965bd8deadSopenharmony_ci
1975bd8deadSopenharmony_ci    The command
1985bd8deadSopenharmony_ci
1995bd8deadSopenharmony_ci        void UseProgram(uint program);
2005bd8deadSopenharmony_ci
2015bd8deadSopenharmony_ci    is equivalent (modulo errors) to calling
2025bd8deadSopenharmony_ci
2035bd8deadSopenharmony_ci        UseShaderProgramEXT(VERTEX_SHADER, program);
2045bd8deadSopenharmony_ci        UseShaderProgramEXT(GEOMETRY_SHADER_EXT, program);
2055bd8deadSopenharmony_ci        UseShaderProgramEXT(FRAGMENT_SHADER, program);
2065bd8deadSopenharmony_ci        ActiveProgramEXT(program);
2075bd8deadSopenharmony_ci
2085bd8deadSopenharmony_ci    If a program object contains multiple shader types but is not bound
2095bd8deadSopenharmony_ci    for all its supported shader types, the program object's shader
2105bd8deadSopenharmony_ci    types not bound do not affect GL's current rendering operation."
2115bd8deadSopenharmony_ci
2125bd8deadSopenharmony_ci -- Section 2.15.3 "Shader Variables" (page 97) 
2135bd8deadSopenharmony_ci
2145bd8deadSopenharmony_ci    Replace the 15th paragraph of the "Uniform Variables" section:
2155bd8deadSopenharmony_ci
2165bd8deadSopenharmony_ci    "To load values into the uniform variables of the active program
2175bd8deadSopenharmony_ci    object (specified by ActiveProgramEXT), use the commands ..."
2185bd8deadSopenharmony_ci
2195bd8deadSopenharmony_ci    Change the last bullet in the "Uniform Variables" section to:
2205bd8deadSopenharmony_ci
2215bd8deadSopenharmony_ci    "* if there is no active program in use."
2225bd8deadSopenharmony_ci
2235bd8deadSopenharmony_ci -- Section 2.20.4 "Shader Execution" (page 103) 
2245bd8deadSopenharmony_ci
2255bd8deadSopenharmony_ci    Change the first paragraph to read:
2265bd8deadSopenharmony_ci
2275bd8deadSopenharmony_ci    "If a successfully linked program object that contains a vertex
2285bd8deadSopenharmony_ci    shader is made current by calling UseShaderProgramEXT with a type of
2295bd8deadSopenharmony_ci    VERTEX_SHADER, the executable version of the vertex shader is used to
2305bd8deadSopenharmony_ci    process incoming vertex values rather than the fixed-function vertex
2315bd8deadSopenharmony_ci    processing described in section 2.11 through 2.14.  In particular,
2325bd8deadSopenharmony_ci    ..."
2335bd8deadSopenharmony_ci
2345bd8deadSopenharmony_ci -- Section 2.20.5 "Required State" (page 109) 
2355bd8deadSopenharmony_ci
2365bd8deadSopenharmony_ci    Change the last paragraph to read:
2375bd8deadSopenharmony_ci
2385bd8deadSopenharmony_ci    "Additionally, four unsigned integers (initially all zero) are
2395bd8deadSopenharmony_ci    required to hold the each respective name of the current vertex
2405bd8deadSopenharmony_ci    shader program, current geometry shader program, current fragment
2415bd8deadSopenharmony_ci    shader program, and active program respectively."
2425bd8deadSopenharmony_ci
2435bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL 3.0 Specification (Rasterization)
2445bd8deadSopenharmony_ci
2455bd8deadSopenharmony_ci -- Section 3.12 "Fragment Shaders" (page 231) 
2465bd8deadSopenharmony_ci
2475bd8deadSopenharmony_ci    Replace the second to the last paragraph with:
2485bd8deadSopenharmony_ci
2495bd8deadSopenharmony_ci    "When the current fragment shader program object currently includes
2505bd8deadSopenharmony_ci    a fragment shader, its fragment shader is considered active, and is
2515bd8deadSopenharmony_ci    used to process fragments.  If the fragment shader program object
2525bd8deadSopenharmony_ci    has no fragment shader, or no fragment shader program object is
2535bd8deadSopenharmony_ci    currently in use, the fixed-function fragment processing operations
2545bd8deadSopenharmony_ci    described in the previous sections are used."
2555bd8deadSopenharmony_ci
2565bd8deadSopenharmony_ci -- Section 3.12.1 "Shader Variables" (page 232) 
2575bd8deadSopenharmony_ci
2585bd8deadSopenharmony_ci    Add this paragraph after the third paragraph:
2595bd8deadSopenharmony_ci
2605bd8deadSopenharmony_ci    "User-defined varying values are well-defined only when the fragment
2615bd8deadSopenharmony_ci    shader program object and the preceding programmable shading stage,
2625bd8deadSopenharmony_ci    either the geometry shader stage if the geometry shader program
2635bd8deadSopenharmony_ci    object contains geometry shader or else the vertex shader stage
2645bd8deadSopenharmony_ci    if the vertex shader program object contains a vertex shader, are
2655bd8deadSopenharmony_ci    the same program object.  So user-defined varying values are only
2665bd8deadSopenharmony_ci    well-defined when both the varying variable's output shader and
2675bd8deadSopenharmony_ci    input shader are the same program object.
2685bd8deadSopenharmony_ci
2695bd8deadSopenharmony_ci    In order to ensure well-defined behavior between a fragment shader
2705bd8deadSopenharmony_ci    program with a different preceding geometry shader program or
2715bd8deadSopenharmony_ci    vertex shader program when the current geometry shader program is
2725bd8deadSopenharmony_ci    zero, applications must use the built-in varying variables such
2735bd8deadSopenharmony_ci    as gl_TexCoord[0].  If the current fragment shader program object
2745bd8deadSopenharmony_ci    uses user-defined input varying variables when the preceded current
2755bd8deadSopenharmony_ci    geometry shader program is not the same program object or, in the
2765bd8deadSopenharmony_ci    case the geometry shader program is zero, the preceding current
2775bd8deadSopenharmony_ci    vertex shader program object is not the same program object, then
2785bd8deadSopenharmony_ci    the values of such input varying variables are undefined.
2795bd8deadSopenharmony_ci
2805bd8deadSopenharmony_ci    The state of user-defined varying inputs to a fragment shader
2815bd8deadSopenharmony_ci    are undefined /even if/ the preceding shader has varying outputs
2825bd8deadSopenharmony_ci    that match the same name and type of the subsequent shader.
2835bd8deadSopenharmony_ci    Implementations are encouraged but not required to force these
2845bd8deadSopenharmony_ci    undefined input varying variables to zero."
2855bd8deadSopenharmony_ci
2865bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL 3.0 Specification (Per-Fragment
2875bd8deadSopenharmony_ciOperations and the Frame Buffer)
2885bd8deadSopenharmony_ci
2895bd8deadSopenharmony_ci    None
2905bd8deadSopenharmony_ci
2915bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL 3.0 Specification (Special
2925bd8deadSopenharmony_ciFunctions)
2935bd8deadSopenharmony_ci
2945bd8deadSopenharmony_ci    None
2955bd8deadSopenharmony_ci
2965bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL 3.0 Specification (State and
2975bd8deadSopenharmony_ciState Requests)
2985bd8deadSopenharmony_ci
2995bd8deadSopenharmony_ci -- Section 5.4 "Display Lists" (page 311) 
3005bd8deadSopenharmony_ci
3015bd8deadSopenharmony_ci    Add "CreateShaderProgramEXT" to the "Program and shader objects"
3025bd8deadSopenharmony_ci    list of commands that cannot be compiled into a display list but
3035bd8deadSopenharmony_ci    are instead executed immediately.
3045bd8deadSopenharmony_ci
3055bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL Specifications
3065bd8deadSopenharmony_ci
3075bd8deadSopenharmony_ci    None
3085bd8deadSopenharmony_ci
3095bd8deadSopenharmony_ciAdditions to the OpenGL Shading Language
3105bd8deadSopenharmony_ci
3115bd8deadSopenharmony_ci    None
3125bd8deadSopenharmony_ci
3135bd8deadSopenharmony_ciAdditions to the ARB_geometry_shader4 specification
3145bd8deadSopenharmony_ci
3155bd8deadSopenharmony_ci -- Section 2.16, Geometry Shaders
3165bd8deadSopenharmony_ci
3175bd8deadSopenharmony_ci    Replace the 3rd and 4th paragraphs to read:
3185bd8deadSopenharmony_ci
3195bd8deadSopenharmony_ci    "Geometry shaders are created as described in section 2.15.1 using a
3205bd8deadSopenharmony_ci    type parameter of GEOMETRY_SHADER_ARB. They are attached to and used
3215bd8deadSopenharmony_ci    in program objects as described in section 2.15.2. When a geometry
3225bd8deadSopenharmony_ci    shader program object currently in use includes a geometry shader,
3235bd8deadSopenharmony_ci    its geometry shader is considered active, and is used to process
3245bd8deadSopenharmony_ci    primitives. If the geometry shader program object has no geometry
3255bd8deadSopenharmony_ci    shader, or no program object is in use, this new primitive processing
3265bd8deadSopenharmony_ci    pipeline stage is bypassed.
3275bd8deadSopenharmony_ci
3285bd8deadSopenharmony_ci    A program object that includes a geometry shader without a vertex
3295bd8deadSopenharmony_ci    shader must only use built-in input varying variables; otherwise
3305bd8deadSopenharmony_ci    a link error may occur."
3315bd8deadSopenharmony_ci
3325bd8deadSopenharmony_ci -- Section 2.16.4, Geometry Shader Execution Environment
3335bd8deadSopenharmony_ci
3345bd8deadSopenharmony_ci    Change the first paragraph to read:
3355bd8deadSopenharmony_ci
3365bd8deadSopenharmony_ci    "If a successfully linked program object that contains a geometry shader is
3375bd8deadSopenharmony_ci    made current as the geometry shader program object by calling
3385bd8deadSopenharmony_ci    UseShaderProgramEXT with a type of GL_GEOMETRY_SHADER_ARB, the
3395bd8deadSopenharmony_ci    executable version of the geometry shader is used to process
3405bd8deadSopenharmony_ci    primitives resulting from the primitive assembly stage."
3415bd8deadSopenharmony_ci
3425bd8deadSopenharmony_ci    Add these paragraphs to the end of the section:
3435bd8deadSopenharmony_ci
3445bd8deadSopenharmony_ci    "User-defined varying values are well-defined only when the geometry
3455bd8deadSopenharmony_ci    shader program object and the preceding vertex shader program object
3465bd8deadSopenharmony_ci    are the same program object.  So user-defined varying values are only
3475bd8deadSopenharmony_ci    well-defined when both the varying variable's output shader and
3485bd8deadSopenharmony_ci    input shader are the same program object.
3495bd8deadSopenharmony_ci
3505bd8deadSopenharmony_ci    In order to ensure well-defined behavior between a geometry shader
3515bd8deadSopenharmony_ci    program with a different preceding vertex shader program, applications
3525bd8deadSopenharmony_ci    must use the built-in varying variables such as gl_TexCoord[0].
3535bd8deadSopenharmony_ci    If the current geometry shader program object uses user-defined
3545bd8deadSopenharmony_ci    input varying variables when the preceded current vertex shader
3555bd8deadSopenharmony_ci    program object is not the same program object, then the values of
3565bd8deadSopenharmony_ci    such input varying variables are undefined.
3575bd8deadSopenharmony_ci
3585bd8deadSopenharmony_ci    The state of user-defined varying inputs to a geometry shader
3595bd8deadSopenharmony_ci    are undefined /even if/ the preceding vertex shader has varying
3605bd8deadSopenharmony_ci    outputs that match the same name and type of the subsequent shader.
3615bd8deadSopenharmony_ci    Implementations are encouraged but not required to force these
3625bd8deadSopenharmony_ci    undefined input varying variables to zero."
3635bd8deadSopenharmony_ci
3645bd8deadSopenharmony_ciGLX Protocol
3655bd8deadSopenharmony_ci
3665bd8deadSopenharmony_ci    UNDER DEVELOPMENT
3675bd8deadSopenharmony_ci
3685bd8deadSopenharmony_ciErrors
3695bd8deadSopenharmony_ci
3705bd8deadSopenharmony_ci    UseShaderProgramEXT generates INVALID_ENUM if the type parameter is
3715bd8deadSopenharmony_ci    not one of VERTEX_SHADER, GEOMETRY_SHADER_ARB, or FRAGMENT_SHADER.
3725bd8deadSopenharmony_ci
3735bd8deadSopenharmony_ci    UseShaderProgramEXT generates INVALID_OPERATION if the program
3745bd8deadSopenharmony_ci    parameter has not been successfully linked.
3755bd8deadSopenharmony_ci
3765bd8deadSopenharmony_ci    UseShaderProgramEXT generates INVALID_OPERATION if transform feedback
3775bd8deadSopenharmony_ci    is active.
3785bd8deadSopenharmony_ci
3795bd8deadSopenharmony_ci    ActiveProgramEXT generates INVALID_OPERATION if the program parameter
3805bd8deadSopenharmony_ci    has not been successfully linked.
3815bd8deadSopenharmony_ci
3825bd8deadSopenharmony_ci    LinkProgram NO LONGER generates an INVALID_OPERATION if the program
3835bd8deadSopenharmony_ci    object has a geometry shader attached and no vertex shader attached
3845bd8deadSopenharmony_ci    as long as the geometry shader uses only built-in varying input
3855bd8deadSopenharmony_ci    variables.
3865bd8deadSopenharmony_ci
3875bd8deadSopenharmony_ciDependencies on ARB_geometry_shader4, EXT_geometry_shader4, and/or NV_geometry_shader4
3885bd8deadSopenharmony_ci
3895bd8deadSopenharmony_ci    If none of ARB_geometry_shader4, EXT_geometry_shader4, or
3905bd8deadSopenharmony_ci    NV_geometry_shader4 are supported by the implementation, ignore all
3915bd8deadSopenharmony_ci    references to geometry shaders and generate an INVALID_ENUM error
3925bd8deadSopenharmony_ci    when UseShaderProgramEXT is called with the token GEOMETRY_SHADER_ARB.
3935bd8deadSopenharmony_ci
3945bd8deadSopenharmony_ciNew State
3955bd8deadSopenharmony_ci
3965bd8deadSopenharmony_ci    Remove CURRENT_PROGRAM from table 6.30 (Program Object State) and
3975bd8deadSopenharmony_ci    append these rows:
3985bd8deadSopenharmony_ci
3995bd8deadSopenharmony_ci    Get Value            Type  Get Command  Initial Value  Description               Sec     Attribute
4005bd8deadSopenharmony_ci    -------------------  ----  -----------  -------------  ------------------------  ------  ---------
4015bd8deadSopenharmony_ci    ACTIVE_PROGRAM_EXT   Z+    GetIntegerv  0              The program object        2.20.2  -
4025bd8deadSopenharmony_ci    (alias for                                             that Uniform* commands
4035bd8deadSopenharmony_ci     CURRENT_PROGRAM)                                      update
4045bd8deadSopenharmony_ci    VERTEX_SHADER        Z+    GetIntegerv  0              Name of current vertex    2.20.2  -
4055bd8deadSopenharmony_ci                                                           shader program object
4065bd8deadSopenharmony_ci    GEOMETRY_SHADER_ARB  Z+    GetIntegerv  0              Name of current geometry  2.20.2  -
4075bd8deadSopenharmony_ci                                                           shader program object
4085bd8deadSopenharmony_ci    FRAGMENT_SHADER      Z+    GetIntegerv  0              Name of current fragment  2.20.2  -
4095bd8deadSopenharmony_ci                                                           shader program object
4105bd8deadSopenharmony_ci                                                    
4115bd8deadSopenharmony_ciNew Implementation Dependent State
4125bd8deadSopenharmony_ci
4135bd8deadSopenharmony_ci    None
4145bd8deadSopenharmony_ci
4155bd8deadSopenharmony_ciIssues
4165bd8deadSopenharmony_ci
4175bd8deadSopenharmony_ci    1.  What should this extension be called?
4185bd8deadSopenharmony_ci
4195bd8deadSopenharmony_ci        RESOLVED:  EXT_separate_shader_objects
4205bd8deadSopenharmony_ci
4215bd8deadSopenharmony_ci        The adjective "separate" is used in several extension names
4225bd8deadSopenharmony_ci        (EXT_blend_equation_separate, EXT_blend_func_separate,
4235bd8deadSopenharmony_ci        EXT_separate_specular_color, ATI_separate_stencil) when joined
4245bd8deadSopenharmony_ci        state is made configurable separately.
4255bd8deadSopenharmony_ci
4265bd8deadSopenharmony_ci        The phrase "shader_objects" refers generally to GLSL shader
4275bd8deadSopenharmony_ci        objects, matching the ARB_shader_objects name.
4285bd8deadSopenharmony_ci
4295bd8deadSopenharmony_ci        Whether the name should be "separate_shader_objects"
4305bd8deadSopenharmony_ci        or "shader_objects_separate" is less clear.  The various
4315bd8deadSopenharmony_ci        "separate" extensions have different conventions as to whether
4325bd8deadSopenharmony_ci        separate is prefixed or suffixed with the separated state.
4335bd8deadSopenharmony_ci        The prefixed form is more natural to say aloud, is consistent
4345bd8deadSopenharmony_ci        with the ATI_separate_stencil naming approach, and abbreviates
4355bd8deadSopenharmony_ci        to SSO (instead of the inopportune abbreviation SOS).
4365bd8deadSopenharmony_ci
4375bd8deadSopenharmony_ci    2.  What happens to a user-defined input varying variable that are
4385bd8deadSopenharmony_ci        not written by a preceding shader's write to the corresponding
4395bd8deadSopenharmony_ci        output varying variable.
4405bd8deadSopenharmony_ci
4415bd8deadSopenharmony_ci        RESOLVED:  The input variable variable's value is left undefined.
4425bd8deadSopenharmony_ci        Implementations are encouraged but not required to zero the
4435bd8deadSopenharmony_ci        value.
4445bd8deadSopenharmony_ci
4455bd8deadSopenharmony_ci        GLSL has a "rendezvous by name" model for connecting varying
4465bd8deadSopenharmony_ci        output variables to varying input variables of a subsequent
4475bd8deadSopenharmony_ci        shader.  With separate shaders, there's no assurance whether a
4485bd8deadSopenharmony_ci        preceding shader will write a given user-defined input varying
4495bd8deadSopenharmony_ci        variable.  HLSL9, Cg, and OpenGL assembly extension programs
4505bd8deadSopenharmony_ci        handle this situation by with "rendezvous by API resource" model.
4515bd8deadSopenharmony_ci        In GLSL terms, this means separate GLSL shaders /must/ communicate
4525bd8deadSopenharmony_ci        by built-in varying variables rather than user-defined varying
4535bd8deadSopenharmony_ci        variables.
4545bd8deadSopenharmony_ci
4555bd8deadSopenharmony_ci        It is undesirable from a performance standpoint to attempt to
4565bd8deadSopenharmony_ci        support "rendezvous by name" for arbitrary separate shaders
4575bd8deadSopenharmony_ci        because the separate shaders won't be naturally compiled to
4585bd8deadSopenharmony_ci        match their varying inputs and outputs of the same name without
4595bd8deadSopenharmony_ci        a special link step.  Such a special link would introduce an
4605bd8deadSopenharmony_ci        extra validation overhead to binding separate shaders.  The link
4615bd8deadSopenharmony_ci        itself would have to be deferred until glBegin time since separate
4625bd8deadSopenharmony_ci        shaders won't match when transitioning from one set of consistent
4635bd8deadSopenharmony_ci        shaders to another.  This special link would still create errors
4645bd8deadSopenharmony_ci        or undefined behavior when the names of input and output varyings
4655bd8deadSopenharmony_ci        matched but their types did not match.
4665bd8deadSopenharmony_ci
4675bd8deadSopenharmony_ci        Also the expectation from other shading APIs that support
4685bd8deadSopenharmony_ci        mix-and-match shader usage is that "rendezvous by API resource"
4695bd8deadSopenharmony_ci        is the expected norm.
4705bd8deadSopenharmony_ci
4715bd8deadSopenharmony_ci        Specifying the behavior being undefined allows a future ARB
4725bd8deadSopenharmony_ci        version of this extension to be more specific without encumbering
4735bd8deadSopenharmony_ci        this extension with enforcing a specific error.
4745bd8deadSopenharmony_ci
4755bd8deadSopenharmony_ci    3.  Do different program objects currently used by different shader
4765bd8deadSopenharmony_ci        types share a single name space for uniforms?
4775bd8deadSopenharmony_ci
4785bd8deadSopenharmony_ci        RESOLVED:  No, different program objects have their own separate
4795bd8deadSopenharmony_ci        name space for uniforms and each has locations specific to its
4805bd8deadSopenharmony_ci        unique program object.
4815bd8deadSopenharmony_ci
4825bd8deadSopenharmony_ci    4.  How do the glUniform* commands determine what program object
4835bd8deadSopenharmony_ci        to query?
4845bd8deadSopenharmony_ci
4855bd8deadSopenharmony_ci        RESOLVED:  This extension introduces the active program specified
4865bd8deadSopenharmony_ci        by glActiveProgramEXT (similar to the active texture selector
4875bd8deadSopenharmony_ci        specified by glActiveTexture) to specify the selector used by
4885bd8deadSopenharmony_ci        glUniform* commands.
4895bd8deadSopenharmony_ci
4905bd8deadSopenharmony_ci        This active program is simply a selector and doesn't actually
4915bd8deadSopenharmony_ci        control any rendering operation.
4925bd8deadSopenharmony_ci
4935bd8deadSopenharmony_ci        The active program can be queried with glGetIntegerv with
4945bd8deadSopenharmony_ci        the GL_ACTIVE_PROGRAM_EXT token which is an alias for
4955bd8deadSopenharmony_ci        GL_CURRENT_PROGRAM.
4965bd8deadSopenharmony_ci
4975bd8deadSopenharmony_ci        As an alternative to setting the GL_ACTIVE_PROGRAM_EXT selector
4985bd8deadSopenharmony_ci        with glActiveProgramEXT, applications are instead encouraged
4995bd8deadSopenharmony_ci        to use the glProgramUniform* commands introduced by the
5005bd8deadSopenharmony_ci        EXT_direct_state_access extension which do not depend on a
5015bd8deadSopenharmony_ci        selector but specify the program object with which to update
5025bd8deadSopenharmony_ci        the specified uniform location explicitly.
5035bd8deadSopenharmony_ci
5045bd8deadSopenharmony_ci    5.  Do the glGetUniform* queries depend on the active program state
5055bd8deadSopenharmony_ci        (GL_ACTIVE_PROGRAM_EXT)?
5065bd8deadSopenharmony_ci
5075bd8deadSopenharmony_ci        RESOLVED:  No, the glGetUniform* queries take the program
5085bd8deadSopenharmony_ci        object for the query as an explicit parameter to the query.
5095bd8deadSopenharmony_ci        These commands do not rely on a selector.
5105bd8deadSopenharmony_ci
5115bd8deadSopenharmony_ci    6a. Should the fragment shader program object be allowed to changed
5125bd8deadSopenharmony_ci        within transform feedback mode?
5135bd8deadSopenharmony_ci
5145bd8deadSopenharmony_ci        RESOLVED:  No, this should generate a GL_INVALID_OPERATION error.
5155bd8deadSopenharmony_ci
5165bd8deadSopenharmony_ci        The OpenGL 3.0 and EXT_transform_feedback specifications say
5175bd8deadSopenharmony_ci        glUseProgram generates a GL_INVALID_OPERATION error when transform
5185bd8deadSopenharmony_ci        feedback is active.
5195bd8deadSopenharmony_ci
5205bd8deadSopenharmony_ci        The rationale for this is that user-defined varying outputs from
5215bd8deadSopenharmony_ci        the vertex or geometry shader might change.
5225bd8deadSopenharmony_ci
5235bd8deadSopenharmony_ci        Perhaps it is desirable to allow different shader program objects
5245bd8deadSopenharmony_ci        when transform feedback mode is active, but this extension
5255bd8deadSopenharmony_ci        doesn't change the existing GLSL error behavior.  In fact,
5265bd8deadSopenharmony_ci        glUseShaderProgramEXT generate the same error glUseProgram does.
5275bd8deadSopenharmony_ci
5285bd8deadSopenharmony_ci    6b. Should the active program be allowed to changed within transform
5295bd8deadSopenharmony_ci        feedback mode?
5305bd8deadSopenharmony_ci
5315bd8deadSopenharmony_ci        RESOLVED:  Yes.
5325bd8deadSopenharmony_ci
5335bd8deadSopenharmony_ci        The active program simply allows uniforms to be changed but
5345bd8deadSopenharmony_ci        doesn't actually change how the graphics pipeline itself is
5355bd8deadSopenharmony_ci        configured or what programs are used for vertex, geometry,
5365bd8deadSopenharmony_ci        and fragment processing.
5375bd8deadSopenharmony_ci
5385bd8deadSopenharmony_ci    7.  What if a program object contains shaders from two domains, say
5395bd8deadSopenharmony_ci        both a vertex shader and a geometry shader, and the program object
5405bd8deadSopenharmony_ci        is just used as the current fragment shader program object?
5415bd8deadSopenharmony_ci
5425bd8deadSopenharmony_ci        RESOLVED:  The vertex shader within the program object is
5435bd8deadSopenharmony_ci        simply ignored.
5445bd8deadSopenharmony_ci
5455bd8deadSopenharmony_ci    8.  What if a program object contains both a vertex and fragment
5465bd8deadSopenharmony_ci        shader and this program object is bound to both the current
5475bd8deadSopenharmony_ci        vertex shader and fragment shader program object but there is
5485bd8deadSopenharmony_ci        also a different geometry shader program object bound?
5495bd8deadSopenharmony_ci
5505bd8deadSopenharmony_ci        RESOLVED:  This works as long as the vertex shader and fragment
5515bd8deadSopenharmony_ci        shader rely on built-in varying variables to communicate and don't
5525bd8deadSopenharmony_ci        depend on passing values between each other with user-defined
5535bd8deadSopenharmony_ci        varying variables because such variables are undefined if an
5545bd8deadSopenharmony_ci        intervening different geometry shader program object is currently
5555bd8deadSopenharmony_ci        used.  Specifically, the vertex shader will output to its
5565bd8deadSopenharmony_ci        built-in varying output variables and the different geometry
5575bd8deadSopenharmony_ci        shader program object can read those built-in varying values
5585bd8deadSopenharmony_ci        through input varying variables.  Likewise the fragment shader
5595bd8deadSopenharmony_ci        can use built-in varying input variables to get varying data
5605bd8deadSopenharmony_ci        from the different geometry shader program object.
5615bd8deadSopenharmony_ci
5625bd8deadSopenharmony_ci    9.  Is glUseShaderProgramEXT allowed to be compiled within a
5635bd8deadSopenharmony_ci        display list?
5645bd8deadSopenharmony_ci
5655bd8deadSopenharmony_ci        RESOLVED:  Yes, just like glUseProgram is allowed within a
5665bd8deadSopenharmony_ci        display list.
5675bd8deadSopenharmony_ci
5685bd8deadSopenharmony_ci    10. Should there be some easier to use API for creating a GLSL
5695bd8deadSopenharmony_ci        program that programs a single shader type?
5705bd8deadSopenharmony_ci
5715bd8deadSopenharmony_ci        RESOLVED:  Yes, see the glCreateShaderProgramEXT command.
5725bd8deadSopenharmony_ci
5735bd8deadSopenharmony_ci        The existing GLSL API for creating a GLSL program involves a lot
5745bd8deadSopenharmony_ci        of steps to support multiple source strings, re-specification of
5755bd8deadSopenharmony_ci        source code, attaching and detaching multiple shader objects,
5765bd8deadSopenharmony_ci        and cross-domain linking.  These features are not particularly
5775bd8deadSopenharmony_ci        relevant for creating separate shader programs.
5785bd8deadSopenharmony_ci
5795bd8deadSopenharmony_ci    11. Can glCreateShaderProgramEXT be compiled into a display list?
5805bd8deadSopenharmony_ci
5815bd8deadSopenharmony_ci        RESOLVED:  No.
5825bd8deadSopenharmony_ci
5835bd8deadSopenharmony_ci        glCreateShaderProgramEXT is equivalent to a sequence of commands
5845bd8deadSopenharmony_ci        that are themselves not allowed to be compiled  into a display
5855bd8deadSopenharmony_ci        list.
5865bd8deadSopenharmony_ci
5875bd8deadSopenharmony_ci    12. Should glCreateShaderProgramEXT allow user-defined varyings?
5885bd8deadSopenharmony_ci
5895bd8deadSopenharmony_ci        RESOLVED:   User-defined varyings are permitted (without error)
5905bd8deadSopenharmony_ci        but shouldn't be used because their behavior is not defined.
5915bd8deadSopenharmony_ci
5925bd8deadSopenharmony_ci        glCreateShaderProgramEXT is likely to be used for compiling
5935bd8deadSopenharmony_ci        separate shaders.  The tenative resolution to issue 2 says the
5945bd8deadSopenharmony_ci        values of user-defined varying input varaibles are undefined if
5955bd8deadSopenharmony_ci        the preceding shader doesn't belong to the same program object.
5965bd8deadSopenharmony_ci        Since the programs returned by glCreateShaderProgramEXT are
5975bd8deadSopenharmony_ci        always for a single domain, there's no point allowing user-defined
5985bd8deadSopenharmony_ci        varyings if they can't be assumed to be well-defined.
5995bd8deadSopenharmony_ci
6005bd8deadSopenharmony_ci    13. How are interpolation modifiers handled for separate shader
6015bd8deadSopenharmony_ci        programs?
6025bd8deadSopenharmony_ci
6035bd8deadSopenharmony_ci        RESOLVED:  For now, interpolation modifiers aren't supported
6045bd8deadSopenharmony_ci        for separate shader object varyings.
6055bd8deadSopenharmony_ci
6065bd8deadSopenharmony_ci        Future resolution:  Unfortunately GLSL only provides interpolation
6075bd8deadSopenharmony_ci        modifiers for user-defined varyings which aren't well-defined
6085bd8deadSopenharmony_ci        for separate shader programs.
6095bd8deadSopenharmony_ci
6105bd8deadSopenharmony_ci        In the short-term, interpolation modifiers aren't commonly used
6115bd8deadSopenharmony_ci        so not supporting interpolation modifiers for seperate GLSL
6125bd8deadSopenharmony_ci        shader programs is probably acceptable.
6135bd8deadSopenharmony_ci
6145bd8deadSopenharmony_ci        Long-term, GLSL can be extended with #pragma constructs that
6155bd8deadSopenharmony_ci        specify to the compiler the interpolation modifier for a given
6165bd8deadSopenharmony_ci        fragment shader built-in varying.  Something like:
6175bd8deadSopenharmony_ci
6185bd8deadSopenharmony_ci            #pragma interpolation(gl_TexCoord[0], centroid)
6195bd8deadSopenharmony_ci            #pragma interpolation(gl_TexCoord[1], flat)
6205bd8deadSopenharmony_ci            #pragma interpolation(gl_TexCoord[2], smooth)
6215bd8deadSopenharmony_ci            #pragma interpolation(gl_TexCoord[3], invariant)
6225bd8deadSopenharmony_ci            #pragma interpolation(gl_TexCoord[4], noperspective)
6235bd8deadSopenharmony_ci
6245bd8deadSopenharmony_ci        This pragma is only legal within a fragment shader compilation
6255bd8deadSopenharmony_ci        unit.  The pragma can be specified multiple times, but
6265bd8deadSopenharmony_ci        inconsistent specification of a specific built-in varying's
6275bd8deadSopenharmony_ci        interpolation is not allowed.
6285bd8deadSopenharmony_ci
6295bd8deadSopenharmony_ci        Alternatively, this extenion could add new built-in input varying
6305bd8deadSopenharmony_ci        variables for the fragment shader:
6315bd8deadSopenharmony_ci
6325bd8deadSopenharmony_ci            // TexCoord category
6335bd8deadSopenharmony_ci            varying in centroid               vec4  gl_CentroidTexCoord[];
6345bd8deadSopenharmony_ci            varying in centroid noperspective vec4  gl_CentroidNoPerspectiveTexCoord[];
6355bd8deadSopenharmony_ci            varying in float                  vec4  gl_FlatTexCoord[];
6365bd8deadSopenharmony_ci            varying in noperspective          vec4  gl_NoPerspectiveTexCoord[];
6375bd8deadSopenharmony_ci            varying in                        ivec4 gl_IntTexCoord[];
6385bd8deadSopenharmony_ci
6395bd8deadSopenharmony_ci            // Color category
6405bd8deadSopenharmony_ci            varying in centroid               vec4  gl_CentroidColor;
6415bd8deadSopenharmony_ci
6425bd8deadSopenharmony_ci            // Secondary color category
6435bd8deadSopenharmony_ci            varying in centroid               vec4  gl_CentroidSecondaryColor;
6445bd8deadSopenharmony_ci
6455bd8deadSopenharmony_ci            // Fog category
6465bd8deadSopenharmony_ci            varying in centroid               vec4  gl_CentroidFogFragCoord;
6475bd8deadSopenharmony_ci
6485bd8deadSopenharmony_ci        It would be an error to use a varying from more than one category
6495bd8deadSopenharmony_ci        in a single program.
6505bd8deadSopenharmony_ci
6515bd8deadSopenharmony_ci    14. Should glLinkProgram work to re-link a shader created with
6525bd8deadSopenharmony_ci        glCreateShaderProgramEXT?
6535bd8deadSopenharmony_ci
6545bd8deadSopenharmony_ci        RESOLVED: NO because the shader created by glCreateShaderProgram
6555bd8deadSopenharmony_ci        is detached and deleted as part of the glCreateShaderProgramEXT
6565bd8deadSopenharmony_ci        sequence.  This means if you call glLinkProgram on a program
6575bd8deadSopenharmony_ci        returned from glCreateShaderProgram, you'll find the re-link
6585bd8deadSopenharmony_ci        fails because no shader object is attached.
6595bd8deadSopenharmony_ci
6605bd8deadSopenharmony_ci        An application is free to attach one or more new shader objects
6615bd8deadSopenharmony_ci        to the program and then relink would work.
6625bd8deadSopenharmony_ci
6635bd8deadSopenharmony_ci        This is fine because re-linking isn't necessary/expected.
6645bd8deadSopenharmony_ci
6655bd8deadSopenharmony_ci    15. Wouldn't re-linking be necessary if the application wanted to
6665bd8deadSopenharmony_ci        use glBindAttribLocation to assign a user-defined attribute to
6675bd8deadSopenharmony_ci        a specific vertex attribute?
6685bd8deadSopenharmony_ci
6695bd8deadSopenharmony_ci        RESOLVED:  Yes and that's a problem if glCreateShaderProgramEXT
6705bd8deadSopenharmony_ci        is used because the shader object is detached and deleted.
6715bd8deadSopenharmony_ci
6725bd8deadSopenharmony_ci        User-defined attributes will work when glCreateShaderProgramEXT
6735bd8deadSopenharmony_ci        is used to easily create a vertex shader program, but the
6745bd8deadSopenharmony_ci        appliation must be satisfied with the implementation-dependent
6755bd8deadSopenharmony_ci        linker-assigned user-defined attributes returned by
6765bd8deadSopenharmony_ci        glGetAttribLocation.
6775bd8deadSopenharmony_ci
6785bd8deadSopenharmony_ci        We could provide a new set of built-in attributes that correspond
6795bd8deadSopenharmony_ci        to declared as:
6805bd8deadSopenharmony_ci
6815bd8deadSopenharmony_ci            attribute vec4 gl_VertexAttrib[];
6825bd8deadSopenharmony_ci
6835bd8deadSopenharmony_ci        How would these attributes map to the other built-in attributes?
6845bd8deadSopenharmony_ci        That would depend on the implementation.  As with ARB_vertex_program,
6855bd8deadSopenharmony_ci        some implementations could choose to alias such generate vertex attributes
6865bd8deadSopenharmony_ci        with conventional vertex attributes (color, fog coord, etc.) or
6875bd8deadSopenharmony_ci        an implementation could treat the generic attributes as disjoint
6885bd8deadSopenharmony_ci        from the conventional vertex attributes.
6895bd8deadSopenharmony_ci
6905bd8deadSopenharmony_ci        If this is unsatisfactory, the solution is to avoid using
6915bd8deadSopenharmony_ci        glCreateShaderProgramEXT and instead use the traditional GLSL
6925bd8deadSopenharmony_ci        approach for creating programs (create shader, compile shader,
6935bd8deadSopenharmony_ci        attach shader, bind attributes, link shader, use shader).
6945bd8deadSopenharmony_ci
6955bd8deadSopenharmony_ci        Demonstrating how to workaround this particular issue, here's
6965bd8deadSopenharmony_ci        an example of creating and using a vertex shader for use with
6975bd8deadSopenharmony_ci        separate shader objects that includes explicit binding of output
6985bd8deadSopenharmony_ci        varyings to fragment data locations.  First the shader:
6995bd8deadSopenharmony_ci        
7005bd8deadSopenharmony_ci          varying in vec4 attribA;
7015bd8deadSopenharmony_ci          varying in vec4 attribB;
7025bd8deadSopenharmony_ci          void main()
7035bd8deadSopenharmony_ci          {
7045bd8deadSopenharmony_ci            gl_Position = ftransform();
7055bd8deadSopenharmony_ci            gl_FrontColor = attribA;
7065bd8deadSopenharmony_ci            gl_BackColor = attribB;
7075bd8deadSopenharmony_ci          }
7085bd8deadSopenharmony_ci          
7095bd8deadSopenharmony_ci        Now creating and using a linked program from this shader where
7105bd8deadSopenharmony_ci        attribA is initialized by vertex attribute 5 and attribB is
7115bd8deadSopenharmony_ci        initialized by vertex attribute 7.
7125bd8deadSopenharmony_ci
7135bd8deadSopenharmony_ci          const GLuint shader = glCreateShader(GL_VERTEX_SHADER);
7145bd8deadSopenharmony_ci          if (shader) {
7155bd8deadSopenharmony_ci              const GLint len = (GLint) strlen(aboveShaderString);
7165bd8deadSopenharmony_ci              glShaderSource(shader, 1, &aboveShaderString, &len);
7175bd8deadSopenharmony_ci              glCompileShader(shader);
7185bd8deadSopenharmony_ci              const uint program = glCreateProgram();
7195bd8deadSopenharmony_ci              if (program) {
7205bd8deadSopenharmony_ci                  GLint compiled = FALSE;
7215bd8deadSopenharmony_ci                  glGetShaderiv(shader, COMPILE_STATUS, &compiled);
7225bd8deadSopenharmony_ci                  if (compiled) {
7235bd8deadSopenharmony_ci                      glAttachShader(program, shader);
7245bd8deadSopenharmony_ci
7255bd8deadSopenharmony_ci                      // Crucial code that glCreateShaderProgramEXT doesn't do
7265bd8deadSopenharmony_ci                      glBindAttribLocation(program, 5, "attribA");
7275bd8deadSopenharmony_ci                      glBindAttribLocation(program, 7, "attribB");
7285bd8deadSopenharmony_ci
7295bd8deadSopenharmony_ci                      glLinkProgram(program);
7305bd8deadSopenharmony_ci                      glDetachShader(program, shader);
7315bd8deadSopenharmony_ci
7325bd8deadSopenharmony_ci                      // Show this program can actually be used as a vertex shader
7335bd8deadSopenharmony_ci                      glUseShaderProgramEXT(GL_VERTEX_SHADER, program);
7345bd8deadSopenharmony_ci                  }
7355bd8deadSopenharmony_ci              }
7365bd8deadSopenharmony_ci              glDeleteShader(shader);
7375bd8deadSopenharmony_ci              return program;
7385bd8deadSopenharmony_ci          } else {
7395bd8deadSopenharmony_ci              return 0;
7405bd8deadSopenharmony_ci          }
7415bd8deadSopenharmony_ci
7425bd8deadSopenharmony_ci        Optionally, the glDetachShader and glDeleteShader commands could
7435bd8deadSopenharmony_ci        be removed to allow this program to be re-linked after different
7445bd8deadSopenharmony_ci        glBindAttribLocation calls.
7455bd8deadSopenharmony_ci
7465bd8deadSopenharmony_ci    16. Can you use glBindFragDataLocation to direct varying output
7475bd8deadSopenharmony_ci        variables from a fragment shader program created by
7485bd8deadSopenharmony_ci        glCreateShaderProgramEXT to specific color buffers?
7495bd8deadSopenharmony_ci
7505bd8deadSopenharmony_ci        RESOLVED: NO for much the same reason you can't do this with
7515bd8deadSopenharmony_ci        attributes as described in issue 15.  But you could create the
7525bd8deadSopenharmony_ci        program with the standard GLSL creation process where you attach
7535bd8deadSopenharmony_ci        your own shaders and relink.
7545bd8deadSopenharmony_ci
7555bd8deadSopenharmony_ci        For fragment shader programs created with
7565bd8deadSopenharmony_ci        glCreateShaderProgramEXT, there is already the gl_FragData[]
7575bd8deadSopenharmony_ci        builtin to output to numbered color buffers.  For integer
7585bd8deadSopenharmony_ci        framebuffers, we would need to add:
7595bd8deadSopenharmony_ci
7605bd8deadSopenharmony_ci            varying out ivec4 gl_IntFragData[];
7615bd8deadSopenharmony_ci
7625bd8deadSopenharmony_ci        User-defined output fragment shader varyings can still be used
7635bd8deadSopenharmony_ci        as long as the application is happy with the linker-assigned
7645bd8deadSopenharmony_ci        locations.
7655bd8deadSopenharmony_ci
7665bd8deadSopenharmony_ci        Demonstrating how to workaround this particular issue, here's
7675bd8deadSopenharmony_ci        an example of creating and using a fragment shader for use with
7685bd8deadSopenharmony_ci        separate shader objects that includes explicit binding of output
7695bd8deadSopenharmony_ci        varyings to fragment data locations.  First the shader:
7705bd8deadSopenharmony_ci
7715bd8deadSopenharmony_ci          varying out ivec4 bufferA;
7725bd8deadSopenharmony_ci          varying out ivec4 bufferB;
7735bd8deadSopenharmony_ci          void main()
7745bd8deadSopenharmony_ci          {
7755bd8deadSopenharmony_ci            bufferA = ivec4(1,2,3,4);
7765bd8deadSopenharmony_ci            bufferB = ivec4(5,6,7,8);
7775bd8deadSopenharmony_ci          }
7785bd8deadSopenharmony_ci
7795bd8deadSopenharmony_ci        Now creating and using a linked program from this shader where
7805bd8deadSopenharmony_ci        bufferA outputs to color buffer 0 and bufferB outputs to color
7815bd8deadSopenharmony_ci        buffer 1:
7825bd8deadSopenharmony_ci
7835bd8deadSopenharmony_ci          const GLuint shader = glCreateShader(GL_FRAGMENT_SHADER);
7845bd8deadSopenharmony_ci          if (shader) {
7855bd8deadSopenharmony_ci              const GLint len = (GLint) strlen(aboveShaderString);
7865bd8deadSopenharmony_ci              glShaderSource(shader, 1, &aboveShaderString, &len);
7875bd8deadSopenharmony_ci              glCompileShader(shader);
7885bd8deadSopenharmony_ci              const uint program = glCreateProgram();
7895bd8deadSopenharmony_ci              if (program) {
7905bd8deadSopenharmony_ci                  GLint compiled = FALSE;
7915bd8deadSopenharmony_ci                  glGetShaderiv(shader, COMPILE_STATUS, &compiled);
7925bd8deadSopenharmony_ci                  if (compiled) {
7935bd8deadSopenharmony_ci                      glAttachShader(program, shader);
7945bd8deadSopenharmony_ci
7955bd8deadSopenharmony_ci                      // Crucial code that glCreateShaderProgramEXT doesn't do
7965bd8deadSopenharmony_ci                      glBindFragDataLocation(program, 0, "bufferA");
7975bd8deadSopenharmony_ci                      glBindFragDataLocation(program, 1, "bufferB");
7985bd8deadSopenharmony_ci
7995bd8deadSopenharmony_ci                      glLinkProgram(program);
8005bd8deadSopenharmony_ci                      glDetachShader(program, shader);
8015bd8deadSopenharmony_ci
8025bd8deadSopenharmony_ci                      // Show this program can actually be used as a fragment shader
8035bd8deadSopenharmony_ci                      glUseShaderProgramEXT(GL_FRAGMENT_SHADER, program);
8045bd8deadSopenharmony_ci                  }
8055bd8deadSopenharmony_ci              }
8065bd8deadSopenharmony_ci              glDeleteShader(shader);
8075bd8deadSopenharmony_ci              return program;
8085bd8deadSopenharmony_ci          } else {
8095bd8deadSopenharmony_ci              return 0;
8105bd8deadSopenharmony_ci          }
8115bd8deadSopenharmony_ci
8125bd8deadSopenharmony_ci        Optionally, the glDetachShader and glDeleteShader could be
8135bd8deadSopenharmony_ci        removed to allow this program to be re-linked after different
8145bd8deadSopenharmony_ci        glBindFragDataLocation calls.
8155bd8deadSopenharmony_ci
8165bd8deadSopenharmony_ci    17. Can you output varyings from a seperate shader program created
8175bd8deadSopenharmony_ci        with glCreateShaderProgramEXT?
8185bd8deadSopenharmony_ci
8195bd8deadSopenharmony_ci        RESOLVED:  No.
8205bd8deadSopenharmony_ci
8215bd8deadSopenharmony_ci        glTransformFeedbackVaryings requires a re-link to take effect on a
8225bd8deadSopenharmony_ci        program.  glCreateShaderProgramEXT detaches and deletes the shader
8235bd8deadSopenharmony_ci        object use to create the program so a glLinkProgram will fail.
8245bd8deadSopenharmony_ci
8255bd8deadSopenharmony_ci        You can still create a vertex or geometry shader program
8265bd8deadSopenharmony_ci        with the standard GLSL creation process where you could use
8275bd8deadSopenharmony_ci        glTransformFeedbackVaryings and glLinkProgram.
8285bd8deadSopenharmony_ci
8295bd8deadSopenharmony_ci    18. I just don't get it?  Why is it such a big deal to just require
8305bd8deadSopenharmony_ci        apps to link all their vertex and fragment shaders together?
8315bd8deadSopenharmony_ci        Please explain a situation where mix-and-match shaders is
8325bd8deadSopenharmony_ci        substantially better than GLSL as it exists without this
8335bd8deadSopenharmony_ci        extension?
8345bd8deadSopenharmony_ci
8355bd8deadSopenharmony_ci        RESOLUTION:  Consider the (not uncommon) case of a vertex shader
8365bd8deadSopenharmony_ci        for skinning a character.  The vertex shader is used in four
8375bd8deadSopenharmony_ci        distinct types of rendering passes, each using the one vertex
8385bd8deadSopenharmony_ci        shader but different fragment shaders.
8395bd8deadSopenharmony_ci
8405bd8deadSopenharmony_ci        For GLSL today, this situation today requires 4 program objects,
8415bd8deadSopenharmony_ci        each containing the one vertex shader paired with each one of
8425bd8deadSopenharmony_ci        the fragment shaders.
8435bd8deadSopenharmony_ci
8445bd8deadSopenharmony_ci        The one vertex shader has an array of dozens of skinning matrices
8455bd8deadSopenharmony_ci        along with numerous other uniform parameters.
8465bd8deadSopenharmony_ci
8475bd8deadSopenharmony_ci        Each fragment shader has its own different set of uniforms too.
8485bd8deadSopenharmony_ci
8495bd8deadSopenharmony_ci        Each GLSL program object has its own (combined) set of GLuint
8505bd8deadSopenharmony_ci        locations for the active uniforms of the vertex and fragment
8515bd8deadSopenharmony_ci        shaders objects linked into the particular program object.
8525bd8deadSopenharmony_ci
8535bd8deadSopenharmony_ci        The locations for a given program object are arbitrary and
8545bd8deadSopenharmony_ci        the location values of two distinct program objects have no
8555bd8deadSopenharmony_ci        correlation.  This is true even when they each link in the same
8565bd8deadSopenharmony_ci        vertex shader (or alternatively same fragment shader).
8575bd8deadSopenharmony_ci
8585bd8deadSopenharmony_ci        Now the application is saddled with the burden of managing
8595bd8deadSopenharmony_ci        distinct location values for the same vertex shader skinning
8605bd8deadSopenharmony_ci        matrices and other uniform variables as well as making sure
8615bd8deadSopenharmony_ci        the values of these variables are mirroed over all four program
8625bd8deadSopenharmony_ci        objects containing the skinning vertex shader.
8635bd8deadSopenharmony_ci
8645bd8deadSopenharmony_ci        What's worse is despite all the program objects being loaded
8655bd8deadSopenharmony_ci        with the same vertex shader uniform variables for skinning, the
8665bd8deadSopenharmony_ci        driver is exceedingly unlikely to recoginize that binding from
8675bd8deadSopenharmony_ci        one of these program objects to another is going to result in
8685bd8deadSopenharmony_ci        no actual vertex shader state change.  Noticing that the uniform
8695bd8deadSopenharmony_ci        vertex shader variables are changing in lock-step over a series
8705bd8deadSopenharmony_ci        of program objects (when the uniform fragment shader variables
8715bd8deadSopenharmony_ci        ARE allowed to diverge) is exceedingly expensive.
8725bd8deadSopenharmony_ci
8735bd8deadSopenharmony_ci        This situation is simple to optimize with mix-and-match shaders
8745bd8deadSopenharmony_ci        because there is just a single vertex shader to worry about.
8755bd8deadSopenharmony_ci        It's only the current fragment shader program that is changing
8765bd8deadSopenharmony_ci        so only the fragment shader state must be updated/re-validated.
8775bd8deadSopenharmony_ci
8785bd8deadSopenharmony_ci        It's also much easier and less expensive for the application to
8795bd8deadSopenharmony_ci        update the vertex shader state because there is just one copy
8805bd8deadSopenharmony_ci        of it to update.
8815bd8deadSopenharmony_ci
8825bd8deadSopenharmony_ci    19. In case of indirect rendering, should glCreateShaderProgramEXT
8835bd8deadSopenharmony_ci        explicitly send string length parameter to server?
8845bd8deadSopenharmony_ci        
8855bd8deadSopenharmony_ci        PROPOSED: Yes. Although source code passed to
8865bd8deadSopenharmony_ci        glCreateShaderProgramEXT is NUL terminated, the server can not
8875bd8deadSopenharmony_ci        safely rely on the client to terminate the string so it must
8885bd8deadSopenharmony_ci        add the NUL terminator before passing the protocol buffer to
8895bd8deadSopenharmony_ci        the GL command processor. The string length is needed to do this
8905bd8deadSopenharmony_ci        accurately.
8915bd8deadSopenharmony_ci
8925bd8deadSopenharmony_ci    20. Can glCreateShaderProgramEXT support command larger than the 
8935bd8deadSopenharmony_ci        maximum command length supported by a single command?
8945bd8deadSopenharmony_ci 
8955bd8deadSopenharmony_ci        PROPOSED: Yes. Source code passed to glCreateShaderProgramEXT is
8965bd8deadSopenharmony_ci        unbounded. Command length can be more than the maximum command
8975bd8deadSopenharmony_ci        length supported by a single command. Support for "large single"
8985bd8deadSopenharmony_ci        command needs to be added.
8995bd8deadSopenharmony_ci        
9005bd8deadSopenharmony_ci         
9015bd8deadSopenharmony_ci
9025bd8deadSopenharmony_ciRevision History
9035bd8deadSopenharmony_ci
9045bd8deadSopenharmony_ci    Rev.    Date    Author    Changes
9055bd8deadSopenharmony_ci    ----  --------  --------  ----------------------------------------
9065bd8deadSopenharmony_ci    1     11/06/08  mjk       Initial revision
9075bd8deadSopenharmony_ci    2     11/10/08  mjk       add glCreateShaderProgramEXT
9085bd8deadSopenharmony_ci    3     11/12/08  mjk       fixed glCreateShaderProgramEXT
9095bd8deadSopenharmony_ci                              add issues 12 and 13
9105bd8deadSopenharmony_ci    4     11/14/08  mjk       issues 13 through 17
9115bd8deadSopenharmony_ci    5     12/03/08  mjk       glActiveProgram replaces
9125bd8deadSopenharmony_ci                              GL_UNIFORM_SHADER_EXT
9135bd8deadSopenharmony_ci    6     04/01/09  mjk       corrections from Jason Green
9145bd8deadSopenharmony_ci    7     08/12/09  mjk       Marked as shipping, resolve and
9155bd8deadSopenharmony_ci                              improve issues 15 & 16
9165bd8deadSopenharmony_ci    8     09/09/09  mjk       Assign number
9175bd8deadSopenharmony_ci    9     09/09/09  mjk       Fix transposed page number
9185bd8deadSopenharmony_ci    10    24/02/10  srahman   added glx protocol for
9195bd8deadSopenharmony_ci                              glCreateShaderProgramEXT
9205bd8deadSopenharmony_ci                              added issues 19 and 20 
9215bd8deadSopenharmony_ci    11    03/07/13  Jon Leech Added note about the unrelated OpenGL ES
9225bd8deadSopenharmony_ci                              extension of the same name.
923