Add a DeviceBase::Initialize that must be called by backends.

Bug: dawn:373
Change-Id: I5213496f4676bedc8e2a88912e89b6e0aacbac37
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/18800
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez
2020-04-07 15:10:17 +00:00
committed by Commit Bot service account
parent 2d10e954ce
commit 09ee5eb499
16 changed files with 106 additions and 37 deletions

View File

@@ -182,7 +182,7 @@ namespace dawn_native { namespace opengl {
ResultOrError<DeviceBase*> CreateDeviceImpl(const DeviceDescriptor* descriptor) override {
// There is no limit on the number of devices created from this adapter because they can
// all share the same backing OpenGL context.
return {new Device(this, descriptor, mFunctions)};
return Device::Create(this, descriptor, mFunctions);
}
void InitializeSupportedExtensions() {

View File

@@ -33,18 +33,32 @@
namespace dawn_native { namespace opengl {
// static
ResultOrError<Device*> Device::Create(AdapterBase* adapter,
const DeviceDescriptor* descriptor,
const OpenGLFunctions& functions) {
Ref<Device> device = AcquireRef(new Device(adapter, descriptor, functions));
DAWN_TRY(device->Initialize());
return device.Detach();
}
Device::Device(AdapterBase* adapter,
const DeviceDescriptor* descriptor,
const OpenGLFunctions& functions)
: DeviceBase(adapter, descriptor), gl(functions) {
InitTogglesFromDriver();
mFormatTable = BuildGLFormatTable();
}
Device::~Device() {
BaseDestructor();
}
MaybeError Device::Initialize() {
InitTogglesFromDriver();
mFormatTable = BuildGLFormatTable();
return DeviceBase::Initialize();
}
void Device::InitTogglesFromDriver() {
bool supportsBaseVertex = gl.IsAtLeastGLES(3, 2) || gl.IsAtLeastGL(3, 2);

View File

@@ -34,11 +34,13 @@ namespace dawn_native { namespace opengl {
class Device : public DeviceBase {
public:
Device(AdapterBase* adapter,
const DeviceDescriptor* descriptor,
const OpenGLFunctions& functions);
static ResultOrError<Device*> Create(AdapterBase* adapter,
const DeviceDescriptor* descriptor,
const OpenGLFunctions& functions);
~Device();
MaybeError Initialize();
// Contains all the OpenGL entry points, glDoFoo is called via device->gl.DoFoo.
const OpenGLFunctions gl;
@@ -63,6 +65,10 @@ namespace dawn_native { namespace opengl {
uint64_t size) override;
private:
Device(AdapterBase* adapter,
const DeviceDescriptor* descriptor,
const OpenGLFunctions& functions);
ResultOrError<BindGroupBase*> CreateBindGroupImpl(
const BindGroupDescriptor* descriptor) override;
ResultOrError<BindGroupLayoutBase*> CreateBindGroupLayoutImpl(