102f4aeb0Sopenharmony_ciName 202f4aeb0Sopenharmony_ci 302f4aeb0Sopenharmony_ci KHR_debug 402f4aeb0Sopenharmony_ci 502f4aeb0Sopenharmony_ciName Strings 602f4aeb0Sopenharmony_ci 702f4aeb0Sopenharmony_ci EGL_KHR_debug 802f4aeb0Sopenharmony_ci 902f4aeb0Sopenharmony_ciContributors 1002f4aeb0Sopenharmony_ci 1102f4aeb0Sopenharmony_ci Jeff Vigil, Qualcomm 1202f4aeb0Sopenharmony_ci Brian Ellis, Qualcomm 1302f4aeb0Sopenharmony_ci (Original contributors of Gl_KHR_debug extension for OpenGL/GL_ES) 1402f4aeb0Sopenharmony_ci Mark Callow, HI 1502f4aeb0Sopenharmony_ci John Leech, Khronos 1602f4aeb0Sopenharmony_ci Ray Smith, ARM 1702f4aeb0Sopenharmony_ci Prabindh Sundareson, Texas Instruments 1802f4aeb0Sopenharmony_ci James Jones, NVIDIA 1902f4aeb0Sopenharmony_ci Jesse Hall, Google 2002f4aeb0Sopenharmony_ci 2102f4aeb0Sopenharmony_ciContact 2202f4aeb0Sopenharmony_ci 2302f4aeb0Sopenharmony_ci Jeff Vigil (jvigil 'at' qualcomm.com) 2402f4aeb0Sopenharmony_ci 2502f4aeb0Sopenharmony_ciNotice 2602f4aeb0Sopenharmony_ci 2702f4aeb0Sopenharmony_ci Copyright (c) 2012-2015 The Khronos Group Inc. Copyright terms at 2802f4aeb0Sopenharmony_ci http://www.khronos.org/registry/speccopyright.html 2902f4aeb0Sopenharmony_ci 3002f4aeb0Sopenharmony_ciStatus 3102f4aeb0Sopenharmony_ci 3202f4aeb0Sopenharmony_ci Complete. Approved by the EGL Working Group on 2015/04/24. 3302f4aeb0Sopenharmony_ci Approved by the Khronos Board of Promoters on 2015/06/26. 3402f4aeb0Sopenharmony_ci 3502f4aeb0Sopenharmony_ciVersion 3602f4aeb0Sopenharmony_ci 3702f4aeb0Sopenharmony_ci Version 18, Modified Date: September 28, 2016 3802f4aeb0Sopenharmony_ci 3902f4aeb0Sopenharmony_ciNumber 4002f4aeb0Sopenharmony_ci 4102f4aeb0Sopenharmony_ci EGL Extension #92 4202f4aeb0Sopenharmony_ci 4302f4aeb0Sopenharmony_ciExtension Type 4402f4aeb0Sopenharmony_ci 4502f4aeb0Sopenharmony_ci EGL client extension 4602f4aeb0Sopenharmony_ci 4702f4aeb0Sopenharmony_ciDependencies 4802f4aeb0Sopenharmony_ci 4902f4aeb0Sopenharmony_ci Applicable to any version of EGL 1.x, but written in relationship 5002f4aeb0Sopenharmony_ci to EGL 1.5. 5102f4aeb0Sopenharmony_ci 5202f4aeb0Sopenharmony_ciOverview 5302f4aeb0Sopenharmony_ci 5402f4aeb0Sopenharmony_ci This extension allows EGL to notify applications when various events 5502f4aeb0Sopenharmony_ci occur that may be useful during application development and debugging. 5602f4aeb0Sopenharmony_ci 5702f4aeb0Sopenharmony_ci These events are represented in the form of debug messages with a 5802f4aeb0Sopenharmony_ci human-readable string representation. Examples of debug events include 5902f4aeb0Sopenharmony_ci errors due to incorrect use of the EGL API, warnings of undefined behavior, 6002f4aeb0Sopenharmony_ci and performance warnings. 6102f4aeb0Sopenharmony_ci 6202f4aeb0Sopenharmony_ci The "type" of the message roughly identifies the nature of the event that 6302f4aeb0Sopenharmony_ci caused the message. Examples include input errors, performance 6402f4aeb0Sopenharmony_ci information, or warnings about undefined behavior. 6502f4aeb0Sopenharmony_ci 6602f4aeb0Sopenharmony_ci Messages are communicated to the application through an application- 6702f4aeb0Sopenharmony_ci defined callback function that is called by the EGL implementation on 6802f4aeb0Sopenharmony_ci each debug message. The motivation for the callback routine is to free 6902f4aeb0Sopenharmony_ci application developers from actively having to query whether an EGL error, 7002f4aeb0Sopenharmony_ci or any other debuggable event has happened after each call to a EGL 7102f4aeb0Sopenharmony_ci function. With a callback, developers can keep their code free of debug 7202f4aeb0Sopenharmony_ci checks, set breakpoints in the callback function, and only have to react 7302f4aeb0Sopenharmony_ci to messages as they occur. The callback also offers much more information 7402f4aeb0Sopenharmony_ci than just an error code. 7502f4aeb0Sopenharmony_ci 7602f4aeb0Sopenharmony_ci To control the volume of debug output, types of messages can be enabled or 7702f4aeb0Sopenharmony_ci disabled. The mechanism is controlled by attributes passed to EGL. The 7802f4aeb0Sopenharmony_ci state of the message type control can be queried. 7902f4aeb0Sopenharmony_ci 8002f4aeb0Sopenharmony_ci Debug output can be enabled and disabled by changing the callback function. 8102f4aeb0Sopenharmony_ci NULL will disable the feature while a valid function pointer will enable 8202f4aeb0Sopenharmony_ci it. 8302f4aeb0Sopenharmony_ci 8402f4aeb0Sopenharmony_ci Finally, this extension defines a mechanism for EGL applications to 8502f4aeb0Sopenharmony_ci label their objects (contexts, surfaces, syncs, etc.) with a pointer 8602f4aeb0Sopenharmony_ci to an application provided structure. This pointer can be a descriptive 8702f4aeb0Sopenharmony_ci string, identifier or pointer to a structure. This enables the application 8802f4aeb0Sopenharmony_ci to associate the EGL object with application information. EGL will not 8902f4aeb0Sopenharmony_ci interpret this pointer as a string or any other meaning - just attach to 9002f4aeb0Sopenharmony_ci the object and pass back in the callback when that object is the primary 9102f4aeb0Sopenharmony_ci object of an event. 9202f4aeb0Sopenharmony_ci 9302f4aeb0Sopenharmony_ciIP Status 9402f4aeb0Sopenharmony_ci 9502f4aeb0Sopenharmony_ci No known IP claims. 9602f4aeb0Sopenharmony_ci 9702f4aeb0Sopenharmony_ciNew Procedures and Functions 9802f4aeb0Sopenharmony_ci 9902f4aeb0Sopenharmony_ci EGLint eglDebugMessageControlKHR( 10002f4aeb0Sopenharmony_ci EGLDEBUGPROCKHR callback, 10102f4aeb0Sopenharmony_ci const EGLAttrib* attrib_list); 10202f4aeb0Sopenharmony_ci 10302f4aeb0Sopenharmony_ci EGLBoolean eglQueryDebugKHR( 10402f4aeb0Sopenharmony_ci EGLint attribute, 10502f4aeb0Sopenharmony_ci EGLAttrib* value); 10602f4aeb0Sopenharmony_ci 10702f4aeb0Sopenharmony_ci EGLInt eglLabelObjectKHR( 10802f4aeb0Sopenharmony_ci EGLDisplay display, 10902f4aeb0Sopenharmony_ci EGLenum objectType, 11002f4aeb0Sopenharmony_ci EGLObjectKHR object, 11102f4aeb0Sopenharmony_ci EGLLabelKHR label); 11202f4aeb0Sopenharmony_ci 11302f4aeb0Sopenharmony_ciNew Types 11402f4aeb0Sopenharmony_ci 11502f4aeb0Sopenharmony_ci A general type to identify EGL objects, such as EGLSurface or EGLContext. 11602f4aeb0Sopenharmony_ci 11702f4aeb0Sopenharmony_ci typedef void* EGLObjectKHR; 11802f4aeb0Sopenharmony_ci 11902f4aeb0Sopenharmony_ci A label is a string, ID or pointer to a structure that the application 12002f4aeb0Sopenharmony_ci can attach to an EGL object. 12102f4aeb0Sopenharmony_ci 12202f4aeb0Sopenharmony_ci typedef void* EGLLabelKHR; 12302f4aeb0Sopenharmony_ci 12402f4aeb0Sopenharmony_ci The callback function that applications can define, and is accepted by 12502f4aeb0Sopenharmony_ci eglDebugMessageControlKHR, is defined as: 12602f4aeb0Sopenharmony_ci 12702f4aeb0Sopenharmony_ci typedef void (APIENTRY *EGLDEBUGPROCKHR)( 12802f4aeb0Sopenharmony_ci EGLenum error, 12902f4aeb0Sopenharmony_ci const char *command, 13002f4aeb0Sopenharmony_ci EGLint messageType, 13102f4aeb0Sopenharmony_ci EGLLabelKHR threadLabel, 13202f4aeb0Sopenharmony_ci EGLLabelKHR objectLabel, 13302f4aeb0Sopenharmony_ci const char* message); 13402f4aeb0Sopenharmony_ci 13502f4aeb0Sopenharmony_ciNew Tokens 13602f4aeb0Sopenharmony_ci 13702f4aeb0Sopenharmony_ci Tokens accepted by the <objectType> parameter of function 13802f4aeb0Sopenharmony_ci eglLabelObjectKHR: 13902f4aeb0Sopenharmony_ci 14002f4aeb0Sopenharmony_ci EGL_OBJECT_THREAD_KHR 0x33B0 14102f4aeb0Sopenharmony_ci EGL_OBJECT_DISPLAY_KHR 0x33B1 14202f4aeb0Sopenharmony_ci EGL_OBJECT_CONTEXT_KHR 0x33B2 14302f4aeb0Sopenharmony_ci EGL_OBJECT_SURFACE_KHR 0x33B3 14402f4aeb0Sopenharmony_ci EGL_OBJECT_IMAGE_KHR 0x33B4 14502f4aeb0Sopenharmony_ci EGL_OBJECT_SYNC_KHR 0x33B5 14602f4aeb0Sopenharmony_ci EGL_OBJECT_STREAM_KHR 0x33B6 14702f4aeb0Sopenharmony_ci 14802f4aeb0Sopenharmony_ci Tokens provided by the <messageType> parameter of EGLDEBUGPROCKHR 14902f4aeb0Sopenharmony_ci or the attributes input to eglControlDebugMessageKHR or attribute 15002f4aeb0Sopenharmony_ci of eglQueryDebugKHR: 15102f4aeb0Sopenharmony_ci 15202f4aeb0Sopenharmony_ci EGL_DEBUG_MSG_CRITICAL_KHR 0x33B9 15302f4aeb0Sopenharmony_ci EGL_DEBUG_MSG_ERROR_KHR 0x33BA 15402f4aeb0Sopenharmony_ci EGL_DEBUG_MSG_WARN_KHR 0x33BB 15502f4aeb0Sopenharmony_ci EGL_DEBUG_MSG_INFO_KHR 0x33BC 15602f4aeb0Sopenharmony_ci 15702f4aeb0Sopenharmony_ci Tokens provided by the input attribute to eglQueryDebugKHR: 15802f4aeb0Sopenharmony_ci 15902f4aeb0Sopenharmony_ci EGL_DEBUG_CALLBACK_KHR 0x33B8 16002f4aeb0Sopenharmony_ci 16102f4aeb0Sopenharmony_ciAdditions to Chapter 3 of the EGL 1.5 Specification 16202f4aeb0Sopenharmony_ci(EGL Functions and Errors) 16302f4aeb0Sopenharmony_ci 16402f4aeb0Sopenharmony_ci Add new Section 3.13: 16502f4aeb0Sopenharmony_ci 16602f4aeb0Sopenharmony_ci "3.13 - Debug Output 16702f4aeb0Sopenharmony_ci 16802f4aeb0Sopenharmony_ci Application developers can obtain more information from EGL runtime in 16902f4aeb0Sopenharmony_ci the form of debug output. This information can include details about EGL 17002f4aeb0Sopenharmony_ci errors, undefined behavior, implementation-dependent performance warnings, 17102f4aeb0Sopenharmony_ci or other useful hints. 17202f4aeb0Sopenharmony_ci 17302f4aeb0Sopenharmony_ci This information is communicated through a stream of debug messages that 17402f4aeb0Sopenharmony_ci are generated as EGL commands are executed. The application can 17502f4aeb0Sopenharmony_ci receive these messages through a callback routine. 17602f4aeb0Sopenharmony_ci 17702f4aeb0Sopenharmony_ci Controls are provided for disabling classes of messages that the 17802f4aeb0Sopenharmony_ci application does not care about. 17902f4aeb0Sopenharmony_ci 18002f4aeb0Sopenharmony_ci Debug output functionality is controlled with: 18102f4aeb0Sopenharmony_ci 18202f4aeb0Sopenharmony_ci EGLint eglDebugMessageControlKHR( 18302f4aeb0Sopenharmony_ci EGLDEBUGPROCKHR callback, 18402f4aeb0Sopenharmony_ci const EGLAttrib* attrib_list); 18502f4aeb0Sopenharmony_ci 18602f4aeb0Sopenharmony_ci If the <callback> parameter is NULL, then no messages are sent to the 18702f4aeb0Sopenharmony_ci callback function and the debug message generation is disabled. If the 18802f4aeb0Sopenharmony_ci <callback> parameter is a pointer to a valid callback function, as defined 18902f4aeb0Sopenharmony_ci by EGLDEBUGPROCKHR, then messages will be sent to that callback function. 19002f4aeb0Sopenharmony_ci 19102f4aeb0Sopenharmony_ci The attribute list <attrib_list> contains a set of message type enums, 19202f4aeb0Sopenharmony_ci and each has a value of EGL_TRUE to enable that class of messages, 19302f4aeb0Sopenharmony_ci or value EGL_FALSE to disable that class of message. 19402f4aeb0Sopenharmony_ci 19502f4aeb0Sopenharmony_ci If the <attrib_list> contains an unknown attribute or value the function 19602f4aeb0Sopenharmony_ci will return a EGL_BAD_ATTRIBUTE error. 19702f4aeb0Sopenharmony_ci 19802f4aeb0Sopenharmony_ci If there is no error, then the function will set the updated callback, 19902f4aeb0Sopenharmony_ci set the updated message types and return EGL_SUCCESS. 20002f4aeb0Sopenharmony_ci 20102f4aeb0Sopenharmony_ci The messages types, their purpose and initial states are given in 20202f4aeb0Sopenharmony_ci table 13.1 below. The parameter <attrib_list> needs only contain the 20302f4aeb0Sopenharmony_ci attributes to change; an application can call eglDebugMessageControl more 20402f4aeb0Sopenharmony_ci than once with a valid callback, and change the message type states as 20502f4aeb0Sopenharmony_ci desired. 20602f4aeb0Sopenharmony_ci 20702f4aeb0Sopenharmony_ci When the callback is set to NULL; the attributes are reset to their 20802f4aeb0Sopenharmony_ci default values. 20902f4aeb0Sopenharmony_ci 21002f4aeb0Sopenharmony_ci Debug Output Message Type Informs about Initial/Default state 21102f4aeb0Sopenharmony_ci ------------------------- ------------- --------------------- 21202f4aeb0Sopenharmony_ci EGL_DEBUG_MSG_CRITICAL_KHR Internal EGL driver failures ENABLED 21302f4aeb0Sopenharmony_ci i.e. EGL_BAD_ALLOC, 21402f4aeb0Sopenharmony_ci EGL_CONTEXT_LOST 21502f4aeb0Sopenharmony_ci 21602f4aeb0Sopenharmony_ci EGL_DEBUG_MSG_ERROR_KHR Input and bad match errors ENABLED 21702f4aeb0Sopenharmony_ci i.e. EGL_BAD_CONTEXT, 21802f4aeb0Sopenharmony_ci EGL_BAD_PARAMETER... 21902f4aeb0Sopenharmony_ci 22002f4aeb0Sopenharmony_ci EGL_DEBUG_MSG_WARN_KHR Warnings, code is EGL_SUCCESS, DISABLED 22102f4aeb0Sopenharmony_ci but message indicates 22202f4aeb0Sopenharmony_ci deprecated or inefficient 22302f4aeb0Sopenharmony_ci operation. 22402f4aeb0Sopenharmony_ci 22502f4aeb0Sopenharmony_ci EGL_DEBUG_MSG_INFO_KHR Verbose operation DISABLED 22602f4aeb0Sopenharmony_ci Messages such as object 22702f4aeb0Sopenharmony_ci creation and destruction 22802f4aeb0Sopenharmony_ci or change in state. 22902f4aeb0Sopenharmony_ci 23002f4aeb0Sopenharmony_ci --------------------------------------------------------------------------- 23102f4aeb0Sopenharmony_ci Table 13.1: Types of debug output messages. Each debug message is associated 23202f4aeb0Sopenharmony_ci with one of these types that describes the nature or class of the message. 23302f4aeb0Sopenharmony_ci 23402f4aeb0Sopenharmony_ci 3.13.1 - Debug Message Callback 23502f4aeb0Sopenharmony_ci 23602f4aeb0Sopenharmony_ci Applications must provide a callback function for receiving debug messages 23702f4aeb0Sopenharmony_ci of the following type: 23802f4aeb0Sopenharmony_ci 23902f4aeb0Sopenharmony_ci typedef void (APIENTRY *EGLDEBUGPROCKHR)( 24002f4aeb0Sopenharmony_ci EGLenum error, 24102f4aeb0Sopenharmony_ci const char *command, 24202f4aeb0Sopenharmony_ci EGLint messageType, 24302f4aeb0Sopenharmony_ci EGLLabelKHR threadLabel, 24402f4aeb0Sopenharmony_ci EGLLabelKHR objectLabel, 24502f4aeb0Sopenharmony_ci const char* message); 24602f4aeb0Sopenharmony_ci 24702f4aeb0Sopenharmony_ci The function's prototype must follow the type definition of EGLDEBUGPROCKHR. 24802f4aeb0Sopenharmony_ci Only one debug callback can be in-use for the application, and 24902f4aeb0Sopenharmony_ci further calls overwrite the previous callback. Specifying NULL as the 25002f4aeb0Sopenharmony_ci value of <callback> clears the current callback and disables message 25102f4aeb0Sopenharmony_ci output. 25202f4aeb0Sopenharmony_ci 25302f4aeb0Sopenharmony_ci The callback will receive the following in its parameters: 25402f4aeb0Sopenharmony_ci 25502f4aeb0Sopenharmony_ci <error> will contain an EGL error code, or EGL_SUCCESS, as applicable. 25602f4aeb0Sopenharmony_ci 25702f4aeb0Sopenharmony_ci <command> will contain a pointer to a string. Example "eglBindApi". 25802f4aeb0Sopenharmony_ci 25902f4aeb0Sopenharmony_ci <messageType> will contain one of the debug message types listed in 26002f4aeb0Sopenharmony_ci table 13.1. 26102f4aeb0Sopenharmony_ci 26202f4aeb0Sopenharmony_ci <threadLabel> will contain the label attached to the current thread. 26302f4aeb0Sopenharmony_ci The <threadLabel> will be NULL if not set by the application. If the 26402f4aeb0Sopenharmony_ci message is from an internal thread, the label will be NULL. 26502f4aeb0Sopenharmony_ci 26602f4aeb0Sopenharmony_ci <objectLabel> will contain the label attached to the primary object 26702f4aeb0Sopenharmony_ci of the message; Labels will be NULL if not set by the application. 26802f4aeb0Sopenharmony_ci The primary object should be the object the function operates on, see 26902f4aeb0Sopenharmony_ci table 13.2 which provides the recommended mapping between functions and 27002f4aeb0Sopenharmony_ci their primary object. This <objectLabel> may be NULL even though the 27102f4aeb0Sopenharmony_ci application labeled the object. This is because it is possible an error 27202f4aeb0Sopenharmony_ci was raised while executing the command before the primary object was 27302f4aeb0Sopenharmony_ci validated, therefore its label cannot be included in the callback. 27402f4aeb0Sopenharmony_ci 27502f4aeb0Sopenharmony_ci <message> will contain a platform specific debug string message; 27602f4aeb0Sopenharmony_ci This string should provide added information to the application 27702f4aeb0Sopenharmony_ci developer regarding the condition that generated the message. 27802f4aeb0Sopenharmony_ci The format of a message is implementation-defined, although it should 27902f4aeb0Sopenharmony_ci represent a concise description of the event that caused the message 28002f4aeb0Sopenharmony_ci to be generated. Message strings can be NULL and should not be assumed 28102f4aeb0Sopenharmony_ci otherwise. 28202f4aeb0Sopenharmony_ci 28302f4aeb0Sopenharmony_ci EGL Command Primary object 28402f4aeb0Sopenharmony_ci ------------------------- ------------- 28502f4aeb0Sopenharmony_ci 28602f4aeb0Sopenharmony_ci eglBindAPI thread 28702f4aeb0Sopenharmony_ci eglBindTexImage surface 28802f4aeb0Sopenharmony_ci eglChooseConfig display 28902f4aeb0Sopenharmony_ci eglClientWaitSync sync 29002f4aeb0Sopenharmony_ci eglCopyBuffers surface 29102f4aeb0Sopenharmony_ci eglCreateContext display 29202f4aeb0Sopenharmony_ci eglCreateImage display 29302f4aeb0Sopenharmony_ci eglCreatePbufferFromClientBuffer display 29402f4aeb0Sopenharmony_ci eglCreatePbufferSurface display 29502f4aeb0Sopenharmony_ci eglCreatePixmapSurface display 29602f4aeb0Sopenharmony_ci eglCreatePlatformWindowSurface display 29702f4aeb0Sopenharmony_ci eglCreatePlatformPixmapSurface display 29802f4aeb0Sopenharmony_ci eglCreateSync display 29902f4aeb0Sopenharmony_ci eglCreateWindowSurface display 30002f4aeb0Sopenharmony_ci eglDestroyContext context 30102f4aeb0Sopenharmony_ci eglDestroyImage image 30202f4aeb0Sopenharmony_ci eglDestroySurface surface 30302f4aeb0Sopenharmony_ci eglDestroySync sync 30402f4aeb0Sopenharmony_ci eglGetConfigAttrib display 30502f4aeb0Sopenharmony_ci eglGetConfigs display 30602f4aeb0Sopenharmony_ci eglGetCurrentContext context 30702f4aeb0Sopenharmony_ci eglGetCurrentDisplay display 30802f4aeb0Sopenharmony_ci eglGetCurrentSurface surface 30902f4aeb0Sopenharmony_ci eglGetDisplay thread 31002f4aeb0Sopenharmony_ci eglGetError thread 31102f4aeb0Sopenharmony_ci eglGetPlatformDisplay thread 31202f4aeb0Sopenharmony_ci eglGetSyncAttrib sync 31302f4aeb0Sopenharmony_ci eglInitialize display 31402f4aeb0Sopenharmony_ci eglMakeCurrent context 31502f4aeb0Sopenharmony_ci eglQueryAPI context 31602f4aeb0Sopenharmony_ci eglQueryContext context 31702f4aeb0Sopenharmony_ci eglQueryString display 31802f4aeb0Sopenharmony_ci eglQuerySurface surface 31902f4aeb0Sopenharmony_ci eglReleaseTexImage surface 32002f4aeb0Sopenharmony_ci eglReleaseThread thread 32102f4aeb0Sopenharmony_ci eglSurfaceAttrib surface 32202f4aeb0Sopenharmony_ci eglSwapBuffers surface 32302f4aeb0Sopenharmony_ci eglSwapInterval surface 32402f4aeb0Sopenharmony_ci eglTerminate display 32502f4aeb0Sopenharmony_ci eglWaitClient context 32602f4aeb0Sopenharmony_ci eglWaitGL context 32702f4aeb0Sopenharmony_ci eglWaitNative thread 32802f4aeb0Sopenharmony_ci eglWaitSync sync 32902f4aeb0Sopenharmony_ci eglDebugMessageControlKHR -none- 33002f4aeb0Sopenharmony_ci eglQueryDebugKHR -none- 33102f4aeb0Sopenharmony_ci eglLabelObjectKHR labeled object 33202f4aeb0Sopenharmony_ci 33302f4aeb0Sopenharmony_ci --------------------------------------------------------------------------- 33402f4aeb0Sopenharmony_ci Table 13.2: Recommendation of primary object in a callback as result 33502f4aeb0Sopenharmony_ci of various EGL commands. 33602f4aeb0Sopenharmony_ci 33702f4aeb0Sopenharmony_ci If the application has specified a <callback> function for receiving debug 33802f4aeb0Sopenharmony_ci output, the implementation will call that function whenever any enabled 33902f4aeb0Sopenharmony_ci message is generated. A message must be posted for every error since 34002f4aeb0Sopenharmony_ci debug messages can be used as an alternative to eglGetError() for error 34102f4aeb0Sopenharmony_ci detection and handling. Specifying a callback function does not affect the 34202f4aeb0Sopenharmony_ci behavior of eglGetError; errors are reported through both mechanisms. 34302f4aeb0Sopenharmony_ci 34402f4aeb0Sopenharmony_ci Applications that specify a callback function must be aware of certain 34502f4aeb0Sopenharmony_ci special conditions when executing code inside a callback when it is 34602f4aeb0Sopenharmony_ci called by EGL. The memory for <message> is read-only, owned and managed 34702f4aeb0Sopenharmony_ci by EGL, and should only be considered valid for the duration of the 34802f4aeb0Sopenharmony_ci function call. Likewise the <command> string is read-only EGL managed 34902f4aeb0Sopenharmony_ci memory and should be considered valid only for the duration of the 35002f4aeb0Sopenharmony_ci callback. 35102f4aeb0Sopenharmony_ci 35202f4aeb0Sopenharmony_ci Setting the label for EGL objects is optional and only intended for 35302f4aeb0Sopenharmony_ci applications to correlate application structures with EGL objects. 35402f4aeb0Sopenharmony_ci All object labels are initially NULL. 35502f4aeb0Sopenharmony_ci 35602f4aeb0Sopenharmony_ci The behavior of calling any EGL operation, its client APIs, or window system 35702f4aeb0Sopenharmony_ci functions from within the callback function is undefined and may lead 35802f4aeb0Sopenharmony_ci to program termination. It should not be considered reentrant. 35902f4aeb0Sopenharmony_ci 36002f4aeb0Sopenharmony_ci Only one debug callback may be registered at a time; registering a new 36102f4aeb0Sopenharmony_ci callback will replace the previous callback. The callback is used by any 36202f4aeb0Sopenharmony_ci thread that calls EGL, so if the application calls into EGL concurrently 36302f4aeb0Sopenharmony_ci from multiple threads it must ensure the callback is thread-safe. 36402f4aeb0Sopenharmony_ci 36502f4aeb0Sopenharmony_ci EGL may employ internal threads to execute EGL commands. These threads can 36602f4aeb0Sopenharmony_ci post debug messages to the callback function. The labels for these 36702f4aeb0Sopenharmony_ci internal threads will be NULL. 36802f4aeb0Sopenharmony_ci 36902f4aeb0Sopenharmony_ci 3.13.2 Debug Labels: 37002f4aeb0Sopenharmony_ci 37102f4aeb0Sopenharmony_ci Debug labels provide a method for annotating any object (context, surface, 37202f4aeb0Sopenharmony_ci sync, etc.) with an application provided label. These labels may then be 37302f4aeb0Sopenharmony_ci used by the debug output or an external tool such as a debugger or profiler 37402f4aeb0Sopenharmony_ci to describe labeled objects. 37502f4aeb0Sopenharmony_ci 37602f4aeb0Sopenharmony_ci The command 37702f4aeb0Sopenharmony_ci 37802f4aeb0Sopenharmony_ci EGLint eglLabelObjectKHR( 37902f4aeb0Sopenharmony_ci EGLDisplay display, 38002f4aeb0Sopenharmony_ci EGLenum objectType, 38102f4aeb0Sopenharmony_ci EGLObjectKHR object, 38202f4aeb0Sopenharmony_ci EGLLabelKHR label); 38302f4aeb0Sopenharmony_ci 38402f4aeb0Sopenharmony_ci enables the application to attach a label to a specified object. 38502f4aeb0Sopenharmony_ci The <display>, <objectType>, and <object> identify the object to be 38602f4aeb0Sopenharmony_ci labeled. 38702f4aeb0Sopenharmony_ci 38802f4aeb0Sopenharmony_ci The <label> contains a pointer sized variable to attach to the 38902f4aeb0Sopenharmony_ci object. This label can be a integer identifier, string or pointer to a 39002f4aeb0Sopenharmony_ci application defined structure. EGL will not interpret this value; 39102f4aeb0Sopenharmony_ci it will merely provide it when the object is involved in a callback 39202f4aeb0Sopenharmony_ci message. The label for any object will initially be NULL until set by 39302f4aeb0Sopenharmony_ci the application. 39402f4aeb0Sopenharmony_ci 39502f4aeb0Sopenharmony_ci An EGL_BAD_PARAMETER error is returned by eglLabelObjectKHR if <objectType> 39602f4aeb0Sopenharmony_ci doesn't match one of the object type enums. An EGL_BAD_PARAMETER is also 39702f4aeb0Sopenharmony_ci returned if the <objectType> is not a supported type; such as no support 39802f4aeb0Sopenharmony_ci for streams. 39902f4aeb0Sopenharmony_ci 40002f4aeb0Sopenharmony_ci An EGL_BAD_PARAMETER error is returned by eglLabelObjectKHR if <object> is 40102f4aeb0Sopenharmony_ci invalid, unknown, NULL, or is not an object created with 40202f4aeb0Sopenharmony_ci EGLDisplay <display>. 40302f4aeb0Sopenharmony_ci 40402f4aeb0Sopenharmony_ci When the <objectType> is EGL_OBJECT_THREAD_KHR, the <object> parameter 40502f4aeb0Sopenharmony_ci will be ignored by EGL. The thread is implicitly the active thread. It is 40602f4aeb0Sopenharmony_ci recommended that the application pass a NULL for the <object> parameter in 40702f4aeb0Sopenharmony_ci this case. 40802f4aeb0Sopenharmony_ci 40902f4aeb0Sopenharmony_ci When the <objectType> is EGL_OBJECT_DISPLAY_KHR, the <object> parameter 41002f4aeb0Sopenharmony_ci must be the same as the <display> parameter - the Display to label. If 41102f4aeb0Sopenharmony_ci these do not match, in this case, a EGL_BAD_PARAMETER is generated. 41202f4aeb0Sopenharmony_ci 41302f4aeb0Sopenharmony_ci The <display> does not need to be initialized for <objectType> 41402f4aeb0Sopenharmony_ci EGL_OBJECT_THREAD_KHR, or EGL_OBJECT_DISPLAY_KHR; However for all other 41502f4aeb0Sopenharmony_ci types it must be initialized in order to validate the <object> for 41602f4aeb0Sopenharmony_ci attaching a label. 41702f4aeb0Sopenharmony_ci 41802f4aeb0Sopenharmony_ci If there is no error, then the function will set the label and return 41902f4aeb0Sopenharmony_ci EGL_SUCCESS. 42002f4aeb0Sopenharmony_ci 42102f4aeb0Sopenharmony_ci 3.13.3 Debug Queries: 42202f4aeb0Sopenharmony_ci 42302f4aeb0Sopenharmony_ci The command 42402f4aeb0Sopenharmony_ci 42502f4aeb0Sopenharmony_ci EGLBoolean eglQueryDebugKHR( 42602f4aeb0Sopenharmony_ci EGLint attribute, 42702f4aeb0Sopenharmony_ci EGLAttrib* value); 42802f4aeb0Sopenharmony_ci 42902f4aeb0Sopenharmony_ci enables the application to query the current value for the debug 43002f4aeb0Sopenharmony_ci attributes. On success the function returns EGL_TRUE. 43102f4aeb0Sopenharmony_ci 43202f4aeb0Sopenharmony_ci If <attribute> is a message type enum, the value returned will 43302f4aeb0Sopenharmony_ci be either EGL_TRUE or EGL_FALSE to indicate whether the specified types of 43402f4aeb0Sopenharmony_ci messages are enabled or disabled respectively. 43502f4aeb0Sopenharmony_ci 43602f4aeb0Sopenharmony_ci Querying for attribute EGL_DEBUG_CALLBACK_KHR will return the current 43702f4aeb0Sopenharmony_ci callback pointer. This feature is intended to enable layering of the 43802f4aeb0Sopenharmony_ci callback with helper libraries. 43902f4aeb0Sopenharmony_ci 44002f4aeb0Sopenharmony_ci Querying for an unknown attribute will result in an EGL_BAD_ATTRIBUTE error 44102f4aeb0Sopenharmony_ci and a return of EGL_FALSE. 44202f4aeb0Sopenharmony_ci 44302f4aeb0Sopenharmony_ciUsage Examples 44402f4aeb0Sopenharmony_ci 44502f4aeb0Sopenharmony_ci This example shows starting debug messaging and attaching string labels to 44602f4aeb0Sopenharmony_ci newly created objects. 44702f4aeb0Sopenharmony_ci 44802f4aeb0Sopenharmony_ci void MyCallBack(EGLenum error, 44902f4aeb0Sopenharmony_ci const char *command, 45002f4aeb0Sopenharmony_ci EGLint messageType, 45102f4aeb0Sopenharmony_ci EGLLabelKHR threadLabel, 45202f4aeb0Sopenharmony_ci EGLLabelKHR objectLabel, 45302f4aeb0Sopenharmony_ci const char* message) 45402f4aeb0Sopenharmony_ci { 45502f4aeb0Sopenharmony_ci printf("Error: %x, With command %s, Type: %d," 45602f4aeb0Sopenharmony_ci "Thread: %s, Object: %s, Message: %s.", 45702f4aeb0Sopenharmony_ci error, command, messageType, threadLabel, objectLabel, message); 45802f4aeb0Sopenharmony_ci } 45902f4aeb0Sopenharmony_ci 46002f4aeb0Sopenharmony_ci EGLint result; 46102f4aeb0Sopenharmony_ci 46202f4aeb0Sopenharmony_ci // DEBUG_MSG_ERROR and CRITICAL are enabled by default 46302f4aeb0Sopenharmony_ci EGLAttrib debugAttribs = {EGL_DEBUG_MSG_WARN_KHR, EGL_TRUE, EGL_NONE}; 46402f4aeb0Sopenharmony_ci // Start up debug messaging: 46502f4aeb0Sopenharmony_ci result = eglDebugMessageControl(MyCallBack, debugAttribs); 46602f4aeb0Sopenharmony_ci 46702f4aeb0Sopenharmony_ci // Label for the rendering thread. 46802f4aeb0Sopenharmony_ci EGLLabelKHR renderThreadLabel = (EGLLabelKHR)"Render thread"; 46902f4aeb0Sopenharmony_ci result = eglLabelObject(NULL, EGL_OBJECT_THREAD_KHR, NULL, renderThreadLabel); 47002f4aeb0Sopenharmony_ci 47102f4aeb0Sopenharmony_ci EGLDisplay dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); 47202f4aeb0Sopenharmony_ci EGLLabelKHR myDisplay = (EGLLabelKHR)"Default display"; 47302f4aeb0Sopenharmony_ci result = eglLabelObject(dpy, EGL_OBJECT_DISPLAY_KHR, dpy, myDisplay); 47402f4aeb0Sopenharmony_ci 47502f4aeb0Sopenharmony_ci eglInitialize(dpy); 47602f4aeb0Sopenharmony_ci 47702f4aeb0Sopenharmony_ci EGLLabelKHR renderContextLabel = (EGLLabelKHR)"Render context"; 47802f4aeb0Sopenharmony_ci EGLContext ctx = eglCreateContext(dpy, config, NULL, contextAttribs); 47902f4aeb0Sopenharmony_ci result = eglLabelObject(dpy, EGL_OBJECT_CONTEXT_KHR, ctx, renderContextLabel); 48002f4aeb0Sopenharmony_ci 48102f4aeb0Sopenharmony_ci 48202f4aeb0Sopenharmony_ciIssues 48302f4aeb0Sopenharmony_ci 48402f4aeb0Sopenharmony_ci 1. Why not use GL_KHR_debug? 48502f4aeb0Sopenharmony_ci 48602f4aeb0Sopenharmony_ci RESOLVED: Most EGL use and object creation happens before creating a 48702f4aeb0Sopenharmony_ci GL context. And since EGL operations are thread related - the debug 48802f4aeb0Sopenharmony_ci messages should be too. 48902f4aeb0Sopenharmony_ci 49002f4aeb0Sopenharmony_ci 2. Is the callback expected only to be called from the thread which it's 49102f4aeb0Sopenharmony_ci registered? 49202f4aeb0Sopenharmony_ci 49302f4aeb0Sopenharmony_ci RESOLVED: In most cases when an application thread calls an EGL function, 49402f4aeb0Sopenharmony_ci it is expected that EGL upon detecting an error will callback using that 49502f4aeb0Sopenharmony_ci application thread. However, EGL may have internal helper threads that 49602f4aeb0Sopenharmony_ci execute operations. These threads can callback but will have no 49702f4aeb0Sopenharmony_ci threadLabel. It is the responsibility of EGL to ensure that if these 49802f4aeb0Sopenharmony_ci threads are blocked in the application's callback by a breakpoint; that 49902f4aeb0Sopenharmony_ci EGL does not fail. Internal threads are an implementation detail and 50002f4aeb0Sopenharmony_ci are not required. 50102f4aeb0Sopenharmony_ci 50202f4aeb0Sopenharmony_ci 50302f4aeb0Sopenharmony_ciRevision History 50402f4aeb0Sopenharmony_ci 50502f4aeb0Sopenharmony_ci Revision 18, 2016-07-28 (Jeff Vigil) 50602f4aeb0Sopenharmony_ci - Clarify return values/error codes. 50702f4aeb0Sopenharmony_ci 50802f4aeb0Sopenharmony_ci Revision 17, 2015-09-23 (Jeff Vigil) 50902f4aeb0Sopenharmony_ci - Correct type name to "EGLDEBUGPROCKHR". Updated example code. 51002f4aeb0Sopenharmony_ci 51102f4aeb0Sopenharmony_ci Revision 16, 2015-04-15 (Jeff Vigil) 51202f4aeb0Sopenharmony_ci - Clarified that <objectLabel> maybe NULL in the callback, if an error 51302f4aeb0Sopenharmony_ci is raised before the primary object handle is validated. 51402f4aeb0Sopenharmony_ci 51502f4aeb0Sopenharmony_ci Revision 15, 2015-03-30 (Jeff Vigil) 51602f4aeb0Sopenharmony_ci - Further details to labeling of EGL_OBJECT_DISPLAY_KHR. 51702f4aeb0Sopenharmony_ci 51802f4aeb0Sopenharmony_ci Revision 14, 2015-03-27 (Jeff Vigil) 51902f4aeb0Sopenharmony_ci - Further clarification of returns and errors. Add further details to 52002f4aeb0Sopenharmony_ci labeling of EGL_OBJECT_THREAD_KHR and EGL_OBJECT_DISPLAY_KHR. 52102f4aeb0Sopenharmony_ci 52202f4aeb0Sopenharmony_ci Revision 13, 2015-03-26 (Jeff Vigil) 52302f4aeb0Sopenharmony_ci - Clarified returns and errors. 52402f4aeb0Sopenharmony_ci 52502f4aeb0Sopenharmony_ci Revision 12, 2015-03-24 (Jeff Vigil) 52602f4aeb0Sopenharmony_ci - Improve readability. Add assigned enum values. 52702f4aeb0Sopenharmony_ci 52802f4aeb0Sopenharmony_ci Revision 11, 2015-03-02 (Jeff Vigil) 52902f4aeb0Sopenharmony_ci - Clarify text regarding parameter attribute_list and its persistence. 53002f4aeb0Sopenharmony_ci 53102f4aeb0Sopenharmony_ci Revision 10, 2015-02-25 (Jeff Vigil) 53202f4aeb0Sopenharmony_ci - Clarify text regarding callback blocking. 53302f4aeb0Sopenharmony_ci - The implementation must provide errors and success in callbacks so 53402f4aeb0Sopenharmony_ci that the callback replaces the use of eglGetError. 53502f4aeb0Sopenharmony_ci - <command> strings are read-only EGL memory. 53602f4aeb0Sopenharmony_ci - Specify default values for attributes. 53702f4aeb0Sopenharmony_ci - Fix typos. 53802f4aeb0Sopenharmony_ci 53902f4aeb0Sopenharmony_ci Revision 9, 2015-02-03 (Jeff Vigil) 54002f4aeb0Sopenharmony_ci - Updated contributors. 54102f4aeb0Sopenharmony_ci - Add extension type. 54202f4aeb0Sopenharmony_ci - Add "KHR" to token and function names. 54302f4aeb0Sopenharmony_ci - Fix typos. 54402f4aeb0Sopenharmony_ci - Add query to get current callback pointer. 54502f4aeb0Sopenharmony_ci 54602f4aeb0Sopenharmony_ci Revision 8, 2014-12-03 (Jeff Vigil) 54702f4aeb0Sopenharmony_ci - Add table containing recommendation for primary object in the callback. 54802f4aeb0Sopenharmony_ci 54902f4aeb0Sopenharmony_ci Revision 7, 2014-10-21 (Jeff Vigil) 55002f4aeb0Sopenharmony_ci - Remove configs as a label-able object. 55102f4aeb0Sopenharmony_ci - Remove redundant text. 55202f4aeb0Sopenharmony_ci - Simplify to one callback per process, not per thread. 55302f4aeb0Sopenharmony_ci 55402f4aeb0Sopenharmony_ci Revision 6, 2014-10-17 (Jeff Vigil) 55502f4aeb0Sopenharmony_ci - Add issues. 55602f4aeb0Sopenharmony_ci - Address internal EGL threads posting messages. 55702f4aeb0Sopenharmony_ci 55802f4aeb0Sopenharmony_ci Revision 5, 2014-05-27 (Jeff Vigil) 55902f4aeb0Sopenharmony_ci - Add missing text for eglQueryDebug. 56002f4aeb0Sopenharmony_ci - Clarify threading model. 56102f4aeb0Sopenharmony_ci 56202f4aeb0Sopenharmony_ci Revision 4, 2014-04-14 (Jeff Vigil) 56302f4aeb0Sopenharmony_ci - Fix due to feedback from EGL WG face-to-face conference. 56402f4aeb0Sopenharmony_ci 56502f4aeb0Sopenharmony_ci Revision 3, 2014-04-10 (Jeff Vigil) 56602f4aeb0Sopenharmony_ci - Refinements. 56702f4aeb0Sopenharmony_ci 56802f4aeb0Sopenharmony_ci Revision 2, 2014-02-21 (Jeff Vigil) 56902f4aeb0Sopenharmony_ci - Simplify API. 57002f4aeb0Sopenharmony_ci 57102f4aeb0Sopenharmony_ci Revision 1, 2013-09-08 (Jeff Vigil) 57202f4aeb0Sopenharmony_ci - Work in progress for F2F, Based on GL_KHR_debug, replace GL with EGL 57302f4aeb0Sopenharmony_ci and remove GL spec specific text. 574