mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-05 06:03:34 +00:00
Buffer: Always use MappedAtCreation state when applicable.
In a follow-up CL we need to know if the buffer is in the MappedAtCreation state for validation of GetMappedRange. Having the state not 100% reflect the state in the spec meant that validation if GetMappedRange would fail for buffers mapped at creation for which IsMapWritable is true. Bug: dawn:445 Change-Id: I4a64335a708b838526da8d65f907b21c782816e0 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23981 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
parent
bae16b4df9
commit
2008d15326
@ -163,16 +163,15 @@ namespace dawn_native {
|
|||||||
ASSERT(!IsError());
|
ASSERT(!IsError());
|
||||||
ASSERT(mappedPointer != nullptr);
|
ASSERT(mappedPointer != nullptr);
|
||||||
|
|
||||||
|
mState = BufferState::MappedAtCreation;
|
||||||
|
|
||||||
// Mappable buffers don't use a staging buffer and are just as if mapped through MapAsync.
|
// Mappable buffers don't use a staging buffer and are just as if mapped through MapAsync.
|
||||||
if (IsMapWritable()) {
|
if (IsMapWritable()) {
|
||||||
DAWN_TRY(MapAtCreationImpl(mappedPointer));
|
DAWN_TRY(MapAtCreationImpl(mappedPointer));
|
||||||
mState = BufferState::Mapped;
|
|
||||||
ASSERT(*mappedPointer != nullptr);
|
ASSERT(*mappedPointer != nullptr);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
mState = BufferState::MappedAtCreation;
|
|
||||||
|
|
||||||
// 0-sized buffers are not supposed to be written to, Return back any non-null pointer.
|
// 0-sized buffers are not supposed to be written to, Return back any non-null pointer.
|
||||||
if (mSize == 0) {
|
if (mSize == 0) {
|
||||||
*mappedPointer = reinterpret_cast<uint8_t*>(intptr_t(0xCAFED00D));
|
*mappedPointer = reinterpret_cast<uint8_t*>(intptr_t(0xCAFED00D));
|
||||||
@ -322,8 +321,9 @@ namespace dawn_native {
|
|||||||
} else if (mState == BufferState::MappedAtCreation) {
|
} else if (mState == BufferState::MappedAtCreation) {
|
||||||
if (mStagingBuffer != nullptr) {
|
if (mStagingBuffer != nullptr) {
|
||||||
mStagingBuffer.reset();
|
mStagingBuffer.reset();
|
||||||
} else {
|
} else if (mSize != 0) {
|
||||||
ASSERT(mSize == 0);
|
ASSERT(IsMapWritable());
|
||||||
|
Unmap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -371,8 +371,9 @@ namespace dawn_native {
|
|||||||
} else if (mState == BufferState::MappedAtCreation) {
|
} else if (mState == BufferState::MappedAtCreation) {
|
||||||
if (mStagingBuffer != nullptr) {
|
if (mStagingBuffer != nullptr) {
|
||||||
GetDevice()->ConsumedError(CopyFromStagingBuffer());
|
GetDevice()->ConsumedError(CopyFromStagingBuffer());
|
||||||
} else {
|
} else if (mSize != 0) {
|
||||||
ASSERT(mSize == 0);
|
ASSERT(IsMapWritable());
|
||||||
|
UnmapImpl();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user