Metal: Handle failure to allocate an MTLCommandBuffer

This requires restructuring the logic around MTLCommandBuffer allocation
so that GetPendingCommandContext is guaranteed to never fail. Logic in
the Metal backend is now similar to the Vulkan backend: the
MTLCommandBuffer is prepared at device initialization time, or after a
submission, such that it is always valid.

A new mUsed boolean is added to CommandRecordingContext to say whether
any commands have been recording. Previously mCommandBuffer was used for
that purpose, but it is now always non-null.

Bug: dawn:801

Change-Id: I5dc6747d1e6d538054010cc50533a03a49af921a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/58720
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Dawn Autoroller
2021-07-21 15:41:29 +00:00
committed by Dawn LUCI CQ
parent f50c22b998
commit 18f63b4e16
7 changed files with 61 additions and 46 deletions

View File

@@ -15,10 +15,7 @@
#ifndef COMMON_NONCOPYABLE_H_
#define COMMON_NONCOPYABLE_H_
// NonCopyable:
// the base class for the classes that are not copyable.
//
// A base class to make a class non-copyable.
class NonCopyable {
protected:
constexpr NonCopyable() = default;
@@ -29,4 +26,15 @@ class NonCopyable {
void operator=(const NonCopyable&) = delete;
};
// A base class to make a class non-movable.
class NonMovable : NonCopyable {
protected:
constexpr NonMovable() = default;
~NonMovable() = default;
private:
NonMovable(NonMovable&&) = delete;
void operator=(NonMovable&&) = delete;
};
#endif