mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 10:49:14 +00:00
Fixing offset alignments when using DynamicUploader
When using a dynamic uploader we didn't align the offset that the allocated memory might have already had. That fixes WriteTexture, WriteBuffer, ClearTexture and on D3D12 ClearBuffer. Bug: dawn:512 Change-Id: I64c7511ad6b0d3d6a28a494e1324a10ad4d38091 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/27020 Commit-Queue: Tomek Ponitka <tommek@google.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
committed by
Commit Bot service account
parent
eff9ef0f22
commit
7f265d1d40
@@ -28,7 +28,8 @@ namespace dawn_native {
|
||||
mDevice->GetPendingCommandSerial());
|
||||
}
|
||||
|
||||
ResultOrError<UploadHandle> DynamicUploader::Allocate(uint64_t allocationSize, Serial serial) {
|
||||
ResultOrError<UploadHandle> DynamicUploader::AllocateInternal(uint64_t allocationSize,
|
||||
Serial serial) {
|
||||
// Disable further sub-allocation should the request be too large.
|
||||
if (allocationSize > kRingBufferSize) {
|
||||
std::unique_ptr<StagingBufferBase> stagingBuffer;
|
||||
@@ -108,4 +109,21 @@ namespace dawn_native {
|
||||
}
|
||||
mReleasedStagingBuffers.ClearUpTo(lastCompletedSerial);
|
||||
}
|
||||
|
||||
// TODO(dawn:512): Optimize this function so that it doesn't allocate additional memory
|
||||
// when it's not necessary.
|
||||
ResultOrError<UploadHandle> DynamicUploader::Allocate(uint64_t allocationSize,
|
||||
Serial serial,
|
||||
uint64_t offsetAlignment) {
|
||||
ASSERT(offsetAlignment > 0);
|
||||
UploadHandle uploadHandle;
|
||||
DAWN_TRY_ASSIGN(uploadHandle,
|
||||
AllocateInternal(allocationSize + offsetAlignment - 1, serial));
|
||||
uint64_t additionalOffset =
|
||||
Align(uploadHandle.startOffset, offsetAlignment) - uploadHandle.startOffset;
|
||||
uploadHandle.mappedBuffer =
|
||||
static_cast<uint8_t*>(uploadHandle.mappedBuffer) + additionalOffset;
|
||||
uploadHandle.startOffset += additionalOffset;
|
||||
return uploadHandle;
|
||||
}
|
||||
} // namespace dawn_native
|
||||
|
||||
Reference in New Issue
Block a user