| 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | <proposal href="proposals/WEBGL_debug/"> |
| 3 | <name>WEBGL_debug</name> |
| 4 | |
| 5 | <contact> <a href="https://www.khronos.org/webgl/public-mailing-list/">WebGL |
| 6 | working group</a> (public_webgl 'at' khronos.org) </contact> |
| 7 | |
| 8 | <contributors> |
| 9 | <contributor>Emmanuel Gil Peyrot, Collabora Ltd.</contributor> |
| 10 | <contributor>Members of the WebGL working group</contributor> |
| 11 | </contributors> |
| 12 | |
| 13 | <number>NN</number> |
| 14 | |
| 15 | <depends> |
| 16 | <api version="1.0"/> |
| 17 | </depends> |
| 18 | |
| 19 | <overview id="overview"> |
| 20 | <p> |
| 21 | This extension allows the GL to notify applications when various events |
| 22 | occur that may be useful during application development, debugging and |
| 23 | profiling. |
| 24 | </p> |
| 25 | |
| 26 | <mirrors href="https://www.opengl.org/registry/specs/KHR/debug.txt" |
| 27 | name="KHR_debug"> |
| 28 | <addendum> |
| 29 | References to debug contexts are deleted. |
| 30 | </addendum> |
| 31 | |
| 32 | <addendum> |
| 33 | References to the debug message log and callback are deleted, replaced |
| 34 | with DOM events. |
| 35 | </addendum> |
| 36 | |
| 37 | <addendum> |
| 38 | The <code>ObjectPtrLabel</code> and <code>GetObjectPtrLabel</code> |
| 39 | functions are replaced with <code>ObjectLabel</code> and |
| 40 | <code>GetObjectLabel</code>. |
| 41 | </addendum> |
| 42 | |
| 43 | <addendum> |
| 44 | The <code>count</code> and <code>ids</code> arguments of |
| 45 | <code>DebugMessageControl</code> are replaced with a |
| 46 | <code>sequence<GLuint> ids</code> argument. |
| 47 | </addendum> |
| 48 | |
| 49 | <addendum> |
| 50 | The <code>length</code> and <code>buf</code> arguments of |
| 51 | <code>DebugMessageInsert</code> and <code>PushDebugGroup</code> are |
| 52 | replaced with a <code>DOMString message</code> argument. |
| 53 | </addendum> |
| 54 | |
| 55 | <addendum> |
| 56 | The <code>identifier</code> and <code>name</code> arguments of |
| 57 | <code>ObjectLabel</code> and <code>GetObjectLabel</code> are replaced |
| 58 | with a <code>WebGLObject object</code> argument. |
| 59 | </addendum> |
| 60 | |
| 61 | <addendum> |
| 62 | The <code>length</code> and <code>label</code> arguments of |
| 63 | <code>ObjectLabel</code> are replaced with a <code>DOMString |
| 64 | label</code> argument. |
| 65 | </addendum> |
| 66 | |
| 67 | <addendum> |
| 68 | The <code>bufSize</code>, <code>length</code> and <code>label</code> |
| 69 | arguments of <code>GetObjectLabel</code> are replaced with a |
| 70 | <code>DOMString</code> return type. |
| 71 | </addendum> |
| 72 | |
| 73 | <addendum> |
| 74 | As per the usual WebGL binding rules, functions don’t keep the KHR |
| 75 | suffix they have in the GLES version, but tokens do. |
| 76 | </addendum> |
| 77 | </mirrors> |
| 78 | |
| 79 | <features> |
| 80 | <feature> |
| 81 | The <code>WEBGL_debug</code> extension object is a DOM |
| 82 | <code>EventTarget</code>, obeying the rules of the <a |
| 83 | href="http://www.w3.org/TR/DOM-Level-3-Events/">DOM Level 3 Events</a>, |
| 84 | with a new <code>WebGLDebugMessage</code> event that gets fired |
| 85 | whenever the driver, browser or application emits a debug message. |
| 86 | </feature> |
| 87 | |
| 88 | <feature> |
| 89 | <code>debugMessageInsertKHR</code> is exposed to allow the application |
| 90 | to insert debug messages into the WebGL stream. |
| 91 | </feature> |
| 92 | |
| 93 | <feature> |
| 94 | <code>objectLabelKHR</code> and <code>getObjectLabelKHR</code> are |
| 95 | exposed, to assign a label to a <code>WebGLObject</code> and retrieve |
| 96 | it. |
| 97 | </feature> |
| 98 | |
| 99 | <feature> |
| 100 | <code>pushDebugGroupKHR</code> and <code>popDebugGroupKHR</code> make |
| 101 | it possible to group a list of WebGL calls together. |
| 102 | </feature> |
| 103 | |
| 104 | <feature> |
| 105 | <code>debugMessageControlKHR</code> allows the application to enable |
| 106 | and disable the debug messages which emit a |
| 107 | <code>WebGLDebugMessage</code> event. This state is part of the debug |
| 108 | group they are part of, and gets poped on |
| 109 | <code>popDebugGroupKHR</code>. |
| 110 | </feature> |
| 111 | </features> |
| 112 | </overview> |
| 113 | |
| 114 | <idl xml:space="preserve"><![CDATA[ |
| 115 | [NoInterfaceObject] |
| 116 | interface WEBGL_debug : EventTarget { |
| 117 | const GLenum MAX_DEBUG_MESSAGE_LENGTH_KHR = 0x9143; |
| 118 | const GLenum MAX_DEBUG_GROUP_STACK_DEPTH_KHR = 0x826C; |
| 119 | const GLenum DEBUG_GROUP_STACK_DEPTH_KHR = 0x826D; |
| 120 | const GLenum MAX_LABEL_LENGTH_KHR = 0x82E8; |
| 121 | |
| 122 | const GLenum DEBUG_SOURCE_API_KHR = 0x8246; |
| 123 | const GLenum DEBUG_SOURCE_WINDOW_SYSTEM_KHR = 0x8247; |
| 124 | const GLenum DEBUG_SOURCE_SHADER_COMPILER_KHR = 0x8248; |
| 125 | const GLenum DEBUG_SOURCE_THIRD_PARTY_KHR = 0x8249; |
| 126 | const GLenum DEBUG_SOURCE_APPLICATION_KHR = 0x824A; |
| 127 | const GLenum DEBUG_SOURCE_OTHER_KHR = 0x824B; |
| 128 | |
| 129 | const GLenum DEBUG_TYPE_ERROR_KHR = 0x824C; |
| 130 | const GLenum DEBUG_TYPE_DEPRECATED_BEHAVIOR_KHR = 0x824D; |
| 131 | const GLenum DEBUG_TYPE_UNDEFINED_BEHAVIOR_KHR = 0x824E; |
| 132 | const GLenum DEBUG_TYPE_PORTABILITY_KHR = 0x824F; |
| 133 | const GLenum DEBUG_TYPE_PERFORMANCE_KHR = 0x8250; |
| 134 | const GLenum DEBUG_TYPE_OTHER_KHR = 0x8251; |
| 135 | const GLenum DEBUG_TYPE_MARKER_KHR = 0x8268; |
| 136 | |
| 137 | const GLenum DEBUG_TYPE_PUSH_GROUP_KHR = 0x8269; |
| 138 | const GLenum DEBUG_TYPE_POP_GROUP_KHR = 0x826A; |
| 139 | |
| 140 | const GLenum DEBUG_SEVERITY_HIGH_KHR = 0x9146; |
| 141 | const GLenum DEBUG_SEVERITY_MEDIUM_KHR = 0x9147; |
| 142 | const GLenum DEBUG_SEVERITY_LOW_KHR = 0x9148; |
| 143 | const GLenum DEBUG_SEVERITY_NOTIFICATION_KHR = 0x826B; |
| 144 | |
| 145 | const GLenum STACK_UNDERFLOW_KHR = 0x0504; |
| 146 | const GLenum STACK_OVERFLOW_KHR = 0x0503; |
| 147 | |
| 148 | void debugMessageControlKHR(GLenum source, GLenum type, GLenum severity, sequence<GLuint> ids, boolean enabled); |
| 149 | void debugMessageInsertKHR(GLenum source, GLenum type, GLuint id, GLenum severity, DOMString buf); |
| 150 | |
| 151 | void pushDebugGroupKHR(GLenum source, GLuint id, DOMString message); |
| 152 | void popDebugGroupKHR(); |
| 153 | |
| 154 | void objectLabelKHR(WebGLObject? object, DOMString label); |
| 155 | DOMString getObjectLabelKHR(WebGLObject? object); |
| 156 | }; // interface WEBGL_debug |
| 157 | |
| 158 | [NoInterfaceObject] |
| 159 | interface WebGLDebugMessage : Event { |
| 160 | readonly attribute GLenum source; |
| 161 | readonly attribute GLenum type; |
| 162 | readonly attribute GLuint id; |
| 163 | readonly attribute GLenum severity; |
| 164 | readonly attribute DOMString message; |
| 165 | }; // interface WebGLDebugMessage |
| 166 | ]]></idl> |
| 167 | |
| 168 | <newfun> |
| 169 | <p>On <code>WEBGL_debug</code>:</p> |
| 170 | |
| 171 | <function name="debugMessageControlKHR" type="void"> |
| 172 | <param name="source" type="GLenum"/> |
| 173 | <param name="type" type="GLenum"/> |
| 174 | <param name="severity" type="GLenum"/> |
| 175 | <param name="ids" type="sequence<GLuint>"/> |
| 176 | <param name="enabled" type="boolean"/> |
| 177 | Enables or disables the reporting of <code>WebGLDebugMessage</code> |
| 178 | events for the specified messages. |
| 179 | </function> |
| 180 | |
| 181 | <function name="debugMessageInsertKHR" type="void"> |
| 182 | <param name="source" type="GLenum"/> |
| 183 | <param name="type" type="GLenum"/> |
| 184 | <param name="id" type="GLuint"/> |
| 185 | <param name="severity" type="GLenum"/> |
| 186 | <param name="message" type="DOMString"/> |
| 187 | Inserts a custom message into the debug log. |
| 188 | </function> |
| 189 | |
| 190 | <function name="pushDebugGroupKHR" type="void"> |
| 191 | <param name="source" type="GLenum"/> |
| 192 | <param name="id" type="GLuint"/> |
| 193 | <param name="message" type="DOMString"/> |
| 194 | Pushes a debug group on the stack. |
| 195 | </function> |
| 196 | |
| 197 | <function name="popDebugGroupKHR" type="void"> |
| 198 | Closes a group opened with <code>pushDebugGroupKHR</code>. |
| 199 | </function> |
| 200 | |
| 201 | <function name="objectLabelKHR" type="void"> |
| 202 | <param name="object" type="WebGLObject?"/> |
| 203 | <param name="label" type="DOMString"/> |
| 204 | Assigns a label to a <code>WebGLObject</code>. |
| 205 | </function> |
| 206 | |
| 207 | <function name="getObjectLabelKHR" type="DOMString"> |
| 208 | <param name="object" type="WebGLObject?"/> |
| 209 | Retrieves the label associated with a <code>WebGLObject</code>. |
| 210 | </function> |
| 211 | |
| 212 | <function name="addEventListener" type="void"> |
| 213 | <param name="type" type="DOMString"/> |
| 214 | <param name="listener" type="EventListener"/> |
| 215 | Register an event handler of a specific event type on the EventTarget. |
| 216 | </function> |
| 217 | |
| 218 | <function name="removeEventListener" type="void"> |
| 219 | <param name="type" type="DOMString"/> |
| 220 | <param name="listener" type="EventListener"/> |
| 221 | Removes an event listener from the EventTarget. |
| 222 | </function> |
| 223 | |
| 224 | <function name="dispatchEvent" type="boolean"> |
| 225 | <param name="event" type="Event"/> |
| 226 | Dispatch an event to this EventTarget. |
| 227 | </function> |
| 228 | |
| 229 | </newfun> |
| 230 | |
| 231 | <samplecode><div class="example"> |
| 232 | Common initialization of the extension, with an example of debug message |
| 233 | reporting. |
| 234 | |
| 235 | <pre xml:space="preserve"><![CDATA[ |
| 236 | function init(gl) { |
| 237 | ... |
| 238 | var ext = gl.getExtension('WEBGL_debug'); |
| 239 | |
| 240 | ext.addEventListener('message', function(evt) { |
| 241 | console.log(evt.source, evt.type, evt.id, evt.severity, evt.message); |
| 242 | }); |
| 243 | ... |
| 244 | }]]></pre></div></samplecode> |
| 245 | |
| 246 | <samplecode><div class="example"> |
| 247 | Skip a section of the code. |
| 248 | |
| 249 | <pre xml:space="preserve"><![CDATA[ |
| 250 | function draw(gl, ext) { |
| 251 | ... |
| 252 | |
| 253 | // Setup of the default active debug group: Filter everything in |
| 254 | ext.debugMessageControlKHR(gl.DONT_CARE, gl.DONT_CARE, gl.DONT_CARE, [], true); |
| 255 | |
| 256 | // Generate a debug marker debug output message |
| 257 | ext.debugMessageInsertKHR( |
| 258 | ext.DEBUG_SOURCE_APPLICATION_KHR, |
| 259 | ext.DEBUG_TYPE_MARKER_KHR, 100, |
| 260 | ext.DEBUG_SEVERITY_NOTIFICATION_KHR, |
| 261 | "Message 1"); |
| 262 | |
| 263 | // Push debug group 1 |
| 264 | ext.pushDebugGroupKHR( |
| 265 | ext.DEBUG_SOURCE_APPLICATION_KHR, |
| 266 | 1, |
| 267 | "Message 2"); |
| 268 | |
| 269 | // Setup of the debug group 1: Filter everything out |
| 270 | ext.debugMessageControlKHR(gl.DONT_CARE, gl.DONT_CARE, gl.DONT_CARE, [], false); |
| 271 | |
| 272 | // This message won't appear in the debug output log of |
| 273 | ext.debugMessageInsertKHR( |
| 274 | ext.DEBUG_SOURCE_APPLICATION_KHR, |
| 275 | ext.DEBUG_TYPE_MARKER_KHR, 100, |
| 276 | ext.DEBUG_SEVERITY_NOTIFICATION_KHR, |
| 277 | "Message 3"); |
| 278 | |
| 279 | // Pop debug group 1, restore the volume control of the default debug group. |
| 280 | ext.popDebugGroupKHR(); |
| 281 | |
| 282 | // Generate a debug marker debug output message |
| 283 | ext.debugMessageInsertKHR( |
| 284 | ext.DEBUG_SOURCE_APPLICATION_KHR, |
| 285 | ext.DEBUG_TYPE_MARKER_KHR, 100, |
| 286 | ext.DEBUG_SEVERITY_NOTIFICATION_KHR, |
| 287 | "Message 5"); |
| 288 | |
| 289 | ... |
| 290 | |
| 291 | // Expected debug output in the JS console: |
| 292 | // Message 1 |
| 293 | // Message 2 |
| 294 | // Message 2 |
| 295 | // Message 5 |
| 296 | }]]></pre></div></samplecode> |
| 297 | |
| 298 | <samplecode><div class="example"> |
| 299 | Only output a subsection of the code and disable some messages for the |
| 300 | entire application. |
| 301 | |
| 302 | <pre xml:space="preserve"><![CDATA[ |
| 303 | function draw(gl, ext) { |
| 304 | ... |
| 305 | |
| 306 | // Setup the control of the debug output for the default debug group |
| 307 | ext.debugMessageControlKHR( |
| 308 | gl.DONT_CARE, gl.DONT_CARE, gl.DONT_CARE, [], false); |
| 309 | ext.debugMessageControlKHR( |
| 310 | ext.DEBUG_SOURCE_THIRD_PARTY_KHR, gl.DONT_CARE, gl.DONT_CARE, [], false); |
| 311 | var messages = [1234, 2345, 3456, 4567]; |
| 312 | ext.debugMessageControlKHR( |
| 313 | ext.DEBUG_SOURCE_APPLICATION_KHR, gl.DEBUG_TYPE_OTHER, gl.DONT_CARE, |
| 314 | messages, false); |
| 315 | ext.debugMessageControlKHR( |
| 316 | ext.DEBUG_SOURCE_APPLICATION_KHR, ext.DEBUG_TYPE_PORTABILITY_KHR, gl.DONT_CARE, |
| 317 | messages, false); |
| 318 | |
| 319 | // Push debug group 1 |
| 320 | // Inherit the default debug group debug output volume control |
| 321 | // Filtered out by ext.debugMessageControlKHR |
| 322 | ext.pushDebugGroupKHR( |
| 323 | ext.DEBUG_SOURCE_APPLICATION_KHR, |
| 324 | 1, |
| 325 | "Message 1"); |
| 326 | |
| 327 | // In this section of the code, we are interested in performances. |
| 328 | ext.debugMessageControlKHR( |
| 329 | ext.DEBUG_SOURCE_APPLICATION_KHR, ext.DEBUG_TYPE_PERFORMANCE_KHR, gl.DONT_CARE, [], true); |
| 330 | // But we already identify that some messages are not really useful for us. |
| 331 | ext.debugMessageControlKHR( |
| 332 | ext.DEBUG_SOURCE_APPLICATION_KHR, ext.DEBUG_TYPE_OTHER_KHR, gl.DONT_CARE, |
| 333 | [5678, 6789], false); |
| 334 | |
| 335 | ext.debugMessageInsertKHR( |
| 336 | ext.DEBUG_SOURCE_APPLICATION_KHR, |
| 337 | ext.DEBUG_TYPE_PERFORMANCE_KHR, 1357, |
| 338 | ext.DEBUG_SEVERITY_MEDIUM_KHR, |
| 339 | "Message 2"); |
| 340 | ext.debugMessageInsertKHR( |
| 341 | ext.DEBUG_SOURCE_THIRD_PARTY_KHR, // We still filter out these messages. |
| 342 | ext.DEBUG_TYPE_OTHER_KHR, 3579, |
| 343 | ext.DEBUG_SEVERITY_MEDIUM_KHR, |
| 344 | "Message 3"); |
| 345 | |
| 346 | ext.popDebugGroupKHR(); |
| 347 | |
| 348 | ... |
| 349 | |
| 350 | // Expected debug output in the JS console: |
| 351 | // Message 2 |
| 352 | }]]></pre></div></samplecode> |
| 353 | |
| 354 | <history> |
| 355 | <revision date="2015/09/18"> |
| 356 | <change>Initial revision.</change> |
| 357 | </revision> |
| 358 | </history> |
| 359 | </proposal> |