@@ -1145,11 +1145,9 @@ void GPUUploadManagerImpl::ScheduleTextureUpdate(const ScheduleTextureUpdateInfo
11451145 });
11461146}
11471147
1148- GPUUploadManagerImpl::Page* GPUUploadManagerImpl::UploadStream::CreatePage (IDeviceContext* pContext, Uint32 RequiredSize)
1148+ GPUUploadManagerImpl::Page* GPUUploadManagerImpl::UploadStream::CreatePage (IDeviceContext* pContext, Uint32 RequiredSize, bool AllowOverLimit )
11491149{
1150- // Always create a new page from the render thread (when pContext is not null) to avoid deadlock in
1151- // UploadStream::ScheduleUpdate.
1152- if (pContext == nullptr )
1150+ if (!AllowOverLimit)
11531151 {
11541152 const Uint32 MaxExistingPageSize = m_PageSizeToCount.empty () ? 0 : m_PageSizeToCount.rbegin ()->first ;
11551153 if (m_MaxPageCount != 0 && m_Pages.size () >= m_MaxPageCount && RequiredSize <= MaxExistingPageSize)
@@ -1201,8 +1199,11 @@ bool GPUUploadManagerImpl::UploadStream::SealAndSwapCurrentPage(IDeviceContext*
12011199
12021200bool GPUUploadManagerImpl::UploadStream::TryRotatePage (IDeviceContext* pContext, Page* ExpectedCurrent, Uint32 RequiredSize)
12031201{
1204- // Grab a free page (workers can't create, so pContext=null)
1205- Page* Fresh = AcquireFreePage (pContext, RequiredSize);
1202+ // Allow going over the max page count when rotating the page from the render thread to
1203+ // prevent deadlock in ScheduleUpdate.
1204+ bool AllowOverLimit = pContext != nullptr ;
1205+ // Grab a free page.
1206+ Page* Fresh = AcquireFreePage (pContext, RequiredSize, AllowOverLimit);
12061207 if (!Fresh)
12071208 return false ;
12081209
@@ -1375,15 +1376,17 @@ void GPUUploadManagerImpl::ProcessPendingPages(IDeviceContext* pContext)
13751376 }
13761377}
13771378
1378- GPUUploadManagerImpl::Page* GPUUploadManagerImpl::UploadStream::AcquireFreePage (IDeviceContext* pContext, Uint32 RequiredSize)
1379+ GPUUploadManagerImpl::Page* GPUUploadManagerImpl::UploadStream::AcquireFreePage (IDeviceContext* pContext,
1380+ Uint32 RequiredSize,
1381+ bool AllowOverLimit)
13791382{
13801383 // For texture pages, all sizes are texture dimensions.
13811384 Uint32 MaxPendingUpdateSize = std::max (m_MaxPendingUpdateSize.load (std::memory_order_acquire), RequiredSize);
13821385
13831386 Page* P = m_FreePages.Pop (MaxPendingUpdateSize);
13841387 if (P == nullptr && pContext != nullptr )
13851388 {
1386- P = CreatePage (pContext, MaxPendingUpdateSize);
1389+ P = CreatePage (pContext, MaxPendingUpdateSize, AllowOverLimit );
13871390 }
13881391
13891392 if (P != nullptr )
0 commit comments