15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    ARB_shading_language_include
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_ARB_shading_language_include
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContact
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    Jon Leech (jon 'at' alumni.caltech.edu)
125bd8deadSopenharmony_ci
135bd8deadSopenharmony_ciNotice
145bd8deadSopenharmony_ci
155bd8deadSopenharmony_ci    Copyright (c) 2010-2013 The Khronos Group Inc. Copyright terms at
165bd8deadSopenharmony_ci        http://www.khronos.org/registry/speccopyright.html
175bd8deadSopenharmony_ci
185bd8deadSopenharmony_ciSpecification Update Policy
195bd8deadSopenharmony_ci
205bd8deadSopenharmony_ci    Khronos-approved extension specifications are updated in response to
215bd8deadSopenharmony_ci    issues and bugs prioritized by the Khronos OpenGL Working Group. For
225bd8deadSopenharmony_ci    extensions which have been promoted to a core Specification, fixes will
235bd8deadSopenharmony_ci    first appear in the latest version of that core Specification, and will
245bd8deadSopenharmony_ci    eventually be backported to the extension document. This policy is
255bd8deadSopenharmony_ci    described in more detail at
265bd8deadSopenharmony_ci        https://www.khronos.org/registry/OpenGL/docs/update_policy.php
275bd8deadSopenharmony_ci
285bd8deadSopenharmony_ciStatus
295bd8deadSopenharmony_ci
305bd8deadSopenharmony_ci    Complete. Approved by the ARB at the 2010/01/22 F2F meeting.
315bd8deadSopenharmony_ci    Approved by the Khronos Board of Promoters on March 10, 2010.
325bd8deadSopenharmony_ci
335bd8deadSopenharmony_ciVersion
345bd8deadSopenharmony_ci
355bd8deadSopenharmony_ci    Version 17, June 24, 2013
365bd8deadSopenharmony_ci
375bd8deadSopenharmony_ciNumber
385bd8deadSopenharmony_ci
395bd8deadSopenharmony_ci    ARB Extension #76
405bd8deadSopenharmony_ci
415bd8deadSopenharmony_ciDependencies
425bd8deadSopenharmony_ci
435bd8deadSopenharmony_ci    A version of OpenGL supporting OpenGL Shading Language 1.10 or later
445bd8deadSopenharmony_ci    is required.
455bd8deadSopenharmony_ci
465bd8deadSopenharmony_ci    This extension is written against the OpenGL 3.2 (Core Profile) and
475bd8deadSopenharmony_ci    OpenGL Shading Language 1.50 Specifications.
485bd8deadSopenharmony_ci
495bd8deadSopenharmony_ciOverview
505bd8deadSopenharmony_ci
515bd8deadSopenharmony_ci    This extension introduces a #include GLSL directive to allow reusing
525bd8deadSopenharmony_ci    the same shader text in multiple shaders and defines the semantics
535bd8deadSopenharmony_ci    and syntax of the names allowed in #include directives. It also
545bd8deadSopenharmony_ci    defines API mechanisms to define the named string backing a
555bd8deadSopenharmony_ci    #include.
565bd8deadSopenharmony_ci
575bd8deadSopenharmony_ciIP Status
585bd8deadSopenharmony_ci
595bd8deadSopenharmony_ci    No known IP claims.
605bd8deadSopenharmony_ci
615bd8deadSopenharmony_ciNew Procedures and Functions
625bd8deadSopenharmony_ci
635bd8deadSopenharmony_ci    void NamedStringARB(enum type, int namelen, const char *name,
645bd8deadSopenharmony_ci                        int stringlen, const char *string)
655bd8deadSopenharmony_ci    void DeleteNamedStringARB(int namelen, const char *name)
665bd8deadSopenharmony_ci
675bd8deadSopenharmony_ci    void CompileShaderIncludeARB(uint shader, sizei count,
685bd8deadSopenharmony_ci                                 const char *const *path,
695bd8deadSopenharmony_ci                                 const int *length)
705bd8deadSopenharmony_ci
715bd8deadSopenharmony_ci    boolean IsNamedStringARB(int namelen, const char *name)
725bd8deadSopenharmony_ci    void GetNamedStringARB(int namelen, const char *name,
735bd8deadSopenharmony_ci                           sizei bufSize, int *stringlen,
745bd8deadSopenharmony_ci                           char *string)
755bd8deadSopenharmony_ci    void GetNamedStringivARB(int namelen, const char *name,
765bd8deadSopenharmony_ci                             enum pname, int *params)
775bd8deadSopenharmony_ci
785bd8deadSopenharmony_ciNew Tokens
795bd8deadSopenharmony_ci
805bd8deadSopenharmony_ci    Accepted by the <type> parameter of NamedStringARB:
815bd8deadSopenharmony_ci
825bd8deadSopenharmony_ci        SHADER_INCLUDE_ARB                              0x8DAE
835bd8deadSopenharmony_ci
845bd8deadSopenharmony_ci    Accepted by the <pname> parameter of GetNamedStringivARB:
855bd8deadSopenharmony_ci
865bd8deadSopenharmony_ci        NAMED_STRING_LENGTH_ARB                         0x8DE9
875bd8deadSopenharmony_ci        NAMED_STRING_TYPE_ARB                           0x8DEA
885bd8deadSopenharmony_ci
895bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL 3.2 Specification (OpenGL Operation)
905bd8deadSopenharmony_ci
915bd8deadSopenharmony_ci    Add new section 2.11.1 preceding the current section 2.11.1 and
925bd8deadSopenharmony_ci    renumber following sections:
935bd8deadSopenharmony_ci
945bd8deadSopenharmony_ci   "2.11.1 Named Strings
955bd8deadSopenharmony_ci
965bd8deadSopenharmony_ci    Arbitrary strings may be defined and given names. These strings can
975bd8deadSopenharmony_ci    be included by name in shaders during compilation, allowing reuse of
985bd8deadSopenharmony_ci    the same code segments. A string and its name are specified
995bd8deadSopenharmony_ci    with the command
1005bd8deadSopenharmony_ci
1015bd8deadSopenharmony_ci        void NamedStringARB(enum type, int namelen, const char *name,
1025bd8deadSopenharmony_ci                            int stringlen, const char *string)
1035bd8deadSopenharmony_ci
1045bd8deadSopenharmony_ci    <type> must be SHADER_INCLUDE_ARB. <namelen> is the number of
1055bd8deadSopenharmony_ci    <char>s in <name>. <name> defines the name associated with the
1065bd8deadSopenharmony_ci    string. <stringlen> is the number of <char>s in <string>. <string>
1075bd8deadSopenharmony_ci    is an arbitrary string of characters. If <namelen> or <stringlen>
1085bd8deadSopenharmony_ci    are negative, then <name> or <string> respectively are considered to
1095bd8deadSopenharmony_ci    be null-terminated strings.
1105bd8deadSopenharmony_ci
1115bd8deadSopenharmony_ci    <name> must be a <valid pathname> as defined in Appendix A of the
1125bd8deadSopenharmony_ci    OpenGL Shading Language Specification. Additionally, <name> must
1135bd8deadSopenharmony_ci    begin with the character '/'. Before creating a named string, <name>
1145bd8deadSopenharmony_ci    is converted to a <tree location> as described in Appendix A of
1155bd8deadSopenharmony_ci    the OpenGL Shading Language Specification.
1165bd8deadSopenharmony_ci
1175bd8deadSopenharmony_ci    After calling NamedStringARB, the contents of <string> are
1185bd8deadSopenharmony_ci    associated with the tree location corresponding to <name>[fn1]. If a
1195bd8deadSopenharmony_ci    string is already associated with that tree location, it will be
1205bd8deadSopenharmony_ci    replaced with the new <string>.
1215bd8deadSopenharmony_ci       [fn1 - Many possible <name>s may correspond to the same tree
1225bd8deadSopenharmony_ci        location.]
1235bd8deadSopenharmony_ci
1245bd8deadSopenharmony_ci    An INVALID_VALUE error will be generated under any of the following
1255bd8deadSopenharmony_ci    conditions:
1265bd8deadSopenharmony_ci
1275bd8deadSopenharmony_ci      - Either <name> or <string> is NULL.
1285bd8deadSopenharmony_ci      - <name> is not a valid pathname beginning with '/'.
1295bd8deadSopenharmony_ci
1305bd8deadSopenharmony_ci    To delete a named string, use the command
1315bd8deadSopenharmony_ci
1325bd8deadSopenharmony_ci        void DeleteNamedStringARB(int namelen, const char *name)
1335bd8deadSopenharmony_ci
1345bd8deadSopenharmony_ci    <namelen>, and <name> have the same meanings as the corresponding
1355bd8deadSopenharmony_ci    parameters of NamedStringARB. After calling DeleteNamedStringARB, no
1365bd8deadSopenharmony_ci    string is associated with the tree location corresponding to <name>.
1375bd8deadSopenharmony_ci
1385bd8deadSopenharmony_ci    An INVALID_VALUE error will be generated under any of the following
1395bd8deadSopenharmony_ci    conditions:
1405bd8deadSopenharmony_ci
1415bd8deadSopenharmony_ci      - <name> is NULL.
1425bd8deadSopenharmony_ci      - <name> is not a valid pathname beginning with '/'.
1435bd8deadSopenharmony_ci
1445bd8deadSopenharmony_ci    An INVALID_OPERATION error will be generated if the tree location
1455bd8deadSopenharmony_ci    corresponding to <name> has no string associated with it."
1465bd8deadSopenharmony_ci
1475bd8deadSopenharmony_ci
1485bd8deadSopenharmony_ci    Replace the description of CompileShader in new section 2.11.2
1495bd8deadSopenharmony_ci    (formerly section 2.11.1) with:
1505bd8deadSopenharmony_ci
1515bd8deadSopenharmony_ci   "Once the source code for a shader has been loaded, a shader object
1525bd8deadSopenharmony_ci    can be compiled with the command
1535bd8deadSopenharmony_ci
1545bd8deadSopenharmony_ci        void CompileShaderIncludeARB(uint shader, sizei count,
1555bd8deadSopenharmony_ci                                     const char * const *path,
1565bd8deadSopenharmony_ci                                     const int *length)
1575bd8deadSopenharmony_ci
1585bd8deadSopenharmony_ci    <path> is an ordered array of <count> pointers to optionally
1595bd8deadSopenharmony_ci    null-terminated character strings defining <search paths>. <length>
1605bd8deadSopenharmony_ci    is an array of <count> values with the number of chars in each
1615bd8deadSopenharmony_ci    string (the string length). If an element in <length> is negative,
1625bd8deadSopenharmony_ci    its accompanying string is null-terminated. If <length> is NULL, all
1635bd8deadSopenharmony_ci    strings in the <path> argument are considered null-terminated.
1645bd8deadSopenharmony_ci
1655bd8deadSopenharmony_ci    Each string in <path> must be a valid <pathname> as defined in
1665bd8deadSopenharmony_ci    Appendix A of the OpenGL Shading Language Specification, and must
1675bd8deadSopenharmony_ci    begin with the character '/'. The ordered list of <path>s is used
1685bd8deadSopenharmony_ci    during compilation, together with the arguments of #include
1695bd8deadSopenharmony_ci    directives in the shader source, to search for named strings
1705bd8deadSopenharmony_ci    corresponding to the #include directives as described in section
1715bd8deadSopenharmony_ci    3.3 of the OpenGL Shading Language Specification. If a #include
1725bd8deadSopenharmony_ci    directive does not correspond to a valid named string, compilation
1735bd8deadSopenharmony_ci    will fail.
1745bd8deadSopenharmony_ci
1755bd8deadSopenharmony_ci    Each shader object has a boolean status that is modified as a result
1765bd8deadSopenharmony_ci    of compilation, and can be queried by calling GetShaderiv (see
1775bd8deadSopenharmony_ci    section 6.1.10) with <pname> COMPILE_STATUS. The status will be set
1785bd8deadSopenharmony_ci    to TRUE if <shader> was compiled without errors and is ready for
1795bd8deadSopenharmony_ci    use, and FALSE otherwise. Compilation can fail for a variety of
1805bd8deadSopenharmony_ci    reasons as listed in the OpenGL Shading Language Specification. If
1815bd8deadSopenharmony_ci    compilation failed, any information about a previous compile is
1825bd8deadSopenharmony_ci    lost. Thus a failed compile does not restore the old state of
1835bd8deadSopenharmony_ci    shader.
1845bd8deadSopenharmony_ci
1855bd8deadSopenharmony_ci    Changing the source code of a shader object with ShaderSource, or
1865bd8deadSopenharmony_ci    the contents of any named strings corresponding to #include
1875bd8deadSopenharmony_ci    directives in the source code, does not change its compile status or
1885bd8deadSopenharmony_ci    the compiled shader code.
1895bd8deadSopenharmony_ci
1905bd8deadSopenharmony_ci    Each shader object has an information log, which is a text string
1915bd8deadSopenharmony_ci    that is overwritten as a result of compilation. This information log
1925bd8deadSopenharmony_ci    can be queried with GetShaderInfoLog to obtain more information
1935bd8deadSopenharmony_ci    about the compilation attempt (see section 6.1.10).
1945bd8deadSopenharmony_ci
1955bd8deadSopenharmony_ci    An INVALID_OPERATION error is generated if <shader> is not the name
1965bd8deadSopenharmony_ci    of a valid shader object generated by CreateShader.
1975bd8deadSopenharmony_ci
1985bd8deadSopenharmony_ci    An INVALID_VALUE error will be generated under any of the following
1995bd8deadSopenharmony_ci    conditions:
2005bd8deadSopenharmony_ci      - <count> is greater than zero and <path> is NULL, or any
2015bd8deadSopenharmony_ci        of the pointers path[0] .. path[<count>-1] is NULL.
2025bd8deadSopenharmony_ci      - Any of the strings in <path> are not valid pathnames beginning
2035bd8deadSopenharmony_ci        with '/'.
2045bd8deadSopenharmony_ci
2055bd8deadSopenharmony_ci*** (compatibility profile only)
2065bd8deadSopenharmony_ci    An INVALID_OPERATION error is generated if CompileShaderIncludeARB
2075bd8deadSopenharmony_ci    is executed between Begin and the corresponding End.
2085bd8deadSopenharmony_ci
2095bd8deadSopenharmony_ci    The command
2105bd8deadSopenharmony_ci
2115bd8deadSopenharmony_ci        CompileShader(uint shader)
2125bd8deadSopenharmony_ci
2135bd8deadSopenharmony_ci    is equivalent to
2145bd8deadSopenharmony_ci
2155bd8deadSopenharmony_ci        CompileShaderIncludeARB(shader,0,NULL,NULL).
2165bd8deadSopenharmony_ci
2175bd8deadSopenharmony_ci    Shader objects can be deleted with the command ..."
2185bd8deadSopenharmony_ci
2195bd8deadSopenharmony_ci
2205bd8deadSopenharmony_ciAdditions to Chapter 5 (Special Functions)
2215bd8deadSopenharmony_ci
2225bd8deadSopenharmony_ci    Add CompileShaderIncludeARB to the list of "Commands Not Usable In
2235bd8deadSopenharmony_ci    Display Lists" in section 5.4.1 of the compatibility profile.
2245bd8deadSopenharmony_ci
2255bd8deadSopenharmony_ciAdditions to Chapter 6 (State and State Requests)
2265bd8deadSopenharmony_ci
2275bd8deadSopenharmony_ci    Add new section 6.1.10 preceding the current section 6.1.10 and
2285bd8deadSopenharmony_ci    renumber following sections:
2295bd8deadSopenharmony_ci
2305bd8deadSopenharmony_ci   "6.1.10 Named String Queries
2315bd8deadSopenharmony_ci
2325bd8deadSopenharmony_ci    The command
2335bd8deadSopenharmony_ci
2345bd8deadSopenharmony_ci        boolean IsNamedStringARB(int namelen, const char *name)
2355bd8deadSopenharmony_ci
2365bd8deadSopenharmony_ci    returns TRUE if the tree location corresponding to <name> has a
2375bd8deadSopenharmony_ci    string associated with it, and FALSE if the tree location has no
2385bd8deadSopenharmony_ci    string associated with it. <name> and <namelen> have the same
2395bd8deadSopenharmony_ci    meanings as the corresponding parameters of NamedStringARB (see
2405bd8deadSopenharmony_ci    section 2.11.1).
2415bd8deadSopenharmony_ci
2425bd8deadSopenharmony_ci    If <name> or <namelen> do not describe a valid name, or if <name> is
2435bd8deadSopenharmony_ci    NULL, IsNamedStringARB succeeds and returns FALSE.
2445bd8deadSopenharmony_ci
2455bd8deadSopenharmony_ci    The command
2465bd8deadSopenharmony_ci
2475bd8deadSopenharmony_ci        void GetNamedStringivARB(int namelen, const char *name,
2485bd8deadSopenharmony_ci                                 enum pname, int *params)
2495bd8deadSopenharmony_ci
2505bd8deadSopenharmony_ci    returns properties of the named string whose tree location
2515bd8deadSopenharmony_ci    corresponds to <name>. <name> and <namelen> have the same meanings
2525bd8deadSopenharmony_ci    as the corresponding parameters of NamedStringARB (see section
2535bd8deadSopenharmony_ci    2.11.1). The parameter value to return is specified by <pname>.
2545bd8deadSopenharmony_ci
2555bd8deadSopenharmony_ci    If <pname> is NAMED_STRING_LENGTH_ARB, the length of the named
2565bd8deadSopenharmony_ci    string, including a null terminator, is returned. If <pname> is
2575bd8deadSopenharmony_ci    NAMED_STRING_TYPE_ARB, the <type> argument passed to NamedStringARB
2585bd8deadSopenharmony_ci    is returned.
2595bd8deadSopenharmony_ci
2605bd8deadSopenharmony_ci    An INVALID_VALUE error will be generated under any of the following
2615bd8deadSopenharmony_ci    conditions:
2625bd8deadSopenharmony_ci
2635bd8deadSopenharmony_ci      - <name> is NULL.
2645bd8deadSopenharmony_ci      - <name> is not a valid pathname beginning with '/'.
2655bd8deadSopenharmony_ci
2665bd8deadSopenharmony_ci    An INVALID_OPERATION error will be generated if the tree location
2675bd8deadSopenharmony_ci    corresponding to <name> has no string associated with it.
2685bd8deadSopenharmony_ci
2695bd8deadSopenharmony_ci    The command
2705bd8deadSopenharmony_ci
2715bd8deadSopenharmony_ci        void GetNamedStringARB(int namelen, const char *name,
2725bd8deadSopenharmony_ci                               sizei bufSize, int *stringlen,
2735bd8deadSopenharmony_ci                               char *string)
2745bd8deadSopenharmony_ci
2755bd8deadSopenharmony_ci    returns in <string> the string corresponding to the specified
2765bd8deadSopenharmony_ci    <name>. <name> and <namelen> have the same meanings as the
2775bd8deadSopenharmony_ci    corresponding parameters of NamedStringARB.
2785bd8deadSopenharmony_ci
2795bd8deadSopenharmony_ci    The returned string will be null-terminated. The actual number of
2805bd8deadSopenharmony_ci    characters written into <string>, excluding the null terminator, is
2815bd8deadSopenharmony_ci    returned in <stringlen>. If <stringlen> is NULL, no length is
2825bd8deadSopenharmony_ci    returned. The maximum number of characters that may be written into
2835bd8deadSopenharmony_ci    <string>, including the null terminator, is specified by <bufSize>.
2845bd8deadSopenharmony_ci
2855bd8deadSopenharmony_ci    An INVALID_VALUE error will be generated under any of the following
2865bd8deadSopenharmony_ci    conditions:
2875bd8deadSopenharmony_ci
2885bd8deadSopenharmony_ci      - <name> is NULL.
2895bd8deadSopenharmony_ci      - <name> is not a valid pathname beginning with '/'.
2905bd8deadSopenharmony_ci
2915bd8deadSopenharmony_ci    An INVALID_OPERATION error will be generated if the tree location
2925bd8deadSopenharmony_ci    corresponding to <name> has no string associated with it."
2935bd8deadSopenharmony_ci
2945bd8deadSopenharmony_ci
2955bd8deadSopenharmony_ciAdditions to Appendix D of the OpenGL 3.2 Specification (Shared Objects and
2965bd8deadSopenharmony_ciMultiple Contexts)
2975bd8deadSopenharmony_ci
2985bd8deadSopenharmony_ci    Add "named strings" to the list of shared object types in the second
2995bd8deadSopenharmony_ci    paragraph of Appendix D, prior to "program and shader objects".
3005bd8deadSopenharmony_ci
3015bd8deadSopenharmony_ci
3025bd8deadSopenharmony_ci    Replace the second paragraph of section D.1.2 with:
3035bd8deadSopenharmony_ci
3045bd8deadSopenharmony_ci   "When a named string, shader object, or program object is deleted, it
3055bd8deadSopenharmony_ci    is flagged for deletion, but its name remains valid until the
3065bd8deadSopenharmony_ci    underlying object can be deleted because it is no longer in use. A
3075bd8deadSopenharmony_ci    named string is in use for the duration of any
3085bd8deadSopenharmony_ci    CompileShaderIncludeARB command [fn3]. A shader object is in use
3095bd8deadSopenharmony_ci    while it is attached to any program object. A program object is in
3105bd8deadSopenharmony_ci    use while it is the current program in any context.
3115bd8deadSopenharmony_ci       [fn3 - this effectively places a lock around the named string
3125bd8deadSopenharmony_ci        dictionary during compilation. Given the lack of ordering
3135bd8deadSopenharmony_ci        inherent in multicontext access to the named string database it
3145bd8deadSopenharmony_ci        would probably be equally acceptable to state that the effect of
3155bd8deadSopenharmony_ci        deleting or changing a named string from one context during
3165bd8deadSopenharmony_ci        compilation in another context is undefined.]
3175bd8deadSopenharmony_ci
3185bd8deadSopenharmony_ci    Named strings are treated as invariant while they are in use during
3195bd8deadSopenharmony_ci    compilation of a shader. That is, named strings will not be added
3205bd8deadSopenharmony_ci    to, changed, or removed from the point of view of
3215bd8deadSopenharmony_ci    CompileShaderIncludeARB, even if such changes are made in other
3225bd8deadSopenharmony_ci    contexts [fn4].
3235bd8deadSopenharmony_ci       [fn4 - implementations may use locking, caching, or other
3245bd8deadSopenharmony_ci        techniques to realize such invariance. Again this effectively
3255bd8deadSopenharmony_ci        places a lock around the dictionary in order to provide
3265bd8deadSopenharmony_ci        predictable multicontext behavior across all implementations.]"
3275bd8deadSopenharmony_ci
3285bd8deadSopenharmony_ci    Add to the list of <data> in the first paragraph of section D.3:
3295bd8deadSopenharmony_ci
3305bd8deadSopenharmony_ci     "- Named strings (only string contents, not string names)."
3315bd8deadSopenharmony_ci
3325bd8deadSopenharmony_ci    Add a new paragraph to the first bullet point, describing the term
3335bd8deadSopenharmony_ci    <directly attached>, in section D.3.2:
3345bd8deadSopenharmony_ci
3355bd8deadSopenharmony_ci     "Additionally, a named string object T will be considered to have
3365bd8deadSopenharmony_ci      been <directly attached> to the current context whenever a
3375bd8deadSopenharmony_ci      CompileShaderIncludeARB command is issued, and to have been
3385bd8deadSopenharmony_ci      detached when that CompileShaderIncludeARB completes."
3395bd8deadSopenharmony_ci
3405bd8deadSopenharmony_ci    (This language may need some iteration. The intent is that whenever
3415bd8deadSopenharmony_ci    CompileShaderIncludeARB is called, the effect is to pick up all
3425bd8deadSopenharmony_ci    changes to the named string dictionary completed in other contexts
3435bd8deadSopenharmony_ci    prior to that compilation by leveraging the existing "directly
3445bd8deadSopenharmony_ci    attached" language of Appendix D instead of introducing a new type
3455bd8deadSopenharmony_ci    of relationship between object and context, even though named
3465bd8deadSopenharmony_ci    strings are not "bound".)
3475bd8deadSopenharmony_ci
3485bd8deadSopenharmony_ci
3495bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL Shading Language 1.50 Specification
3505bd8deadSopenharmony_ci
3515bd8deadSopenharmony_ci    Including the following line in a shader will enable #include and
3525bd8deadSopenharmony_ci    related extended language features described in this extension:
3535bd8deadSopenharmony_ci
3545bd8deadSopenharmony_ci        #extension GL_ARB_shading_language_include : <behavior>
3555bd8deadSopenharmony_ci
3565bd8deadSopenharmony_ci    where <behavior> is as specified in section 3.3 for the #extension
3575bd8deadSopenharmony_ci    directive.
3585bd8deadSopenharmony_ci
3595bd8deadSopenharmony_ci
3605bd8deadSopenharmony_ci    Add a new class of characters following the first paragraph
3615bd8deadSopenharmony_ci    of section 3.1 "Character Set":
3625bd8deadSopenharmony_ci
3635bd8deadSopenharmony_ci   "The double quote ( " ) for use only with #include and #line."
3645bd8deadSopenharmony_ci
3655bd8deadSopenharmony_ci    Replace the next-to-last paragraph of section 3.1 with:
3665bd8deadSopenharmony_ci
3675bd8deadSopenharmony_ci   "There are no character or string data types, with the exception of
3685bd8deadSopenharmony_ci    the quoted string used to name an include string for the
3695bd8deadSopenharmony_ci    preprocessor."
3705bd8deadSopenharmony_ci
3715bd8deadSopenharmony_ci
3725bd8deadSopenharmony_ci    Add following the first paragraph of section 3.2:
3735bd8deadSopenharmony_ci
3745bd8deadSopenharmony_ci   "A shader can also include another string, using #include, as
3755bd8deadSopenharmony_ci    described later. The included string is a single string, not an
3765bd8deadSopenharmony_ci    array of strings, but this string may itself include other strings."
3775bd8deadSopenharmony_ci
3785bd8deadSopenharmony_ci    Replace the last paragraph of section 3.2 with:
3795bd8deadSopenharmony_ci
3805bd8deadSopenharmony_ci   "Diagnostic messages returned from compiling a shader must identify
3815bd8deadSopenharmony_ci    both the line number within a string and which source string the
3825bd8deadSopenharmony_ci    message applies to.  For included strings (using #include), the
3835bd8deadSopenharmony_ci    string is identified by the path provided in the shader to the
3845bd8deadSopenharmony_ci    #include statement.  For an array of shader source strings, strings
3855bd8deadSopenharmony_ci    are counted sequentially with the first string being string 0.  Line
3865bd8deadSopenharmony_ci    numbers are one more than the number of new-lines that have been
3875bd8deadSopenharmony_ci    processed.  These are all consistent with use of the __LINE__,
3885bd8deadSopenharmony_ci    __FILE__, and __FILE_SPACE__ macros as described below."
3895bd8deadSopenharmony_ci
3905bd8deadSopenharmony_ci    Add to the list of preprocessor directives in the second paragraph
3915bd8deadSopenharmony_ci    of section 3.3:
3925bd8deadSopenharmony_ci
3935bd8deadSopenharmony_ci   "#include"
3945bd8deadSopenharmony_ci
3955bd8deadSopenharmony_ci    Add following the paragraph in section 3.3 starting "The number
3965bd8deadSopenharmony_ci    sign...":
3975bd8deadSopenharmony_ci
3985bd8deadSopenharmony_ci   "Functionality for #include is dependent on the GL to supply a tree
3995bd8deadSopenharmony_ci    of strings to search, plus an ordered list of initial search points
4005bd8deadSopenharmony_ci    within that tree. The presence of these is assumed below.
4015bd8deadSopenharmony_ci
4025bd8deadSopenharmony_ci    The #include directive is followed by a quoted <path>; a string
4035bd8deadSopenharmony_ci    quoted with double quotes or angled brackets ( < > ):
4045bd8deadSopenharmony_ci
4055bd8deadSopenharmony_ci    #include "path"
4065bd8deadSopenharmony_ci    #include <path>
4075bd8deadSopenharmony_ci
4085bd8deadSopenharmony_ci    This will lookup <path> in the supplied tree, as described in Appendix
4095bd8deadSopenharmony_ci    A, and select its associated string. The associated string is
4105bd8deadSopenharmony_ci    substituted and processed as is standard for C++ preprocessors, with
4115bd8deadSopenharmony_ci    full preprocessing applied after the substitution. It is a
4125bd8deadSopenharmony_ci    compile-time error if <path> is not valid as described in Appendix
4135bd8deadSopenharmony_ci    A.
4145bd8deadSopenharmony_ci
4155bd8deadSopenharmony_ci    If <path> starts with a forward slash, whether it is quoted with
4165bd8deadSopenharmony_ci    double quotes or with angled brackets, the list of search points is
4175bd8deadSopenharmony_ci    ignored and <path> is looked up in the tree as described in Appendix
4185bd8deadSopenharmony_ci    A. It is a compile-time error if a path starting with a forward
4195bd8deadSopenharmony_ci    slash either
4205bd8deadSopenharmony_ci
4215bd8deadSopenharmony_ci      * exists in the tree, but does not have a string associated with
4225bd8deadSopenharmony_ci        it, or
4235bd8deadSopenharmony_ci      * does not exist in the tree.
4245bd8deadSopenharmony_ci
4255bd8deadSopenharmony_ci    If <path> does not start with a forward slash, it is a path relative
4265bd8deadSopenharmony_ci    to one of the ordered list of initial search points. If this path is
4275bd8deadSopenharmony_ci    quoted with angled brackets, the tree is searched relative to the
4285bd8deadSopenharmony_ci    first search point in the ordered list, and then relative to each
4295bd8deadSopenharmony_ci    subsequent search point, in order, until a matching path is found in
4305bd8deadSopenharmony_ci    the tree. This is also the behavior if it is quoted with double
4315bd8deadSopenharmony_ci    quotes in an initial (non-included) shader string. If it is quoted
4325bd8deadSopenharmony_ci    with double quotes in a previously included string, then the first
4335bd8deadSopenharmony_ci    search point will be the tree location where the previously included
4345bd8deadSopenharmony_ci    string had been found. If not found there, the search continues at
4355bd8deadSopenharmony_ci    the beginning of the list of search points, as just described. It is
4365bd8deadSopenharmony_ci    a compile error if
4375bd8deadSopenharmony_ci
4385bd8deadSopenharmony_ci      * the first time the path is found in the tree relative to a
4395bd8deadSopenharmony_ci        search point, there is no string assigned to that path
4405bd8deadSopenharmony_ci      * the path is not found relative to any of the search points."
4415bd8deadSopenharmony_ci
4425bd8deadSopenharmony_ci    Replace the paragraph of section 3.3 starting with '__FILE__
4435bd8deadSopenharmony_ci    will...' with:
4445bd8deadSopenharmony_ci
4455bd8deadSopenharmony_ci   "__FILE__ will substitute either a decimal integer constant that says
4465bd8deadSopenharmony_ci    which source string number is currently being processed, or the path
4475bd8deadSopenharmony_ci    of the string if the string was an included string. This path will
4485bd8deadSopenharmony_ci    be the same as the path supplied to the #include directive."
4495bd8deadSopenharmony_ci
4505bd8deadSopenharmony_ci    Replace the last paragraph of section 3.3 with:
4515bd8deadSopenharmony_ci
4525bd8deadSopenharmony_ci   "#line must have, after macro substitution, one of the following
4535bd8deadSopenharmony_ci    forms:
4545bd8deadSopenharmony_ci
4555bd8deadSopenharmony_ci       #line <line>
4565bd8deadSopenharmony_ci       #line <line> <source-string-number>
4575bd8deadSopenharmony_ci       #line <line> "<path>"
4585bd8deadSopenharmony_ci
4595bd8deadSopenharmony_ci    where <line> and <source-string-number> are constant integer
4605bd8deadSopenharmony_ci    expressions and <path> is a valid string for a path supplied in the
4615bd8deadSopenharmony_ci    #include directive. After processing this directive (including its
4625bd8deadSopenharmony_ci    new-line), the implementation will behave as if it is compiling at
4635bd8deadSopenharmony_ci    line number <line> and source string number <source-string-number>
4645bd8deadSopenharmony_ci    or <path> path. Subsequent source strings will be numbered
4655bd8deadSopenharmony_ci    sequentially, until another #line directive overrides that
4665bd8deadSopenharmony_ci    numbering."
4675bd8deadSopenharmony_ci
4685bd8deadSopenharmony_ciAdditions to Appendix A (Looking up Paths in Trees) of the OpenGL
4695bd8deadSopenharmony_ciShading Language 1.50 Specification
4705bd8deadSopenharmony_ci
4715bd8deadSopenharmony_ci    Add a new appendix A:
4725bd8deadSopenharmony_ci
4735bd8deadSopenharmony_ci   "Appendix A: Looking up Paths in Trees
4745bd8deadSopenharmony_ci
4755bd8deadSopenharmony_ci    Introduction
4765bd8deadSopenharmony_ci
4775bd8deadSopenharmony_ci    The GLSL #include mechanism looks up paths in a tree built through
4785bd8deadSopenharmony_ci    the OpenGL API. This appendix describes the syntax and semantic
4795bd8deadSopenharmony_ci    model of the tree and paths into the tree. How the tree is used is
4805bd8deadSopenharmony_ci    up to users of the tree, like the OpenGL API or GLSL.
4815bd8deadSopenharmony_ci
4825bd8deadSopenharmony_ci    The Tree
4835bd8deadSopenharmony_ci
4845bd8deadSopenharmony_ci    The tree is a singly rooted hierarchy of tree locations. The root
4855bd8deadSopenharmony_ci    may have one or more child locations, and any location may in turn
4865bd8deadSopenharmony_ci    have its own children. Except for the root, each location has
4875bd8deadSopenharmony_ci    exactly one parent; the root has no parent.
4885bd8deadSopenharmony_ci
4895bd8deadSopenharmony_ci    Paths into the Tree
4905bd8deadSopenharmony_ci
4915bd8deadSopenharmony_ci    The locations in the tree are created or looked up by path strings.
4925bd8deadSopenharmony_ci    The path string "/" locates the root of the tree. The path "/foo"
4935bd8deadSopenharmony_ci    locates the child "foo" of the root. Formally, a valid path is a
4945bd8deadSopenharmony_ci    sequence of tokens delimited by the beginning of the string, by the
4955bd8deadSopenharmony_ci    path-separator forward slash ( / ), and by the end of the string.
4965bd8deadSopenharmony_ci    The string "foo/bar" has two tokens; "foo" and "bar". The string
4975bd8deadSopenharmony_ci    "/foo/./bar" has 3 tokens; "foo", ".", and "bar". The string
4985bd8deadSopenharmony_ci    "/foo/.." has two tokens; "foo" and "..". The string "/foo/.bar" has
4995bd8deadSopenharmony_ci    two tokens; "foo" and ".bar". A path is invalid if
5005bd8deadSopenharmony_ci
5015bd8deadSopenharmony_ci      * <path> contains any characters not listed in Section 3.1
5025bd8deadSopenharmony_ci        "Character Set", or the double quote character, or angled
5035bd8deadSopenharmony_ci        brackets, or any white space characters other than the space
5045bd8deadSopenharmony_ci        character,
5055bd8deadSopenharmony_ci      * <path> has consecutive forward slashes ( // ); "/foo//bar" is
5065bd8deadSopenharmony_ci        not valid (zero length tokens are not allowed),
5075bd8deadSopenharmony_ci      * <path> ends with a forward slash ( / ), or
5085bd8deadSopenharmony_ci      * <path> contains no characters.
5095bd8deadSopenharmony_ci
5105bd8deadSopenharmony_ci    There are no path escape characters, so there is no way to get the
5115bd8deadSopenharmony_ci    forward slash delimiter within a single token.
5125bd8deadSopenharmony_ci
5135bd8deadSopenharmony_ci    When using a path to lookup a tree location, the path tokens are
5145bd8deadSopenharmony_ci    used to walk the tree. The initial location to start the walk is
5155bd8deadSopenharmony_ci    specified by the user of the tree and is updated as follows by the
5165bd8deadSopenharmony_ci    tokens in the path. (Paths starting with "/" will start at the
5175bd8deadSopenharmony_ci    root.) Taken left to right:
5185bd8deadSopenharmony_ci
5195bd8deadSopenharmony_ci    The token ".." walks to the parent. Or, if already at the root, then
5205bd8deadSopenharmony_ci    the location remains at the root.
5215bd8deadSopenharmony_ci
5225bd8deadSopenharmony_ci    The token "." leaves the location unchanged.
5235bd8deadSopenharmony_ci
5245bd8deadSopenharmony_ci    Any other token is considered the name of a child of the current
5255bd8deadSopenharmony_ci    location, and walks to that child. (If there is no child of that
5265bd8deadSopenharmony_ci    name, this may result in a failed lookup or in the child being
5275bd8deadSopenharmony_ci    created, as specified by the user of the tree for the operation
5285bd8deadSopenharmony_ci    being performed.)
5295bd8deadSopenharmony_ci
5305bd8deadSopenharmony_ci    Associated Strings
5315bd8deadSopenharmony_ci
5325bd8deadSopenharmony_ci    Each location in the tree can have an additional string associated
5335bd8deadSopenharmony_ci    with it (that a user like the #include mechanism can use as an
5345bd8deadSopenharmony_ci    included string). This is true even for locations that have
5355bd8deadSopenharmony_ci    children: "/foo/bar" can exist in the tree at the same time that
5365bd8deadSopenharmony_ci    "/foo" has an additional string associated with it. Typically, when
5375bd8deadSopenharmony_ci    a path is used to find a location in the tree, it is for the purpose
5385bd8deadSopenharmony_ci    of returning this associated string.
5395bd8deadSopenharmony_ci
5405bd8deadSopenharmony_ci    Hence, the tree can be built from a collection of (path,string)
5415bd8deadSopenharmony_ci    pairs, where path is a string establishing the existence of a
5425bd8deadSopenharmony_ci    location in the tree and string is the string associated with the
5435bd8deadSopenharmony_ci    node. Details of how to do this are specified by the user of the
5445bd8deadSopenharmony_ci    tree."
5455bd8deadSopenharmony_ci
5465bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL Specifications
5475bd8deadSopenharmony_ci
5485bd8deadSopenharmony_ci    None.
5495bd8deadSopenharmony_ci
5505bd8deadSopenharmony_ciGLX Protocol
5515bd8deadSopenharmony_ci
5525bd8deadSopenharmony_ci    To be determined.
5535bd8deadSopenharmony_ci
5545bd8deadSopenharmony_ciErrors
5555bd8deadSopenharmony_ci
5565bd8deadSopenharmony_ci    <fill in from spec language above>
5575bd8deadSopenharmony_ci
5585bd8deadSopenharmony_ciNew State
5595bd8deadSopenharmony_ci
5605bd8deadSopenharmony_ci    Add new state table 6.46 and renumber existing
5615bd8deadSopenharmony_ci    tables starting at 6.47:
5625bd8deadSopenharmony_ci
5635bd8deadSopenharmony_ci   "Table 6.46: Named String State
5645bd8deadSopenharmony_ci
5655bd8deadSopenharmony_ci    Get Value               Initial Value Get Command         Type    Description           Sec.   Attribute
5665bd8deadSopenharmony_ci    ---------               ------------- ----------------    ------  --------------------- ------ ---------
5675bd8deadSopenharmony_ci    NAMED_STRING_LENGTH_ARB --            GetNamedStringivARB n x Z+  Named string length   6.1.10 --
5685bd8deadSopenharmony_ci    NAMED_STRING_TYPE_ARB   --            GetNamedStringivARB n x Z_1 Named string type     6.1.10 --
5695bd8deadSopenharmony_ci    --                      --            GetNamedStringARB   n x S   Named string contents 6.1.10 --"
5705bd8deadSopenharmony_ci
5715bd8deadSopenharmony_ciRevision History
5725bd8deadSopenharmony_ci
5735bd8deadSopenharmony_ci    Rev.    Date    Author    Changes
5745bd8deadSopenharmony_ci    ----  --------  --------- ------------------------------------------
5755bd8deadSopenharmony_ci    17    13/06/24  Jon Leech
5765bd8deadSopenharmony_ci      - Add additional 'const' attribute to CompileShaderIncludeARB
5775bd8deadSopenharmony_ci        <path> (Bug 9006).
5785bd8deadSopenharmony_ci    16    10/02/10  Jon Leech
5795bd8deadSopenharmony_ci      - Remove 'const' attribute from GetNamedStringARB <stringlen>.
5805bd8deadSopenharmony_ci    15    10/01/27  Jon Leech
5815bd8deadSopenharmony_ci      - Update issues. Minor corrections from John Kessenich.
5825bd8deadSopenharmony_ci    14    10/01/26  pbrown
5835bd8deadSopenharmony_ci      - Assigned enumerant values.
5845bd8deadSopenharmony_ci    13    10/01/26  Jon Leech
5855bd8deadSopenharmony_ci      - Restore ARB suffixes.
5865bd8deadSopenharmony_ci    12    10/01/25  Jon Leech
5875bd8deadSopenharmony_ci      - Merge major edits from GLSL 1.60 (now GLSL 3.30).
5885bd8deadSopenharmony_ci    11    10/01/14  Jon Leech
5895bd8deadSopenharmony_ci      - Sync up with minor edits to the GL 3.3 API spec language. Major
5905bd8deadSopenharmony_ci        edits to the GLSL 1.60 spec language are still to be pulled back
5915bd8deadSopenharmony_ci        into the extension.
5925bd8deadSopenharmony_ci    10    09/11/12  Jon Leech
5935bd8deadSopenharmony_ci      - Remove redundant <namelen> == zero errors, since an empty name
5945bd8deadSopenharmony_ci        is not a valid pathname.
5955bd8deadSopenharmony_ci      - Change "match" to "have the same meanings as" when describing
5965bd8deadSopenharmony_ci        parameters common to multiple commands.
5975bd8deadSopenharmony_ci      - Make errors for CompileShaderInclude consistent and more
5985bd8deadSopenharmony_ci        robust against NULL pointers.
5995bd8deadSopenharmony_ci      - Confirm that IsNamedString does not generate errors due to
6005bd8deadSopenharmony_ci        otherwise invalid names.
6015bd8deadSopenharmony_ci      - Added Bruce's comments on sharing to issue 4.
6025bd8deadSopenharmony_ci     9    09/10/30  Jon Leech
6035bd8deadSopenharmony_ci      - Replace "canonical pathname" with "tree location".
6045bd8deadSopenharmony_ci      - Add NAMED_STRING_TYPE query.
6055bd8deadSopenharmony_ci      - Add new state table with named string parameters and contents.
6065bd8deadSopenharmony_ci      - Add issue 20 on why there are no examples.
6075bd8deadSopenharmony_ci     8    09/10/29  Jon Leech
6085bd8deadSopenharmony_ci      - Add GetNamedStringiv query for named string length.
6095bd8deadSopenharmony_ci      - Add requirement to pathname rule 3 that #include strings and
6105bd8deadSopenharmony_ci        string names may not end in '/', but search paths may end in
6115bd8deadSopenharmony_ci        '/'.
6125bd8deadSopenharmony_ci      - Change type of 'namelen' and 'stringlen' parameters from sizei
6135bd8deadSopenharmony_ci        to int to allow specifying null-termianted strings.
6145bd8deadSopenharmony_ci      - Finish removing references to namespaces from GLSL language.
6155bd8deadSopenharmony_ci     7    09/10/28  Jon Leech
6165bd8deadSopenharmony_ci      Many changes from group discussion:
6175bd8deadSopenharmony_ci      - Rename extension to ARB_shading_language_include by
6185bd8deadSopenharmony_ci        symmetry with ARB_shading_language_100.
6195bd8deadSopenharmony_ci      - Remove namespace objects and go back to a single shared named
6205bd8deadSopenharmony_ci        string dictionary.
6215bd8deadSopenharmony_ci      - Remove __FILE_NAMESPACE__ macro from shader language.
6225bd8deadSopenharmony_ci      - Pass multiple path strings to CompileShaderInclude, instead of
6235bd8deadSopenharmony_ci        multiple namespace objects.
6245bd8deadSopenharmony_ci      - Require all string names and paths specified through the API to
6255bd8deadSopenharmony_ci        start with '/'.
6265bd8deadSopenharmony_ci      - Support both #include <name> and #include "name" and try to make
6275bd8deadSopenharmony_ci        usage correspond to expectations of C/C++ programmers.
6285bd8deadSopenharmony_ci      - Allow "." and ".." in pathnames and otherwise refine
6295bd8deadSopenharmony_ci        rules on allowed paths.
6305bd8deadSopenharmony_ci      - Introduce concept of canonical pathnames as the key in
6315bd8deadSopenharmony_ci        the named string dictionary.
6325bd8deadSopenharmony_ci      - Added GetNamedString query for completeness.
6335bd8deadSopenharmony_ci      - Still need to expand bullet list of #include behavior into GLSL
6345bd8deadSopenharmony_ci        spec language.
6355bd8deadSopenharmony_ci      - Updated sharing model.
6365bd8deadSopenharmony_ci     6    09/10/15  Jon Leech
6375bd8deadSopenharmony_ci      - Change type of CompileShaderInclude <length> parameter to sizei.
6385bd8deadSopenharmony_ci      - Add GLSL spec edits from John Kessenich, related issues 16-18,
6395bd8deadSopenharmony_ci        and describe the required #extension line.
6405bd8deadSopenharmony_ci      - Use #include <name> instead of #include "name" (see issue 15).
6415bd8deadSopenharmony_ci      - Fix type of CompileShaderInclude <length> parameter.
6425bd8deadSopenharmony_ci      - Make namespace contents invariant for the duration of
6435bd8deadSopenharmony_ci        CompileShaderInclude (from the point of view of the code being
6445bd8deadSopenharmony_ci        compiled).
6455bd8deadSopenharmony_ci      - Update sharing and object model issues 4 and 8 and corresponding
6465bd8deadSopenharmony_ci        Appendix D and error language in the spec.
6475bd8deadSopenharmony_ci      - Fix typos.
6485bd8deadSopenharmony_ci     5    09/10/14  Jon Leech
6495bd8deadSopenharmony_ci      - Rewritten to add namespaces as proposed by Daniel Koch.
6505bd8deadSopenharmony_ci      - Use the shader and program object model for namespace objects.
6515bd8deadSopenharmony_ci      - Change the appendix D language for how multicontext changes to
6525bd8deadSopenharmony_ci        namespaces and names are handled
6535bd8deadSopenharmony_ci      - Update all the issues.
6545bd8deadSopenharmony_ci     4    09/10/04  Jon Leech Add more issues from email discussion
6555bd8deadSopenharmony_ci     3    09/09/24  Jon Leech Define named strings as shared resources
6565bd8deadSopenharmony_ci     2    09/09/24  Jon Leech Fix name of DeleteNamedString
6575bd8deadSopenharmony_ci     1    09/09/24  Jon Leech Initial revision for the Phoenix F2F mtg
6585bd8deadSopenharmony_ci
6595bd8deadSopenharmony_ciIssues
6605bd8deadSopenharmony_ci
6615bd8deadSopenharmony_ci    1) Should names be global, per-program, or per-shader?
6625bd8deadSopenharmony_ci
6635bd8deadSopenharmony_ci        RESOLVED: names are global across the context share list. This
6645bd8deadSopenharmony_ci        is desirable since the point of #include is to reuse as much
6655bd8deadSopenharmony_ci        content as possible.
6665bd8deadSopenharmony_ci
6675bd8deadSopenharmony_ci    2) Should named strings be specified in the API with a single
6685bd8deadSopenharmony_ci       string, or with an array of strings like ShaderSource?
6695bd8deadSopenharmony_ci
6705bd8deadSopenharmony_ci        RESOLVED: a single string.
6715bd8deadSopenharmony_ci
6725bd8deadSopenharmony_ci    3) Are there any constraints on the contents of string names and
6735bd8deadSopenharmony_ci       strings?
6745bd8deadSopenharmony_ci
6755bd8deadSopenharmony_ci        RESOLVED: There are constraints on string names when a named
6765bd8deadSopenharmony_ci        string is defined, deleted, or queried. Names must be valid GLSL
6775bd8deadSopenharmony_ci        pathnames and must also begin with '/'. Additionally string
6785bd8deadSopenharmony_ci        names are converted to tree locations prior to defining a
6795bd8deadSopenharmony_ci        string.
6805bd8deadSopenharmony_ci
6815bd8deadSopenharmony_ci        There are no definition-time constraints on string contents,
6825bd8deadSopenharmony_ci        though of course #include directives must expand to legal source
6835bd8deadSopenharmony_ci        in the shader being compiled, or compilation will fail.
6845bd8deadSopenharmony_ci
6855bd8deadSopenharmony_ci    4) How full-featured are named string objects?
6865bd8deadSopenharmony_ci
6875bd8deadSopenharmony_ci        PROPOSED: named strings are full-fledged objects, although they
6885bd8deadSopenharmony_ci        are objects whose names are "tree locations" corresponding to
6895bd8deadSopenharmony_ci        strings specified in the API, instead of GLuint handles.
6905bd8deadSopenharmony_ci
6915bd8deadSopenharmony_ci        Named strings are intended to be very simple objects which will
6925bd8deadSopenharmony_ci        be infrequently created, updated, or deleted, so naming them by
6935bd8deadSopenharmony_ci        passing string names should be fast enough for this use. There
6945bd8deadSopenharmony_ci        is an IsNamedString query, but there is no way to iterate over
6955bd8deadSopenharmony_ci        all the strings (just as there is no way to iterate over all the
6965bd8deadSopenharmony_ci        names of any other class of object in OpenGL).
6975bd8deadSopenharmony_ci
6985bd8deadSopenharmony_ci        UNRESOLVED: we still need to make sure the proposed sharing
6995bd8deadSopenharmony_ci        rules will make sense and address all the special cases.
7005bd8deadSopenharmony_ci        Bruce offered the following comments on spec language:
7015bd8deadSopenharmony_ci
7025bd8deadSopenharmony_ci       "When a named string, shader object, or program object is
7035bd8deadSopenharmony_ci        deleted, it is flagged for deletion, but its name remains valid
7045bd8deadSopenharmony_ci        until the underlying object can be deleted because it is no
7055bd8deadSopenharmony_ci        longer in use."
7065bd8deadSopenharmony_ci
7075bd8deadSopenharmony_ci        Bruce: I think there are potentially some problems with this.
7085bd8deadSopenharmony_ci        Consider an app routine that does something like this:
7095bd8deadSopenharmony_ci
7105bd8deadSopenharmony_ci        1. Walks some directory tree on the FS
7115bd8deadSopenharmony_ci        2. Suck in all the contents, make named strings out of them.
7125bd8deadSopenharmony_ci        3. CompileShaderIncludes
7135bd8deadSopenharmony_ci        4. Deletes the named strings it created.
7145bd8deadSopenharmony_ci
7155bd8deadSopenharmony_ci        Now suppose this routine is used twice, and at the same time
7165bd8deadSopenharmony_ci        another thread/context calls CompileShaderIncludes (even
7175bd8deadSopenharmony_ci        implicitly via CompilerShader, with no #includes in the source)
7185bd8deadSopenharmony_ci        - according to the language below, this still causes the entire
7195bd8deadSopenharmony_ci        database to become attached. If this other CompileShaderIncludes
7205bd8deadSopenharmony_ci        starts just before step 4 the first time round, and end just
7215bd8deadSopenharmony_ci        before step 3 the second time around, then all the deletions
7225bd8deadSopenharmony_ci        suddenly kick in right before we were about to call the
7235bd8deadSopenharmony_ci        compiler. So even though these compilations used completely
7245bd8deadSopenharmony_ci        disjoint sets of objects, they still managed to cause spooky
7255bd8deadSopenharmony_ci        action at a distance.
7265bd8deadSopenharmony_ci
7275bd8deadSopenharmony_ci       "[fn4 - implementations may use locking, caching, or other
7285bd8deadSopenharmony_ci        techniques to realize such invariance. Again this effectively
7295bd8deadSopenharmony_ci        places a lock around the dictionary in order to provide
7305bd8deadSopenharmony_ci        predictable multicontext behavior across all implementations.]"
7315bd8deadSopenharmony_ci
7325bd8deadSopenharmony_ci        Bruce: I don't see how changing names in the middle of
7335bd8deadSopenharmony_ci        compilation is any different from calling ShaderSource in one
7345bd8deadSopenharmony_ci        context at the same time as CompileShader in the other context.
7355bd8deadSopenharmony_ci        Making such guarantees aren't going to make apps that don't
7365bd8deadSopenharmony_ci        synchronise their threads properly magically start working, and
7375bd8deadSopenharmony_ci        they could add a lot of extra complexity to what is supposed to
7385bd8deadSopenharmony_ci        be a very simple system.
7395bd8deadSopenharmony_ci
7405bd8deadSopenharmony_ci    5) Do we need named string queries?
7415bd8deadSopenharmony_ci
7425bd8deadSopenharmony_ci        RESOLVED: Since they are objects (albeit simple ones), we
7435bd8deadSopenharmony_ci        support queries.
7445bd8deadSopenharmony_ci
7455bd8deadSopenharmony_ci    6)  The GLSL language is underspecified
7465bd8deadSopenharmony_ci
7475bd8deadSopenharmony_ci        UNRESOLVED: John Kessenich has written up a detailed bullet list
7485bd8deadSopenharmony_ci        defining the behavior of #include and how API string names and
7495bd8deadSopenharmony_ci        #include string arguments are converted to "tree locations". The
7505bd8deadSopenharmony_ci        bullet points has not yet been refined into final spec language.
7515bd8deadSopenharmony_ci
7525bd8deadSopenharmony_ci    7) What is the <type> parameter for?
7535bd8deadSopenharmony_ci
7545bd8deadSopenharmony_ci        RESOLVED: Future expansion.
7555bd8deadSopenharmony_ci
7565bd8deadSopenharmony_ci    8) Are named strings shared?
7575bd8deadSopenharmony_ci
7585bd8deadSopenharmony_ci        RESOLVED: Yes. The update semantics may appear odd because named
7595bd8deadSopenharmony_ci        strings are not explicitly bound to a context; they simply exist
7605bd8deadSopenharmony_ci        in the share list. Appendix D language has been updated to
7615bd8deadSopenharmony_ci        describe treat CompileShaderInclude as a virtual bind point
7625bd8deadSopenharmony_ci        which "directly attaches" all named strings to the context for
7635bd8deadSopenharmony_ci        the duration of any compilation in which they may be used.
7645bd8deadSopenharmony_ci
7655bd8deadSopenharmony_ci        RESOLVED: CompileShaderInclude is defined to use the state of
7665bd8deadSopenharmony_ci        the named string dictionary at the time it is called. Additions
7675bd8deadSopenharmony_ci        or deletions from other contexts will not affect an ongoing
7685bd8deadSopenharmony_ci        compile. This might be implemented with any combination of
7695bd8deadSopenharmony_ci        techniques such as locks, reference counting against deletion,
7705bd8deadSopenharmony_ci        caching context-local copies, etc. This should produce
7715bd8deadSopenharmony_ci        well-defined behavior without overly constraining implementation
7725bd8deadSopenharmony_ci        choices.
7735bd8deadSopenharmony_ci
7745bd8deadSopenharmony_ci    9) What is the binding point at which #include strings are
7755bd8deadSopenharmony_ci       associated with shaders?
7765bd8deadSopenharmony_ci
7775bd8deadSopenharmony_ci        RESOLVED: CompileShaderInclude. Since the string associated with
7785bd8deadSopenharmony_ci        a name can change over time, for predictability we must specify
7795bd8deadSopenharmony_ci        when a shader expands #include directives. CompileShaderInclude
7805bd8deadSopenharmony_ci        is the only logical place to do this.
7815bd8deadSopenharmony_ci
7825bd8deadSopenharmony_ci        If there are any implementations which defer compilation, they
7835bd8deadSopenharmony_ci        will probably have to do extra work in CompileShaderInclude to
7845bd8deadSopenharmony_ci        cache the named string contents at that time.
7855bd8deadSopenharmony_ci
7865bd8deadSopenharmony_ci    10) Who is responsible for creating the named string dictionary?
7875bd8deadSopenharmony_ci
7885bd8deadSopenharmony_ci        RESOLVED: The app. This extension provides mechanism, not
7895bd8deadSopenharmony_ci        policy, and there is no realistic and portable way for a GL
7905bd8deadSopenharmony_ci        implementation to guess what #include directives are supposed to
7915bd8deadSopenharmony_ci        mean. However, it's straightforward to provide utility libraries
7925bd8deadSopenharmony_ci        which read a particular directory tree of files and define them
7935bd8deadSopenharmony_ci        as a corresponding set of named strings in GL.
7945bd8deadSopenharmony_ci
7955bd8deadSopenharmony_ci        In the future, it would be possible for a layered extension to
7965bd8deadSopenharmony_ci        allow directly searching the client filesystem by passing
7975bd8deadSopenharmony_ci        special searchpaths to CompileShaderInclude. For example, the
7985bd8deadSopenharmony_ci        path "//usr/include/GL", which is not a valid search path in
7995bd8deadSopenharmony_ci        this extension, could be defined to search starting in
8005bd8deadSopenharmony_ci        /usr/include/GL on the client filesystem. There are a number of
8015bd8deadSopenharmony_ci        thorny pitfalls in such usage (for example portability and
8025bd8deadSopenharmony_ci        implementability on separate client/server hardware) and we do
8035bd8deadSopenharmony_ci        not feel a need to support such usage initially.
8045bd8deadSopenharmony_ci
8055bd8deadSopenharmony_ci    11) Do we need to provide a "#once" or "#pragma once" directive to
8065bd8deadSopenharmony_ci        protect against re-inclusion of headers, and possible infinite
8075bd8deadSopenharmony_ci        loops of #includes?
8085bd8deadSopenharmony_ci
8095bd8deadSopenharmony_ci        RESOLVED: No (by straw poll of the Nextgen TSG on 2009/10/19).
8105bd8deadSopenharmony_ci        Instead the
8115bd8deadSopenharmony_ci
8125bd8deadSopenharmony_ci            #ifndef FOO_H
8135bd8deadSopenharmony_ci            #define FOO_H
8145bd8deadSopenharmony_ci            ...
8155bd8deadSopenharmony_ci            #endif /* FOO_H */
8165bd8deadSopenharmony_ci
8175bd8deadSopenharmony_ci        approach can be used. See discussion of this feature in C:
8185bd8deadSopenharmony_ci
8195bd8deadSopenharmony_ci            http://en.wikipedia.org/wiki/Pragma_once
8205bd8deadSopenharmony_ci
8215bd8deadSopenharmony_ci    12) What other approaches for named strings exist?
8225bd8deadSopenharmony_ci
8235bd8deadSopenharmony_ci        Alternatives we experimented with were a new shader type along
8245bd8deadSopenharmony_ci        with a #name or glShaderName() directive, or explicit "include
8255bd8deadSopenharmony_ci        space" objects in which named strings exist, instead of what is
8265bd8deadSopenharmony_ci        effectively a single implicit "include space" object as in this
8275bd8deadSopenharmony_ci        proposal.
8285bd8deadSopenharmony_ci
8295bd8deadSopenharmony_ci    13) Should we impose syntax and namespace rules on string names?
8305bd8deadSopenharmony_ci
8315bd8deadSopenharmony_ci        RESOLVED: String names (API) and search paths / #include
8325bd8deadSopenharmony_ci        pathnames (GLSL) are expressed in a syntax supporting many Unix
8335bd8deadSopenharmony_ci        pathnames as well as the "." and ".." directives, and must be in
8345bd8deadSopenharmony_ci        the valid GLSL character set. Exact rules define how #include
8355bd8deadSopenharmony_ci        pathnames are searched for in the named string database.
8365bd8deadSopenharmony_ci
8375bd8deadSopenharmony_ci        RESOLVED: We do not impose any namespace rules on string names
8385bd8deadSopenharmony_ci        or search paths.
8395bd8deadSopenharmony_ci
8405bd8deadSopenharmony_ci        PROPOSED: We suggest that string names starting with "/GL/" be
8415bd8deadSopenharmony_ci        reserved to Khronos, but do not enforce this, and also suggest
8425bd8deadSopenharmony_ci        that applications use consistent conventions on pathnames, such
8435bd8deadSopenharmony_ci        as defining named strings under "/<vendorname>/path" and
8445bd8deadSopenharmony_ci        referring to them by that same name in #include directives.
8455bd8deadSopenharmony_ci
8465bd8deadSopenharmony_ci    14) Is this an extension or a "feature specification"?
8475bd8deadSopenharmony_ci
8485bd8deadSopenharmony_ci        RESOLVED: An extension. We decided not to put #include into
8495bd8deadSopenharmony_ci        OpenGL 3.3 / 4.0 yet.
8505bd8deadSopenharmony_ci
8515bd8deadSopenharmony_ci    15) How are nested (and potentially relative) includes handled?
8525bd8deadSopenharmony_ci
8535bd8deadSopenharmony_ci        RESOLVED: Rules like those of a Unix C preprocessor are used to
8545bd8deadSopenharmony_ci        combine #include arguments with the specified compiler search
8555bd8deadSopenharmony_ci        path.
8565bd8deadSopenharmony_ci
8575bd8deadSopenharmony_ci    16) Do we really need to override the source string name with #line?
8585bd8deadSopenharmony_ci        This seems of questionable benefit.
8595bd8deadSopenharmony_ci
8605bd8deadSopenharmony_ci        RESOLVED: Yes. Of utility to automatic code generators like
8615bd8deadSopenharmony_ci        Yacc.
8625bd8deadSopenharmony_ci
8635bd8deadSopenharmony_ci    17) Should 0 or something like -1 be substituted for __FILE_SPACE__
8645bd8deadSopenharmony_ci        when used in a non-included sting?
8655bd8deadSopenharmony_ci
8665bd8deadSopenharmony_ci        PROPOSED: __FILE_NAMESPACE__ is no longer required, since
8675bd8deadSopenharmony_ci        explicit namespace objects have been removed from the extension.
8685bd8deadSopenharmony_ci        Instead __FILE__ is replaced with something corresponding to the
8695bd8deadSopenharmony_ci        "tree location" of the #include file being processed.
8705bd8deadSopenharmony_ci
8715bd8deadSopenharmony_ci    18) Consistency of API and GLSL string names / pathnames.
8725bd8deadSopenharmony_ci
8735bd8deadSopenharmony_ci        RESOLVED: The API and GLSL validate string names using the same
8745bd8deadSopenharmony_ci        rules, which are defined in the GLSL specification.
8755bd8deadSopenharmony_ci
8765bd8deadSopenharmony_ci    19) Why must string names and search paths in the API start with
8775bd8deadSopenharmony_ci        '/'?
8785bd8deadSopenharmony_ci
8795bd8deadSopenharmony_ci        Because string names and search paths must both be absolute,
8805bd8deadSopenharmony_ci        rather than relative, paths to function as intended.
8815bd8deadSopenharmony_ci
8825bd8deadSopenharmony_ci    20) Should there be examples of names and how multiple names
8835bd8deadSopenharmony_ci        correspond to the same tree location?
8845bd8deadSopenharmony_ci
8855bd8deadSopenharmony_ci        UNRESOLVED.
886