mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-15 07:00:58 +00:00
Merge pull request #527 from infapi00/limit-staging-commands
Staging: add a limit of how many commands to stage
This commit is contained in:
commit
381424f47b
2 changed files with 13 additions and 0 deletions
|
@ -34,6 +34,7 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#include "Staging_VK.h"
|
||||
|
||||
idCVar r_vkUploadBufferSizeMB( "r_vkUploadBufferSizeMB", "64", CVAR_INTEGER | CVAR_INIT, "Size of gpu upload buffer." );
|
||||
idCVar r_vkStagingMaxCommands( "r_vkStagingMaxCommands", "-1", CVAR_INTEGER | CVAR_INIT, "Maximum amount of commands staged (-1 for no limit)" );
|
||||
|
||||
/*
|
||||
===========================================================================
|
||||
|
@ -182,6 +183,12 @@ byte* idVulkanStagingManager::Stage( const int size, const int alignment, VkComm
|
|||
Flush();
|
||||
}
|
||||
|
||||
int maxCommands = r_vkStagingMaxCommands.GetInteger();
|
||||
if ( ( maxCommands > 0 ) && ( stage->stagedCommands >= maxCommands) )
|
||||
{
|
||||
Flush();
|
||||
}
|
||||
|
||||
stage = &buffers[ currentBuffer ];
|
||||
if( stage->submitted )
|
||||
{
|
||||
|
@ -195,6 +202,8 @@ byte* idVulkanStagingManager::Stage( const int size, const int alignment, VkComm
|
|||
byte* data = stage->data + stage->offset;
|
||||
stage->offset += size;
|
||||
|
||||
stage->stagedCommands++;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
@ -237,6 +246,7 @@ void idVulkanStagingManager::Flush()
|
|||
vkQueueSubmit( vkcontext.graphicsQueue, 1, &submitInfo, stage.fence );
|
||||
|
||||
stage.submitted = true;
|
||||
stage.stagedCommands = 0;
|
||||
|
||||
currentBuffer = ( currentBuffer + 1 ) % NUM_FRAME_DATA;
|
||||
}
|
||||
|
@ -256,6 +266,7 @@ void idVulkanStagingManager::Wait( stagingBuffer_t& stage )
|
|||
ID_VK_CHECK( vkWaitForFences( vkcontext.device, 1, &stage.fence, VK_TRUE, UINT64_MAX ) );
|
||||
ID_VK_CHECK( vkResetFences( vkcontext.device, 1, &stage.fence ) );
|
||||
|
||||
stage.stagedCommands = 0;
|
||||
stage.offset = 0;
|
||||
stage.submitted = false;
|
||||
|
||||
|
|
|
@ -54,6 +54,8 @@ struct stagingBuffer_t
|
|||
VkFence fence;
|
||||
VkDeviceSize offset;
|
||||
byte* data;
|
||||
|
||||
int stagedCommands;
|
||||
};
|
||||
|
||||
class idVulkanStagingManager
|
||||
|
|
Loading…
Reference in a new issue