JOGL v2.6.0-rc-20250706
JOGL, High-Performance Graphics Binding for Java™ (public API).
GLDebugMessage.java
Go to the documentation of this file.
1/**
2 * Copyright 2011 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28package com.jogamp.opengl;
29
30import com.jogamp.common.os.Platform;
31
32/**
33 * OpenGL debug message generated by the driver
34 * and delivered via {@link GLDebugListener}.
35 */
36public class GLDebugMessage {
37 final GLContext source;
38 final long when;
39 final int dbgSource;
40 final int dbgType;
41 final int dbgId;
42 final int dbgSeverity;
43 final String dbgMsg;
44
45 /**
46 * @param source The source of the event
47 * @param when The time of the event
48 * @param dbgSource The ARB source
49 * @param dbgType The ARB type
50 * @param dbgId The ARB id
51 * @param dbgSeverity The ARB severity level
52 * @param dbgMsg The debug message
53 */
54 public GLDebugMessage(final GLContext source, final long when, final int dbgSource, final int dbgType, final int dbgId, final int dbgSeverity, final String dbgMsg) {
55 this.source = source;
56 this.when = when;
57 this.dbgSource = dbgSource;
58 this.dbgType = dbgType;
59 this.dbgId = dbgId;
60 this.dbgSeverity = dbgSeverity;
61 this.dbgMsg = dbgMsg;
62 }
63
64 /**
65 *
66 * @param source
67 * @param when
68 * @param dbgId
69 * @param amdDbgCategory
70 * @param dbgSeverity AMD severity level equals ARB severity level (value and semantic)
71 * @param dbgMsg
72 * @return
73 */
74 public static GLDebugMessage translateAMDEvent(final GLContext source, final long when, final int dbgId, final int amdDbgCategory, final int dbgSeverity, final String dbgMsg) {
75 int dbgSource, dbgType;
76
77 // AMD category == ARB source/type
78 switch(amdDbgCategory) {
80 dbgSource = GL2ES2.GL_DEBUG_SOURCE_API;
82 break;
83
84 //
85 // def source / other type
86 //
87
91 break;
92
96 break;
97
100 dbgType = GL2ES2.GL_DEBUG_TYPE_OTHER;
101 break;
102
103
104 //
105 // other source / def type
106 //
107
109 dbgSource = GL2ES2.GL_DEBUG_SOURCE_OTHER;
111 break;
112
114 dbgSource = GL2ES2.GL_DEBUG_SOURCE_OTHER;
116 break;
117
119 dbgSource = GL2ES2.GL_DEBUG_SOURCE_OTHER;
121 break;
122
124 default:
125 dbgSource = GL2ES2.GL_DEBUG_SOURCE_OTHER;
126 dbgType = GL2ES2.GL_DEBUG_TYPE_OTHER;
127 }
128
129 return new GLDebugMessage(source, when, dbgSource, dbgType, dbgId, dbgSeverity, dbgMsg);
130 }
131
132 public static int translateARB2AMDCategory(final int dbgSource, final int dbgType) {
133 switch (dbgSource) {
136
139
142 }
143
144 switch(dbgType) {
147
150
153 }
154
156 }
157
159 return source;
160 }
161
162 public long getWhen() {
163 return when;
164 }
165
166 public int getDbgSource() {
167 return dbgSource;
168 }
169
170 public int getDbgType() {
171 return dbgType;
172 }
173
174 public int getDbgId() {
175 return dbgId;
176 }
177
178 public int getDbgSeverity() {
179 return dbgSeverity;
180 }
181
182 public String getDbgMsg() {
183 return dbgMsg;
184 }
185
186 public StringBuilder toString(StringBuilder sb) {
187 final String crtab = Platform.getNewline()+"\t";
188 if(null==sb) {
189 sb = new StringBuilder();
190 }
191 sb.append("GLDebugEvent[ id ");
192 toHexString(sb, dbgId)
193 .append(crtab).append("type ").append(getDbgTypeString(dbgType))
194 .append(crtab).append("severity ").append(getDbgSeverityString(dbgSeverity))
195 .append(crtab).append("source ").append(getDbgSourceString(dbgSource))
196 .append(crtab).append("msg ").append(dbgMsg)
197 .append(crtab).append("when ").append(when);
198 if(null != source) {
199 sb.append(crtab).append("source ").append(source.getGLVersion()).append(" - hash 0x").append(Integer.toHexString(source.hashCode()));
200 }
201 sb.append("]");
202 return sb;
203 }
204
205 @Override
206 public String toString() {
207 return toString(null).toString();
208 }
209
210 public static String getDbgSourceString(final int dbgSource) {
211 switch(dbgSource) {
212 case GL2ES2.GL_DEBUG_SOURCE_API: return "GL API";
213 case GL2ES2.GL_DEBUG_SOURCE_SHADER_COMPILER: return "GLSL or extension compiler";
214 case GL2ES2.GL_DEBUG_SOURCE_WINDOW_SYSTEM: return "Native Windowing binding";
215 case GL2ES2.GL_DEBUG_SOURCE_THIRD_PARTY: return "Third party";
216 case GL2ES2.GL_DEBUG_SOURCE_APPLICATION: return "Application";
217 case GL2ES2.GL_DEBUG_SOURCE_OTHER: return "generic";
218 default: return "Unknown (" + toHexString(dbgSource) + ")";
219 }
220 }
221
222 public static String getDbgTypeString(final int dbgType) {
223 switch(dbgType) {
224 case GL2ES2.GL_DEBUG_TYPE_ERROR: return "Error";
225 case GL2ES2.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: return "Warning: marked for deprecation";
226 case GL2ES2.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: return "Warning: undefined behavior";
227 case GL2ES2.GL_DEBUG_TYPE_PERFORMANCE: return "Warning: implementation dependent performance";
228 case GL2ES2.GL_DEBUG_TYPE_PORTABILITY: return "Warning: vendor-specific extension use";
229 case GL2ES2.GL_DEBUG_TYPE_OTHER: return "Warning: generic";
230 default: return "Unknown (" + toHexString(dbgType) + ")";
231 }
232 }
233
234 public static String getDbgSeverityString(final int dbgSeverity) {
235 switch(dbgSeverity) {
236 case GL2ES2.GL_DEBUG_SEVERITY_HIGH: return "High: dangerous undefined behavior";
237 case GL2ES2.GL_DEBUG_SEVERITY_MEDIUM: return "Medium: Severe performance/deprecation/other warnings";
238 case GL2ES2.GL_DEBUG_SEVERITY_LOW: return "Low: Performance warnings (redundancy/undefined)";
239 case GL4.GL_DEBUG_SEVERITY_NOTIFICATION: return "Notification: Informational messages";
240 default: return "Unknown (" + toHexString(dbgSeverity) + ")";
241 }
242 }
243
244 public static StringBuilder toHexString(StringBuilder sb, final int i) {
245 if(null==sb) {
246 sb = new StringBuilder();
247 }
248 return sb.append("0x").append(Integer.toHexString(i));
249 }
250 public static String toHexString(final int i) {
251 return "0x"+Integer.toHexString(i);
252 }
253
254}
Abstraction for an OpenGL rendering context.
Definition: GLContext.java:74
final String getGLVersion()
Returns a valid OpenGL version string, ie
Definition: GLContext.java:769
OpenGL debug message generated by the driver and delivered via GLDebugListener.
static String getDbgSeverityString(final int dbgSeverity)
static String getDbgTypeString(final int dbgType)
StringBuilder toString(StringBuilder sb)
static StringBuilder toHexString(StringBuilder sb, final int i)
static String toHexString(final int i)
static int translateARB2AMDCategory(final int dbgSource, final int dbgType)
static String getDbgSourceString(final int dbgSource)
static GLDebugMessage translateAMDEvent(final GLContext source, final long when, final int dbgId, final int amdDbgCategory, final int dbgSeverity, final String dbgMsg)
GLDebugMessage(final GLContext source, final long when, final int dbgSource, final int dbgType, final int dbgId, final int dbgSeverity, final String dbgMsg)
static final int GL_DEBUG_SOURCE_APPLICATION
GL_KHR_debug, GL_ES_VERSION_3_2, GL_VERSION_4_3, GL_KHR_debug, GL_ARB_debug_output Alias for: GL_DEBU...
Definition: GL2ES2.java:550
static final int GL_DEBUG_SEVERITY_NOTIFICATION
GL_KHR_debug, GL_ES_VERSION_3_2, GL_VERSION_4_3, GL_KHR_debug Alias for: GL_DEBUG_SEVERITY_NOTIFICATI...
Definition: GL2ES2.java:225
static final int GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR
GL_KHR_debug, GL_ES_VERSION_3_2, GL_VERSION_4_3, GL_ARB_debug_output, GL_KHR_debug Alias for: GL_DEBU...
Definition: GL2ES2.java:314
static final int GL_DEBUG_TYPE_OTHER
GL_KHR_debug, GL_ES_VERSION_3_2, GL_VERSION_4_3, GL_ARB_debug_output, GL_KHR_debug Alias for: GL_DEBU...
Definition: GL2ES2.java:262
static final int GL_DEBUG_SOURCE_WINDOW_SYSTEM
GL_KHR_debug, GL_ES_VERSION_3_2, GL_VERSION_4_3, GL_ARB_debug_output, GL_KHR_debug Alias for: GL_DEBU...
Definition: GL2ES2.java:67
static final int GL_DEBUG_TYPE_ERROR
GL_KHR_debug, GL_ES_VERSION_3_2, GL_VERSION_4_3, GL_ARB_debug_output, GL_KHR_debug Alias for: GL_DEBU...
Definition: GL2ES2.java:333
static final int GL_DEBUG_SEVERITY_MEDIUM
GL_KHR_debug, GL_ES_VERSION_3_2, GL_VERSION_4_3, GL_KHR_debug, GL_ARB_debug_output,...
Definition: GL2ES2.java:576
static final int GL_DEBUG_SOURCE_SHADER_COMPILER
GL_KHR_debug, GL_ES_VERSION_3_2, GL_VERSION_4_3, GL_ARB_debug_output, GL_KHR_debug Alias for: GL_DEBU...
Definition: GL2ES2.java:222
static final int GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR
GL_KHR_debug, GL_ES_VERSION_3_2, GL_VERSION_4_3, GL_KHR_debug, GL_ARB_debug_output Alias for: GL_DEBU...
Definition: GL2ES2.java:556
static final int GL_DEBUG_SOURCE_THIRD_PARTY
GL_KHR_debug, GL_ES_VERSION_3_2, GL_VERSION_4_3, GL_ARB_debug_output, GL_KHR_debug Alias for: GL_DEBU...
Definition: GL2ES2.java:474
static final int GL_DEBUG_SEVERITY_HIGH
GL_KHR_debug, GL_ES_VERSION_3_2, GL_VERSION_4_3, GL_ARB_debug_output, GL_KHR_debug,...
Definition: GL2ES2.java:187
static final int GL_DEBUG_SOURCE_OTHER
GL_KHR_debug, GL_ES_VERSION_3_2, GL_VERSION_4_3, GL_KHR_debug, GL_ARB_debug_output Alias for: GL_DEBU...
Definition: GL2ES2.java:93
static final int GL_DEBUG_TYPE_PORTABILITY
GL_KHR_debug, GL_ES_VERSION_3_2, GL_VERSION_4_3, GL_ARB_debug_output, GL_KHR_debug Alias for: GL_DEBU...
Definition: GL2ES2.java:319
static final int GL_DEBUG_SEVERITY_LOW
GL_KHR_debug, GL_ES_VERSION_3_2, GL_VERSION_4_3, GL_KHR_debug, GL_ARB_debug_output,...
Definition: GL2ES2.java:311
static final int GL_DEBUG_TYPE_PERFORMANCE
GL_KHR_debug, GL_ES_VERSION_3_2, GL_VERSION_4_3, GL_KHR_debug, GL_ARB_debug_output Alias for: GL_DEBU...
Definition: GL2ES2.java:526
static final int GL_DEBUG_SOURCE_API
GL_KHR_debug, GL_ES_VERSION_3_2, GL_VERSION_4_3, GL_ARB_debug_output, GL_KHR_debug Alias for: GL_DEBU...
Definition: GL2ES2.java:190
static final int GL_DEBUG_CATEGORY_DEPRECATION_AMD
GL_AMD_debug_output Define "GL_DEBUG_CATEGORY_DEPRECATION_AMD" with expression '0x914B',...
Definition: GL2GL3.java:385
static final int GL_DEBUG_CATEGORY_OTHER_AMD
GL_AMD_debug_output Define "GL_DEBUG_CATEGORY_OTHER_AMD" with expression '0x9150',...
Definition: GL2GL3.java:637
static final int GL_DEBUG_CATEGORY_PERFORMANCE_AMD
GL_AMD_debug_output Define "GL_DEBUG_CATEGORY_PERFORMANCE_AMD" with expression '0x914D',...
Definition: GL2GL3.java:500
static final int GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD
GL_AMD_debug_output Define "GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD" with expression '0x914C',...
Definition: GL2GL3.java:504
static final int GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD
GL_AMD_debug_output Define "GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD" with expression '0x914E',...
Definition: GL2GL3.java:481
static final int GL_DEBUG_CATEGORY_APPLICATION_AMD
GL_AMD_debug_output Define "GL_DEBUG_CATEGORY_APPLICATION_AMD" with expression '0x914F',...
Definition: GL2GL3.java:359
static final int GL_DEBUG_CATEGORY_API_ERROR_AMD
GL_AMD_debug_output Define "GL_DEBUG_CATEGORY_API_ERROR_AMD" with expression '0x9149',...
Definition: GL2GL3.java:98
static final int GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD
GL_AMD_debug_output Define "GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD" with expression '0x914A',...
Definition: GL2GL3.java:246