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 29 using tcu::TestLog; 30 using tcu::toHex; 31 32 namespace glu 33 { 34 35 CallLogWrapper::CallLogWrapper (const glw::Functions& gl, tcu::TestLog& log) 36 : m_gl (gl) 37 , m_log (log) 38 , m_enableLog (false) 39 { 40 } 41 42 CallLogWrapper::~CallLogWrapper (void) 43 { 44 } 45 46 template <typename T> 47 inline tcu::Format::ArrayPointer<T> getPointerStr (const T* arr, deUint32 size) 48 { 49 return tcu::formatArray(arr, (int)size); 50 } 51 52 template <typename T> 53 inline tcu::Format::ArrayPointer<T> getPointerStr (const T* arr, int size) 54 { 55 return tcu::formatArray(arr, de::max(size, 0)); 56 } 57 58 // String formatter. 59 60 class StringFmt 61 { 62 public: 63 const glw::GLchar* str; 64 StringFmt (const glw::GLchar* str_) : str(str_) {} 65 }; 66 67 inline std::ostream& operator<< (std::ostream& str, StringFmt fmt) 68 { 69 return str << (fmt.str ? (const char*)fmt.str : "NULL"); 70 } 71 72 inline StringFmt getStringStr (const char* value) { return StringFmt(value); } 73 inline StringFmt getStringStr (const glw::GLubyte* value) { return StringFmt((const char*)value); } 74 75 // Framebuffer parameter pointer formatter. 76 77 class FboParamPtrFmt 78 { 79 public: 80 deUint32 param; 81 const int* value; 82 83 FboParamPtrFmt (deUint32 param_, const int* value_) : param(param_), value(value_) {} 84 }; 85 86 std::ostream& operator<< (std::ostream& str, FboParamPtrFmt fmt) 87 { 88 if (fmt.value) 89 { 90 switch (fmt.param) 91 { 92 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: 93 return str << tcu::Format::Enum<int, 2>(getFramebufferAttachmentTypeName, *fmt.value); 94 95 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: 96 return str << tcu::Format::Enum<int, 2>(getCubeMapFaceName, *fmt.value); 97 98 case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: 99 return str << tcu::Format::Enum<int, 2>(getTypeName, *fmt.value); 100 101 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: 102 return str << tcu::Format::Enum<int, 2>(getFramebufferColorEncodingName, *fmt.value); 103 104 case GL_FRAMEBUFFER_ATTACHMENT_LAYERED: 105 return str << tcu::Format::Enum<int, 2>(getBooleanName, *fmt.value); 106 107 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: 108 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER: 109 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: 110 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: 111 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: 112 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: 113 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: 114 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: 115 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: 116 return str << *fmt.value; 117 118 default: 119 return str << tcu::toHex(*fmt.value); 120 } 121 } 122 else 123 return str << "(null)"; 124 } 125 126 inline FboParamPtrFmt getFramebufferAttachmentParameterValueStr (deUint32 param, const int* value) 127 { 128 return FboParamPtrFmt(param, value); 129 } 130 131 #include "gluQueryUtil.inl" 132 #include "gluCallLogUtil.inl" 133 134 // API entry-point implementations are auto-generated 135 #include "gluCallLogWrapper.inl" 136 137 } // glu 138