gfxGLCardProfiler.cpp
Engine/source/gfx/gl/gfxGLCardProfiler.cpp
Detailed Description
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#include "gfx/gl/gfxGLCardProfiler.h" 25#include "gfx/gl/gfxGLDevice.h" 26#include "gfx/gl/gfxGLEnumTranslate.h" 27 28void GFXGLCardProfiler::init() 29{ 30 mChipSet = reinterpret_cast<const char*>(glGetString(GL_VENDOR)); 31 mRendererString = "OpenGL"; 32 mCardDescription = reinterpret_cast<const char*>(glGetString(GL_RENDERER)); 33 mVersionString = reinterpret_cast<const char*>(glGetString(GL_VERSION)); 34 mVideoMemory = static_cast<GFXGLDevice*>(GFX)->getTotalVideoMemory(); 35 36 Parent::init(); 37} 38 39void GFXGLCardProfiler::setupCardCapabilities() 40{ 41 GLint maxTexSize; 42 glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTexSize); 43 44 // OpenGL doesn't have separate maximum width/height. 45 setCapability("maxTextureWidth", maxTexSize); 46 setCapability("maxTextureHeight", maxTexSize); 47 setCapability("maxTextureSize", maxTexSize); 48 49 // Check for anisotropic filtering support. 50 setCapability("GL_EXT_texture_filter_anisotropic", gglHasExtension(EXT_texture_filter_anisotropic)); 51 52 // Check for buffer storage 53#ifdef TORQUE_NSIGHT_WORKAROUND 54 setCapability("GL_ARB_buffer_storage", false); 55#else 56 setCapability("GL_ARB_buffer_storage", gglHasExtension(ARB_buffer_storage)); 57#endif 58 59 // Check for texture storage 60 setCapability("GL_ARB_texture_storage", gglHasExtension(ARB_texture_storage)); 61 62 // Check for copy image support 63 setCapability("GL_ARB_copy_image", gglHasExtension(ARB_copy_image)); 64 65 // Check for vertex attrib binding 66 setCapability("GL_ARB_vertex_attrib_binding", gglHasExtension(ARB_vertex_attrib_binding)); 67 68 //check for KHR debug 69 setCapability("GL_KHR_debug", gglHasExtension(KHR_debug)); 70 71 //check for KHR debug 72 setCapability("GL_EXT_debug_marker", gglHasExtension(EXT_debug_marker)); 73 74} 75 76bool GFXGLCardProfiler::_queryCardCap(const String& query, U32& foundResult) 77{ 78 // Just doing what the D3D11 layer does 79 return 0; 80} 81 82bool GFXGLCardProfiler::_queryFormat(const GFXFormat fmt, const GFXTextureProfile *profile, bool &inOutAutogenMips) 83{ 84 // We assume if the format is valid that we can use it for any purpose. 85 // This may not be the case, but we have no way to check short of in depth 86 // testing of every format for every purpose. And by testing, I mean sitting 87 // down and doing it by hand, because there is no OpenGL API to check these 88 // things. 89 return GFXGLTextureInternalFormat[fmt] != GL_ZERO; 90} 91