MetalBinding: query the MTLDevice instead of creating it.
With adapters the Metal backend will be in charge of creating the MTLDevice so we remove this responsibility from the bindings. BUG=dawn:29 Change-Id: Id7b9e5f6249963e2b87a91242a18119ba8d11c13 Reviewed-on: https://dawn-review.googlesource.com/c/3661 Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
9506d53938
commit
95fd2821c2
|
@ -34,7 +34,7 @@ namespace dawn_native { namespace metal {
|
|||
|
||||
class Device : public DeviceBase {
|
||||
public:
|
||||
Device(id<MTLDevice> mtlDevice);
|
||||
Device();
|
||||
~Device();
|
||||
|
||||
CommandBufferBase* CreateCommandBuffer(CommandBufferBuilder* builder) override;
|
||||
|
|
|
@ -122,8 +122,13 @@ namespace dawn_native { namespace metal {
|
|||
}
|
||||
} // anonymous namespace
|
||||
|
||||
dawnDevice CreateDevice(id<MTLDevice> metalDevice) {
|
||||
return reinterpret_cast<dawnDevice>(new Device(metalDevice));
|
||||
dawnDevice CreateDevice() {
|
||||
return reinterpret_cast<dawnDevice>(new Device());
|
||||
}
|
||||
|
||||
id<MTLDevice> GetMetalDevice(dawnDevice cDevice) {
|
||||
Device* device = reinterpret_cast<Device*>(cDevice);
|
||||
return device->GetMTLDevice();
|
||||
}
|
||||
|
||||
BackendConnection* Connect(InstanceBase* instance) {
|
||||
|
@ -132,8 +137,8 @@ namespace dawn_native { namespace metal {
|
|||
|
||||
// Device
|
||||
|
||||
Device::Device(id<MTLDevice> mtlDevice)
|
||||
: mMtlDevice(mtlDevice),
|
||||
Device::Device()
|
||||
: mMtlDevice(MTLCreateSystemDefaultDevice()),
|
||||
mMapTracker(new MapRequestTracker(this)),
|
||||
mResourceUploader(new ResourceUploader(this)) {
|
||||
[mMtlDevice retain];
|
||||
|
|
|
@ -23,7 +23,8 @@
|
|||
#import <QuartzCore/CAMetalLayer.h>
|
||||
|
||||
namespace dawn_native { namespace metal {
|
||||
DAWN_NATIVE_EXPORT dawnDevice CreateDevice(id<MTLDevice> metalDevice);
|
||||
DAWN_NATIVE_EXPORT dawnDevice CreateDevice();
|
||||
DAWN_NATIVE_EXPORT id<MTLDevice> GetMetalDevice(dawnDevice device);
|
||||
}} // namespace dawn_native::metal
|
||||
|
||||
#endif // DAWNNATIVE_METALBACKEND_H_
|
||||
|
|
|
@ -111,9 +111,11 @@ namespace utils {
|
|||
void SetupGLFWWindowHints() override {
|
||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||
}
|
||||
|
||||
dawnDevice CreateDevice() override {
|
||||
mMetalDevice = MTLCreateSystemDefaultDevice();
|
||||
return dawn_native::metal::CreateDevice(mMetalDevice);
|
||||
dawnDevice device = dawn_native::metal::CreateDevice();
|
||||
mMetalDevice = dawn_native::metal::GetMetalDevice(device);
|
||||
return device;
|
||||
}
|
||||
|
||||
uint64_t GetSwapChainImplementation() override {
|
||||
|
|
Loading…
Reference in New Issue