Advertisement
Guest User

InitDebugContext

a guest
Dec 16th, 2015
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.47 KB | None | 0 0
  1. void InitDebugContext()
  2. {
  3.     // Set the debug output callback if the driver supports it.
  4.     FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 1"));
  5.     VERIFY_GL(__FUNCTION__);
  6.     FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 2"));
  7.     bool bDebugOutputInitialized = false;
  8.     FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 3"));
  9. #if !ENABLE_VERIFY_GL
  10.     FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 4"));
  11.     #if defined(GL_ARB_debug_output)
  12.     FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 5"));
  13.         if (glDebugMessageCallbackARB)
  14.         {
  15.             FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 6"));
  16.             // Synchronous output can slow things down, but we'll get better callstack if breaking in or crashing in the callback. This is debug only after all.
  17.             glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
  18.             FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 7"));
  19.             glDebugMessageCallbackARB(GLDEBUGPROCARB(OpenGLDebugMessageCallbackARB), /*UserParam=*/ NULL);
  20.             FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 8"));
  21.             bDebugOutputInitialized = (glGetError() == GL_NO_ERROR);
  22.             FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 9"));
  23.         }
  24.     #elif defined(GL_KHR_debug)
  25.     FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 10"));
  26.         // OpenGLES names the debug functions differently, but they behave the same
  27.         if (glDebugMessageCallbackKHR)
  28.         {
  29.             FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 11"));
  30.             glDebugMessageCallbackKHR(GLDEBUGPROCKHR(OpenGLDebugMessageCallbackARB), /*UserParam=*/ NULL);
  31.             FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 12"));
  32.             bDebugOutputInitialized = (glGetError() == GL_NO_ERROR);
  33.             FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 13"));
  34.         }
  35.     #endif // GL_ARB_debug_output / GL_KHR_debug
  36.         FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 14"));
  37.     #if defined(GL_AMD_debug_output)
  38.         FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 15"));
  39.         if (glDebugMessageCallbackAMD && !bDebugOutputInitialized)
  40.         {
  41.             FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 16"));
  42.             glDebugMessageCallbackAMD(OpenGLDebugMessageCallbackAMD, /*UserParam=*/ NULL);
  43.             FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 17"));
  44.             bDebugOutputInitialized = (glGetError() == GL_NO_ERROR);
  45.             FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 18"));
  46.         }
  47.     #endif // GL_AMD_debug_output
  48.         FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 19"));
  49. #endif // !ENABLE_VERIFY_GL
  50.         FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 20"));
  51.     if (!bDebugOutputInitialized && !PLATFORM_MAC)
  52.     {
  53.         FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 21"));
  54.         UE_LOG(LogRHI,Warning,TEXT("OpenGL debug output extension not supported!"));
  55.     }
  56.     FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 22"));
  57.     // this is to suppress feeding back of the debug markers and groups to the log, since those originate in the app anyways...
  58. #if ENABLE_OPENGL_DEBUG_GROUPS && GL_ARB_debug_output && GL_KHR_debug && !OPENGL_ES31
  59.     FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 23"));
  60.     if(glDebugMessageControlARB && bDebugOutputInitialized)
  61.     {
  62.         FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 24"));
  63.         glDebugMessageControlARB(GL_DEBUG_SOURCE_APPLICATION_ARB, GL_DEBUG_TYPE_MARKER, GL_DONT_CARE, 0, NULL, GL_FALSE);
  64.         FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 25"));
  65.         glDebugMessageControlARB(GL_DEBUG_SOURCE_APPLICATION_ARB, GL_DEBUG_TYPE_PUSH_GROUP, GL_DONT_CARE, 0, NULL, GL_FALSE);
  66.         FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 26"));
  67.         glDebugMessageControlARB(GL_DEBUG_SOURCE_APPLICATION_ARB, GL_DEBUG_TYPE_POP_GROUP, GL_DONT_CARE, 0, NULL, GL_FALSE);
  68.         FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 27"));
  69. #ifdef GL_KHR_debug
  70.         FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 28"));
  71.         glDebugMessageControlARB(GL_DEBUG_SOURCE_API_ARB, GL_DEBUG_TYPE_OTHER_ARB, GL_DEBUG_SEVERITY_NOTIFICATION, 0, NULL, GL_FALSE);
  72.         FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 29"));
  73. #endif
  74.         UE_LOG(LogRHI,Verbose,TEXT("disabling reporting back of debug groups and markers to the OpenGL debug output callback"));
  75.         FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 30"));
  76.     }
  77.     FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 31"));
  78. #elif ENABLE_OPENGL_DEBUG_GROUPS && !defined(GL_ARB_debug_output) && GL_KHR_debug
  79.     FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 32"));
  80.     if(glDebugMessageControlKHR)
  81.     {
  82.         FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 33"));
  83.         glDebugMessageControlKHR(GL_DEBUG_SOURCE_APPLICATION_KHR, GL_DEBUG_TYPE_MARKER, GL_DONT_CARE, 0, NULL, GL_FALSE);
  84.         FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 34"));
  85.         glDebugMessageControlKHR(GL_DEBUG_SOURCE_APPLICATION_KHR, GL_DEBUG_TYPE_PUSH_GROUP, GL_DONT_CARE, 0, NULL, GL_FALSE);
  86.         FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 35"));
  87.         glDebugMessageControlKHR(GL_DEBUG_SOURCE_APPLICATION_KHR, GL_DEBUG_TYPE_POP_GROUP, GL_DONT_CARE, 0, NULL, GL_FALSE);
  88.         FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 36"));
  89.         glDebugMessageControlKHR(GL_DEBUG_SOURCE_API_KHR, GL_DEBUG_TYPE_OTHER_KHR, GL_DEBUG_SEVERITY_NOTIFICATION, 0, NULL, GL_FALSE);
  90.         FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 37"));
  91.         UE_LOG(LogRHI,Verbose,TEXT("disabling reporting back of debug groups and markers to the OpenGL debug output callback"));
  92.         FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 38"));
  93.     }
  94.     FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 39"));
  95. #endif
  96.     FPlatformMisc::LowLevelOutputDebugString(TEXT("Debug 40"));
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement