Link allocator size to number of threads

This commit is contained in:
Linnea May 2022-04-05 14:12:17 -07:00
Родитель ee30afff05
Коммит 9e14255bd4
2 изменённых файлов: 4 добавлений и 3 удалений

Просмотреть файл

@ -232,6 +232,7 @@ HRESULT TransformAsync::SubmitEval(IMFSample* pInput)
CHECK_HR(hr = CheckDX11Device());
// Ensure the allocator is set up
CHECK_HR(hr = SetupAlloc());
// CheckDX11Device & SetupAlloc ensure we can now allocate a D3D-backed output sample.
(hr = m_spOutputSampleAllocator->AllocateSample(pOutputSample.put()));
if (FAILED(hr))
@ -481,7 +482,7 @@ HRESULT TransformAsync::SetupAlloc()
m_spOutputSampleAllocator.attach(spVideoSampleAllocator.detach());
}
CHECK_HR(hr = m_spOutputSampleAllocator->InitializeSampleAllocatorEx(2, 15, m_spAllocatorAttributes.get(), m_spOutputType.get()));
CHECK_HR(hr = m_spOutputSampleAllocator->InitializeSampleAllocatorEx(2, m_numThreads, m_spAllocatorAttributes.get(), m_spOutputType.get()));
// Set up IMFVideoSampleAllocatorCallback
m_spOutputSampleCallback = m_spOutputSampleAllocator.try_as<IMFVideoSampleAllocatorCallback>();
@ -1045,7 +1046,7 @@ HRESULT TransformAsync::OnFlush(void)
HRESULT hr = S_OK;
do
{
// TODO: Remove fence values so that framerate can restart
std::lock_guard<std::recursive_mutex> lock(m_mutex);
m_dwStatus &= (~MYMFT_STATUS_STREAM_STARTED);

Просмотреть файл

@ -346,7 +346,7 @@ protected:
// Model Inference fields
int m_numThreads = // Number of threads running inference in parallel.
max(std::thread::hardware_concurrency() - 2, 5);
max(std::thread::hardware_concurrency(), 5);
std::vector<std::unique_ptr<IStreamModel>> m_models; // m_numThreads number of models to run inference in parallel.
int modelIndex = 0;