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 | |
| 24 | namespace android { |
| 25 | namespace uirenderer { |
| 26 | |
Chris Craik | 5686bae | 2015-06-23 10:33:46 -0700 | [diff] [blame] | 27 | bool GLUtils::dumpGLErrors() { |
| 28 | bool errorObserved = false; |
Chris Craik | e4aa95e | 2014-05-08 13:57:05 -0700 | [diff] [blame] | 29 | GLenum status = GL_NO_ERROR; |
| 30 | while ((status = glGetError()) != GL_NO_ERROR) { |
Chris Craik | 5686bae | 2015-06-23 10:33:46 -0700 | [diff] [blame] | 31 | errorObserved = true; |
Chris Craik | e4aa95e | 2014-05-08 13:57:05 -0700 | [diff] [blame] | 32 | switch (status) { |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 33 | case GL_INVALID_ENUM: |
| 34 | ALOGE("GL error: GL_INVALID_ENUM"); |
| 35 | break; |
| 36 | case GL_INVALID_VALUE: |
| 37 | ALOGE("GL error: GL_INVALID_VALUE"); |
| 38 | break; |
| 39 | case GL_INVALID_OPERATION: |
| 40 | ALOGE("GL error: GL_INVALID_OPERATION"); |
| 41 | break; |
| 42 | case GL_OUT_OF_MEMORY: |
| 43 | ALOGE("GL error: Out of memory!"); |
| 44 | break; |
| 45 | default: |
| 46 | ALOGE("GL error: 0x%x", status); |
Chris Craik | e4aa95e | 2014-05-08 13:57:05 -0700 | [diff] [blame] | 47 | } |
| 48 | } |
Chris Craik | 5686bae | 2015-06-23 10:33:46 -0700 | [diff] [blame] | 49 | return errorObserved; |
Chris Craik | e4aa95e | 2014-05-08 13:57:05 -0700 | [diff] [blame] | 50 | } |
| 51 | |
Stan Iliev | 11606ff | 2018-09-17 14:01:16 -0400 | [diff] [blame] | 52 | const char* GLUtils::getGLFramebufferError() { |
| 53 | switch (glCheckFramebufferStatus(GL_FRAMEBUFFER)) { |
| 54 | case GL_FRAMEBUFFER_COMPLETE: |
| 55 | return "GL_FRAMEBUFFER_COMPLETE"; |
| 56 | case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: |
| 57 | return "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT"; |
| 58 | case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: |
| 59 | return "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT"; |
| 60 | case GL_FRAMEBUFFER_UNSUPPORTED: |
| 61 | return "GL_FRAMEBUFFER_UNSUPPORTED"; |
| 62 | case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS: |
| 63 | return "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS"; |
| 64 | default: |
| 65 | return "Unknown error"; |
| 66 | } |
| 67 | } |
| 68 | |
Chris Blume | 7b8a808 | 2018-11-30 15:51:58 -0800 | [diff] [blame] | 69 | } // namespace uirenderer |
| 70 | } // namespace android |