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:
parent
cc47878116
commit
90a5595bbe
|
@ -46,6 +46,7 @@ namespace dawn_native { namespace metal {
|
||||||
void TickImpl() override;
|
void TickImpl() override;
|
||||||
|
|
||||||
id<MTLDevice> GetMTLDevice();
|
id<MTLDevice> GetMTLDevice();
|
||||||
|
id<MTLCommandQueue> GetMTLQueue();
|
||||||
|
|
||||||
id<MTLCommandBuffer> GetPendingCommandBuffer();
|
id<MTLCommandBuffer> GetPendingCommandBuffer();
|
||||||
Serial GetPendingCommandSerial() const override;
|
Serial GetPendingCommandSerial() const override;
|
||||||
|
|
|
@ -171,6 +171,10 @@ namespace dawn_native { namespace metal {
|
||||||
return mMtlDevice;
|
return mMtlDevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
id<MTLCommandQueue> Device::GetMTLQueue() {
|
||||||
|
return mCommandQueue;
|
||||||
|
}
|
||||||
|
|
||||||
id<MTLCommandBuffer> Device::GetPendingCommandBuffer() {
|
id<MTLCommandBuffer> Device::GetPendingCommandBuffer() {
|
||||||
TRACE_EVENT0(GetPlatform(), TRACE_DISABLED_BY_DEFAULT("gpu.dawn"),
|
TRACE_EVENT0(GetPlatform(), TRACE_DISABLED_BY_DEFAULT("gpu.dawn"),
|
||||||
"DeviceMTL::GetPendingCommandBuffer");
|
"DeviceMTL::GetPendingCommandBuffer");
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace dawn_native { namespace metal {
|
||||||
const auto& im = GetImplementation();
|
const auto& im = GetImplementation();
|
||||||
DawnWSIContextMetal wsiContext = {};
|
DawnWSIContextMetal wsiContext = {};
|
||||||
wsiContext.device = ToBackend(GetDevice())->GetMTLDevice();
|
wsiContext.device = ToBackend(GetDevice())->GetMTLDevice();
|
||||||
|
wsiContext.queue = ToBackend(GetDevice())->GetMTLQueue();
|
||||||
im.Init(im.userData, &wsiContext);
|
im.Init(im.userData, &wsiContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,7 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
id<MTLDevice> device = nil;
|
id<MTLDevice> device = nil;
|
||||||
|
id<MTLCommandQueue> queue = nil;
|
||||||
} DawnWSIContextMetal;
|
} DawnWSIContextMetal;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace utils {
|
||||||
|
|
||||||
void Init(DawnWSIContextMetal* ctx) {
|
void Init(DawnWSIContextMetal* ctx) {
|
||||||
mMtlDevice = ctx->device;
|
mMtlDevice = ctx->device;
|
||||||
mCommandQueue = [mMtlDevice newCommandQueue];
|
mCommandQueue = ctx->queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
DawnSwapChainError Configure(DawnTextureFormat format,
|
DawnSwapChainError Configure(DawnTextureFormat format,
|
||||||
|
|
Loading…
Reference in New Issue