mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-14 07:36:15 +00:00
Vulkan: Implement the backend connection and adapter.
This also changes VulkanInfo to gather info on backends / adapters instead of the device, because all the info gathering can happen before the device is created. BUG=dawn:29 Change-Id: I9dc4412f494428f1ae589544d3adf76fe8b9a3a3 Reviewed-on: https://dawn-review.googlesource.com/c/3941 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
c26f6dae33
commit
d1be0e7077
@@ -28,8 +28,20 @@ namespace utils {
|
||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||
}
|
||||
dawnDevice CreateDevice() override {
|
||||
mDevice = dawn_native::vulkan::CreateDevice();
|
||||
return mDevice;
|
||||
// Make an instance and find a Vulkan 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::Vulkan) {
|
||||
mDevice = adapter.CreateDevice();
|
||||
return mDevice;
|
||||
}
|
||||
}
|
||||
|
||||
UNREACHABLE();
|
||||
return {};
|
||||
}
|
||||
uint64_t GetSwapChainImplementation() override {
|
||||
if (mSwapchainImpl.userData == nullptr) {
|
||||
@@ -49,7 +61,8 @@ namespace utils {
|
||||
}
|
||||
|
||||
private:
|
||||
dawnDevice mDevice;
|
||||
std::unique_ptr<dawn_native::Instance> mInstance;
|
||||
dawnDevice mDevice = nullptr;
|
||||
dawnSwapChainImplementation mSwapchainImpl = {};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user