Fix Mesh/Buffer:flush uploading more data than it needs to, sometimes.

This commit is contained in:
Alex Szpakowski
2020-07-21 21:56:47 -03:00
parent 7ad5e5a21a
commit 1d087cc5c2
2 changed files with 15 additions and 2 deletions
+14 -2
View File
@@ -112,6 +112,7 @@ void *Buffer::map()
modifiedOffset = 0;
modifiedSize = 0;
isMappedDataModified = false;
return memoryMap;
}
@@ -149,8 +150,13 @@ void Buffer::unmap()
if (!mapped)
return;
mapped = false;
if ((mapFlags & MAP_EXPLICIT_RANGE_MODIFY) != 0)
{
if (!isMappedDataModified)
return;
modifiedOffset = std::min(modifiedOffset, getSize() - 1);
modifiedSize = std::min(modifiedSize, getSize() - modifiedOffset);
}
@@ -184,8 +190,6 @@ void Buffer::unmap()
modifiedOffset = 0;
modifiedSize = 0;
mapped = false;
}
void Buffer::setMappedRangeModified(size_t offset, size_t modifiedsize)
@@ -193,6 +197,14 @@ void Buffer::setMappedRangeModified(size_t offset, size_t modifiedsize)
if (!mapped || !(mapFlags & MAP_EXPLICIT_RANGE_MODIFY))
return;
if (!isMappedDataModified)
{
modifiedOffset = offset;
modifiedSize = size;
isMappedDataModified = true;
return;
}
// We're being conservative right now by internally marking the whole range
// from the start of section a to the end of section b as modified if both
// a and b are marked as modified.
+1
View File
@@ -75,6 +75,7 @@ private:
size_t modifiedOffset = 0;
size_t modifiedSize = 0;
bool isMappedDataModified = false;
}; // Buffer