Bug 1611024 - Turn WebGPU programmable passes into interface mixins r=jgilbert,webidl,bzbarsky

this makes us closer to the upstream spec and removes a bunch of useless code

Differential Revision: https://phabricator.services.mozilla.com/D62377

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Dzmitry Malyshau 2020-02-11 03:03:47 +00:00
Родитель 98e23d977a
Коммит bf6b5347b2
13 изменённых файлов: 24 добавлений и 194 удалений

Просмотреть файл

@ -1348,9 +1348,6 @@ DOMInterfaces = {
'GPUPipelineLayout': {
'nativeType': 'mozilla::webgpu::PipelineLayout',
},
'GPUProgrammablePassEncoder': {
'nativeType': 'mozilla::webgpu::ProgrammablePassEncoder',
},
'GPUQueue': {
'nativeType': 'mozilla::webgpu::Queue',
},
@ -1360,9 +1357,6 @@ DOMInterfaces = {
'GPURenderBundleEncoder': {
'nativeType': 'mozilla::webgpu::RenderBundleEncoder',
},
'GPURenderEncoderBase': {
'nativeType': 'mozilla::webgpu::RenderEncoderBase',
},
'GPURenderPassEncoder': {
'nativeType': 'mozilla::webgpu::RenderPassEncoder',
},

Просмотреть файл

@ -13,13 +13,7 @@
namespace mozilla {
namespace webgpu {
NS_IMPL_CYCLE_COLLECTION_INHERITED(ComputePassEncoder, ProgrammablePassEncoder,
mParent)
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED_0(ComputePassEncoder,
ProgrammablePassEncoder)
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(ComputePassEncoder,
ProgrammablePassEncoder)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
GPU_IMPL_CYCLE_COLLECTION(ComputePassEncoder, mParent)
GPU_IMPL_JS_WRAP(ComputePassEncoder)
ffi::WGPURawPass BeginComputePass(RawId aEncoderId,

Просмотреть файл

@ -10,7 +10,6 @@
#include "mozilla/webgpu/WebGPUTypes.h"
#include "mozilla/webgpu/ffi/wgpu.h"
#include "ObjectModel.h"
#include "ProgrammablePassEncoder.h"
namespace mozilla {
namespace webgpu {
@ -19,12 +18,10 @@ class Buffer;
class CommandEncoder;
class ComputePipeline;
class ComputePassEncoder final : public ProgrammablePassEncoder,
class ComputePassEncoder final : public ObjectBase,
public ChildOf<CommandEncoder> {
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(
ComputePassEncoder, ProgrammablePassEncoder)
GPU_DECL_CYCLE_COLLECTION(ComputePassEncoder)
GPU_DECL_JS_WRAP(ComputePassEncoder)
ComputePassEncoder(CommandEncoder* const aParent,
@ -38,7 +35,7 @@ class ComputePassEncoder final : public ProgrammablePassEncoder,
public:
void SetBindGroup(uint32_t aSlot, const BindGroup& aBindGroup,
const dom::Sequence<uint32_t>& aDynamicOffsets) override;
const dom::Sequence<uint32_t>& aDynamicOffsets);
void SetPipeline(const ComputePipeline& aPipeline);
void Dispatch(uint32_t x, uint32_t y, uint32_t z);
void EndPass(ErrorResult& aRv);

Просмотреть файл

@ -1,23 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "ProgrammablePassEncoder.h"
#include "BindGroup.h"
namespace mozilla {
namespace webgpu {
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(ProgrammablePassEncoder)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ProgrammablePassEncoder)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(ProgrammablePassEncoder)
NS_IMPL_CYCLE_COLLECTING_RELEASE(ProgrammablePassEncoder)
ProgrammablePassEncoder::ProgrammablePassEncoder() = default;
} // namespace webgpu
} // namespace mozilla

Просмотреть файл

@ -1,46 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef GPU_ProgrammablePassEncoder_H_
#define GPU_ProgrammablePassEncoder_H_
#include "mozilla/dom/TypedArray.h"
#include "ObjectModel.h"
namespace mozilla {
namespace dom {
template <typename T>
class Sequence;
} // namespace dom
namespace webgpu {
class BindGroup;
class CommandEncoder;
class ProgrammablePassEncoder : public nsISupports, public ObjectBase {
public:
// Note: here and in derived classes, there is no need for SCRIPT_HOLDER if
// it doesn't hold any JS::Value or JSObject members. That way, we could be
// using a simpler `NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED` macro.
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ProgrammablePassEncoder)
ProgrammablePassEncoder();
protected:
~ProgrammablePassEncoder() = default;
void Cleanup() {}
public:
// TODO: remove all of this, see
// https://bugzilla.mozilla.org/show_bug.cgi?id=1611024
virtual void SetBindGroup(uint32_t aSlot, const BindGroup& aBindGroup,
const dom::Sequence<uint32_t>& aDynamicOffsets) = 0;
};
} // namespace webgpu
} // namespace mozilla
#endif // GPU_ProgrammablePassEncoder_H_

Просмотреть файл

@ -11,22 +11,8 @@
namespace mozilla {
namespace webgpu {
NS_IMPL_CYCLE_COLLECTION_INHERITED(RenderBundleEncoder, RenderEncoderBase,
mParent)
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED_0(RenderBundleEncoder,
RenderEncoderBase)
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(RenderBundleEncoder,
RenderEncoderBase)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
GPU_IMPL_CYCLE_COLLECTION(RenderBundleEncoder, mParent)
GPU_IMPL_JS_WRAP(RenderBundleEncoder)
void RenderBundleEncoder::SetBindGroup(
uint32_t aSlot, const BindGroup& aBindGroup,
const dom::Sequence<uint32_t>& aDynamicOffsets) {
if (mValid) {
MOZ_CRASH("TODO");
}
}
} // namespace webgpu
} // namespace mozilla

Просмотреть файл

@ -7,7 +7,6 @@
#define GPU_RenderBundleEncoder_H_
#include "ObjectModel.h"
#include "RenderEncoderBase.h"
namespace mozilla {
namespace webgpu {
@ -15,22 +14,18 @@ namespace webgpu {
class Device;
class RenderBundle;
class RenderBundleEncoder final : public RenderEncoderBase,
public ChildOf<Device> {
class RenderBundleEncoder final : public ObjectBase, public ChildOf<Device> {
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(RenderBundleEncoder,
RenderEncoderBase)
GPU_DECL_CYCLE_COLLECTION(RenderBundleEncoder)
GPU_DECL_JS_WRAP(RenderBundleEncoder)
RenderBundleEncoder() = delete;
private:
~RenderBundleEncoder() = default;
void Cleanup() {}
public:
void SetBindGroup(uint32_t aSlot, const BindGroup& aBindGroup,
const dom::Sequence<uint32_t>& aDynamicOffsets) override;
};
} // namespace webgpu

Просмотреть файл

@ -1,23 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "RenderEncoderBase.h"
#include "RenderPipeline.h"
namespace mozilla {
namespace webgpu {
NS_IMPL_CYCLE_COLLECTION_INHERITED(RenderEncoderBase, ProgrammablePassEncoder)
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED_0(RenderEncoderBase,
ProgrammablePassEncoder)
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(RenderEncoderBase,
ProgrammablePassEncoder)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
RenderEncoderBase::~RenderEncoderBase() = default;
} // namespace webgpu
} // namespace mozilla

Просмотреть файл

@ -1,35 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef GPU_RenderEncoderBase_H_
#define GPU_RenderEncoderBase_H_
#include "mozilla/dom/TypedArray.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "ProgrammablePassEncoder.h"
namespace mozilla {
namespace webgpu {
class Buffer;
class ComputePipeline;
class RenderEncoderBase : public ProgrammablePassEncoder {
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(
RenderEncoderBase, ProgrammablePassEncoder)
RenderEncoderBase() = delete;
protected:
virtual ~RenderEncoderBase();
public:
};
} // namespace webgpu
} // namespace mozilla
#endif // GPU_RenderEncoderBase_H_

Просмотреть файл

@ -10,13 +10,7 @@
namespace mozilla {
namespace webgpu {
NS_IMPL_CYCLE_COLLECTION_INHERITED(RenderPassEncoder, RenderEncoderBase,
mParent)
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED_0(RenderPassEncoder,
RenderEncoderBase)
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(RenderPassEncoder,
RenderEncoderBase)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
GPU_IMPL_CYCLE_COLLECTION(RenderPassEncoder, mParent)
GPU_IMPL_JS_WRAP(RenderPassEncoder)
RenderPassEncoder::~RenderPassEncoder() = default;

Просмотреть файл

@ -7,7 +7,6 @@
#define GPU_RenderPassEncoder_H_
#include "ObjectModel.h"
#include "RenderEncoderBase.h"
namespace mozilla {
namespace dom {
@ -24,12 +23,10 @@ namespace webgpu {
class CommandEncoder;
class RenderBundle;
class RenderPassEncoder final : public RenderEncoderBase,
class RenderPassEncoder final : public ObjectBase,
public ChildOf<CommandEncoder> {
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(RenderPassEncoder,
RenderEncoderBase)
GPU_DECL_CYCLE_COLLECTION(RenderPassEncoder)
GPU_DECL_JS_WRAP(RenderPassEncoder)
RenderPassEncoder() = delete;
@ -40,7 +37,7 @@ class RenderPassEncoder final : public RenderEncoderBase,
public:
void SetBindGroup(uint32_t aSlot, const BindGroup& aBindGroup,
const dom::Sequence<uint32_t>& aDynamicOffsets) override;
const dom::Sequence<uint32_t>& aDynamicOffsets);
};
} // namespace webgpu

Просмотреть файл

@ -33,11 +33,9 @@ h_and_cpp = [
'ObjectModel',
'OutOfMemoryError',
'PipelineLayout',
'ProgrammablePassEncoder',
'Queue',
'RenderBundle',
'RenderBundleEncoder',
'RenderEncoderBase',
'RenderPassEncoder',
'RenderPipeline',
'Sampler',

Просмотреть файл

@ -802,9 +802,7 @@ interface GPUCommandEncoder {
};
GPUCommandEncoder includes GPUObjectBase;
[Pref="dom.webgpu.enabled",
Exposed=Window]
interface GPUProgrammablePassEncoder {
interface mixin GPUProgrammablePassEncoder {
void setBindGroup(unsigned long index, GPUBindGroup bindGroup,
optional sequence<unsigned long> dynamicOffsets = []);
@ -812,12 +810,9 @@ interface GPUProgrammablePassEncoder {
//void popDebugGroup();
//void insertDebugMarker(DOMString markerLabel);
};
GPUProgrammablePassEncoder includes GPUObjectBase;
// Render Pass
[Pref="dom.webgpu.enabled",
Exposed=Window]
interface GPURenderEncoderBase : GPUProgrammablePassEncoder {
interface mixin GPURenderEncoderBase {
//void setPipeline(GPURenderPipeline pipeline);
//void setIndexBuffer(GPUBuffer buffer, u64 offset);
@ -835,7 +830,7 @@ interface GPURenderEncoderBase : GPUProgrammablePassEncoder {
[Pref="dom.webgpu.enabled",
Exposed=Window]
interface GPURenderPassEncoder : GPURenderEncoderBase {
interface GPURenderPassEncoder {
//void setViewport(float x, float y,
// float width, float height,
// float minDepth, float maxDepth);
@ -848,6 +843,9 @@ interface GPURenderPassEncoder : GPURenderEncoderBase {
//void executeBundles(sequence<GPURenderBundle> bundles);
//void endPass();
};
GPURenderPassEncoder includes GPUObjectBase;
GPURenderPassEncoder includes GPUProgrammablePassEncoder;
GPURenderPassEncoder includes GPURenderEncoderBase;
// Compute Pass
dictionary GPUComputePassDescriptor : GPUObjectDescriptorBase {
@ -855,7 +853,7 @@ dictionary GPUComputePassDescriptor : GPUObjectDescriptorBase {
[Pref="dom.webgpu.enabled",
Exposed=Window]
interface GPUComputePassEncoder : GPUProgrammablePassEncoder {
interface GPUComputePassEncoder {
void setPipeline(GPUComputePipeline pipeline);
void dispatch(u32 x, optional u32 y = 1, optional u32 z = 1);
//void dispatchIndirect(GPUBuffer indirectBuffer, u64 indirectOffset);
@ -863,6 +861,8 @@ interface GPUComputePassEncoder : GPUProgrammablePassEncoder {
[Throws]
void endPass();
};
GPUComputePassEncoder includes GPUObjectBase;
GPUComputePassEncoder includes GPUProgrammablePassEncoder;
// Command Buffer
dictionary GPUCommandBufferDescriptor : GPUObjectDescriptorBase {
@ -883,9 +883,11 @@ dictionary GPURenderBundleEncoderDescriptor : GPUObjectDescriptorBase {
// Render Bundle
[Pref="dom.webgpu.enabled",
Exposed=Window]
interface GPURenderBundleEncoder : GPURenderEncoderBase {
interface GPURenderBundleEncoder {
//GPURenderBundle finish(optional GPURenderBundleDescriptor descriptor = {});
};
GPURenderBundleEncoder includes GPUObjectBase;
GPURenderBundleEncoder includes GPURenderEncoderBase;
dictionary GPURenderBundleDescriptor : GPUObjectDescriptorBase {
};