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>
Mon, 30 Mar 2020 16:06:10 +0000 (16:06 +0000)
commit81d8c2ada561340400ccda0c560dc8f61ffb9a30
tree5d415e126d9055fd1b53fc4cc549562a915c07b2
parent1c29477aa06ea733994d1d11d6bf63ba27ac8359
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.

Using 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: I8719c45a19718ff79ef21f47515fe1c15b99628b
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/43112
Presubmit-Ready: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Corentin Wallez <cwallez@google.com>
src/WSI/BUILD.gn
src/WSI/MetalSurface.mm