dawn_wsi: Pass the Metal queue to the SwapChainImpl

If the swapchain creates its own queue, there can be races to determine
whether the submit of the present happens first. The didn't show up
in our samples but was an issue in real apps. Passing the queue to the
swapchain makes it simple to keep operations well ordered.

BUG=dawn:225

Change-Id: I9cc8e6e8140ad4a816373cffc9bda74ee826a41b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11640
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Corentin Wallez 2019-10-07 08:18:09 +00:00 committed by Commit Bot service account
parent cc47878116
commit 90a5595bbe
5 changed files with 8 additions and 1 deletions

View File

@ -46,6 +46,7 @@ namespace dawn_native { namespace metal {
void TickImpl() override;
id<MTLDevice> GetMTLDevice();
id<MTLCommandQueue> GetMTLQueue();
id<MTLCommandBuffer> GetPendingCommandBuffer();
Serial GetPendingCommandSerial() const override;

View File

@ -171,6 +171,10 @@ namespace dawn_native { namespace metal {
return mMtlDevice;
}
id<MTLCommandQueue> Device::GetMTLQueue() {
return mCommandQueue;
}
id<MTLCommandBuffer> Device::GetPendingCommandBuffer() {
TRACE_EVENT0(GetPlatform(), TRACE_DISABLED_BY_DEFAULT("gpu.dawn"),
"DeviceMTL::GetPendingCommandBuffer");

View File

@ -26,6 +26,7 @@ namespace dawn_native { namespace metal {
const auto& im = GetImplementation();
DawnWSIContextMetal wsiContext = {};
wsiContext.device = ToBackend(GetDevice())->GetMTLDevice();
wsiContext.queue = ToBackend(GetDevice())->GetMTLQueue();
im.Init(im.userData, &wsiContext);
}

View File

@ -69,6 +69,7 @@ typedef struct {
typedef struct {
id<MTLDevice> device = nil;
id<MTLCommandQueue> queue = nil;
} DawnWSIContextMetal;
#endif

View File

@ -39,7 +39,7 @@ namespace utils {
void Init(DawnWSIContextMetal* ctx) {
mMtlDevice = ctx->device;
mCommandQueue = [mMtlDevice newCommandQueue];
mCommandQueue = ctx->queue;
}
DawnSwapChainError Configure(DawnTextureFormat format,