• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 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 
17 #ifndef COMMON_UTILS_H
18 #define COMMON_UTILS_H
19 
20 #include <math.h>
21 #include <string>
22 
23 #include <android/log.h>
24 
25 #include <GLES3/gl31.h>
26 #include <GLES3/gl3ext.h>
27 
28 #define LOG_TAG "GPUStressTestActivity"
29 #define  LOGI(...)  __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
30 #define  LOGE(...)  __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
31 
PrintGLError(...)32 inline void PrintGLError(...) {
33   __android_log_print(ANDROID_LOG_ERROR,LOG_TAG, "GL_ERROR");
34 }
35 
36 #ifdef LOG_GL_ERRORS
37 #define GL_CALL(call)                      \
38   {                                        \
39     call;                                  \
40     if (glGetError() != GL_NO_ERROR) {     \
41       PrintGLError();                      \
42     }                                      \
43   }
44 #else
45 #define GL_CALL(call)                      \
46   {                                        \
47     call;                                  \
48   }
49 #endif
50 
51 template <size_t size>
StripLambda(const char (& shader)[size])52 std::string StripLambda(const char(&shader)[size]) {
53   return std::string(shader + 6, shader + size - 2);
54 }
55 
56 #define SHADER0(Src) StripLambda(#Src)
57 
58 bool CompileShader(GLuint shader, const std::string& shader_string);
59 bool LinkProgram(GLuint program, GLuint vertex_shader, GLuint fragment_shader);
60 
61 // Converts from degrees to radians.
62 float DegToRad(float deg);
63 
64 GLenum GLCheckError();
65 GLenum GLCheckErrorStr(std::string str);
66 
67 #endif // COMMON_UTILS_H
68