• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Name
2
3    ARB_clear_texture
4
5Name Strings
6
7    GL_ARB_clear_texture
8
9Contact
10
11    Daniel Koch, NVIDIA Corporation (dkoch 'at' nvidia.com)
12
13Contributors
14
15    Graham Sellers, AMD
16    Jonathan Putsman, Imagination
17    Ian Rominick, Intel
18    Jeff Bolz, NVIDIA
19    Pat Brown, NVIDIA
20    Piers Daniel, NVIDIA
21    James Helferty, NVIDIA
22    Members of the ARB working group
23
24Notice
25
26    Copyright (c) 2013 The Khronos Group Inc. Copyright terms at
27        http://www.khronos.org/registry/speccopyright.html
28
29Specification Update Policy
30
31    Khronos-approved extension specifications are updated in response to
32    issues and bugs prioritized by the Khronos OpenGL Working Group. For
33    extensions which have been promoted to a core Specification, fixes will
34    first appear in the latest version of that core Specification, and will
35    eventually be backported to the extension document. This policy is
36    described in more detail at
37        https://www.khronos.org/registry/OpenGL/docs/update_policy.php
38
39Status
40
41    Complete. Approved by the ARB on June 3, 2013.
42    Ratified by the Khronos Board of Promoters on July 19, 2013.
43
44Version
45
46    Last Modified Date: August 12, 2013
47    Revision: 16
48
49Number
50
51    ARB Extension #145
52
53Dependencies
54
55    OpenGL 1.3 is required.
56
57    This extension is written against the OpenGL 4.3 (Core Profile)
58    Specification (October 18, 2012).
59
60    This extension interacts with EXT_texture_integer.
61
62    This extension interacts with ARB_texture_buffer_object.
63
64    This extension interacts with ARB_texture_multisample.
65
66    This extension interacts with ARB_depth_texture.
67
68    This extension interacts with EXT_packed_depth_stencil and
69    ARB_framebuffer_object.
70
71    This extension interacts with ARB_texture_stencil8.
72
73    This extension interacts with ARB_shader_image_load_store.
74
75    This extension interacts with ARB_internalformat_query2.
76
77Overview
78
79    Texture objects are fundamental to the operation of OpenGL. They are
80    used as a source for texture sampling and destination for rendering
81    as well as being accessed in shaders for image load/store operations
82    It is also possible to invalidate the contents of a texture. It is
83    currently only possible to set texture image data to known values by
84    uploading some or all of a image array from application memory or by
85    attaching it to a framebuffer object and using the Clear or ClearBuffer
86    commands.
87
88    Both uploading initial texture data and clearing by attaching to a
89    framebuffer have potential disadvantages when one simply wants to
90    initialize texture data to a known value. Uploading initial data
91    requires the application to allocate a (potentially large) chunk
92    of memory and transferring that to the GL.  This can be a costly
93    operation both in terms of memory bandwidth and power usage.
94    Alternatively, attaching a texture level to a framebuffer to clear it
95    may not be possible if the texture format isn't supported for
96    rendering, or even if it is, attaching the image to a framebuffer object
97    may cause the texture to be allocated in certain types of memory, which
98    it may otherwise not need to be placed in.
99
100    This extension solves these problems by providing a mechanism whereby
101    the contents of a texture image array can be set to known values by
102    using the ClearTexImage or ClearTexSubImage commands.  These commands
103    can also be useful for initializing an image that will be used for
104    atomic shader operations.
105
106IP Status
107
108    No known IP claims.
109
110New Procedures and Functions
111
112    void ClearTexImage(uint texture, int level,
113                       enum format, enum type,
114                       const void * data);
115
116    void ClearTexSubImage(uint texture, int level,
117                          int xoffset, int yoffset, int zoffset,
118                          sizei width, sizei height, sizei depth,
119                          enum format, enum type,
120                          const void * data);
121
122New Types
123
124    None
125
126New Tokens
127
128    Accepted by the <pname> parameter for GetInternalformativ and
129    GetInternalformati64v:
130
131        CLEAR_TEXTURE           0x9365
132
133Additions to Chapter 7 of the OpenGL 4.3 (Core Profile) Specification
134
135    In section 7.12.2 (Shader Memory Access Synchronization) edit the
136    description of the TEXTURE_UPDATE_BARRIER_BIT to add ClearTexImage
137    and ClearTexSubImage to the list of commands that can write to
138    texture images.
139
140Additions to Chapter 8 of the OpenGL 4.3 (Core Profile) Specification
141(Textures and Samplers)
142
143    Add a new Section 8.x (Clearing Texture Image Data) after
144    Section 8.20 (Invalidating Texture Image Data):
145
146    "All or part of a texture image may be filled with a constant value
147    by calling the command
148
149      void ClearTexSubImage(uint texture, int level,
150                            int xoffset, int yoffset, int zoffset,
151                            sizei width, sizei height, sizei depth,
152                            enum format, enum type,
153                            const void * data);
154
155    with <texture> and <level> indicating which texture array image is being
156    cleared.  It is an error if <texture> is zero or not the name of a texture
157    object, if <texture> is a buffer texture, or if the texture image has
158    a compressed internal format.
159
160    Arguments <xoffset>, <yoffset>, and <zoffset> specify the lower left
161    texel coordinates of a <width>-wide by <height>-high by <depth>-deep
162    rectangular subregion of the texel array and are interpreted as they
163    are in TexSubImage3D as described in section 8.6 (Alternate Texture
164    Image Specification Commands).
165
166    For 1D array textures, <yoffset> is interpreted as the first layer to be
167    cleared and <height> is the number of layers to clear. For 2D array
168    textures, <zoffset> is interpreted as the first layer to be cleared
169    and <depth> is the number of layers to clear. Cube map textures are
170    treated as an array of six slices in the z-dimension, where the value
171    of <zoffset> is interpreted as specifying the cube map face for the
172    corresponding <layer> in table 9.3 (Layer numbers for cube map texture
173    faces) and <depth> is the number of faces to clear. For cube map array
174    textures, <zoffset> is the first layer-face to clear, and <depth> is the
175    number of layer-faces to clear. Each layer-face is translated into an
176    array layer and a cube map face as described for layer-face numbers in
177    section 8.5.3.
178
179    Negative values of <xoffset>, <yoffset>, and <zoffset> correspond
180    to the coordinates of border texels, addressed as in Figure 8.3.
181    Taking <w_s>, <h_s>, <d_s>, <w_b>, <h_b>, and <d_b> to be the specified
182    width, height, depth, and the border width, border height, and border
183    depth of the texel array and taking <x>, <y>, <z>, <w>, <h>, and <d> to
184    be the <xoffset>, <yoffset>, <zoffset>, <width>, <height>, and <depth>
185    argument values, any of the following relationships generate an error:
186              <x> < - <w_b>
187        <x> + <w> > <w_s> - <w_b>
188              <y> < - <h_b>
189        <y> + <h> > <h_s> - <h_b>
190              <z> < - <d_b>
191        <z> + <d> > <d_s> - <d_b>
192    For texture types that do not have certain dimensions, this
193    command treats those dimensions as having a size of 1.  For example,
194    to clear a portion of a two-dimensional texture, the application would
195    use <zoffset> equal to zero and <depth> equal to one.
196
197    <format> and <type> specify the format and type of the source
198    data and are interpreted as they are for TexImage3D, as described in
199    section 8.4.4 (Transfer of Pixel Rectangles). Textures with a base
200    internal format of DEPTH_COMPONENT, STENCIL_INDEX, or DEPTH_STENCIL
201    require depth component, stencil, or depth/stencil component data
202    respectively. Textures with other base internal formats require RGBA
203    formats. Textures with integer internal formats (see table 8.12) require
204    integer data.
205
206    <data> is a pointer to an array of between one and four components of
207    texel data that will be used as the source for the constant fill value.
208    The elements of <data> are converted by the GL into the
209    <internalformat> of the texture image (that was specified when the level
210    was defined by any of the TexImage, TexStorage or CopyTexImage
211    commands) in the manner described in section 8.4.4 (Transfer of Pixel
212    Rectangles), and then used to fill the specified range of the
213    destination texture level.  If <data> is NULL, then the pointer is
214    ignored and the sub-range of the texture image is filled with zeros.
215    If <texture> is a multisample texture, all the samples in a texel
216    are cleared to the same value, that which was specified by <data>.
217
218    Errors
219
220    An INVALID_OPERATION error is generated if <texture> is zero or not the
221    name of a texture object.
222    An INVALID_OPERATION error is generated if <texture> is a buffer texture.
223    An INVALID_OPERATION error is generated if <texture> has a compressed
224    internal format.
225    An INVALID_OPERATION error is generated if the base internal format is
226    DEPTH_COMPONENT and <format> is not DEPTH_COMPONENT.
227    An INVALID_OPERATION error is generated if the base internal format is
228    DEPTH_STENCIL and <format> is not DEPTH_STENCIL.
229    An INVALID_OPERATION error is generated if the base internal format is
230    STENCIL_INDEX and <format> is not STENCIL_INDEX.
231    An INVALID_OPERATION error is generated if the base internal format is
232    RGBA and the <format> is DEPTH_COMPONENT, STENCIL_INDEX, or DEPTH_STENCIL.
233    An INVALID_OPERATION error is generated if the internal format is integer
234    and <format> does not specify integer data.
235    An INVALID_OPERATION error is generated if the internal format is
236    not integer and <format> does specify integer data.
237    An INVALID_OPERATION error is generated if the <xoffset>, <yoffset>,
238    <zoffset>, <width>, <height>, and <depth> parameters (or combinations
239    thereof) fall outside the defined texture image array (including border,
240    if any).
241
242    The command
243
244      void ClearTexImage(uint texture, int level,
245                         enum format, enum type,
246                         const void * data);
247
248    is equivalent to calling ClearTexSubImage with <xoffset>, <yoffset>,
249    and <zoffset> equal to -<b> and <width>, <height>, and <depth> equal
250    to the dimensions of the texture image plus 2x<b> (or zero and one
251    for dimensions the texture doesn't have).
252
253    Errors
254
255    An INVALID_OPERATION error is generated if the image array identified by
256    <level> has not previously been defined by a TexImage* or TexStorage*
257    command."
258
259Additions to Chapter 22 of the OpenGL 4.3 (Core Profile) Specification
260
261    In section 22.3 add the following to the list of <pname> values accepted
262    by GetInternalformativ and GetInternalformati64v:
263
264        CLEAR_TEXTURE: The support for using the resource with the
265        ClearTex*Image commands is returned in <params>.  Possible values
266        returned are FULL_SUPPORT, CAVEAT_SUPPORT, or NONE.  If the resource
267        or operation is not supported, NONE is returned.
268
269Additions to the AGL/EGL/GLX/WGL Specifications
270
271    None
272
273Dependencies on EXT_texture_integer
274
275    If EXT_texture_integer or equivalent functionality is not supported,
276    ignore all references to integer textures.
277
278Dependencies on ARB_texture_buffer_object
279
280    If ARB_texture_buffer_object of equivalent functionality is not supported,
281    ignore all references to buffer textures.
282
283Dependencies on ARB_texture_multisample
284
285    If ARB_texture_multisample or equivalent functionality is not supported,
286    ignore all references to multisample textures.
287
288Dependencies on ARB_depth_texture
289
290    If ARB_depth_texture or equivalent functionality is not supported,
291    ignore all references to depth textures and depth component formats.
292
293Dependencies on EXT_packed_depth_stencil and ARB_framebuffer_object
294
295    If EXT_packed_depth_stencil, ARB_framebuffer_object, or equivalent
296    functionality is not supported, ignore all refereces to depth/stencil
297    textures and depth/stencil components.
298
299Dependencies on ARB_texture_stencil8
300
301    If ARB_texture_stencil8 or equivalent functionality is not supported,
302    ignore all references to stencil textures and stencil index formats.
303
304Dependencies on ARB_shader_image_load_store
305
306    If ARB_shader_image_load_store or equivalent functionality is not
307    supported, ignore the references to TEXTURE_UPDATE_BARRIER_BIT and
308    edits to section 7.12.2.
309
310Dependencies on ARB_internalformat_query2
311
312    If ARB_internalformat_query2 or equivalent functionality is not
313    supported, ignore the references GetInternalformat* and the CLEAR_TEXTURE
314    enum is not added.
315
316Errors
317
318    An INVALID_OPERATION error is generated by ClearTexImage or
319    ClearTexSubImage if <texture> is zero or not the name of a texture object.
320
321    An INVALID_OPERATION error is generated by ClearTexImage or
322    ClearTexSubImage if <texture> is a buffer texture.
323
324    An INVALID_OPERATION error is generated by ClearTexImage or
325    ClearTexSubImage if <texture> has a compressed internal format.
326
327    An INVALID_OPERATION error is generated by ClearTexImage or
328    ClearTexSubImage if the base internal format is DEPTH_COMPONENT and
329    <format> is not DEPTH_COMPONENT.
330
331    An INVALID_OPERATION error is generated by ClearTexImage or
332    ClearTexSubImage if the base internal format is STENCIL_INDEX and
333    <format> is not STENCIL_INDEX.
334
335    An INVALID_OPERATION error is generated by ClearTexImage or
336    ClearTexSubImage if the base internal format is DEPTH_STENCIL and
337    <format> is not DEPTH_STENCIL.
338
339    An INVALID_OPERATION error is generated by ClearTexImage or
340    ClearTexSubImage if the base internal format is RGBA and the <format>
341    is DEPTH_COMPONENT, STENCIL_INDEX, or DEPTH_STENCIL.
342
343    An INVALID_OPERATION error is generated by ClearTexImage or
344    ClearTexSubImage if the internal format is integer and <format> does not
345    specify integer data.
346
347    An INVALID_OPERATION error is generated by ClearTexImage or
348    ClearTexSubImage if the internal format is not integer and <format>
349    does specify integer data.
350
351    An INVALID_OPERATION error is generated by ClearTexSubImage if the
352    <xoffset>, <yoffset>, <zoffset>, <width>, <height>, and <depth>
353    parameters (or combinations thereof) fall outside the defined texture
354    image array (including border, if any).
355
356    An INVALID_OPERATION error is generated by ClearTexImage if the
357    image array identified by <level> has not previously been defined.
358
359New State
360
361    None.
362
363New Implementation Dependent State
364
365    None.
366
367Sample Code
368
369    TBD
370
371Conformance Tests
372
373    Needed.
374
375Issues
376
377    1. Should these commands use <target> or <name> to specify the object?
378
379    DISCUSSION: TexImage/TexSubImage pass in a target and operate on the
380    object that is currently bound to that target. However the
381    InvalidateTexImage/InvalidateTexSubImage commands operate on a named
382    object. A target would be necessary if ClearTex*Image supported
383    defining new textures. It does not support this. It could also be
384    useful for clearing only one face of a cube map - if this is useful
385    this can be accomplished by creating a 2D texture which is view of one
386    face of a cube map.
387
388    RESOLVED. We will use named objects and be consistent with
389    the InvalidateTexImage entry points.
390
391    2. Should scissor and viewport settings be respected?
392
393    DISCUSSION: The scissor and viewport settings really have no meaning
394    with respect to a texture that is not attached to a framebuffer object.
395    D3D11's ClearRenderTargetView also does not apply scissor or viewport.
396
397    RESOLVED. Scissor and viewport are not relevant to this command.
398
399    3. Should we support clearing only a portion of a texture?
400
401    RESOLVED. Yes, it seems like it would be useful functionality.
402
403    4. How many command variants do we need? We may want to provide
404    integer, unsigned integer, or floating-point data. Is a void
405    parameter sufficient, or do we need to use different commands
406    similar to ClearBuffer?
407
408    RESOLVED. Similar to the initial texure data specification via
409    TexSubImage, a single command is provided. The format and type
410    parameters specify how the data should be interpreted, and enough
411    data needs to provided to completely define one texel. This operates
412    similarly to the ClearBufferData commands.
413
414    5. Should depth/stencil textures be supported? If so, are the depth
415    and stencil values provided separately?
416
417    RESOLVED. Depth/stencil textures are supported in the same manner
418    they are for TexSubImage.  The format and type describe how the
419    data is interpreted.
420
421    6. Should compressed textures be supported? If so, does a whole
422    block of data need to be specified?
423
424    DISCUSSION. For many compressed formats it may be fairly straight
425    forward for a driver to construct a block based on a single value.
426    It is unclear if this applies to all formats or not. In any case,
427    if compressed textures are supported, the sub region that is cleared
428    is required to be aligned on with block boundaries.
429
430    RESOLUTION: No. Compressed textures are not support. Not all formats
431    support runtime compression so providing uncompressed data would not
432    be viable. Providing a single block of compressed data may be possible
433    but then it would have to be aligned to block boundaries and this becomes
434    more of a sub-image command than a clear operation. This does not seem
435    to have a compelling use-case so it is not being added at this time. It
436    can always be added in a layered extension if desired.
437
438    7. Should we add an entry point for renderbuffers?
439
440    RESOLVED. No. At this point there is really no use case that
441    renderbuffers support that cannot be supported by multisample textures.
442    Thus in order to avoid aggrandizing renderbuffers, this will not be
443    provided.  Additionally, renderbuffers are by definition renderable,
444    and thus they can be cleared by the standard mechanisms without affecting
445    memory allocation patterns.
446
447    8. Should these commands support support loading <data> from the pixel
448    unpack buffer (ie PBO) or only client memory?
449
450    RESOLVED. ClearTex*Image only supports <data> in client memory, like the
451    comparable ClearBuffer*Data commands. There seems to be little value in
452    supporting buffer-backed sources when there is only one texels' worth of
453    data to upload. If the worst case (RGBA32F) it is only 16 bytes of data.
454
455    9. How does clearing multisample textures work?
456
457    RESOLVED: As with regular textures, the dimensions are specified in texels.
458    All the samples in a texel are cleared to the same values, ie the one set
459    of values which are provided in <data>.
460
461    10. Does conditional rendering interact with the ClearTex*Image commands?
462
463    RESOLVED: No. This is treated in a similar manner to the TexSubImage
464    commands rather than the other image clearing commands and is thus not
465    affected by conditional rendering.  This is similar to the clear buffer
466    data commands.
467
468    11. Would there be any benefit to providing some form of colormask style
469    behavior?
470
471    RESOLVED: No. This is intended to be a simple operation like memset.
472    If more complicated behaviour is required, one of the other mechanisms
473    for specifying texture image data should be used.
474
475    12. Can ClearTexImage be used on buffer textures?
476
477    RESOLVED: No. In the same way that TexSubImage cannot be used for
478    buffer textures, neither can ClearTexImage.  The ClearBuffer{Sub}Data
479    commands can be used for this purpose.
480
481    13. What happens if the subregion to be cleared is larger than the defined
482    texture level's size?
483
484    RESOLVED: This is an error similar to TexSubImage3D.
485
486    14. What about texture zero?
487
488    RESOLVED: Which one? There are many zero textures (one of each target type).
489    Since these commands don't distinguish based on target, this is an error.
490    Also we really don't want to aggrandize texture zero.
491
492    15. What happens for undefined levels?
493
494    RESOLVED: This depends on the command.  An undefined level will have
495    width, height, and depth of zero, and thus a ClearTexSubImage command with
496    a non-zero sized clear region will fail the bounds check and result in
497    an INVALID_OPERATION. A zero-sized clear region with no-offset is allowed,
498    but is a no-op. ClearTexImage though, is defined in terms of
499    ClearTexSubImage called with appropriate dimensions and offsets. Since
500    it's unclear how many dimensions an undefined level would have, we've
501    defined this to be an error.
502
503    16. What happens for incomplete textures?
504
505    RESOLVED: Incomplete textures do not affect the behaviour of these commands
506    since they operate on individual levels.  However see Issue 15 for
507    behaviour on undefined levels.
508
509    17. How does ClearTexture interact with the (compatibility) GENERATE_MIPMAP
510    texture state?
511
512    RESOLVED: It doesn't (i.e. it doesn't provoke automatic mipmap generation).
513    In general the policy is that new functionality doesn't need to interact with
514    legacy functionality. This also falls out of the way the spec is written
515    since section 8.14.5 on automatic mipmap generation says it applies to the
516    image specification operations defined in sections 8.5 to 8.7. ClearTexture
517    is defined in section 8.21.
518
519Revision History
520
521    Revision 16, 2013/08/12, Jon Leech
522        - Clarify issue 8 (public bug 934).
523    Revision 15, 2013/06/25, dgkoch
524        - assign value for GL_CLEAR_TEXTURE
525    Revision 14, 2013/06/21, dgkoch
526        - add CLEAR_TEXTURE for GetInternalformat* query.
527    Revision 13, 2013/06/04, dgkoch
528      - add issue 17.
529    Revision 12, 2013/05/30, Jon Leech
530      - Move new error to per-command Errors section.
531    Revision 11, 2013/05/30, dgkoch
532      - Add Issues 15, 16. Add error for ClearTexImage on undefined levels.
533      - fix naming of ARB_texture_stencil8 dependency.
534    Revision 10, 2013/05/30, Jon Leech
535      - Remove (some) redundant error descriptions from inline spec language
536        and simplify description of layer-faces.
537    Revision 9, 2013/05/29, dgkoch
538      - change error back to INVALID_OP
539    Revision 8, 2013/05/29, dgkoch
540      - added general error conditions to command description
541      - change error for non-texture names to be INVALID_VALUE
542      - minor grammatical and formatting fixes.
543    Revision 7, 2013/05/29, dgkoch
544      - add interaction with ARB_shader_image_load_store / MemoryBarrier
545    Revision 6, 2013/05/02, dgkoch
546      - add interaction with stencil textures
547      - fix typos and formatting
548    Revision 5, 2013/04/23, dgkoch
549      - fix more typos, confirm out of bounds error
550    Revision 4, 2013/04/22, dgkoch
551      - resolved issue 13, and update language appropriately
552      - add error for texture zero, remove error for undefined levels
553      - fix typos
554    Revision 3, 2013/04/21, dgkoch
555      - various formatting fixes
556      - add dependencies
557      - flesh out a lot of spec language instead of referring to other sections
558      - add error conditions
559      - allow larger dimensions than the texture image array.
560      - Resolved issues 6,7,10,11
561      - Added issues 12,13.
562    Revision 2, 2013/03/13, dgkoch
563      - Added issues 9,10,11
564      - Resolved issues 1,2,3,4,5,8,9
565      - update contact & contributors
566    Revision 1, 2013/01/15, dgkoch
567      - Initial revision
568