1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES Utilities
3 * ------------------------------------------------
5 * Copyright 2014 The Android Open Source Project
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 * \brief OpenGL value to string utilities.
22 *//*--------------------------------------------------------------------*/
24 #include "gluStrUtil.hpp"
25 #include "glwEnums.hpp"
33 std::ostream& operator<< (std::ostream& str, const BooleanPointerFmt& fmt)
38 for (deUint32 ndx = 0; ndx < fmt.size; ndx++)
42 str << getBooleanStr(fmt.value[ndx]);
48 return str << "(null)";
52 std::ostream& operator<< (std::ostream& str, const EnumPointerFmt& fmt)
57 for (deUint32 ndx = 0; ndx < fmt.size; ndx++)
61 // use storage size (4) as print width for clarity
62 str << tcu::Format::Enum<int, 4>(fmt.getName, fmt.value[ndx]);
68 return str << "(null)";
71 std::ostream& operator<< (std::ostream& str, const TextureUnitStr& unitStr)
73 int unitNdx = unitStr.texUnit - GL_TEXTURE0;
75 return str << "GL_TEXTURE" << unitNdx;
77 return str << tcu::toHex(unitStr.texUnit);
80 std::ostream& operator<< (std::ostream& str, const TextureParameterValueStr& valueStr)
82 switch (valueStr.param)
84 case GL_TEXTURE_WRAP_S:
85 case GL_TEXTURE_WRAP_T:
86 case GL_TEXTURE_WRAP_R:
87 return str << getTextureWrapModeStr(valueStr.value);
89 case GL_TEXTURE_BASE_LEVEL:
90 case GL_TEXTURE_MAX_LEVEL:
91 case GL_TEXTURE_MAX_LOD:
92 case GL_TEXTURE_MIN_LOD:
93 return str << valueStr.value;
95 case GL_TEXTURE_COMPARE_MODE:
96 return str << getTextureCompareModeStr(valueStr.value);
98 case GL_TEXTURE_COMPARE_FUNC:
99 return str << getCompareFuncStr(valueStr.value);
101 case GL_TEXTURE_SWIZZLE_R:
102 case GL_TEXTURE_SWIZZLE_G:
103 case GL_TEXTURE_SWIZZLE_B:
104 case GL_TEXTURE_SWIZZLE_A:
105 return str << getTextureSwizzleStr(valueStr.value);
107 case GL_TEXTURE_MIN_FILTER:
108 case GL_TEXTURE_MAG_FILTER:
109 return str << getTextureFilterStr(valueStr.value);
111 case GL_DEPTH_STENCIL_TEXTURE_MODE:
112 return str << getTextureDepthStencilModeStr(valueStr.value);
115 return str << tcu::toHex(valueStr.value);
121 detail::EnumPointerFmt getInvalidateAttachmentStr (const deUint32* attachments, int numAttachments)
123 return detail::EnumPointerFmt(attachments, (deUint32)numAttachments, getInvalidateAttachmentName);
126 std::ostream& operator<< (std::ostream& str, ApiType apiType)
130 if (apiType.getProfile() == PROFILE_ES)
133 str << apiType.getMajorVersion() << "." << apiType.getMinorVersion();
135 if (apiType.getProfile() == PROFILE_CORE)
136 str << " core profile";
137 else if (apiType.getProfile() == PROFILE_COMPATIBILITY)
138 str << " compatibility profile";
139 else if (apiType.getProfile() != PROFILE_ES)
140 str << " (unknown profile)";
145 std::ostream& operator<< (std::ostream& str, ContextType contextType)
147 str << contextType.getAPI();
149 if (contextType.getFlags() != ContextFlags(0))
157 { CONTEXT_DEBUG, "debug" },
158 { CONTEXT_FORWARD_COMPATIBLE, "forward-compatible" },
159 { CONTEXT_ROBUST, "robust" }
161 ContextFlags flags = contextType.getFlags();
165 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_descs) && flags != 0; ndx++)
167 if ((flags & s_descs[ndx].flag) != 0)
169 if (flags != contextType.getFlags())
172 str << s_descs[ndx].desc;
173 flags = flags & ~s_descs[ndx].flag;
180 if (flags != contextType.getFlags())
182 str << tcu::toHex(flags);
191 #include "gluStrUtil.inl"