Chris Craik | e4aa95e | 2014-05-08 13:57:05 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Chris Craik | e4aa95e | 2014-05-08 13:57:05 -0700 | [diff] [blame] | 17 | #include <GLES2/gl2.h> |
| 18 | #include <GLES2/gl2ext.h> |
| 19 | |
| 20 | #include <utils/Log.h> |
| 21 | |
| 22 | #include "GLUtils.h" |
| 23 | |
John Reck | 975591a | 2016-01-22 16:28:07 -0800 | [diff] [blame] | 24 | #if DEBUG_OPENGL >= DEBUG_LEVEL_HIGH && !defined(HWUI_GLES_WRAP_ENABLED) |
| 25 | #error Setting DEBUG_OPENGL to HIGH requires setting HWUI_ENABLE_OPENGL_VALIDATION to true in the Android.mk! |
| 26 | #endif |
| 27 | |
Chris Craik | e4aa95e | 2014-05-08 13:57:05 -0700 | [diff] [blame] | 28 | namespace android { |
| 29 | namespace uirenderer { |
| 30 | |
Chris Craik | 5686bae | 2015-06-23 10:33:46 -0700 | [diff] [blame] | 31 | bool GLUtils::dumpGLErrors() { |
John Reck | 975591a | 2016-01-22 16:28:07 -0800 | [diff] [blame] | 32 | #if DEBUG_OPENGL >= DEBUG_LEVEL_HIGH |
| 33 | // If DEBUG_LEVEL_HIGH is set then every GLES call is already wrapped |
| 34 | // and asserts that there was no error. So this can just return success. |
| 35 | return false; |
| 36 | #else |
Chris Craik | 5686bae | 2015-06-23 10:33:46 -0700 | [diff] [blame] | 37 | bool errorObserved = false; |
Chris Craik | e4aa95e | 2014-05-08 13:57:05 -0700 | [diff] [blame] | 38 | GLenum status = GL_NO_ERROR; |
| 39 | while ((status = glGetError()) != GL_NO_ERROR) { |
Chris Craik | 5686bae | 2015-06-23 10:33:46 -0700 | [diff] [blame] | 40 | errorObserved = true; |
Chris Craik | e4aa95e | 2014-05-08 13:57:05 -0700 | [diff] [blame] | 41 | switch (status) { |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame^] | 42 | case GL_INVALID_ENUM: |
| 43 | ALOGE("GL error: GL_INVALID_ENUM"); |
| 44 | break; |
| 45 | case GL_INVALID_VALUE: |
| 46 | ALOGE("GL error: GL_INVALID_VALUE"); |
| 47 | break; |
| 48 | case GL_INVALID_OPERATION: |
| 49 | ALOGE("GL error: GL_INVALID_OPERATION"); |
| 50 | break; |
| 51 | case GL_OUT_OF_MEMORY: |
| 52 | ALOGE("GL error: Out of memory!"); |
| 53 | break; |
| 54 | default: |
| 55 | ALOGE("GL error: 0x%x", status); |
Chris Craik | e4aa95e | 2014-05-08 13:57:05 -0700 | [diff] [blame] | 56 | } |
| 57 | } |
Chris Craik | 5686bae | 2015-06-23 10:33:46 -0700 | [diff] [blame] | 58 | return errorObserved; |
John Reck | 975591a | 2016-01-22 16:28:07 -0800 | [diff] [blame] | 59 | #endif |
Chris Craik | e4aa95e | 2014-05-08 13:57:05 -0700 | [diff] [blame] | 60 | } |
| 61 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame^] | 62 | }; // namespace uirenderer |
| 63 | }; // namespace android |