Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "gpu/command_buffer/service/gl_utils.h" | 5 #include "gpu/command_buffer/service/gl_utils.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "gpu/command_buffer/common/capabilities.h" | 8 #include "gpu/command_buffer/common/capabilities.h" |
| 9 #include "gpu/command_buffer/service/feature_info.h" | 9 #include "gpu/command_buffer/service/feature_info.h" |
| 10 #include "ui/gl/gl_version_info.h" | 10 #include "ui/gl/gl_version_info.h" |
| 11 | 11 |
| 12 namespace gpu { | 12 namespace gpu { |
| 13 namespace gles2 { | 13 namespace gles2 { |
| 14 | 14 |
| 15 namespace { | |
| 16 const char* GetDebugSourceString(GLenum source) { | |
| 17 switch (source) { | |
| 18 case GL_DEBUG_SOURCE_API: | |
| 19 return "OpenGL"; | |
| 20 case GL_DEBUG_SOURCE_WINDOW_SYSTEM: | |
| 21 return "Windows"; | |
|
piman
2016/11/02 18:46:53
nit: "Window System" ?
Geoff Lang
2016/11/03 14:16:14
Done.
| |
| 22 case GL_DEBUG_SOURCE_SHADER_COMPILER: | |
| 23 return "Shader Compiler"; | |
| 24 case GL_DEBUG_SOURCE_THIRD_PARTY: | |
| 25 return "Third Party"; | |
| 26 case GL_DEBUG_SOURCE_APPLICATION: | |
| 27 return "Application"; | |
| 28 case GL_DEBUG_SOURCE_OTHER: | |
| 29 return "Other"; | |
| 30 default: | |
| 31 return "UNKNOWN"; | |
| 32 } | |
| 33 } | |
| 34 | |
| 35 const char* GetDebugTypeString(GLenum type) { | |
| 36 switch (type) { | |
| 37 case GL_DEBUG_TYPE_ERROR: | |
| 38 return "Error"; | |
| 39 case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: | |
| 40 return "Deprecated behavior"; | |
| 41 case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: | |
| 42 return "Undefined behavior"; | |
| 43 case GL_DEBUG_TYPE_PORTABILITY: | |
| 44 return "Portability"; | |
| 45 case GL_DEBUG_TYPE_PERFORMANCE: | |
| 46 return "Performance"; | |
| 47 case GL_DEBUG_TYPE_OTHER: | |
| 48 return "Other"; | |
| 49 case GL_DEBUG_TYPE_MARKER: | |
| 50 return "Marker"; | |
| 51 default: | |
| 52 return "UNKNOWN"; | |
| 53 } | |
| 54 } | |
| 55 | |
| 56 const char* GetDebugSeverityString(GLenum severity) { | |
| 57 switch (severity) { | |
| 58 case GL_DEBUG_SEVERITY_HIGH: | |
| 59 return "High"; | |
| 60 case GL_DEBUG_SEVERITY_MEDIUM: | |
| 61 return "Medium"; | |
| 62 case GL_DEBUG_SEVERITY_LOW: | |
| 63 return "Low"; | |
| 64 case GL_DEBUG_SEVERITY_NOTIFICATION: | |
| 65 return "Notification"; | |
| 66 default: | |
| 67 return "UNKNOWN"; | |
| 68 } | |
| 69 } | |
| 70 } | |
| 71 | |
| 15 std::vector<int> GetAllGLErrors() { | 72 std::vector<int> GetAllGLErrors() { |
| 16 int gl_errors[] = { | 73 int gl_errors[] = { |
| 17 GL_NO_ERROR, | 74 GL_NO_ERROR, |
| 18 GL_INVALID_ENUM, | 75 GL_INVALID_ENUM, |
| 19 GL_INVALID_VALUE, | 76 GL_INVALID_VALUE, |
| 20 GL_INVALID_OPERATION, | 77 GL_INVALID_OPERATION, |
| 21 GL_INVALID_FRAMEBUFFER_OPERATION, | 78 GL_INVALID_FRAMEBUFFER_OPERATION, |
| 22 GL_OUT_OF_MEMORY, | 79 GL_OUT_OF_MEMORY, |
| 23 }; | 80 }; |
| 24 return base::CustomHistogram::ArrayToCustomRanges(gl_errors, | 81 return base::CustomHistogram::ArrayToCustomRanges(gl_errors, |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 } | 234 } |
| 178 | 235 |
| 179 bool CheckUniqueAndNonNullIds(GLsizei n, const GLuint* client_ids) { | 236 bool CheckUniqueAndNonNullIds(GLsizei n, const GLuint* client_ids) { |
| 180 if (n <= 0) | 237 if (n <= 0) |
| 181 return true; | 238 return true; |
| 182 std::unordered_set<uint32_t> unique_ids(client_ids, client_ids + n); | 239 std::unordered_set<uint32_t> unique_ids(client_ids, client_ids + n); |
| 183 return (unique_ids.size() == static_cast<size_t>(n)) && | 240 return (unique_ids.size() == static_cast<size_t>(n)) && |
| 184 (unique_ids.find(0) == unique_ids.end()); | 241 (unique_ids.find(0) == unique_ids.end()); |
| 185 } | 242 } |
| 186 | 243 |
| 244 void APIENTRY LogGLDebugMessage(GLenum source, | |
| 245 GLenum type, | |
| 246 GLuint id, | |
| 247 GLenum severity, | |
| 248 GLsizei length, | |
| 249 const GLchar* message, | |
| 250 GLvoid* user_param) { | |
| 251 LOG(ERROR) << "GL Driver Message (" << GetDebugSourceString(source) << ", " | |
| 252 << GetDebugTypeString(type) << ", " << id << ", " | |
| 253 << GetDebugSeverityString(severity) << "): " << message; | |
| 254 } | |
| 255 | |
| 256 void InitializeGLDebugLogging() { | |
| 257 glEnable(GL_DEBUG_OUTPUT); | |
| 258 glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); | |
| 259 | |
| 260 // Enable logging of medium and high severity messages | |
| 261 glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_HIGH, 0, | |
| 262 nullptr, GL_TRUE); | |
| 263 glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_MEDIUM, 0, | |
| 264 nullptr, GL_TRUE); | |
| 265 glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_LOW, 0, | |
| 266 nullptr, GL_FALSE); | |
| 267 glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, | |
| 268 GL_DEBUG_SEVERITY_NOTIFICATION, 0, nullptr, GL_FALSE); | |
| 269 | |
| 270 glDebugMessageCallback(&LogGLDebugMessage, nullptr); | |
| 271 } | |
| 272 | |
| 187 } // namespace gles2 | 273 } // namespace gles2 |
| 188 } // namespace gpu | 274 } // namespace gpu |
| OLD | NEW |