mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 10:00:40 +00:00
Fix D3D12 sharing test when the adapters used by D3D11/D3D12 differ
D3D11 may default to a different adapter than D3D12. For the sharing test, both adapters must be D3D12 compatible. Tell D3D11 to use the adapter that D3D12 is using to ensure compatibility. Also fixed a memory leak in the test.
This commit is contained in:
committed by
Baldur Karlsson
parent
2f7b260d39
commit
b2150e901f
@@ -132,7 +132,7 @@ void D3D11GraphicsTest::Prepare(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
bool D3D11GraphicsTest::Init()
|
||||
bool D3D11GraphicsTest::Init(IDXGIAdapterPtr pAdapter)
|
||||
{
|
||||
if(!GraphicsTest::Init())
|
||||
return false;
|
||||
@@ -148,7 +148,10 @@ bool D3D11GraphicsTest::Init()
|
||||
|
||||
if(headless)
|
||||
{
|
||||
hr = CreateDevice(adapters, NULL, features, flags);
|
||||
if(pAdapter != NULL)
|
||||
hr = CreateDevice({pAdapter}, NULL, features, flags);
|
||||
else
|
||||
hr = CreateDevice(adapters, NULL, features, flags);
|
||||
|
||||
if(FAILED(hr))
|
||||
{
|
||||
@@ -179,7 +182,10 @@ bool D3D11GraphicsTest::Init()
|
||||
swapDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
|
||||
swapDesc.Flags = 0;
|
||||
|
||||
hr = CreateDevice(adapters, &swapDesc, features, flags);
|
||||
if(pAdapter != NULL)
|
||||
hr = CreateDevice({pAdapter}, &swapDesc, features, flags);
|
||||
else
|
||||
hr = CreateDevice(adapters, &swapDesc, features, flags);
|
||||
|
||||
if(FAILED(hr))
|
||||
{
|
||||
@@ -216,7 +222,7 @@ GraphicsWindow *D3D11GraphicsTest::MakeWindow(int width, int height, const char
|
||||
return new Win32Window(width, height, title);
|
||||
}
|
||||
|
||||
HRESULT D3D11GraphicsTest::CreateDevice(std::vector<IDXGIAdapterPtr> &adaptersToTry,
|
||||
HRESULT D3D11GraphicsTest::CreateDevice(const std::vector<IDXGIAdapterPtr> &adaptersToTry,
|
||||
DXGI_SWAP_CHAIN_DESC *swapDesc, D3D_FEATURE_LEVEL *features,
|
||||
UINT flags)
|
||||
{
|
||||
|
||||
@@ -46,12 +46,12 @@ struct D3D11GraphicsTest : public GraphicsTest
|
||||
static const TestAPI API = TestAPI::D3D11;
|
||||
|
||||
void Prepare(int argc, char **argv);
|
||||
bool Init();
|
||||
bool Init(IDXGIAdapterPtr pAdapter = NULL);
|
||||
void Shutdown();
|
||||
GraphicsWindow *MakeWindow(int width, int height, const char *title);
|
||||
|
||||
HRESULT CreateDevice(std::vector<IDXGIAdapterPtr> &adaptersToTry, DXGI_SWAP_CHAIN_DESC *swapDesc,
|
||||
D3D_FEATURE_LEVEL *features, UINT flags);
|
||||
HRESULT CreateDevice(const std::vector<IDXGIAdapterPtr> &adaptersToTry,
|
||||
DXGI_SWAP_CHAIN_DESC *swapDesc, D3D_FEATURE_LEVEL *features, UINT flags);
|
||||
void PostDeviceCreate();
|
||||
|
||||
enum BufType
|
||||
|
||||
@@ -52,27 +52,18 @@ RD_TEST(D3D12_Sharing, D3D12GraphicsTest)
|
||||
if(!Init())
|
||||
return 3;
|
||||
|
||||
if(!d3d11.Init())
|
||||
LUID luid = dev->GetAdapterLuid();
|
||||
IDXGIAdapterPtr pDXGIAdapter;
|
||||
HRESULT hr = EnumAdapterByLuid(dev->GetAdapterLuid(), pDXGIAdapter);
|
||||
if(FAILED(hr))
|
||||
return 2;
|
||||
|
||||
if(!d3d11.Init(pDXGIAdapter))
|
||||
return 4;
|
||||
|
||||
ID3D12DevicePtr dev2;
|
||||
|
||||
{
|
||||
LUID luid = dev->GetAdapterLuid();
|
||||
|
||||
IDXGIAdapterPtr pDXGIAdapter;
|
||||
HRESULT hr = EnumAdapterByLuid(dev->GetAdapterLuid(), pDXGIAdapter);
|
||||
std::vector<IDXGIAdapterPtr> adapters;
|
||||
adapters.push_back(pDXGIAdapter);
|
||||
|
||||
if(FAILED(hr))
|
||||
return 2;
|
||||
|
||||
dev2 = CreateDevice(adapters, D3D_FEATURE_LEVEL_11_0);
|
||||
|
||||
if(!dev2)
|
||||
return 2;
|
||||
}
|
||||
ID3D12DevicePtr dev2 = CreateDevice({pDXGIAdapter}, D3D_FEATURE_LEVEL_11_0);
|
||||
if(!dev2)
|
||||
return 2;
|
||||
|
||||
ID3DBlobPtr vsblob = Compile(D3DDefaultVertex, "main", "vs_4_0");
|
||||
ID3DBlobPtr psblob = Compile(D3DDefaultPixel, "main", "ps_4_0");
|
||||
@@ -173,6 +164,9 @@ RD_TEST(D3D12_Sharing, D3D12GraphicsTest)
|
||||
// wait on the fence from d3d11's work then continue
|
||||
queue->Wait(m_GPUSyncFence, m_GPUSyncCounter);
|
||||
|
||||
delete[] updateData;
|
||||
updateData = NULL;
|
||||
|
||||
cmd = GetCommandBuffer();
|
||||
|
||||
Reset(cmd);
|
||||
|
||||
@@ -425,7 +425,7 @@ HRESULT D3D12GraphicsTest::EnumAdapterByLuid(LUID luid, IDXGIAdapterPtr &pAdapte
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
ID3D12DevicePtr D3D12GraphicsTest::CreateDevice(std::vector<IDXGIAdapterPtr> &adaptersToTry,
|
||||
ID3D12DevicePtr D3D12GraphicsTest::CreateDevice(const std::vector<IDXGIAdapterPtr> &adaptersToTry,
|
||||
D3D_FEATURE_LEVEL features)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
@@ -52,7 +52,7 @@ struct D3D12GraphicsTest : public GraphicsTest
|
||||
GraphicsWindow *MakeWindow(int width, int height, const char *title);
|
||||
|
||||
HRESULT EnumAdapterByLuid(LUID luid, IDXGIAdapterPtr &pAdapter);
|
||||
ID3D12DevicePtr CreateDevice(std::vector<IDXGIAdapterPtr> &adaptersToTry,
|
||||
ID3D12DevicePtr CreateDevice(const std::vector<IDXGIAdapterPtr> &adaptersToTry,
|
||||
D3D_FEATURE_LEVEL features);
|
||||
|
||||
enum BufType
|
||||
|
||||
Reference in New Issue
Block a user