Only enable counters when we detect the relevant vendor

* This avoids problem if the vendor counter library has problems on init
  on non-vendor hardware, rather than just bailing out/claiming no
  support.
This commit is contained in:
baldurk
2018-04-25 19:11:02 +01:00
parent f1ec9b9e81
commit af94c429ea
4 changed files with 59 additions and 10 deletions
+19 -4
View File
@@ -157,12 +157,27 @@ void D3D11Replay::CreateResources()
RenderDoc::Inst().SetProgress(LoadProgress::DebugManagerInit, 0.9f);
AMDCounters *countersAMD = new AMDCounters();
NVCounters *countersNV = new NVCounters();
AMDCounters *countersAMD = NULL;
NVCounters *countersNV = NULL;
if(m_Vendor == GPUVendor::AMD)
{
RDCLOG("AMD GPU detected - trying to initialise AMD counters");
countersAMD = new AMDCounters();
}
else if(m_Vendor == GPUVendor::nVidia)
{
RDCLOG("nVidia GPU detected - trying to initialise nVidia counters");
countersNV = new NVCounters();
}
else
{
RDCLOG("%s GPU detected - no counters available", ToStr(m_Vendor).c_str());
}
ID3D11Device *d3dDevice = m_pDevice->GetReal();
if(countersAMD->Init(AMDCounters::ApiType::Dx11, (void *)d3dDevice))
if(countersAMD && countersAMD->Init(AMDCounters::ApiType::Dx11, (void *)d3dDevice))
{
m_pAMDCounters = countersAMD;
}
@@ -172,7 +187,7 @@ void D3D11Replay::CreateResources()
m_pAMDCounters = NULL;
}
if(countersNV->Init(d3dDevice))
if(countersNV && countersNV->Init(d3dDevice))
{
m_pNVCounters = countersNV;
}
+12 -2
View File
@@ -121,11 +121,21 @@ void D3D12Replay::CreateResources()
if(RenderDoc::Inst().IsReplayApp())
{
AMDCounters *counters = new AMDCounters();
AMDCounters *counters = NULL;
if(m_Vendor == GPUVendor::AMD)
{
RDCLOG("AMD GPU detected - trying to initialise AMD counters");
counters = new AMDCounters();
}
else
{
RDCLOG("%s GPU detected - no counters available", ToStr(m_Vendor).c_str());
}
ID3D12Device *d3dDevice = m_pDevice->GetReal();
if(counters->Init(AMDCounters::ApiType::Dx12, (void *)d3dDevice))
if(counters && counters->Init(AMDCounters::ApiType::Dx12, (void *)d3dDevice))
{
m_pAMDCounters = counters;
}
+13 -2
View File
@@ -35,8 +35,19 @@ void GLReplay::PreContextInitCounters()
void GLReplay::PostContextInitCounters()
{
AMDCounters *counters = new AMDCounters();
if(counters->Init(AMDCounters::ApiType::Ogl, m_ReplayCtx.ctx))
AMDCounters *counters = NULL;
if(m_Vendor == GPUVendor::AMD)
{
RDCLOG("AMD GPU detected - trying to initialise AMD counters");
counters = new AMDCounters();
}
else
{
RDCLOG("%s GPU detected - no counters available", ToStr(m_Vendor).c_str());
}
if(counters && counters->Init(AMDCounters::ApiType::Ogl, m_ReplayCtx.ctx))
{
m_pAMDCounters = counters;
}
+15 -2
View File
@@ -1399,8 +1399,21 @@ void VulkanReplay::CreateResources()
GPA_vkContextOpenInfo context = {Unwrap(m_pDriver->GetInstance()),
Unwrap(m_pDriver->GetPhysDev()), Unwrap(m_pDriver->GetDev())};
AMDCounters *counters = new AMDCounters();
if(counters->Init(AMDCounters::ApiType::Vk, (void *)&context))
AMDCounters *counters = NULL;
GPUVendor vendor = m_pDriver->GetDriverVersion().Vendor();
if(vendor == GPUVendor::AMD)
{
RDCLOG("AMD GPU detected - trying to initialise AMD counters");
counters = new AMDCounters();
}
else
{
RDCLOG("%s GPU detected - no counters available", ToStr(vendor).c_str());
}
if(counters && counters->Init(AMDCounters::ApiType::Vk, (void *)&context))
{
m_pAMDCounters = counters;
}