OSDN Git Service

MetalSurface: set layer.device to a ref of the system default device.
authorCorentin Wallez <cwallez@cwallez-macbookpro3.roam.corp.google.com>
Fri, 27 Mar 2020 16:38:29 +0000 (17:38 +0100)
committerCorentin Wallez <cwallez@google.com>
Wed, 1 Apr 2020 17:31:06 +0000 (17:31 +0000)
commitcb58662302c8e73845116fc5f14acaa08c037cb2
tree18275b2d3fd67afdff784dabc288d4a67d1967a1
parentc66dad9552ef9cab3a4dfb66c22d756fc5c4b06c
MetalSurface: set layer.device to a ref of the system default device.

If layer.device is null, [layer nextDrawable] returns nil, so on surface
initialization we set layer.device to a dummy MTLDevice by getting a
reference of the system default device.

MTLCreateSystemDefaultDevice() requires linking against
Metal.framework but Chromium needs to ship on platforms that don't have
Metal. This means we can't directly link against the framework, instead
we "weakly" link against it so that if it is not present, the function
pointers are just null (instead of failing to launch).

Bug: dawn:269
Change-Id: I5984613f576849c6f219c253da7eb277fa75ef52
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/43209
Kokoro-Presubmit: Corentin Wallez <cwallez@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Corentin Wallez <cwallez@google.com>
CMakeLists.txt
src/WSI/BUILD.gn
src/WSI/MetalSurface.mm