15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci ARB_texture_barrier 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_ARB_texture_barrier 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContact 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Jeff Bolz, NVIDIA Corporation (jbolz 'at' nvidia.com) 125bd8deadSopenharmony_ci 135bd8deadSopenharmony_ciNotice 145bd8deadSopenharmony_ci 155bd8deadSopenharmony_ci Copyright (c) 2014-2015 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. 315bd8deadSopenharmony_ci 325bd8deadSopenharmony_ciVersion 335bd8deadSopenharmony_ci 345bd8deadSopenharmony_ci Last Modified Date: May 9, 2015 355bd8deadSopenharmony_ci Revision: 5 365bd8deadSopenharmony_ci 375bd8deadSopenharmony_ciNumber 385bd8deadSopenharmony_ci 395bd8deadSopenharmony_ci ARB Extension #167 405bd8deadSopenharmony_ci 415bd8deadSopenharmony_ciDependencies 425bd8deadSopenharmony_ci 435bd8deadSopenharmony_ci This extension is written against The OpenGL 4.4 (Compatibility Profile) 445bd8deadSopenharmony_ci specification. 455bd8deadSopenharmony_ci 465bd8deadSopenharmony_ciOverview 475bd8deadSopenharmony_ci 485bd8deadSopenharmony_ci This extension relaxes the restrictions on rendering to a currently 495bd8deadSopenharmony_ci bound texture and provides a mechanism to avoid read-after-write 505bd8deadSopenharmony_ci hazards. 515bd8deadSopenharmony_ci 525bd8deadSopenharmony_ciNew Procedures and Functions 535bd8deadSopenharmony_ci 545bd8deadSopenharmony_ci void TextureBarrier(void); 555bd8deadSopenharmony_ci 565bd8deadSopenharmony_ciNew Tokens 575bd8deadSopenharmony_ci 585bd8deadSopenharmony_ci None. 595bd8deadSopenharmony_ci 605bd8deadSopenharmony_ciAdditions to Chapter 9 of the OpenGL 4.4 Specification (Per-Fragment 615bd8deadSopenharmony_ciOperations and the Frame Buffer) 625bd8deadSopenharmony_ci 635bd8deadSopenharmony_ci Modify Section 9.3.1 Rendering Feedback Loops, p. 289 645bd8deadSopenharmony_ci 655bd8deadSopenharmony_ci (Replace the complicated set of conditions with the following) 665bd8deadSopenharmony_ci 675bd8deadSopenharmony_ci "Specifically, the values of rendered fragments are undefined if any 685bd8deadSopenharmony_ci shader stage fetches texels and the same texels are written via fragment 695bd8deadSopenharmony_ci shader outputs, even if the reads and writes are not in the same Draw 705bd8deadSopenharmony_ci call, unless any of the following exceptions apply: 715bd8deadSopenharmony_ci 725bd8deadSopenharmony_ci - The reads and writes are from/to disjoint sets of texels (after 735bd8deadSopenharmony_ci accounting for texture filtering rules). 745bd8deadSopenharmony_ci 755bd8deadSopenharmony_ci - There is only a single read and write of each texel, and the read is in 765bd8deadSopenharmony_ci the fragment shader invocation that writes the same texel (e.g. using 775bd8deadSopenharmony_ci "texelFetch2D(sampler, ivec2(gl_FragCoord.xy), 0);"). 785bd8deadSopenharmony_ci 795bd8deadSopenharmony_ci - If a texel has been written, then in order to safely read the result 805bd8deadSopenharmony_ci a texel fetch must be in a subsequent Draw separated by the command 815bd8deadSopenharmony_ci 825bd8deadSopenharmony_ci void TextureBarrier(void); 835bd8deadSopenharmony_ci 845bd8deadSopenharmony_ci TextureBarrier() will guarantee that writes have completed and caches 855bd8deadSopenharmony_ci have been invalidated before subsequent Draws are executed." 865bd8deadSopenharmony_ci 875bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL Specifications 885bd8deadSopenharmony_ci 895bd8deadSopenharmony_ci None 905bd8deadSopenharmony_ci 915bd8deadSopenharmony_ciErrors 925bd8deadSopenharmony_ci 935bd8deadSopenharmony_ci None. 945bd8deadSopenharmony_ci 955bd8deadSopenharmony_ciNew State 965bd8deadSopenharmony_ci 975bd8deadSopenharmony_ci None. 985bd8deadSopenharmony_ci 995bd8deadSopenharmony_ciNew Implementation Dependent State 1005bd8deadSopenharmony_ci 1015bd8deadSopenharmony_ci None. 1025bd8deadSopenharmony_ci 1035bd8deadSopenharmony_ciGLX Protocol 1045bd8deadSopenharmony_ci 1055bd8deadSopenharmony_ci The following rendering command is sent to the server as 1065bd8deadSopenharmony_ci a glXRender request: 1075bd8deadSopenharmony_ci 1085bd8deadSopenharmony_ci TextureBarrier 1095bd8deadSopenharmony_ci 1105bd8deadSopenharmony_ci 2 4 rendering command length 1115bd8deadSopenharmony_ci 2 4348 rendering command opcode 1125bd8deadSopenharmony_ci 1135bd8deadSopenharmony_ciIssues 1145bd8deadSopenharmony_ci 1155bd8deadSopenharmony_ci (1) What algorithms can take advantage of TextureBarrier? 1165bd8deadSopenharmony_ci 1175bd8deadSopenharmony_ci This can be used to accomplish a limited form of programmable blending 1185bd8deadSopenharmony_ci for applications where a single Draw call does not self-intersect, by 1195bd8deadSopenharmony_ci binding the same texture as both render target and texture and applying 1205bd8deadSopenharmony_ci blending operations in the fragment shader. Additionally, bounding-box 1215bd8deadSopenharmony_ci optimizations can be used to minimize the number of TextureBarrier 1225bd8deadSopenharmony_ci calls between Draws. For example: 1235bd8deadSopenharmony_ci 1245bd8deadSopenharmony_ci dirtybbox.empty(); 1255bd8deadSopenharmony_ci foreach (object in scene) { 1265bd8deadSopenharmony_ci if (dirtybbox.intersects(object.bbox())) { 1275bd8deadSopenharmony_ci TextureBarrier(); 1285bd8deadSopenharmony_ci dirtybbox.empty(); 1295bd8deadSopenharmony_ci } 1305bd8deadSopenharmony_ci object.draw(); 1315bd8deadSopenharmony_ci dirtybbox = bound(dirtybbox, object.bbox()); 1325bd8deadSopenharmony_ci } 1335bd8deadSopenharmony_ci 1345bd8deadSopenharmony_ci Another application is to render-to-texture algorithms that ping-pong 1355bd8deadSopenharmony_ci between two textures, using the result of one rendering pass as the input 1365bd8deadSopenharmony_ci to the next. Existing mechanisms require expensive FBO Binds, DrawBuffer 1375bd8deadSopenharmony_ci changes, or FBO attachment changes to safely swap the render target and 1385bd8deadSopenharmony_ci texture. With texture barriers, layered geometry shader rendering, and 1395bd8deadSopenharmony_ci texture arrays, an application can very cheaply ping-pong between two 1405bd8deadSopenharmony_ci layers of a single texture. i.e. 1415bd8deadSopenharmony_ci 1425bd8deadSopenharmony_ci X = 0; 1435bd8deadSopenharmony_ci // Bind the array texture to a texture unit 1445bd8deadSopenharmony_ci // Attach the array texture to an FBO using FramebufferTexture3D 1455bd8deadSopenharmony_ci while (!done) { 1465bd8deadSopenharmony_ci // Stuff X in a constant, vertex attrib, etc. 1475bd8deadSopenharmony_ci Draw - 1485bd8deadSopenharmony_ci Texturing from layer X; 1495bd8deadSopenharmony_ci Writing gl_Layer = 1 - X in the geometry shader; 1505bd8deadSopenharmony_ci 1515bd8deadSopenharmony_ci TextureBarrier(); 1525bd8deadSopenharmony_ci X = 1 - X; 1535bd8deadSopenharmony_ci } 1545bd8deadSopenharmony_ci 1555bd8deadSopenharmony_ci However, be warned that this requires geometry shaders and hence adds 1565bd8deadSopenharmony_ci the overhead that all geometry must pass through an additional program 1575bd8deadSopenharmony_ci stage, so an application using large amounts of geometry could become 1585bd8deadSopenharmony_ci geometry-limited or more shader-limited. 1595bd8deadSopenharmony_ci 1605bd8deadSopenharmony_ciRevision History 1615bd8deadSopenharmony_ci 1625bd8deadSopenharmony_ci Rev. Date Author Changes 1635bd8deadSopenharmony_ci ---- -------- -------- ----------------------------------------- 1645bd8deadSopenharmony_ci 1 jbolz Initial revision. 1655bd8deadSopenharmony_ci 2 mjk Assign number. 1665bd8deadSopenharmony_ci 3 srahman Add glx protocol specification. 1675bd8deadSopenharmony_ci 4 04/22/14 pdaniell Modify for inclusion into OpenGL 4.5 1685bd8deadSopenharmony_ci 5 05/09/15 Jon Leech Add copyright statement. 169