Added a project with NVidia counters and NvPmApi header from NV Perfkit

- nv_counters.h/.cpp load NVidia counters using NvPmApi 4.4.0
This commit is contained in:
reinsteam
2018-03-28 19:27:44 +01:00
committed by Baldur Karlsson
parent 3074ebeb51
commit 48cb7d6c49
11 changed files with 1974 additions and 0 deletions
+13
View File
@@ -13,6 +13,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "renderdoc", "renderdoc\rend
{EC847717-119A-2391-0477-212E1140082C} = {EC847717-119A-2391-0477-212E1140082C}
{B7399F39-300F-450E-F471-9490F959D2A7} = {B7399F39-300F-450E-F471-9490F959D2A7}
{EA1242CF-BB42-B1AC-9B6A-A508D96D1CB7} = {EA1242CF-BB42-B1AC-9B6A-A508D96D1CB7}
{40349AD9-5558-4DF4-84E2-11934DE90A11} = {40349AD9-5558-4DF4-84E2-11934DE90A11}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DLL", "DLL", "{B1FB29A4-9C48-4D47-BAEF-CF14CB2A40A3}"
@@ -76,6 +77,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "version", "renderdoc\render
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "renderdocui_stub", "qrenderdoc\renderdocui_stub.vcxproj", "{37955C79-D91D-423F-8C6C-8F5BCF4F28D4}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NV", "renderdoc\driver\ihv\nv\NV.vcxproj", "{40349AD9-5558-4DF4-84E2-11934DE90A11}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Development|x64 = Development|x64
@@ -252,6 +255,14 @@ Global
{37955C79-D91D-423F-8C6C-8F5BCF4F28D4}.Release|x64.Build.0 = Release|x64
{37955C79-D91D-423F-8C6C-8F5BCF4F28D4}.Release|x86.ActiveCfg = Release|Win32
{37955C79-D91D-423F-8C6C-8F5BCF4F28D4}.Release|x86.Build.0 = Release|Win32
{40349AD9-5558-4DF4-84E2-11934DE90A11}.Development|x64.ActiveCfg = Development|x64
{40349AD9-5558-4DF4-84E2-11934DE90A11}.Development|x64.Build.0 = Development|x64
{40349AD9-5558-4DF4-84E2-11934DE90A11}.Development|x86.ActiveCfg = Development|Win32
{40349AD9-5558-4DF4-84E2-11934DE90A11}.Development|x86.Build.0 = Development|Win32
{40349AD9-5558-4DF4-84E2-11934DE90A11}.Release|x64.ActiveCfg = Release|x64
{40349AD9-5558-4DF4-84E2-11934DE90A11}.Release|x64.Build.0 = Release|x64
{40349AD9-5558-4DF4-84E2-11934DE90A11}.Release|x86.ActiveCfg = Release|Win32
{40349AD9-5558-4DF4-84E2-11934DE90A11}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -284,5 +295,7 @@ Global
{61157930-78C3-4355-8B49-4CC91B98F17B} = {A0E6051E-4374-42E0-9F3C-28DFC64A1029}
{257FD75C-4D17-4A23-A754-23BFD85887A0} = {B5A783D9-AEB9-420D-8E77-D4D930F8D88C}
{37955C79-D91D-423F-8C6C-8F5BCF4F28D4} = {B5A783D9-AEB9-420D-8E77-D4D930F8D88C}
{40349AD9-5558-4DF4-84E2-11934DE90A11} = {4DA2F3E3-9A65-45DD-A69B-82C7757D4904}
EndGlobalSection
EndGlobalSection
EndGlobal
+110
View File
@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Development|Win32">
<Configuration>Development</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Development|x64">
<Configuration>Development</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{40349AD9-5558-4DF4-84E2-11934DE90A11}</ProjectGuid>
<RootNamespace>NV</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<ExecutablePath>$(ExecutablePath)</ExecutablePath>
<IncludePath>$(SolutionDir)\breakpad;$(IncludePath)</IncludePath>
<LibraryPath>$(LibraryPath)</LibraryPath>
<ExcludePath>$(ExcludePath)</ExcludePath>
<TargetName>driver_$(ProjectName)</TargetName>
</PropertyGroup>
<PropertyGroup>
<IntDir>$(SolutionDir)$(Platform)\$(Configuration)\obj\$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Platform)'=='x64'">
<ClCompile>
<PreprocessorDefinitions>WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
<ClCompile>
<PreprocessorDefinitions>RELEASE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>$(SolutionDir)renderdoc\;$(SolutionDir)renderdoc\3rdparty\</AdditionalIncludeDirectories>
<PreprocessorDefinitions>RENDERDOC_EXPORTS;RENDERDOC_PLATFORM_WIN32;WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level4</WarningLevel>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<TreatWarningAsError>true</TreatWarningAsError>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>4100</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Development'">
<ClCompile>
<Optimization>Disabled</Optimization>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="nv_counters.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="nv_counters.h" />
<ClInclude Include="official\PerfKit\include\NvPmApi.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\shaders\spirv\renderdoc_spirv.vcxproj">
<Project>{0aae0ad1-371b-4a36-9ed1-80e10e960605}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClInclude Include="official\PerfKit\include\NvPmApi.h">
<Filter>official\PerfKit\include</Filter>
</ClInclude>
<ClInclude Include="nv_counters.h">
<Filter>Counters</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="official">
<UniqueIdentifier>{4573e5d0-aa55-4c18-8467-2da46af59c23}</UniqueIdentifier>
</Filter>
<Filter Include="official\PerfKit">
<UniqueIdentifier>{1be7ed6c-c292-4f4b-87b3-412b5a9f22ea}</UniqueIdentifier>
</Filter>
<Filter Include="official\PerfKit\include">
<UniqueIdentifier>{368e0d68-5160-4abe-921f-467132b1aa99}</UniqueIdentifier>
</Filter>
<Filter Include="Counters">
<UniqueIdentifier>{630ba7bc-f1cd-4dd7-ba0d-5e4d689be9fd}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="nv_counters.cpp">
<Filter>Counters</Filter>
</ClCompile>
</ItemGroup>
</Project>
+193
View File
@@ -0,0 +1,193 @@
#include "nv_counters.h"
#include "common/common.h"
#define NVPM_INITGUID
#include "official/PerfKit/include/NvPmApi.h"
#include "strings/string_utils.h"
struct EnumCountersCtx
{
std::vector<GPUCounter> mExternalIds;
std::vector<uint32_t> mInternalIds;
std::vector<CounterDescription> mDescriptors;
NvPmApi *mNvPmApi;
uint32_t mCurrentCounterId;
};
static bool NvPmResultFails(NVPMRESULT actual, char const *failMsg)
{
return actual != NVPM_OK;
}
int NvPmCountCounters(NVPMCounterID unCounterID, const char *pcCounterName, void *pUserData)
{
uint32_t *pNumCounters = static_cast<uint32_t *>(pUserData);
*pNumCounters += 1;
return NVPM_OK;
}
int NvPmGatherCounters(NVPMCounterID unCounterID, const char *pcCounterName, void *pUserData)
{
EnumCountersCtx *pEnumCtx = static_cast<EnumCountersCtx *>(pUserData);
const uint32_t i = pEnumCtx->mCurrentCounterId;
GPUCounter globalId = static_cast<GPUCounter>(static_cast<uint32_t>(GPUCounter::FirstNvidia) + i);
pEnumCtx->mExternalIds[i] = globalId;
pEnumCtx->mInternalIds[i] = unCounterID;
CounterDescription &desc = pEnumCtx->mDescriptors[i];
NVPMUINT64 Attribute = 0;
pEnumCtx->mNvPmApi->GetCounterAttribute(unCounterID, NVPMA_COUNTER_TYPE, &Attribute);
NVPMCOUNTERTYPE Type = static_cast<NVPMCOUNTERTYPE>(Attribute);
switch(Type)
{
case NVPM_CT_GPU: desc.category = "GPU"; break;
case NVPM_CT_OGL: desc.category = "D3D"; break;
case NVPM_CT_D3D: desc.category = "D3D"; break;
case NVPM_CT_SIMEXP: desc.category = "SIMEXP"; break;
case NVPM_CT_AGGREGATE: desc.category = "AGGREGATE"; break;
case NVPM_CT_USER: desc.category = "USER"; break;
};
pEnumCtx->mNvPmApi->GetCounterAttribute(unCounterID, NVPMA_COUNTER_DISPLAY, &Attribute);
NVPMCOUNTERDISPLAY Display = static_cast<NVPMCOUNTERDISPLAY>(Attribute);
switch(Display)
{
case NVPM_CD_RATIO: desc.unit = CounterUnit::Ratio; break;
case NVPM_CD_RAW: desc.unit = CounterUnit::Cycles; break;
}
pEnumCtx->mNvPmApi->GetCounterAttribute(unCounterID, NVPMA_COUNTER_DOMAIN, &Attribute);
pEnumCtx->mNvPmApi->GetCounterAttribute(unCounterID, NVPMA_COUNTER_VALUE_TYPE, &Attribute);
NVPMCOUNTERVALUETYPE ValueType = static_cast<NVPMCOUNTERVALUETYPE>(Attribute);
switch(ValueType)
{
case NVPM_VALUE_TYPE_UINT64:
{
desc.resultType = CompType::UInt;
desc.resultByteWidth = sizeof(uint64_t);
}
break;
case NVPM_VALUE_TYPE_FLOAT64:
{
desc.resultType = CompType::Double;
desc.resultByteWidth = sizeof(double);
}
break;
}
char Description[512];
NVPMUINT DescriptionSize = sizeof(Description);
pEnumCtx->mNvPmApi->GetCounterDescription(unCounterID, Description, &DescriptionSize);
desc.counter = globalId;
desc.description = Description;
desc.name = pcCounterName;
desc.uuid.words[0] = 0xC8958C90;
desc.uuid.words[1] = 0xB7064F22;
desc.uuid.words[2] = 0x8AF5E0A3 ^ strhash(desc.name.c_str());
desc.uuid.words[3] = 0x831B2C39 ^ strhash(desc.description.c_str());
pEnumCtx->mCurrentCounterId += 1;
return NVPM_OK;
}
NVCounters::NVCounters() : mNvPmLib(NULL), mNvPmApi(NULL), mNvPmCtx(static_cast<uint64_t>(-1)) {}
NVCounters::~NVCounters()
{
if(mNvPmCtx != static_cast<uint64_t>(-1))
{
mNvPmApi->DestroyContext(mNvPmCtx);
mNvPmCtx = static_cast<uint64_t>(-1);
}
if(mNvPmApi != 0)
{
mNvPmApi->Shutdown();
mNvPmApi = NULL;
}
mNvPmLib = NULL;
}
bool NVCounters::Init()
{
if(mNvPmLib != NULL)
{
return false;
}
mNvPmLib = Process::LoadModule("NvPmApi.Core.dll");
if(mNvPmLib == NULL)
{
return false;
}
NVPMGetExportTable_Pfn pfnGetExportTable =
(NVPMGetExportTable_Pfn)Process::GetFunctionAddress(mNvPmLib, "NVPMGetExportTable");
if(pfnGetExportTable == NULL)
{
return false;
}
if(NvPmResultFails(pfnGetExportTable(&ETID_NvPmApi, (void **)&mNvPmApi), "Get 'NvPmApi' table"))
{
return false;
}
if(NvPmResultFails(mNvPmApi->Init(), "Init 'NvPmApi'"))
{
return false;
}
return true;
}
bool NVCounters::Init(ID3D11Device *pDevice)
{
if(Init() == false)
{
return false;
}
if(NvPmResultFails(mNvPmApi->CreateContextFromD3D11Device(pDevice, &mNvPmCtx),
"Init 'NVPMContext' from ID3D11Device"))
{
return false;
}
uint32_t NumCounters = 0;
mNvPmApi->EnumCountersByContextUserData(mNvPmCtx, NvPmCountCounters, &NumCounters);
EnumCountersCtx ctx;
ctx.mExternalIds.resize(NumCounters);
ctx.mInternalIds.resize(NumCounters);
ctx.mDescriptors.resize(NumCounters);
ctx.mNvPmApi = mNvPmApi;
ctx.mCurrentCounterId = 0;
mNvPmApi->EnumCountersByContextUserData(mNvPmCtx, NvPmGatherCounters, &ctx);
ctx.mExternalIds.swap(mExternalIds);
ctx.mInternalIds.swap(mInternalIds);
ctx.mDescriptors.swap(mDescriptors);
return true;
}
+36
View File
@@ -0,0 +1,36 @@
#pragma once
#include <stdint.h>
#include <vector>
#include "api/replay/renderdoc_replay.h"
struct ID3D11Device;
class NVCounters
{
public:
NVCounters();
~NVCounters();
bool Init(ID3D11Device *pDevice);
std::vector<GPUCounter> GetPublicCounterIds() const { return mExternalIds; }
CounterDescription GetCounterDescription(GPUCounter counterID) const
{
const uint32_t LocalId =
static_cast<uint32_t>(counterID) - static_cast<uint32_t>(GPUCounter::FirstNvidia);
return mDescriptors[LocalId];
}
private:
bool Init(void);
void *mNvPmLib;
struct _NvPmApi *mNvPmApi;
uint64_t mNvPmCtx;
std::vector<GPUCounter> mExternalIds;
std::vector<uint32_t> mInternalIds;
std::vector<CounterDescription> mDescriptors;
};
@@ -0,0 +1,23 @@
Copyright 2013-2014 NVIDIA Corporation
BY DOWNLOADING, INSTALLING, OR RUNNING THE SOFTWARE AND OTHER AVAILABLE MATERIALS, YOU ("DEVELOPER") AGREE TO BE BOUND BY THE FOLLOWING TERMS AND CONDITIONS
The materials available for download to Developers and may include software in both source ("Source Code") and object code ("Object Code"), documentation ("Documentation"), certain art work ("Art Assets") and other materials (collectively, these materials referred to herein as "Materials"), as applicable. Except as expressly indicated herein, all terms and conditions of this Agreement apply to all of the Materials.
Except as expressly set forth herein, NVIDIA owns all of the Materials and makes them available to Developer only under the terms and conditions set forth in this Agreement.
LICENSE: NVIDIA hereby grants to Developer a royalty-free, non-exclusive license to possess and to use the Materials for both commercial and non-commercial purposes but only in connection with NVIDIA products. Developer agrees not distribute the Materials or any derivative works created therewith without the express written permission of an authorized NVIDIA officer or employee. The following terms apply to the specified type of Material:
Source Code: Developer shall have the right to modify and create derivative works with the Source Code. Developer shall own any derivative works ("Derivatives") it creates to the Source Code, provided that Developer uses the Materials in accordance with the terms of this Agreement. Developer may distribute the Derivatives, provided that all NVIDIA copyright notices and trademarks are used properly and the Derivatives include the following statement: "This software contains source code provided by NVIDIA Corporation."
Object Code: Developer agrees not to (or have a third party) disassemble, decompile or reverse engineer the Object Code portions of any of the Materials. Developer acknowledges that certain of the Materials provided in Object Code version may contain third party components that may be subject to restrictions, and expressly agrees not to attempt to modify or distribute such Materials without first receiving consent from NVIDIA.
Art Assets: Developer shall have the right to modify and create Derivatives of the Art Assets, but may not distribute any of the Art Assets or Derivatives created therefrom without NVIDIAs prior written consent.
TERM: The license granted by this Agreement shall be perpetual, unless terminated by NVIDIA. NVIDIA may terminate this Agreement (and with it, all of Developers right to any NVIDIA Materials) upon written notice (which may include email) to Developer, with or without cause.
SUPPORT: NVIDIA has no obligation to support or to continue providing or updating any of the Materials.
NO WARRANTY: THE SOFTWARE AND ANY OTHER MATERIALS PROVIDED BY NVIDIA TO DEVELOPER HEREUNDER ARE PROVIDED "AS IS." NVIDIA DISCLAIMS ALL WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
LIMITATION OF LIABILITY: NVIDIA SHALL NOT BE LIABLE TO DEVELOPER, DEVELOPERS CUSTOMERS, OR ANY OTHER PERSON OR ENTITY CLAIMING THROUGH OR UNDER DEVELOPER FOR ANY LOSS OF PROFITS, INCOME, SAVINGS, OR ANY OTHER CONSEQUENTIAL, INCIDENTAL, SPECIAL, PUNITIVE, DIRECT OR INDIRECT DAMAGES (WHETHER IN AN ACTION IN CONTRACT, TORT OR BASED ON A WARRANTY), INCLUDING BUT NOT LIMITED TO ANY DAMAGE TO DEVELOPER'S HARDWARE OR SOFTWARE THROUGH DEVELOPER'S USE OF THE NVIDIA SOFTWARE, EVEN IF DEVELOPER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF THE ESSENTIAL PURPOSE OF ANY LIMITED REMEDY. IN NO EVENT SHALL NVIDIAS AGGREGATE LIABILITY TO DEVELOPER OR ANY OTHER PERSON OR ENTITY CLAIMING THROUGH OR UNDER DEVELOPER EXCEED THE AMOUNT OF MONEY ACTUALLY PAID BY DEVELOPER TO NVIDIA FOR THE SOFTWARE OR ANY OTHER MATERIALS.
@@ -0,0 +1,174 @@
================================================================================
CONTENTS
================================================================================
-- Release Highlights
-- Supported NVIDIA Display Drivers
-- Supported NVIDIA Hardware
-- Supported Operating Systems
-- New Features
-- Known Issues
-- Revision History
-- More Information
================================================================================
Release Highlights
================================================================================
* New compute counters have been added for the Kepler architecture to enable
profiling of DirectCompute applications. See New Features section for the list
changes.
================================================================================
Supported NVIDIA Display Drivers
================================================================================
319.xx and above are supported. 326.xx is recommended.
================================================================================
Supported NVIDIA Hardware
================================================================================
PerfKit supports the NVIDIA GPUs listed below:
* GeForce 6XX and 7XX Series (Kepler Family)
* GeForce 4XX and 5XX Series (Fermi Family)
* GeForce 2XX, 9, and 8 Series
PerfKit may or may not be available on other NVIDIA GPUs.
The full list of supported NVIDIA GPUs can be found at
https://developer.nvidia.com/nsight-visual-studio-edition-supported-gpus-full-list
================================================================================
Supported Operating Systems
================================================================================
PerfKit supports
* Microsoft Windows Vista
* Microsoft Windows 7
* Microsoft Windows 8
================================================================================
New Features
================================================================================
KEPLER COMPUTE COUNTERS
This release add significant improvements to the coverage and accuracy of
the compute counters.
These changes have not been made for the Fermi architecture.
SM Counters
* Renamed many of the counters.
* SM column indicates the counter is available per _vsm#
* GPU column indicates the counter is available as a total for the GPU
New Counter Name Old Counter Name SM GPU
-------------------------------------------------------------------------------------
sm_active_cycles[_vsm#] active_cycles_q Y Y
sm_active_warps[_vsm#] active_warps_q Y Y
sm_branches_taken[_vsm#] branches_q Y Y
sm_divergent_branches[_vsm#] divergent_branches_q Y Y
sm_ctas_launched[_vsm#] ctas_launched Y Y
sm_inst_executed[_vsm#] inst_executed_q Y Y
sm_inst_issued[_vsm#] inst_issued_q Y Y
sm_pmevent_##[_vsm#] pmevent_##_q Y Y
sm_warps_launched[_vsm#] warps_launched_q Y Y
threads_launched[_gpc#_tpc#] threads_launched_q Y Y
L1 Counters
* Added many new L1/L2 counters.
* Added GPU and SM (per L1) values for some of the existing counters.
l1_atoms_bytes
l1_atoms_transactions
l1_global_load_bytes
l1_global_load_hitrate
l1_global_load_transactions
l1_global_load_transactions_hit[_vsm#]
l1_global_load_transactions_miss[_vsm#]
l1_global_load_uncached_transactions[_vsm#]
l1_global_store_bytes
l1_global_store_transactions[_vsm#]
l1_global_uncached_load_bytes
l1_hitrate
l1_local_load_bytes
l1_local_load_hitrate
l1_local_load_transactions
l1_local_load_transactions_hit[_vsm#]
l1_local_load_transactions_miss[_vsm#]
l1_local_store_bytes
l1_local_store_hitrate
l1_local_store_transactions
l1_local_store_transactions_hit[_vsm#]
l1_local_store_transactions_miss[_vsm#]
l1_reds_bytes
l1_reds_transactions
l1_shared_bank_conflicts
l1_shared_load_bytes
l1_shared_load_transactions[_vsm#]
l1_shared_store_bytes
l1_shared_store_transactions[_vsm#]
l2_hitrate
l2_read_bytes_{atomic, l1, tex}
l2_read_sectors_{atomic, l1, tex}
l2_slice#_read_hit_sectors{_atomic, l1, tex,}_fb#
l2_slice#_read_hit_sysmem_sectors_fb#
l2_slice#_read_hit_vidmem_sectors_fb#
l2_slice#_read_sectors{_atomic, l1, tex,}_fb#
l2_slice#_read_sysmem_sectors_fb#
l2_slice#_read_vidmem_sectors_fb#
l2_slice#_write_sectors{_atomic, l1, tex,}_fb#
l2_slice#_write_sysmem_sectors_fb#
l2_slice#_write_vidmem_sectors_fb#
l2_write_bytes_{atomic, l1, tex}
l2_{read, write}_hitrate
l2_{read, write}_sectors_{atomic, l1, tex}
l2_{read, write}_{sysmem, vidmem}_bytes
Texture Counters
* Added GPU and per texture unit versions of the counters. Counters with the
suffix _gpc#_tpc# provide values for all texture units.
GRAPHICS COUNTERS
* Two sets of counters have been renamed. These counters are now collected
from SMs improving the accuracy. These changes were made to both Kepler
and Fermi.
New Counter Name Old Counter Name SM GPU
-------------------------------------------------------------------------------------
inst_executed_{SHADER_TYPE}[_vsm] {SHADER_TYPE}_instruction_count Y Y
inst_executed_{SHADER_TYPE}[_ratio] {SHADER_TYPE}_instruction_rate Y Y
================================================================================
Known Issues
================================================================================
* NVPMAPI does not support devices in SLI configuration. When in SLI configuration
NVPMAPI may return counters from the wrong device.
* NVPMAPI is not thread safe.
================================================================================
Revision History
================================================================================
PerfKit 3.x versioning scheme follows the NVIDIA Nsight Visual Studio Edition
versioning scheme. PerfKit SDK previously used a different version scheme that
ended with version 6.x.
2013/08 PerfKit 3.1.0
2013/09 PerfKit 3.2.0
================================================================================
More Information
================================================================================
Additional information and downloads can be found at
http://developer.nvidia.com/nvidia-perfkit
Support issues can be mailed to PerfKit@nvidia.com.
@@ -0,0 +1,363 @@
================================================================================
CONTENTS
================================================================================
-- Release Highlights
-- Supported NVIDIA Display Drivers and Tegra Images
-- Supported NVIDIA Hardware
-- Supported Operating Systems
-- New Features
-- Known Issues
-- Revision History
-- More Information
================================================================================
Release Highlights
================================================================================
4.4.0
* Adds support for Maxwell gm200 based GPUs including GeForce Titan X
4.3.0
* Adds support for Nvidia Tegra X1 32-bit and 64-bit devices
4.2.3
* The PerfKit SDK directory structure has new <arch> subdirectory under
bin, lib, and samples bin so that 32-bit and 64-bit libraries and binaries
can be shipped in one package.
4.2.2
* Adds support for Maxwell gm206 based GPUs including the GeForce GTX 960.
4.2.1
* Adds QNX support for Jetson Pro (Tegra K1) Pro platform.
* On Microsoft Windows NvPerfKitControl can now be used in place of NvInstEnabler.
* On Microsoft Windows NvPmSampleOGL and NvPmSampleDX replace the previous
samples.
4.1.1
* Adds Android KitKat and Lollipop support for Tegra K1 32-bit and 64-bit devices.
* Adds NvPerfKitControl to control driver instrumentation and set gpu clock rate
as sysmax, promax and restore on Android platform.
4.1.0
* Adds support for Vibrante 3.0 Linux 1.0a for Jetson Pro (Tegra K1) platform.
* Adds support for Linux4Tegra rel21 for Jetson TK1 (Tegra K1) platform.
* Adds support for new Maxwell gm204 based GPUs including GeForce GTX970
and GTX980.
* On Microsoft Windows adds initial support for NVIDIA Optimus and Microsoft
Hybrid systems.
* On Microsoft Windows removes dependency on Nvda.NvDebugApi.dll.
4.0.1
* Adds support for Vibrante 3.0 Linux for Jetson Pro (Tegra K1) platform.
4.0.0
* Added support for Maxwell architecture including GeForce 830M, 840M, 850M,
860M, 745, 750, and 750 Ti.
* Removed support for all Tesla architecture based GPUs.
* Added new functions to the API to support
1. counters with floating point data types
2. overflow indicator for counters
3. counter enumeration function supporting user data
================================================================================
Supported NVIDIA Display Drivers and Tegra Images
================================================================================
* On Windows NVIDIA
r334.89 is recommended for 4.0.0.
r343.98 is recommended for 4.1.0.
r346.xx or greater is recommended for 4.2.0.
r347.74 or greater is recommended for 4.4.0.
* Vibrante 3.0-Linux Alpha3 on Jetson Pro TK1 platform.
* L4T rel21 and rel22 on Jetson TK1 platform.
* QNX rel23 on Jetson Pro TK1 platform.
================================================================================
Supported NVIDIA Hardware
================================================================================
PerfKit supports the NVIDIA GPUs listed below:
* GeForce 8XX Series, GTX9XX, and GTX TITAN X (Maxwell Architecture)
* GeForce 6XX and 7XX Series (Kepler Architecture)
* GeForce 4XX and 5XX Series (Fermi Architecture)
PerfKit supports the NVIDIA Tegra Platforms listed below:
* NVIDIA Jetson Pro (K1)
* NVIDIA Jetson TK1
* NVIDIA Shield Tablet
PerfKit may or may not be available on other NVIDIA GPUs including Quadro and
Telsa. The full list of supported NVIDIA GPUs can be found at
https://developer.nvidia.com/nsight-visual-studio-edition-supported-gpus-full-list
================================================================================
Supported Operating Systems
================================================================================
PerfKit supports
* Microsoft Windows Vista
* Microsoft Windows 7
* Microsoft Windows 8
* Microsoft Windows 8.1
* Vibrante Linux 3.0a3
* Linux4Tegra rel21
* Android KitKat
* Android Lollipop
* QNX 6.60
================================================================================
New Features in 4.2.1
================================================================================
NEW PLATFORMS
Adds support for QNX on NVIDIA Jetson Pro (Tegra TK1).
MAXWELL ARCHITECTURE SUPPORT
New Counters Gpu Family
----------------------------------------------------------------------------
l2_hitrate Maxwell COMPUTE
tex_cache_sector_misses Maxwell COMPUTE
BUG FIXES
* CPU usage of NvInstEnabler.exe on Microsoft Windows should be reduced.
================================================================================
New Features in 4.1
================================================================================
NEW PLATFORMS
Adds support for Android KitKat and L on NVIDIA Shield Tablet and other
Tegra TK1 32-bit and 64-bit devices.
Adds support for NVIDIA Vibrante Linux on NVIDIA Jetson Pro.
Adds support for NVIDIA Linux4Tegra on NVIDIA Jetson TK1.
MICROSOFT WINDOWS
PerfKit 4.1.0 for Windows now consists of only NvPmApi.Core.dll. The dependency
on Nvda.NvDebugApi.dll has been removed.
TEGRA
PerfKit for Tegra contains a new OpenGL ES sample named NvPmSample. The sample
works on Android, Vibrante3.0 and Linux4Tegra releases. The sample provides an example
of how to implement both real-time mode and experiment mode for different types
of OpenGL ES workloads.
MAXWELL ARCHITETURE SUPPORT
Perfkit 4.1.0 adds support for gm204.
FERMI/KEPLER/MAXWELL ARCHITECTURE SUPPORT
Renamed Counters
----------------------------------------------------------------------------
Old Name New Name
tex*_cache_texel_queries tex*_cache_tex_queries_gpc*_tpc*
New Counters
----------------------------------------------------------------------------
fb_read_bytes COMPUTE
fb_read_sectors COMPUTE
fb_write_bytes COMPUTE
fb_write_sectors COMPUTE
================================================================================
New Features in 4.0
================================================================================
COUNTER DATA TYPES
NVPMAPI previously only supported UINT64 data type for raw counters,
aggregate counters, and simplified experiments. This release adds support
for double precision floating point counters.
- The function NVPMGetCounterAttribute and attribute NVPMA_COUNTER_VALUE_TYPE
can be used to query the type of a counter. The supported types are
NVPM_VALUE_TYPE_{UINT64, FLOAT64}.
- The legacy functions NVPMSample, NVPMGetCounterValueByName, and
NVPMGetCounterValue will only return functions as UINT64. New counters of
type FLOAT64 will be cast to UINT64 and returned.
- The new functions NVPMGetCounterValueUint64 and NVPMGetCounterValueFloat64
should be used to query counter values. If the function is used to query
the value of a counter with a different type the error
NVPM_INCORRECT_VALUE_TYPE will be returned.
- The structure NVPMSampleValueEx has been extended to support both UINT64
and FLOAT64 data types. The counter type is passed through the ulFlags
member.
COUNTER OVERFLOW
The majority of GPU hardware counters are 32-bit and can overflow on long
draw calls or long compute dispatches. The new functions
NVPMGetCounterValueUint64 and NVPMGetCounterValueFloat64 have an output
parameter pOverflow that is set to 1 if the counter overflowed.
NVPMSampleValueEx indicates overflow for each counter using the flag
NVPMSampleValueEx.ulFlags & NVPMSAMPLEEX_FLAG_OVERFLOW.
ENHANCED COUNTER ENUMERATION
The new function NVPMEnumCountersByContextUserData accepts a void* pUserData
parameter that is passed to each callback simplifying enumeration of counter
data.
MAXWELL ARCHITECTURE SUPPORT
Perfkit 4.0 adds support for gm107 and gm108 chips. In many cases the same
counters are maintained between Kepler and Maxwell.
TESLA ARCHITECTURE SUPPORT (REMOVED)
Tesla architecture (not Tesla brand) GPUs have been removed from PerfKit.
Please use PerfKit 3.2.2 if you need support for Tesla architecture based GPUs.
FERMI ARCHITECTURE SUPPORT
Removed Counters
----------------------------------------------------------------------------
crop_busy
rop_busy
zrop_busy
fb_read_req_subp*_fb*
Renamed Counters
----------------------------------------------------------------------------
Old Name New Name
elapsed_cycles_gpc0 elapsed_cycles
ia_l2_read_bytes l2_read_bytes_ia
l2_fb_read_bytes l2_read_bytes_vidmem
l2_fb_write_bytes l2_write_bytes_vidmem
rop_l2_read_bytes l2_read_bytes_rop
rop_l2_write_bytes l2_write_bytes_rop
tex_l2_read_bytes l2_read_bytes_tex
tex_l2_requests l2_read_sectors_tex
New Counters
----------------------------------------------------------------------------
l2_read_bytes_mem
l2_read_bytes_sysmem
l2_write_bytes_mem
l2_write_bytes_sysmem
Counter Domain Changes
----------------------------------------------------------------------------
Old New
elapsed_cycles BOTH COMPUTE
inst_executed_cs_vsm0 BOTH COMPUTE
fb_subp*_{read, write}_sectors_fb* BOTH COMPUTE
l1_local_load_transaction_miss* BOTH COMPUTE
l2_slice*_read_sectors_tex_fb* BOTH COMPUTE
tex*_bank_conflicts_gpc*_tpc* BOTH COMPUTE
tex*_cache_sector_{misses, queries}_gpc*_tpc* BOTH COMPUTE
KEPLER ARCHITECTURE SUPPORT
Removed Counters
----------------------------------------------------------------------------
crop_busy
cta_launched // use sm_ctas_launched
cta_launched_vsm* // use sm_ctas_launched_vsm*
elapsed_cycles_gpc*
elapsed_cycles_gpc*_tpc*
inst_executed_{shader_type}_vsm*
rop_busy
sm_inst_executed_lsu_red_vsm*
tex_l2_read_bytes // use l2_read_bytes_tex
tex_l2_requests // use l2_read_sectors_tex
zrop_busy
Renamed Counters
----------------------------------------------------------------------------
Old Name New Name
elapsed_cycles_gpc0 elapsed_cycles
ia_l2_read_bytes l2_read_bytes_ia
l2_fb_read_bytes l2_read_bytes_vidmem
l2_fb_write_bytes l2_write_bytes_vidmem
rop_l2_read_bytes l2_read_bytes_rop
rop_l2_write_bytes l2_write_bytes_rop
l2_read_sysmem_bytes l2_read_bytes_sysmem
l2_read_vidmem_bytes l2_read_bytes_vidmem
l2_write_sysmem_bytes l2_write_bytes_sysmem
l2_write_vidmem_bytes l2_write_bytes_vidmem
New Counters
----------------------------------------------------------------------------
l1_atoms_transactions_per_request
l1_global_load_transactions_per_request
l1_global_store_transactions_per_request
l1_local_load_transactions_per_request
l1_local_store_transactions_per_request
l1_reds_transactions_per_request
l1_shared_load_transactions_per_request
l1_shared_store_transactions_per_request
l2_read_bytes
l2_read_bytes_mem
l2_read_sectors
l2_write_bytes
l2_write_bytes_mem
l2_write_sectors
sm_active_warps_vsm*
sm_executed_ipc
sm_issued_ipc
Counter Domain Changes
----------------------------------------------------------------------------
Old New
elapsed_cycles BOTH COMPUTE
fb_subp*_{read, write}_sectors_fb* BOTH COMPUTE
l1_local_load_transaction_miss* BOTH COMPUTE
l2_read_sectors_tex COMPUTE BOTH
l2_slice*_read_sectors_tex_fb* BOTH COMPUTE
sm_active_cycles_vsm* BOTH COMPUTE
tex*_bank_conflicts_gpc*_tpc* BOTH COMPUTE
tex*_cache_sector_{misses, queries}_gpc*_tpc* BOTH COMPUTE
tex*_ldg* BOTH COMPUTE
================================================================================
Known Issues
================================================================================
* NVPMAPI does not support devices in SLI configuration. When in SLI
configuration NVPMAPI may return counters from the wrong device.
* Maxwell gm20x devices may require running the application as Administrator or
root (sudo) in order to be correctly profiled. It will be fixed in new drivers
in future.
================================================================================
Revision History
================================================================================
PerfKit 3.x/4.x version scheme follows the NVIDIA Nsight Visual Studio Edition
version. PerfKit SDK previously used a different version scheme that ended with
version 6.x.
2015/03 Perfkit 4.4.0
2015/02 PerfKit 4.3.0
2015/01 PerfKit 4.2.3
2015/01 PerfKit 4.2.2
2015/01 PerfKit 4.2.1
2014/12 PerfKit 4.2.0
2014/10 PerfKit 4.1.1
2014/09 PerfKit 4.1.0
2014/07 PerfKit 4.0.1
2014/04 PerfKit 4.0.0
2013/12 PerfKit 3.2.2
2013/11 PerfKit 3.2.1
2013/09 PerfKit 3.2.0
2013/08 PerfKit 3.1.0
================================================================================
More Information
================================================================================
Additional information and downloads can be found at
http://developer.nvidia.com/nvidia-perfkit
Support issues can be mailed to PerfKit@nvidia.com.
@@ -0,0 +1,53 @@
================================================================================
NVIDIA PERFKIT FOR Windows XP, Windows 7, Windows 8 and Windows 8.1.
================================================================================
Version 4.4.0 of NVIDIA PerfKit for Windows.
================================================================================
Driver Instrumentation
================================================================================
NVIDIA PerfKit SDK provides low level access to GPU hardware performance
counters and DirectX/OpenGL device driver counters. In order to access the
driver counters, aggregate and simexp counters data, the Windows driver
instrumentation must be enabled by the user.
On Windows platforms this is performed by setting a system level driver
state that can be read when the Windows driver is firstly loaded into
the instrumented process.
Enabling driver instrumentation adds a minimal CPU overhead to the driver.
================================================================================
Running an Instrumented Application
================================================================================
The standard method to run an application using NvPmApi.Core.dll is
# enable NVIDIA GL driver instrumentation
NvPerfKitControl inst=enable
# set PATH to include path to NvPmApi.Core.dll, <arch> is either x86 or x64
set PATH=%PATH%;PerfKit-4.4.0/bin/<arch>/
# run the application
NvPmApiQuery
================================================================================
Set instrumentation state
================================================================================
NvPerfKitControl is used to set instrumentation state for Windows.
Run it directly without any option, it prints the current instrumentation state.
To enable instrumentation, run with "inst=enable",
to disable instrumentation, run with "inst=disable".
================================================================================
Support
================================================================================
Additional information and downloads can be found at
http://developer.nvidia.com/nvidia-perfkit
Support issues can be mailed to PerfKit@nvidia.com.
@@ -0,0 +1,976 @@
/*
* Copyright 2014 NVIDIA Corporation. All rights reserved.
*
* NOTICE TO USER:
*
* This source code is subject to NVIDIA ownership rights under U.S. and
* international Copyright laws.
*
* This software and the information contained herein is PROPRIETARY and
* CONFIDENTIAL to NVIDIA and is being provided under the terms and conditions
* of a form of NVIDIA software license agreement.
*
* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
* CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
* IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
* OR PERFORMANCE OF THIS SOURCE CODE.
*
* U.S. Government End Users. This source code is a "commercial item" as
* that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
* "commercial computer software" and "commercial computer software
* documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
* and is provided to the U.S. Government only as a commercial end item.
* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
* 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
* source code with only those rights set forth herein.
*
* Any use of this source code in individual and commercial software must
* include, in the user documentation and internal comments to the code,
* the above Disclaimer and U.S. Government End Users Notice.
*/
///////////////////////////////////////////////////////////////////////////////
/// \file
/// NVPMAPI-Next Header files
///////////////////////////////////////////////////////////////////////////////
#ifndef _NVPMAPI_H_
#define _NVPMAPI_H_
#ifdef __cplusplus
extern "C" {
#endif // End of __cplusplus
#include <stdint.h>
/// Generic unsigned data types, 8-64 bits
typedef uint8_t NVPMUINT8;
typedef uint16_t NVPMUINT16;
typedef uint32_t NVPMUINT32;
typedef uint32_t NVPMUINT;
typedef uint64_t NVPMUINT64;
typedef double NVPMFLOAT64;
/// Context from NVPMAPI mapping back to the original API specific device/context
typedef NVPMUINT64 NVPMContext;
/// Abstract handle type for GL/CUDA, here to keep includes to a minimum
typedef NVPMUINT64 APIContextHandle;
/// Every counter has a unique ID
typedef NVPMUINT NVPMCounterID;
///////////////////////////////////////////////////////////////////////////////
/// Unified return code for all NVPMAPI-Next methods
/// The negative result values are thrown on init or if init failed
///////////////////////////////////////////////////////////////////////////////
#ifndef NVPMRESULT_DEFINED
typedef enum {
/// Performance disabled in registry
NVPM_FAILURE_DISABLED = -5,
/// Mixed mode (32bit client 64bit kernel) unsupported
NVPM_FAILURE_32BIT_ON_64BIT = -4,
/// Returned when NVPMInit has not been called or failed
NVPM_NO_IMPLEMENTATION = -3,
/// nvpmapi.dll was not found
NVPM_LIBRARY_NOT_FOUND = -2,
/// General, internal failure when initializing
NVPM_FAILURE = -1,
/// Finished successfully
NVPM_OK = 0,
/// Invalid parameter found
NVPM_ERROR_INVALID_PARAMETER,
/// Driver version mismatch ?
NVPM_ERROR_DRIVER_MISMATCH,
/// Not initialized when trying to use
NVPM_ERROR_NOT_INITIALIZED,
/// Already initialized when trying to initialize
NVPM_ERROR_ALREADY_INITIALIZED,
/// Bad enumerator found
NVPM_ERROR_BAD_ENUMERATOR,
/// String is too small
NVPM_ERROR_STRING_TOO_SMALL,
/// Invalid counter found
NVPM_ERROR_INVALID_COUNTER,
/// No more memory to be allocated
NVPM_ERROR_OUT_OF_MEMORY,
///
NVPM_ERROR_EXPERIMENT_INCOMPLETE,
///
NVPM_ERROR_INVALID_PASS,
///
NVPM_ERROR_INVALID_OBJECT,
///
NVPM_ERROR_COUNTER_NOT_ENABLED,
///
NVPM_ERROR_COUNTER_NOT_FOUND,
///
NVPM_ERROR_EXPERIMENT_NOT_RUN,
///
NVPM_ERROR_32BIT_ON_64BIT,
///
NVPM_ERROR_STATE_MACHINE,
///
NVPM_ERROR_INTERNAL,
///
NVPM_WARNING_ENDED_EARLY,
///
NVPM_ERROR_TIME_OUT,
///
NVPM_WARNING_DUPLICATE,
///
NVPM_ERROR_COUNTERS_ENABLED,
///
NVPM_ERROR_CONTEXT_NOT_SUPPORTED,
///
NVPM_ERROR_INVALID_CONTEXT,
///
NVPM_ERROR_GPU_UNSUPPORTED,
///
NVPM_INCORRECT_VALUE_TYPE,
NVPM_ERROR_MAX
} NVPMRESULT;
#define NVPMRESULT_DEFINED
#endif
#if defined(_WIN32) // Windows
#define NVCALL __stdcall
#else // Linux / Mac
#define NVCALL
#endif // End of _WIN32
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMSetWarningLevel(NVPMUINT unLevel);
///
/// @brief Set warning output level to be set
/// @param[in] unLevel debug output levels
/// @return unified return code #NVPMRESULT
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMSetWarningLevel_Pfn)(NVPMUINT unLevel);
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMGetExtendedError(NVPMUINT *pnError);
///
/// @brief Get extended error code
/// @param[out] pnError error code returned here
/// @return unified return code #NVPMRESULT
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMGetExtendedError_Pfn)(NVPMUINT *pnError);
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMInit();
///
/// @brief Initialize NVPMAPI-Next
/// @return unified return code #NVPMRESULT
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMInit_Pfn)();
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMShutdown();
///
/// @brief Shutdown NVPMAPI-Next
/// @return unified return code #NVPMRESULT
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMShutdown_Pfn)();
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMCreateContextFromOGLContext(APIContextHandle hglrc, NVPMContext *perfCtx);
///
/// @brief Create NVPMContext from OpenGL context
/// @param[in] hglrc OpenGL context handle
/// @param[out] perfCtx pointer to the result NVPMContext
/// @return unified return code #NVPMRESULT
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMCreateContextFromOGLContext_Pfn)(
APIContextHandle hglrc,
NVPMContext *perfCtx
);
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMCreateContextFromCudaContext(APIContextHandle cuCtx, NVPMContext *perfCtx);
///
/// @brief Create NVPMContext from CUDA context
/// @param[in] cuCtx CUDA context handle
/// @param[out] perfCtx pointer to the result NVPMContext
/// @return unified return code #NVPMRESULT
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMCreateContextFromCudaContext_Pfn)(
APIContextHandle cuCtx,
NVPMContext *perfCtx
);
#if defined(_WIN32)
typedef struct IDirect3DDevice9 IDirect3DDevice9;
typedef struct ID3D10Device ID3D10Device;
typedef struct ID3D11Device ID3D11Device;
typedef struct ID3D11Device1 ID3D11Device1;
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMCreateContextFromD3D9Device(IDirect3DDevice9 *pD3DDevice, NVPMContext *perfCtx);
///
/// @brief Create NVPMContext from Direct3D9 device
/// @param[in] pD3DDevice Direct3D9 device handle
/// @param[out] perfCtx pointer to the result NVPMContext
/// @return unified return code #NVPMRESULT
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMCreateContextFromD3D9Device_Pfn)(
IDirect3DDevice9 *pD3D9Device,
NVPMContext *perfCtx
);
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMCreateContextFromD3D10Device(ID3D10Device *pD3DDevice, NVPMContext *perfCtx);
///
/// @brief Create NVPMContext from Direct3D10 device
/// @param[in] pD3DDevice Direct3D10 device handle
/// @param[out] perfCtx pointer to the result NVPMContext
/// @return unified return code #NVPMRESULT
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMCreateContextFromD3D10Device_Pfn)(
ID3D10Device *pD3DDevice,
NVPMContext *perfCtx
);
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMCreateContextFromD3D11Device(ID3D11Device *pD3DDevice, NVPMContext *perfCtx);
///
/// @brief Create NVPMContext from Direct3D11 device
/// @param[in] pD3DDevice Direct3D11 device handle
/// @param[out] perfCtx pointer to the result NVPMContext
/// @return unified return code #NVPMRESULT
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMCreateContextFromD3D11Device_Pfn)(
ID3D11Device *pD3DDevice,
NVPMContext *perfCtx
);
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMCreateContextFromD3D11Device1(ID3D11Device1 *pD3DDevice, NVPMContext *perfCtx);
///
/// @brief Create NVPMContext from Direct3D11_1 device
/// @param[in] pD3DDevice Direct3D11_1 device handle
/// @param[out] perfCtx pointer to the result NVPMContext
/// @return unified return code #NVPMRESULT
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMCreateContextFromD3D11Device1_Pfn)(
ID3D11Device1 *pD3DDevice,
NVPMContext *perfCtx
);
#endif // _WIN32
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMDestroyContext(NVPMContext perfCtx);
///
/// @brief Destroy existing NVPMContext
/// @param[in] perfCtx NVPMContext instance to be destroyed
/// @return unified return code #NVPMRESULT
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMDestroyContext_Pfn)(NVPMContext perfCtx);
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMEnumCounters(NVPMCounterID unCounterID, const char *pcCounterName);
///
/// @brief Callback function for enumeration of counters/experiments.
/// @param[in] unCounterID Available counter's ID.
/// @param[in] pcCounterName Available counter's name.
/// @return NVPM_OK to continue enumerating available counters.
///////////////////////////////////////////////////////////////////////////////
typedef int (*NVPMEnumFunc)(NVPMCounterID unCounterID, const char *pcCounterName);
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMEnumCountersByContext(NVPMContext perfCtx, NVPMEnumFunc pEnumFunction);
///
/// @brief Enumerate counters/experiments.
/// @param [in] perfCtx The perfCtx to enum counters from
/// @param [in] pEnumFunction function pointer to enum each available counter.
/// Prototype of callback function as #NVPMEnumFunc
/// @return unified return code #NVPMRESULT
/// @see NVPMEnumFunc
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMEnumCountersByContext_Pfn)(NVPMContext perfCtx, NVPMEnumFunc pEnumFunction);
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMEnumCountersUserData(NVPMCounterID unCounterID, const char *pcCounterName, void *pUserData);
///
/// @brief Callback function for enumeration of counters/experiments supporting user data.
/// @param[in] unCounterID Available counter's ID.
/// @param[in] pcCounterName Available counter's name.
/// @param[in] pUserData Pointer to user specified data passed into #NVPMEnumCountersByContextUserData.
/// @return NVPM_OK to continue enumerating available counters.
///////////////////////////////////////////////////////////////////////////////
typedef int (*NVPMEnumFuncUserData)(NVPMCounterID unCounterID, const char *pcCounterName, void *pUserData);
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMEnumCountersByContextUserData(NVPMContext perfCtx, NVPMEnumFunc pEnumFunction, void *pUserData);
///
/// @brief Enumerate counters/experiments.
/// @param [in] perfCtx The perfCtx to enum counters from
/// @param [in] pEnumFunction function pointer to enum each available counter.
/// Prototype of callback function as #NVPMEnumFuncUserData
/// @param [in] pUserData pointer to user data passed to each call to #NVPMEnumFuncUserData.
/// @return unified return code #NVPMRESULT
/// @see NVPMEnumFunc
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMEnumCountersByContextUserData_Pfn)(NVPMContext perfCtx, NVPMEnumFuncUserData pEnumFunction, void *pUserData);
///////////////////////////////////////////////////////////////////////////////
/// @brief Get the name of a counter specified by ID
/// @param[in] unCounterID ID to the counter which is interested
/// @param[out] pcString returned name string
/// @param[in,out] punLen length of return string ??
/// @return unified return code #NVPMRESULT
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMGetCounterName_Pfn)(
NVPMCounterID unCounterID,
char *pcString,
NVPMUINT *punLen
);
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMGetCounterDescription(NVPMCounterID unCounterID, char *pcString, NVPMUINT *punLen);
///
/// @brief Get the description of a counter specified by ID
/// @param[in] unCounterID ID to the counter which is interested
/// @param[out] pcString returned description string
/// @param[in,out] punLen length of return string ??
/// @return unified return code #NVPMRESULT
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMGetCounterDescription_Pfn)(
NVPMCounterID unCounterID,
char *pcString,
NVPMUINT *punLen
);
///////////////////////////////////////////////////////////////////////////////
/// NVPMAPI_INTERFACE NVPMGetCounterIDByContext(NVPMContext perfCtx, const char *pcString, NVPMCounterID *punCounterID);
///
/// @brief Get the ID of a counter specified by name for a given context
/// @param [in] perfCtx The perfCtx to get counters number from
/// @param[in] pcString name of the counter which is interested
/// @param[out] punCounterID returned ID to the counter which is
/// interested
/// @return unified return code #NVPMRESULT
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMGetCounterIDByContext_Pfn)(
NVPMContext perfCtx,
const char *pcString,
NVPMCounterID *punCounterID
);
///////////////////////////////////////////////////////////////////////////////
/// NVPMAPI_INTERFACE NVPMGetCounterClockRateByContext(NVPMContext perfCtx, const char *pcString, float *pfValue);
///
/// @brief Get the clock rate of a counter specified by name
/// @param [in] perfCtx The perfCtx to get counters number from
/// @param[in] pcString name of the counter which is interested
/// @param[out] pfValue returned clock rate in MHz
/// @return unified return code #NVPMRESULT
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMGetCounterClockRateByContext_Pfn)(
NVPMContext perfCtx,
const char *pcString,
float *pfValue
);
///////////////////////////////////////////////////////////////////////////////
// Query attribute information for a given counter. These can be called
// when enumerating with NVPMEnumCounters();
///////////////////////////////////////////////////////////////////////////////
/// Counter's type
typedef enum {
/// GPU counter
NVPM_CT_GPU,
/// OpenGL counter
NVPM_CT_OGL,
/// Direct3D counter
NVPM_CT_D3D,
/// Simplified experiment counter (can only be used in Experiment mode)
NVPM_CT_SIMEXP,
/// User counter type
NVPM_CT_USER,
/// Aggregated experiment counter
NVPM_CT_AGGREGATE,
} NVPMCOUNTERTYPE;
/// Counter display type
typedef enum {
/// Counter should be displayed as a ratio of value/cycles
NVPM_CD_RATIO,
/// Counter should be displayed as the value only
NVPM_CD_RAW
} NVPMCOUNTERDISPLAY;
/// Counter value type.
typedef enum {
// 64b unsigned integer
NVPM_VALUE_TYPE_UINT64,
// 64b float (double)
NVPM_VALUE_TYPE_FLOAT64,
} NVPMCOUNTERVALUETYPE;
/// Attribute type used in function NVPMGetCounterAttribute
typedef enum {
/// The type of counter, see NVPMCOUNTERTYPE
NVPMA_COUNTER_TYPE,
/// The display hint for the counter, see NVPMCOUNTERDISPLAY
NVPMA_COUNTER_DISPLAY,
/// The domain of counter
NVPMA_COUNTER_DOMAIN,
/// The value type of the counter
NVPMA_COUNTER_VALUE_TYPE,
/// Get the maximum of counter value.
NVPMA_COUNTER_MAX, // Return the maximum counter value
} NVPMATTRIBUTE;
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMGetCounterAttribute(NVPMCounterID unCounterID, NVPMATTRIBUTE nvAttribute, NVPMUINT64 *punValue);
///
/// @brief Get the some attribute of a counter specified by ID
/// @param[in] unCounterID ID to the counter which is interested
/// @param[out] nvAttribute which attribute of that counter is interested, see
/// #NVPMATTRIBUTE for detail information.
/// @param[out] punValue attribute result
/// @return unified return code #NVPMRESULT
/// @see NVPMATTRIBUTE
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMGetCounterAttribute_Pfn)(
NVPMCounterID unCounterID,
NVPMATTRIBUTE nvAttribute,
NVPMUINT64 *punValue
);
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMAddCounterByName(NVPMContext perfCtx, const char *pcName);
///
/// @brief Activate counter specified by name
/// @param[in] perfCtx In which NVPMContext instance we want to activate the
/// counter
/// @param[in] pcName pointer to a string of the counter name
/// @return unified return code #NVPMRESULT
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMAddCounterByName_Pfn)(
NVPMContext perfCtx,
const char *pcName
);
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMAddCounter(NVPMContext perfCtx, NVPMCounterID unCounterID);
///
/// @brief Activate counter specified by ID
/// @param[in] perfCtx In which NVPMContext instance we want to activate the
/// counter
/// @param[in] unCounterID counter ID
/// @return unified return code #NVPMRESULT
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMAddCounter_Pfn)(NVPMContext perfCtx, NVPMCounterID unCounterID);
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMAddCounters(NVPMContext perfCtx, NVPMUINT unCount, NVPMCounterID *punCounterIDs);
///
/// @brief Activate multiple counters at a time specified by an ID array
/// @param[in] perfCtx In which NVPMContext instance we want to activate the
/// counter
/// @param[in] unCount size of counter ID array
/// @param[in] punCounterIDs pointer to the counter ID array
/// @return unified return code #NVPMRESULT
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMAddCounters_Pfn)(
NVPMContext perfCtx,
NVPMUINT unCount,
NVPMCounterID *punCounterIDs
);
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMRemoveCounterByName(NVPMContext perfCtx, const char *pcName);
///
/// @brief Deactivate counter specified by name
/// @param[in] perfCtx In which NVPMContext instance we want to deactivate the
/// performance counter
/// @param[in] pcName pointer to a string of the counter name
/// @return unified return code #NVPMRESULT
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMRemoveCounterByName_Pfn)(
NVPMContext perfCtx,
const char *pcName
);
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMRemoveCounter(NVPMContext perfCtx, NVPMCounterID unCounterID);
///
/// @brief Deactivate counter specified by ID
/// @param[in] perfCtx In which NVPMContext instance we want to deactivate the
/// performance counter
/// @param[in] unCounterID counter ID
/// @return unified return code #NVPMRESULT
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMRemoveCounter_Pfn)(
NVPMContext perfCtx,
NVPMCounterID unCounterID
);
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMRemoveCounters(NVPMContext perfCtx, NVPMUINT unCount, NVPMCounterID *punCounterIDs);
///
/// @brief Deactivate multiple counters at a time specified by an ID array
/// @param[in] perfCtx In which NVPMContext instance we want to deactivate the
/// performance counter
/// @param[in] unCount size of counter ID array
/// @param[in] punCounterIDs pointer to the counter ID array
/// @return unified return code #NVPMRESULT
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMRemoveCounters_Pfn)(
NVPMContext perfCtx,
NVPMUINT unCount,
NVPMCounterID *punCounterIDs
);
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMRemoveAllCounters(NVPMContext perfCtx);
///
/// @brief Deactivate all counters in the specified NVPMContext instance
/// @param[in] perfCtx In which NVPMContext instance we want to deactivate all
/// the performance counters
/// @return unified return code #NVPMRESULT
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMRemoveAllCounters_Pfn)(NVPMContext perfCtx);
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMReserveObjects(NVPMContext perfCtx, NVPMUINT objNum);
///
/// @brief Reserve certain amount of NVPMPerfObjects
/// @param[in] perfCtx Specify which NVPMContext instance to operate
/// @param[in] objNum number of PerfObjects to be reserved
/// @return unified return code #NVPMRESULT
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMReserveObjects_Pfn)(
NVPMContext perfCtx,
NVPMUINT objNum
);
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMDeleteObjects(NVPMContext perfCtx);
///
/// @brief Delete all NVPMPerfObjects in a given NVPMPerfContext
/// @param[in] perfCtx Specify which NVPMContext instance to operate
/// @return unified return code #NVPMRESULT
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMDeleteObjects_Pfn)(NVPMContext perfCtx);
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMBeginExperiment(NVPMContext perfCtx, NVPMUINT *pnNumPasses);
///
/// @brief Begin experiment
/// @param[in] perfCtx Specify which NVPMContext instance to operate
/// @param[out] pnNumPasses return how many passes needed to do this experiment
/// @return unified return code #NVPMRESULT
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMBeginExperiment_Pfn)(
NVPMContext perfCtx,
NVPMUINT *pnNumPasses
);
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMEndExperiment(NVPMContext perfCtx);
///
/// @brief Ending an experiment
/// @param[in] perfCtx Specify which NVPMContext instance to operate
/// @return unified return code #NVPMRESULT
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMEndExperiment_Pfn)(NVPMContext perfCtx);
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMBeginPass(NVPMContext perfCtx, NVPMUINT nPass);
///
/// @brief Beginning a pass
/// @param[in] perfCtx Specify which NVPMContext instance to operate
/// @param[in] nPass specify which pass it's going to be run
/// @return unified return code #NVPMRESULT
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMBeginPass_Pfn)(
NVPMContext perfCtx,
NVPMUINT nPass
);
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMEndPass(NVPMContext perfCtx, NVPMUINT nPass);
///
/// @brief Ending a pass
/// @param[in] perfCtx Specify which NVPMContext instance to operate
/// @param[in] nPass specify which pass to be ended
/// @return unified return code #NVPMRESULT
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMEndPass_Pfn)(
NVPMContext perfCtx,
NVPMUINT nPass
);
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMBeginObject(NVPMContext perfCtx, NVPMUINT nObjectID);
///
/// @brief Beginning a NVPMPerfObject, make that NVPMPerfOject active
/// @param[in] perfCtx Specify which NVPMContext instance to operate
/// @param[in] nObjectID ID of the NVPMPerfObject to be used
/// @return unified return code #NVPMRESULT
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMBeginObject_Pfn)(
NVPMContext perfCtx,
NVPMUINT nObjectID
);
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMEndObject(NVPMContext perfCtx, NVPMUINT nObjectID);
///
/// @brief Ending of a NVPMPerfObject, make that NVPMPerfObject inactive
/// @param[in] perfCtx Specify which NVPMContext instance to operate
/// @param[in] nObjectID ID of the NVPMPerfObject to be used
/// @return unified return code #NVPMRESULT
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMEndObject_Pfn)(
NVPMContext perfCtx,
NVPMUINT nObjectID
);
///////////////////////////////////////////////////////////////////////////////
// Sample Methods
// This is the typical "sample now" based interface. If you pass in an array
// of SampleValue's, it will return the currently active counters (NULL returns
// no counters). Fill *punCount with the available entries in pucValues/pucCycles
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// @brief The NVPMSampleValue structure contains the counter ID, value and
/// cycle.
/// @remarks The NVPMSampleValue structure is mainly used in function
/// #NVPMSample to get active counter information.
/// @remarks If the value of counter is RAW type(Integer), it is equal to
/// ulValue.
/// @remarks If the value of counter is PERCENT type(Float), it is equal to
/// ulValue/ulCycles.
/// @see NVPMSample, NVPMSampleValueEx
///////////////////////////////////////////////////////////////////////////////
typedef struct _NVPMSampleValue {
/// ID of counter
NVPMCounterID unCounterID;
/// Value of counter
NVPMUINT64 ulValue;
/// Cycles of counter
NVPMUINT64 ulCycles;
} NVPMSampleValue;
///////////////////////////////////////////////////////////////////////////////
/// @brief The NVPMSampleValueEx structure contains the counter ID, value,
/// cycle and updated flag.
/// @remarks The NVPMSampleValueEx structure is mainly used in function
/// #NVPMSampleEx to get active counter information. It is the extension of
/// structure #NVPMSampleValue.
/// @remarks If the value of counter is RAW type(Integer), it is equal to
/// ulValue.
/// @remarks If the value of counter is RATIO type(Float), it is equal to
/// ulValue/ulCycles.
/// @remarks The member unCounterValueUpdated is only internal used, just set
/// it to 0.
/// @see NVPMSampleEx, NVPMSampleValue
///////////////////////////////////////////////////////////////////////////////
typedef struct _NVPMSampleValueEx {
/// Version of struct
NVPMUINT32 ulVersion;
/// ID of counter
NVPMCounterID unCounterID;
/// Value of counter
union {
NVPMUINT64 ulValue;
NVPMFLOAT64 dValue;
};
/// Cycles of counter
NVPMUINT64 ulCycles;
/// Various flags
NVPMUINT64 ulFlags;
} NVPMSampleValueEx;
#define NVPMSAMPLEEX_FLAG_OVERFLOW 0x0000000000000001 /// Flag used to indicate if the counter value has overflowed.
#define NVPMSAMPLEEX_FLAG_UPDATED 0x0000000000000002 /// Flag used to check the counter value updated.
#define NVPMSAMPLEEX_FLAG_VALUE_TYPE_MASK 0x000000000000FF00
#define NVPMSAMPLEEX_FLAG_VALUE_TYPE_SHIFT 8
#define NVPMSAMPLEEX_FLAG_VALUE_TYPE(flag) ((NVPMCOUNTERVALUETYPE) (((flag) & NVPMSAMPLEEX_FLAG_VALUE_TYPE_MASK) >> NVPMSAMPLEEX_FLAG_VALUE_TYPE_SHIFT))
#define MAKE_NVPMSAMPLEVALUEEX_VERSION(VERSION, STRUCT_SIZE) (NVPMUINT32)((VERSION << 16) | STRUCT_SIZE)
/// nvpm sample value ex version major */
#define NVPMSAMPLEVALUEEX_VER_1 1
#define NVPMSAMPLEVALUEEX_VER_2 2
#define NVPMSAMPLEVALUEEX_VER NVPMSAMPLEVALUEEX_VER_2 // The latest version is VER_2. VER_1 is still supported and
// the old NVPMSampleValueEx is compatible with the new one.
#define NVPMSAMPLEVALUEEX_VERSION() MAKE_NVPMSAMPLEVALUEEX_VERSION( NVPMSAMPLEVALUEEX_VER, sizeof(NVPMSampleValueEx) )
#define NVPMSAMPLEVALUEEX_VERSION_GET_STRUCT_SIZE(X) ( (X) & 0xFFFF )
#define NVPMSAMPLEVALUEEX_VERSION_GET_VERSION(X) ( (X) >> 16 )
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMSample(NVPMContext perfCtx, NVPMSampleValue *pSamples, NVPMUINT *punCount);
///
/// @brief Sample active counters for a specified NVPMContext and output active
/// counter information
/// @param[in] perfCtx Specify which NVPMContext instance to operate
/// @param[out] pSamples The buffer which get the updated counter information
/// from the core.
/// @param[in,out] punCount Input as the item count of pSamples, and output as
/// the number of counter information which is actually saved to pSample.
/// @return If succeed, return NVPM_OK, else unified return code #NVPMRESULT.
/// @remarks When pSamples and punCount are both NULL, will not update the
/// active counter data.
/// @remarks When pSamples is NULL and punCount is not NULL, will update the
/// active counter data, but no counter data will be output and *punCount
/// will set to 0.
/// @remarks When pSamples is not NULL and punCount is NULL, will update the
/// active counter data, but no counter data will be output to pSamples.
/// @remarks When neither pSamples nor punCount is NULL, the following actions
/// will be taken in order:
/// *punCount = min(*punCount,number of active counters);
/// Update *punCount active counters' data into pSamples.
/// @remarks You can also get active counter value by function
/// #NVPMGetCounterValueByName
/// @see NVPMGetCounterValueByName, NVPMSampleValue, NVPMSampleValueEx,
/// NVPMSampleEx
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMSample_Pfn)(
NVPMContext perfCtx,
NVPMSampleValue *pSamples,
NVPMUINT *punCount
);
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMSampleEx(NVPMContext perfCtx, NVPMSampleValueEx *pSamples, NVPMUINT *punCount, NVPMUINT unNVPMSampleValueExVersion);
///
/// @brief Extended version of NVPMSample
/// @param[in] perfCtx Specify which NVPMContext instance to operate
/// @param[out] pSamples The buffer which get the updated counter information
/// from the core.
/// @param[in,out] punCount Input as the item count of pSamples, and output as
/// the number of counter information which is actually saved to pSample.
/// @param[in] unNVPMSampleValueExVersion version of NVPMSampleValueEx
/// @return If succeed, return NVPM_OK, else unified return code #NVPMRESULT.
/// @remarks When pSamples and punCount are both NULL, will not update the
/// active counter data.
/// @remarks When pSamples is NULL and punCount is NULL, update the active
/// counter data.
/// @remarks When pSamples is NULL and punCount is not NULL, will update the
/// active counter data, but no counter data will be output and *punCount
/// will set to 0.
/// @remarks When pSamples is not NULL and punCount is NULL, will update the
/// active counter data, but no counter data will be output to pSamples.
/// @remarks When neither pSamples nor punCount is NULL, the following actions
/// will be taken in order:
/// *punCount = min(*punCount,number of active counters);
/// Update *punCount active counters' data into pSamples.
/// @remarks You can also get active counter value by function
/// #NVPMGetCounterValueByName
/// @see NVPMGetCounterValueByName, NVPMSample, NVPMSampleValue,
/// NVPMSampleValueEx,
///
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMSampleEx_Pfn)(
NVPMContext perfCtx,
NVPMSampleValueEx *pSamples,
NVPMUINT *punCount
);
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMGetCounterValueByName(NVPMContext perfCtx, const char *pcName, NVPMUINT nObjectID, NVPMUINT64 *pulValue, NVPMUINT64 *pulCycles);
///
/// @brief Get value of a counter specified by name in a give NVPMPerfObject of
/// a given NVPMPerfContext
/// @param[in] perfCtx Specify which NVPMContext instance to operate
/// @param[in] pcName name of the target counter
/// @param[in] nObjectID ID of the NVPMPerfObject
/// @param[out] pulValue returned value of that counter
/// @param[out] pulCycles returned cycles number of that counter
/// @param[out] pOverflow returned overflow flags, if it's nozero, the counter has overflowed. Otherwise it hasn't overflowed.
/// @return unified return code #NVPMRESULT. If the counter's value type cannot be returned by the called function, NVPM_INCORRECT_VALUE_TYPE will be returned.
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMGetCounterValueByName_Pfn)(
NVPMContext perfCtx,
const char *pcName,
NVPMUINT nObjectID,
NVPMUINT64 *pulValue,
NVPMUINT64 *pulCycles
);
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMGetCounterValue{Uint64,Float64}(NVPMContext perfCtx, NVPMCounterID unCounterID, NVPMUINT nObjectID, NVPM{UINT,FLOAT}64 *pulValue, NVPMUINT64 *pulCycles);
///
/// @brief Get value of a counter specified by ID in a give NVPMPerfObject
/// of a given NVPMPerfContext
/// @param[in] perfCtx Specify which NVPMContext instance to operate
/// @param[in] unCounterID ID of the target counter
/// @param[in] nObjectID ID of given NVPMPerfObject
/// @param[out] p{ul,d}Value returned value of that counter
/// @param[out] pulCycles returned cycles number of that counter
/// @param[out] pOverflow returned overflow flags, if it's nozero, the counter has overflowed. Otherwise it hasn't overflowed.
/// @return unified return code #NVPMRESULT. If the counter's value type cannot be returned by the called function, NVPM_INCORRECT_VALUE_TYPE will be returned.
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMGetCounterValue_Pfn)(
NVPMContext perfCtx,
NVPMCounterID unCounterID,
NVPMUINT nObjectID,
NVPMUINT64 *pulValue,
NVPMUINT64 *pulCycles
);
typedef NVPMRESULT (NVCALL *NVPMGetCounterValueUint64_Pfn)(
NVPMContext perfCtx,
NVPMCounterID unCounterID,
NVPMUINT nObjectID,
NVPMUINT64 *pulValue,
NVPMUINT64 *pulCycles,
NVPMUINT8 *pOverflow
);
typedef NVPMRESULT (NVCALL *NVPMGetCounterValueFloat64_Pfn)(
NVPMContext perfCtx,
NVPMCounterID unCounterID,
NVPMUINT nObjectID,
NVPMFLOAT64 *pdValue,
NVPMUINT64 *pulCycles,
NVPMUINT8 *pOverflow
);
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMGetGPUBottleneckName(NVPMContext perfCtx, NVPMUINT64 ulValue, char *pcName);
///
/// @brief convert bottleneck pipeline stage from ID to meaningful name string
/// @param[in] perfCtx Specify which NVPMContext instance to operate
/// @param[in] ulValue pipeline stage id
/// @param[out] pcName returned name string of the given pipeline stage
/// @return unified return code #NVPMRESULT
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMGetGPUBottleneckName_Pfn)(
NVPMContext perfCtx,
NVPMUINT64 ulValue,
char *pcName
);
///////////////////////////////////////////////////////////////////////////////
/// NVPMRESULT NVPMRegisterNewDataProviderCallback(FuncPtrNewDataProvider fpNewDP);
///
/// @brief register a callback function to be called when new data provider is
/// registered to the NVPMAPI module
/// @param[in] fpNewDP function pointer, return NVPMUINT64 and void parameter
/// @return unified return code #NVPMRESULT
///////////////////////////////////////////////////////////////////////////////
typedef NVPMUINT64 (*FuncPtrNewDataProvider)(void);
typedef NVPMRESULT (NVCALL *NVPMRegisterNewDataProviderCallback_Pfn)(
FuncPtrNewDataProvider fpNewDP
);
///////////////////////////////////////////////////////////////////////////////
// This section defines the external/exported interface for NVPMAPI-Next via
// function pointers.
///////////////////////////////////////////////////////////////////////////////
#ifdef GUID_DEFINED
typedef GUID NVPM_UUID;
#else
/// The standard UUID definition. sizeof(NVPM_UUID) *needs* to be 16.
/// If it isn't on a needed compilation platform, we need nasty Work-ARounds.
typedef struct NVPM_UUID {
NVPMUINT Data1;
NVPMUINT16 Data2;
NVPMUINT16 Data3;
NVPMUINT8 Data4[8];
} NVPM_UUID;
#endif
#ifdef NVPM_INITGUID
// MSVC seems to require the use of "extern" here, whereas every other
// compiler seems require omitting it.
#if defined(_MSC_VER)
#define NVPM_DEFINE_GUID(x__, a, b, c, d0,d1,d2,d3,d4,d5,d6,d7) \
extern const NVPM_UUID x__ = {a, b, c, {d0,d1,d2,d3,d4,d5,d6,d7}}
#else // !defined(_MSC_VER)
#define NVPM_DEFINE_GUID(x__, a, b, c, d0,d1,d2,d3,d4,d5,d6,d7) \
const NVPM_UUID x__ = {a, b, c, {d0,d1,d2,d3,d4,d5,d6,d7}}
#endif // defined(_MSC_VER)
#else // !NVPM_INITGUID
#define NVPM_DEFINE_GUID(x__, a, b, c, d0,d1,d2,d3,d4,d5,d6,d7) \
extern const NVPM_UUID x__
#endif // NVPM_INITGUID
// {243E8DA1-4BF8-44B9-98C4-F984D06BDF46}
NVPM_DEFINE_GUID(ETID_NvPmApi,
0x243e8da1, 0x4bf8, 0x44b9, 0x98, 0xc4, 0xf9, 0x84, 0xd0, 0x6b, 0xdf, 0x46);
typedef struct _NvPmApi
{
// This export table supports versioning by adding to the end without changing
// the ETID. The struct_size field will always be set to the size in bytes of
// the entire export table structure.
NVPMUINT struct_size;
NVPMSetWarningLevel_Pfn SetWarningLevel;
NVPMGetExtendedError_Pfn GetExtendedError;
NVPMInit_Pfn Init;
NVPMShutdown_Pfn Shutdown;
NVPMCreateContextFromOGLContext_Pfn CreateContextFromOGLContext;
NVPMCreateContextFromCudaContext_Pfn CreateContextFromCudaContext;
#if defined(_WIN32)
NVPMCreateContextFromD3D9Device_Pfn CreateContextFromD3D9Device;
NVPMCreateContextFromD3D10Device_Pfn CreateContextFromD3D10Device;
NVPMCreateContextFromD3D11Device_Pfn CreateContextFromD3D11Device;
NVPMCreateContextFromD3D11Device1_Pfn CreateContextFromD3D11Device1;
#endif
NVPMDestroyContext_Pfn DestroyContext;
NVPMEnumCountersByContext_Pfn EnumCountersByContext;
NVPMGetCounterName_Pfn GetCounterName;
NVPMGetCounterDescription_Pfn GetCounterDescription;
NVPMGetCounterIDByContext_Pfn GetCounterIDByContext;
NVPMGetCounterClockRateByContext_Pfn GetCounterClockRateByContext;
NVPMGetCounterAttribute_Pfn GetCounterAttribute;
NVPMAddCounterByName_Pfn AddCounterByName;
NVPMAddCounter_Pfn AddCounter;
NVPMAddCounters_Pfn AddCounters;
NVPMRemoveCounterByName_Pfn RemoveCounterByName;
NVPMRemoveCounter_Pfn RemoveCounter;
NVPMRemoveCounters_Pfn RemoveCounters;
NVPMRemoveAllCounters_Pfn RemoveAllCounters;
NVPMReserveObjects_Pfn ReserveObjects;
NVPMDeleteObjects_Pfn DeleteObjects;
NVPMBeginExperiment_Pfn BeginExperiment;
NVPMEndExperiment_Pfn EndExperiment;
NVPMBeginPass_Pfn BeginPass;
NVPMEndPass_Pfn EndPass;
NVPMBeginObject_Pfn BeginObject;
NVPMEndObject_Pfn EndObject;
NVPMSample_Pfn Sample;
NVPMSampleEx_Pfn SampleEx;
NVPMGetCounterValueByName_Pfn GetCounterValueByName;
NVPMGetCounterValue_Pfn GetCounterValue;
NVPMGetGPUBottleneckName_Pfn GetGPUBottleneckName;
NVPMRegisterNewDataProviderCallback_Pfn RegisterNewDataProviderCallback;
NVPMGetCounterValueUint64_Pfn GetCounterValueUint64;
NVPMGetCounterValueFloat64_Pfn GetCounterValueFloat64;
NVPMEnumCountersByContextUserData_Pfn EnumCountersByContextUserData;
} NvPmApi;
///////////////////////////////////////////////////////////////////////////////
/// NVPMAPI_INTERFACE NVPMGetExportTable(const NVPM_UUID* pExportTableId, void** ppExportTable);
///
/// @brief Get interface table
/// @param[in] const NVPM_UUID* pExportTableId GUID for the interface table
/// @param[out] void** ppExportTable table exported
/// @return unified return code #NVPMRESULT
///////////////////////////////////////////////////////////////////////////////
typedef NVPMRESULT (NVCALL *NVPMGetExportTable_Pfn)(
const NVPM_UUID* pExportTableId,
void** ppExportTable);
#ifdef __cplusplus
};
#endif // End of __cplusplus
#endif // End of _NVPMAPI_H_
+3
View File
@@ -533,6 +533,9 @@
<ProjectReference Include="driver\ihv\amd\AMD.vcxproj">
<Project>{5de5a561-548a-4dd7-90f0-06a2b39eae9a}</Project>
</ProjectReference>
<ProjectReference Include="driver\ihv\nv\NV.vcxproj">
<Project>{40349ad9-5558-4df4-84e2-11934de90a11}</Project>
</ProjectReference>
<ProjectReference Include="driver\vulkan\renderdoc_vulkan.vcxproj">
<Project>{88c5dac6-30a0-4cfd-af51-540a977d1f3f}</Project>
</ProjectReference>