xref: /aosp_15_r20/external/deqp/framework/opengl/gluDefs.hpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1*35238bceSAndroid Build Coastguard Worker #ifndef _GLUDEFS_HPP
2*35238bceSAndroid Build Coastguard Worker #define _GLUDEFS_HPP
3*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
4*35238bceSAndroid Build Coastguard Worker  * drawElements Quality Program OpenGL ES Utilities
5*35238bceSAndroid Build Coastguard Worker  * ------------------------------------------------
6*35238bceSAndroid Build Coastguard Worker  *
7*35238bceSAndroid Build Coastguard Worker  * Copyright 2014 The Android Open Source Project
8*35238bceSAndroid Build Coastguard Worker  *
9*35238bceSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
10*35238bceSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
11*35238bceSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
12*35238bceSAndroid Build Coastguard Worker  *
13*35238bceSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
14*35238bceSAndroid Build Coastguard Worker  *
15*35238bceSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
16*35238bceSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
17*35238bceSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18*35238bceSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
19*35238bceSAndroid Build Coastguard Worker  * limitations under the License.
20*35238bceSAndroid Build Coastguard Worker  *
21*35238bceSAndroid Build Coastguard Worker  *//*!
22*35238bceSAndroid Build Coastguard Worker  * \file
23*35238bceSAndroid Build Coastguard Worker  * \brief OpenGL ES Test Utility Library.
24*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
25*35238bceSAndroid Build Coastguard Worker 
26*35238bceSAndroid Build Coastguard Worker #include "tcuDefs.hpp"
27*35238bceSAndroid Build Coastguard Worker 
28*35238bceSAndroid Build Coastguard Worker // Macros for checking API errors.
29*35238bceSAndroid Build Coastguard Worker #define GLU_EXPECT_NO_ERROR(ERR, MSG) glu::checkError((ERR), MSG, __FILE__, __LINE__)
30*35238bceSAndroid Build Coastguard Worker #define GLU_CHECK_ERROR(ERR) GLU_EXPECT_NO_ERROR(ERR, DE_NULL)
31*35238bceSAndroid Build Coastguard Worker #define GLU_CHECK_MSG(MSG) GLU_EXPECT_NO_ERROR(glGetError(), MSG)
32*35238bceSAndroid Build Coastguard Worker #define GLU_CHECK() GLU_CHECK_MSG(DE_NULL)
33*35238bceSAndroid Build Coastguard Worker #define GLU_CHECK_CALL_ERROR(CALL, ERR)  \
34*35238bceSAndroid Build Coastguard Worker     do                                   \
35*35238bceSAndroid Build Coastguard Worker     {                                    \
36*35238bceSAndroid Build Coastguard Worker         CALL;                            \
37*35238bceSAndroid Build Coastguard Worker         GLU_EXPECT_NO_ERROR(ERR, #CALL); \
38*35238bceSAndroid Build Coastguard Worker     } while (false)
39*35238bceSAndroid Build Coastguard Worker #define GLU_CHECK_CALL(CALL)                      \
40*35238bceSAndroid Build Coastguard Worker     do                                            \
41*35238bceSAndroid Build Coastguard Worker     {                                             \
42*35238bceSAndroid Build Coastguard Worker         CALL;                                     \
43*35238bceSAndroid Build Coastguard Worker         GLU_EXPECT_NO_ERROR(glGetError(), #CALL); \
44*35238bceSAndroid Build Coastguard Worker     } while (false)
45*35238bceSAndroid Build Coastguard Worker 
46*35238bceSAndroid Build Coastguard Worker #define GLU_CHECK_GLW_MSG(GL, MSG) GLU_EXPECT_NO_ERROR((GL).getError(), MSG)
47*35238bceSAndroid Build Coastguard Worker #define GLU_CHECK_GLW(GL) GLU_CHECK_GLW_MSG(GL, DE_NULL)
48*35238bceSAndroid Build Coastguard Worker #define GLU_CHECK_GLW_CALL(GL, CALL)                 \
49*35238bceSAndroid Build Coastguard Worker     do                                               \
50*35238bceSAndroid Build Coastguard Worker     {                                                \
51*35238bceSAndroid Build Coastguard Worker         (GL).CALL;                                   \
52*35238bceSAndroid Build Coastguard Worker         GLU_EXPECT_NO_ERROR((GL).getError(), #CALL); \
53*35238bceSAndroid Build Coastguard Worker     } while (false)
54*35238bceSAndroid Build Coastguard Worker 
55*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*!
56*35238bceSAndroid Build Coastguard Worker  * \brief OpenGL (ES) utilities
57*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
58*35238bceSAndroid Build Coastguard Worker namespace glu
59*35238bceSAndroid Build Coastguard Worker {
60*35238bceSAndroid Build Coastguard Worker 
BufferOffsetAsPointer(uintptr_t byteOffset)61*35238bceSAndroid Build Coastguard Worker DE_INLINE void *BufferOffsetAsPointer(uintptr_t byteOffset)
62*35238bceSAndroid Build Coastguard Worker {
63*35238bceSAndroid Build Coastguard Worker     return reinterpret_cast<void *>(byteOffset);
64*35238bceSAndroid Build Coastguard Worker }
65*35238bceSAndroid Build Coastguard Worker 
66*35238bceSAndroid Build Coastguard Worker class RenderContext;
67*35238bceSAndroid Build Coastguard Worker 
68*35238bceSAndroid Build Coastguard Worker class Error : public tcu::TestError
69*35238bceSAndroid Build Coastguard Worker {
70*35238bceSAndroid Build Coastguard Worker public:
71*35238bceSAndroid Build Coastguard Worker     Error(int error, const char *message, const char *expr, const char *file, int line);
72*35238bceSAndroid Build Coastguard Worker     Error(int error, const std::string &message);
73*35238bceSAndroid Build Coastguard Worker     virtual ~Error(void) throw();
74*35238bceSAndroid Build Coastguard Worker 
getError(void) const75*35238bceSAndroid Build Coastguard Worker     int getError(void) const
76*35238bceSAndroid Build Coastguard Worker     {
77*35238bceSAndroid Build Coastguard Worker         return m_error;
78*35238bceSAndroid Build Coastguard Worker     }
79*35238bceSAndroid Build Coastguard Worker 
80*35238bceSAndroid Build Coastguard Worker private:
81*35238bceSAndroid Build Coastguard Worker     int m_error;
82*35238bceSAndroid Build Coastguard Worker };
83*35238bceSAndroid Build Coastguard Worker 
84*35238bceSAndroid Build Coastguard Worker class OutOfMemoryError : public tcu::ResourceError
85*35238bceSAndroid Build Coastguard Worker {
86*35238bceSAndroid Build Coastguard Worker public:
87*35238bceSAndroid Build Coastguard Worker     OutOfMemoryError(const char *message, const char *expr, const char *file, int line);
88*35238bceSAndroid Build Coastguard Worker     OutOfMemoryError(const std::string &message);
89*35238bceSAndroid Build Coastguard Worker     virtual ~OutOfMemoryError(void) throw();
90*35238bceSAndroid Build Coastguard Worker };
91*35238bceSAndroid Build Coastguard Worker 
92*35238bceSAndroid Build Coastguard Worker void checkError(uint32_t err, const char *msg, const char *file, int line);
93*35238bceSAndroid Build Coastguard Worker void checkError(const RenderContext &context, const char *msg, const char *file, int line);
94*35238bceSAndroid Build Coastguard Worker 
95*35238bceSAndroid Build Coastguard Worker } // namespace glu
96*35238bceSAndroid Build Coastguard Worker 
97*35238bceSAndroid Build Coastguard Worker #endif // _GLUDEFS_HPP
98