• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Name
2
3    ARB_texture_barrier
4
5Name Strings
6
7    GL_ARB_texture_barrier
8
9Contact
10
11    Jeff Bolz, NVIDIA Corporation (jbolz 'at' nvidia.com)
12
13Notice
14
15    Copyright (c) 2014-2015 The Khronos Group Inc. Copyright terms at
16        http://www.khronos.org/registry/speccopyright.html
17
18Specification Update Policy
19
20    Khronos-approved extension specifications are updated in response to
21    issues and bugs prioritized by the Khronos OpenGL Working Group. For
22    extensions which have been promoted to a core Specification, fixes will
23    first appear in the latest version of that core Specification, and will
24    eventually be backported to the extension document. This policy is
25    described in more detail at
26        https://www.khronos.org/registry/OpenGL/docs/update_policy.php
27
28Status
29
30    Complete.
31
32Version
33
34    Last Modified Date:         May 9, 2015
35    Revision:                   5
36
37Number
38
39    ARB Extension #167
40
41Dependencies
42
43    This extension is written against The OpenGL 4.4 (Compatibility Profile)
44    specification.
45
46Overview
47
48    This extension relaxes the restrictions on rendering to a currently
49    bound texture and provides a mechanism to avoid read-after-write
50    hazards.
51
52New Procedures and Functions
53
54    void TextureBarrier(void);
55
56New Tokens
57
58    None.
59
60Additions to Chapter 9 of the OpenGL 4.4 Specification (Per-Fragment
61Operations and the Frame Buffer)
62
63    Modify Section 9.3.1 Rendering Feedback Loops, p. 289
64
65    (Replace the complicated set of conditions with the following)
66
67    "Specifically, the values of rendered fragments are undefined if any
68    shader stage fetches texels and the same texels are written via fragment
69    shader outputs, even if the reads and writes are not in the same Draw
70    call, unless any of the following exceptions apply:
71
72    - The reads and writes are from/to disjoint sets of texels (after
73      accounting for texture filtering rules).
74
75    - There is only a single read and write of each texel, and the read is in
76      the fragment shader invocation that writes the same texel (e.g. using
77      "texelFetch2D(sampler, ivec2(gl_FragCoord.xy), 0);").
78
79    - If a texel has been written, then in order to safely read the result
80      a texel fetch must be in a subsequent Draw separated by the command
81
82        void TextureBarrier(void);
83
84      TextureBarrier() will guarantee that writes have completed and caches
85      have been invalidated before subsequent Draws are executed."
86
87Additions to the AGL/GLX/WGL Specifications
88
89    None
90
91Errors
92
93    None.
94
95New State
96
97    None.
98
99New Implementation Dependent State
100
101    None.
102
103GLX Protocol
104
105    The following rendering command is sent to the server as
106    a glXRender request:
107
108    TextureBarrier
109
110        2      4               rendering command length
111        2      4348            rendering command opcode
112
113Issues
114
115    (1) What algorithms can take advantage of TextureBarrier?
116
117      This can be used to accomplish a limited form of programmable blending
118      for applications where a single Draw call does not self-intersect, by
119      binding the same texture as both render target and texture and applying
120      blending operations in the fragment shader. Additionally, bounding-box
121      optimizations can be used to minimize the number of TextureBarrier
122      calls between Draws. For example:
123
124        dirtybbox.empty();
125        foreach (object in scene) {
126          if (dirtybbox.intersects(object.bbox())) {
127            TextureBarrier();
128            dirtybbox.empty();
129          }
130          object.draw();
131          dirtybbox = bound(dirtybbox, object.bbox());
132        }
133
134      Another application is to render-to-texture algorithms that ping-pong
135      between two textures, using the result of one rendering pass as the input
136      to the next. Existing mechanisms require expensive FBO Binds, DrawBuffer
137      changes, or FBO attachment changes to safely swap the render target and
138      texture. With texture barriers, layered geometry shader rendering, and
139      texture arrays, an application can very cheaply ping-pong between two
140      layers of a single texture. i.e.
141
142        X = 0;
143        // Bind the array texture to a texture unit
144        // Attach the array texture to an FBO using FramebufferTexture3D
145        while (!done) {
146          // Stuff X in a constant, vertex attrib, etc.
147          Draw -
148            Texturing from layer X;
149            Writing gl_Layer = 1 - X in the geometry shader;
150
151          TextureBarrier();
152          X = 1 - X;
153        }
154
155      However, be warned that this requires geometry shaders and hence adds
156      the overhead that all geometry must pass through an additional program
157      stage, so an application using large amounts of geometry could become
158      geometry-limited or more shader-limited.
159
160Revision History
161
162    Rev.    Date    Author    Changes
163    ----  --------  --------  -----------------------------------------
164     1              jbolz     Initial revision.
165     2              mjk       Assign number.
166     3              srahman   Add glx protocol specification.
167     4    04/22/14  pdaniell  Modify for inclusion into OpenGL 4.5
168     5    05/09/15  Jon Leech Add copyright statement.
169