59 const GLchar *message,
62 if (
ELEM(type, GL_DEBUG_TYPE_PUSH_GROUP, GL_DEBUG_TYPE_POP_GROUP)) {
85 if (
ELEM(severity, GL_DEBUG_SEVERITY_LOW, GL_DEBUG_SEVERITY_NOTIFICATION)) {
87 const char *
format = use_color ?
"\033[2m%s\033[0m" :
"%s";
92 char debug_groups[512] =
"";
102 case GL_DEBUG_TYPE_ERROR:
103 case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
104 case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
107 case GL_DEBUG_TYPE_PORTABILITY:
108 case GL_DEBUG_TYPE_PERFORMANCE:
109 case GL_DEBUG_TYPE_OTHER:
110 case GL_DEBUG_TYPE_MARKER:
118 if (severity == GL_DEBUG_SEVERITY_HIGH) {
121 fprintf(stderr,
"\033[2m");
125 fprintf(stderr,
"\033[0m\n");
140 const char format[] =
"Successfully hooked OpenGL debug callback using %s";
142 if (epoxy_gl_version() >= 43 || epoxy_has_gl_extension(
"GL_KHR_debug")) {
143 SNPRINTF(msg,
format, epoxy_gl_version() >= 43 ?
"OpenGL 4.3" :
"KHR_debug extension");
144 glEnable(GL_DEBUG_OUTPUT);
145 glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
147 glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0,
nullptr, GL_TRUE);
148 glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION,
149 GL_DEBUG_TYPE_MARKER,
151 GL_DEBUG_SEVERITY_NOTIFICATION,
155 else if (epoxy_has_gl_extension(
"GL_ARB_debug_output")) {
157 glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
158 glDebugMessageCallbackARB((GLDEBUGPROCARB)
debug_callback,
nullptr);
159 glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0,
nullptr, GL_TRUE);
160 glDebugMessageInsertARB(GL_DEBUG_SOURCE_APPLICATION_ARB,
161 GL_DEBUG_TYPE_OTHER_ARB,
163 GL_DEBUG_SEVERITY_LOW_ARB,
168 CLOG_STR_WARN(&
LOG,
"Failed to hook OpenGL debug callback. Use fallback debug layer.");
225 uint16_t ubo_needed = interface->enabled_ubo_mask_;
229 uint16_t ssbo_needed = interface->enabled_ssbo_mask_;
230 ssbo_needed &= ~ctx->bound_ssbo_slots;
233 uint64_t tex_needed = interface->enabled_tex_mask_;
234 tex_needed &=
~GLContext::state_manager_active_get()->bound_texture_slots();
237 uint8_t ima_needed = interface->enabled_ima_mask_;
238 ima_needed &=
~GLContext::state_manager_active_get()->bound_image_slots();
240 if (ubo_needed == 0 && tex_needed == 0 && ima_needed == 0 && ssbo_needed == 0) {
244 for (
int i = 0; ubo_needed != 0; i++, ubo_needed >>= 1) {
245 if ((ubo_needed & 1) != 0) {
246 const ShaderInput *ubo_input = interface->ubo_get(i);
247 const char *ubo_name = interface->input_name_get(ubo_input);
250 SNPRINTF(msg,
"Missing UBO bind at slot %d : %s > %s : %s", i, sh_name, ubo_name, info);
251 debug_callback(0, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, 0, msg,
nullptr);
255 for (
int i = 0; ssbo_needed != 0; i++, ssbo_needed >>= 1) {
256 if ((ssbo_needed & 1) != 0) {
257 const ShaderInput *ssbo_input = interface->ssbo_get(i);
258 const char *ssbo_name = interface->input_name_get(ssbo_input);
261 SNPRINTF(msg,
"Missing SSBO bind at slot %d : %s > %s : %s", i, sh_name, ssbo_name, info);
262 debug_callback(0, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, 0, msg,
nullptr);
266 for (
int i = 0; tex_needed != 0; i++, tex_needed >>= 1) {
267 if ((tex_needed & 1) != 0) {
270 const char *tex_name = interface->input_name_get(
tex_input);
273 SNPRINTF(msg,
"Missing Texture bind at slot %d : %s > %s : %s", i, sh_name, tex_name, info);
274 debug_callback(0, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, 0, msg,
nullptr);
278 for (
int i = 0; ima_needed != 0; i++, ima_needed >>= 1) {
279 if ((ima_needed & 1) != 0) {
282 const char *tex_name = interface->input_name_get(
tex_input);
285 SNPRINTF(msg,
"Missing Image bind at slot %d : %s > %s : %s", i, sh_name, tex_name, info);
286 debug_callback(0, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, 0, msg,
nullptr);
void void CLG_logf(const CLG_LogType *lg, enum CLG_Severity severity, const char *file_line, const char *fn, const char *format,...) _CLOG_ATTR_NONNULL(1
void * debug_capture_scope_create(const char *name) override
void debug_unbind_all_ubo() override
void debug_capture_end() override
bool debug_capture_begin(const char *title) override
uint16_t bound_ssbo_slots
void debug_group_begin(const char *name, int index) override
void debug_capture_scope_end(void *scope) override
void debug_group_end() override
bool debug_capture_scope_begin(void *scope) override
void debug_unbind_all_ssbo() override
static void tex_input(float *out, int num, bNodeStack *in, TexParams *params, short thread)