Skip to content

Commit

Permalink
Merge pull request GPUOpen-LibrariesAndSDKs#163 from kd-11/master
Browse files Browse the repository at this point in the history
mem_alloc: Optimize allocation conflict checking
  • Loading branch information
adam-sawicki-a authored Feb 16, 2021
2 parents f201205 + e8c483d commit b654142
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/vk_mem_alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -9656,7 +9656,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;
Expand Down Expand Up @@ -9740,7 +9740,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(allocSize % bufferImageGranularity || *pOffset % bufferImageGranularity)
{
VmaSuballocationList::const_iterator nextSuballocItem = lastSuballocItem;
++nextSuballocItem;
Expand Down Expand Up @@ -9799,7 +9799,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;
Expand Down Expand Up @@ -9839,7 +9839,7 @@ bool VmaBlockMetadata_Generic::CheckAllocation(

// Check next suballocations for BufferImageGranularity conflicts.
// If conflict exists, allocation cannot be made here.
if(bufferImageGranularity > 1)
if(allocSize % bufferImageGranularity || *pOffset % bufferImageGranularity)
{
VmaSuballocationList::const_iterator nextSuballocItem = suballocItem;
++nextSuballocItem;
Expand Down Expand Up @@ -11007,7 +11007,7 @@ bool VmaBlockMetadata_Linear::CreateAllocationRequest_UpperAddress(

// Check next suballocations from 2nd for BufferImageGranularity conflicts.
// Make bigger alignment if necessary.
if(bufferImageGranularity > 1 && !suballocations2nd.empty())
if(bufferImageGranularity > 1 && bufferImageGranularity != allocAlignment && !suballocations2nd.empty())
{
bool bufferImageGranularityConflict = false;
for(size_t nextSuballocIndex = suballocations2nd.size(); nextSuballocIndex--; )
Expand Down Expand Up @@ -11112,7 +11112,7 @@ bool VmaBlockMetadata_Linear::CreateAllocationRequest_LowerAddress(

// Check previous suballocations for BufferImageGranularity conflicts.
// Make bigger alignment if necessary.
if(bufferImageGranularity > 1 && !suballocations1st.empty())
if(bufferImageGranularity > 1 && bufferImageGranularity != allocAlignment && !suballocations1st.empty())
{
bool bufferImageGranularityConflict = false;
for(size_t prevSuballocIndex = suballocations1st.size(); prevSuballocIndex--; )
Expand Down Expand Up @@ -11144,7 +11144,7 @@ bool VmaBlockMetadata_Linear::CreateAllocationRequest_LowerAddress(
{
// Check next suballocations for BufferImageGranularity conflicts.
// If conflict exists, allocation cannot be made here.
if(bufferImageGranularity > 1 && m_2ndVectorMode == SECOND_VECTOR_DOUBLE_STACK)
if((allocSize % bufferImageGranularity || resultOffset % bufferImageGranularity) && m_2ndVectorMode == SECOND_VECTOR_DOUBLE_STACK)
{
for(size_t nextSuballocIndex = suballocations2nd.size(); nextSuballocIndex--; )
{
Expand Down Expand Up @@ -11202,7 +11202,7 @@ bool VmaBlockMetadata_Linear::CreateAllocationRequest_LowerAddress(

// Check previous suballocations for BufferImageGranularity conflicts.
// Make bigger alignment if necessary.
if(bufferImageGranularity > 1 && !suballocations2nd.empty())
if(bufferImageGranularity > 1 && bufferImageGranularity != allocAlignment && !suballocations2nd.empty())
{
bool bufferImageGranularityConflict = false;
for(size_t prevSuballocIndex = suballocations2nd.size(); prevSuballocIndex--; )
Expand Down Expand Up @@ -11260,7 +11260,7 @@ bool VmaBlockMetadata_Linear::CreateAllocationRequest_LowerAddress(

// Check next suballocations for BufferImageGranularity conflicts.
// If conflict exists, we must mark more allocations lost or fail.
if(bufferImageGranularity > 1)
if(allocSize % bufferImageGranularity || resultOffset % bufferImageGranularity)
{
while(index1st < suballocations1st.size())
{
Expand Down Expand Up @@ -11306,7 +11306,7 @@ bool VmaBlockMetadata_Linear::CreateAllocationRequest_LowerAddress(
{
// Check next suballocations for BufferImageGranularity conflicts.
// If conflict exists, allocation cannot be made here.
if(bufferImageGranularity > 1)
if(allocSize % bufferImageGranularity || resultOffset % bufferImageGranularity)
{
for(size_t nextSuballocIndex = index1st;
nextSuballocIndex < suballocations1st.size();
Expand Down

0 comments on commit b654142

Please sign in to comment.