gfxCardProfile.h
Engine/source/gfx/gfxCardProfile.h
Classes:
class
GFXCardProfiler provides a device independent wrapper around both the capabilities reported by the card/drivers and the exceptions recorded in various scripts.
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#ifndef _GFXCARDPROFILE_H_ 25#define _GFXCARDPROFILE_H_ 26 27#ifndef _TDICTIONARY_H_ 28#include "core/util/tDictionary.h" 29#endif 30#ifndef _GFXDEVICE_H_ 31#include "gfx/gfxDevice.h" 32#endif 33#ifndef _TORQUE_STRING_H_ 34#include "core/util/str.h" 35#endif 36 37 38/// GFXCardProfiler provides a device independent wrapper around both the 39/// capabilities reported by the card/drivers and the exceptions recorded 40/// in various scripts. 41/// 42/// See the Torque Scripting Manual for more details. 43/// 44class GFXCardProfiler 45{ 46 /// @name icpi Internal Card Profile Interface 47 /// 48 /// This is the interface implemented by subclasses of this class in order 49 /// to provide implementation-specific information about the current 50 /// card/drivers. 51 /// 52 /// Basically, the implementation needs to provide some unique strings: 53 /// - mVersionString indicating the current driver version of the 54 /// card in question. (For instance, "53.36") 55 /// - mCardDescription indicating the name of the card ("Radeon 8500") 56 /// - getRendererString() indicating the name of the renderer ("DX9", "GL1.2"). 57 /// Each card profiler subclass must return a unique constant so we can keep 58 /// data separate. Bear in mind that punctuation is stripped from filenames. 59 /// 60 /// The profiler also needs to implement setupCardCapabilities(), which is responsible 61 /// for querying the active device and setting defaults based on the reported capabilities, 62 /// and _queryCardCap, which is responsible for recognizing and responding to 63 /// device-specific capability queries. 64 /// 65 /// @{ 66 67public: 68 69 /// 70 const String &getVersionString() const { return mVersionString; } 71 const String &getCardString() const { return mCardDescription; } 72 const String &getChipString() const { return mChipSet; } 73 U32 getVideoMemoryInMB() const { return mVideoMemory; } 74 75 virtual const String &getRendererString() const = 0; 76 77protected: 78 79 String mVersionString; 80 String mCardDescription; 81 String mChipSet; 82 U32 mVideoMemory; 83 84 virtual void setupCardCapabilities()=0; 85 86 /// Implementation specific query code. 87 /// 88 /// This function is meant to be overridden by the specific implementation class. 89 /// 90 /// Some query strings are handled by the external implementation while others must 91 /// be done by the specific implementation. This is given first chance to return 92 /// a result, then the generic rules are applied. 93 /// 94 /// @param query Capability being queried. 95 /// @param foundResult Result to return to the caller. If the function returns true 96 /// then this value is returned as the result of the query. 97 virtual bool _queryCardCap(const String &query, U32 &foundResult)=0; 98 99 virtual bool _queryFormat( const GFXFormat fmt, const GFXTextureProfile *profile, bool &inOutAutogenMips ) = 0; 100 /// @} 101 102 /// @name helpergroup Helper Functions 103 /// 104 /// Various helper functions. 105 106 /// Load a specified script file from the profiles directory, if it exists. 107 void loadProfileScript(const char* scriptName); 108 109 /// Load the script files in order for the specified card profile tuple. 110 void loadProfileScripts(const String& render, const String& vendor, const String& card, const String& version); 111 112 String strippedString(const char*string); 113 114 /// @} 115 116 /// Capability dictionary. 117 Map<String, U32> mCapDictionary; 118 119public: 120 121 /// @name ecpi External Card Profile Interface 122 /// 123 /// @{ 124 125 /// Called for a profile for a given device. 126 GFXCardProfiler(); 127 virtual ~GFXCardProfiler(); 128 129 /// Set load script files and generally initialize things. 130 virtual void init()=0; 131 132 /// Called to query a capability. Given a query string it returns a 133 /// bool indicating whether or not the capability holds. If you call 134 /// this and cap isn't recognized then it returns false and prints 135 /// a console error. 136 U32 queryProfile(const String &cap); 137 138 /// Same as queryProfile(), but a default can be specified to indicate 139 /// what value should be returned if the profiler doesn't know anything 140 /// about it. If cap is not recognized, defaultValue is returned and 141 /// no error is reported. 142 U32 queryProfile(const String &cap, U32 defaultValue); 143 144 /// Set the specified capability to the specified value. 145 void setCapability(const String &cap, U32 value); 146 147 /// Queries support for the specified texture format, and texture profile 148 bool checkFormat( const GFXFormat fmt, const GFXTextureProfile *profile, bool &inOutAutogenMips ); 149 150 /// @} 151}; 152 153#endif 154 155