mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-18 09:25:25 +00:00
Metal: Implement the backend connection and adapter.
BUG=dawn:29 Change-Id: Idaca7d2f8ac52d5f46d8030571b5e2da3a573a97 Reviewed-on: https://dawn-review.googlesource.com/c/3940 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
a27bdb4a5e
commit
978fa65a2c
@@ -22,6 +22,8 @@
|
||||
#include "GLFW/glfw3.h"
|
||||
#include "GLFW/glfw3native.h"
|
||||
|
||||
#import <QuartzCore/CAMetalLayer.h>
|
||||
|
||||
namespace utils {
|
||||
class SwapChainImplMTL {
|
||||
public:
|
||||
@@ -113,9 +115,21 @@ namespace utils {
|
||||
}
|
||||
|
||||
dawnDevice CreateDevice() override {
|
||||
dawnDevice device = dawn_native::metal::CreateDevice();
|
||||
mMetalDevice = dawn_native::metal::GetMetalDevice(device);
|
||||
return device;
|
||||
// Make an instance and find a Metal adapter
|
||||
mInstance = std::make_unique<dawn_native::Instance>();
|
||||
mInstance->DiscoverDefaultAdapters();
|
||||
|
||||
std::vector<dawn_native::Adapter> adapters = mInstance->GetAdapters();
|
||||
for (dawn_native::Adapter adapter : adapters) {
|
||||
if (adapter.GetBackendType() == dawn_native::BackendType::Metal) {
|
||||
dawnDevice device = adapter.CreateDevice();
|
||||
mMetalDevice = dawn_native::metal::GetMetalDevice(device);
|
||||
return device;
|
||||
}
|
||||
}
|
||||
|
||||
UNREACHABLE();
|
||||
return {};
|
||||
}
|
||||
|
||||
uint64_t GetSwapChainImplementation() override {
|
||||
@@ -131,6 +145,7 @@ namespace utils {
|
||||
}
|
||||
|
||||
private:
|
||||
std::unique_ptr<dawn_native::Instance> mInstance;
|
||||
id<MTLDevice> mMetalDevice = nil;
|
||||
dawnSwapChainImplementation mSwapchainImpl = {};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user