[dxvk] Add safety mechanism to submit large descriptor pools

This commit is contained in:
Philip Rebohle 2022-06-23 16:00:23 +02:00
parent cfc06405d2
commit d4d87123b4
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
3 changed files with 29 additions and 3 deletions

View File

@ -103,9 +103,9 @@ namespace dxvk {
m_initBarriers.recordCommands(m_cmd);
m_execBarriers.recordCommands(m_cmd);
if (m_type != DxvkContextType::Primary) {
if (m_descriptorPool->shouldSubmit(false)) {
m_cmd->trackDescriptorPool(m_descriptorPool, m_descriptorManager);
m_descriptorPool = nullptr;
m_descriptorPool = m_descriptorManager->getDescriptorPool();
}
m_cmd->endRecording();
@ -114,7 +114,7 @@ namespace dxvk {
void DxvkContext::endFrame() {
if (m_descriptorPool != nullptr) {
if (m_descriptorPool->shouldSubmit(true)) {
m_cmd->trackDescriptorPool(m_descriptorPool, m_descriptorManager);
m_descriptorPool = m_descriptorManager->getDescriptorPool();
}

View File

@ -50,6 +50,24 @@ namespace dxvk {
}
bool DxvkDescriptorPool::shouldSubmit(bool endFrame) {
// Never submit empty descriptor pools
if (!m_setsAllocated)
return false;
// No frame tracking for supplementary contexts, so
// always submit those at the end of a command list
if (endFrame || m_contextType != DxvkContextType::Primary)
return true;
// Submit very large descriptor pools to prevent extreme
// memory bloat. This may be necessary for off-screen
// rendering applications, or in situations where games
// pre-render a lot of images without presenting in between.
return m_descriptorPools.size() >= 8;
}
void DxvkDescriptorPool::alloc(
const DxvkBindingLayoutObjects* layout,
uint32_t setMask,

View File

@ -88,6 +88,14 @@ namespace dxvk {
~DxvkDescriptorPool();
/**
* \brief Tests whether the descriptor pool should be replaced
*
* \param [in] endFrame Whether this is the end of the frame
* \returns \c true if the pool should be submitted
*/
bool shouldSubmit(bool endFrame);
/**
* \brief Allocates one or multiple descriptor sets
*