mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-13 23:26:24 +00:00
OpenGL: Implement the backend connection and adapter.
The OpenGL backend can't gather discover default adapters because it needs getProc to do anything so we add DiscoverAdapters method to Instance that takes backend-specific options. dawn_native::opengl::CreateDevice is removed in favor of the adapter path so OpenGLBinding is modified to create an instance locally. This is only temporary until all backends support adapters, at which point a lot of *Binding code will be factored. Also contains a small fix for Result<T, E> with movable types. BUG=dawn:29 Change-Id: I4eb3d4a14a871af73e1872132aff72b45e5fe566 Reviewed-on: https://dawn-review.googlesource.com/c/3663 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
ab8eb2d6ed
commit
90e594ee8b
@@ -108,13 +108,23 @@ namespace utils {
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
#endif
|
||||
}
|
||||
|
||||
dawnDevice CreateDevice() override {
|
||||
glfwMakeContextCurrent(mWindow);
|
||||
// Load the GL entry points in our copy of the glad static library
|
||||
gladLoadGLLoader(reinterpret_cast<GLADloadproc>(glfwGetProcAddress));
|
||||
|
||||
return dawn_native::opengl::CreateDevice(
|
||||
reinterpret_cast<void* (*)(const char*)>(glfwGetProcAddress));
|
||||
// Make an instance and "discover" an OpenGL adapter with glfw's getProc
|
||||
mInstance = std::make_unique<dawn_native::Instance>();
|
||||
|
||||
dawn_native::opengl::AdapterDiscoveryOptions adapterOptions;
|
||||
adapterOptions.getProc = reinterpret_cast<void* (*)(const char*)>(glfwGetProcAddress);
|
||||
mInstance->DiscoverAdapters(&adapterOptions);
|
||||
|
||||
std::vector<dawn_native::Adapter> adapters = mInstance->GetAdapters();
|
||||
ASSERT(adapters.size() == 1);
|
||||
|
||||
return adapters[0].CreateDevice();
|
||||
}
|
||||
|
||||
uint64_t GetSwapChainImplementation() override {
|
||||
@@ -129,6 +139,7 @@ namespace utils {
|
||||
}
|
||||
|
||||
private:
|
||||
std::unique_ptr<dawn_native::Instance> mInstance;
|
||||
dawnSwapChainImplementation mSwapchainImpl = {};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user