1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 02:32:36 +01:00

gpu-open/vma: Optimize CheckAllocation method

- Avoids doing useless work. The scanning algorithm is painfully slow on hardware with alignment requirement > 1
- Upto 50ms saved for ~600 allocations when many small allocations exist
This commit is contained in:
kd-11 2021-01-26 23:50:13 +03:00 committed by kd-11
parent 6f4dbf4fcd
commit 5a049d41fd

View File

@ -8848,7 +8848,7 @@ bool VmaBlockMetadata_Generic::CheckAllocation(
// Check previous suballocations for BufferImageGranularity conflicts.
// Make bigger alignment if necessary.
if(bufferImageGranularity > 1)
if(bufferImageGranularity > 1 && bufferImageGranularity != allocAlignment)
{
bool bufferImageGranularityConflict = false;
VmaSuballocationList::const_iterator prevSuballocItem = suballocItem;
@ -8932,7 +8932,7 @@ bool VmaBlockMetadata_Generic::CheckAllocation(
// Check next suballocations for BufferImageGranularity conflicts.
// If conflict exists, we must mark more allocations lost or fail.
if(bufferImageGranularity > 1)
if(bufferImageGranularity > 1 && (allocSize % bufferImageGranularity || *pOffset % bufferImageGranularity))
{
VmaSuballocationList::const_iterator nextSuballocItem = lastSuballocItem;
++nextSuballocItem;
@ -8991,7 +8991,7 @@ bool VmaBlockMetadata_Generic::CheckAllocation(
// Check previous suballocations for BufferImageGranularity conflicts.
// Make bigger alignment if necessary.
if(bufferImageGranularity > 1)
if(bufferImageGranularity > 1 && bufferImageGranularity != allocAlignment)
{
bool bufferImageGranularityConflict = false;
VmaSuballocationList::const_iterator prevSuballocItem = suballocItem;
@ -9031,7 +9031,7 @@ bool VmaBlockMetadata_Generic::CheckAllocation(
// Check next suballocations for BufferImageGranularity conflicts.
// If conflict exists, allocation cannot be made here.
if(bufferImageGranularity > 1)
if(bufferImageGranularity > 1 && (allocSize % bufferImageGranularity || *pOffset % bufferImageGranularity))
{
VmaSuballocationList::const_iterator nextSuballocItem = suballocItem;
++nextSuballocItem;