Plugged in NV counters into D3D11Replay.

- Counters are displayed in RenderDoc 'Performance counter selection' window
This commit is contained in:
reinsteam
2018-03-28 19:27:44 +01:00
committed by Baldur Karlsson
parent 48cb7d6c49
commit f3cb0e1854
3 changed files with 64 additions and 5 deletions
+41 -1
View File
@@ -26,6 +26,7 @@
#include <iterator>
#include "common/common.h"
#include "driver/ihv/amd/amd_counters.h"
#include "driver/ihv/nv/nv_counters.h"
#include "d3d11_context.h"
#include "d3d11_debug.h"
#include "d3d11_device.h"
@@ -54,6 +55,12 @@ vector<GPUCounter> D3D11Replay::EnumerateCounters()
ret.insert(ret.end(), amdCounters.begin(), amdCounters.end());
}
if(m_pNVCounters)
{
vector<GPUCounter> nvCounters = m_pNVCounters->GetPublicCounterIds();
ret.insert(ret.end(), nvCounters.begin(), nvCounters.end());
}
return ret;
}
@@ -71,6 +78,15 @@ CounterDescription D3D11Replay::DescribeCounter(GPUCounter counterID)
}
}
/////NV//////
if(IsNvidiaCounter(counterID))
{
if(m_pNVCounters)
{
return m_pNVCounters->GetCounterDescription(counterID);
}
}
// 448A0516-B50E-4312-A6DC-CFE7222FC1AC
desc.uuid.words[0] = 0x448A0516;
desc.uuid.words[1] = 0xB50E4312;
@@ -332,6 +348,11 @@ void D3D11Replay::FillTimersAMD(uint32_t &eventStartID, uint32_t &sampleIndex,
}
}
void D3D11Replay::FillTimersNV(uint32_t &eventStartID, uint32_t &sampleIndex,
vector<uint32_t> &eventIDs, const DrawcallDescription &drawnode)
{
}
vector<CounterResult> D3D11Replay::FetchCountersAMD(const vector<GPUCounter> &counters)
{
vector<CounterResult> ret;
@@ -375,6 +396,12 @@ vector<CounterResult> D3D11Replay::FetchCountersAMD(const vector<GPUCounter> &co
return m_pAMDCounters->GetCounterData(sessionID, sampleIndex, eventIDs, counters);
}
vector<CounterResult> D3D11Replay::FetchCountersNV(const vector<GPUCounter> &counters)
{
vector<CounterResult> ret;
return ret;
}
vector<CounterResult> D3D11Replay::FetchCounters(const vector<GPUCounter> &counters)
{
vector<CounterResult> ret;
@@ -389,7 +416,7 @@ vector<CounterResult> D3D11Replay::FetchCounters(const vector<GPUCounter> &count
vector<GPUCounter> d3dCounters;
std::copy_if(counters.begin(), counters.end(), std::back_inserter(d3dCounters),
[](const GPUCounter &c) { return !IsAMDCounter(c); });
[](const GPUCounter &c) { return !IsAMDCounter(c) && !IsNvidiaCounter(c); });
if(m_pAMDCounters)
{
@@ -404,6 +431,19 @@ vector<CounterResult> D3D11Replay::FetchCounters(const vector<GPUCounter> &count
}
}
if(m_pNVCounters)
{
// Filter out the AMD counters
vector<GPUCounter> nvCounters;
std::copy_if(counters.begin(), counters.end(), std::back_inserter(nvCounters),
[](const GPUCounter &c) { return IsNvidiaCounter(c); });
if(!nvCounters.empty())
{
ret = FetchCountersNV(nvCounters);
}
}
if(d3dCounters.empty())
{
return ret;
+16 -4
View File
@@ -26,6 +26,7 @@
#include "d3d11_replay.h"
#include "driver/dx/official/d3dcompiler.h"
#include "driver/ihv/amd/amd_counters.h"
#include "driver/ihv/nv/nv_counters.h"
#include "driver/shaders/dxbc/dxbc_debug.h"
#include "maths/camera.h"
#include "maths/matrix.h"
@@ -156,20 +157,30 @@ void D3D11Replay::CreateResources()
RenderDoc::Inst().SetProgress(LoadProgress::DebugManagerInit, 0.9f);
AMDCounters *counters = new AMDCounters();
AMDCounters *pAMDCounters = new AMDCounters();
NVCounters *pNVCounters = new NVCounters();
ID3D11Device *d3dDevice = m_pDevice->GetReal();
if(counters->Init(AMDCounters::ApiType::Dx11, (void *)d3dDevice))
if(pAMDCounters->Init(AMDCounters::ApiType::Dx11, (void *)d3dDevice))
{
m_pAMDCounters = counters;
m_pAMDCounters = pAMDCounters;
}
else
{
delete counters;
delete pAMDCounters;
m_pAMDCounters = NULL;
}
if(pNVCounters->Init(d3dDevice))
{
m_pNVCounters = pNVCounters;
}
else
{
delete pNVCounters;
m_pNVCounters = NULL;
}
RenderDoc::Inst().SetProgress(LoadProgress::DebugManagerInit, 1.0f);
}
@@ -187,6 +198,7 @@ void D3D11Replay::DestroyResources()
m_PixelHistory.Release();
SAFE_DELETE(m_pAMDCounters);
SAFE_DELETE(m_pNVCounters);
ShutdownStreamOut();
ClearPostVSCache();
+7
View File
@@ -37,6 +37,7 @@ class WrappedID3D11Device;
class WrappedID3D11DeviceContext;
class AMDCounters;
class NVCounters;
struct D3D11CounterContext;
struct D3D11PostVSData
@@ -245,9 +246,14 @@ private:
void ShutdownStreamOut();
std::vector<CounterResult> FetchCountersAMD(const vector<GPUCounter> &counters);
std::vector<CounterResult> FetchCountersNV(const vector<GPUCounter> &counters);
void FillTimers(D3D11CounterContext &ctx, const DrawcallDescription &drawnode);
void FillTimersAMD(uint32_t &eventStartID, uint32_t &sampleIndex, vector<uint32_t> &eventIDs,
const DrawcallDescription &drawnode);
void FillTimersNV(uint32_t &eventStartID, uint32_t &sampleIndex, vector<uint32_t> &eventIDs,
const DrawcallDescription &drawnode);
void SerializeImmediateContext();
bool RenderTextureInternal(TextureDisplay cfg, bool blendAlpha);
@@ -286,6 +292,7 @@ private:
IDXGIFactory *m_pFactory = NULL;
AMDCounters *m_pAMDCounters = NULL;
NVCounters *m_pNVCounters = NULL;
WrappedID3D11Device *m_pDevice = NULL;
WrappedID3D11DeviceContext *m_pImmediateContext = NULL;