Simplify BackendBinding following adapters.

It doesn't need to care about device creation anymore, except for the
GLFW window hints and creating a GL context to discover the adapter.

Also remove the non-adapter GetPCIInfo.

BUG=dawn:29

Change-Id: I9bc8232536a55d2f973463ae0f2e0548dfc35456
Reviewed-on: https://dawn-review.googlesource.com/c/4381
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Corentin Wallez
2019-02-12 15:48:15 +00:00
committed by Commit Bot service account
parent 5987c4e839
commit bb5696bcd3
14 changed files with 139 additions and 170 deletions

View File

@@ -95,36 +95,9 @@ namespace utils {
class OpenGLBinding : public BackendBinding {
public:
void SetupGLFWWindowHints() override {
#if defined(DAWN_PLATFORM_APPLE)
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
#else
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 4);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
#endif
}
dawnDevice CreateDevice() override {
glfwMakeContextCurrent(mWindow);
OpenGLBinding(GLFWwindow* window, dawnDevice device) : BackendBinding(window, device) {
// Load the GL entry points in our copy of the glad static library
gladLoadGLLoader(reinterpret_cast<GLADloadproc>(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 {
@@ -139,12 +112,11 @@ namespace utils {
}
private:
std::unique_ptr<dawn_native::Instance> mInstance;
dawnSwapChainImplementation mSwapchainImpl = {};
};
BackendBinding* CreateOpenGLBinding() {
return new OpenGLBinding;
BackendBinding* CreateOpenGLBinding(GLFWwindow* window, dawnDevice device) {
return new OpenGLBinding(window, device);
}
} // namespace utils