Skip to content

Commit

Permalink
Add ServiceWorker support (gpuweb#4464)
Browse files Browse the repository at this point in the history
  • Loading branch information
beaufortfrancois authored Jan 25, 2024
1 parent 7cb18d2 commit 584375a
Showing 1 changed file with 46 additions and 44 deletions.
90 changes: 46 additions & 44 deletions spec/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1863,7 +1863,7 @@ See {{GPUAdapter/limits|GPUAdapter.limits}} and {{GPUDevice/limits|GPUDevice.lim
<!-- When adding limits here, add them to the Correspondence Reference as well. -->

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
interface GPUSupportedLimits {
readonly attribute unsigned long maxTextureDimension1D;
readonly attribute unsigned long maxTextureDimension2D;
Expand Down Expand Up @@ -1909,7 +1909,7 @@ the {{GPUFeatureName}} values of the [=features=] supported by an adapter or
device. It must only contain strings from the {{GPUFeatureName}} enum.

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
interface GPUSupportedFeatures {
readonly setlike<DOMString>;
};
Expand Down Expand Up @@ -1943,7 +1943,7 @@ Its [=set entries=] are the string names of the WGSL [=language extensions=]
supported by the implementation (regardless of the adapter or device).

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
interface WGSLLanguageFeatures {
readonly setlike<DOMString>;
};
Expand All @@ -1965,7 +1965,7 @@ For privacy considerations, see [[#privacy-adapter-identifiers]].
</p>

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
interface GPUAdapterInfo {
readonly attribute DOMString vendor;
readonly attribute DOMString architecture;
Expand Down Expand Up @@ -2296,8 +2296,9 @@ them to WGSL values (`bool`, `i32`, `u32`, `f32`, `f16`).

## navigator.gpu ## {#navigator-gpu}

A {{GPU}} object is available in the {{Window}} and {{DedicatedWorkerGlobalScope}} contexts through the {{Navigator}}
and {{WorkerNavigator}} interfaces respectively and is exposed via `navigator.gpu`:
A {{GPU}} object is available in the {{Window}}, {{DedicatedWorkerGlobalScope}},
{{ServiceWorkerGlobalScope}} contexts through the {{Navigator}} and {{WorkerNavigator}} interfaces
respectively and is exposed via `navigator.gpu`:

<script type=idl>
interface mixin NavigatorGPU {
Expand All @@ -2320,7 +2321,7 @@ WorkerNavigator includes NavigatorGPU;
<dfn interface>GPU</dfn> is the entry point to WebGPU.

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
interface GPU {
Promise<GPUAdapter?> requestAdapter(optional GPURequestAdapterOptions options = {});
GPUTextureFormat getPreferredCanvasFormat();
Expand Down Expand Up @@ -2591,7 +2592,7 @@ and describes its capabilities ([=features=] and [=limits=]).
To get a {{GPUAdapter}}, use {{GPU/requestAdapter()}}.

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
interface GPUAdapter {
[SameObject] readonly attribute GPUSupportedFeatures features;
[SameObject] readonly attribute GPUSupportedLimits limits;
Expand Down Expand Up @@ -2885,7 +2886,7 @@ the functionality of that device.
To get a {{GPUDevice}}, use {{GPUAdapter/requestDevice()}}.

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
interface GPUDevice : EventTarget {
[SameObject] readonly attribute GPUSupportedFeatures features;
[SameObject] readonly attribute GPUSupportedLimits limits;
Expand Down Expand Up @@ -3095,7 +3096,7 @@ its mapping.
Buffers may be {{GPUBufferDescriptor/mappedAtCreation}}.

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
interface GPUBuffer {
readonly attribute GPUSize64Out size;
readonly attribute GPUFlagsConstant usage;
Expand Down Expand Up @@ -3307,7 +3308,7 @@ dictionary GPUBufferDescriptor

<script type=idl>
typedef [EnforceRange] unsigned long GPUBufferUsageFlags;
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
namespace GPUBufferUsage {
const GPUFlagsConstant MAP_READ = 0x0001;
const GPUFlagsConstant MAP_WRITE = 0x0002;
Expand Down Expand Up @@ -3547,7 +3548,7 @@ only be unmapped and destroyed on the worker on which it was mapped. Likewise

<script type=idl>
typedef [EnforceRange] unsigned long GPUMapModeFlags;
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
namespace GPUMapMode {
const GPUFlagsConstant READ = 0x0001;
const GPUFlagsConstant WRITE = 0x0002;
Expand Down Expand Up @@ -3886,7 +3887,7 @@ two-dimensional image at a particular `z` value in the texture.
Slices are not separate subresources.

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
interface GPUTexture {
GPUTextureView createView(optional GPUTextureViewDescriptor descriptor = {});

Expand Down Expand Up @@ -4157,7 +4158,7 @@ enum GPUTextureDimension {

<script type=idl>
typedef [EnforceRange] unsigned long GPUTextureUsageFlags;
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
namespace GPUTextureUsage {
const GPUFlagsConstant COPY_SRC = 0x01;
const GPUFlagsConstant COPY_DST = 0x02;
Expand Down Expand Up @@ -4391,7 +4392,7 @@ A {{GPUTextureView}} is a view onto some subset of the [=texture subresources=]
a particular {{GPUTexture}}.

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
interface GPUTextureView {
};
GPUTextureView includes GPUObjectBase;
Expand Down Expand Up @@ -5059,7 +5060,7 @@ External textures use several binding slots: see [=Exceeds the binding slot limi
</div>

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
interface GPUExternalTexture {
};
GPUExternalTexture includes GPUObjectBase;
Expand Down Expand Up @@ -5278,7 +5279,7 @@ be used in a shader to interpret texture resource data.
{{GPUSampler}}s are created via {{GPUDevice/createSampler()}}.

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
interface GPUSampler {
};
GPUSampler includes GPUObjectBase;
Expand Down Expand Up @@ -5556,7 +5557,7 @@ enum GPUCompareFunction {
A {{GPUBindGroupLayout}} defines the interface between a set of resources bound in a {{GPUBindGroup}} and their accessibility in shader stages.

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
interface GPUBindGroupLayout {
};
GPUBindGroupLayout includes GPUObjectBase;
Expand Down Expand Up @@ -5638,7 +5639,7 @@ dictionary GPUBindGroupLayoutEntry {

<script type=idl>
typedef [EnforceRange] unsigned long GPUShaderStageFlags;
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
namespace GPUShaderStage {
const GPUFlagsConstant VERTEX = 0x1;
const GPUFlagsConstant FRAGMENT = 0x2;
Expand Down Expand Up @@ -6044,7 +6045,7 @@ A {{GPUBindGroup}} defines a set of resources to be bound together in a group
and how the resources are used in shader stages.

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
interface GPUBindGroup {
};
GPUBindGroup includes GPUObjectBase;
Expand Down Expand Up @@ -6348,7 +6349,7 @@ The full binding address of a resource can be defined as a trio of:
The components of this address can also be seen as the binding space of a pipeline. A {{GPUBindGroup}} (with the corresponding {{GPUBindGroupLayout}}) covers that space for a fixed bind group index. The contained bindings need to be a superset of the resources used by the shader at this bind group index.

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
interface GPUPipelineLayout {
};
GPUPipelineLayout includes GPUObjectBase;
Expand Down Expand Up @@ -6505,7 +6506,7 @@ if their internal {{GPUPipelineLayout/[[bindGroupLayouts]]}} sequences contain
</h3>

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
interface GPUShaderModule {
Promise<GPUCompilationInfo> getCompilationInfo();
};
Expand Down Expand Up @@ -6712,7 +6713,7 @@ enum GPUCompilationMessageType {
"info",
};

[Exposed=(Window, DedicatedWorker), Serializable, SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), Serializable, SecureContext]
interface GPUCompilationMessage {
readonly attribute DOMString message;
readonly attribute GPUCompilationMessageType type;
Expand All @@ -6722,7 +6723,7 @@ interface GPUCompilationMessage {
readonly attribute unsigned long long length;
};

[Exposed=(Window, DedicatedWorker), Serializable, SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), Serializable, SecureContext]
interface GPUCompilationInfo {
readonly attribute FrozenArray<GPUCompilationMessage> messages;
};
Expand Down Expand Up @@ -6934,7 +6935,7 @@ There are two ways to create pipelines:
<!--TODO(gpuweb/gpuweb#3709): Change `message` to optional, defaulting to `""`. -->

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext, Serializable]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext, Serializable]
interface GPUPipelineError : DOMException {
constructor(optional DOMString message = "", GPUPipelineErrorInit options);
readonly attribute GPUPipelineErrorReason reason;
Expand Down Expand Up @@ -7592,7 +7593,7 @@ Stages of a compute [=pipeline=]:
1. Compute shader

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
interface GPUComputePipeline {
};
GPUComputePipeline includes GPUObjectBase;
Expand Down Expand Up @@ -7789,7 +7790,7 @@ A render [=pipeline=] is comprised of the following <dfn dfn>render stages</dfn>
1. Output merging, controlled by {{GPUFragmentState/targets|GPUFragmentState.targets}}

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
interface GPURenderPipeline {
};
GPURenderPipeline includes GPUObjectBase;
Expand Down Expand Up @@ -8441,7 +8442,7 @@ dictionary GPUBlendState {

<script type=idl>
typedef [EnforceRange] unsigned long GPUColorWriteFlags;
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
namespace GPUColorWrite {
const GPUFlagsConstant RED = 0x1;
const GPUFlagsConstant GREEN = 0x2;
Expand Down Expand Up @@ -9358,7 +9359,7 @@ To reuse rendering commands across multiple submissions, use {{GPURenderBundle}}
</h3>

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
interface GPUCommandBuffer {
};
GPUCommandBuffer includes GPUObjectBase;
Expand Down Expand Up @@ -9466,7 +9467,7 @@ The <dfn dfn>encoder state</dfn> may be one of the following:
</h3>

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
interface GPUCommandEncoder {
GPURenderPassEncoder beginRenderPass(GPURenderPassDescriptor descriptor);
GPUComputePassEncoder beginComputePass(optional GPUComputePassDescriptor descriptor = {});
Expand Down Expand Up @@ -10552,7 +10553,7 @@ It must only be included by interfaces which also include those mixins.
</h3>

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
interface GPUComputePassEncoder {
undefined setPipeline(GPUComputePipeline pipeline);
undefined dispatchWorkgroups(GPUSize32 workgroupCountX, optional GPUSize32 workgroupCountY = 1, optional GPUSize32 workgroupCountZ = 1);
Expand Down Expand Up @@ -10860,7 +10861,7 @@ called the compute pass encoder can no longer be used.
</h3>

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
interface GPURenderPassEncoder {
undefined setViewport(float x, float y,
float width, float height,
Expand Down Expand Up @@ -12392,7 +12393,7 @@ changing.
</h3>

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
interface GPURenderBundle {
};
GPURenderBundle includes GPUObjectBase;
Expand Down Expand Up @@ -12430,7 +12431,7 @@ dictionary GPURenderBundleDescriptor
</script>

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
interface GPURenderBundleEncoder {
GPURenderBundle finish(optional GPURenderBundleDescriptor descriptor = {});
};
Expand Down Expand Up @@ -12593,7 +12594,7 @@ dictionary GPUQueueDescriptor
</h3>

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
interface GPUQueue {
undefined submit(sequence<GPUCommandBuffer> commandBuffers);

Expand Down Expand Up @@ -12966,7 +12967,7 @@ GPUQueue includes GPUObjectBase;
</h3>

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
interface GPUQuerySet {
undefined destroy();

Expand Down Expand Up @@ -13221,7 +13222,7 @@ which allows changing the canvas configuration without replacing the canvas.
## GPUCanvasContext ## {#canvas-context}

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
interface GPUCanvasContext {
readonly attribute (HTMLCanvasElement or OffscreenCanvas) canvas;

Expand Down Expand Up @@ -13539,6 +13540,7 @@ specified points.

- "update the rendering or user interface of that `Document`"
- "update the rendering of that dedicated worker"
- "update the rendering of that service worker"

Run the following steps:

Expand Down Expand Up @@ -13751,7 +13753,7 @@ enum GPUDeviceLostReason {
"destroyed",
};

[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
interface GPUDeviceLostInfo {
readonly attribute GPUDeviceLostReason reason;
readonly attribute DOMString message;
Expand All @@ -13778,7 +13780,7 @@ partial interface GPUDevice {
</h3>

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
interface GPUError {
readonly attribute DOMString message;
};
Expand Down Expand Up @@ -13822,7 +13824,7 @@ JSON, for a debug report).
</dl>

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
interface GPUValidationError
: GPUError {
constructor(DOMString message);
Expand All @@ -13847,7 +13849,7 @@ error, and is expected to fail the same way across all devices assuming the same
</div>

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
interface GPUOutOfMemoryError
: GPUError {
constructor(DOMString message);
Expand All @@ -13872,7 +13874,7 @@ resources is released first.
</div>

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
interface GPUInternalError
: GPUError {
constructor(DOMString message);
Expand Down Expand Up @@ -14179,7 +14181,7 @@ normal operation of an application. Prefer using {{GPUDevice/pushErrorScope()}}
{{GPUDevice/popErrorScope()}} in those cases.

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
[Exposed=(Window, DedicatedWorker, ServiceWorker), SecureContext]
interface GPUUncapturedErrorEvent : Event {
constructor(
DOMString type,
Expand All @@ -14204,7 +14206,7 @@ dictionary GPUUncapturedErrorEventInit : EventInit {

<script type=idl>
partial interface GPUDevice {
[Exposed=(Window, DedicatedWorker)]
[Exposed=(Window, DedicatedWorker, ServiceWorker)]
attribute EventHandler onuncapturederror;
};
</script>
Expand Down

0 comments on commit 584375a

Please sign in to comment.