• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Name
2
3    ANGLE_texture_usage
4
5Name Strings
6
7    GL_ANGLE_texture_usage
8
9Contributors
10
11    Nicolas Capens, TransGaming
12    Daniel Koch, TransGaming
13
14Contact
15
16    Daniel Koch, TransGaming (daniel 'at' transgaming.com)
17
18Status
19
20    Complete
21
22Version
23
24    Last Modified Date:  November 10, 2011
25    Version:             2
26
27Number
28
29    OpenGL ES Extension #112
30
31Dependencies
32
33    This extension is written against the OpenGL ES 2.0 Specification.
34
35Overview
36
37    In some implementations it is advantageous to know the expected
38    usage of a texture before the backing storage for it is allocated.
39    This can help to inform the implementation's choice of format
40    and type of memory used for the allocation. If the usage is not
41    known in advance, the implementation essentially has to make a
42    guess as to how it will be used.  If it is later proven wrong,
43    it may need to perform costly re-allocations and/or reformatting
44    of the texture data, resulting in reduced performance.
45
46    This extension adds a texture usage flag that is specified via
47    the TEXTURE_USAGE_ANGLE TexParameter.  This can be used to
48    indicate that the application knows that this texture will be
49    used for rendering.
50
51IP Status
52
53    No known IP claims.
54
55New Procedures and Functions
56
57    None
58
59New Tokens
60
61    Accepted as a value for <pname> for the TexParameter{if} and
62    TexParameter{if}v commands and for the <value> parameter of
63    GetTexParameter{if}v:
64
65        TEXTURE_USAGE_ANGLE                     0x93A2
66
67    Accepted as a value to <param> for the TexParameter{if} and
68    to <params> for the TexParameter{if}v commands with a <pname> of
69    TEXTURE_USAGE_ANGLE; returned as possible values for <data> when
70    GetTexParameter{if}v is queried with a <value> of TEXTURE_USAGE_ANGLE:
71
72        NONE                                    0x0000
73        FRAMEBUFFER_ATTACHMENT_ANGLE            0x93A3
74
75Additions to Chapter 2 of the OpenGL ES 2.0 Specification (OpenGL ES Operation)
76
77    None
78
79Additions to Chapter 3 of the OpenGL ES 2.0 Specification (Rasterization)
80
81    Add a new row to Table 3.10 (Texture parameters and their values):
82
83    Name                | Type | Legal Values
84    ------------------------------------------------------------
85    TEXTURE_USAGE_ANGLE | enum | NONE, FRAMEBUFFER_ATTACHMENT_ANGLE
86
87    Add a new section 3.7.x (Texture Usage) before section 3.7.12 and
88    renumber the subsequent sections:
89
90    "3.7.x Texture Usage
91
92    Texture usage can be specified via the TEXTURE_USAGE_ANGLE value
93    for the <pname> argument to TexParameter{if}[v]. In order to take effect,
94    the texture usage must be specified before the texture contents are
95    defined either via TexImage2D or TexStorage2DEXT.
96
97    The usage values can impact the layout and type of memory used for the
98    texture data. Specifying incorrect usage values may result in reduced
99    functionality and/or significantly degraded performance.
100
101    Possible values for <params> when <pname> is TEXTURE_USAGE_ANGLE are:
102
103    NONE - the default. No particular usage has been specified and it is
104        up to the implementation to determine the usage of the texture.
105        Leaving the usage unspecified means that the implementation may
106        have to reallocate the texture data as the texture is used in
107        various ways.
108
109    FRAMEBUFFER_ATTACHMENT_ANGLE - this texture will be attached to a
110        framebuffer object and used as a desination for rendering or blits."
111
112    Modify section 3.7.12 (Texture State) and place the last 3 sentences
113    with the following:
114
115    "Next, there are the three sets of texture properties; each consists of
116    the selected minification and magnification filters, the wrap modes for
117    <s> and <t>, and the usage flags. In the initial state, the value assigned
118    to TEXTURE_MIN_FILTER is NEAREST_MIPMAP_LINEAR, and the value for
119    TEXTURE_MAG_FILTER is LINEAR. <s> and <t> wrap modes are both set to
120    REPEAT. The initial value for TEXTURE_USAGE_ANGLE is NONE."
121
122
123Additions to Chapter 4 of the OpenGL ES 2.0 Specification (Per-Fragment
124Operations and the Framebuffer)
125
126    None
127
128Additions to Chapter 5 of the OpenGL ES 2.0 Specification (Special
129Functions):
130
131    None
132
133Additions to Chapter 6 of the OpenGL ES 2.0 Specification (State and
134State Requests)
135
136    None
137
138Dependencies on EXT_texture_storage
139
140    If EXT_texture_storage is not supported, omit any references to
141    TexStorage2DEXT.
142
143Errors
144
145    If TexParameter{if} or TexParamter{if}v is called with a <pname>
146    of TEXTURE_USAGE_ANGLE and the value of <param> or <params> is not
147    NONE or FRAMEBUFFER_ATTACHMENT_ANGLE the error INVALID_VALUE is
148    generated.
149
150Usage Example
151
152    /* create and bind texture */
153    glGenTextures(1, &texture);
154    glActiveTexture(GL_TEXTURE0);
155    glBindTexture(GL_TEXTURE_2D, texture);
156
157    /* specify texture parameters */
158    glTexParameteri(GL_TEXTURE_2D, GL_*, ...);  /* as before */
159
160    /* specify that we'll be rendering to the texture */
161    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_USAGE_ANGLE, GL_FRAMEBUFFER_ATTACHMENT_ANGLE);
162
163    glTexStorage2DEXT(GL_TEXTURE_2D, levels, ...); // Allocation
164    for(int level = 0; level < levels; ++level)
165        glTexSubImage2D(GL_TEXTURE_2D, level, ...); // Initialisation
166
167Issues
168
169    1. Should there be a dynamic usage value?
170
171       DISCUSSION: We could accept a dynamic flag to indicate that a texture will
172       be updated frequently. We could map this to D3D9 dynamic textures. This would
173       allow us to avoid creating temporary surfaces when updating the texture.
174       However renderable textures cannot be dynamic in D3D9, which eliminates the
175       primary use case for this.  Furthermore, the memory usage of dynamic textures
176       typically increases threefold when you lock it.
177
178    2. Should the texture usage be an enum or a bitfield?
179
180       UNRESOLVED.  Using a bitfield would allow combination of values to be specified.
181       On the other hand, if combinations are really required, additional <pnames>
182       could be added as necessary.  Querying a bitfield via the GetTexParameter command
183       feels a bit odd.
184
185    3. What should happen if TEXTURE_USAGE_ANGLE is set/changed after the texture
186       contents have been specified?
187
188       RESOLVED: It will have no effect. However, if the texture is redefined (for
189       example by TexImage2D) the new allocation will use the updated usage.
190       GetTexParameter is used to query the value of the TEXTURE_USAGE_ANGLE
191       state that was last set by TexParameter for the currently bound texture, or
192       the default value if it has never been set. There is no way to determine the
193       usage that was in effect at the time the texture was defined.
194
195Revision History
196
197    Rev.    Date      Author     Changes
198    ----  ----------- ---------  ----------------------------------------
199      1   10 Nov 2011 dgkoch     Initial revision
200      2   10 Nov 2011 dgkoch     Add overview
201
202
203