1Name 2 3 ARB_robust_buffer_access_behavior 4 5Name Strings 6 7 GL_ARB_robust_buffer_access_behavior 8 9Contact 10 11 Piers Daniell, NVIDIA (pdaniell 'at' nvidia.com) 12 13Contributors 14 15 Jan-Harald Fredriksen, AMD 16 Jeff Bolz, NVIDIA 17 Kenneth Russell, Google 18 Pat Brown, NVIDIA 19 20Notice 21 22 Copyright (c) 2012-2013 The Khronos Group Inc. Copyright terms at 23 http://www.khronos.org/registry/speccopyright.html 24 25Specification Update Policy 26 27 Khronos-approved extension specifications are updated in response to 28 issues and bugs prioritized by the Khronos OpenGL Working Group. For 29 extensions which have been promoted to a core Specification, fixes will 30 first appear in the latest version of that core Specification, and will 31 eventually be backported to the extension document. This policy is 32 described in more detail at 33 https://www.khronos.org/registry/OpenGL/docs/update_policy.php 34 35Status 36 37 Complete. 38 Approved by the ARB on 2012/06/12. 39 40Version 41 42 Last Modified Date: October 2, 2013 43 Version: 10 44 45Number 46 47 ARB Extension #135 48 49Dependencies 50 51 The ARB_robustness extension is required. 52 53 This extension is written against The OpenGL 4.2 (Compatibility Profile) 54 specification. 55 56Overview 57 58 This extension specifies the behavior of out-of-bounds buffer and array 59 accesses. This is an improvement over the existing ARB_robustness 60 extension which stated that the application should not crash, but 61 the behavior is otherwise undefined. This extension specifies the access 62 protection provided by the GL to ensure that out-of-bounds accesses 63 cannot read from or write to data not owned by the application. All 64 accesses are contained within the buffer object and program area they 65 reference. These additional robustness guarantees apply to contexts 66 created with the CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB feature enabled. 67 68IP Status 69 70 No known IP claims. 71 72New Procedures and Functions 73 74 None 75 76New Tokens 77 78 None 79 80Additions to Chapter 2 of the OpenGL 4.2 (Compatibility Profile) 81Specification (OpenGL Operation) 82 83 Add to Section 2.8 "Vertex Arrays" before 2.8.1 (Packed Vertex Data 84 Formats): 85 86 "Robust buffer access can be enabled by creating a context with robust 87 access enabled through the window system binding APIs. When enabled, 88 indices within the elements array that reference vertex data that 89 lies outside the enabled attributes vertex buffer objects, result in 90 reading zero. It is not possible to read vertex data from outside the 91 enabled vertex buffer objects or from another GL context, and these 92 accesses do not result in abnormal program termination." 93 94 Add to Section 2.9.4 (Effects of Accessing Outside Buffer Bounds) on 95 page 65 the following: 96 97 "Robust buffer access can be enabled by creating a context with robust 98 access enabled through the window system binding APIs. When enabled, any 99 command unable to set a GL error as described above, for example buffer 100 object accesses from the active program, will not read or modify memory 101 outside of the buffer object and will not result in GL interruption or 102 termination. Out-of-bounds reads may return values from within the buffer 103 object or zero. Out-of-bounds writes may modify values within the buffer 104 object or be discarded. Accesses made through resources attached to 105 binding points are only protected within the buffer object from which the 106 binding point is declared. For example, for an out-of-bounds access to 107 a member variable of a uniform block, the access protection is provided 108 within the uniform buffer object, and not for the bound buffer range for 109 this uniform block." 110 111 Add a new paragraph to the end of the "Texel Fetches" sub-section on page 112 147 that reads: 113 114 "In all the above cases, if the context was created with robust buffer 115 access enabled then instead of undefined behavior the result of the 116 texel fetch is zero. For the case of a texel fetch on an incomplete 117 texture the result is a texture source color of (0, 0, 0, 1)." 118 119 Add the following paragraph to the sub-section titled "Undefined Behavior" 120 near the bottom of page 152: 121 122 "Robust buffer access can be enabled by creating a context with robust 123 access enabled through the window system binding APIs. When enabled, 124 out-of-bounds accesses will be bounded within the working memory of the 125 active program and cannot access memory owned by other GL contexts, 126 and will not result in abnormal program termination. Out-of-bounds 127 access to local and global variables cannot read values from other 128 program invocations. An out-of-bounds read may return another value 129 from the active program's working memory or zero. An out-of-bounds 130 write may overwrite a value from the active program's working memory 131 or be discarded. 132 133 Out-of-bounds accesses to resources backed by buffer objects cannot 134 read or modify data outside of the buffer object. For resources bound 135 to buffer ranges, access is restricted within the buffer object from 136 which the buffer range was created, and not within the buffer range 137 itself. Out-of-bounds reads may return values from within the buffer 138 object or zero. Out-of-bounds writes may modify values within the buffer 139 object or be discarded. 140 141 Out-of-bounds accesses to arrays of resources, such as an array of 142 textures, can only access the data of bound resources. Reads from 143 unbound resources return zero and writes are discarded. It is not 144 possible to access data owned by other GL contexts. 145 146 Applications that require defined behavior for out-of-bounds accesses 147 should range check all computed indices before dereferencing the array, 148 vector or matrix." 149 150Additions to The OpenGL Shading Language Specification, Version 4.20.6 151 152 Add a new Section 5.11 (Out-of-Bounds Access and Robust Buffer Access 153 Behavior) 154 155 "In the sub-sections described above for array, vector, matrix and 156 structure accesses, any out-of-bounds access produced undefined behavior. 157 However, if robust buffer access is enabled via the OpenGL API, such accesses will 158 be bound within the memory extent of the active program. It will not be 159 possible to access memory from other programs, and accesses will not result in 160 abnormal program termination. Out-of-bounds reads return undefined values, 161 which include values from other variables of the active program or zero. 162 Out-of-bounds writes may be discarded or overwrite other variables of the 163 active program, depending on the value of the computed index and how this 164 relates to the extent of the active program's memory. Applications that 165 require defined behavior for out-of-bounds accesses should range check 166 all computed indices before dereferencing an array." 167 168Errors 169 170 None 171 172New State 173 174 None 175 176New Implementation Dependent State 177 178 None 179 180Issues 181 182 1) Why are out-of-bounds reads of buffer object backed resourced defined 183 to "return zero or a value from the current buffer object" rather than 184 just "return zero"? 185 186 RESOLVED: This is necessary to allow the implementation to either 187 range check, apply a mask/modulus or apply a clamp to the index. 188 189 2) Why do out-of-bounds writes to buffer object backed resources have a 190 stronger guarantee than reads? The spec says that writes outside of 191 the bounded range are discarded but reads are only protected within 192 the buffer object. 193 194 RESOLVED: This stronger guarentee for writes can be made because 195 GPUs made since around 2008 (DX10) already implement this behavior. 196 197Revision History 198 199 Rev. Date Author Changes 200 ---- ------------ --------- ------------------------------------------- 201 10 02 Oct 2013 Jon Leech Drop bogus clause about reading zero for 202 ``disabled attributes'' in section 2.8 203 (Bug 10695). 204 205 9 15 May 2012 pdaniell Specify that texel fetches are defined to 206 return zero for the error cases only when 207 robust buffer access is enabled. 208 209 8 20 Apr 2012 pdaniell Mark issues 1 and 2 resolved. 210 211 7 15 Mar 2012 pdaniell Edits based on reviews from Kenneth Russel 212 and Jan-Harald Fredriksen. 213 214 6 30 Jan 2012 pdaniell Edits based on internal review. 215 216 5 24 Jan 2012 pdaniell Add spec language to define out of bounds 217 access behavior of vertex array index, 218 buffer objects and shader arrays, vectors 219 and matrices. 220 221 4 24 Jan 2012 pdaniell ARBify. Still need to convert to real spec. 222 223 3 28 Nov 2011 pdaniell Simplify the spec to better represent what 224 today's desktop GPUs already support. 225 226 2 16 Nov 2011 pdaniell Add some more detail to the overview 227 228 1 27 Oct 2011 kbr Initial version 229