1/*------------------------------------------------------------------------- 2 * drawElements Quality Program OpenGL ES Utilities 3 * ------------------------------------------------ 4 * 5 * Copyright 2014 The Android Open Source Project 6 * 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 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 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. 18 * 19 *//*! 20 * \file 21 * \brief GL call wrapper for logging. 22 *//*--------------------------------------------------------------------*/ 23 24#include "gluCallLogWrapper.hpp" 25#include "gluStrUtil.hpp" 26#include "glwFunctions.hpp" 27#include "glwEnums.hpp" 28 29using tcu::TestLog; 30using tcu::toHex; 31 32namespace glu 33{ 34 35CallLogWrapper::CallLogWrapper (const glw::Functions& gl, tcu::TestLog& log) 36 : m_gl (gl) 37 , m_log (log) 38 , m_enableLog (false) 39{ 40} 41 42CallLogWrapper::~CallLogWrapper (void) 43{ 44} 45 46template <typename T> 47inline tcu::Format::ArrayPointer<T> getPointerStr (const T* arr, deUint32 size) 48{ 49 return tcu::formatArray(arr, (int)size); 50} 51 52template <typename T> 53inline tcu::Format::ArrayPointer<T> getPointerStr (const T* arr, int size) 54{ 55 return tcu::formatArray(arr, de::max(size, 0)); 56} 57 58inline detail::EnumPointerFmt getEnumPointerStr (const deUint32* value, glw::GLsizei size, detail::EnumPointerFmt::GetEnumNameFunc getName) 59{ 60 return detail::EnumPointerFmt(value, (deUint32)de::max(0, size), getName); 61} 62 63// String formatter. 64 65class StringFmt 66{ 67public: 68 const glw::GLchar* str; 69 StringFmt (const glw::GLchar* str_) : str(str_) {} 70}; 71 72inline std::ostream& operator<< (std::ostream& str, StringFmt fmt) 73{ 74 return str << (fmt.str ? (const char*)fmt.str : "NULL"); 75} 76 77inline StringFmt getStringStr (const char* value) { return StringFmt(value); } 78inline StringFmt getStringStr (const glw::GLubyte* value) { return StringFmt((const char*)value); } 79 80// Framebuffer parameter pointer formatter. 81 82class FboParamPtrFmt 83{ 84public: 85 deUint32 param; 86 const int* value; 87 88 FboParamPtrFmt (deUint32 param_, const int* value_) : param(param_), value(value_) {} 89}; 90 91std::ostream& operator<< (std::ostream& str, FboParamPtrFmt fmt) 92{ 93 if (fmt.value) 94 { 95 switch (fmt.param) 96 { 97 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: 98 return str << tcu::Format::Enum(getFramebufferAttachmentTypeName, *fmt.value); 99 100 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: 101 return str << tcu::Format::Enum(getCubeMapFaceName, *fmt.value); 102 103 case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: 104 return str << tcu::Format::Enum(getTypeName, *fmt.value); 105 106 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: 107 return str << tcu::Format::Enum(getFramebufferColorEncodingName, *fmt.value); 108 109 case GL_FRAMEBUFFER_ATTACHMENT_LAYERED: 110 return str << tcu::Format::Enum(getBooleanName, *fmt.value); 111 112 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: 113 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER: 114 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: 115 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: 116 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: 117 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: 118 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: 119 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: 120 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: 121 return str << *fmt.value; 122 123 default: 124 return str << tcu::toHex(*fmt.value); 125 } 126 } 127 else 128 return str << "(null)"; 129} 130 131inline FboParamPtrFmt getFramebufferAttachmentParameterValueStr (deUint32 param, const int* value) 132{ 133 return FboParamPtrFmt(param, value); 134} 135 136// API entry-point implementations are auto-generated 137#include "gluCallLogWrapper.inl" 138 139} // glu 140