mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-14 15:46:28 +00:00
dawn_native: Factor getting procs into a single function.
Now the backends only expose the creation of devices. Getting the procs is moved to DawnNative that will over time more backend-agnostic APIs.
This commit is contained in:
committed by
Corentin Wallez
parent
f9f44ae289
commit
dcb71a131c
@@ -36,7 +36,7 @@ namespace utils {
|
||||
virtual ~BackendBinding() = default;
|
||||
|
||||
virtual void SetupGLFWWindowHints() = 0;
|
||||
virtual void GetProcAndDevice(dawnProcTable* procs, dawnDevice* device) = 0;
|
||||
virtual dawnDevice CreateDevice() = 0;
|
||||
virtual uint64_t GetSwapChainImplementation() = 0;
|
||||
virtual dawnTextureFormat GetPreferredSwapChainTextureFormat() = 0;
|
||||
|
||||
|
||||
@@ -29,9 +29,8 @@ namespace utils {
|
||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||
}
|
||||
|
||||
void GetProcAndDevice(dawnProcTable* procs, dawnDevice* device) override {
|
||||
dawn_native::d3d12::Init(procs, device);
|
||||
mBackendDevice = *device;
|
||||
dawnDevice CreateDevice() override {
|
||||
return dawn_native::d3d12::CreateDevice();
|
||||
}
|
||||
|
||||
uint64_t GetSwapChainImplementation() override {
|
||||
|
||||
@@ -105,11 +105,9 @@ namespace utils {
|
||||
void SetupGLFWWindowHints() override {
|
||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||
}
|
||||
void GetProcAndDevice(dawnProcTable* procs, dawnDevice* device) override {
|
||||
dawnDevice CreateDevice() override {
|
||||
mMetalDevice = MTLCreateSystemDefaultDevice();
|
||||
|
||||
dawn_native::metal::Init(mMetalDevice, procs, device);
|
||||
mBackendDevice = *device;
|
||||
return dawn_native::metal::CreateDevice(mMetalDevice);
|
||||
}
|
||||
|
||||
uint64_t GetSwapChainImplementation() override {
|
||||
@@ -126,7 +124,6 @@ namespace utils {
|
||||
|
||||
private:
|
||||
id<MTLDevice> mMetalDevice = nil;
|
||||
dawnDevice mBackendDevice = nullptr;
|
||||
dawnSwapChainImplementation mSwapchainImpl = {};
|
||||
};
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ namespace utils {
|
||||
public:
|
||||
void SetupGLFWWindowHints() override {
|
||||
}
|
||||
void GetProcAndDevice(dawnProcTable* procs, dawnDevice* device) override {
|
||||
dawn_native::null::Init(procs, device);
|
||||
dawnDevice CreateDevice() override {
|
||||
return dawn_native::null::CreateDevice();
|
||||
}
|
||||
uint64_t GetSwapChainImplementation() override {
|
||||
return 0;
|
||||
|
||||
@@ -108,15 +108,13 @@ namespace utils {
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
#endif
|
||||
}
|
||||
void GetProcAndDevice(dawnProcTable* procs, dawnDevice* device) override {
|
||||
dawnDevice CreateDevice() override {
|
||||
glfwMakeContextCurrent(mWindow);
|
||||
// Load the GL entry points in our copy of the glad static library
|
||||
gladLoadGLLoader(reinterpret_cast<GLADloadproc>(glfwGetProcAddress));
|
||||
|
||||
dawn_native::opengl::Init(reinterpret_cast<void* (*)(const char*)>(glfwGetProcAddress),
|
||||
procs, device);
|
||||
|
||||
mBackendDevice = *device;
|
||||
return dawn_native::opengl::CreateDevice(
|
||||
reinterpret_cast<void* (*)(const char*)>(glfwGetProcAddress));
|
||||
}
|
||||
|
||||
uint64_t GetSwapChainImplementation() override {
|
||||
@@ -131,7 +129,6 @@ namespace utils {
|
||||
}
|
||||
|
||||
private:
|
||||
dawnDevice mBackendDevice = nullptr;
|
||||
dawnSwapChainImplementation mSwapchainImpl = {};
|
||||
};
|
||||
|
||||
|
||||
@@ -53,15 +53,14 @@ namespace utils {
|
||||
void SetupGLFWWindowHints() override {
|
||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||
}
|
||||
void GetProcAndDevice(dawnProcTable* procs, dawnDevice* device) override {
|
||||
dawnDevice CreateDevice() override {
|
||||
uint32_t extensionCount = 0;
|
||||
const char** glfwInstanceExtensions =
|
||||
glfwGetRequiredInstanceExtensions(&extensionCount);
|
||||
std::vector<const char*> requiredExtensions(glfwInstanceExtensions,
|
||||
glfwInstanceExtensions + extensionCount);
|
||||
|
||||
dawn_native::vulkan::Init(procs, device, requiredExtensions);
|
||||
mDevice = *device;
|
||||
return dawn_native::vulkan::CreateDevice(requiredExtensions);
|
||||
}
|
||||
uint64_t GetSwapChainImplementation() override {
|
||||
if (mSwapchainImpl.userData == nullptr) {
|
||||
|
||||
Reference in New Issue
Block a user