Have capture engine pick the display adapter with most video memory, then should match the winml device
This commit is contained in:
Родитель
f8afcde053
Коммит
61a595f507
|
@ -106,10 +106,32 @@ HRESULT CreateDX11Device(_Out_ ID3D11Device** ppDevice, _Out_ ID3D11DeviceContex
|
|||
D3D_FEATURE_LEVEL_9_1
|
||||
};
|
||||
|
||||
|
||||
// Find the adapter with the most video memory
|
||||
UINT i = 0;
|
||||
|
||||
std::vector <IDXGIAdapter*> vAdapters;
|
||||
winrt::com_ptr<IDXGIAdapter> pBestAdapter;
|
||||
|
||||
winrt::com_ptr<IDXGIAdapter> spAdapter;
|
||||
winrt::com_ptr<IDXGIFactory> spFactory;
|
||||
DXGI_ADAPTER_DESC desc;
|
||||
hr = CreateDXGIFactory1(IID_PPV_ARGS(spFactory.put()));
|
||||
size_t maxVideoMem = 0;
|
||||
while (spFactory->EnumAdapters(i, spAdapter.put()) != DXGI_ERROR_NOT_FOUND)
|
||||
{
|
||||
spAdapter->GetDesc(&desc);
|
||||
if (desc.DedicatedVideoMemory > maxVideoMem)
|
||||
{
|
||||
spAdapter.copy_to(pBestAdapter.put());
|
||||
maxVideoMem = desc.DedicatedVideoMemory;
|
||||
}
|
||||
spAdapter = nullptr;
|
||||
++i;
|
||||
}
|
||||
|
||||
hr = D3D11CreateDevice(
|
||||
nullptr,
|
||||
D3D_DRIVER_TYPE_HARDWARE,
|
||||
pBestAdapter.get(),
|
||||
D3D_DRIVER_TYPE_UNKNOWN,
|
||||
nullptr,
|
||||
D3D11_CREATE_DEVICE_VIDEO_SUPPORT,
|
||||
levels,
|
||||
|
|
|
@ -126,7 +126,7 @@ void BackgroundBlur::Run(IDirect3DSurface src, IDirect3DSurface dest)
|
|||
std::lock_guard<std::mutex> guard{ Processing };
|
||||
OutputDebugString(L"Eval Completed");
|
||||
// StyleTransferEffect copies to a member outputCache video frame and then copies to output outside of first condition
|
||||
m_outputVideoFrame.CopyToAsync(outVideoFrame).get();
|
||||
m_outputVideoFrame.CopyToAsync(outVideoFrame).get(); // TODO: Still threading bug here methinks
|
||||
m_inputVideoFrame.Close();
|
||||
m_outputVideoFrame.Close();
|
||||
});
|
||||
|
|
|
@ -114,6 +114,14 @@ protected:
|
|||
};
|
||||
|
||||
// TODO: Make an even more Invert IStreamModel?
|
||||
//class Invert : public IStreamModel
|
||||
//{
|
||||
//public:
|
||||
// Invert(int w, int h) : IStreamModel(w, h) { SetModels(w, h); }
|
||||
// Invert() : IStreamModel() {}
|
||||
// void SetModels(int w, int h);
|
||||
// void Run(IDirect3DSurface src, IDirect3DSurface dest);
|
||||
//};
|
||||
|
||||
class StyleTransfer : public IStreamModel {
|
||||
public:
|
||||
|
|
|
@ -205,6 +205,10 @@ HRESULT TransformAsync::SubmitEval(IMFSample* pInputSample)
|
|||
IDirect3DSurface src, dest;
|
||||
winrt::com_ptr<IMFMediaBuffer> pMediaBuffer;
|
||||
|
||||
winrt::com_ptr<IDXGIDevice> pDXGIDevice{ m_spDevice.as<IDXGIDevice>() };
|
||||
winrt::com_ptr<IDXGIAdapter> pAdapter;
|
||||
DXGI_ADAPTER_DESC desc;
|
||||
|
||||
auto model = m_models[0].get(); // Lock on?
|
||||
|
||||
TRACE((L"\n[Sample: %d | model: %d | ", dwCurrentSample, modelIndex));
|
||||
|
@ -233,8 +237,12 @@ HRESULT TransformAsync::SubmitEval(IMFSample* pInputSample)
|
|||
|
||||
// **** 2. Run inference on input sample
|
||||
src = SampleToD3Dsurface(pInputSample);
|
||||
// TODO: Fix device manager because pOutputSample isn't d3d backed, this call fails
|
||||
dest = SampleToD3Dsurface(pOutputSample.get());
|
||||
|
||||
// Extract the device
|
||||
|
||||
pDXGIDevice->GetAdapter(pAdapter.put());
|
||||
pAdapter->GetDesc(&desc);
|
||||
{
|
||||
// Do the copies inside runtest
|
||||
auto now = std::chrono::high_resolution_clock::now();
|
||||
|
|
Загрузка…
Ссылка в новой задаче