00001 /****************************************************************************\ 00002 Copyright (c) 2002, 2003 NVIDIA Corporation. 00003 00004 NVIDIA Corporation("NVIDIA") supplies this software to you in 00005 consideration of your agreement to the following terms, and your use, 00006 installation, modification or redistribution of this NVIDIA software 00007 constitutes acceptance of these terms. If you do not agree with these 00008 terms, please do not use, install, modify or redistribute this NVIDIA 00009 software. 00010 00011 In consideration of your agreement to abide by the following terms, and 00012 subject to these terms, NVIDIA grants you a personal, non-exclusive 00013 license, under NVIDIA's copyrights in this original NVIDIA software (the 00014 "NVIDIA Software"), to use, reproduce, modify and redistribute the 00015 NVIDIA Software, with or without modifications, in source and/or binary 00016 forms; provided that if you redistribute the NVIDIA Software, you must 00017 retain the copyright notice of NVIDIA, this notice and the following 00018 text and disclaimers in all such redistributions of the NVIDIA Software. 00019 Neither the name, trademarks, service marks nor logos of NVIDIA 00020 Corporation may be used to endorse or promote products derived from the 00021 NVIDIA Software without specific prior written permission from NVIDIA. 00022 Except as expressly stated in this notice, no other rights or licenses 00023 express or implied, are granted by NVIDIA herein, including but not 00024 limited to any patent rights that may be infringed by your derivative 00025 works or by other works in which the NVIDIA Software may be 00026 incorporated. No hardware is licensed hereunder. 00027 00028 THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT 00029 WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, 00030 INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, 00031 NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR 00032 ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER 00033 PRODUCTS. 00034 00035 IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, 00036 INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 00037 TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 00038 USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY 00039 OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE 00040 NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, 00041 TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF 00042 NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00043 \****************************************************************************/ 00044 00045 #ifndef _NVPMAPI_INT_H_ 00046 #define _NVPMAPI_INT_H_ 00047 00048 #ifdef __cplusplus 00049 extern "C" { 00050 #endif 00051 //----------------------------------------------------------------------------- 00052 // NVIDIA Performance Monitoring (PM) API, 00053 // Interface to NVIDIA Graphics Performance Data Gathering 00054 // ------------------------------------------------------- 00055 //----------------------------------------------------------------------------- 00056 00057 typedef unsigned int UINT; 00058 typedef unsigned long long UINT64; 00059 00060 #define NVPM_INFINITE_VAL 0xFFFFFFFFFFFFFFFF 00061 00062 #ifndef NVPMRESULT_DEFINED 00063 typedef enum { 00064 NVPM_OK, 00065 NVPM_ERROR_INVALID_PARAMETER, 00066 NVPM_ERROR_DRIVER_MISMATCH, 00067 NVPM_ERROR_NOT_INITIALIZED, 00068 NVPM_ERROR_BAD_ENUMERATOR, 00069 NVPM_ERROR_STRING_TOO_SMALL, 00070 NVPM_ERROR_INVALID_COUNTER, 00071 NVPM_ERROR_OUT_OF_MEMORY, 00072 NVPM_ERROR_NOT_IN_EXPERIMENT, 00073 NVPM_ERROR_EXPERIMENT_INCOMPLETE, 00074 NVPM_ERROR_INVALID_PASS, 00075 NVPM_ERROR_NOT_IN_PASS, 00076 NVPM_ERROR_IN_PASS, 00077 NVPM_ERROR_NOT_IN_OBJECT, 00078 NVPM_ERROR_IN_OBJECT, 00079 NVPM_ERROR_INVALID_OBJECT, 00080 NVPM_ERROR_COUNTER_NOT_ENABLED, 00081 NVPM_ERROR_COUNTER_NOT_FOUND, 00082 NVPM_ERROR_EXPERIMENT_NOT_RUN, 00083 NVPM_ERROR_EXPERIMENT_RUNNING, 00084 NVPM_ERROR_32BIT_ON_64BIT, 00085 NVPM_ERROR_INTERNAL, 00086 } NVPMRESULT; 00087 #define NVPMRESULT_DEFINED 00088 #endif 00089 00090 #ifdef NVPMAPI_INTERFACE 00091 #undef NVPMAPI_INTERFACE 00092 #endif 00093 00094 #ifdef _WIN32 00095 #define NVPMAPI_INTERFACE extern NVPMRESULT __cdecl 00096 #else 00097 #define NVPMAPI_INTERFACE extern NVPMRESULT 00098 #endif 00099 00100 // Initialize the NVPMAPI system 00101 NVPMAPI_INTERFACE NVPMInit(); 00102 00103 NVPMAPI_INTERFACE NVPMSetWarningLevel(UINT unLevel); 00104 00105 // Shutdown NVPMAPI and allow it to perform any necessary resource cleanup 00106 NVPMAPI_INTERFACE NVPMShutdown(); 00107 00108 // Enumerate available counters/experiments 00109 typedef int NVPMEnumFunc(UINT unCounterIndex, char *pcCounterName); 00110 NVPMAPI_INTERFACE NVPMEnumCounters(NVPMEnumFunc pEnumFunction); 00111 00112 // Retrieve the number of counters available 00113 NVPMAPI_INTERFACE NVPMGetNumCounters(UINT *punCount); 00114 00115 // Retrieve name or description of a counter. Passing NULL for pcString 00116 // and a valid pointer for punLen will return the length of the 00117 // name/description in punLen. Passing a pointer in pcString and a buffer 00118 // size in punLen will attempt to write the name (\0 term) to pcString. 00119 // If the buffer is too small, nothing is written and punLen is set to the 00120 // string length needed. 00121 NVPMAPI_INTERFACE NVPMGetCounterName(UINT unCounterIndex, char *pcString, UINT *punLen); 00122 NVPMAPI_INTERFACE NVPMGetCounterDescription(UINT unCounterIndex, char *pcString, UINT *punLen); 00123 NVPMAPI_INTERFACE NVPMGetCounterIndex(char *pcString, UINT *punCounterIndex); 00124 NVPMAPI_INTERFACE NVPMGetCounterClockRate(char *pcString, float *pfValue); // Return in MHz 00125 00126 // Query attribute information for a given counter. These can be called 00127 // when enumerating with NVPMEnumCounters(); 00128 typedef enum {NVPM_CT_GPU, NVPM_CT_OGL, NVPM_CT_D3D, NVPM_CT_SIMEXP} NVPMCOUNTERTYPE; 00129 typedef enum {NVPM_CV_PERCENT, NVPM_CV_RAW} NVPMCOUNTERVALUE; 00130 typedef enum {NVPM_CDH_PERCENT, NVPM_CDH_RAW} NVPMCOUNTERDISPLAYHINT; 00131 typedef enum { 00132 NVPMA_COUNTER_TYPE, // Return the type of the counter (NVPMCOUNTERTYPE) 00133 NVPMA_COUNTER_VALUE, // Return the counter value type (NVPMCOUNTERVALUE) 00134 NVPMA_COUNTER_DISPLAY_HINT, // Give a hint to how the counter should be displayed. 00135 NVPMA_COUNTER_MAX, // Return the maximum counter value 00136 } NVPMATTRIBUTE; 00137 00138 NVPMAPI_INTERFACE NVPMGetCounterAttribute(UINT unCounterIndex, NVPMATTRIBUTE nvAttribute, UINT64 *punValue); 00139 00140 // Add counters interface for enabling either a single counter or a compound experiment. 00141 NVPMAPI_INTERFACE NVPMAddCounterByName(char *pcName); 00142 NVPMAPI_INTERFACE NVPMAddCounter(UINT unCounterIndex); 00143 NVPMAPI_INTERFACE NVPMAddCounters(UINT unCount, UINT *punCounterIndices); 00144 00145 // Remove counters interface for disabling either a single counter or a compound experiment. 00146 NVPMAPI_INTERFACE NVPMRemoveCounterByName(char *pcName); 00147 NVPMAPI_INTERFACE NVPMRemoveCounter(UINT unCounterIndex); 00148 NVPMAPI_INTERFACE NVPMRemoveCounters(UINT unCount, UINT *punCounterIndices); 00149 NVPMAPI_INTERFACE NVPMRemoveAllCounters(); 00150 00151 // Allocate slots for counter data to be put into. If this isn't done, all data is put in "slot 0". 00152 #define NVPM_MAX_OBJECTS 4096 00153 NVPMAPI_INTERFACE NVPMAllocObjects(int); 00154 00156 // This is the experiment based interface for NVPMAPI 00157 00158 // Signals to NVPMAPI that the user is ready to begin sampling. It returns in 00159 // pnNumPasses the number of passes it will take to provide data for all of 00160 // the enabled counters. 00161 NVPMAPI_INTERFACE NVPMBeginExperiment(int *pnNumPasses); 00162 00163 // Lets NVPMAPI know that you are done with an experiment. Bookend for 00164 // NVPMBeginExperiment and handles dangling passes/objects. 00165 NVPMAPI_INTERFACE NVPMEndExperiment(); 00166 00167 // Signifies the beginning of a pass. 00168 NVPMAPI_INTERFACE NVPMBeginPass(int nPass); 00169 00170 // Lets NVPMAPI know that you are done with a pass. Bookend for 00171 // NVPMBeginPass and handles dangling objects. 00172 NVPMAPI_INTERFACE NVPMEndPass(int nPass); 00173 00174 // Begin/end an object in a pass. 00175 NVPMAPI_INTERFACE NVPMBeginObject(int nObjectID); 00176 NVPMAPI_INTERFACE NVPMEndObject(int nObjectID); 00177 00179 // This is the typical "sample now" based interface. If you pass in an array 00180 // of SampleValue's, it will return the currently active counters (NULL returns 00181 // no counters). Fill *punCount with the available entries in pucValues/pucCycles 00182 typedef struct _NVPMSampleValue { 00183 UINT unCounterIndex; 00184 UINT64 ulValue; 00185 UINT64 ulCycles; 00186 } NVPMSampleValue; 00187 NVPMAPI_INTERFACE NVPMSample(NVPMSampleValue *pSamples, UINT *punCount); 00188 00190 // Retrieve the resulting counter values 00191 NVPMAPI_INTERFACE NVPMGetCounterValueByName(char *pcName, int nObjectID, UINT64 *pulValue, UINT64 *pulCycles); 00192 NVPMAPI_INTERFACE NVPMGetCounterValue(UINT unCounterIndex, int nObjectID, UINT64 *pulValue, UINT64 *pulCycles); 00193 NVPMAPI_INTERFACE NVPMGetGPUBottleneckName(UINT64 ulValue, char *pcName); 00194 00195 // If NVPM_ERROR_INTERNAL is returned, this will give extended information to help debug what happened 00196 // Send this result (along with any other pertinent contextual information) to NVPerfKit@nvidia.com 00197 NVPMAPI_INTERFACE NVPMGetExtendedError(UINT *pnError); 00198 00199 #ifdef __cplusplus 00200 }; 00201 #endif 00202 00203 #endif // _NVPMAPI_INT_H_