Update the AMD GPA integration for GPA 3.0.

This commit is contained in:
Matthäus G. Chajdas
2017-09-27 15:35:41 +02:00
committed by Baldur Karlsson
parent c05bdc2032
commit 4bd282755d
14 changed files with 341 additions and 437 deletions
+43 -184
View File
@@ -31,77 +31,6 @@
#include "serialise/string_utils.h"
typedef GPA_Status(__stdcall *PFN_GPA_INITIALIZE)();
typedef GPA_Status(__stdcall *PFN_GPA_OPENCONTEXT)(void *pContext);
typedef GPA_Status(__stdcall *PFN_GPA_GET_NUM_COUNTERS)(gpa_uint32 *pCount);
typedef GPA_Status(__stdcall *PFN_GPA_GET_COUNTER_NAME)(gpa_uint32 index, const char **ppName);
typedef GPA_Status(__stdcall *PFN_GPA_GET_COUNTER_INDEX)(const char *pCounter, gpa_uint32 *pIndex);
typedef GPA_Status(__stdcall *PFN_GPA_GET_COUNTER_DESCRIPTION)(gpa_uint32 index,
const char **ppDescription);
typedef GPA_Status(__stdcall *PFN_GPA_GET_COUNTER_DATA_TYPE)(gpa_uint32 index, GPA_Type *pDataType);
typedef GPA_Status(__stdcall *PFN_GPA_GET_COUNTER_USAGE_TYPE)(gpa_uint32 index,
GPA_Usage_Type *usageType);
typedef GPA_Status(__stdcall *PFN_GPA_ENABLE_COUNTER)(gpa_uint32 index);
typedef GPA_Status(__stdcall *PFN_GPA_ENABLE_COUNTER_STR)(const char *pCounter);
typedef GPA_Status(__stdcall *PFN_GPA_ENABLE_ALL_COUNTERS)();
typedef GPA_Status(__stdcall *PFN_GPA_DISABLE_COUNTER)(gpa_uint32 index);
typedef GPA_Status(__stdcall *PFN_GPA_DISABLE_COUNTER_STR)(const char *pCounter);
typedef GPA_Status(__stdcall *PFN_GPA_DISABLE_ALL_COUNTERS)();
typedef GPA_Status(__stdcall *PFN_GPA_GET_PASS_COUNT)(gpa_uint32 *pNumPasses);
typedef GPA_Status(__stdcall *PFN_GPA_BEGIN_SESSION)(gpa_uint32 *pSessionID);
typedef GPA_Status(__stdcall *PFN_GPA_END_SESSION)();
typedef GPA_Status(__stdcall *PFN_GPA_BEGIN_PASS)();
typedef GPA_Status(__stdcall *PFN_GPA_END_PASS)();
typedef GPA_Status(__stdcall *PFN_GPA_BEGIN_SAMPLE)(gpa_uint32 sampleID);
typedef GPA_Status(__stdcall *PFN_GPA_END_SAMPLE)();
typedef GPA_Status(__stdcall *PFN_GPA_IS_SESSION_READY)(bool *pReadyResult, gpa_uint32 sessionID);
typedef GPA_Status(__stdcall *PFN_GPA_IS_SAMPLE_READY)(bool *pReadyResult, gpa_uint32 sessionID,
gpa_uint32 sampleID);
typedef GPA_Status(__stdcall *PFN_GPA_GET_SAMPLE_UINT32)(gpa_uint32 sessionID, gpa_uint32 sampleID,
gpa_uint32 counterID, gpa_uint32 *pResult);
typedef GPA_Status(__stdcall *PFN_GPA_GET_SAMPLE_UINT64)(gpa_uint32 sessionID, gpa_uint32 sampleID,
gpa_uint32 counterID, gpa_uint64 *pResult);
typedef GPA_Status(__stdcall *PFN_GPA_GET_SAMPLE_FLOAT32)(gpa_uint32 sessionID, gpa_uint32 sampleID,
gpa_uint32 counterID, gpa_float32 *pResult);
typedef GPA_Status(__stdcall *PFN_GPA_GET_SAMPLE_FLOAT64)(gpa_uint32 sessionID, gpa_uint32 sampleID,
gpa_uint32 counterID, gpa_float64 *pResult);
typedef GPA_Status(__stdcall *PFN_GPA_CLOSE_CONTEXT)();
typedef GPA_Status(__stdcall *PFN_GPA_DESTROY)();
class GPUPerfAPI
{
public:
PFN_GPA_INITIALIZE init;
PFN_GPA_OPENCONTEXT openContext;
PFN_GPA_GET_NUM_COUNTERS getNumCounters;
PFN_GPA_GET_COUNTER_NAME getCounterName;
PFN_GPA_GET_COUNTER_INDEX getCounterIndex;
PFN_GPA_GET_COUNTER_DESCRIPTION getCounterDescription;
PFN_GPA_GET_COUNTER_DATA_TYPE getCounterDataType;
PFN_GPA_GET_COUNTER_USAGE_TYPE getCounterUsageType;
PFN_GPA_ENABLE_COUNTER enableCounter;
PFN_GPA_ENABLE_COUNTER_STR enableCounterStr;
PFN_GPA_ENABLE_ALL_COUNTERS enableAllCounters;
PFN_GPA_DISABLE_COUNTER disableCounter;
PFN_GPA_DISABLE_COUNTER_STR disableCounterStr;
PFN_GPA_DISABLE_ALL_COUNTERS disableAllCounters;
PFN_GPA_GET_PASS_COUNT getPassCount;
PFN_GPA_BEGIN_SESSION beginSession;
PFN_GPA_END_SESSION endSession;
PFN_GPA_BEGIN_PASS beginPass;
PFN_GPA_END_PASS endPass;
PFN_GPA_BEGIN_SAMPLE beginSample;
PFN_GPA_END_SAMPLE endSample;
PFN_GPA_IS_SESSION_READY isSessionReady;
PFN_GPA_IS_SAMPLE_READY isSampleReady;
PFN_GPA_GET_SAMPLE_UINT32 getSampleUInt32;
PFN_GPA_GET_SAMPLE_UINT64 getSampleUInt64;
PFN_GPA_GET_SAMPLE_FLOAT32 getSampleFloat32;
PFN_GPA_GET_SAMPLE_FLOAT64 getSampleFloat64;
PFN_GPA_CLOSE_CONTEXT closeContext;
PFN_GPA_DESTROY destroy;
};
AMDCounters::AMDCounters() : m_pGPUPerfAPI(NULL)
{
}
@@ -128,65 +57,27 @@ bool AMDCounters::Init(void *pContext)
return false;
}
m_pGPUPerfAPI = new GPUPerfAPI();
m_pGPUPerfAPI->init = (PFN_GPA_INITIALIZE)GetProcAddress(module, "GPA_Initialize");
m_pGPUPerfAPI->openContext = (PFN_GPA_OPENCONTEXT)GetProcAddress(module, "GPA_OpenContext");
m_pGPUPerfAPI->getNumCounters =
(PFN_GPA_GET_NUM_COUNTERS)GetProcAddress(module, "GPA_GetNumCounters");
m_pGPUPerfAPI->getCounterName =
(PFN_GPA_GET_COUNTER_NAME)GetProcAddress(module, "GPA_GetCounterName");
m_pGPUPerfAPI->getCounterIndex =
(PFN_GPA_GET_COUNTER_INDEX)GetProcAddress(module, "GPA_GetCounterIndex");
m_pGPUPerfAPI->getCounterDescription =
(PFN_GPA_GET_COUNTER_DESCRIPTION)GetProcAddress(module, "GPA_GetCounterDescription");
m_pGPUPerfAPI->getCounterDataType =
(PFN_GPA_GET_COUNTER_DATA_TYPE)GetProcAddress(module, "GPA_GetCounterDataType");
m_pGPUPerfAPI->getCounterUsageType =
(PFN_GPA_GET_COUNTER_USAGE_TYPE)GetProcAddress(module, "GPA_GetCounterUsageType");
m_pGPUPerfAPI->enableCounter =
(PFN_GPA_ENABLE_COUNTER)GetProcAddress(module, "GPA_EnableCounter");
m_pGPUPerfAPI->enableCounterStr =
(PFN_GPA_ENABLE_COUNTER_STR)GetProcAddress(module, "GPA_EnableCounterStr");
m_pGPUPerfAPI->enableAllCounters =
(PFN_GPA_ENABLE_ALL_COUNTERS)GetProcAddress(module, "GPA_EnableAllCounters");
m_pGPUPerfAPI->disableCounter =
(PFN_GPA_DISABLE_COUNTER)GetProcAddress(module, "GPA_DisableCounter");
m_pGPUPerfAPI->disableCounterStr =
(PFN_GPA_DISABLE_COUNTER_STR)GetProcAddress(module, "GPA_DisableCounterStr");
m_pGPUPerfAPI->disableAllCounters =
(PFN_GPA_DISABLE_ALL_COUNTERS)GetProcAddress(module, "GPA_DisableAllCounters");
m_pGPUPerfAPI->getPassCount = (PFN_GPA_GET_PASS_COUNT)GetProcAddress(module, "GPA_GetPassCount");
m_pGPUPerfAPI->beginSession = (PFN_GPA_BEGIN_SESSION)GetProcAddress(module, "GPA_BeginSession");
m_pGPUPerfAPI->endSession = (PFN_GPA_END_SESSION)GetProcAddress(module, "GPA_EndSession");
m_pGPUPerfAPI->beginPass = (PFN_GPA_BEGIN_PASS)GetProcAddress(module, "GPA_BeginPass");
m_pGPUPerfAPI->endPass = (PFN_GPA_END_PASS)GetProcAddress(module, "GPA_EndPass");
m_pGPUPerfAPI->beginSample = (PFN_GPA_BEGIN_SAMPLE)GetProcAddress(module, "GPA_BeginSample");
m_pGPUPerfAPI->endSample = (PFN_GPA_END_SAMPLE)GetProcAddress(module, "GPA_EndSample");
m_pGPUPerfAPI->isSessionReady =
(PFN_GPA_IS_SESSION_READY)GetProcAddress(module, "GPA_IsSessionReady");
m_pGPUPerfAPI->isSampleReady =
(PFN_GPA_IS_SAMPLE_READY)GetProcAddress(module, "GPA_IsSampleReady");
m_pGPUPerfAPI->getSampleUInt32 =
(PFN_GPA_GET_SAMPLE_UINT32)GetProcAddress(module, "GPA_GetSampleUInt32");
m_pGPUPerfAPI->getSampleUInt64 =
(PFN_GPA_GET_SAMPLE_UINT64)GetProcAddress(module, "GPA_GetSampleUInt64");
m_pGPUPerfAPI->getSampleFloat32 =
(PFN_GPA_GET_SAMPLE_FLOAT32)GetProcAddress(module, "GPA_GetSampleFloat32");
m_pGPUPerfAPI->getSampleFloat64 =
(PFN_GPA_GET_SAMPLE_FLOAT64)GetProcAddress(module, "GPA_GetSampleFloat64");
m_pGPUPerfAPI->closeContext = (PFN_GPA_CLOSE_CONTEXT)GetProcAddress(module, "GPA_CloseContext");
m_pGPUPerfAPI->destroy = (PFN_GPA_DESTROY)GetProcAddress(module, "GPA_Destroy");
m_pGPUPerfAPI = new GPAApi();
GPA_GetFuncTablePtrType getFuncTable =
(GPA_GetFuncTablePtrType)GetProcAddress(module, "GPA_GetFuncTable");
if(m_pGPUPerfAPI->init() != GPA_STATUS_OK)
if(getFuncTable)
{
getFuncTable((void **)&m_pGPUPerfAPI);
}
if(m_pGPUPerfAPI->GPA_Initialize() != GPA_STATUS_OK)
{
delete m_pGPUPerfAPI;
m_pGPUPerfAPI = NULL;
return false;
}
if(m_pGPUPerfAPI->openContext(pContext) != GPA_STATUS_OK)
if(m_pGPUPerfAPI->GPA_OpenContext(pContext, GPA_OPENCONTEXT_HIDE_PUBLIC_COUNTERS_BIT |
GPA_OPENCONTEXT_CLOCK_MODE_PEAK_BIT) !=
GPA_STATUS_OK)
{
m_pGPUPerfAPI->destroy();
m_pGPUPerfAPI->GPA_Destroy();
delete m_pGPUPerfAPI;
m_pGPUPerfAPI = NULL;
return false;
@@ -203,8 +94,8 @@ AMDCounters::~AMDCounters()
{
GPA_Status status = GPA_STATUS_OK;
status = m_pGPUPerfAPI->closeContext();
status = m_pGPUPerfAPI->destroy();
status = m_pGPUPerfAPI->GPA_CloseContext();
status = m_pGPUPerfAPI->GPA_Destroy();
delete m_pGPUPerfAPI;
}
@@ -214,7 +105,7 @@ vector<AMDCounters::InternalCounterDescription> AMDCounters::EnumerateCounters()
{
gpa_uint32 num;
m_pGPUPerfAPI->getNumCounters(&num);
m_pGPUPerfAPI->GPA_GetNumCounters(&num);
vector<InternalCounterDescription> counters;
@@ -223,12 +114,6 @@ vector<AMDCounters::InternalCounterDescription> AMDCounters::EnumerateCounters()
InternalCounterDescription internalDesc;
internalDesc.desc = InternalGetCounterDescription(i);
// We ignore any D3D11 counters, as those are handled elsewhere
if(strncmp(internalDesc.desc.category.c_str(), "D3D11", 5) == 0)
{
continue;
}
internalDesc.internalIndex = i;
internalDesc.desc.counterID = MakeAMDCounter(i);
counters.push_back(internalDesc);
@@ -251,42 +136,16 @@ CounterDescription AMDCounters::InternalGetCounterDescription(uint32_t internalI
{
CounterDescription desc = {};
const char *tmp = NULL;
m_pGPUPerfAPI->getCounterName(internalIndex, &tmp);
m_pGPUPerfAPI->GPA_GetCounterName(internalIndex, &tmp);
desc.name = tmp;
m_pGPUPerfAPI->getCounterDescription(internalIndex, &tmp);
std::vector<char> descCopy;
int separator = -1;
int sharpFound = 0;
const char *c = tmp;
while(*c)
{
if(*c == '#')
{
++sharpFound;
descCopy.push_back('\0');
if(sharpFound == 2)
{
separator = (int32_t)(c - tmp);
}
}
else
{
descCopy.push_back(*c);
}
++c;
}
descCopy.push_back('\0');
desc.category = descCopy.data() + 1;
desc.description = descCopy.data() + separator + 1;
m_pGPUPerfAPI->GPA_GetCounterDescription(internalIndex, &tmp);
desc.description = tmp;
m_pGPUPerfAPI->GPA_GetCounterCategory(internalIndex, &tmp);
desc.category = tmp;
GPA_Usage_Type usageType;
m_pGPUPerfAPI->getCounterUsageType(internalIndex, &usageType);
m_pGPUPerfAPI->GPA_GetCounterUsageType(internalIndex, &usageType);
switch(usageType)
{
@@ -316,7 +175,7 @@ CounterDescription AMDCounters::InternalGetCounterDescription(uint32_t internalI
GPA_Type type;
m_pGPUPerfAPI->getCounterDataType(internalIndex, &type);
m_pGPUPerfAPI->GPA_GetCounterDataType(internalIndex, &type);
// results should either be float32/64 or uint32/64 as the GetSample functions only support those
switch(type)
@@ -361,23 +220,23 @@ void AMDCounters::EnableCounter(GPUCounter counter)
{
const uint32_t internalIndex = m_Counters[GPUCounterToCounterIndex(counter)].internalIndex;
m_pGPUPerfAPI->enableCounter(internalIndex);
m_pGPUPerfAPI->GPA_EnableCounter(internalIndex);
}
void AMDCounters::EnableAllCounters()
{
m_pGPUPerfAPI->enableAllCounters();
m_pGPUPerfAPI->GPA_EnableAllCounters();
}
void AMDCounters::DisableAllCounters()
{
m_pGPUPerfAPI->disableAllCounters();
m_pGPUPerfAPI->GPA_DisableAllCounters();
}
uint32_t AMDCounters::GetPassCount()
{
gpa_uint32 numRequiredPasses;
m_pGPUPerfAPI->getPassCount(&numRequiredPasses);
m_pGPUPerfAPI->GPA_GetPassCount(&numRequiredPasses);
return (uint32_t)numRequiredPasses;
}
@@ -386,43 +245,43 @@ uint32_t AMDCounters::BeginSession()
{
gpa_uint32 sessionID;
m_pGPUPerfAPI->beginSession(&sessionID);
m_pGPUPerfAPI->GPA_BeginSession(&sessionID);
return (uint32_t)sessionID;
}
void AMDCounters::EndSesssion()
{
m_pGPUPerfAPI->endSession();
m_pGPUPerfAPI->GPA_EndSession();
}
bool AMDCounters::IsSessionReady(uint32_t sessionIndex)
{
bool readyResult = false;
gpa_uint8 readyResult = 0;
GPA_Status status = m_pGPUPerfAPI->isSessionReady(&readyResult, sessionIndex);
GPA_Status status = m_pGPUPerfAPI->GPA_IsSessionReady(&readyResult, sessionIndex);
return readyResult && status == GPA_STATUS_OK;
}
void AMDCounters::BeginPass()
{
m_pGPUPerfAPI->beginPass();
m_pGPUPerfAPI->GPA_BeginPass();
}
void AMDCounters::EndPass()
{
m_pGPUPerfAPI->endPass();
m_pGPUPerfAPI->GPA_EndPass();
}
void AMDCounters::BeginSample(uint32_t index)
{
m_pGPUPerfAPI->beginSample(index);
m_pGPUPerfAPI->GPA_BeginSample(index);
}
void AMDCounters::EndSample()
{
m_pGPUPerfAPI->endSample();
m_pGPUPerfAPI->GPA_EndSample();
}
uint32_t AMDCounters::GetSampleUint32(uint32_t session, uint32_t sample, GPUCounter counter)
@@ -430,11 +289,11 @@ uint32_t AMDCounters::GetSampleUint32(uint32_t session, uint32_t sample, GPUCoun
const uint32_t internalIndex = m_Counters[GPUCounterToCounterIndex(counter)].internalIndex;
uint32_t value;
m_pGPUPerfAPI->getSampleUInt32(session, sample, internalIndex, &value);
m_pGPUPerfAPI->GPA_GetSampleUInt32(session, sample, internalIndex, &value);
// normalise units as expected
GPA_Usage_Type usageType;
m_pGPUPerfAPI->getCounterUsageType(internalIndex, &usageType);
m_pGPUPerfAPI->GPA_GetCounterUsageType(internalIndex, &usageType);
if(usageType == GPA_USAGE_TYPE_KILOBYTES)
value *= 1000;
@@ -447,11 +306,11 @@ uint64_t AMDCounters::GetSampleUint64(uint32_t session, uint32_t sample, GPUCoun
const uint32_t internalIndex = m_Counters[GPUCounterToCounterIndex(counter)].internalIndex;
gpa_uint64 value;
m_pGPUPerfAPI->getSampleUInt64(session, sample, internalIndex, &value);
m_pGPUPerfAPI->GPA_GetSampleUInt64(session, sample, internalIndex, &value);
// normalise units as expected
GPA_Usage_Type usageType;
m_pGPUPerfAPI->getCounterUsageType(internalIndex, &usageType);
m_pGPUPerfAPI->GPA_GetCounterUsageType(internalIndex, &usageType);
if(usageType == GPA_USAGE_TYPE_KILOBYTES)
value *= 1000;
@@ -464,11 +323,11 @@ float AMDCounters::GetSampleFloat32(uint32_t session, uint32_t sample, GPUCounte
const uint32_t internalIndex = m_Counters[GPUCounterToCounterIndex(counter)].internalIndex;
float value;
m_pGPUPerfAPI->getSampleFloat32(session, sample, internalIndex, &value);
m_pGPUPerfAPI->GPA_GetSampleFloat32(session, sample, internalIndex, &value);
// normalise units as expected
GPA_Usage_Type usageType;
m_pGPUPerfAPI->getCounterUsageType(internalIndex, &usageType);
m_pGPUPerfAPI->GPA_GetCounterUsageType(internalIndex, &usageType);
if(usageType == GPA_USAGE_TYPE_KILOBYTES)
value *= 1000.0f;
@@ -483,11 +342,11 @@ double AMDCounters::GetSampleFloat64(uint32_t session, uint32_t sample, GPUCount
const uint32_t internalIndex = m_Counters[GPUCounterToCounterIndex(counter)].internalIndex;
double value;
m_pGPUPerfAPI->getSampleFloat64(session, sample, internalIndex, &value);
m_pGPUPerfAPI->GPA_GetSampleFloat64(session, sample, internalIndex, &value);
// normalise units as expected
GPA_Usage_Type usageType;
m_pGPUPerfAPI->getCounterUsageType(internalIndex, &usageType);
m_pGPUPerfAPI->GPA_GetCounterUsageType(internalIndex, &usageType);
if(usageType == GPA_USAGE_TYPE_KILOBYTES)
value *= 1000.0;
+3 -2
View File
@@ -27,7 +27,7 @@
#include <vector>
#include "api/replay/renderdoc_replay.h"
class GPUPerfAPI;
struct _GPAApi;
inline constexpr GPUCounter MakeAMDCounter(int index)
{
@@ -71,7 +71,8 @@ public:
double GetSampleFloat64(uint32_t session, uint32_t sample, GPUCounter counter);
private:
GPUPerfAPI *m_pGPUPerfAPI;
_GPAApi *m_pGPUPerfAPI;
static uint32_t GPUCounterToCounterIndex(GPUCounter counter)
{
return (uint32_t)(counter) - (uint32_t)(GPUCounter::FirstAMD);
@@ -12,7 +12,6 @@
#include "GPAICounterAccessor.h"
#include "GPAICounterScheduler.h"
#include "GPUPerfAPITypes.h"
#include "GPUPerfAPITypes-Private.h"
// Internal function. We don't want this exposed by the internal DLLs though, so it doesn't use GPALIB_DECL
/// Generates a counter accessor object that can be used to obtain the counters to expose
@@ -12,10 +12,6 @@
GPA_FUNCTION_PREFIX(GPA_RegisterLoggingCallback)
#ifdef AMDT_INTERNAL
GPA_FUNCTION_PREFIX(GPA_RegisterLoggingDebugCallback)
#endif // AMDT_INTERNAL
GPA_FUNCTION_PREFIX(GPA_Initialize)
GPA_FUNCTION_PREFIX(GPA_Destroy)
@@ -27,6 +23,7 @@ GPA_FUNCTION_PREFIX(GPA_SelectContext)
// Counter Interrogation
GPA_FUNCTION_PREFIX(GPA_GetNumCounters)
GPA_FUNCTION_PREFIX(GPA_GetCounterName)
GPA_FUNCTION_PREFIX(GPA_GetCounterCategory)
GPA_FUNCTION_PREFIX(GPA_GetCounterDescription)
GPA_FUNCTION_PREFIX(GPA_GetCounterDataType)
GPA_FUNCTION_PREFIX(GPA_GetCounterUsageType)
@@ -56,6 +53,11 @@ GPA_FUNCTION_PREFIX(GPA_EndSession)
GPA_FUNCTION_PREFIX(GPA_BeginPass)
GPA_FUNCTION_PREFIX(GPA_EndPass)
GPA_FUNCTION_PREFIX(GPA_BeginSampleList)
GPA_FUNCTION_PREFIX(GPA_EndSampleList)
GPA_FUNCTION_PREFIX(GPA_BeginSampleInSampleList)
GPA_FUNCTION_PREFIX(GPA_EndSampleInSampleList)
GPA_FUNCTION_PREFIX(GPA_BeginSample)
GPA_FUNCTION_PREFIX(GPA_EndSample)
@@ -71,9 +73,8 @@ GPA_FUNCTION_PREFIX(GPA_GetSampleFloat32)
GPA_FUNCTION_PREFIX(GPA_GetDeviceID)
GPA_FUNCTION_PREFIX(GPA_GetDeviceDesc)
#ifdef AMDT_INTERNAL
GPA_FUNCTION_PREFIX(GPA_InternalSetDrawCallCounts)
#endif
GPA_FUNCTION_PREFIX(GPA_InternalSetDrawCallCounts)
#ifdef NEED_TO_UNDEFINE_GPA_FUNCTION_PREFIX
#undef GPA_FUNCTION_PREFIX
@@ -40,48 +40,60 @@ struct GPACounterTypeInfo
class GPA_ICounterAccessor
{
public:
/// Set the flags indicating which counters are allowed
/// \param bAllowPublicCounters flag indicating whether or not public counters are allowed
/// \param bAllowHardwareCounters flag indicating whether or not hardware counters are allowed
/// \param bAllowSoftwareCounters flag indicating whether or not software counters are allowed
virtual void SetAllowedCounters(bool bAllowPublicCounters, bool bAllowHardwareCounters, bool bAllowSoftwareCounters) = 0;
/// Get the number of available counters
/// \return the number of available counters
virtual gpa_uint32 GetNumCounters() = 0;
virtual gpa_uint32 GetNumCounters() const = 0;
/// Gets a counter's name
/// \param index The index of a counter, must be between 0 and the value returned from GetNumPublicCounters()
/// \return The counter name
virtual const char* GetCounterName(gpa_uint32 index) = 0;
virtual const char* GetCounterName(gpa_uint32 index) const = 0;
/// Gets the category of the specified counter
/// \param index The index of the counter whose category is needed
/// \return The category of the specified counter
virtual const char* GetCounterCategory(gpa_uint32 index) const = 0;
/// Gets a counter's description
/// \param index The index of a counter, must be between 0 and the value returned from GetNumPublicCounters()
/// \return The counter description
virtual const char* GetCounterDescription(gpa_uint32 index) = 0;
virtual const char* GetCounterDescription(gpa_uint32 index) const = 0;
/// Gets the data type of a public counter
/// \param index The index of a counter
/// \return The data type of the the desired counter
virtual GPA_Type GetCounterDataType(gpa_uint32 index) = 0;
virtual GPA_Type GetCounterDataType(gpa_uint32 index) const = 0;
/// Gets the usage type of a public counter
/// \param index The index of a counter
/// \return The usage of the the desired counter
virtual GPA_Usage_Type GetCounterUsageType(gpa_uint32 index) = 0;
virtual GPA_Usage_Type GetCounterUsageType(gpa_uint32 index) const = 0;
/// Gets a public counter
/// \param index The index of the public counter to return
/// \return A public counter
virtual const GPA_PublicCounter* GetPublicCounter(gpa_uint32 index) = 0;
virtual const GPA_PublicCounter* GetPublicCounter(gpa_uint32 index) const = 0;
/// Gets a hardware counter
/// \param index The index of a hardware counter to return
/// \return A hardware counter
virtual GPA_HardwareCounterDescExt* GetHardwareCounterExt(gpa_uint32 index) = 0;
virtual const GPA_HardwareCounterDescExt* GetHardwareCounterExt(gpa_uint32 index) const = 0;
/// Gets the number of public counters available
/// \return The number of public counters
virtual gpa_uint32 GetNumPublicCounters() = 0;
virtual gpa_uint32 GetNumPublicCounters() const = 0;
/// Gets the internal counters required for the specified public counter index
/// \param index The index of a public counter
/// \return A vector of internal counter indices
virtual std::vector<gpa_uint32> GetInternalCountersRequired(gpa_uint32 index) = 0;
virtual std::vector<gpa_uint32> GetInternalCountersRequired(gpa_uint32 index) const = 0;
/// Computes a public counter value pased on supplied results and hardware info
/// \param[in] counterIndex The public counter index to calculate
@@ -94,13 +106,16 @@ public:
/// Gets the counter type information based on the global counter index
/// \param globalIndex The index into the main list of counters
/// \return The info about the counter
virtual GPACounterTypeInfo GetCounterTypeInfo(gpa_uint32 globalIndex) = 0;
virtual GPACounterTypeInfo GetCounterTypeInfo(gpa_uint32 globalIndex) const = 0;
/// Gets a counter's index
/// \param pName The name of a counter
/// \param[out] pIndex The index of the counter
/// \return true if the counter is found, false otherwise
virtual bool GetCounterIndex(const char* pName, gpa_uint32* pIndex) = 0;
virtual bool GetCounterIndex(const char* pName, gpa_uint32* pIndex) const = 0;
/// Virtual Destructor
virtual ~GPA_ICounterAccessor() = default;
};
#endif //_GPA_I_COUNTER_ACCESSOR_H_
@@ -1,46 +0,0 @@
//==============================================================================
// Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved.
/// \author AMD Developer Tools Team
/// \file
/// \brief This file can be included by an application that wishes to use the HSA
/// version of GPUPerfAPI. It defines a structure that can be passed to the
/// GPA_OpenContext call when using GPUPerfAPI with HSA.
//==============================================================================
#ifndef _GPUPERFAPI_HSA_H_
#define _GPUPERFAPI_HSA_H_
#include "GPUPerfAPITypes.h"
#include "GPUPerfAPI.h"
#include "hsa.h"
// NOTE: When using the HSA version of GPUPerfAPI, you can initialize and call
// GPUPerfAPI in one of two ways:
// 1) You must call GPA_Initialize prior to the application initializing
// the HSA runtime with a call to hsa_init. You can then simply pass
// in a hsa_queue_t* instance when calling GPA_OpenContext. When doing
// this, GPUPerfAPI will set up the HSA runtime correctly to use the
// AQL-emulation mode and the pre/post-dispatch callbacks.
// 2) You can perform all initialization yourself to ensure that AQL-emulation
// mode is used and the pre/post-dispatch callbacks are used. In that case,
// you can then call GPA_OpenContext with an instance of the below structure
// (whose members you would initialize with data provided by the pre-dispatch
// callback). Note: this second method is currently used by the CodeXL GPU
// Profiler, though in the future, it may be modified to use the first method.
//
// It is recommended to use the first method above when using GPUPerfAPI directly
// from an HSA application.
/// an instance of this structure can be passed to GPA_OpenContext for the HSA
/// version of GPUPerfAPI.
typedef struct
{
const hsa_agent_t* m_pAgent; ///< the agent
const hsa_queue_t* m_pQueue; ///< the queue
void* m_pAqlTranslationHandle; ///< the AQL translation handle (an opaque pointer) supplied by the pre-dispatch callback
} GPA_HSA_Context;
#endif // _GPUPERFAPI_HSA_H_
@@ -1,49 +0,0 @@
//==============================================================================
// Copyright (c) 2009-2016 Advanced Micro Devices, Inc. All rights reserved.
/// \author AMD Developer Tools Team
/// \file
/// \brief Include this file rather than GPUPerfAPI.h for our internal usage.
//==============================================================================
#ifndef _GPUPERFAPI_PRIVATE_H_
#define _GPUPERFAPI_PRIVATE_H_
#include "GPUPerfAPIOS.h"
#include "GPUPerfAPI.h"
#include "GPUPerfAPITypes-Private.h"
#include "GPUPerfAPIFunctionTypes-Private.h"
// For internal use only
// *INDENT-OFF*
#ifdef AMDT_INTERNAL
/// \brief Register a debug callback function to receive debug log messages.
///
/// Only one debug callback function can be registered, so the implementation should be able
/// to handle the different types of messages. A parameter to the callback function will
/// indicate the message type being received.
/// \param loggingType Identifies the type of messages to receive callbacks for.
/// \param callbackFuncPtr Pointer to the callback function
/// \return GPA_STATUS_OK, unless the callbackFuncPtr is nullptr and the loggingType is not
/// GPA_LOGGING_NONE, in which case GPA_STATUS_ERROR_NULL_POINTER is returned.
GPALIB_DECL GPA_Status GPA_RegisterLoggingDebugCallback(GPA_Log_Debug_Type loggingType, GPA_LoggingDebugCallbackPtrType callbackFuncPtr);
/// \brief Internal function. Pass draw call counts to GPA for internal purposes.
/// \param iCounts[in] the draw counts for the current frame
/// \return The GPA result status of the operation. GPA_STATUS_OK is returned if the operation is successful.
GPALIB_DECL GPA_Status GPA_InternalSetDrawCallCounts(const int iCounts);
#endif // AMDT_INTERNAL
// *INDENT-ON*
/// \brief Internal function. Unsupported and may be removed from the API at any time.
///
/// \return The GPA result status of the operation. GPA_STATUS_OK is returned if the operation is successful.
GPALIB_DECL GPA_Status GPA_InternalProfileStart();
/// \brief Internal function. Unsupported and may be removed from the API at any time.
///
/// \param pFilename the name of the file to write profile results
/// \return The GPA result status of the operation. GPA_STATUS_OK is returned if the operation is successful.
GPALIB_DECL GPA_Status GPA_InternalProfileStop(const char* pFilename);
#endif // _GPUPERFAPI_PRIVATE_H_
@@ -0,0 +1,27 @@
//==============================================================================
// Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved.
/// \author AMD Developer Tools Team
/// \file
/// \brief This file should be included by an application that wishes to use
/// the Vulkan version of GPUPerfAPI. It defines structures that should
/// be passed to the GPA_OpenContext and GPA_BeginSampleList calls when
/// using GPUPerfAPI with Vulkan.
//==============================================================================
#ifndef _GPUPERFAPI_VK_H_
#define _GPUPERFAPI_VK_H_
#include <vulkan/vulkan.h>
/// The struct that should be supplied to GPA_OpenContext().
/// The instance, physicalDevice, and device should be set prior to
/// calling OpenContext() to reflect the Vulkan objects on which profiling
/// will take place.
typedef struct GPA_vkContextOpenInfo
{
VkInstance instance; ///< The instance on which to profile
VkPhysicalDevice physicalDevice; ///< The physical device on which to profile
VkDevice device; ///< The device on which to profile
} GPA_vkContextOpenInfo;
#endif // _GPUPERFAPI_VK_H_
@@ -1,5 +1,5 @@
//==============================================================================
// Copyright (c) 2010-2016 Advanced Micro Devices, Inc. All rights reserved.
// Copyright (c) 2010-2017 Advanced Micro Devices, Inc. All rights reserved.
/// \author AMD Developer Tools Team
/// \file
/// \brief This file is the only header that must be included by an application that
@@ -30,6 +30,52 @@
#include "GPUPerfAPITypes.h"
#include "GPUPerfAPIFunctionTypes.h"
/// Platform specific defintions
#ifdef _WIN32
#include <windows.h>
typedef HMODULE LibHandle; /// typedef for HMODULE for loading the library on windows
typedef GUID GPA_API_UUID; /// typedef for Windows GUID definition
#else
typedef void* LibHandle; /// typedef for void* for loading the library on linux
/// Structure for holding UUID
typedef struct GPA_API_UUID
{
unsigned long data1;
unsigned short data2;
unsigned short data3;
unsigned char data4[8];
#ifdef __cplusplus
/// operator overloaded function for equality comparison
/// \return true if UUIDs are equal otherwise false
bool operator==(GPA_API_UUID otherUUID)
{
bool isEqual = true;
isEqual &= data1 == otherUUID.data1;
isEqual &= data2 == otherUUID.data2;
isEqual &= data3 == otherUUID.data3;
isEqual &= data4[0] == otherUUID.data4[0];
isEqual &= data4[1] == otherUUID.data4[1];
isEqual &= data4[2] == otherUUID.data4[2];
isEqual &= data4[3] == otherUUID.data4[3];
return isEqual;
}
#endif
}GPA_API_UUID;
#endif
/// UUID value for the version specific GPA API
// UUID: 2696c8b4 - fd56 - 41fc - 9742 - af3c6aa34182
// This needs to be updated if the GPA API function table changes
#define GPA_API_3_0_UUID { 0x2696c8b4,\
0xfd56,\
0x41fc,\
{ 0x97, 0X42, 0Xaf, 0X3c, 0X6a, 0Xa3, 0X41, 0X82 } };
/// UUID value for the current GPA API
const GPA_API_UUID GPA_API_CURRENT_UUID = GPA_API_3_0_UUID;
/// \brief Register a callback function to receive log messages.
///
/// Only one callback function can be registered, so the implementation should be able
@@ -62,8 +108,9 @@ GPALIB_DECL GPA_Status GPA_Destroy();
///
/// This function must be called before any other GPA functions.
/// \param pContext The context to open counters for. Typically a device pointer. Refer to GPA API specific documentation for further details.
/// \param flags Flags used to initialize the context. Should be a combination of GPA_OpenContext_Bits
/// \return The GPA result status of the operation. GPA_STATUS_OK is returned if the operation is successful.
GPALIB_DECL GPA_Status GPA_OpenContext(void* pContext);
GPALIB_DECL GPA_Status GPA_OpenContext(void* pContext, GPA_OpenContextFlags flags);
/// \brief Closes the counters in the currently active context.
///
@@ -91,14 +138,21 @@ GPALIB_DECL GPA_Status GPA_GetNumCounters(gpa_uint32* pCount);
/// \brief Get the name of a specific counter.
///
/// \param index The index of the counter name to query. Must lie between 0 and (GPA_GetNumCounters result - 1).
/// \param ppName The value which will hold the name upon successful execution.
/// \param ppName The address which will hold the name upon successful execution.
/// \return The GPA result status of the operation. GPA_STATUS_OK is returned if the operation is successful.
GPALIB_DECL GPA_Status GPA_GetCounterName(gpa_uint32 index, const char** ppName);
/// \brief Get category of the specified counter.
///
/// \param index The index of the counter to query. Must lie between 0 and (GPA_GetNumCounters result - 1).
/// \param ppCategory The address which will hold the category string upon successful execution.
/// \return The GPA result status of the operation. GPA_STATUS_OK is returned if the operation is successful.
GPALIB_DECL GPA_Status GPA_GetCounterCategory(gpa_uint32 index, const char** ppCategory);
/// \brief Get description of the specified counter.
///
/// \param index The index of the counter to query. Must lie between 0 and (GPA_GetNumCounters result - 1).
/// \param ppDescription The value which will hold the description upon successful execution.
/// \param ppDescription The address which will hold the description upon successful execution.
/// \return The GPA result status of the operation. GPA_STATUS_OK is returned if the operation is successful.
GPALIB_DECL GPA_Status GPA_GetCounterDescription(gpa_uint32 index, const char** ppDescription);
@@ -265,12 +319,53 @@ GPALIB_DECL GPA_Status GPA_BeginPass();
GPALIB_DECL GPA_Status GPA_EndPass();
///
/// \brief Begin sampling for a sample list
///
/// For use with the explicit graphics APIs (DirectX 12 and Vulkan). Each sample must be associated with a sample list.
/// For DirectX 12, a sample list is a ID3D12GraphicsCommandList. For Vulkan, it is a VkCommandBuffer
/// \param pSampleList the sample list on which to begin sampling
/// \return The GPA result status of the operation. GPA_STATUS_OK is returned if the operation is successful.
GPALIB_DECL GPA_Status GPA_BeginSampleList(void* pSampleList);
/// \brief End sampling for a sample list
///
/// For use with the explicit graphics APIs (DirectX 12 and Vulkan). Each sample must be associated with a sample list.
/// For DirectX 12, a sample list is a ID3D12GraphicsCommandList. For Vulkan, it is a VkCommandBuffer
/// \param pSampleList the sample list on which to end sampling
/// \return The GPA result status of the operation. GPA_STATUS_OK is returned if the operation is successful.
GPALIB_DECL GPA_Status GPA_EndSampleList(void* pSampleList);
/// \brief Begin a sample in a sample list
///
/// For use with the explicit graphics APIs (DirectX 12 and Vulkan). Each sample must be associated with a sample list.
/// For DirectX 12, a sample list is a ID3D12GraphicsCommandList. For Vulkan, it is a VkCommandBuffer
/// Multiple samples can be performed inside a BeginSampleList/EndSampleList sequence.
/// Each sample computes the values of the counters between GPA_BeginSampleInSampleList and GPA_EndSampleInSampleList.
/// To identify each sample the user must provide a unique sampleID as a parameter to this function.
/// The number need only be unique within the same BeginSession/EndSession sequence.
/// GPA_BeginSampleInSampleList must be followed by a call to GPA_EndSampleInSampleList before GPA_BeginSampleInSampleList is called again.
/// \param sampleID Any integer, unique within the BeginSession/EndSession sequence, used to retrieve the sample results.
/// \param pSampleList the sample list on which to begin a sample
/// \return The GPA result status of the operation. GPA_STATUS_OK is returned if the operation is successful.
GPALIB_DECL GPA_Status GPA_BeginSampleInSampleList(gpa_uint32 sampleID, void* pSampleList);
/// \brief End a sample in a sample list.
///
/// For use with the explicit graphics APIs (DirectX 12 and Vulkan). Each sample must be associated with a sample list.
/// For DirectX 12, a sample list is a ID3D12GraphicsCommandList. For Vulkan, it is a VkCommandBuffer
/// GPA_BeginSampleInSampleList must be followed by a call to GPA_EndSampleInSampleList before GPA_BeginSampleInSampleList is called again.
/// \param pSampleList the sample list on which to end a sample
/// \return The GPA result status of the operation. GPA_STATUS_OK is returned if the operation is successful.
GPALIB_DECL GPA_Status GPA_EndSampleInSampleList(void* pSampleList);
/// \brief Begin a sample using the enabled counters.
///
/// Multiple samples can be performed inside a BeginSession/EndSession sequence.
/// Each sample computes the values of the counters between BeginSample and EndSample.
/// To identify each sample the user must provide a unique sampleID as a parameter to this function.
/// The number need only be unique within the same BeginSession/EndSession sequence.
/// Not supported when using DirectX 12 or Vulkan
/// BeginSample must be followed by a call to EndSample before BeginSample is called again.
/// \param sampleID Any integer, unique within the BeginSession/EndSession sequence, used to retrieve the sample results.
/// \return The GPA result status of the operation. GPA_STATUS_OK is returned if the operation is successful.
@@ -280,6 +375,7 @@ GPALIB_DECL GPA_Status GPA_BeginSample(gpa_uint32 sampleID);
/// \brief End sampling using the enabled counters.
///
/// BeginSample must be followed by a call to EndSample before BeginSample is called again.
/// Not supported when using DirectX 12 or Vulkan
/// \return The GPA result status of the operation. GPA_STATUS_OK is returned if the operation is successful.
GPALIB_DECL GPA_Status GPA_EndSample();
@@ -288,9 +384,9 @@ GPALIB_DECL GPA_Status GPA_EndSample();
///
/// This is useful if samples are conditionally created and a count is not kept.
/// \param sessionID The session to get the number of samples for.
/// \param pSamples The value that will be set to the number of samples contained within the session.
/// \param pSampleCount The value that will be set to the number of samples contained within the session.
/// \return The GPA result status of the operation. GPA_STATUS_OK is returned if the operation is successful.
GPALIB_DECL GPA_Status GPA_GetSampleCount(gpa_uint32 sessionID, gpa_uint32* pSamples);
GPALIB_DECL GPA_Status GPA_GetSampleCount(gpa_uint32 sessionID, gpa_uint32* pSampleCount);
/// \brief Determine if an individual sample result is available.
@@ -300,11 +396,11 @@ GPALIB_DECL GPA_Status GPA_GetSampleCount(gpa_uint32 sessionID, gpa_uint32* pSam
/// The function does not block, permitting periodic polling.
/// To block until a sample is ready use a GetSample* function instead of this.
/// It can be more efficient to determine if a whole session's worth of data is available using GPA_IsSessionReady.
/// \param pReadyResult The value that will contain the result of the sample being ready. True if ready.
/// \param pReadyResult The value that will contain the result of the sample being ready. Non-zero if ready.
/// \param sessionID The session containing the sample to determine availability.
/// \param sampleID The sample identifier of the sample to query availability for.
/// \return The GPA result status of the operation. GPA_STATUS_OK is returned if the operation is successful.
GPALIB_DECL GPA_Status GPA_IsSampleReady(bool* pReadyResult, gpa_uint32 sessionID, gpa_uint32 sampleID);
GPALIB_DECL GPA_Status GPA_IsSampleReady(gpa_uint8* pReadyResult, gpa_uint32 sessionID, gpa_uint32 sampleID);
/// \brief Determine if all samples within a session are available.
@@ -313,10 +409,10 @@ GPALIB_DECL GPA_Status GPA_IsSampleReady(bool* pReadyResult, gpa_uint32 sessionI
/// This function allows you to determine when the results of a session can be read.
/// The function does not block, permitting periodic polling.
/// To block until a sample is ready use a GetSample* function instead of this.
/// \param pReadyResult The value that will contain the result of the session being ready. True if ready.
/// \param pReadyResult The value that will contain the result of the session being ready. Non-Zero if ready.
/// \param sessionID The session to determine availability for.
/// \return The GPA result status of the operation. GPA_STATUS_OK is returned if the operation is successful.
GPALIB_DECL GPA_Status GPA_IsSessionReady(bool* pReadyResult, gpa_uint32 sessionID);
GPALIB_DECL GPA_Status GPA_IsSessionReady(gpa_uint8* pReadyResult, gpa_uint32 sessionID);
/// \brief Get a sample of type 64-bit unsigned integer.
@@ -376,9 +472,9 @@ GPALIB_DECL const char* GPA_GetStatusAsStr(GPA_Status status);
/// \brief Get the GPU device id associated with the current context
///
/// \param deviceID The value that will be set to the device id.
/// \param pDeviceID The value that will be set to the device id.
/// \return The GPA result status of the operation. GPA_STATUS_OK is returned if the operation is successful.
GPALIB_DECL GPA_Status GPA_GetDeviceID(gpa_uint32* deviceID);
GPALIB_DECL GPA_Status GPA_GetDeviceID(gpa_uint32* pDeviceID);
/// \brief Get the GPU device description associated with the current context
///
@@ -386,4 +482,39 @@ GPALIB_DECL GPA_Status GPA_GetDeviceID(gpa_uint32* deviceID);
/// \return The GPA result status of the operation. GPA_STATUS_OK is returned if the operation is successful.
GPALIB_DECL GPA_Status GPA_GetDeviceDesc(const char** ppDesc);
/// \brief Internal function. Pass draw call counts to GPA for internal purposes.
///
/// \param iCounts[in] the draw counts for the current frame
/// \return The GPA result status of the operation. GPA_STATUS_OK is returned if the operation is successful.
GPALIB_DECL GPA_Status GPA_InternalSetDrawCallCounts(const int iCounts);
/// \brief Get the GPA Api function table
///
/// \param ppGPAFuncTable[out] pointer to pointer of GPAApi - GPA Function table structure
/// \return The GPA result status of the operation. GPA_STATUS_OK is returned if the operation is successful.
GPALIB_DECL GPA_Status GPA_GetFuncTable(void** ppGPAFuncTable);
/// Structure to hold the function table of the exported GPA APIs
typedef struct _GPAApi
{
GPA_API_UUID m_apiId;
#define GPA_FUNCTION_PREFIX(func) func##PtrType func;
#include "GPAFunctions.h"
#undef GPA_FUNCTION_PREFIX
#ifdef __cplusplus
_GPAApi()
{
m_apiId = GPA_API_CURRENT_UUID;
#define GPA_FUNCTION_PREFIX(func) func = nullptr;
#include "GPAFunctions.h"
#undef GPA_FUNCTION_PREFIX
}
#endif
} GPAApi;
#endif // _GPUPERFAPI_H_
@@ -8,7 +8,7 @@
#ifndef _GPUPERFAPI_COUNTERS_H_
#define _GPUPERFAPI_COUNTERS_H_
#include "GPUPerfAPITypes-Private.h"
#include "GPUPerfAPITypes.h"
#include "GPAICounterAccessor.h"
#include "GPAICounterScheduler.h"
@@ -1,33 +0,0 @@
//==============================================================================
// Copyright (c) 2010-2016 Advanced Micro Devices, Inc. All rights reserved.
/// \author AMD Developer Tools Team
/// \file
/// \brief This file is for internal use to define the function types.
//==============================================================================
#ifndef _GPUPERFAPI_FUNCTION_TYPES_INTERNAL_H_
#define _GPUPERFAPI_FUNCTION_TYPES_INTERNAL_H_
#include "GPUPerfAPIFunctionTypes.h"
/// Typedef for a function pointer for a function to enable counters from a file
typedef GPA_Status(*GPA_EnableCountersFromFilePtrType)(const char* pFile, gpa_uint32* pCountersRead);
/// Typedef for a function pointer for a debug logging callback
typedef void(*GPA_LoggingDebugCallbackPtrType)(GPA_Log_Debug_Type messageType, const char* pMessage);
/// Typedef for a function pointer for a function to register a debug logging callback
typedef GPA_Status(*GPA_RegisterLoggingDebugCallbackPtrType)(GPA_Log_Debug_Type loggingType, GPA_LoggingDebugCallbackPtrType pCallbackFuncPtr);
/// Typedef for a function pointer for a function to start profiling a GPA function
typedef GPA_Status(*GPA_InternalProfileStartPtrType)();
/// Typedef for a function pointer for a function to stop profiling a GPA function
typedef GPA_Status(*GPA_InternalProfileStopPtrType)(const char* pFilename);
/// Typedef for a function pointer for a function to set the number of draw calls in a frame
/// For internal purposes only -- not needed for normal operation of GPUPerfAPI
typedef GPA_Status(*GPA_InternalSetDrawCallCountsPtrType)(const int iCounts);
#endif // _GPUPERFAPI_FUNCTION_TYPES_INTERNAL_H_
@@ -1,5 +1,5 @@
//==============================================================================
// Copyright (c) 2010-2016 Advanced Micro Devices, Inc. All rights reserved.
// Copyright (c) 2010-2017 Advanced Micro Devices, Inc. All rights reserved.
/// \author AMD Developer Tools Team
/// \file
/// \brief This file defines function types to make it easier to dynamically load
@@ -22,13 +22,14 @@ typedef GPA_Status(*GPA_InitializePtrType)(); ///< Typedef for a function point
typedef GPA_Status(*GPA_DestroyPtrType)(); ///< Typedef for a function pointer for GPA_Destroy
// Context
typedef GPA_Status(*GPA_OpenContextPtrType)(void* pContext); ///< Typedef for a function pointer for GPA_OpenContext
typedef GPA_Status(*GPA_OpenContextPtrType)(void* pContext, GPA_OpenContextFlags flags); ///< Typedef for a function pointer for GPA_OpenContext
typedef GPA_Status(*GPA_CloseContextPtrType)(); ///< Typedef for a function pointer for GPA_CloseContext
typedef GPA_Status(*GPA_SelectContextPtrType)(void* pCcontext); ///< Typedef for a function pointer for GPA_SelectContext
// Counter Interrogation
typedef GPA_Status(*GPA_GetNumCountersPtrType)(gpa_uint32* pCount); ///< Typedef for a function pointer for GPA_GetNumCounters
typedef GPA_Status(*GPA_GetCounterNamePtrType)(gpa_uint32 index, const char** ppName); ///< Typedef for a function pointer for GPA_GetCounterName
typedef GPA_Status(*GPA_GetCounterCategoryPtrType)(gpa_uint32 index, const char** ppCategory); ///< Typedef for a function pointer for GPA_GetCounterCategory
typedef GPA_Status(*GPA_GetCounterDescriptionPtrType)(gpa_uint32 index, const char** ppDescription); ///< Typedef for a function pointer for GPA_GetCounterDescription
typedef GPA_Status(*GPA_GetCounterDataTypePtrType)(gpa_uint32 index, GPA_Type* pCounterDataType); ///< Typedef for a function pointer for GPA_GetCounterDataType
typedef GPA_Status(*GPA_GetCounterUsageTypePtrType)(gpa_uint32 index, GPA_Usage_Type* pCounterUsageType); ///< Typedef for a function pointer for GPA_GetCounterUsageType
@@ -58,13 +59,17 @@ typedef GPA_Status(*GPA_EndSessionPtrType)(); ///< Typedef for a function point
typedef GPA_Status(*GPA_BeginPassPtrType)(); ///< Typedef for a function pointer for GPA_BeginPass
typedef GPA_Status(*GPA_EndPassPtrType)(); ///< Typedef for a function pointer for GPA_EndPass
typedef GPA_Status(*GPA_BeginSampleListPtrType)(void* pSampleList); ///< Typedef for a function pointer for GPA_BeginSampleList
typedef GPA_Status(*GPA_EndSampleListPtrType)(void* pSampleList); ///< Typedef for a function pointer for GPA_EndSampleList
typedef GPA_Status(*GPA_BeginSampleInSampleListPtrType)(gpa_uint32 sampleID, void* pSampleList); ///< Typedef for a function pointer for GPA_BeginSampleInSampleList
typedef GPA_Status(*GPA_EndSampleInSampleListPtrType)(void* pSampleList); ///< Typedef for a function pointer for GPA_EndSampleInSampleList
typedef GPA_Status(*GPA_BeginSamplePtrType)(gpa_uint32 sampleID); ///< Typedef for a function pointer for GPA_BeginSample
typedef GPA_Status(*GPA_EndSamplePtrType)(); ///< Typedef for a function pointer for GPA_EndSample
typedef GPA_Status(*GPA_GetSampleCountPtrType)(gpa_uint32 sessionID, gpa_uint32* pSamples); ///< Typedef for a function pointer for GPA_GetSampleCount
typedef GPA_Status(*GPA_IsSampleReadyPtrType)(bool* pReadyResult, gpa_uint32 sessionID, gpa_uint32 sampleID); ///< Typedef for a function pointer for GPA_IsSampleReady
typedef GPA_Status(*GPA_IsSessionReadyPtrType)(bool* pReadyResult, gpa_uint32 sessionID); ///< Typedef for a function pointer for GPA_IsSessionReady
typedef GPA_Status(*GPA_IsSampleReadyPtrType)(gpa_uint8* pReadyResult, gpa_uint32 sessionID, gpa_uint32 sampleID); ///< Typedef for a function pointer for GPA_IsSampleReady
typedef GPA_Status(*GPA_IsSessionReadyPtrType)(gpa_uint8* pReadyResult, gpa_uint32 sessionID); ///< Typedef for a function pointer for GPA_IsSessionReady
typedef GPA_Status(*GPA_GetSampleUInt64PtrType)(gpa_uint32 sessionID, gpa_uint32 sampleID, gpa_uint32 counterID, gpa_uint64* pResult); ///< Typedef for a function pointer for GPA_GetSampleUInt64
typedef GPA_Status(*GPA_GetSampleUInt32PtrType)(gpa_uint32 sessionID, gpa_uint32 sampleID, gpa_uint32 counterIndex, gpa_uint32* pResult); ///< Typedef for a function pointer for GPA_GetSampleUInt32
typedef GPA_Status(*GPA_GetSampleFloat32PtrType)(gpa_uint32 sessionID, gpa_uint32 sampleID, gpa_uint32 counterIndex, gpa_float32* pResult); ///< Typedef for a function pointer for GPA_GetSampleFloat32
@@ -73,4 +78,8 @@ typedef GPA_Status(*GPA_GetSampleFloat64PtrType)(gpa_uint32 sessionID, gpa_uint3
typedef GPA_Status(*GPA_GetDeviceIDPtrType)(gpa_uint32* pDeviceID); ///< Typedef for a function pointer for GPA_GetDeviceID
typedef GPA_Status(*GPA_GetDeviceDescPtrType)(const char** ppDesc); ///< Typedef for a function pointer for GPA_GetDeviceDesc
typedef GPA_Status(*GPA_InternalSetDrawCallCountsPtrType)(const int iCounts); /// Typedef for a function pointer for a function to set the number of draw calls in a frame
typedef GPA_Status(*GPA_GetFuncTablePtrType)(void** funcTable); /// Typedef for a function pointer for GPA function GPA_GetFuncTablePtrType function
#endif // _GPUPERFAPI_FUNCTION_TYPES_H_
@@ -1,61 +0,0 @@
//==============================================================================
// Copyright (c) 2010-2016 Advanced Micro Devices, Inc. All rights reserved.
/// \author AMD Developer Tools Team
/// \file
/// \brief This file is for internal use to define the function types.
//==============================================================================
#ifndef _GPUPERFAPI_TYPES_INTERNAL_H_
#define _GPUPERFAPI_TYPES_INTERNAL_H_
#include "GPUPerfAPITypes.h"
// For internal use only
/// Counter type definitions
typedef enum
{
GPA_COUNTER_TYPE_DYNAMIC, ///< hardware per sample counter type
GPA_COUNTER_TYPE_SESSION, ///< hardware per session counter type
GPA_COUNTER_TYPE_API_DYNAMIC, ///< api per sample counter type
GPA_COUNTER_TYPE_API_SESSION, ///< api per session counter
GPA_COUNTER_TYPE__LAST ///< Marker indicating last element
} GPA_CounterType;
/// Private Logging types that adds messages defined in Debug Builds only
enum GPA_Log_Debug_Type
{
// these must match the public GPA_Logging_type enum (but note we change LOGGING to LOG)
GPA_LOG_NONE = 0,
GPA_LOG_ERROR = 1,
GPA_LOG_MESSAGE = 2,
GPA_LOG_ERROR_AND_MESSAGE = 3,
GPA_LOG_TRACE = 4,
GPA_LOG_ERROR_AND_TRACE = 5,
GPA_LOG_MESSAGE_AND_TRACE = 6,
GPA_LOG_ERROR_MESSAGE_AND_TRACE = 7,
GPA_LOG_ALL = 0xFF,
#ifdef AMDT_INTERNAL
// these are private types that are only defined in internal builds
GPA_LOG_DEBUG_ERROR = 0x0100,
GPA_LOG_DEBUG_MESSAGE = 0x0200,
GPA_LOG_DEBUG_TRACE = 0x0400,
GPA_LOG_DEBUG_COUNTERDEFS = 0x0800,
GPA_LOG_DEBUG_ALL = 0xFF00
#endif // AMDT_INTERNAL
};
/// this enum needs to be kept up to date with GDT_HW_GENERATION in DeviceInfo.h
enum GPA_HW_GENERATION
{
GPA_HW_GENERATION_NONE, ///< undefined hw generation
GPA_HW_GENERATION_NVIDIA, ///< Used for nvidia cards by GPA
GPA_HW_GENERATION_INTEL, ///< Used for Intel cards by GPA
GPA_HW_GENERATION_SOUTHERNISLAND, ///< GFX IP 6
GPA_HW_GENERATION_SEAISLAND, ///< GFX IP 7
GPA_HW_GENERATION_VOLCANICISLAND, ///< GFX IP 8
GPA_HW_GENERATION_LAST
};
#endif // _GPUPERFAPI_TYPES_INTERNAL_H_
@@ -1,5 +1,5 @@
//==============================================================================
// Copyright (c) 2010-2016 Advanced Micro Devices, Inc. All rights reserved.
// Copyright (c) 2010-2017 Advanced Micro Devices, Inc. All rights reserved.
/// \author AMD Developer Tools Team
/// \file
/// \brief Defines the data types and enumerations used by GPUPerfAPI.
@@ -24,15 +24,11 @@
typedef unsigned short gpa_uint16;
typedef unsigned int gpa_uint32;
typedef unsigned __int64 gpa_uint64;
#ifndef __cplusplus
typedef gpa_uint8 bool;
#endif
#endif // _WIN32
#ifdef __linux__
#ifdef GPALIB_DECL
#else
#ifndef GPALIB_DECL
#ifdef __cplusplus
#define GPALIB_DECL extern "C"
#else
@@ -51,17 +47,14 @@
typedef unsigned short gpa_uint16;
typedef unsigned int gpa_uint32;
typedef unsigned long long gpa_uint64;
#ifndef __cplusplus
typedef gpa_uint8 bool;
#endif
#define UNREFERENCED_PARAMETER(x)
#define UNREFERECED_VAR(x)
#define _strcmpi(a, b) strcasecmp(a, b)
// for now, just use non secure version for Linux
#define strcpy_s(dst, ndst, src) strcpy(dst, src)
#define strcat_s(dst, ndst, src) strcat(dst, src)
#define strtok_s(a, b, c) strtok(a, b)
#endif // __linux__
@@ -117,12 +110,34 @@ typedef enum
GPA_STATUS_ERROR_FAILED,
GPA_STATUS_ERROR_HARDWARE_NOT_SUPPORTED,
GPA_STATUS_ERROR_DRIVER_NOT_SUPPORTED,
GPA_STATUS_ERROR_API_NOT_SUPPORTED,
GPA_STATUS_ERROR_LOAD_FAILED,
GPA_STATUS_ERROR_LIB_LOAD_FAILED,
GPA_STATUS_ERROR_LIB_LOAD_VERION_MISMATCH,
// following are status codes used internally within GPUPerfAPI
GPA_STATUS_INTERNAL = 256,
GPA_STATUS_OK_HANDLED = GPA_STATUS_INTERNAL,
} GPA_Status;
typedef unsigned int GPA_Flags;
/// Flags to pass into GPA_OpenContext()
enum GPA_OpenContext_Bits
{
GPA_OPENCONTEXT_DEFAULT_BIT = 0x0000, ///< Opens context using all default options
GPA_OPENCONTEXT_HIDE_PUBLIC_COUNTERS_BIT = 0x0001, ///< Prevent the public counters from being exposed
GPA_OPENCONTEXT_HIDE_SOFTWARE_COUNTERS_BIT = 0x0002, ///< Prevent the software counters from being exposed
GPA_OPENCONTEXT_HIDE_HARDWARE_COUNTERS_BIT = 0x0004, ///< Prevent the hardware counters from being exposed
GPA_OPENCONTEXT_CLOCK_MODE_NONE_BIT = 0x0008, ///< Clocks are set to default mode
GPA_OPENCONTEXT_CLOCK_MODE_PEAK_BIT = 0x0010, ///< Clocks set to maximum when possible
GPA_OPENCONTEXT_CLOCK_MODE_MIN_MEMORY_BIT = 0x0020, ///< Memory clock is set to the lowest available level
GPA_OPENCONTEXT_CLOCK_MODE_MIN_ENGINE_BIT = 0x0040 ///< Engine clock is set to the lowest available level
};
/// Allows GPA_OpenContext_Bits to be combined into a single parameter.
typedef GPA_Flags GPA_OpenContextFlags;
/// Value type definitions
typedef enum
{
@@ -151,27 +166,63 @@ typedef enum
/// Logging type definitions
typedef enum
{
GPA_LOGGING_NONE = 0,
GPA_LOGGING_ERROR = 1,
GPA_LOGGING_MESSAGE = 2,
GPA_LOGGING_ERROR_AND_MESSAGE = 3,
GPA_LOGGING_TRACE = 4,
GPA_LOGGING_ERROR_AND_TRACE = 5,
GPA_LOGGING_MESSAGE_AND_TRACE = 6,
GPA_LOGGING_ERROR_MESSAGE_AND_TRACE = 7,
GPA_LOGGING_ALL = 0xFF
GPA_LOGGING_NONE = 0x00, ///< No logging
GPA_LOGGING_ERROR = 0x01, ///< Log errors
GPA_LOGGING_MESSAGE = 0x02, ///< Log messages
GPA_LOGGING_ERROR_AND_MESSAGE = GPA_LOGGING_ERROR | GPA_LOGGING_MESSAGE, ///< Log errors and messages
GPA_LOG_ERROR_AND_MESSAGE = GPA_LOGGING_ERROR_AND_MESSAGE, ///< Log errors and messages - Backward Compatibility
GPA_LOGGING_TRACE = 0x04, ///< Log traces
GPA_LOGGING_ERROR_AND_TRACE = GPA_LOGGING_ERROR | GPA_LOGGING_TRACE, ///< Log errors and traces
GPA_LOGGING_MESSAGE_AND_TRACE = GPA_LOGGING_MESSAGE | GPA_LOGGING_TRACE, ///< Log messages traces
GPA_LOGGING_ERROR_MESSAGE_AND_TRACE = GPA_LOGGING_ERROR | GPA_LOGGING_MESSAGE | GPA_LOGGING_TRACE, ///< Log errors and messages and traces
GPA_LOGGING_ALL = 0xFF, ///< Log all
GPA_LOGGING_DEBUG_ERROR = 0x0100, ///< Log debugging errors
GPA_LOGGING_DEBUG_MESSAGE = 0x0200, ///< Log debugging messages
GPA_LOGGING_DEBUG_TRACE = 0x0400, ///< Log debugging traces
GPA_LOGGING_DEBUG_COUNTERDEFS = 0x0800, ///< Log debugging counter defs
GPA_LOGGING_DEBUG_ALL = 0xFF00 ///< Log all debugging
} GPA_Logging_Type;
/// APIs Supported (either publicly or internally) by GPUPerfAPI
typedef enum
{
GPA_API_DIRECTX_11,
GPA_API_DIRECTX_12,
GPA_API_OPENGL,
GPA_API_OPENGLES,
GPA_API_OPENCL,
GPA_API_HSA,
GPA_API__LAST
GPA_API__START, ///< Marker indicating first element
GPA_API_DIRECTX_11 = GPA_API__START, ///< DirectX 11 API
GPA_API_DIRECTX_12, ///< DirectX 12 API
GPA_API_OPENGL, ///< OpenGL API
GPA_API_OPENGLES, ///< OpenGLES API
GPA_API_OPENCL, ///< OpenCL API
GPA_API_HSA, ///< HSA API
GPA_API_VULKAN, ///< Vulkan API
GPA_API_NO_SUPPORT, ///< API which are not yet supported or support have been removed
GPA_API__LAST ///< Marker indicating last element
} GPA_API_Type;
/// Counter type definitions
typedef enum
{
GPA_COUNTER_TYPE_DYNAMIC, ///< hardware per sample counter type
GPA_COUNTER_TYPE_SESSION, ///< hardware per session counter type
GPA_COUNTER_TYPE_API_DYNAMIC, ///< api per sample counter type
GPA_COUNTER_TYPE_API_SESSION, ///< api per session counter
GPA_COUNTER_TYPE__LAST ///< Marker indicating last element
} GPA_CounterType;
/// this enum needs to be kept up to date with GDT_HW_GENERATION in DeviceInfo.h
enum GPA_HW_GENERATION
{
GPA_HW_GENERATION_NONE, ///< undefined hw generation
GPA_HW_GENERATION_NVIDIA, ///< Used for nvidia cards by GPA
GPA_HW_GENERATION_INTEL, ///< Used for Intel cards by GPA
GPA_HW_GENERATION_GFX6, ///< GFX IP 6
GPA_HW_GENERATION_SOUTHERNISLAND = GPA_HW_GENERATION_GFX6, ///< For backwards compatibility
GPA_HW_GENERATION_GFX7, ///< GFX IP 7
GPA_HW_GENERATION_SEAISLAND = GPA_HW_GENERATION_GFX7, ///< For backwards compatibility
GPA_HW_GENERATION_GFX8, ///< GFX IP 8
GPA_HW_GENERATION_VOLCANICISLAND = GPA_HW_GENERATION_GFX8, ///< For backwards compatibility
GPA_HW_GENERATION_GFX9, ///< GFX IP 9
GPA_HW_GENERATION_LAST
};
#endif // _GPUPERFAPI_TYPES_H_