Handle staging buffer map failure on Metal.

BUG=dawn:108

Change-Id: Iae1331e179d112d5b93327e7e44f6a5e870557e7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9882
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Bryan Bernhart 2019-08-12 23:16:17 +00:00 committed by Commit Bot service account
parent 74e4834d3d
commit 9b45b5aafa
1 changed files with 9 additions and 0 deletions

View File

@ -25,7 +25,16 @@ namespace dawn_native { namespace metal {
const size_t bufferSize = GetSize(); const size_t bufferSize = GetSize();
mBuffer = [mDevice->GetMTLDevice() newBufferWithLength:bufferSize mBuffer = [mDevice->GetMTLDevice() newBufferWithLength:bufferSize
options:MTLResourceStorageModeShared]; options:MTLResourceStorageModeShared];
if (mBuffer == nil) {
return DAWN_CONTEXT_LOST_ERROR("Unable to allocate buffer.");
}
mMappedPointer = [mBuffer contents]; mMappedPointer = [mBuffer contents];
if (mMappedPointer == nullptr) {
return DAWN_CONTEXT_LOST_ERROR("Unable to map staging buffer.");
}
return {}; return {};
} }