OpenGL: Restore ContextExternal support
This commit is contained in:
parent
0bd776df12
commit
cc359d7bbb
|
@ -97,8 +97,9 @@ ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> Backend::DiscoverPhysicalDev
|
|||
DAWN_INVALID_IF(options->getProc == nullptr,
|
||||
"PhysicalDeviceDiscoveryOptions::getProc must be set");
|
||||
|
||||
Ref<PhysicalDevice> physicalDevice = AcquireRef(new PhysicalDevice(
|
||||
GetInstance(), static_cast<wgpu::BackendType>(optionsBase->backendType)));
|
||||
Ref<PhysicalDevice> physicalDevice = AcquireRef(
|
||||
new PhysicalDevice(GetInstance(), static_cast<wgpu::BackendType>(optionsBase->backendType),
|
||||
options->makeCurrent, options->destroy, options->userData));
|
||||
DAWN_TRY(physicalDevice->InitializeGLFunctions(options->getProc));
|
||||
DAWN_TRY(physicalDevice->Initialize());
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "dawn/common/GPUInfo.h"
|
||||
#include "dawn/native/Instance.h"
|
||||
#include "dawn/native/opengl/ContextEGL.h"
|
||||
#include "dawn/native/opengl/ContextExternal.h"
|
||||
#include "dawn/native/opengl/DeviceGL.h"
|
||||
|
||||
namespace dawn::native::opengl {
|
||||
|
@ -53,12 +54,21 @@ uint32_t GetVendorIdFromVendors(const char* vendor) {
|
|||
|
||||
} // anonymous namespace
|
||||
|
||||
PhysicalDevice::PhysicalDevice(InstanceBase* instance, wgpu::BackendType backendType)
|
||||
: PhysicalDeviceBase(instance, backendType) {}
|
||||
PhysicalDevice::PhysicalDevice(InstanceBase* instance,
|
||||
wgpu::BackendType backendType,
|
||||
void (*makeCurrent)(void*),
|
||||
void (*destroy)(void*),
|
||||
void* userData)
|
||||
: PhysicalDeviceBase(instance, backendType),
|
||||
mMakeCurrent(makeCurrent),
|
||||
mDestroy(destroy),
|
||||
mUserData(userData) {}
|
||||
|
||||
MaybeError PhysicalDevice::InitializeGLFunctions(void* (*getProc)(const char*)) {
|
||||
if (mMakeCurrent == nullptr) {
|
||||
// Use getProc to populate the dispatch table
|
||||
mEGLFunctions.Init(getProc);
|
||||
}
|
||||
return mFunctions.Initialize(getProc);
|
||||
}
|
||||
|
||||
|
@ -238,7 +248,11 @@ ResultOrError<Ref<DeviceBase>> PhysicalDevice::CreateDeviceImpl(AdapterBase* ada
|
|||
EGLenum api =
|
||||
GetBackendType() == wgpu::BackendType::OpenGL ? EGL_OPENGL_API : EGL_OPENGL_ES_API;
|
||||
std::unique_ptr<Device::Context> context;
|
||||
if (mMakeCurrent != nullptr) {
|
||||
DAWN_TRY_ASSIGN(context, ContextExternal::Create(mMakeCurrent, mDestroy, mUserData));
|
||||
} else {
|
||||
DAWN_TRY_ASSIGN(context, ContextEGL::Create(mEGLFunctions, api));
|
||||
}
|
||||
return Device::Create(adapter, descriptor, mFunctions, std::move(context), deviceToggles);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,11 @@ namespace dawn::native::opengl {
|
|||
|
||||
class PhysicalDevice : public PhysicalDeviceBase {
|
||||
public:
|
||||
PhysicalDevice(InstanceBase* instance, wgpu::BackendType backendType);
|
||||
PhysicalDevice(InstanceBase* instance,
|
||||
wgpu::BackendType backendType,
|
||||
void (*makeCurrent)(void*),
|
||||
void (*destroy)(void*),
|
||||
void* userData);
|
||||
|
||||
MaybeError InitializeGLFunctions(void* (*getProc)(const char*));
|
||||
|
||||
|
@ -48,6 +52,9 @@ class PhysicalDevice : public PhysicalDeviceBase {
|
|||
|
||||
OpenGLFunctions mFunctions;
|
||||
EGLFunctions mEGLFunctions;
|
||||
void (*mMakeCurrent)(void*);
|
||||
void (*mDestroy)(void*);
|
||||
void* mUserData;
|
||||
};
|
||||
|
||||
} // namespace dawn::native::opengl
|
||||
|
|
Loading…
Reference in New Issue