summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorLeo K <crowlkats@toaxl.com>2021-08-24 13:29:42 +0200
committerGitHub <noreply@github.com>2021-08-24 13:29:42 +0200
commitf4a9db350fbf00a6cb13a2c030b925cfd5218ed2 (patch)
tree3ab5cc4f4db7e4855df04fc792ee1e66e05a5d13 /ext
parent50f69a6996ae4dcdfe53f15fc49949d3756c9787 (diff)
chore(ext/webgpu): update wgpu to 0.10.0 (#11781)
Co-authored-by: Luca Casonato <hello@lcas.dev>
Diffstat (limited to 'ext')
-rw-r--r--ext/webgpu/01_webgpu.js49
-rw-r--r--ext/webgpu/02_idl_types.js58
-rw-r--r--ext/webgpu/Cargo.toml4
-rw-r--r--ext/webgpu/binding.rs4
-rw-r--r--ext/webgpu/buffer.rs2
-rw-r--r--ext/webgpu/bundle.rs16
-rw-r--r--ext/webgpu/command_encoder.rs28
-rw-r--r--ext/webgpu/error.rs9
-rw-r--r--ext/webgpu/lib.deno_webgpu.d.ts37
-rw-r--r--ext/webgpu/lib.rs138
-rw-r--r--ext/webgpu/pipeline.rs14
-rw-r--r--ext/webgpu/queue.rs6
-rw-r--r--ext/webgpu/sampler.rs4
-rw-r--r--ext/webgpu/shader.rs25
-rw-r--r--ext/webgpu/texture.rs2
-rw-r--r--ext/webgpu/webgpu.idl109
16 files changed, 293 insertions, 212 deletions
diff --git a/ext/webgpu/01_webgpu.js b/ext/webgpu/01_webgpu.js
index 50d4d6eba..f7ad6caa7 100644
--- a/ext/webgpu/01_webgpu.js
+++ b/ext/webgpu/01_webgpu.js
@@ -215,7 +215,7 @@
* @property {number} rid
* @property {GPUSupportedFeatures} features
* @property {GPUSupportedLimits} limits
- * @property {boolean} isSoftware
+ * @property {boolean} isFallbackAdapter
*/
/**
@@ -257,8 +257,8 @@
return this[_adapter].limits;
}
/** @returns {boolean} */
- get isSoftware() {
- return this[_adapter].isSoftware;
+ get isFallbackAdapter() {
+ return this[_adapter].isFallbackAdapter;
}
constructor() {
@@ -353,8 +353,11 @@
* @property {number} maxVertexBufferArrayStride
* @property {number} maxInterStageShaderComponents
* @property {number} maxComputeWorkgroupStorageSize
- * @property {number} maxComputeWorkgroupInvocations
- * @property {number} maxComputePerDimensionDispatchSize
+ * @property {number} maxComputeInvocationsPerWorkgroup
+ * @property {number} maxComputeWorkgroupSizeX
+ * @property {number} maxComputeWorkgroupSizeY
+ * @property {number} maxComputeWorkgroupSizeZ
+ * @property {number} maxComputeWorkgroupsPerDimension
*/
class GPUSupportedLimits {
@@ -448,13 +451,25 @@
webidl.assertBranded(this, GPUSupportedLimits);
return this[_limits].maxComputeWorkgroupStorageSize;
}
- get maxComputeWorkgroupInvocations() {
+ get maxComputeInvocationsPerWorkgroup() {
webidl.assertBranded(this, GPUSupportedLimits);
- return this[_limits].maxComputeWorkgroupInvocations;
+ return this[_limits].maxComputeInvocationsPerWorkgroup;
}
- get maxComputePerDimensionDispatchSize() {
+ get maxComputeWorkgroupSizeX() {
webidl.assertBranded(this, GPUSupportedLimits);
- return this[_limits].maxComputePerDimensionDispatchSize;
+ return this[_limits].maxComputeWorkgroupSizeX;
+ }
+ get maxComputeWorkgroupSizeY() {
+ webidl.assertBranded(this, GPUSupportedLimits);
+ return this[_limits].maxComputeWorkgroupSizeY;
+ }
+ get maxComputeWorkgroupSizeZ() {
+ webidl.assertBranded(this, GPUSupportedLimits);
+ return this[_limits].maxComputeWorkgroupSizeZ;
+ }
+ get maxComputeWorkgroupsPerDimension() {
+ webidl.assertBranded(this, GPUSupportedLimits);
+ return this[_limits].maxComputeWorkgroupsPerDimension;
}
[SymbolFor("Deno.privateCustomInspect")](inspect) {
@@ -1090,14 +1105,9 @@
{
deviceRid: device.rid,
label: descriptor.label,
- code: (typeof descriptor.code === "string")
- ? descriptor.code
- : undefined,
+ code: descriptor.code,
sourceMap: descriptor.sourceMap,
},
- ...(descriptor.code instanceof Uint32Array
- ? [new Uint8Array(descriptor.code.buffer)]
- : []),
);
device.pushError(err);
@@ -1575,6 +1585,7 @@
origin: destination.origin
? normalizeGPUOrigin3D(destination.origin)
: undefined,
+ aspect: destination.aspect,
},
dataLayout,
size: normalizeGPUExtent3D(size),
@@ -2071,10 +2082,10 @@
static get COPY_DST() {
return 0x02;
}
- static get SAMPLED() {
+ static get TEXTURE_BINDING() {
return 0x04;
}
- static get STORAGE() {
+ static get STORAGE_BINDING() {
return 0x08;
}
static get RENDER_ATTACHMENT() {
@@ -2906,6 +2917,7 @@
origin: destination.origin
? normalizeGPUOrigin3D(destination.origin)
: undefined,
+ aspect: destination.aspect,
},
copySize: normalizeGPUExtent3D(copySize),
},
@@ -2968,6 +2980,7 @@
origin: source.origin
? normalizeGPUOrigin3D(source.origin)
: undefined,
+ aspect: source.aspect,
},
destination: {
...destination,
@@ -3034,6 +3047,7 @@
origin: source.origin
? normalizeGPUOrigin3D(source.origin)
: undefined,
+ aspect: source.aspect,
},
destination: {
texture: destinationTextureRid,
@@ -3041,6 +3055,7 @@
origin: destination.origin
? normalizeGPUOrigin3D(destination.origin)
: undefined,
+ aspect: source.aspect,
},
copySize: normalizeGPUExtent3D(copySize),
},
diff --git a/ext/webgpu/02_idl_types.js b/ext/webgpu/02_idl_types.js
index 9102b8d7a..364a39747 100644
--- a/ext/webgpu/02_idl_types.js
+++ b/ext/webgpu/02_idl_types.js
@@ -39,11 +39,7 @@
GPUOutOfMemoryError,
GPUValidationError,
} = window.__bootstrap.webgpu;
- const {
- SymbolIterator,
- TypeError,
- Uint32Array,
- } = window.__bootstrap.primordials;
+ const { SymbolIterator, TypeError } = window.__bootstrap.primordials;
// This needs to be initalized after all of the base classes are implmented,
// otherwise their converters might not be available yet.
@@ -94,7 +90,7 @@
converter: webidl.converters["GPUPowerPreference"],
},
{
- key: "forceSoftware",
+ key: "forceFallbackAdapter",
converter: webidl.converters.boolean,
defaultValue: false,
},
@@ -681,7 +677,6 @@
webidl.converters["GPUStorageTextureAccess"] = webidl.createEnumConverter(
"GPUStorageTextureAccess",
[
- "read-only",
"write-only",
],
);
@@ -691,7 +686,7 @@
{
key: "access",
converter: webidl.converters["GPUStorageTextureAccess"],
- required: true,
+ defaultValue: "write-only",
},
{
key: "format",
@@ -861,19 +856,7 @@
const dictMembersGPUShaderModuleDescriptor = [
{
key: "code",
- converter: (V, opts) => {
- if (V instanceof Uint32Array) {
- return webidl.converters["Uint32Array"](V, opts);
- }
- if (typeof V === "string") {
- return webidl.converters["DOMString"](V, opts);
- }
- throw webidl.makeException(
- TypeError,
- "can not be converted to Uint32Array or DOMString.",
- opts,
- );
- },
+ converter: webidl.converters["DOMString"],
required: true,
},
{ key: "sourceMap", converter: webidl.converters["object"] },
@@ -977,9 +960,9 @@
GPURenderPipeline,
);
- // ENUM: GPUInputStepMode
- webidl.converters["GPUInputStepMode"] = webidl.createEnumConverter(
- "GPUInputStepMode",
+ // ENUM: GPUVertexStepMode
+ webidl.converters["GPUVertexStepMode"] = webidl.createEnumConverter(
+ "GPUVertexStepMode",
[
"vertex",
"instance",
@@ -1055,7 +1038,7 @@
},
{
key: "stepMode",
- converter: webidl.converters["GPUInputStepMode"],
+ converter: webidl.converters["GPUVertexStepMode"],
defaultValue: "vertex",
},
{
@@ -1811,8 +1794,8 @@
GPURenderBundleEncoder,
);
- // DICTIONARY: GPURenderBundleEncoderDescriptor
- const dictMembersGPURenderBundleEncoderDescriptor = [
+ // DICTIONARY: GPURenderPassLayout
+ const dictMembersGPURenderPassLayout = [
{
key: "colorFormats",
converter: webidl.createSequenceConverter(
@@ -1830,10 +1813,31 @@
defaultValue: 1,
},
];
+ webidl.converters["GPURenderPassLayout"] = webidl
+ .createDictionaryConverter(
+ "GPURenderPassLayout",
+ dictMembersGPUObjectDescriptorBase,
+ dictMembersGPURenderPassLayout,
+ );
+
+ // DICTIONARY: GPURenderBundleEncoderDescriptor
+ const dictMembersGPURenderBundleEncoderDescriptor = [
+ {
+ key: "depthReadOnly",
+ converter: webidl.converters.boolean,
+ defaultValue: false,
+ },
+ {
+ key: "stencilReadOnly",
+ converter: webidl.converters.boolean,
+ defaultValue: false,
+ },
+ ];
webidl.converters["GPURenderBundleEncoderDescriptor"] = webidl
.createDictionaryConverter(
"GPURenderBundleEncoderDescriptor",
dictMembersGPUObjectDescriptorBase,
+ dictMembersGPURenderPassLayout,
dictMembersGPURenderBundleEncoderDescriptor,
);
diff --git a/ext/webgpu/Cargo.toml b/ext/webgpu/Cargo.toml
index 644b947e6..1108d9ae6 100644
--- a/ext/webgpu/Cargo.toml
+++ b/ext/webgpu/Cargo.toml
@@ -17,5 +17,5 @@ path = "lib.rs"
deno_core = { version = "0.98.0", path = "../../core" }
serde = { version = "1.0.126", features = ["derive"] }
tokio = { version = "1.8.1", features = ["full"] }
-wgpu-core = { version = "0.9.0", features = ["trace"] }
-wgpu-types = "0.9.0"
+wgpu-core = { version = "0.10.0", features = ["trace"] }
+wgpu-types = "0.10.0"
diff --git a/ext/webgpu/binding.rs b/ext/webgpu/binding.rs
index daf4e718d..c1b98fcef 100644
--- a/ext/webgpu/binding.rs
+++ b/ext/webgpu/binding.rs
@@ -91,7 +91,8 @@ pub fn op_webgpu_create_bind_group_layout(
for entry in &args.entries {
entries.push(wgpu_types::BindGroupLayoutEntry {
binding: entry.binding,
- visibility: wgpu_types::ShaderStage::from_bits(entry.visibility).unwrap(),
+ visibility: wgpu_types::ShaderStages::from_bits(entry.visibility)
+ .unwrap(),
ty: if let Some(buffer) = &entry.buffer {
wgpu_types::BindingType::Buffer {
ty: match &buffer.kind {
@@ -166,7 +167,6 @@ pub fn op_webgpu_create_bind_group_layout(
} else if let Some(storage_texture) = &entry.storage_texture {
wgpu_types::BindingType::StorageTexture {
access: match storage_texture.access.as_str() {
- "read-only" => wgpu_types::StorageTextureAccess::ReadOnly,
"write-only" => wgpu_types::StorageTextureAccess::WriteOnly,
_ => unreachable!(),
},
diff --git a/ext/webgpu/buffer.rs b/ext/webgpu/buffer.rs
index e42c77598..b87982aec 100644
--- a/ext/webgpu/buffer.rs
+++ b/ext/webgpu/buffer.rs
@@ -55,7 +55,7 @@ pub fn op_webgpu_create_buffer(
let descriptor = wgpu_core::resource::BufferDescriptor {
label: args.label.map(Cow::from),
size: args.size,
- usage: wgpu_types::BufferUsage::from_bits(args.usage)
+ usage: wgpu_types::BufferUsages::from_bits(args.usage)
.ok_or_else(|| type_error("usage is not valid"))?,
mapped_at_creation: args.mapped_at_creation.unwrap_or(false),
};
diff --git a/ext/webgpu/bundle.rs b/ext/webgpu/bundle.rs
index 9ea80b171..3a228ba62 100644
--- a/ext/webgpu/bundle.rs
+++ b/ext/webgpu/bundle.rs
@@ -37,6 +37,8 @@ pub struct CreateRenderBundleEncoderArgs {
color_formats: Vec<String>,
depth_stencil_format: Option<String>,
sample_count: Option<u32>,
+ depth_read_only: bool,
+ stencil_read_only: bool,
}
pub fn op_webgpu_create_render_bundle_encoder(
@@ -58,11 +60,17 @@ pub fn op_webgpu_create_render_bundle_encoder(
let descriptor = wgpu_core::command::RenderBundleEncoderDescriptor {
label: args.label.map(Cow::from),
color_formats: Cow::from(color_formats),
- depth_stencil_format: args
- .depth_stencil_format
- .map(|s| serialize_texture_format(&s))
- .transpose()?,
sample_count: args.sample_count.unwrap_or(1),
+ depth_stencil: if let Some(depth_stencil_format) = args.depth_stencil_format
+ {
+ Some(wgpu_types::RenderBundleDepthStencil {
+ format: serialize_texture_format(&depth_stencil_format)?,
+ depth_read_only: args.depth_read_only,
+ stencil_read_only: args.stencil_read_only,
+ })
+ } else {
+ None
+ },
};
let res =
diff --git a/ext/webgpu/command_encoder.rs b/ext/webgpu/command_encoder.rs
index b2d659f13..b68bab7bd 100644
--- a/ext/webgpu/command_encoder.rs
+++ b/ext/webgpu/command_encoder.rs
@@ -31,7 +31,7 @@ impl Resource for WebGpuCommandBuffer {
fn serialize_store_op(store_op: String) -> wgpu_core::command::StoreOp {
match store_op.as_str() {
"store" => wgpu_core::command::StoreOp::Store,
- "discard" => wgpu_core::command::StoreOp::Clear,
+ "discard" => wgpu_core::command::StoreOp::Discard,
_ => unreachable!(),
}
}
@@ -323,7 +323,7 @@ pub struct GpuImageCopyTexture {
pub texture: u32,
pub mip_level: Option<u32>,
pub origin: Option<GpuOrigin3D>,
- pub _aspect: Option<String>, // not yet implemented
+ pub aspect: String,
}
#[derive(Deserialize)]
@@ -373,6 +373,12 @@ pub fn op_webgpu_command_encoder_copy_buffer_to_texture(
y: origin.y.unwrap_or(0),
z: origin.z.unwrap_or(0),
}),
+ aspect: match args.destination.aspect.as_str() {
+ "all" => wgpu_types::TextureAspect::All,
+ "stencil-only" => wgpu_types::TextureAspect::StencilOnly,
+ "depth-only" => wgpu_types::TextureAspect::DepthOnly,
+ _ => unreachable!(),
+ },
};
gfx_ok!(command_encoder => instance.command_encoder_copy_buffer_to_texture(
command_encoder,
@@ -424,6 +430,12 @@ pub fn op_webgpu_command_encoder_copy_texture_to_buffer(
z: origin.z.unwrap_or(0),
}
}),
+ aspect: match args.source.aspect.as_str() {
+ "all" => wgpu_types::TextureAspect::All,
+ "stencil-only" => wgpu_types::TextureAspect::StencilOnly,
+ "depth-only" => wgpu_types::TextureAspect::DepthOnly,
+ _ => unreachable!(),
+ },
};
let destination = wgpu_core::command::ImageCopyBuffer {
buffer: destination_buffer_resource.0,
@@ -487,6 +499,12 @@ pub fn op_webgpu_command_encoder_copy_texture_to_texture(
z: origin.z.unwrap_or(0),
}
}),
+ aspect: match args.source.aspect.as_str() {
+ "all" => wgpu_types::TextureAspect::All,
+ "stencil-only" => wgpu_types::TextureAspect::StencilOnly,
+ "depth-only" => wgpu_types::TextureAspect::DepthOnly,
+ _ => unreachable!(),
+ },
};
let destination = wgpu_core::command::ImageCopyTexture {
texture: destination_texture_resource.0,
@@ -499,6 +517,12 @@ pub fn op_webgpu_command_encoder_copy_texture_to_texture(
y: origin.y.unwrap_or(0),
z: origin.z.unwrap_or(0),
}),
+ aspect: match args.destination.aspect.as_str() {
+ "all" => wgpu_types::TextureAspect::All,
+ "stencil-only" => wgpu_types::TextureAspect::StencilOnly,
+ "depth-only" => wgpu_types::TextureAspect::DepthOnly,
+ _ => unreachable!(),
+ },
};
gfx_ok!(command_encoder => instance.command_encoder_copy_texture_to_texture(
command_encoder,
diff --git a/ext/webgpu/error.rs b/ext/webgpu/error.rs
index 57e2e675f..c821fbf8f 100644
--- a/ext/webgpu/error.rs
+++ b/ext/webgpu/error.rs
@@ -8,7 +8,6 @@ use wgpu_core::binding_model::CreateBindGroupError;
use wgpu_core::binding_model::CreateBindGroupLayoutError;
use wgpu_core::binding_model::CreatePipelineLayoutError;
use wgpu_core::binding_model::GetBindGroupLayoutError;
-use wgpu_core::command::CommandAllocatorError;
use wgpu_core::command::CommandEncoderError;
use wgpu_core::command::ComputePassError;
use wgpu_core::command::CopyError;
@@ -145,14 +144,6 @@ impl From<CreateRenderBundleError> for WebGpuError {
}
}
-impl From<CommandAllocatorError> for WebGpuError {
- fn from(err: CommandAllocatorError) -> Self {
- match err {
- CommandAllocatorError::Device(err) => err.into(),
- }
- }
-}
-
impl From<CopyError> for WebGpuError {
fn from(err: CopyError) -> Self {
WebGpuError::Validation(err.to_string())
diff --git a/ext/webgpu/lib.deno_webgpu.d.ts b/ext/webgpu/lib.deno_webgpu.d.ts
index 9f7a31cb7..001b3c1f0 100644
--- a/ext/webgpu/lib.deno_webgpu.d.ts
+++ b/ext/webgpu/lib.deno_webgpu.d.ts
@@ -37,8 +37,11 @@ declare class GPUSupportedLimits {
maxVertexBufferArrayStride?: number;
maxInterStageShaderComponents?: number;
maxComputeWorkgroupStorageSize?: number;
- maxComputeWorkgroupInvocations?: number;
- maxComputePerDimensionDispatchSize?: number;
+ maxComputeInvocationsPerWorkgroup?: number;
+ maxComputeWorkgroupSizeX?: number;
+ maxComputeWorkgroupSizeY?: number;
+ maxComputeWorkgroupSizeZ?: number;
+ maxComputeWorkgroupsPerDimension?: number;
}
declare class GPUSupportedFeatures {
@@ -69,7 +72,7 @@ declare class GPU {
declare interface GPURequestAdapterOptions {
powerPreference?: GPUPowerPreference;
- forceSoftware?: boolean;
+ forceFallbackAdapter?: boolean;
}
declare type GPUPowerPreference = "low-power" | "high-performance";
@@ -78,7 +81,7 @@ declare class GPUAdapter {
readonly name: string;
readonly features: GPUSupportedFeatures;
readonly limits: GPUSupportedLimits;
- readonly isSoftware: boolean;
+ readonly isFallbackAdapter: boolean;
requestDevice(descriptor?: GPUDeviceDescriptor): Promise<GPUDevice>;
}
@@ -226,8 +229,8 @@ declare type GPUTextureUsageFlags = number;
declare class GPUTextureUsage {
static COPY_SRC: 0x01;
static COPY_DST: 0x02;
- static SAMPLED: 0x04;
- static STORAGE: 0x08;
+ static TEXTURE_BINDING: 0x04;
+ static STORAGE_BINDING: 0x08;
static RENDER_ATTACHMENT: 0x10;
}
@@ -400,13 +403,7 @@ declare type GPUTextureSampleType =
| "sint"
| "uint";
-declare interface GPUTextureBindingLayout {
- sampleType?: GPUTextureSampleType;
- viewDimension?: GPUTextureViewDimension;
- multisampled?: boolean;
-}
-
-declare type GPUStorageTextureAccess = "read-only" | "write-only";
+declare type GPUStorageTextureAccess = "write-only";
declare interface GPUStorageTextureBindingLayout {
access: GPUStorageTextureAccess;
@@ -467,7 +464,7 @@ declare class GPUShaderModule implements GPUObjectBase {
}
declare interface GPUShaderModuleDescriptor extends GPUObjectDescriptorBase {
- code: string | Uint32Array;
+ code: string;
sourceMap?: any;
}
@@ -655,7 +652,7 @@ declare type GPUVertexFormat =
| "sint32x2"
| "sint32x3"
| "sint32x4";
-declare type GPUInputStepMode = "vertex" | "instance";
+declare type GPUVertexStepMode = "vertex" | "instance";
declare interface GPUVertexState extends GPUProgrammableStage {
buffers?: (GPUVertexBufferLayout | null)[];
@@ -663,7 +660,7 @@ declare interface GPUVertexState extends GPUProgrammableStage {
declare interface GPUVertexBufferLayout {
arrayStride: number;
- stepMode?: GPUInputStepMode;
+ stepMode?: GPUVertexStepMode;
attributes: GPUVertexAttribute[];
}
@@ -1022,13 +1019,17 @@ declare class GPURenderBundleEncoder
finish(descriptor?: GPURenderBundleDescriptor): GPURenderBundle;
}
-declare interface GPURenderBundleEncoderDescriptor
- extends GPUObjectDescriptorBase {
+declare interface GPURenderPassLayout extends GPUObjectDescriptorBase {
colorFormats: GPUTextureFormat[];
depthStencilFormat?: GPUTextureFormat;
sampleCount?: number;
}
+declare interface GPURenderBundleEncoderDescriptor extends GPURenderPassLayout {
+ depthReadOnly?: boolean;
+ stencilReadOnly?: boolean;
+}
+
declare class GPUQueue implements GPUObjectBase {
label: string | null;
diff --git a/ext/webgpu/lib.rs b/ext/webgpu/lib.rs
index aa9de2110..d2b0a239b 100644
--- a/ext/webgpu/lib.rs
+++ b/ext/webgpu/lib.rs
@@ -28,15 +28,13 @@ mod macros {
($id:expr => $global:ident.$method:ident( $($param:expr),* )) => {
match $id.backend() {
#[cfg(not(target_os = "macos"))]
- wgpu_types::Backend::Vulkan => $global.$method::<wgpu_core::backend::Vulkan>( $($param),* ),
+ wgpu_types::Backend::Vulkan => $global.$method::<wgpu_core::api::Vulkan>( $($param),* ),
#[cfg(target_os = "macos")]
- wgpu_types::Backend::Metal => $global.$method::<wgpu_core::backend::Metal>( $($param),* ),
+ wgpu_types::Backend::Metal => $global.$method::<wgpu_core::api::Metal>( $($param),* ),
#[cfg(windows)]
- wgpu_types::Backend::Dx12 => $global.$method::<wgpu_core::backend::Dx12>( $($param),* ),
- #[cfg(windows)]
- wgpu_types::Backend::Dx11 => $global.$method::<wgpu_core::backend::Dx11>( $($param),* ),
+ wgpu_types::Backend::Dx12 => $global.$method::<wgpu_core::api::Dx12>( $($param),* ),
#[cfg(all(unix, not(target_os = "macos")))]
- wgpu_types::Backend::Gl => $global.$method::<wgpu_core::backend::Gl>( $($param),+ ),
+ wgpu_types::Backend::Gl => $global.$method::<wgpu_core::api::Gles>( $($param),+ ),
other => panic!("Unexpected backend {:?}", other),
}
};
@@ -75,7 +73,6 @@ pub struct Unstable(pub bool);
fn check_unstable(state: &OpState, api_name: &str) {
let unstable = state.borrow::<Unstable>();
-
if !unstable.0 {
eprintln!(
"Unstable API '{}'. The --unstable flag must be provided.",
@@ -151,18 +148,20 @@ fn deserialize_features(features: &wgpu_types::Features) -> Vec<&'static str> {
if features.contains(wgpu_types::Features::MAPPABLE_PRIMARY_BUFFERS) {
return_features.push("mappable-primary-buffers");
}
- if features.contains(wgpu_types::Features::SAMPLED_TEXTURE_BINDING_ARRAY) {
- return_features.push("sampled-texture-binding-array");
+ if features.contains(wgpu_types::Features::TEXTURE_BINDING_ARRAY) {
+ return_features.push("texture-binding-array");
}
- if features
- .contains(wgpu_types::Features::SAMPLED_TEXTURE_ARRAY_DYNAMIC_INDEXING)
- {
- return_features.push("sampled-texture-array-dynamic-indexing");
+ if features.contains(wgpu_types::Features::BUFFER_BINDING_ARRAY) {
+ return_features.push("buffer-binding-array");
}
- if features
- .contains(wgpu_types::Features::SAMPLED_TEXTURE_ARRAY_NON_UNIFORM_INDEXING)
- {
- return_features.push("sampled-texture-array-non-uniform-indexing");
+ if features.contains(wgpu_types::Features::STORAGE_RESOURCE_BINDING_ARRAY) {
+ return_features.push("storage-resource-binding-array");
+ }
+ if features.contains(wgpu_types::Features::SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING) {
+ return_features.push("sampled-texture-and-storage-buffer-array-non-uniform-indexing");
+ }
+ if features.contains(wgpu_types::Features::UNIFORM_BUFFER_AND_STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING) {
+ return_features.push("uniform-buffer-and-storage-buffer-texture-non-uniform-indexing");
}
if features.contains(wgpu_types::Features::UNSIZED_BINDING_ARRAY) {
return_features.push("unsized-binding-array");
@@ -199,6 +198,21 @@ fn deserialize_features(features: &wgpu_types::Features) -> Vec<&'static str> {
if features.contains(wgpu_types::Features::VERTEX_ATTRIBUTE_64BIT) {
return_features.push("vertex-attribute-64bit");
}
+ if features.contains(wgpu_types::Features::CONSERVATIVE_RASTERIZATION) {
+ return_features.push("conservative-rasterization");
+ }
+ if features.contains(wgpu_types::Features::VERTEX_WRITABLE_STORAGE) {
+ return_features.push("vertex-writable-storage");
+ }
+ if features.contains(wgpu_types::Features::CLEAR_COMMANDS) {
+ return_features.push("clear-commands");
+ }
+ if features.contains(wgpu_types::Features::SPIRV_SHADER_PASSTHROUGH) {
+ return_features.push("spirv-shader-passthrough");
+ }
+ if features.contains(wgpu_types::Features::SHADER_PRIMITIVE_INDEX) {
+ return_features.push("shader-primitive-index");
+ }
return_features
}
@@ -239,7 +253,7 @@ pub async fn op_webgpu_request_adapter(
state.put(wgpu_core::hub::Global::new(
"webgpu",
wgpu_core::hub::IdentityManagerFactory,
- wgpu_types::BackendBit::PRIMARY,
+ wgpu_types::Backends::PRIMARY,
));
state.borrow::<Instance>()
};
@@ -253,13 +267,13 @@ pub async fn op_webgpu_request_adapter(
},
None => Default::default(),
},
- // TODO(lucacasonato): respect forceSoftware
+ // TODO(lucacasonato): respect forceFallbackAdapter
compatible_surface: None, // windowless
};
let res = instance.request_adapter(
&descriptor,
wgpu_core::instance::AdapterInputs::Mask(
- wgpu_types::BackendBit::PRIMARY,
+ wgpu_types::Backends::PRIMARY,
|_| std::marker::PhantomData,
),
);
@@ -305,8 +319,8 @@ struct GpuLimits {
max_storage_buffers_per_shader_stage: Option<u32>,
max_storage_textures_per_shader_stage: Option<u32>,
max_uniform_buffers_per_shader_stage: Option<u32>,
- max_uniform_buffer_binding_size: Option<u32>,
- max_storage_buffer_binding_size: Option<u32>,
+ max_uniform_buffer_binding_size: Option<u32>, // TODO(@crowlkats): u64
+ max_storage_buffer_binding_size: Option<u32>, // TODO(@crowlkats): u64
// min_uniform_buffer_offset_alignment: Option<u32>,
// min_storage_buffer_offset_alignment: Option<u32>,
max_vertex_buffers: Option<u32>,
@@ -314,8 +328,11 @@ struct GpuLimits {
max_vertex_buffer_array_stride: Option<u32>,
// max_inter_stage_shader_components: Option<u32>,
// max_compute_workgroup_storage_size: Option<u32>,
- // max_compute_workgroup_invocations: Option<u32>,
- // max_compute_per_dimension_dispatch_size: Option<u32>,
+ // max_compute_invocations_per_workgroup: Option<u32>,
+ // max_compute_workgroup_size_x: Option<u32>,
+ // max_compute_workgroup_size_y: Option<u32>,
+ // max_compute_workgroup_size_z: Option<u32>,
+ // max_compute_workgroups_per_dimension: Option<u32>,
}
impl From<GpuLimits> for wgpu_types::Limits {
@@ -370,12 +387,21 @@ impl From<GpuLimits> for wgpu_types::Limits {
// max_compute_workgroup_storage_size: limits
// .max_compute_workgroup_storage_size
// .unwrap_or(default),
- // max_compute_workgroup_invocations: limits
- // .max_compute_workgroup_invocations
- // .unwrap_or(default),
- // max_compute_per_dimension_dispatch_size: limits
- // .max_compute_per_dimension_dispatch_size
- // .unwrap_or(default),
+ // max_compute_invocations_per_workgroup: limits
+ // .max_compute_invocations_per_workgroup
+ // .unwrap_or(default),
+ // max_compute_workgroup_size_x: limits
+ // .max_compute_workgroup_size_x
+ // .unwrap_or(default),
+ // max_compute_workgroup_size_y: limits
+ // .max_compute_workgroup_size_y
+ // .unwrap_or(default),
+ // max_compute_workgroup_size_z: limits
+ // .max_compute_workgroup_size_z
+ // .unwrap_or(default),
+ // max_compute_workgroups_per_dimension: limits
+ // .max_compute_workgroups_per_dimension
+ // .unwrap_or(default),
max_push_constant_size: 0,
}
}
@@ -422,24 +448,26 @@ pub async fn op_webgpu_request_device(
if passed_features.contains(&"mappable-primary-buffers".to_string()) {
features.set(wgpu_types::Features::MAPPABLE_PRIMARY_BUFFERS, true);
}
- if passed_features.contains(&"sampled-texture-binding-array".to_string()) {
- features.set(wgpu_types::Features::SAMPLED_TEXTURE_BINDING_ARRAY, true);
+ if passed_features.contains(&"texture-binding-array".to_string()) {
+ features.set(wgpu_types::Features::TEXTURE_BINDING_ARRAY, true);
}
- if passed_features
- .contains(&"sampled-texture-array-dynamic-indexing".to_string())
- {
- features.set(
- wgpu_types::Features::SAMPLED_TEXTURE_ARRAY_DYNAMIC_INDEXING,
- true,
- );
+ if passed_features.contains(&"buffer-binding-array".to_string()) {
+ features.set(wgpu_types::Features::BUFFER_BINDING_ARRAY, true);
}
- if passed_features
- .contains(&"sampled-texture-array-non-uniform-indexing".to_string())
- {
- features.set(
- wgpu_types::Features::SAMPLED_TEXTURE_ARRAY_NON_UNIFORM_INDEXING,
- true,
- );
+ if passed_features.contains(&"storage-resource-binding-array".to_string()) {
+ features.set(wgpu_types::Features::STORAGE_RESOURCE_BINDING_ARRAY, true);
+ }
+ if passed_features.contains(
+ &"sampled-texture-and-storage-buffer-array-non-uniform-indexing"
+ .to_string(),
+ ) {
+ features.set(wgpu_types::Features::SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING, true);
+ }
+ if passed_features.contains(
+ &"uniform-buffer-and-storage-buffer-texture-non-uniform-indexing"
+ .to_string(),
+ ) {
+ features.set(wgpu_types::Features::UNIFORM_BUFFER_AND_STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING, true);
}
if passed_features.contains(&"unsized-binding-array".to_string()) {
features.set(wgpu_types::Features::UNSIZED_BINDING_ARRAY, true);
@@ -479,6 +507,21 @@ pub async fn op_webgpu_request_device(
if passed_features.contains(&"vertex-attribute-64bit".to_string()) {
features.set(wgpu_types::Features::VERTEX_ATTRIBUTE_64BIT, true);
}
+ if passed_features.contains(&"conservative-rasterization".to_string()) {
+ features.set(wgpu_types::Features::CONSERVATIVE_RASTERIZATION, true);
+ }
+ if passed_features.contains(&"vertex-writable-storage".to_string()) {
+ features.set(wgpu_types::Features::VERTEX_WRITABLE_STORAGE, true);
+ }
+ if passed_features.contains(&"clear-commands".to_string()) {
+ features.set(wgpu_types::Features::CLEAR_COMMANDS, true);
+ }
+ if passed_features.contains(&"spirv-shader-passthrough".to_string()) {
+ features.set(wgpu_types::Features::SPIRV_SHADER_PASSTHROUGH, true);
+ }
+ if passed_features.contains(&"shader-primitive-index".to_string()) {
+ features.set(wgpu_types::Features::SHADER_PRIMITIVE_INDEX, true);
+ }
}
let descriptor = wgpu_types::DeviceDescriptor {
@@ -520,7 +563,7 @@ pub async fn op_webgpu_request_device(
#[serde(rename_all = "camelCase")]
pub struct CreateQuerySetArgs {
device_rid: ResourceId,
- _label: Option<String>, // not yet implemented
+ label: Option<String>,
#[serde(rename = "type")]
kind: String,
count: u32,
@@ -538,6 +581,7 @@ pub fn op_webgpu_create_query_set(
let instance = &state.borrow::<Instance>();
let descriptor = wgpu_types::QuerySetDescriptor {
+ label: args.label.map(Cow::from),
ty: match args.kind.as_str() {
"pipeline-statistics" => {
let mut pipeline_statistics_names =
diff --git a/ext/webgpu/pipeline.rs b/ext/webgpu/pipeline.rs
index 3a3707d36..877143f94 100644
--- a/ext/webgpu/pipeline.rs
+++ b/ext/webgpu/pipeline.rs
@@ -9,6 +9,8 @@ use std::borrow::Cow;
use super::error::{WebGpuError, WebGpuResult};
+const MAX_BIND_GROUPS: usize = 8;
+
pub(crate) struct WebGpuPipelineLayout(
pub(crate) wgpu_core::id::PipelineLayoutId,
);
@@ -200,7 +202,7 @@ pub fn op_webgpu_create_compute_pipeline(
Some(_) => None,
None => Some(wgpu_core::device::ImplicitPipelineIds {
root_id: std::marker::PhantomData,
- group_ids: &[std::marker::PhantomData; wgpu_core::MAX_BIND_GROUPS],
+ group_ids: &[std::marker::PhantomData; MAX_BIND_GROUPS],
}),
};
@@ -489,11 +491,11 @@ pub fn op_webgpu_create_render_pipeline(
array_stride: buffer.array_stride,
step_mode: match buffer.step_mode {
Some(step_mode) => match step_mode.as_str() {
- "vertex" => wgpu_types::InputStepMode::Vertex,
- "instance" => wgpu_types::InputStepMode::Instance,
+ "vertex" => wgpu_types::VertexStepMode::Vertex,
+ "instance" => wgpu_types::VertexStepMode::Instance,
_ => unreachable!(),
},
- None => wgpu_types::InputStepMode::Vertex,
+ None => wgpu_types::VertexStepMode::Vertex,
},
attributes: Cow::from(
buffer
@@ -610,7 +612,7 @@ pub fn op_webgpu_create_render_pipeline(
write_mask: target
.write_mask
.map_or(Default::default(), |mask| {
- wgpu_types::ColorWrite::from_bits(mask).unwrap()
+ wgpu_types::ColorWrites::from_bits(mask).unwrap()
}),
})
.collect::<Vec<wgpu_types::ColorTargetState>>(),
@@ -623,7 +625,7 @@ pub fn op_webgpu_create_render_pipeline(
Some(_) => None,
None => Some(wgpu_core::device::ImplicitPipelineIds {
root_id: std::marker::PhantomData,
- group_ids: &[std::marker::PhantomData; wgpu_core::MAX_BIND_GROUPS],
+ group_ids: &[std::marker::PhantomData; MAX_BIND_GROUPS],
}),
};
diff --git a/ext/webgpu/queue.rs b/ext/webgpu/queue.rs
index 6af1e61e3..da1f7a1ad 100644
--- a/ext/webgpu/queue.rs
+++ b/ext/webgpu/queue.rs
@@ -128,6 +128,12 @@ pub fn op_webgpu_write_texture(
y: origin.y.unwrap_or(0),
z: origin.z.unwrap_or(0),
}),
+ aspect: match args.destination.aspect.as_str() {
+ "all" => wgpu_types::TextureAspect::All,
+ "stencil-only" => wgpu_types::TextureAspect::StencilOnly,
+ "depth-only" => wgpu_types::TextureAspect::DepthOnly,
+ _ => unreachable!(),
+ },
};
let data_layout = wgpu_types::ImageDataLayout {
offset: args.data_layout.offset.unwrap_or(0),
diff --git a/ext/webgpu/sampler.rs b/ext/webgpu/sampler.rs
index 827ba4b3a..63c475d37 100644
--- a/ext/webgpu/sampler.rs
+++ b/ext/webgpu/sampler.rs
@@ -97,9 +97,7 @@ pub fn op_webgpu_create_sampler(
min_filter: serialize_filter_mode(args.min_filter),
mipmap_filter: serialize_filter_mode(args.mipmap_filter),
lod_min_clamp: args.lod_min_clamp.unwrap_or(0.0),
- lod_max_clamp: args.lod_max_clamp.unwrap_or(
- wgpu_core::resource::SamplerDescriptor::default().lod_max_clamp,
- ),
+ lod_max_clamp: args.lod_max_clamp.unwrap_or(32.0),
compare: args
.compare
.as_ref()
diff --git a/ext/webgpu/shader.rs b/ext/webgpu/shader.rs
index bd3b03f55..efb67e8f0 100644
--- a/ext/webgpu/shader.rs
+++ b/ext/webgpu/shader.rs
@@ -1,9 +1,7 @@
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
-use deno_core::error::null_opbuf;
use deno_core::error::AnyError;
use deno_core::ResourceId;
-use deno_core::ZeroCopyBuf;
use deno_core::{OpState, Resource};
use serde::Deserialize;
use std::borrow::Cow;
@@ -22,14 +20,14 @@ impl Resource for WebGpuShaderModule {
pub struct CreateShaderModuleArgs {
device_rid: ResourceId,
label: Option<String>,
- code: Option<String>,
+ code: String,
_source_map: Option<()>, // not yet implemented
}
pub fn op_webgpu_create_shader_module(
state: &mut OpState,
args: CreateShaderModuleArgs,
- zero_copy: Option<ZeroCopyBuf>,
+ _: (),
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let device_resource = state
@@ -37,26 +35,11 @@ pub fn op_webgpu_create_shader_module(
.get::<super::WebGpuDevice>(args.device_rid)?;
let device = device_resource.0;
- let source = match args.code {
- Some(code) => {
- wgpu_core::pipeline::ShaderModuleSource::Wgsl(Cow::from(code))
- }
- None => wgpu_core::pipeline::ShaderModuleSource::SpirV(Cow::from(unsafe {
- match &zero_copy {
- Some(zero_copy) => {
- let (prefix, data, suffix) = zero_copy.align_to::<u32>();
- assert!(prefix.is_empty());
- assert!(suffix.is_empty());
- data
- }
- None => return Err(null_opbuf()),
- }
- })),
- };
+ let source =
+ wgpu_core::pipeline::ShaderModuleSource::Wgsl(Cow::from(args.code));
let descriptor = wgpu_core::pipeline::ShaderModuleDescriptor {
label: args.label.map(Cow::from),
- flags: wgpu_types::ShaderFlags::all(),
};
gfx_put!(device => instance.device_create_shader_module(
diff --git a/ext/webgpu/texture.rs b/ext/webgpu/texture.rs
index 4829811e2..a0ea7a1bd 100644
--- a/ext/webgpu/texture.rs
+++ b/ext/webgpu/texture.rs
@@ -171,7 +171,7 @@ pub fn op_webgpu_create_texture(
None => wgpu_types::TextureDimension::D2,
},
format: serialize_texture_format(&args.format)?,
- usage: wgpu_types::TextureUsage::from_bits(args.usage).unwrap(),
+ usage: wgpu_types::TextureUsages::from_bits(args.usage).unwrap(),
};
gfx_put!(device => instance.device_create_texture(
diff --git a/ext/webgpu/webgpu.idl b/ext/webgpu/webgpu.idl
index b2a536f2f..026506996 100644
--- a/ext/webgpu/webgpu.idl
+++ b/ext/webgpu/webgpu.idl
@@ -6,7 +6,7 @@ dictionary GPUObjectDescriptorBase {
USVString label;
};
-[Exposed=Window]
+[Exposed=(Window, DedicatedWorker)]
interface GPUSupportedLimits {
readonly attribute unsigned long maxTextureDimension1D;
readonly attribute unsigned long maxTextureDimension2D;
@@ -20,8 +20,8 @@ interface GPUSupportedLimits {
readonly attribute unsigned long maxStorageBuffersPerShaderStage;
readonly attribute unsigned long maxStorageTexturesPerShaderStage;
readonly attribute unsigned long maxUniformBuffersPerShaderStage;
- readonly attribute unsigned long maxUniformBufferBindingSize;
- readonly attribute unsigned long maxStorageBufferBindingSize;
+ readonly attribute unsigned long long maxUniformBufferBindingSize;
+ readonly attribute unsigned long long maxStorageBufferBindingSize;
readonly attribute unsigned long minUniformBufferOffsetAlignment;
readonly attribute unsigned long minStorageBufferOffsetAlignment;
readonly attribute unsigned long maxVertexBuffers;
@@ -29,11 +29,14 @@ interface GPUSupportedLimits {
readonly attribute unsigned long maxVertexBufferArrayStride;
readonly attribute unsigned long maxInterStageShaderComponents;
readonly attribute unsigned long maxComputeWorkgroupStorageSize;
- readonly attribute unsigned long maxComputeWorkgroupInvocations;
- readonly attribute unsigned long maxComputePerDimensionDispatchSize;
+ readonly attribute unsigned long maxComputeInvocationsPerWorkgroup;
+ readonly attribute unsigned long maxComputeWorkgroupSizeX;
+ readonly attribute unsigned long maxComputeWorkgroupSizeY;
+ readonly attribute unsigned long maxComputeWorkgroupSizeZ;
+ readonly attribute unsigned long maxComputeWorkgroupsPerDimension;
};
-[Exposed=Window]
+[Exposed=(Window, DedicatedWorker)]
interface GPUSupportedFeatures {
readonly setlike<DOMString>;
};
@@ -55,7 +58,7 @@ interface GPU {
dictionary GPURequestAdapterOptions {
GPUPowerPreference powerPreference;
- boolean forceSoftware = false;
+ boolean forceFallbackAdapter = false;
};
enum GPUPowerPreference {
@@ -63,19 +66,19 @@ enum GPUPowerPreference {
"high-performance"
};
-[Exposed=Window]
+[Exposed=(Window, DedicatedWorker)]
interface GPUAdapter {
readonly attribute DOMString name;
[SameObject] readonly attribute GPUSupportedFeatures features;
[SameObject] readonly attribute GPUSupportedLimits limits;
- readonly attribute boolean isSoftware;
+ readonly attribute boolean isFallbackAdapter;
Promise<GPUDevice> requestDevice(optional GPUDeviceDescriptor descriptor = {});
};
dictionary GPUDeviceDescriptor : GPUObjectDescriptorBase {
sequence<GPUFeatureName> requiredFeatures = [];
- record<DOMString, GPUSize32> requiredLimits = {};
+ record<DOMString, GPUSize64> requiredLimits = {};
};
enum GPUFeatureName {
@@ -87,7 +90,7 @@ enum GPUFeatureName {
"timestamp-query",
};
-[Exposed=(Window, DedicatedWorker), Serializable]
+[Exposed=(Window, DedicatedWorker)]
interface GPUDevice : EventTarget {
[SameObject] readonly attribute GPUSupportedFeatures features;
[SameObject] readonly attribute GPUSupportedLimits limits;
@@ -117,7 +120,7 @@ interface GPUDevice : EventTarget {
};
GPUDevice includes GPUObjectBase;
-[Exposed=Window, Serializable]
+[Exposed=(Window, DedicatedWorker)]
interface GPUBuffer {
Promise<undefined> mapAsync(GPUMapModeFlags mode, optional GPUSize64 offset = 0, optional GPUSize64 size);
ArrayBuffer getMappedRange(optional GPUSize64 offset = 0, optional GPUSize64 size);
@@ -134,7 +137,7 @@ dictionary GPUBufferDescriptor : GPUObjectDescriptorBase {
};
typedef [EnforceRange] unsigned long GPUBufferUsageFlags;
-[Exposed=Window]
+[Exposed=(Window, DedicatedWorker)]
interface GPUBufferUsage {
const GPUFlagsConstant MAP_READ = 0x0001;
const GPUFlagsConstant MAP_WRITE = 0x0002;
@@ -149,13 +152,13 @@ interface GPUBufferUsage {
};
typedef [EnforceRange] unsigned long GPUMapModeFlags;
-[Exposed=Window]
+[Exposed=(Window, DedicatedWorker)]
interface GPUMapMode {
const GPUFlagsConstant READ = 0x0001;
const GPUFlagsConstant WRITE = 0x0002;
};
-[Exposed=Window, Serializable]
+[Exposed=(Window, DedicatedWorker)]
interface GPUTexture {
GPUTextureView createView(optional GPUTextureViewDescriptor descriptor = {});
@@ -179,16 +182,16 @@ enum GPUTextureDimension {
};
typedef [EnforceRange] unsigned long GPUTextureUsageFlags;
-[Exposed=Window]
+[Exposed=(Window, DedicatedWorker)]
interface GPUTextureUsage {
const GPUFlagsConstant COPY_SRC = 0x01;
const GPUFlagsConstant COPY_DST = 0x02;
- const GPUFlagsConstant SAMPLED = 0x04;
- const GPUFlagsConstant STORAGE = 0x08;
+ const GPUFlagsConstant TEXTURE_BINDING = 0x04;
+ const GPUFlagsConstant STORAGE_BINDING = 0x08;
const GPUFlagsConstant RENDER_ATTACHMENT = 0x10;
};
-[Exposed=Window]
+[Exposed=(Window, DedicatedWorker)]
interface GPUTextureView {
};
GPUTextureView includes GPUObjectBase;
@@ -297,7 +300,7 @@ enum GPUTextureFormat {
"depth32float-stencil8",
};
-[Exposed=Window]
+[Exposed=(Window, DedicatedWorker)]
interface GPUSampler {
};
GPUSampler includes GPUObjectBase;
@@ -310,7 +313,7 @@ dictionary GPUSamplerDescriptor : GPUObjectDescriptorBase {
GPUFilterMode minFilter = "nearest";
GPUFilterMode mipmapFilter = "nearest";
float lodMinClamp = 0;
- float lodMaxClamp = 0xffffffff; // TODO: What should this be? Was Number.MAX_VALUE.
+ float lodMaxClamp = 32;
GPUCompareFunction compare;
[Clamp] unsigned short maxAnisotropy = 1;
};
@@ -337,7 +340,7 @@ enum GPUCompareFunction {
"always"
};
-[Exposed=Window, Serializable]
+[Exposed=(Window, DedicatedWorker)]
interface GPUBindGroupLayout {
};
GPUBindGroupLayout includes GPUObjectBase;
@@ -347,7 +350,7 @@ dictionary GPUBindGroupLayoutDescriptor : GPUObjectDescriptorBase {
};
typedef [EnforceRange] unsigned long GPUShaderStageFlags;
-[Exposed=Window]
+[Exposed=(Window, DedicatedWorker)]
interface GPUShaderStage {
const GPUFlagsConstant VERTEX = 0x1;
const GPUFlagsConstant FRAGMENT = 0x2;
@@ -401,17 +404,16 @@ dictionary GPUTextureBindingLayout {
};
enum GPUStorageTextureAccess {
- "read-only",
"write-only",
};
dictionary GPUStorageTextureBindingLayout {
- required GPUStorageTextureAccess access;
+ GPUStorageTextureAccess access = "write-only";
required GPUTextureFormat format;
GPUTextureViewDimension viewDimension = "2d";
};
-[Exposed=Window]
+[Exposed=(Window, DedicatedWorker)]
interface GPUBindGroup {
};
GPUBindGroup includes GPUObjectBase;
@@ -434,7 +436,7 @@ dictionary GPUBufferBinding {
GPUSize64 size;
};
-[Exposed=Window, Serializable]
+[Exposed=(Window, DedicatedWorker)]
interface GPUPipelineLayout {
};
GPUPipelineLayout includes GPUObjectBase;
@@ -443,7 +445,7 @@ dictionary GPUPipelineLayoutDescriptor : GPUObjectDescriptorBase {
required sequence<GPUBindGroupLayout> bindGroupLayouts;
};
-[Exposed=Window, Serializable]
+[Exposed=(Window, DedicatedWorker)]
interface GPUShaderModule {
Promise<GPUCompilationInfo> compilationInfo();
};
@@ -460,7 +462,7 @@ enum GPUCompilationMessageType {
"info"
};
-[Exposed=Window, Serializable]
+[Exposed=(Window, DedicatedWorker), Serializable]
interface GPUCompilationMessage {
readonly attribute DOMString message;
readonly attribute GPUCompilationMessageType type;
@@ -470,7 +472,7 @@ interface GPUCompilationMessage {
readonly attribute unsigned long long length;
};
-[Exposed=Window, Serializable]
+[Exposed=(Window, DedicatedWorker), Serializable]
interface GPUCompilationInfo {
readonly attribute FrozenArray<GPUCompilationMessage> messages;
};
@@ -491,7 +493,7 @@ dictionary GPUProgrammableStage {
typedef double GPUPipelineConstantValue; // May represent WGSL’s bool, f32, i32, u32.
-[Exposed=Window, Serializable]
+[Exposed=(Window, DedicatedWorker)]
interface GPUComputePipeline {
};
GPUComputePipeline includes GPUObjectBase;
@@ -501,7 +503,7 @@ dictionary GPUComputePipelineDescriptor : GPUPipelineDescriptorBase {
required GPUProgrammableStage compute;
};
-[Exposed=Window, Serializable]
+[Exposed=(Window, DedicatedWorker)]
interface GPURenderPipeline {
};
GPURenderPipeline includes GPUObjectBase;
@@ -567,7 +569,7 @@ dictionary GPUBlendState {
};
typedef [EnforceRange] unsigned long GPUColorWriteFlags;
-[Exposed=Window]
+[Exposed=(Window, DedicatedWorker)]
interface GPUColorWrite {
const GPUFlagsConstant RED = 0x1;
const GPUFlagsConstant GREEN = 0x2;
@@ -679,7 +681,7 @@ enum GPUVertexFormat {
"sint32x4",
};
-enum GPUInputStepMode {
+enum GPUVertexStepMode {
"vertex",
"instance"
};
@@ -690,7 +692,7 @@ dictionary GPUVertexState: GPUProgrammableStage {
dictionary GPUVertexBufferLayout {
required GPUSize64 arrayStride;
- GPUInputStepMode stepMode = "vertex";
+ GPUVertexStepMode stepMode = "vertex";
required sequence<GPUVertexAttribute> attributes;
};
@@ -701,7 +703,7 @@ dictionary GPUVertexAttribute {
required GPUIndex32 shaderLocation;
};
-[Exposed=Window]
+[Exposed=(Window, DedicatedWorker)]
interface GPUCommandBuffer {
readonly attribute Promise<double> executionTime;
};
@@ -710,7 +712,7 @@ GPUCommandBuffer includes GPUObjectBase;
dictionary GPUCommandBufferDescriptor : GPUObjectDescriptorBase {
};
-[Exposed=Window]
+[Exposed=(Window, DedicatedWorker)]
interface GPUCommandEncoder {
GPURenderPassEncoder beginRenderPass(GPURenderPassDescriptor descriptor);
GPUComputePassEncoder beginComputePass(optional GPUComputePassDescriptor descriptor = {});
@@ -756,8 +758,6 @@ GPUCommandEncoder includes GPUObjectBase;
dictionary GPUCommandEncoderDescriptor : GPUObjectDescriptorBase {
boolean measureExecutionTime = false;
-
- // TODO: reusability flag?
};
dictionary GPUImageDataLayout {
@@ -791,7 +791,7 @@ interface mixin GPUProgrammablePassEncoder {
undefined insertDebugMarker(USVString markerLabel);
};
-[Exposed=Window]
+[Exposed=(Window, DedicatedWorker)]
interface GPUComputePassEncoder {
undefined setPipeline(GPUComputePipeline pipeline);
undefined dispatch(GPUSize32 x, optional GPUSize32 y = 1, optional GPUSize32 z = 1);
@@ -827,7 +827,7 @@ interface mixin GPURenderEncoderBase {
undefined drawIndexedIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
};
-[Exposed=Window]
+[Exposed=(Window, DedicatedWorker)]
interface GPURenderPassEncoder {
undefined setViewport(float x, float y,
float width, float height,
@@ -889,7 +889,13 @@ enum GPUStoreOp {
"discard"
};
-[Exposed=Window]
+dictionary GPURenderPassLayout: GPUObjectDescriptorBase {
+ required sequence<GPUTextureFormat> colorFormats;
+ GPUTextureFormat depthStencilFormat;
+ GPUSize32 sampleCount = 1;
+};
+
+[Exposed=(Window, DedicatedWorker)]
interface GPURenderBundle {
};
GPURenderBundle includes GPUObjectBase;
@@ -897,7 +903,7 @@ GPURenderBundle includes GPUObjectBase;
dictionary GPURenderBundleDescriptor : GPUObjectDescriptorBase {
};
-[Exposed=Window]
+[Exposed=(Window, DedicatedWorker)]
interface GPURenderBundleEncoder {
GPURenderBundle finish(optional GPURenderBundleDescriptor descriptor = {});
};
@@ -905,13 +911,12 @@ GPURenderBundleEncoder includes GPUObjectBase;
GPURenderBundleEncoder includes GPUProgrammablePassEncoder;
GPURenderBundleEncoder includes GPURenderEncoderBase;
-dictionary GPURenderBundleEncoderDescriptor : GPUObjectDescriptorBase {
- required sequence<GPUTextureFormat> colorFormats;
- GPUTextureFormat depthStencilFormat;
- GPUSize32 sampleCount = 1;
+dictionary GPURenderBundleEncoderDescriptor : GPURenderPassLayout {
+ boolean depthReadOnly = false;
+ boolean stencilReadOnly = false;
};
-[Exposed=Window]
+[Exposed=(Window, DedicatedWorker)]
interface GPUQueue {
undefined submit(sequence<GPUCommandBuffer> commandBuffers);
@@ -932,7 +937,7 @@ interface GPUQueue {
};
GPUQueue includes GPUObjectBase;
-[Exposed=Window]
+[Exposed=(Window, DedicatedWorker)]
interface GPUQuerySet {
undefined destroy();
};
@@ -962,7 +967,7 @@ enum GPUDeviceLostReason {
"destroyed",
};
-[Exposed=Window]
+[Exposed=(Window, DedicatedWorker)]
interface GPUDeviceLostInfo {
readonly attribute (GPUDeviceLostReason or undefined) reason;
readonly attribute DOMString message;
@@ -977,12 +982,12 @@ enum GPUErrorFilter {
"validation"
};
-[Exposed=Window]
+[Exposed=(Window, DedicatedWorker)]
interface GPUOutOfMemoryError {
constructor();
};
-[Exposed=Window]
+[Exposed=(Window, DedicatedWorker)]
interface GPUValidationError {
constructor(DOMString message);
readonly attribute DOMString message;