huangcm
2025-02-24 69ed55dec4b2116a19e4cca4393cbc014fce5fb2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/*-------------------------------------------------------------------------
 * drawElements Quality Program OpenGL ES Utilities
 * ------------------------------------------------
 *
 * Copyright 2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 *//*!
 * \file
 * \brief OpenGL value to string utilities.
 *//*--------------------------------------------------------------------*/
 
#include "gluStrUtil.hpp"
#include "glwEnums.hpp"
 
namespace glu
{
 
namespace detail
{
 
std::ostream& operator<< (std::ostream& str, const BooleanPointerFmt& fmt)
{
   if (fmt.value)
   {
       str << "{ ";
       for (deUint32 ndx = 0; ndx < fmt.size; ndx++)
       {
           if (ndx != 0)
               str << ", ";
           str << getBooleanStr(fmt.value[ndx]);
       }
       str << " }";
       return str;
   }
   else
       return str << "(null)";
}
 
 
std::ostream& operator<< (std::ostream& str, const EnumPointerFmt& fmt)
{
   if (fmt.value)
   {
       str << "{ ";
       for (deUint32 ndx = 0; ndx < fmt.size; ndx++)
       {
           if (ndx != 0)
               str << ", ";
           // use storage size (4) as print width for clarity
           str << tcu::Format::Enum<int, 4>(fmt.getName, fmt.value[ndx]);
       }
       str << " }";
       return str;
   }
   else
       return str << "(null)";
}
 
std::ostream& operator<< (std::ostream& str, const TextureUnitStr& unitStr)
{
   int unitNdx = unitStr.texUnit - GL_TEXTURE0;
   if (unitNdx >= 0)
       return str << "GL_TEXTURE" << unitNdx;
   else
       return str << tcu::toHex(unitStr.texUnit);
}
 
std::ostream& operator<< (std::ostream& str, const TextureParameterValueStr& valueStr)
{
   switch (valueStr.param)
   {
       case GL_TEXTURE_WRAP_S:
       case GL_TEXTURE_WRAP_T:
       case GL_TEXTURE_WRAP_R:
           return str << getTextureWrapModeStr(valueStr.value);
 
       case GL_TEXTURE_BASE_LEVEL:
       case GL_TEXTURE_MAX_LEVEL:
       case GL_TEXTURE_MAX_LOD:
       case GL_TEXTURE_MIN_LOD:
           return str << valueStr.value;
 
       case GL_TEXTURE_COMPARE_MODE:
           return str << getTextureCompareModeStr(valueStr.value);
 
       case GL_TEXTURE_COMPARE_FUNC:
           return str << getCompareFuncStr(valueStr.value);
 
       case GL_TEXTURE_SWIZZLE_R:
       case GL_TEXTURE_SWIZZLE_G:
       case GL_TEXTURE_SWIZZLE_B:
       case GL_TEXTURE_SWIZZLE_A:
           return str << getTextureSwizzleStr(valueStr.value);
 
       case GL_TEXTURE_MIN_FILTER:
       case GL_TEXTURE_MAG_FILTER:
           return str << getTextureFilterStr(valueStr.value);
 
       case GL_DEPTH_STENCIL_TEXTURE_MODE:
           return str << getTextureDepthStencilModeStr(valueStr.value);
 
       default:
           return str << tcu::toHex(valueStr.value);
   }
}
 
} // detail
 
detail::EnumPointerFmt getInvalidateAttachmentStr (const deUint32* attachments, int numAttachments)
{
   return detail::EnumPointerFmt(attachments, (deUint32)numAttachments, getInvalidateAttachmentName);
}
 
std::ostream& operator<< (std::ostream& str, ApiType apiType)
{
   str << "OpenGL ";
 
   if (apiType.getProfile() == PROFILE_ES)
       str << "ES ";
 
   str << apiType.getMajorVersion() << "." << apiType.getMinorVersion();
 
   if (apiType.getProfile() == PROFILE_CORE)
       str << " core profile";
   else if (apiType.getProfile() == PROFILE_COMPATIBILITY)
       str << " compatibility profile";
   else if (apiType.getProfile() != PROFILE_ES)
       str << " (unknown profile)";
 
   return str;
}
 
std::ostream& operator<< (std::ostream& str, ContextType contextType)
{
   str << contextType.getAPI();
 
   if (contextType.getFlags() != ContextFlags(0))
   {
       static const struct
       {
           ContextFlags    flag;
           const char*        desc;
       } s_descs[] =
       {
           { CONTEXT_DEBUG,                "debug"                    },
           { CONTEXT_FORWARD_COMPATIBLE,    "forward-compatible"    },
           { CONTEXT_ROBUST,                "robust"                }
       };
       ContextFlags    flags    = contextType.getFlags();
 
       str << " (";
 
       for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_descs) && flags != 0; ndx++)
       {
           if ((flags & s_descs[ndx].flag) != 0)
           {
               if (flags != contextType.getFlags())
                   str << ", ";
 
               str << s_descs[ndx].desc;
               flags = flags & ~s_descs[ndx].flag;
           }
       }
 
       if (flags != 0)
       {
           // Unresolved
           if (flags != contextType.getFlags())
               str << ", ";
           str << tcu::toHex(flags);
       }
 
       str << ")";
   }
 
   return str;
}
 
#include "gluStrUtil.inl"
 
} // glu