2018-06-13 20:43:48 +03:00
|
|
|
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* 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/.
|
|
|
|
*
|
|
|
|
* The origin of this IDL file is
|
2019-10-02 19:46:03 +03:00
|
|
|
* https://gpuweb.github.io/gpuweb/
|
2018-06-13 20:43:48 +03:00
|
|
|
*/
|
|
|
|
|
2020-07-21 00:07:03 +03:00
|
|
|
|
|
|
|
|
|
|
|
typedef [EnforceRange] unsigned long GPUBufferDynamicOffset;
|
|
|
|
typedef [EnforceRange] unsigned long long GPUFenceValue;
|
|
|
|
typedef [EnforceRange] unsigned long GPUStencilValue;
|
|
|
|
typedef [EnforceRange] unsigned long GPUSampleMask;
|
|
|
|
typedef [EnforceRange] long GPUDepthBias;
|
|
|
|
|
|
|
|
typedef [EnforceRange] unsigned long long GPUSize64;
|
|
|
|
typedef [EnforceRange] unsigned long GPUIntegerCoordinate;
|
|
|
|
typedef [EnforceRange] unsigned long GPUIndex32;
|
|
|
|
typedef [EnforceRange] unsigned long GPUSize32;
|
|
|
|
typedef [EnforceRange] long GPUSignedOffset32;
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
dictionary GPUColorDict {
|
|
|
|
required double r;
|
|
|
|
required double g;
|
|
|
|
required double b;
|
|
|
|
required double a;
|
|
|
|
};
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
dictionary GPUOrigin2DDict {
|
2020-07-21 00:07:03 +03:00
|
|
|
GPUIntegerCoordinate x = 0;
|
|
|
|
GPUIntegerCoordinate y = 0;
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
dictionary GPUOrigin3DDict {
|
2020-07-21 00:07:03 +03:00
|
|
|
GPUIntegerCoordinate x = 0;
|
|
|
|
GPUIntegerCoordinate y = 0;
|
|
|
|
GPUIntegerCoordinate z = 0;
|
2019-10-02 04:42:07 +03:00
|
|
|
};
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
dictionary GPUExtent3DDict {
|
2020-07-21 00:07:03 +03:00
|
|
|
required GPUIntegerCoordinate width;
|
|
|
|
required GPUIntegerCoordinate height;
|
|
|
|
required GPUIntegerCoordinate depth;
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
typedef (sequence<double> or GPUColorDict) GPUColor;
|
2020-07-21 00:07:03 +03:00
|
|
|
typedef (sequence<GPUIntegerCoordinate> or GPUOrigin2DDict) GPUOrigin2D;
|
|
|
|
typedef (sequence<GPUIntegerCoordinate> or GPUOrigin3DDict) GPUOrigin3D;
|
|
|
|
typedef (sequence<GPUIntegerCoordinate> or GPUExtent3DDict) GPUExtent3D;
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
interface mixin GPUObjectBase {
|
|
|
|
attribute DOMString? label;
|
|
|
|
};
|
|
|
|
|
|
|
|
dictionary GPUObjectDescriptorBase {
|
|
|
|
DOMString? label;
|
|
|
|
};
|
2019-10-02 04:42:07 +03:00
|
|
|
|
|
|
|
// ****************************************************************************
|
2019-10-02 19:46:03 +03:00
|
|
|
// INITIALIZATION
|
2019-10-02 04:42:07 +03:00
|
|
|
// ****************************************************************************
|
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
[
|
2019-12-12 06:09:30 +03:00
|
|
|
Pref="dom.webgpu.enabled",
|
2019-12-10 20:07:18 +03:00
|
|
|
Exposed=Window
|
2019-10-02 19:46:03 +03:00
|
|
|
]
|
|
|
|
interface GPU {
|
2019-11-14 07:59:56 +03:00
|
|
|
// May reject with DOMException
|
|
|
|
[NewObject]
|
|
|
|
Promise<GPUAdapter> requestAdapter(optional GPURequestAdapterOptions options = {});
|
2019-10-02 19:46:03 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
// Add a "webgpu" member to Navigator/Worker that contains the global instance of a "WebGPU"
|
|
|
|
interface mixin GPUProvider {
|
2019-12-12 06:09:30 +03:00
|
|
|
[SameObject, Replaceable, Pref="dom.webgpu.enabled", Exposed=Window] readonly attribute GPU gpu;
|
2019-10-02 19:46:03 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
enum GPUPowerPreference {
|
|
|
|
"low-power",
|
|
|
|
"high-performance"
|
|
|
|
};
|
|
|
|
|
|
|
|
dictionary GPURequestAdapterOptions {
|
|
|
|
GPUPowerPreference powerPreference;
|
|
|
|
};
|
|
|
|
|
2019-12-12 06:09:30 +03:00
|
|
|
[Pref="dom.webgpu.enabled",
|
2019-09-27 18:26:14 +03:00
|
|
|
Exposed=Window]
|
2019-10-02 19:46:03 +03:00
|
|
|
interface GPUAdapter {
|
|
|
|
readonly attribute DOMString name;
|
|
|
|
//GPUExtensions getExtensions();
|
|
|
|
//readonly attribute GPULimits limits; Don't expose higher limits for now.
|
|
|
|
|
2019-11-14 07:59:56 +03:00
|
|
|
// May reject with DOMException
|
|
|
|
[NewObject]
|
|
|
|
Promise<GPUDevice> requestDevice(optional GPUDeviceDescriptor descriptor = {});
|
2019-10-02 19:46:03 +03:00
|
|
|
};
|
|
|
|
GPUAdapter includes GPUObjectBase;
|
|
|
|
|
|
|
|
dictionary GPUExtensions {
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
dictionary GPULimits {
|
2020-07-21 00:07:03 +03:00
|
|
|
GPUSize32 maxBindGroups = 4;
|
|
|
|
GPUSize32 maxDynamicUniformBuffersPerPipelineLayout = 8;
|
|
|
|
GPUSize32 maxDynamicStorageBuffersPerPipelineLayout = 4;
|
|
|
|
GPUSize32 maxSampledTexturesPerShaderStage = 16;
|
|
|
|
GPUSize32 maxSamplersPerShaderStage = 16;
|
|
|
|
GPUSize32 maxStorageBuffersPerShaderStage = 4;
|
|
|
|
GPUSize32 maxStorageTexturesPerShaderStage = 4;
|
|
|
|
GPUSize32 maxUniformBuffersPerShaderStage = 12;
|
|
|
|
GPUSize32 maxUniformBufferBindingSize = 16384;
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
// Device
|
2019-12-12 06:09:30 +03:00
|
|
|
[Pref="dom.webgpu.enabled",
|
2019-09-27 18:26:14 +03:00
|
|
|
Exposed=Window]
|
2019-10-02 19:46:03 +03:00
|
|
|
interface GPUDevice {
|
|
|
|
//GPUExtensions getExtensions();
|
|
|
|
//GPULimits getLimits();
|
|
|
|
//readonly attribute GPUAdapter adapter;
|
|
|
|
|
2020-01-22 10:31:51 +03:00
|
|
|
[SameObject] readonly attribute GPUQueue defaultQueue;
|
|
|
|
|
2020-10-19 19:28:27 +03:00
|
|
|
[NewObject, Throws]
|
2020-10-19 20:19:12 +03:00
|
|
|
GPUBuffer createBuffer(GPUBufferDescriptor descriptor);
|
2020-02-24 23:12:16 +03:00
|
|
|
[NewObject]
|
|
|
|
GPUTexture createTexture(GPUTextureDescriptor descriptor);
|
|
|
|
[NewObject]
|
|
|
|
GPUSampler createSampler(optional GPUSamplerDescriptor descriptor = {});
|
2019-10-02 19:46:03 +03:00
|
|
|
|
2020-01-24 19:27:09 +03:00
|
|
|
GPUBindGroupLayout createBindGroupLayout(GPUBindGroupLayoutDescriptor descriptor);
|
|
|
|
GPUPipelineLayout createPipelineLayout(GPUPipelineLayoutDescriptor descriptor);
|
|
|
|
GPUBindGroup createBindGroup(GPUBindGroupDescriptor descriptor);
|
2019-10-02 19:46:03 +03:00
|
|
|
|
2020-01-24 19:27:09 +03:00
|
|
|
GPUShaderModule createShaderModule(GPUShaderModuleDescriptor descriptor);
|
|
|
|
GPUComputePipeline createComputePipeline(GPUComputePipelineDescriptor descriptor);
|
2020-03-03 19:37:02 +03:00
|
|
|
GPURenderPipeline createRenderPipeline(GPURenderPipelineDescriptor descriptor);
|
2019-10-02 19:46:03 +03:00
|
|
|
|
2020-01-22 10:31:51 +03:00
|
|
|
[NewObject]
|
|
|
|
GPUCommandEncoder createCommandEncoder(optional GPUCommandEncoderDescriptor descriptor = {});
|
2019-10-02 19:46:03 +03:00
|
|
|
//GPURenderBundleEncoder createRenderBundleEncoder(GPURenderBundleEncoderDescriptor descriptor);
|
2019-10-02 04:42:07 +03:00
|
|
|
};
|
2019-10-02 19:46:03 +03:00
|
|
|
GPUDevice includes GPUObjectBase;
|
2019-10-02 04:42:07 +03:00
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
dictionary GPUDeviceDescriptor {
|
|
|
|
GPUExtensions extensions;
|
|
|
|
GPULimits limits;
|
|
|
|
|
|
|
|
// TODO are other things configurable like queues?
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
|
|
|
|
// ****************************************************************************
|
|
|
|
// ERROR HANDLING
|
|
|
|
// ****************************************************************************
|
|
|
|
|
2019-12-12 06:09:30 +03:00
|
|
|
[Pref="dom.webgpu.enabled",
|
2019-09-27 18:26:14 +03:00
|
|
|
Exposed=Window]
|
2019-10-02 19:46:03 +03:00
|
|
|
interface GPUDeviceLostInfo {
|
|
|
|
readonly attribute DOMString message;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum GPUErrorFilter {
|
|
|
|
"none",
|
|
|
|
"out-of-memory",
|
|
|
|
"validation"
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-12-12 06:09:30 +03:00
|
|
|
[Pref="dom.webgpu.enabled",
|
2019-09-27 18:26:14 +03:00
|
|
|
Exposed=Window]
|
2019-10-02 19:46:03 +03:00
|
|
|
interface GPUOutOfMemoryError {
|
|
|
|
//constructor();
|
2019-10-02 04:42:07 +03:00
|
|
|
};
|
|
|
|
|
2019-12-12 06:09:30 +03:00
|
|
|
[Pref="dom.webgpu.enabled",
|
2019-10-02 06:04:25 +03:00
|
|
|
Exposed=Window]
|
2019-10-02 19:46:03 +03:00
|
|
|
interface GPUValidationError {
|
2020-12-18 23:07:47 +03:00
|
|
|
constructor(DOMString message);
|
|
|
|
readonly attribute DOMString message;
|
2019-10-02 04:42:07 +03:00
|
|
|
};
|
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
typedef (GPUOutOfMemoryError or GPUValidationError) GPUError;
|
|
|
|
|
|
|
|
partial interface GPUDevice {
|
|
|
|
//readonly attribute Promise<GPUDeviceLostInfo> lost;
|
|
|
|
//void pushErrorScope(GPUErrorFilter filter);
|
|
|
|
//Promise<GPUError?> popErrorScope();
|
2020-11-20 15:57:45 +03:00
|
|
|
[Exposed=Window]
|
|
|
|
attribute EventHandler onuncapturederror;
|
2019-10-02 19:46:03 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
// ****************************************************************************
|
|
|
|
// SHADER RESOURCES (buffer, textures, texture views, samples)
|
|
|
|
// ****************************************************************************
|
|
|
|
|
|
|
|
// Buffer
|
2020-07-21 00:07:03 +03:00
|
|
|
typedef unsigned long GPUBufferUsageFlags;
|
2019-12-12 06:09:30 +03:00
|
|
|
[Pref="dom.webgpu.enabled",
|
2019-10-02 06:04:25 +03:00
|
|
|
Exposed=Window]
|
2019-10-02 19:46:03 +03:00
|
|
|
interface GPUBufferUsage {
|
2020-07-21 00:07:03 +03:00
|
|
|
const GPUBufferUsageFlags MAP_READ = 0x0001;
|
|
|
|
const GPUBufferUsageFlags MAP_WRITE = 0x0002;
|
|
|
|
const GPUBufferUsageFlags COPY_SRC = 0x0004;
|
|
|
|
const GPUBufferUsageFlags COPY_DST = 0x0008;
|
|
|
|
const GPUBufferUsageFlags INDEX = 0x0010;
|
|
|
|
const GPUBufferUsageFlags VERTEX = 0x0020;
|
|
|
|
const GPUBufferUsageFlags UNIFORM = 0x0040;
|
|
|
|
const GPUBufferUsageFlags STORAGE = 0x0080;
|
|
|
|
const GPUBufferUsageFlags INDIRECT = 0x0100;
|
|
|
|
const GPUBufferUsageFlags QUERY_RESOLVE = 0x0200;
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2020-11-07 05:43:09 +03:00
|
|
|
dictionary GPUBufferDescriptor : GPUObjectDescriptorBase {
|
2020-07-21 00:07:03 +03:00
|
|
|
required GPUSize64 size;
|
2019-10-02 19:46:03 +03:00
|
|
|
required GPUBufferUsageFlags usage;
|
2020-10-19 20:19:12 +03:00
|
|
|
boolean mappedAtCreation = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef unsigned long GPUMapModeFlags;
|
|
|
|
|
|
|
|
[Pref="dom.webgpu.enabled",
|
|
|
|
Exposed=Window]
|
|
|
|
interface GPUMapMode
|
|
|
|
{
|
|
|
|
const GPUMapModeFlags READ = 0x0001;
|
|
|
|
const GPUMapModeFlags WRITE = 0x0002;
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-12-12 06:09:30 +03:00
|
|
|
[Pref="dom.webgpu.enabled",
|
2019-09-27 18:26:14 +03:00
|
|
|
Exposed=Window]
|
2019-10-02 19:46:03 +03:00
|
|
|
interface GPUBuffer {
|
2019-12-10 20:07:18 +03:00
|
|
|
[NewObject]
|
2020-10-19 20:19:12 +03:00
|
|
|
Promise<void> mapAsync(GPUMapModeFlags mode, optional GPUSize64 offset = 0, optional GPUSize64 size);
|
|
|
|
[NewObject, Throws]
|
|
|
|
ArrayBuffer getMappedRange(optional GPUSize64 offset = 0, optional GPUSize64 size);
|
2019-12-10 20:07:18 +03:00
|
|
|
[Throws]
|
|
|
|
void unmap();
|
2019-10-02 19:46:03 +03:00
|
|
|
|
2020-04-16 22:28:22 +03:00
|
|
|
void destroy();
|
2019-10-02 19:46:03 +03:00
|
|
|
};
|
|
|
|
GPUBuffer includes GPUObjectBase;
|
|
|
|
|
|
|
|
typedef sequence<any> GPUMappedBuffer;
|
|
|
|
|
|
|
|
// Texture
|
|
|
|
enum GPUTextureDimension {
|
|
|
|
"1d",
|
|
|
|
"2d",
|
|
|
|
"3d",
|
|
|
|
};
|
|
|
|
|
|
|
|
enum GPUTextureFormat {
|
|
|
|
// 8-bit formats
|
|
|
|
"r8unorm",
|
|
|
|
"r8snorm",
|
|
|
|
"r8uint",
|
|
|
|
"r8sint",
|
|
|
|
|
|
|
|
// 16-bit formats
|
|
|
|
"r16uint",
|
|
|
|
"r16sint",
|
|
|
|
"r16float",
|
|
|
|
"rg8unorm",
|
|
|
|
"rg8snorm",
|
|
|
|
"rg8uint",
|
|
|
|
"rg8sint",
|
|
|
|
|
|
|
|
// 32-bit formats
|
|
|
|
"r32uint",
|
|
|
|
"r32sint",
|
|
|
|
"r32float",
|
|
|
|
"rg16uint",
|
|
|
|
"rg16sint",
|
|
|
|
"rg16float",
|
|
|
|
"rgba8unorm",
|
|
|
|
"rgba8unorm-srgb",
|
|
|
|
"rgba8snorm",
|
|
|
|
"rgba8uint",
|
|
|
|
"rgba8sint",
|
|
|
|
"bgra8unorm",
|
|
|
|
"bgra8unorm-srgb",
|
|
|
|
// Packed 32-bit formats
|
|
|
|
"rgb10a2unorm",
|
|
|
|
"rg11b10float",
|
|
|
|
|
|
|
|
// 64-bit formats
|
|
|
|
"rg32uint",
|
|
|
|
"rg32sint",
|
|
|
|
"rg32float",
|
|
|
|
"rgba16uint",
|
|
|
|
"rgba16sint",
|
|
|
|
"rgba16float",
|
|
|
|
|
|
|
|
// 128-bit formats
|
|
|
|
"rgba32uint",
|
|
|
|
"rgba32sint",
|
|
|
|
"rgba32float",
|
|
|
|
|
|
|
|
// Depth and stencil formats
|
|
|
|
"depth32float",
|
|
|
|
"depth24plus",
|
|
|
|
"depth24plus-stencil8"
|
|
|
|
};
|
|
|
|
|
2020-07-21 00:07:03 +03:00
|
|
|
typedef unsigned long GPUTextureUsageFlags;
|
2019-12-12 06:09:30 +03:00
|
|
|
[Pref="dom.webgpu.enabled",
|
2019-10-02 19:46:03 +03:00
|
|
|
Exposed=Window]
|
|
|
|
interface GPUTextureUsage {
|
2020-07-21 00:07:03 +03:00
|
|
|
const GPUTextureUsageFlags COPY_SRC = 0x01;
|
|
|
|
const GPUTextureUsageFlags COPY_DST = 0x02;
|
|
|
|
const GPUTextureUsageFlags SAMPLED = 0x04;
|
|
|
|
const GPUTextureUsageFlags STORAGE = 0x08;
|
|
|
|
const GPUTextureUsageFlags OUTPUT_ATTACHMENT = 0x10;
|
2019-10-02 19:46:03 +03:00
|
|
|
};
|
|
|
|
|
2020-11-07 05:43:09 +03:00
|
|
|
dictionary GPUTextureDescriptor : GPUObjectDescriptorBase {
|
2019-10-02 19:46:03 +03:00
|
|
|
required GPUExtent3D size;
|
2020-07-21 00:07:03 +03:00
|
|
|
GPUIntegerCoordinate mipLevelCount = 1;
|
|
|
|
GPUSize32 sampleCount = 1;
|
2019-10-02 19:46:03 +03:00
|
|
|
GPUTextureDimension dimension = "2d";
|
|
|
|
required GPUTextureFormat format;
|
|
|
|
required GPUTextureUsageFlags usage;
|
|
|
|
};
|
|
|
|
|
2019-12-12 06:09:30 +03:00
|
|
|
[Pref="dom.webgpu.enabled",
|
2019-10-02 19:46:03 +03:00
|
|
|
Exposed=Window]
|
|
|
|
interface GPUTexture {
|
2020-02-24 23:12:16 +03:00
|
|
|
[NewObject]
|
|
|
|
GPUTextureView createView(optional GPUTextureViewDescriptor descriptor = {});
|
2019-10-02 19:46:03 +03:00
|
|
|
|
2020-04-16 22:28:22 +03:00
|
|
|
void destroy();
|
2019-10-02 19:46:03 +03:00
|
|
|
};
|
|
|
|
GPUTexture includes GPUObjectBase;
|
|
|
|
|
|
|
|
// Texture view
|
|
|
|
enum GPUTextureViewDimension {
|
|
|
|
"1d",
|
|
|
|
"2d",
|
|
|
|
"2d-array",
|
|
|
|
"cube",
|
|
|
|
"cube-array",
|
|
|
|
"3d"
|
|
|
|
};
|
|
|
|
|
|
|
|
enum GPUTextureAspect {
|
|
|
|
"all",
|
|
|
|
"stencil-only",
|
|
|
|
"depth-only"
|
|
|
|
};
|
|
|
|
|
|
|
|
dictionary GPUTextureViewDescriptor : GPUObjectDescriptorBase {
|
2020-02-24 23:12:16 +03:00
|
|
|
GPUTextureFormat format;
|
|
|
|
GPUTextureViewDimension dimension;
|
|
|
|
GPUTextureAspect aspect = "all";
|
2020-07-21 00:07:03 +03:00
|
|
|
GPUIntegerCoordinate baseMipLevel = 0;
|
2020-07-29 01:26:21 +03:00
|
|
|
GPUIntegerCoordinate mipLevelCount;
|
2020-07-21 00:07:03 +03:00
|
|
|
GPUIntegerCoordinate baseArrayLayer = 0;
|
2020-07-29 01:26:21 +03:00
|
|
|
GPUIntegerCoordinate arrayLayerCount;
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-12-12 06:09:30 +03:00
|
|
|
[Pref="dom.webgpu.enabled",
|
2019-10-02 06:04:25 +03:00
|
|
|
Exposed=Window]
|
2019-10-02 19:46:03 +03:00
|
|
|
interface GPUTextureView {
|
|
|
|
};
|
|
|
|
GPUTextureView includes GPUObjectBase;
|
|
|
|
|
|
|
|
// Sampler
|
|
|
|
enum GPUAddressMode {
|
|
|
|
"clamp-to-edge",
|
|
|
|
"repeat",
|
|
|
|
"mirror-repeat"
|
2019-10-02 04:42:07 +03:00
|
|
|
};
|
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
enum GPUFilterMode {
|
|
|
|
"nearest",
|
|
|
|
"linear",
|
|
|
|
};
|
|
|
|
|
|
|
|
enum GPUCompareFunction {
|
|
|
|
"never",
|
|
|
|
"less",
|
|
|
|
"equal",
|
|
|
|
"less-equal",
|
|
|
|
"greater",
|
|
|
|
"not-equal",
|
|
|
|
"greater-equal",
|
|
|
|
"always"
|
|
|
|
};
|
|
|
|
|
|
|
|
dictionary GPUSamplerDescriptor : GPUObjectDescriptorBase {
|
|
|
|
GPUAddressMode addressModeU = "clamp-to-edge";
|
|
|
|
GPUAddressMode addressModeV = "clamp-to-edge";
|
|
|
|
GPUAddressMode addressModeW = "clamp-to-edge";
|
|
|
|
GPUFilterMode magFilter = "nearest";
|
|
|
|
GPUFilterMode minFilter = "nearest";
|
|
|
|
GPUFilterMode mipmapFilter = "nearest";
|
|
|
|
float lodMinClamp = 0;
|
|
|
|
float lodMaxClamp = 1000.0; //TODO?
|
2020-03-17 00:32:37 +03:00
|
|
|
GPUCompareFunction compare;
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-12-12 06:09:30 +03:00
|
|
|
[Pref="dom.webgpu.enabled",
|
2019-09-27 18:26:14 +03:00
|
|
|
Exposed=Window]
|
2019-10-02 19:46:03 +03:00
|
|
|
interface GPUSampler {
|
|
|
|
};
|
|
|
|
GPUSampler includes GPUObjectBase;
|
|
|
|
|
|
|
|
enum GPUTextureComponentType {
|
|
|
|
"float",
|
|
|
|
"sint",
|
2020-11-13 17:15:49 +03:00
|
|
|
"uint",
|
|
|
|
"depth-comparison"
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
// ****************************************************************************
|
|
|
|
// BINDING MODEL (bindgroup layout, bindgroup)
|
|
|
|
// ****************************************************************************
|
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
// PipelineLayout
|
|
|
|
dictionary GPUPipelineLayoutDescriptor : GPUObjectDescriptorBase {
|
|
|
|
required sequence<GPUBindGroupLayout> bindGroupLayouts;
|
|
|
|
};
|
|
|
|
|
2019-12-12 06:09:30 +03:00
|
|
|
[Pref="dom.webgpu.enabled",
|
2019-10-02 19:46:03 +03:00
|
|
|
Exposed=Window]
|
|
|
|
interface GPUPipelineLayout {
|
|
|
|
};
|
|
|
|
GPUPipelineLayout includes GPUObjectBase;
|
|
|
|
|
2018-06-13 20:43:48 +03:00
|
|
|
// BindGroupLayout
|
2020-07-21 00:07:03 +03:00
|
|
|
typedef unsigned long GPUShaderStageFlags;
|
2019-12-12 06:09:30 +03:00
|
|
|
[Pref="dom.webgpu.enabled",
|
2019-09-27 18:26:14 +03:00
|
|
|
Exposed=Window]
|
2019-10-02 19:46:03 +03:00
|
|
|
interface GPUShaderStage {
|
2020-07-21 00:07:03 +03:00
|
|
|
const GPUShaderStageFlags VERTEX = 1;
|
|
|
|
const GPUShaderStageFlags FRAGMENT = 2;
|
|
|
|
const GPUShaderStageFlags COMPUTE = 4;
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
enum GPUBindingType {
|
|
|
|
"uniform-buffer",
|
|
|
|
"storage-buffer",
|
|
|
|
"readonly-storage-buffer",
|
|
|
|
"sampler",
|
2020-03-17 00:32:37 +03:00
|
|
|
"comparison-sampler",
|
2019-10-02 19:46:03 +03:00
|
|
|
"sampled-texture",
|
2020-03-17 00:32:37 +03:00
|
|
|
"readonly-storage-texture",
|
|
|
|
"writeonly-storage-texture",
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2020-03-17 00:32:37 +03:00
|
|
|
dictionary GPUBindGroupLayoutEntry {
|
2020-07-21 00:07:03 +03:00
|
|
|
required GPUIndex32 binding;
|
2019-10-02 19:46:03 +03:00
|
|
|
required GPUShaderStageFlags visibility;
|
|
|
|
required GPUBindingType type;
|
2020-11-07 05:43:09 +03:00
|
|
|
GPUTextureViewDimension viewDimension;
|
|
|
|
GPUTextureComponentType textureComponentType;
|
2019-10-02 19:46:03 +03:00
|
|
|
boolean multisampled = false;
|
2020-03-17 00:32:37 +03:00
|
|
|
boolean hasDynamicOffset = false;
|
|
|
|
GPUTextureFormat storageTextureFormat;
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
dictionary GPUBindGroupLayoutDescriptor : GPUObjectDescriptorBase {
|
2020-03-17 00:32:37 +03:00
|
|
|
required sequence<GPUBindGroupLayoutEntry> entries;
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-12-12 06:09:30 +03:00
|
|
|
[Pref="dom.webgpu.enabled",
|
2019-09-27 18:26:14 +03:00
|
|
|
Exposed=Window]
|
2019-10-02 19:46:03 +03:00
|
|
|
interface GPUBindGroupLayout {
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
2019-10-02 19:46:03 +03:00
|
|
|
GPUBindGroupLayout includes GPUObjectBase;
|
2018-06-13 20:43:48 +03:00
|
|
|
|
|
|
|
// BindGroup
|
2019-10-02 19:46:03 +03:00
|
|
|
dictionary GPUBufferBinding {
|
|
|
|
required GPUBuffer buffer;
|
2020-07-21 00:07:03 +03:00
|
|
|
GPUSize64 offset = 0;
|
|
|
|
GPUSize64 size;
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
typedef (GPUSampler or GPUTextureView or GPUBufferBinding) GPUBindingResource;
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2020-03-17 00:32:37 +03:00
|
|
|
dictionary GPUBindGroupEntry {
|
2020-07-21 00:07:03 +03:00
|
|
|
required GPUIndex32 binding;
|
2019-10-02 19:46:03 +03:00
|
|
|
required GPUBindingResource resource;
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
dictionary GPUBindGroupDescriptor : GPUObjectDescriptorBase {
|
|
|
|
required GPUBindGroupLayout layout;
|
2020-03-17 00:32:37 +03:00
|
|
|
required sequence<GPUBindGroupEntry> entries;
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-12-12 06:09:30 +03:00
|
|
|
[Pref="dom.webgpu.enabled",
|
2019-09-27 18:26:14 +03:00
|
|
|
Exposed=Window]
|
2019-10-02 19:46:03 +03:00
|
|
|
interface GPUBindGroup {
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
2019-10-02 19:46:03 +03:00
|
|
|
GPUBindGroup includes GPUObjectBase;
|
2018-06-13 20:43:48 +03:00
|
|
|
|
|
|
|
// ****************************************************************************
|
|
|
|
// PIPELINE CREATION (blend state, DS state, ..., pipelines)
|
|
|
|
// ****************************************************************************
|
|
|
|
|
|
|
|
// BlendState
|
2019-10-02 19:46:03 +03:00
|
|
|
enum GPUBlendFactor {
|
|
|
|
"zero",
|
|
|
|
"one",
|
|
|
|
"src-color",
|
|
|
|
"one-minus-src-color",
|
|
|
|
"src-alpha",
|
|
|
|
"one-minus-src-alpha",
|
|
|
|
"dst-color",
|
|
|
|
"one-minus-dst-color",
|
|
|
|
"dst-alpha",
|
|
|
|
"one-minus-dst-alpha",
|
|
|
|
"src-alpha-saturated",
|
|
|
|
"blend-color",
|
|
|
|
"one-minus-blend-color",
|
|
|
|
};
|
|
|
|
|
|
|
|
enum GPUBlendOperation {
|
|
|
|
"add",
|
|
|
|
"subtract",
|
|
|
|
"reverse-subtract",
|
|
|
|
"min",
|
|
|
|
"max"
|
|
|
|
};
|
|
|
|
|
|
|
|
dictionary GPUBlendDescriptor {
|
|
|
|
GPUBlendFactor srcFactor = "one";
|
|
|
|
GPUBlendFactor dstFactor = "zero";
|
|
|
|
GPUBlendOperation operation = "add";
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2020-07-21 00:07:03 +03:00
|
|
|
typedef unsigned long GPUColorWriteFlags;
|
2019-12-12 06:09:30 +03:00
|
|
|
[Pref="dom.webgpu.enabled",
|
2019-09-27 18:26:14 +03:00
|
|
|
Exposed=Window]
|
2019-10-02 19:46:03 +03:00
|
|
|
interface GPUColorWrite {
|
2020-07-21 00:07:03 +03:00
|
|
|
const GPUColorWriteFlags RED = 0x1;
|
|
|
|
const GPUColorWriteFlags GREEN = 0x2;
|
|
|
|
const GPUColorWriteFlags BLUE = 0x4;
|
|
|
|
const GPUColorWriteFlags ALPHA = 0x8;
|
|
|
|
const GPUColorWriteFlags ALL = 0xF;
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
dictionary GPUColorStateDescriptor {
|
|
|
|
required GPUTextureFormat format;
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2020-05-02 18:52:26 +03:00
|
|
|
GPUBlendDescriptor alphaBlend = {};
|
|
|
|
GPUBlendDescriptor colorBlend = {};
|
2019-10-02 19:46:03 +03:00
|
|
|
GPUColorWriteFlags writeMask = 0xF;
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
// DepthStencilState
|
2019-10-02 19:46:03 +03:00
|
|
|
enum GPUStencilOperation {
|
|
|
|
"keep",
|
|
|
|
"zero",
|
|
|
|
"replace",
|
|
|
|
"invert",
|
|
|
|
"increment-clamp",
|
|
|
|
"decrement-clamp",
|
|
|
|
"increment-wrap",
|
|
|
|
"decrement-wrap"
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
dictionary GPUStencilStateFaceDescriptor {
|
|
|
|
GPUCompareFunction compare = "always";
|
|
|
|
GPUStencilOperation failOp = "keep";
|
|
|
|
GPUStencilOperation depthFailOp = "keep";
|
|
|
|
GPUStencilOperation passOp = "keep";
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
dictionary GPUDepthStencilStateDescriptor {
|
|
|
|
required GPUTextureFormat format;
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
boolean depthWriteEnabled = false;
|
|
|
|
GPUCompareFunction depthCompare = "always";
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2020-04-16 22:28:22 +03:00
|
|
|
GPUStencilStateFaceDescriptor stencilFront = {};
|
|
|
|
GPUStencilStateFaceDescriptor stencilBack = {};
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2020-07-21 00:07:03 +03:00
|
|
|
GPUStencilValue stencilReadMask = 0xFFFFFFFF;
|
|
|
|
GPUStencilValue stencilWriteMask = 0xFFFFFFFF;
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
// InputState
|
2019-10-02 19:46:03 +03:00
|
|
|
enum GPUIndexFormat {
|
|
|
|
"uint16",
|
|
|
|
"uint32",
|
|
|
|
};
|
|
|
|
|
|
|
|
enum GPUVertexFormat {
|
|
|
|
"uchar2",
|
|
|
|
"uchar4",
|
|
|
|
"char2",
|
|
|
|
"char4",
|
|
|
|
"uchar2norm",
|
|
|
|
"uchar4norm",
|
|
|
|
"char2norm",
|
|
|
|
"char4norm",
|
|
|
|
"ushort2",
|
|
|
|
"ushort4",
|
|
|
|
"short2",
|
|
|
|
"short4",
|
|
|
|
"ushort2norm",
|
|
|
|
"ushort4norm",
|
|
|
|
"short2norm",
|
|
|
|
"short4norm",
|
|
|
|
"half2",
|
|
|
|
"half4",
|
|
|
|
"float",
|
|
|
|
"float2",
|
|
|
|
"float3",
|
|
|
|
"float4",
|
|
|
|
"uint",
|
|
|
|
"uint2",
|
|
|
|
"uint3",
|
|
|
|
"uint4",
|
|
|
|
"int",
|
|
|
|
"int2",
|
|
|
|
"int3",
|
|
|
|
"int4",
|
|
|
|
};
|
|
|
|
|
|
|
|
enum GPUInputStepMode {
|
|
|
|
"vertex",
|
|
|
|
"instance",
|
|
|
|
};
|
|
|
|
|
|
|
|
dictionary GPUVertexAttributeDescriptor {
|
|
|
|
required GPUVertexFormat format;
|
2020-07-21 00:07:03 +03:00
|
|
|
required GPUSize64 offset;
|
|
|
|
required GPUIndex32 shaderLocation;
|
2019-10-02 19:46:03 +03:00
|
|
|
};
|
|
|
|
|
2020-03-17 00:32:37 +03:00
|
|
|
dictionary GPUVertexBufferLayoutDescriptor {
|
2020-07-21 00:07:03 +03:00
|
|
|
required GPUSize64 arrayStride;
|
2019-10-02 19:46:03 +03:00
|
|
|
GPUInputStepMode stepMode = "vertex";
|
2020-04-13 01:48:09 +03:00
|
|
|
required sequence<GPUVertexAttributeDescriptor> attributes;
|
2019-10-02 19:46:03 +03:00
|
|
|
};
|
|
|
|
|
2020-03-17 00:32:37 +03:00
|
|
|
dictionary GPUVertexStateDescriptor {
|
2019-10-02 19:46:03 +03:00
|
|
|
GPUIndexFormat indexFormat = "uint32";
|
2020-04-07 01:29:18 +03:00
|
|
|
sequence<GPUVertexBufferLayoutDescriptor?> vertexBuffers = [];
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
// ShaderModule
|
|
|
|
typedef (Uint32Array or DOMString) GPUShaderCode;
|
|
|
|
|
|
|
|
dictionary GPUShaderModuleDescriptor : GPUObjectDescriptorBase {
|
|
|
|
required GPUShaderCode code;
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-12-12 06:09:30 +03:00
|
|
|
[Pref="dom.webgpu.enabled",
|
2019-09-27 18:26:14 +03:00
|
|
|
Exposed=Window]
|
2019-10-02 19:46:03 +03:00
|
|
|
interface GPUShaderModule {
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
2019-10-02 19:46:03 +03:00
|
|
|
GPUShaderModule includes GPUObjectBase;
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
// Common stuff for ComputePipeline and RenderPipeline
|
|
|
|
dictionary GPUPipelineDescriptorBase : GPUObjectDescriptorBase {
|
2020-11-13 17:15:49 +03:00
|
|
|
GPUPipelineLayout layout;
|
|
|
|
};
|
|
|
|
|
|
|
|
interface mixin GPUPipelineBase {
|
|
|
|
GPUBindGroupLayout getBindGroupLayout(unsigned long index);
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
dictionary GPUProgrammableStageDescriptor {
|
2020-01-24 19:27:09 +03:00
|
|
|
required GPUShaderModule module;
|
2019-10-02 19:46:03 +03:00
|
|
|
required DOMString entryPoint;
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
// ComputePipeline
|
|
|
|
dictionary GPUComputePipelineDescriptor : GPUPipelineDescriptorBase {
|
|
|
|
required GPUProgrammableStageDescriptor computeStage;
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-12-12 06:09:30 +03:00
|
|
|
[Pref="dom.webgpu.enabled",
|
2019-09-27 18:26:14 +03:00
|
|
|
Exposed=Window]
|
2019-10-02 19:46:03 +03:00
|
|
|
interface GPUComputePipeline {
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
2019-10-02 19:46:03 +03:00
|
|
|
GPUComputePipeline includes GPUObjectBase;
|
2020-11-13 17:15:49 +03:00
|
|
|
GPUComputePipeline includes GPUPipelineBase;
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
// GPURenderPipeline
|
|
|
|
enum GPUPrimitiveTopology {
|
|
|
|
"point-list",
|
|
|
|
"line-list",
|
|
|
|
"line-strip",
|
|
|
|
"triangle-list",
|
|
|
|
"triangle-strip"
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
dictionary GPURasterizationStateDescriptor {
|
|
|
|
GPUFrontFace frontFace = "ccw";
|
|
|
|
GPUCullMode cullMode = "none";
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2020-07-21 00:07:03 +03:00
|
|
|
GPUDepthBias depthBias = 0;
|
2019-10-02 19:46:03 +03:00
|
|
|
float depthBiasSlopeScale = 0;
|
|
|
|
float depthBiasClamp = 0;
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
enum GPUFrontFace {
|
|
|
|
"ccw",
|
|
|
|
"cw"
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
enum GPUCullMode {
|
|
|
|
"none",
|
|
|
|
"front",
|
|
|
|
"back"
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
dictionary GPURenderPipelineDescriptor : GPUPipelineDescriptorBase {
|
|
|
|
required GPUProgrammableStageDescriptor vertexStage;
|
|
|
|
GPUProgrammableStageDescriptor fragmentStage;
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
required GPUPrimitiveTopology primitiveTopology;
|
2020-04-07 01:29:18 +03:00
|
|
|
GPURasterizationStateDescriptor rasterizationState = {};
|
2019-10-02 19:46:03 +03:00
|
|
|
required sequence<GPUColorStateDescriptor> colorStates;
|
|
|
|
GPUDepthStencilStateDescriptor depthStencilState;
|
2020-03-17 00:32:37 +03:00
|
|
|
GPUVertexStateDescriptor vertexState = {};
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2020-07-21 00:07:03 +03:00
|
|
|
GPUSize32 sampleCount = 1;
|
|
|
|
GPUSampleMask sampleMask = 0xFFFFFFFF;
|
2019-10-02 19:46:03 +03:00
|
|
|
boolean alphaToCoverageEnabled = false;
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-12-12 06:09:30 +03:00
|
|
|
[Pref="dom.webgpu.enabled",
|
2019-09-27 18:26:14 +03:00
|
|
|
Exposed=Window]
|
2019-10-02 19:46:03 +03:00
|
|
|
interface GPURenderPipeline {
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
2019-10-02 19:46:03 +03:00
|
|
|
GPURenderPipeline includes GPUObjectBase;
|
2020-11-13 17:15:49 +03:00
|
|
|
GPURenderPipeline includes GPUPipelineBase;
|
2019-10-02 04:42:07 +03:00
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
// ****************************************************************************
|
|
|
|
// COMMAND RECORDING (Command buffer and all relevant structures)
|
|
|
|
// ****************************************************************************
|
|
|
|
|
|
|
|
enum GPULoadOp {
|
|
|
|
"load"
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
enum GPUStoreOp {
|
|
|
|
"store",
|
|
|
|
"clear"
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
dictionary GPURenderPassColorAttachmentDescriptor {
|
|
|
|
required GPUTextureView attachment;
|
|
|
|
GPUTextureView resolveTarget;
|
|
|
|
|
|
|
|
required (GPULoadOp or GPUColor) loadValue;
|
2020-04-07 01:29:18 +03:00
|
|
|
GPUStoreOp storeOp = "store";
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
dictionary GPURenderPassDepthStencilAttachmentDescriptor {
|
|
|
|
required GPUTextureView attachment;
|
|
|
|
|
|
|
|
required (GPULoadOp or float) depthLoadValue;
|
|
|
|
required GPUStoreOp depthStoreOp;
|
|
|
|
|
2020-07-21 00:07:03 +03:00
|
|
|
required (GPULoadOp or GPUStencilValue) stencilLoadValue;
|
2019-10-02 19:46:03 +03:00
|
|
|
required GPUStoreOp stencilStoreOp;
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
dictionary GPURenderPassDescriptor : GPUObjectDescriptorBase {
|
|
|
|
required sequence<GPURenderPassColorAttachmentDescriptor> colorAttachments;
|
|
|
|
GPURenderPassDepthStencilAttachmentDescriptor depthStencilAttachment;
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2020-07-21 00:07:03 +03:00
|
|
|
dictionary GPUTextureDataLayout {
|
|
|
|
GPUSize64 offset = 0;
|
|
|
|
required GPUSize32 bytesPerRow;
|
|
|
|
GPUSize32 rowsPerImage = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
dictionary GPUBufferCopyView : GPUTextureDataLayout {
|
2019-10-02 19:46:03 +03:00
|
|
|
required GPUBuffer buffer;
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
dictionary GPUTextureCopyView {
|
|
|
|
required GPUTexture texture;
|
2020-07-21 00:07:03 +03:00
|
|
|
GPUIntegerCoordinate mipLevel = 0;
|
2019-10-02 19:46:03 +03:00
|
|
|
GPUOrigin3D origin;
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
dictionary GPUImageBitmapCopyView {
|
|
|
|
//required ImageBitmap imageBitmap; //TODO
|
|
|
|
GPUOrigin2D origin;
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
dictionary GPUCommandEncoderDescriptor : GPUObjectDescriptorBase {
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-12-12 06:09:30 +03:00
|
|
|
[Pref="dom.webgpu.enabled",
|
2019-09-27 18:26:14 +03:00
|
|
|
Exposed=Window]
|
2019-10-02 19:46:03 +03:00
|
|
|
interface GPUCommandEncoder {
|
2020-01-22 10:31:51 +03:00
|
|
|
[NewObject]
|
|
|
|
GPUComputePassEncoder beginComputePass(optional GPUComputePassDescriptor descriptor = {});
|
2020-02-19 22:25:30 +03:00
|
|
|
[NewObject]
|
|
|
|
GPURenderPassEncoder beginRenderPass(GPURenderPassDescriptor descriptor);
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
void copyBufferToBuffer(
|
|
|
|
GPUBuffer source,
|
2020-07-21 00:07:03 +03:00
|
|
|
GPUSize64 sourceOffset,
|
2019-10-02 19:46:03 +03:00
|
|
|
GPUBuffer destination,
|
2020-07-21 00:07:03 +03:00
|
|
|
GPUSize64 destinationOffset,
|
|
|
|
GPUSize64 size);
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
void copyBufferToTexture(
|
|
|
|
GPUBufferCopyView source,
|
|
|
|
GPUTextureCopyView destination,
|
|
|
|
GPUExtent3D copySize);
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
void copyTextureToBuffer(
|
|
|
|
GPUTextureCopyView source,
|
|
|
|
GPUBufferCopyView destination,
|
|
|
|
GPUExtent3D copySize);
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
void copyTextureToTexture(
|
|
|
|
GPUTextureCopyView source,
|
|
|
|
GPUTextureCopyView destination,
|
|
|
|
GPUExtent3D copySize);
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2020-04-13 16:59:24 +03:00
|
|
|
/*
|
2019-10-02 19:46:03 +03:00
|
|
|
void copyImageBitmapToTexture(
|
|
|
|
GPUImageBitmapCopyView source,
|
|
|
|
GPUTextureCopyView destination,
|
|
|
|
GPUExtent3D copySize);
|
|
|
|
*/
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
//void pushDebugGroup(DOMString groupLabel);
|
|
|
|
//void popDebugGroup();
|
|
|
|
//void insertDebugMarker(DOMString markerLabel);
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2020-01-22 10:31:51 +03:00
|
|
|
[NewObject]
|
|
|
|
GPUCommandBuffer finish(optional GPUCommandBufferDescriptor descriptor = {});
|
2019-10-02 19:46:03 +03:00
|
|
|
};
|
|
|
|
GPUCommandEncoder includes GPUObjectBase;
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2020-02-11 06:03:47 +03:00
|
|
|
interface mixin GPUProgrammablePassEncoder {
|
2020-07-21 00:07:03 +03:00
|
|
|
void setBindGroup(GPUIndex32 index, GPUBindGroup bindGroup,
|
|
|
|
optional sequence<GPUBufferDynamicOffset> dynamicOffsets = []);
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
//void pushDebugGroup(DOMString groupLabel);
|
|
|
|
//void popDebugGroup();
|
|
|
|
//void insertDebugMarker(DOMString markerLabel);
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
// Render Pass
|
2020-02-11 06:03:47 +03:00
|
|
|
interface mixin GPURenderEncoderBase {
|
2020-02-19 22:25:30 +03:00
|
|
|
void setPipeline(GPURenderPipeline pipeline);
|
2019-10-02 19:46:03 +03:00
|
|
|
|
2020-07-21 00:07:03 +03:00
|
|
|
void setIndexBuffer(GPUBuffer buffer, optional GPUSize64 offset = 0, optional GPUSize64 size = 0);
|
|
|
|
void setVertexBuffer(GPUIndex32 slot, GPUBuffer buffer, optional GPUSize64 offset = 0, optional GPUSize64 size = 0);
|
2019-10-02 19:46:03 +03:00
|
|
|
|
2020-07-21 00:07:03 +03:00
|
|
|
void draw(GPUSize32 vertexCount,
|
|
|
|
optional GPUSize32 instanceCount = 1,
|
|
|
|
optional GPUSize32 firstVertex = 0,
|
|
|
|
optional GPUSize32 firstInstance = 0);
|
|
|
|
void drawIndexed(GPUSize32 indexCount,
|
|
|
|
optional GPUSize32 instanceCount = 1,
|
|
|
|
optional GPUSize32 firstIndex = 0,
|
|
|
|
optional GPUSignedOffset32 baseVertex = 0,
|
|
|
|
optional GPUSize32 firstInstance = 0);
|
2019-10-02 19:46:03 +03:00
|
|
|
|
2020-07-21 16:20:18 +03:00
|
|
|
void drawIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
|
|
|
|
void drawIndexedIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-12-12 06:09:30 +03:00
|
|
|
[Pref="dom.webgpu.enabled",
|
2019-09-27 18:26:14 +03:00
|
|
|
Exposed=Window]
|
2020-02-11 06:03:47 +03:00
|
|
|
interface GPURenderPassEncoder {
|
2019-10-02 19:46:03 +03:00
|
|
|
//void setViewport(float x, float y,
|
|
|
|
// float width, float height,
|
|
|
|
// float minDepth, float maxDepth);
|
|
|
|
|
|
|
|
//void setScissorRect(u32 x, u32 y, u32 width, u32 height);
|
|
|
|
|
|
|
|
//void setBlendColor(GPUColor color);
|
|
|
|
//void setStencilReference(u32 reference);
|
|
|
|
|
|
|
|
//void executeBundles(sequence<GPURenderBundle> bundles);
|
2020-02-19 22:25:30 +03:00
|
|
|
[Throws]
|
|
|
|
void endPass();
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
2020-02-11 06:03:47 +03:00
|
|
|
GPURenderPassEncoder includes GPUObjectBase;
|
|
|
|
GPURenderPassEncoder includes GPUProgrammablePassEncoder;
|
|
|
|
GPURenderPassEncoder includes GPURenderEncoderBase;
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
// Compute Pass
|
|
|
|
dictionary GPUComputePassDescriptor : GPUObjectDescriptorBase {
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-12-12 06:09:30 +03:00
|
|
|
[Pref="dom.webgpu.enabled",
|
2019-09-27 18:26:14 +03:00
|
|
|
Exposed=Window]
|
2020-02-11 06:03:47 +03:00
|
|
|
interface GPUComputePassEncoder {
|
2020-01-24 19:27:09 +03:00
|
|
|
void setPipeline(GPUComputePipeline pipeline);
|
2020-07-21 00:07:03 +03:00
|
|
|
void dispatch(GPUSize32 x, optional GPUSize32 y = 1, optional GPUSize32 z = 1);
|
2020-07-21 16:20:18 +03:00
|
|
|
void dispatchIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2020-01-22 10:31:51 +03:00
|
|
|
[Throws]
|
|
|
|
void endPass();
|
2019-10-02 04:42:07 +03:00
|
|
|
};
|
2020-02-11 06:03:47 +03:00
|
|
|
GPUComputePassEncoder includes GPUObjectBase;
|
|
|
|
GPUComputePassEncoder includes GPUProgrammablePassEncoder;
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
// Command Buffer
|
|
|
|
dictionary GPUCommandBufferDescriptor : GPUObjectDescriptorBase {
|
2019-10-02 04:42:07 +03:00
|
|
|
};
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2019-12-12 06:09:30 +03:00
|
|
|
[Pref="dom.webgpu.enabled",
|
2019-10-02 04:42:07 +03:00
|
|
|
Exposed=Window]
|
2019-10-02 19:46:03 +03:00
|
|
|
interface GPUCommandBuffer {
|
|
|
|
};
|
|
|
|
GPUCommandBuffer includes GPUObjectBase;
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
dictionary GPURenderBundleEncoderDescriptor : GPUObjectDescriptorBase {
|
|
|
|
required sequence<GPUTextureFormat> colorFormats;
|
|
|
|
GPUTextureFormat depthStencilFormat;
|
2020-07-21 00:07:03 +03:00
|
|
|
GPUSize32 sampleCount = 1;
|
2019-10-02 19:46:03 +03:00
|
|
|
};
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
// Render Bundle
|
2019-12-12 06:09:30 +03:00
|
|
|
[Pref="dom.webgpu.enabled",
|
2019-10-02 19:46:03 +03:00
|
|
|
Exposed=Window]
|
2020-02-11 06:03:47 +03:00
|
|
|
interface GPURenderBundleEncoder {
|
2019-10-02 19:46:03 +03:00
|
|
|
//GPURenderBundle finish(optional GPURenderBundleDescriptor descriptor = {});
|
|
|
|
};
|
2020-02-11 06:03:47 +03:00
|
|
|
GPURenderBundleEncoder includes GPUObjectBase;
|
2020-02-19 22:25:30 +03:00
|
|
|
//GPURenderBundleEncoder includes GPURenderEncoderBase;
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
dictionary GPURenderBundleDescriptor : GPUObjectDescriptorBase {
|
|
|
|
};
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2019-12-12 06:09:30 +03:00
|
|
|
[Pref="dom.webgpu.enabled",
|
2019-10-02 19:46:03 +03:00
|
|
|
Exposed=Window]
|
|
|
|
interface GPURenderBundle {
|
|
|
|
};
|
|
|
|
GPURenderBundle includes GPUObjectBase;
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
// ****************************************************************************
|
|
|
|
// OTHER (Fence, Queue SwapChain, Device)
|
|
|
|
// ****************************************************************************
|
2019-10-02 06:04:25 +03:00
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
// Fence
|
|
|
|
dictionary GPUFenceDescriptor : GPUObjectDescriptorBase {
|
2020-07-21 00:07:03 +03:00
|
|
|
GPUFenceValue initialValue = 0;
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-12-12 06:09:30 +03:00
|
|
|
[Pref="dom.webgpu.enabled",
|
2019-10-02 19:46:03 +03:00
|
|
|
Exposed=Window]
|
|
|
|
interface GPUFence {
|
2020-07-21 00:07:03 +03:00
|
|
|
//GPUFenceValue getCompletedValue();
|
|
|
|
//Promise<void> onCompletion(GPUFenceValue completionValue);
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
2019-10-02 19:46:03 +03:00
|
|
|
GPUFence includes GPUObjectBase;
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
// Queue
|
2019-12-12 06:09:30 +03:00
|
|
|
[Pref="dom.webgpu.enabled",
|
2019-10-02 04:42:07 +03:00
|
|
|
Exposed=Window]
|
2019-10-02 19:46:03 +03:00
|
|
|
interface GPUQueue {
|
2020-01-22 10:31:51 +03:00
|
|
|
void submit(sequence<GPUCommandBuffer> buffers);
|
2019-10-02 06:04:25 +03:00
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
//GPUFence createFence(optional GPUFenceDescriptor descriptor = {});
|
2020-07-21 00:07:03 +03:00
|
|
|
//void signal(GPUFence fence, GPUFenceValue signalValue);
|
2020-07-29 01:26:21 +03:00
|
|
|
|
|
|
|
[Throws]
|
|
|
|
void writeBuffer(
|
|
|
|
GPUBuffer buffer,
|
|
|
|
GPUSize64 bufferOffset,
|
|
|
|
[AllowShared] ArrayBuffer data,
|
|
|
|
optional GPUSize64 dataOffset = 0,
|
|
|
|
optional GPUSize64 size);
|
|
|
|
|
|
|
|
[Throws]
|
|
|
|
void writeTexture(
|
|
|
|
GPUTextureCopyView destination,
|
|
|
|
[AllowShared] ArrayBuffer data,
|
|
|
|
GPUTextureDataLayout dataLayout,
|
|
|
|
GPUExtent3D size);
|
2019-10-02 04:42:07 +03:00
|
|
|
};
|
2019-10-02 19:46:03 +03:00
|
|
|
GPUQueue includes GPUObjectBase;
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2019-12-12 06:09:30 +03:00
|
|
|
[Pref="dom.webgpu.enabled",
|
2019-10-02 19:46:03 +03:00
|
|
|
Exposed=Window]
|
|
|
|
interface GPUSwapChain {
|
2020-04-07 01:29:18 +03:00
|
|
|
GPUTexture getCurrentTexture();
|
2019-10-02 19:46:03 +03:00
|
|
|
};
|
|
|
|
GPUSwapChain includes GPUObjectBase;
|
2019-10-02 06:04:25 +03:00
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
dictionary GPUSwapChainDescriptor : GPUObjectDescriptorBase {
|
|
|
|
required GPUDevice device;
|
|
|
|
required GPUTextureFormat format;
|
2020-04-07 01:29:18 +03:00
|
|
|
GPUTextureUsageFlags usage = 0x10; //GPUTextureUsage.OUTPUT_ATTACHMENT
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|
|
|
|
|
2019-12-12 06:09:30 +03:00
|
|
|
[Pref="dom.webgpu.enabled",
|
2019-09-27 18:26:14 +03:00
|
|
|
Exposed=Window]
|
2019-10-02 19:46:03 +03:00
|
|
|
interface GPUCanvasContext {
|
|
|
|
// Calling configureSwapChain a second time invalidates the previous one,
|
|
|
|
// and all of the textures it's produced.
|
2020-04-07 01:29:18 +03:00
|
|
|
[Throws]
|
|
|
|
GPUSwapChain configureSwapChain(GPUSwapChainDescriptor descriptor);
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
//Promise<GPUTextureFormat> getSwapChainPreferredFormat(GPUDevice device);
|
2018-06-13 20:43:48 +03:00
|
|
|
};
|