Skip to content

Commit

Permalink
Fixed the code that rounds sizes up to a multiple of 4: #38
Browse files Browse the repository at this point in the history
  • Loading branch information
apanteleev committed Oct 26, 2023
1 parent 01a90aa commit 8942401
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/vulkan/vulkan-buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ namespace nvrhi::vulkan
// vulkan allows for <= 64kb buffer updates to be done inline via vkCmdUpdateBuffer,
// but the data size must always be a multiple of 4
// enlarge the buffer slightly to allow for this
size += size % 4;
size = (size + 3) & ~3ull;
}

auto bufferInfo = vk::BufferCreateInfo()
Expand Down Expand Up @@ -437,7 +437,7 @@ namespace nvrhi::vulkan
int64_t thisGulpSize = std::min(remaining, int64_t(commandBufferWriteLimit));

// we bloat the read size here past the incoming buffer since the transfer must be a multiple of 4; the extra garbage should never be used anywhere
thisGulpSize += thisGulpSize % 4;
thisGulpSize = (thisGulpSize + 3) & ~3ll;
m_CurrentCmdBuf->cmdBuf.updateBuffer(buffer->buffer, destOffsetBytes + dataSize - remaining, thisGulpSize, &base[dataSize - remaining]);
remaining -= thisGulpSize;
}
Expand Down

0 comments on commit 8942401

Please sign in to comment.