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

@@ -43,7 +43,7 @@ namespace dawn_native { namespace null {
}
ResultOrError<DeviceBase*> Adapter::CreateDeviceImpl(const DeviceDescriptor* descriptor) {
return {new Device(this, descriptor)};
return Device::Create(this, descriptor);
}
class Backend : public BackendConnection {
@@ -78,8 +78,11 @@ namespace dawn_native { namespace null {
// Device
Device::Device(Adapter* adapter, const DeviceDescriptor* descriptor)
: DeviceBase(adapter, descriptor) {
// static
ResultOrError<Device*> Device::Create(Adapter* adapter, const DeviceDescriptor* descriptor) {
Ref<Device> device = AcquireRef(new Device(adapter, descriptor));
DAWN_TRY(device->Initialize());
return device.Detach();
}
Device::~Device() {
@@ -89,6 +92,10 @@ namespace dawn_native { namespace null {
ASSERT(mMemoryUsage == 0);
}
MaybeError Device::Initialize() {
return DeviceBase::Initialize();
}
ResultOrError<BindGroupBase*> Device::CreateBindGroupImpl(
const BindGroupDescriptor* descriptor) {
return new BindGroup(this, descriptor);

View File

@@ -83,9 +83,11 @@ namespace dawn_native { namespace null {
class Device : public DeviceBase {
public:
Device(Adapter* adapter, const DeviceDescriptor* descriptor);
static ResultOrError<Device*> Create(Adapter* adapter, const DeviceDescriptor* descriptor);
~Device();
MaybeError Initialize();
CommandBufferBase* CreateCommandBuffer(CommandEncoder* encoder,
const CommandBufferDescriptor* descriptor) override;
@@ -108,6 +110,8 @@ namespace dawn_native { namespace null {
void DecrementMemoryUsage(size_t bytes);
private:
using DeviceBase::DeviceBase;
ResultOrError<BindGroupBase*> CreateBindGroupImpl(
const BindGroupDescriptor* descriptor) override;
ResultOrError<BindGroupLayoutBase*> CreateBindGroupLayoutImpl(