15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    ANGLE_texture_usage
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_ANGLE_texture_usage
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContributors
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    Nicolas Capens, TransGaming
125bd8deadSopenharmony_ci    Daniel Koch, TransGaming
135bd8deadSopenharmony_ci
145bd8deadSopenharmony_ciContact
155bd8deadSopenharmony_ci
165bd8deadSopenharmony_ci    Daniel Koch, TransGaming (daniel 'at' transgaming.com)
175bd8deadSopenharmony_ci
185bd8deadSopenharmony_ciStatus
195bd8deadSopenharmony_ci
205bd8deadSopenharmony_ci    Complete
215bd8deadSopenharmony_ci
225bd8deadSopenharmony_ciVersion
235bd8deadSopenharmony_ci
245bd8deadSopenharmony_ci    Last Modified Date:  November 10, 2011
255bd8deadSopenharmony_ci    Version:             2
265bd8deadSopenharmony_ci
275bd8deadSopenharmony_ciNumber
285bd8deadSopenharmony_ci
295bd8deadSopenharmony_ci    OpenGL ES Extension #112 
305bd8deadSopenharmony_ci
315bd8deadSopenharmony_ciDependencies
325bd8deadSopenharmony_ci
335bd8deadSopenharmony_ci    This extension is written against the OpenGL ES 2.0 Specification.
345bd8deadSopenharmony_ci
355bd8deadSopenharmony_ciOverview
365bd8deadSopenharmony_ci
375bd8deadSopenharmony_ci    In some implementations it is advantageous to know the expected
385bd8deadSopenharmony_ci    usage of a texture before the backing storage for it is allocated.  
395bd8deadSopenharmony_ci    This can help to inform the implementation's choice of format
405bd8deadSopenharmony_ci    and type of memory used for the allocation. If the usage is not
415bd8deadSopenharmony_ci    known in advance, the implementation essentially has to make a 
425bd8deadSopenharmony_ci    guess as to how it will be used.  If it is later proven wrong,
435bd8deadSopenharmony_ci    it may need to perform costly re-allocations and/or reformatting 
445bd8deadSopenharmony_ci    of the texture data, resulting in reduced performance.
455bd8deadSopenharmony_ci
465bd8deadSopenharmony_ci    This extension adds a texture usage flag that is specified via
475bd8deadSopenharmony_ci    the TEXTURE_USAGE_ANGLE TexParameter.  This can be used to 
485bd8deadSopenharmony_ci    indicate that the application knows that this texture will be 
495bd8deadSopenharmony_ci    used for rendering.
505bd8deadSopenharmony_ci
515bd8deadSopenharmony_ciIP Status
525bd8deadSopenharmony_ci
535bd8deadSopenharmony_ci    No known IP claims.
545bd8deadSopenharmony_ci
555bd8deadSopenharmony_ciNew Procedures and Functions
565bd8deadSopenharmony_ci
575bd8deadSopenharmony_ci    None
585bd8deadSopenharmony_ci
595bd8deadSopenharmony_ciNew Tokens
605bd8deadSopenharmony_ci
615bd8deadSopenharmony_ci    Accepted as a value for <pname> for the TexParameter{if} and 
625bd8deadSopenharmony_ci    TexParameter{if}v commands and for the <value> parameter of
635bd8deadSopenharmony_ci    GetTexParameter{if}v: 
645bd8deadSopenharmony_ci
655bd8deadSopenharmony_ci        TEXTURE_USAGE_ANGLE                     0x93A2
665bd8deadSopenharmony_ci
675bd8deadSopenharmony_ci    Accepted as a value to <param> for the TexParameter{if} and 
685bd8deadSopenharmony_ci    to <params> for the TexParameter{if}v commands with a <pname> of 
695bd8deadSopenharmony_ci    TEXTURE_USAGE_ANGLE; returned as possible values for <data> when 
705bd8deadSopenharmony_ci    GetTexParameter{if}v is queried with a <value> of TEXTURE_USAGE_ANGLE:
715bd8deadSopenharmony_ci
725bd8deadSopenharmony_ci        NONE                                    0x0000
735bd8deadSopenharmony_ci        FRAMEBUFFER_ATTACHMENT_ANGLE            0x93A3
745bd8deadSopenharmony_ci
755bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL ES 2.0 Specification (OpenGL ES Operation)
765bd8deadSopenharmony_ci
775bd8deadSopenharmony_ci    None
785bd8deadSopenharmony_ci
795bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL ES 2.0 Specification (Rasterization)
805bd8deadSopenharmony_ci
815bd8deadSopenharmony_ci    Add a new row to Table 3.10 (Texture parameters and their values):
825bd8deadSopenharmony_ci
835bd8deadSopenharmony_ci    Name                | Type | Legal Values 
845bd8deadSopenharmony_ci    ------------------------------------------------------------
855bd8deadSopenharmony_ci    TEXTURE_USAGE_ANGLE | enum | NONE, FRAMEBUFFER_ATTACHMENT_ANGLE
865bd8deadSopenharmony_ci
875bd8deadSopenharmony_ci    Add a new section 3.7.x (Texture Usage) before section 3.7.12 and 
885bd8deadSopenharmony_ci    renumber the subsequent sections: 
895bd8deadSopenharmony_ci
905bd8deadSopenharmony_ci    "3.7.x Texture Usage
915bd8deadSopenharmony_ci
925bd8deadSopenharmony_ci    Texture usage can be specified via the TEXTURE_USAGE_ANGLE value
935bd8deadSopenharmony_ci    for the <pname> argument to TexParameter{if}[v]. In order to take effect,
945bd8deadSopenharmony_ci    the texture usage must be specified before the texture contents are
955bd8deadSopenharmony_ci    defined either via TexImage2D or TexStorage2DEXT.
965bd8deadSopenharmony_ci
975bd8deadSopenharmony_ci    The usage values can impact the layout and type of memory used for the 
985bd8deadSopenharmony_ci    texture data. Specifying incorrect usage values may result in reduced
995bd8deadSopenharmony_ci    functionality and/or significantly degraded performance.
1005bd8deadSopenharmony_ci
1015bd8deadSopenharmony_ci    Possible values for <params> when <pname> is TEXTURE_USAGE_ANGLE are:
1025bd8deadSopenharmony_ci
1035bd8deadSopenharmony_ci    NONE - the default. No particular usage has been specified and it is
1045bd8deadSopenharmony_ci        up to the implementation to determine the usage of the texture.
1055bd8deadSopenharmony_ci        Leaving the usage unspecified means that the implementation may 
1065bd8deadSopenharmony_ci        have to reallocate the texture data as the texture is used in 
1075bd8deadSopenharmony_ci        various ways.
1085bd8deadSopenharmony_ci
1095bd8deadSopenharmony_ci    FRAMEBUFFER_ATTACHMENT_ANGLE - this texture will be attached to a 
1105bd8deadSopenharmony_ci        framebuffer object and used as a desination for rendering or blits."
1115bd8deadSopenharmony_ci
1125bd8deadSopenharmony_ci    Modify section 3.7.12 (Texture State) and place the last 3 sentences
1135bd8deadSopenharmony_ci    with the following:
1145bd8deadSopenharmony_ci
1155bd8deadSopenharmony_ci    "Next, there are the three sets of texture properties; each consists of
1165bd8deadSopenharmony_ci    the selected minification and magnification filters, the wrap modes for
1175bd8deadSopenharmony_ci    <s> and <t>, and the usage flags. In the initial state, the value assigned
1185bd8deadSopenharmony_ci    to TEXTURE_MIN_FILTER is NEAREST_MIPMAP_LINEAR, and the value for 
1195bd8deadSopenharmony_ci    TEXTURE_MAG_FILTER is LINEAR. <s> and <t> wrap modes are both set to
1205bd8deadSopenharmony_ci    REPEAT. The initial value for TEXTURE_USAGE_ANGLE is NONE."
1215bd8deadSopenharmony_ci
1225bd8deadSopenharmony_ci
1235bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL ES 2.0 Specification (Per-Fragment
1245bd8deadSopenharmony_ciOperations and the Framebuffer)
1255bd8deadSopenharmony_ci
1265bd8deadSopenharmony_ci    None
1275bd8deadSopenharmony_ci
1285bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL ES 2.0 Specification (Special
1295bd8deadSopenharmony_ciFunctions):
1305bd8deadSopenharmony_ci
1315bd8deadSopenharmony_ci    None
1325bd8deadSopenharmony_ci
1335bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL ES 2.0 Specification (State and
1345bd8deadSopenharmony_ciState Requests)
1355bd8deadSopenharmony_ci
1365bd8deadSopenharmony_ci    None
1375bd8deadSopenharmony_ci
1385bd8deadSopenharmony_ciDependencies on EXT_texture_storage
1395bd8deadSopenharmony_ci
1405bd8deadSopenharmony_ci    If EXT_texture_storage is not supported, omit any references to 
1415bd8deadSopenharmony_ci    TexStorage2DEXT.
1425bd8deadSopenharmony_ci
1435bd8deadSopenharmony_ciErrors
1445bd8deadSopenharmony_ci
1455bd8deadSopenharmony_ci    If TexParameter{if} or TexParamter{if}v is called with a <pname>
1465bd8deadSopenharmony_ci    of TEXTURE_USAGE_ANGLE and the value of <param> or <params> is not
1475bd8deadSopenharmony_ci    NONE or FRAMEBUFFER_ATTACHMENT_ANGLE the error INVALID_VALUE is
1485bd8deadSopenharmony_ci    generated.
1495bd8deadSopenharmony_ci
1505bd8deadSopenharmony_ciUsage Example
1515bd8deadSopenharmony_ci
1525bd8deadSopenharmony_ci    /* create and bind texture */
1535bd8deadSopenharmony_ci    glGenTextures(1, &texture);
1545bd8deadSopenharmony_ci    glActiveTexture(GL_TEXTURE0);
1555bd8deadSopenharmony_ci    glBindTexture(GL_TEXTURE_2D, texture);
1565bd8deadSopenharmony_ci
1575bd8deadSopenharmony_ci    /* specify texture parameters */
1585bd8deadSopenharmony_ci    glTexParameteri(GL_TEXTURE_2D, GL_*, ...);  /* as before */
1595bd8deadSopenharmony_ci    
1605bd8deadSopenharmony_ci    /* specify that we'll be rendering to the texture */
1615bd8deadSopenharmony_ci    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_USAGE_ANGLE, GL_FRAMEBUFFER_ATTACHMENT_ANGLE);
1625bd8deadSopenharmony_ci
1635bd8deadSopenharmony_ci    glTexStorage2DEXT(GL_TEXTURE_2D, levels, ...); // Allocation
1645bd8deadSopenharmony_ci    for(int level = 0; level < levels; ++level)
1655bd8deadSopenharmony_ci        glTexSubImage2D(GL_TEXTURE_2D, level, ...); // Initialisation
1665bd8deadSopenharmony_ci
1675bd8deadSopenharmony_ciIssues
1685bd8deadSopenharmony_ci
1695bd8deadSopenharmony_ci    1. Should there be a dynamic usage value?
1705bd8deadSopenharmony_ci   
1715bd8deadSopenharmony_ci       DISCUSSION: We could accept a dynamic flag to indicate that a texture will
1725bd8deadSopenharmony_ci       be updated frequently. We could map this to D3D9 dynamic textures. This would
1735bd8deadSopenharmony_ci       allow us to avoid creating temporary surfaces when updating the texture.
1745bd8deadSopenharmony_ci       However renderable textures cannot be dynamic in D3D9, which eliminates the 
1755bd8deadSopenharmony_ci       primary use case for this.  Furthermore, the memory usage of dynamic textures
1765bd8deadSopenharmony_ci       typically increases threefold when you lock it.
1775bd8deadSopenharmony_ci
1785bd8deadSopenharmony_ci    2. Should the texture usage be an enum or a bitfield?
1795bd8deadSopenharmony_ci
1805bd8deadSopenharmony_ci       UNRESOLVED.  Using a bitfield would allow combination of values to be specified.
1815bd8deadSopenharmony_ci       On the other hand, if combinations are really required, additional <pnames>
1825bd8deadSopenharmony_ci       could be added as necessary.  Querying a bitfield via the GetTexParameter command
1835bd8deadSopenharmony_ci       feels a bit odd.
1845bd8deadSopenharmony_ci
1855bd8deadSopenharmony_ci    3. What should happen if TEXTURE_USAGE_ANGLE is set/changed after the texture
1865bd8deadSopenharmony_ci       contents have been specified?
1875bd8deadSopenharmony_ci
1885bd8deadSopenharmony_ci       RESOLVED: It will have no effect. However, if the texture is redefined (for 
1895bd8deadSopenharmony_ci       example by TexImage2D) the new allocation will use the updated usage.
1905bd8deadSopenharmony_ci       GetTexParameter is used to query the value of the TEXTURE_USAGE_ANGLE
1915bd8deadSopenharmony_ci       state that was last set by TexParameter for the currently bound texture, or
1925bd8deadSopenharmony_ci       the default value if it has never been set. There is no way to determine the 
1935bd8deadSopenharmony_ci       usage that was in effect at the time the texture was defined.
1945bd8deadSopenharmony_ci
1955bd8deadSopenharmony_ciRevision History
1965bd8deadSopenharmony_ci
1975bd8deadSopenharmony_ci    Rev.    Date      Author     Changes
1985bd8deadSopenharmony_ci    ----  ----------- ---------  ----------------------------------------
1995bd8deadSopenharmony_ci      1   10 Nov 2011 dgkoch     Initial revision
2005bd8deadSopenharmony_ci      2   10 Nov 2011 dgkoch     Add overview
2015bd8deadSopenharmony_ci   
2025bd8deadSopenharmony_ci
203