mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05:00
chore: update webgpu (#17534)
This commit is contained in:
parent
266915d5ce
commit
3035dee9f1
24 changed files with 914 additions and 408 deletions
81
Cargo.lock
generated
81
Cargo.lock
generated
|
@ -123,9 +123,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ash"
|
name = "ash"
|
||||||
version = "0.37.0+1.3.209"
|
version = "0.37.2+1.3.238"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "006ca68e0f2b03f22d6fa9f2860f85aed430d257fec20f8879b2145e7c7ae1a6"
|
checksum = "28bf19c1f0a470be5fbf7522a308a05df06610252c5bcf5143e1b23f629a9a03"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libloading",
|
"libloading",
|
||||||
]
|
]
|
||||||
|
@ -289,16 +289,6 @@ version = "1.3.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bitflags_serde_shim"
|
|
||||||
version = "0.2.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "25c3d626f0280ec39b33a6fc5c6c1067432b4c41e94aee40ded197a6649bf025"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags",
|
|
||||||
"serde",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "block"
|
name = "block"
|
||||||
version = "0.1.6"
|
version = "0.1.6"
|
||||||
|
@ -407,12 +397,6 @@ version = "1.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cfg_aliases"
|
|
||||||
version = "0.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chrono"
|
name = "chrono"
|
||||||
version = "0.4.22"
|
version = "0.4.22"
|
||||||
|
@ -522,12 +506,6 @@ version = "0.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e"
|
checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "copyless"
|
|
||||||
version = "0.1.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a2df960f5d869b2dd8532793fde43eb5427cceb126c929747a26823ab0eeb536"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "core-foundation"
|
name = "core-foundation"
|
||||||
version = "0.9.3"
|
version = "0.9.3"
|
||||||
|
@ -685,9 +663,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "d3d12"
|
name = "d3d12"
|
||||||
version = "0.5.0"
|
version = "0.6.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "827914e1f53b1e0e025ecd3d967a7836b7bcb54520f90e21ef8df7b4d88a2759"
|
checksum = "d8f0de2f5a8e7bd4a9eec0e3c781992a4ce1724f68aec7d7a3715344de8b39da"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"libloading",
|
"libloading",
|
||||||
|
@ -1288,6 +1266,7 @@ name = "deno_webgpu"
|
||||||
version = "0.87.0"
|
version = "0.87.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"deno_core",
|
"deno_core",
|
||||||
|
"raw-window-handle",
|
||||||
"serde",
|
"serde",
|
||||||
"tokio",
|
"tokio",
|
||||||
"wgpu-core",
|
"wgpu-core",
|
||||||
|
@ -2023,9 +2002,9 @@ checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "glow"
|
name = "glow"
|
||||||
version = "0.11.2"
|
version = "0.12.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d8bd5877156a19b8ac83a29b2306fe20537429d318f3ff0a1a2119f8d9c61919"
|
checksum = "8edf6019dff2d92ad27c1e3ff82ad50a0aea5b01370353cc928bfdc33e95925c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"slotmap",
|
"slotmap",
|
||||||
|
@ -2363,12 +2342,6 @@ dependencies = [
|
||||||
"generic-array 0.14.6",
|
"generic-array 0.14.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "inplace_it"
|
|
||||||
version = "0.3.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e567468c50f3d4bc7397702e09b380139f9b9288b4e909b070571007f8b5bf78"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "instant"
|
name = "instant"
|
||||||
version = "0.1.12"
|
version = "0.1.12"
|
||||||
|
@ -2798,9 +2771,9 @@ checksum = "f13de1c3edc9a5b9dc3a1029f56e9ab3eba34640010aff4fc01044c42ef67afa"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "naga"
|
name = "naga"
|
||||||
version = "0.9.0"
|
version = "0.11.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5f50357e1167a3ab92d6b3c7f4bf5f7fd13fde3f4b28bf0d5ea07b5100fdb6c0"
|
checksum = "5eafe22a23b797c9bc227c6c896419b26b5bb88fa903417a3adaed08778850d5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bit-set",
|
"bit-set",
|
||||||
"bitflags",
|
"bitflags",
|
||||||
|
@ -3504,9 +3477,9 @@ checksum = "63e935c45e09cc6dcf00d2f0b2d630a58f4095320223d47fc68918722f0538b6"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "raw-window-handle"
|
name = "raw-window-handle"
|
||||||
version = "0.4.3"
|
version = "0.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b800beb9b6e7d2df1fe337c9e3d04e3af22a124460fb4c30fcc22c9117cefb41"
|
checksum = "ed7e3d950b66e19e0c372f3fa3fbbcf85b1746b571f74e0c2af6042a5c93420a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cty",
|
"cty",
|
||||||
]
|
]
|
||||||
|
@ -3552,12 +3525,6 @@ dependencies = [
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "renderdoc-sys"
|
|
||||||
version = "0.7.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f1382d1f0a252c4bf97dc20d979a2fdd05b024acd7c2ed0f7595d7817666a157"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "reqwest"
|
name = "reqwest"
|
||||||
version = "0.11.11"
|
version = "0.11.11"
|
||||||
|
@ -3644,9 +3611,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ron"
|
name = "ron"
|
||||||
version = "0.7.1"
|
version = "0.8.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "88073939a61e5b7680558e6be56b419e208420c2adb92be54921fa6b72283f1a"
|
checksum = "300a51053b1cb55c80b7a9fde4120726ddf25ca241a1cbb926626f62fb136bff"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"bitflags",
|
"bitflags",
|
||||||
|
@ -5541,21 +5508,20 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wgpu-core"
|
name = "wgpu-core"
|
||||||
version = "0.13.2"
|
version = "0.15.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "89b92788dec9d0c1bed849a1b83f01b2ee12819bf04a79c90f68e4173f7b5ba2"
|
checksum = "be1f61be28e557a6ecb2506cac06c63fae3b6d302a006f38195a7a80995abeb9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arrayvec",
|
"arrayvec",
|
||||||
"bit-vec",
|
"bit-vec",
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"cfg_aliases",
|
|
||||||
"codespan-reporting",
|
"codespan-reporting",
|
||||||
"copyless",
|
|
||||||
"fxhash",
|
"fxhash",
|
||||||
"log",
|
"log",
|
||||||
"naga",
|
"naga",
|
||||||
"parking_lot 0.12.1",
|
"parking_lot 0.12.1",
|
||||||
"profiling",
|
"profiling",
|
||||||
|
"raw-window-handle",
|
||||||
"ron",
|
"ron",
|
||||||
"serde",
|
"serde",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
|
@ -5567,9 +5533,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wgpu-hal"
|
name = "wgpu-hal"
|
||||||
version = "0.13.2"
|
version = "0.15.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "20cbdfc3d0637dba3d5536b93adef3d26023a0b96f0e1ee5ee9560a401d9f646"
|
checksum = "82e95792925fe3d58950b9a5c2a191caa145e2bc570e2d233f0d7320f6a8e814"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"android_system_properties",
|
"android_system_properties",
|
||||||
"arrayvec",
|
"arrayvec",
|
||||||
|
@ -5584,9 +5550,9 @@ dependencies = [
|
||||||
"glow",
|
"glow",
|
||||||
"gpu-alloc",
|
"gpu-alloc",
|
||||||
"gpu-descriptor",
|
"gpu-descriptor",
|
||||||
"inplace_it",
|
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"khronos-egl",
|
"khronos-egl",
|
||||||
|
"libc",
|
||||||
"libloading",
|
"libloading",
|
||||||
"log",
|
"log",
|
||||||
"metal",
|
"metal",
|
||||||
|
@ -5596,7 +5562,7 @@ dependencies = [
|
||||||
"profiling",
|
"profiling",
|
||||||
"range-alloc",
|
"range-alloc",
|
||||||
"raw-window-handle",
|
"raw-window-handle",
|
||||||
"renderdoc-sys",
|
"smallvec",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
"web-sys",
|
"web-sys",
|
||||||
|
@ -5606,13 +5572,14 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wgpu-types"
|
name = "wgpu-types"
|
||||||
version = "0.13.2"
|
version = "0.15.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1f762cbc08e1a51389859cf9c199c7aef544789cf3510889aab12c607f701604"
|
checksum = "ecf8cfcbf98f94cc8bd5981544c687140cf9d3948e2ab83849367ead2cd737cf"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"bitflags_serde_shim",
|
"js-sys",
|
||||||
"serde",
|
"serde",
|
||||||
|
"web-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -121,6 +121,11 @@ url = { version = "2.3.1", features = ["serde", "expose_internals"] }
|
||||||
uuid = { version = "=1.1.2", features = ["v4"] }
|
uuid = { version = "=1.1.2", features = ["v4"] }
|
||||||
zstd = "=0.11.2"
|
zstd = "=0.11.2"
|
||||||
|
|
||||||
|
# webgpu
|
||||||
|
raw-window-handle = "0.5.0"
|
||||||
|
wgpu-core = "0.15"
|
||||||
|
wgpu-types = "0.15"
|
||||||
|
|
||||||
# macros
|
# macros
|
||||||
proc-macro2 = "1"
|
proc-macro2 = "1"
|
||||||
quote = "1"
|
quote = "1"
|
||||||
|
|
58
cli/tsc/dts/lib.deno_webgpu.d.ts
vendored
58
cli/tsc/dts/lib.deno_webgpu.d.ts
vendored
|
@ -22,6 +22,7 @@ declare class GPUSupportedLimits {
|
||||||
maxTextureDimension3D?: number;
|
maxTextureDimension3D?: number;
|
||||||
maxTextureArrayLayers?: number;
|
maxTextureArrayLayers?: number;
|
||||||
maxBindGroups?: number;
|
maxBindGroups?: number;
|
||||||
|
maxBindingsPerBindGroup?: number;
|
||||||
maxDynamicUniformBuffersPerPipelineLayout?: number;
|
maxDynamicUniformBuffersPerPipelineLayout?: number;
|
||||||
maxDynamicStorageBuffersPerPipelineLayout?: number;
|
maxDynamicStorageBuffersPerPipelineLayout?: number;
|
||||||
maxSampledTexturesPerShaderStage?: number;
|
maxSampledTexturesPerShaderStage?: number;
|
||||||
|
@ -34,6 +35,7 @@ declare class GPUSupportedLimits {
|
||||||
minUniformBufferOffsetAlignment?: number;
|
minUniformBufferOffsetAlignment?: number;
|
||||||
minStorageBufferOffsetAlignment?: number;
|
minStorageBufferOffsetAlignment?: number;
|
||||||
maxVertexBuffers?: number;
|
maxVertexBuffers?: number;
|
||||||
|
maxBufferSize?: number;
|
||||||
maxVertexAttributes?: number;
|
maxVertexAttributes?: number;
|
||||||
maxVertexBufferArrayStride?: number;
|
maxVertexBufferArrayStride?: number;
|
||||||
maxInterStageShaderComponents?: number;
|
maxInterStageShaderComponents?: number;
|
||||||
|
@ -109,7 +111,6 @@ declare interface GPUDeviceDescriptor extends GPUObjectDescriptorBase {
|
||||||
/** @category WebGPU */
|
/** @category WebGPU */
|
||||||
declare type GPUFeatureName =
|
declare type GPUFeatureName =
|
||||||
| "depth-clip-control"
|
| "depth-clip-control"
|
||||||
| "depth24unorm-stencil8"
|
|
||||||
| "depth32float-stencil8"
|
| "depth32float-stencil8"
|
||||||
| "pipeline-statistics-query"
|
| "pipeline-statistics-query"
|
||||||
| "texture-compression-bc"
|
| "texture-compression-bc"
|
||||||
|
@ -139,9 +140,6 @@ declare class GPUDevice extends EventTarget implements GPUObjectBase {
|
||||||
readonly lost: Promise<GPUDeviceLostInfo>;
|
readonly lost: Promise<GPUDeviceLostInfo>;
|
||||||
pushErrorScope(filter: GPUErrorFilter): undefined;
|
pushErrorScope(filter: GPUErrorFilter): undefined;
|
||||||
popErrorScope(): Promise<GPUError | null>;
|
popErrorScope(): Promise<GPUError | null>;
|
||||||
onuncapturederror:
|
|
||||||
| ((this: GPUDevice, ev: GPUUncapturedErrorEvent) => any)
|
|
||||||
| null;
|
|
||||||
|
|
||||||
readonly features: GPUSupportedFeatures;
|
readonly features: GPUSupportedFeatures;
|
||||||
readonly limits: GPUSupportedLimits;
|
readonly limits: GPUSupportedLimits;
|
||||||
|
@ -189,6 +187,10 @@ declare class GPUDevice extends EventTarget implements GPUObjectBase {
|
||||||
declare class GPUBuffer implements GPUObjectBase {
|
declare class GPUBuffer implements GPUObjectBase {
|
||||||
label: string;
|
label: string;
|
||||||
|
|
||||||
|
readonly size: number;
|
||||||
|
readonly usage: GPUBufferUsageFlags;
|
||||||
|
readonly mapState: GPUBufferMapState;
|
||||||
|
|
||||||
mapAsync(
|
mapAsync(
|
||||||
mode: GPUMapModeFlags,
|
mode: GPUMapModeFlags,
|
||||||
offset?: number,
|
offset?: number,
|
||||||
|
@ -200,6 +202,9 @@ declare class GPUBuffer implements GPUObjectBase {
|
||||||
destroy(): undefined;
|
destroy(): undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @category WebGPU */
|
||||||
|
declare type GPUBufferMapState = "unmapped" | "pending" | "mapped";
|
||||||
|
|
||||||
/** @category WebGPU */
|
/** @category WebGPU */
|
||||||
declare interface GPUBufferDescriptor extends GPUObjectDescriptorBase {
|
declare interface GPUBufferDescriptor extends GPUObjectDescriptorBase {
|
||||||
size: number;
|
size: number;
|
||||||
|
@ -239,6 +244,15 @@ declare class GPUTexture implements GPUObjectBase {
|
||||||
|
|
||||||
createView(descriptor?: GPUTextureViewDescriptor): GPUTextureView;
|
createView(descriptor?: GPUTextureViewDescriptor): GPUTextureView;
|
||||||
destroy(): undefined;
|
destroy(): undefined;
|
||||||
|
|
||||||
|
readonly width: number;
|
||||||
|
readonly height: number;
|
||||||
|
readonly depthOrArrayLayers: number;
|
||||||
|
readonly mipLevelCount: number;
|
||||||
|
readonly sampleCount: number;
|
||||||
|
readonly dimension: GPUTextureDimension;
|
||||||
|
readonly format: GPUTextureFormat;
|
||||||
|
readonly usage: GPUTextureUsageFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @category WebGPU */
|
/** @category WebGPU */
|
||||||
|
@ -249,6 +263,7 @@ declare interface GPUTextureDescriptor extends GPUObjectDescriptorBase {
|
||||||
dimension?: GPUTextureDimension;
|
dimension?: GPUTextureDimension;
|
||||||
format: GPUTextureFormat;
|
format: GPUTextureFormat;
|
||||||
usage: GPUTextureUsageFlags;
|
usage: GPUTextureUsageFlags;
|
||||||
|
viewFormats?: GPUTextureFormat[];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @category WebGPU */
|
/** @category WebGPU */
|
||||||
|
@ -337,7 +352,6 @@ declare type GPUTextureFormat =
|
||||||
| "depth24plus"
|
| "depth24plus"
|
||||||
| "depth24plus-stencil8"
|
| "depth24plus-stencil8"
|
||||||
| "depth32float"
|
| "depth32float"
|
||||||
| "depth24unorm-stencil8"
|
|
||||||
| "depth32float-stencil8"
|
| "depth32float-stencil8"
|
||||||
| "bc1-rgba-unorm"
|
| "bc1-rgba-unorm"
|
||||||
| "bc1-rgba-unorm-srgb"
|
| "bc1-rgba-unorm-srgb"
|
||||||
|
@ -814,6 +828,13 @@ declare interface GPUVertexAttribute {
|
||||||
shaderLocation: number;
|
shaderLocation: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @category WebGPU */
|
||||||
|
declare interface GPUImageDataLayout {
|
||||||
|
offset?: number;
|
||||||
|
bytesPerRow?: number;
|
||||||
|
rowsPerImage?: number;
|
||||||
|
}
|
||||||
|
|
||||||
/** @category WebGPU */
|
/** @category WebGPU */
|
||||||
declare class GPUCommandBuffer implements GPUObjectBase {
|
declare class GPUCommandBuffer implements GPUObjectBase {
|
||||||
label: string;
|
label: string;
|
||||||
|
@ -883,13 +904,6 @@ declare class GPUCommandEncoder implements GPUObjectBase {
|
||||||
/** @category WebGPU */
|
/** @category WebGPU */
|
||||||
declare interface GPUCommandEncoderDescriptor extends GPUObjectDescriptorBase {}
|
declare interface GPUCommandEncoderDescriptor extends GPUObjectDescriptorBase {}
|
||||||
|
|
||||||
/** @category WebGPU */
|
|
||||||
declare interface GPUImageDataLayout {
|
|
||||||
offset?: number;
|
|
||||||
bytesPerRow?: number;
|
|
||||||
rowsPerImage?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @category WebGPU */
|
/** @category WebGPU */
|
||||||
declare interface GPUImageCopyBuffer extends GPUImageDataLayout {
|
declare interface GPUImageCopyBuffer extends GPUImageDataLayout {
|
||||||
buffer: GPUBuffer;
|
buffer: GPUBuffer;
|
||||||
|
@ -1091,7 +1105,6 @@ declare class GPURenderPassEncoder
|
||||||
declare interface GPURenderPassDescriptor extends GPUObjectDescriptorBase {
|
declare interface GPURenderPassDescriptor extends GPUObjectDescriptorBase {
|
||||||
colorAttachments: (GPURenderPassColorAttachment | null)[];
|
colorAttachments: (GPURenderPassColorAttachment | null)[];
|
||||||
depthStencilAttachment?: GPURenderPassDepthStencilAttachment;
|
depthStencilAttachment?: GPURenderPassDepthStencilAttachment;
|
||||||
occlusionQuerySet?: GPUQuerySet;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @category WebGPU */
|
/** @category WebGPU */
|
||||||
|
@ -1229,6 +1242,9 @@ declare class GPUQuerySet implements GPUObjectBase {
|
||||||
label: string;
|
label: string;
|
||||||
|
|
||||||
destroy(): undefined;
|
destroy(): undefined;
|
||||||
|
|
||||||
|
readonly type: GPUQueryType;
|
||||||
|
readonly count: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @category WebGPU */
|
/** @category WebGPU */
|
||||||
|
@ -1263,9 +1279,6 @@ declare class GPUError {
|
||||||
readonly message: string;
|
readonly message: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @category WebGPU */
|
|
||||||
declare type GPUErrorFilter = "out-of-memory" | "validation";
|
|
||||||
|
|
||||||
/** @category WebGPU */
|
/** @category WebGPU */
|
||||||
declare class GPUOutOfMemoryError extends GPUError {
|
declare class GPUOutOfMemoryError extends GPUError {
|
||||||
constructor(message: string);
|
constructor(message: string);
|
||||||
|
@ -1277,18 +1290,7 @@ declare class GPUValidationError extends GPUError {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @category WebGPU */
|
/** @category WebGPU */
|
||||||
declare class GPUUncapturedErrorEvent extends Event {
|
declare type GPUErrorFilter = "out-of-memory" | "validation";
|
||||||
constructor(
|
|
||||||
type: string,
|
|
||||||
gpuUncapturedErrorEventInitDict: GPUUncapturedErrorEventInit,
|
|
||||||
);
|
|
||||||
readonly error: GPUError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @category WebGPU */
|
|
||||||
declare interface GPUUncapturedErrorEventInit extends EventInit {
|
|
||||||
error?: GPUError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @category WebGPU */
|
/** @category WebGPU */
|
||||||
declare interface GPUColorDict {
|
declare interface GPUColorDict {
|
||||||
|
|
|
@ -3,16 +3,38 @@
|
||||||
[package]
|
[package]
|
||||||
name = "deno_webgpu"
|
name = "deno_webgpu"
|
||||||
version = "0.87.0"
|
version = "0.87.0"
|
||||||
authors.workspace = true
|
authors = ["the Deno authors"]
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
license.workspace = true
|
license = "MIT"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
repository = "https://github.com/gfx-rs/wgpu"
|
repository = "https://github.com/gfx-rs/wgpu"
|
||||||
description = "WebGPU implementation for Deno"
|
description = "WebGPU implementation for Deno"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
surface = ["wgpu-core/raw-window-handle", "dep:raw-window-handle"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
deno_core.workspace = true
|
deno_core.workspace = true
|
||||||
|
raw-window-handle = { workspace = true, optional = true }
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
tokio.workspace = true
|
tokio.workspace = true
|
||||||
wgpu-core = { version = "0.13", features = ["trace", "replay", "serde"] }
|
wgpu-types = { workspace = true, features = ["trace", "replay", "serde"] }
|
||||||
wgpu-types = { version = "0.13", features = ["trace", "replay", "serde"] }
|
|
||||||
|
[dependencies.wgpu-core]
|
||||||
|
workspace = true
|
||||||
|
features = ["trace", "replay", "serde", "strict_asserts", "wgsl", "gles"]
|
||||||
|
|
||||||
|
# We want the wgpu-core Metal backend on macOS and iOS.
|
||||||
|
[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies.wgpu-core]
|
||||||
|
workspace = true
|
||||||
|
features = ["metal"]
|
||||||
|
|
||||||
|
# We want the wgpu-core Direct3D backends on Windows.
|
||||||
|
[target.'cfg(windows)'.dependencies.wgpu-core]
|
||||||
|
workspace = true
|
||||||
|
features = ["dx11", "dx12"]
|
||||||
|
|
||||||
|
# We want the wgpu-core Vulkan backend on Unix (but not Emscripten) and Windows.
|
||||||
|
[target.'cfg(any(windows, all(unix, not(target_arch = "emscripten"))))'.dependencies.wgpu-core]
|
||||||
|
workspace = true
|
||||||
|
features = ["vulkan"]
|
||||||
|
|
|
@ -57,7 +57,6 @@
|
||||||
const _architecture = Symbol("[[architecture]]");
|
const _architecture = Symbol("[[architecture]]");
|
||||||
const _description = Symbol("[[description]]");
|
const _description = Symbol("[[description]]");
|
||||||
const _limits = Symbol("[[limits]]");
|
const _limits = Symbol("[[limits]]");
|
||||||
const _features = Symbol("[[features]]");
|
|
||||||
const _reason = Symbol("[[reason]]");
|
const _reason = Symbol("[[reason]]");
|
||||||
const _message = Symbol("[[message]]");
|
const _message = Symbol("[[message]]");
|
||||||
const _label = Symbol("[[label]]");
|
const _label = Symbol("[[label]]");
|
||||||
|
@ -68,6 +67,15 @@
|
||||||
const _encoders = Symbol("[[encoders]]");
|
const _encoders = Symbol("[[encoders]]");
|
||||||
const _encoder = Symbol("[[encoder]]");
|
const _encoder = Symbol("[[encoder]]");
|
||||||
const _descriptor = Symbol("[[descriptor]]");
|
const _descriptor = Symbol("[[descriptor]]");
|
||||||
|
const _width = Symbol("[[width]]");
|
||||||
|
const _height = Symbol("[[height]]");
|
||||||
|
const _depthOrArrayLayers = Symbol("[[depthOrArrayLayers]]");
|
||||||
|
const _mipLevelCount = Symbol("[[mipLevelCount]]");
|
||||||
|
const _sampleCount = Symbol("[[sampleCount]]");
|
||||||
|
const _dimension = Symbol("[[dimension]]");
|
||||||
|
const _format = Symbol("[[format]]");
|
||||||
|
const _type = Symbol("[[type]]");
|
||||||
|
const _count = Symbol("[[count]]");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {any} self
|
* @param {any} self
|
||||||
|
@ -175,11 +183,14 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const illegalConstructorKey = Symbol("illegalConstructorKey");
|
||||||
class GPUError extends Error {
|
class GPUError extends Error {
|
||||||
constructor() {
|
constructor(key = null) {
|
||||||
super();
|
super();
|
||||||
|
if (key !== illegalConstructorKey) {
|
||||||
webidl.illegalConstructor();
|
webidl.illegalConstructor();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[_message];
|
[_message];
|
||||||
get message() {
|
get message() {
|
||||||
|
@ -189,20 +200,6 @@
|
||||||
}
|
}
|
||||||
const GPUErrorPrototype = GPUError.prototype;
|
const GPUErrorPrototype = GPUError.prototype;
|
||||||
|
|
||||||
class GPUOutOfMemoryError extends GPUError {
|
|
||||||
name = "GPUOutOfMemoryError";
|
|
||||||
constructor(message) {
|
|
||||||
const prefix = "Failed to construct 'GPUOutOfMemoryError'";
|
|
||||||
webidl.requiredArguments(arguments.length, 1, { prefix });
|
|
||||||
message = webidl.converters.DOMString(message, {
|
|
||||||
prefix,
|
|
||||||
context: "Argument 1",
|
|
||||||
});
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const GPUOutOfMemoryErrorPrototype = GPUOutOfMemoryError.prototype;
|
|
||||||
|
|
||||||
class GPUValidationError extends GPUError {
|
class GPUValidationError extends GPUError {
|
||||||
name = "GPUValidationError";
|
name = "GPUValidationError";
|
||||||
/** @param {string} message */
|
/** @param {string} message */
|
||||||
|
@ -213,11 +210,29 @@
|
||||||
prefix,
|
prefix,
|
||||||
context: "Argument 1",
|
context: "Argument 1",
|
||||||
});
|
});
|
||||||
super(message);
|
super(illegalConstructorKey);
|
||||||
|
this[webidl.brand] = webidl.brand;
|
||||||
|
this[_message] = message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const GPUValidationErrorPrototype = GPUValidationError.prototype;
|
const GPUValidationErrorPrototype = GPUValidationError.prototype;
|
||||||
|
|
||||||
|
class GPUOutOfMemoryError extends GPUError {
|
||||||
|
name = "GPUOutOfMemoryError";
|
||||||
|
constructor(message) {
|
||||||
|
const prefix = "Failed to construct 'GPUOutOfMemoryError'";
|
||||||
|
webidl.requiredArguments(arguments.length, 1, { prefix });
|
||||||
|
message = webidl.converters.DOMString(message, {
|
||||||
|
prefix,
|
||||||
|
context: "Argument 1",
|
||||||
|
});
|
||||||
|
super(illegalConstructorKey);
|
||||||
|
this[webidl.brand] = webidl.brand;
|
||||||
|
this[_message] = message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const GPUOutOfMemoryErrorPrototype = GPUOutOfMemoryError.prototype;
|
||||||
|
|
||||||
class GPU {
|
class GPU {
|
||||||
[webidl.brand] = webidl.brand;
|
[webidl.brand] = webidl.brand;
|
||||||
|
|
||||||
|
@ -314,27 +329,24 @@
|
||||||
const requiredFeatures = descriptor.requiredFeatures ?? [];
|
const requiredFeatures = descriptor.requiredFeatures ?? [];
|
||||||
for (let i = 0; i < requiredFeatures.length; ++i) {
|
for (let i = 0; i < requiredFeatures.length; ++i) {
|
||||||
const feature = requiredFeatures[i];
|
const feature = requiredFeatures[i];
|
||||||
if (!SetPrototypeHas(this[_adapter].features[_features], feature)) {
|
if (
|
||||||
|
!SetPrototypeHas(
|
||||||
|
this[_adapter].features[webidl.setlikeInner],
|
||||||
|
feature,
|
||||||
|
)
|
||||||
|
) {
|
||||||
throw new TypeError(
|
throw new TypeError(
|
||||||
`${prefix}: nonGuaranteedFeatures must be a subset of the adapter features.`,
|
`${prefix}: requiredFeatures must be a subset of the adapter features.`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let requiredLimits = descriptor.requiredLimits;
|
|
||||||
if (requiredLimits) {
|
|
||||||
requiredLimits = {
|
|
||||||
...this[_adapter].limits[_limits],
|
|
||||||
...requiredLimits,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
// TODO(lucacasonato): validate requiredLimits
|
|
||||||
|
|
||||||
const { rid, features, limits } = await core.opAsync(
|
const { rid, features, limits } = await core.opAsync(
|
||||||
"op_webgpu_request_device",
|
"op_webgpu_request_device",
|
||||||
this[_adapter].rid,
|
this[_adapter].rid,
|
||||||
descriptor.label,
|
descriptor.label,
|
||||||
requiredFeatures,
|
requiredFeatures,
|
||||||
requiredLimits,
|
descriptor.requiredLimits,
|
||||||
);
|
);
|
||||||
|
|
||||||
const inner = new InnerGPUDevice({
|
const inner = new InnerGPUDevice({
|
||||||
|
@ -344,9 +356,9 @@
|
||||||
limits: createGPUSupportedLimits(limits),
|
limits: createGPUSupportedLimits(limits),
|
||||||
});
|
});
|
||||||
return createGPUDevice(
|
return createGPUDevice(
|
||||||
descriptor.label ?? null,
|
descriptor.label,
|
||||||
inner,
|
inner,
|
||||||
createGPUQueue(descriptor.label ?? null, inner),
|
createGPUQueue(descriptor.label, inner),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,10 +453,10 @@
|
||||||
}
|
}
|
||||||
const GPUAdapterInfoPrototype = GPUAdapterInfo.prototype;
|
const GPUAdapterInfoPrototype = GPUAdapterInfo.prototype;
|
||||||
|
|
||||||
function createGPUSupportedLimits(features) {
|
function createGPUSupportedLimits(limits) {
|
||||||
/** @type {GPUSupportedLimits} */
|
/** @type {GPUSupportedLimits} */
|
||||||
const adapterFeatures = webidl.createBranded(GPUSupportedLimits);
|
const adapterFeatures = webidl.createBranded(GPUSupportedLimits);
|
||||||
adapterFeatures[_limits] = features;
|
adapterFeatures[_limits] = limits;
|
||||||
return adapterFeatures;
|
return adapterFeatures;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -505,6 +517,14 @@
|
||||||
webidl.assertBranded(this, GPUSupportedLimitsPrototype);
|
webidl.assertBranded(this, GPUSupportedLimitsPrototype);
|
||||||
return this[_limits].maxBindGroups;
|
return this[_limits].maxBindGroups;
|
||||||
}
|
}
|
||||||
|
get maxBindingsPerBindGroup() {
|
||||||
|
webidl.assertBranded(this, GPUSupportedLimitsPrototype);
|
||||||
|
return this[_limits].maxBindingsPerBindGroup;
|
||||||
|
}
|
||||||
|
get maxBufferSize() {
|
||||||
|
webidl.assertBranded(this, GPUSupportedLimitsPrototype);
|
||||||
|
return this[_limits].maxBufferSize;
|
||||||
|
}
|
||||||
get maxDynamicUniformBuffersPerPipelineLayout() {
|
get maxDynamicUniformBuffersPerPipelineLayout() {
|
||||||
webidl.assertBranded(this, GPUSupportedLimitsPrototype);
|
webidl.assertBranded(this, GPUSupportedLimitsPrototype);
|
||||||
return this[_limits].maxDynamicUniformBuffersPerPipelineLayout;
|
return this[_limits].maxDynamicUniformBuffersPerPipelineLayout;
|
||||||
|
@ -611,7 +631,6 @@
|
||||||
constructor() {
|
constructor() {
|
||||||
webidl.illegalConstructor();
|
webidl.illegalConstructor();
|
||||||
}
|
}
|
||||||
|
|
||||||
[SymbolFor("Deno.privateCustomInspect")](inspect) {
|
[SymbolFor("Deno.privateCustomInspect")](inspect) {
|
||||||
return `${this.constructor.name} ${
|
return `${this.constructor.name} ${
|
||||||
inspect([...new SafeArrayIterator(this.values())])
|
inspect([...new SafeArrayIterator(this.values())])
|
||||||
|
@ -923,7 +942,7 @@
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const buffer = createGPUBuffer(
|
const buffer = createGPUBuffer(
|
||||||
descriptor.label ?? null,
|
descriptor.label,
|
||||||
device,
|
device,
|
||||||
rid,
|
rid,
|
||||||
descriptor.size,
|
descriptor.size,
|
||||||
|
@ -955,7 +974,7 @@
|
||||||
device.pushError(err);
|
device.pushError(err);
|
||||||
|
|
||||||
const texture = createGPUTexture(
|
const texture = createGPUTexture(
|
||||||
descriptor.label ?? null,
|
descriptor,
|
||||||
device,
|
device,
|
||||||
rid,
|
rid,
|
||||||
);
|
);
|
||||||
|
@ -975,14 +994,14 @@
|
||||||
context: "Argument 1",
|
context: "Argument 1",
|
||||||
});
|
});
|
||||||
const device = assertDevice(this, { prefix, context: "this" });
|
const device = assertDevice(this, { prefix, context: "this" });
|
||||||
const { rid, err } = ops.op_webgpu_create_sampler({
|
const { rid, err } = ops.op_webgpu_create_texture({
|
||||||
deviceRid: device.rid,
|
deviceRid: device.rid,
|
||||||
...descriptor,
|
...descriptor,
|
||||||
});
|
});
|
||||||
device.pushError(err);
|
device.pushError(err);
|
||||||
|
|
||||||
const sampler = createGPUSampler(
|
const sampler = createGPUSampler(
|
||||||
descriptor.label ?? null,
|
descriptor.label,
|
||||||
device,
|
device,
|
||||||
rid,
|
rid,
|
||||||
);
|
);
|
||||||
|
@ -1006,13 +1025,13 @@
|
||||||
for (let i = 0; i < descriptor.entries.length; ++i) {
|
for (let i = 0; i < descriptor.entries.length; ++i) {
|
||||||
const entry = descriptor.entries[i];
|
const entry = descriptor.entries[i];
|
||||||
|
|
||||||
let count = 0;
|
let j = 0;
|
||||||
if (entry.buffer) count++;
|
if (entry.buffer) j++;
|
||||||
if (entry.sampler) count++;
|
if (entry.sampler) j++;
|
||||||
if (entry.texture) count++;
|
if (entry.texture) j++;
|
||||||
if (entry.storageTexture) count++;
|
if (entry.storageTexture) j++;
|
||||||
|
|
||||||
if (count !== 1) {
|
if (j !== 1) {
|
||||||
throw new Error(); // TODO(@crowlKats): correct error
|
throw new Error(); // TODO(@crowlKats): correct error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1025,7 +1044,7 @@
|
||||||
device.pushError(err);
|
device.pushError(err);
|
||||||
|
|
||||||
const bindGroupLayout = createGPUBindGroupLayout(
|
const bindGroupLayout = createGPUBindGroupLayout(
|
||||||
descriptor.label ?? null,
|
descriptor.label,
|
||||||
device,
|
device,
|
||||||
rid,
|
rid,
|
||||||
);
|
);
|
||||||
|
@ -1067,7 +1086,7 @@
|
||||||
device.pushError(err);
|
device.pushError(err);
|
||||||
|
|
||||||
const pipelineLayout = createGPUPipelineLayout(
|
const pipelineLayout = createGPUPipelineLayout(
|
||||||
descriptor.label ?? null,
|
descriptor.label,
|
||||||
device,
|
device,
|
||||||
rid,
|
rid,
|
||||||
);
|
);
|
||||||
|
@ -1162,7 +1181,7 @@
|
||||||
device.pushError(err);
|
device.pushError(err);
|
||||||
|
|
||||||
const bindGroup = createGPUBindGroup(
|
const bindGroup = createGPUBindGroup(
|
||||||
descriptor.label ?? null,
|
descriptor.label,
|
||||||
device,
|
device,
|
||||||
rid,
|
rid,
|
||||||
);
|
);
|
||||||
|
@ -1186,12 +1205,11 @@
|
||||||
device.rid,
|
device.rid,
|
||||||
descriptor.label,
|
descriptor.label,
|
||||||
descriptor.code,
|
descriptor.code,
|
||||||
descriptor.sourceMap,
|
|
||||||
);
|
);
|
||||||
device.pushError(err);
|
device.pushError(err);
|
||||||
|
|
||||||
const shaderModule = createGPUShaderModule(
|
const shaderModule = createGPUShaderModule(
|
||||||
descriptor.label ?? null,
|
descriptor.label,
|
||||||
device,
|
device,
|
||||||
rid,
|
rid,
|
||||||
);
|
);
|
||||||
|
@ -1245,7 +1263,7 @@
|
||||||
device.pushError(err);
|
device.pushError(err);
|
||||||
|
|
||||||
const computePipeline = createGPUComputePipeline(
|
const computePipeline = createGPUComputePipeline(
|
||||||
descriptor.label ?? null,
|
descriptor.label,
|
||||||
device,
|
device,
|
||||||
rid,
|
rid,
|
||||||
);
|
);
|
||||||
|
@ -1320,7 +1338,7 @@
|
||||||
device.pushError(err);
|
device.pushError(err);
|
||||||
|
|
||||||
const renderPipeline = createGPURenderPipeline(
|
const renderPipeline = createGPURenderPipeline(
|
||||||
descriptor.label ?? null,
|
descriptor.label,
|
||||||
device,
|
device,
|
||||||
rid,
|
rid,
|
||||||
);
|
);
|
||||||
|
@ -1357,7 +1375,7 @@
|
||||||
device.pushError(err);
|
device.pushError(err);
|
||||||
|
|
||||||
const commandEncoder = createGPUCommandEncoder(
|
const commandEncoder = createGPUCommandEncoder(
|
||||||
descriptor.label ?? null,
|
descriptor.label,
|
||||||
device,
|
device,
|
||||||
rid,
|
rid,
|
||||||
);
|
);
|
||||||
|
@ -1382,16 +1400,14 @@
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
const device = assertDevice(this, { prefix, context: "this" });
|
const device = assertDevice(this, { prefix, context: "this" });
|
||||||
const { rid, err } = ops.op_webgpu_create_render_bundle_encoder(
|
const { rid, err } = ops.op_webgpu_create_render_bundle_encoder({
|
||||||
{
|
|
||||||
deviceRid: device.rid,
|
deviceRid: device.rid,
|
||||||
...descriptor,
|
...descriptor,
|
||||||
},
|
});
|
||||||
);
|
|
||||||
device.pushError(err);
|
device.pushError(err);
|
||||||
|
|
||||||
const renderBundleEncoder = createGPURenderBundleEncoder(
|
const renderBundleEncoder = createGPURenderBundleEncoder(
|
||||||
descriptor.label ?? null,
|
descriptor.label,
|
||||||
device,
|
device,
|
||||||
rid,
|
rid,
|
||||||
);
|
);
|
||||||
|
@ -1422,7 +1438,7 @@
|
||||||
device.pushError(err);
|
device.pushError(err);
|
||||||
|
|
||||||
const querySet = createGPUQuerySet(
|
const querySet = createGPUQuerySet(
|
||||||
descriptor.label ?? null,
|
descriptor.label,
|
||||||
device,
|
device,
|
||||||
rid,
|
rid,
|
||||||
descriptor,
|
descriptor,
|
||||||
|
@ -1523,7 +1539,7 @@
|
||||||
* @param {GPUCommandBuffer[]} commandBuffers
|
* @param {GPUCommandBuffer[]} commandBuffers
|
||||||
*/
|
*/
|
||||||
submit(commandBuffers) {
|
submit(commandBuffers) {
|
||||||
webidl.assertBranded(this, GPUQueue.prototype);
|
webidl.assertBranded(this, GPUQueuePrototype);
|
||||||
const prefix = "Failed to execute 'submit' on 'GPUQueue'";
|
const prefix = "Failed to execute 'submit' on 'GPUQueue'";
|
||||||
webidl.requiredArguments(arguments.length, 1, {
|
webidl.requiredArguments(arguments.length, 1, {
|
||||||
prefix,
|
prefix,
|
||||||
|
@ -1546,10 +1562,7 @@
|
||||||
return rid;
|
return rid;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
const { err } = ops.op_webgpu_queue_submit(
|
const { err } = ops.op_webgpu_queue_submit(device.rid, commandBufferRids);
|
||||||
device.rid,
|
|
||||||
commandBufferRids,
|
|
||||||
);
|
|
||||||
for (let i = 0; i < commandBuffers.length; ++i) {
|
for (let i = 0; i < commandBuffers.length; ++i) {
|
||||||
commandBuffers[i][_rid] = undefined;
|
commandBuffers[i][_rid] = undefined;
|
||||||
}
|
}
|
||||||
|
@ -1557,7 +1570,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
onSubmittedWorkDone() {
|
onSubmittedWorkDone() {
|
||||||
webidl.assertBranded(this, GPUQueue.prototype);
|
webidl.assertBranded(this, GPUQueuePrototype);
|
||||||
return PromiseResolve();
|
return PromiseResolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1569,7 +1582,7 @@
|
||||||
* @param {number} [size]
|
* @param {number} [size]
|
||||||
*/
|
*/
|
||||||
writeBuffer(buffer, bufferOffset, data, dataOffset = 0, size) {
|
writeBuffer(buffer, bufferOffset, data, dataOffset = 0, size) {
|
||||||
webidl.assertBranded(this, GPUQueue.prototype);
|
webidl.assertBranded(this, GPUQueuePrototype);
|
||||||
const prefix = "Failed to execute 'writeBuffer' on 'GPUQueue'";
|
const prefix = "Failed to execute 'writeBuffer' on 'GPUQueue'";
|
||||||
webidl.requiredArguments(arguments.length, 3, { prefix });
|
webidl.requiredArguments(arguments.length, 3, { prefix });
|
||||||
buffer = webidl.converters["GPUBuffer"](buffer, {
|
buffer = webidl.converters["GPUBuffer"](buffer, {
|
||||||
|
@ -1622,7 +1635,7 @@
|
||||||
* @param {GPUExtent3D} size
|
* @param {GPUExtent3D} size
|
||||||
*/
|
*/
|
||||||
writeTexture(destination, data, dataLayout, size) {
|
writeTexture(destination, data, dataLayout, size) {
|
||||||
webidl.assertBranded(this, GPUQueue.prototype);
|
webidl.assertBranded(this, GPUQueuePrototype);
|
||||||
const prefix = "Failed to execute 'writeTexture' on 'GPUQueue'";
|
const prefix = "Failed to execute 'writeTexture' on 'GPUQueue'";
|
||||||
webidl.requiredArguments(arguments.length, 4, { prefix });
|
webidl.requiredArguments(arguments.length, 4, { prefix });
|
||||||
destination = webidl.converters.GPUImageCopyTexture(destination, {
|
destination = webidl.converters.GPUImageCopyTexture(destination, {
|
||||||
|
@ -1681,6 +1694,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GPUObjectBaseMixin("GPUQueue", GPUQueue);
|
GPUObjectBaseMixin("GPUQueue", GPUQueue);
|
||||||
|
const GPUQueuePrototype = GPUQueue.prototype;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef CreateGPUBufferOptions
|
* @typedef CreateGPUBufferOptions
|
||||||
|
@ -1716,25 +1730,18 @@
|
||||||
class GPUBuffer {
|
class GPUBuffer {
|
||||||
/** @type {InnerGPUDevice} */
|
/** @type {InnerGPUDevice} */
|
||||||
[_device];
|
[_device];
|
||||||
|
|
||||||
/** @type {number} */
|
/** @type {number} */
|
||||||
[_rid];
|
[_rid];
|
||||||
|
|
||||||
/** @type {number} */
|
/** @type {number} */
|
||||||
[_size];
|
[_size];
|
||||||
|
|
||||||
/** @type {number} */
|
/** @type {number} */
|
||||||
[_usage];
|
[_usage];
|
||||||
|
/** @type {"mapped" | "mapped at creation" | "pending" | "unmapped" | "destroy"} */
|
||||||
/** @type {"mapped" | "mapped at creation" | "mapped pending" | "unmapped" | "destroy"} */
|
|
||||||
[_state];
|
[_state];
|
||||||
|
|
||||||
/** @type {[number, number] | null} */
|
/** @type {[number, number] | null} */
|
||||||
[_mappingRange];
|
[_mappingRange];
|
||||||
|
|
||||||
/** @type {[ArrayBuffer, number, number][] | null} */
|
/** @type {[ArrayBuffer, number, number][] | null} */
|
||||||
[_mappedRanges];
|
[_mappedRanges];
|
||||||
|
|
||||||
/** @type {number} */
|
/** @type {number} */
|
||||||
[_mapMode];
|
[_mapMode];
|
||||||
|
|
||||||
|
@ -1761,13 +1768,33 @@
|
||||||
webidl.illegalConstructor();
|
webidl.illegalConstructor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get size() {
|
||||||
|
webidl.assertBranded(this, GPUBufferPrototype);
|
||||||
|
return this[_size];
|
||||||
|
}
|
||||||
|
|
||||||
|
get usage() {
|
||||||
|
webidl.assertBranded(this, GPUBufferPrototype);
|
||||||
|
return this[_usage];
|
||||||
|
}
|
||||||
|
|
||||||
|
get mapState() {
|
||||||
|
webidl.assertBranded(this, GPUBufferPrototype);
|
||||||
|
const state = this[_state];
|
||||||
|
if (state === "mapped at creation") {
|
||||||
|
return "mapped";
|
||||||
|
} else {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {number} mode
|
* @param {number} mode
|
||||||
* @param {number} offset
|
* @param {number} offset
|
||||||
* @param {number} [size]
|
* @param {number} [size]
|
||||||
*/
|
*/
|
||||||
async mapAsync(mode, offset = 0, size) {
|
async mapAsync(mode, offset = 0, size) {
|
||||||
webidl.assertBranded(this, GPUBuffer.prototype);
|
webidl.assertBranded(this, GPUBufferPrototype);
|
||||||
const prefix = "Failed to execute 'mapAsync' on 'GPUBuffer'";
|
const prefix = "Failed to execute 'mapAsync' on 'GPUBuffer'";
|
||||||
webidl.requiredArguments(arguments.length, 1, { prefix });
|
webidl.requiredArguments(arguments.length, 1, { prefix });
|
||||||
mode = webidl.converters.GPUMapModeFlags(mode, {
|
mode = webidl.converters.GPUMapModeFlags(mode, {
|
||||||
|
@ -1839,7 +1866,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
this[_mapMode] = mode;
|
this[_mapMode] = mode;
|
||||||
this[_state] = "mapping pending";
|
this[_state] = "pending";
|
||||||
const promise = PromisePrototypeThen(
|
const promise = PromisePrototypeThen(
|
||||||
core.opAsync(
|
core.opAsync(
|
||||||
"op_webgpu_buffer_get_map_async",
|
"op_webgpu_buffer_get_map_async",
|
||||||
|
@ -1867,7 +1894,7 @@
|
||||||
* @param {number} size
|
* @param {number} size
|
||||||
*/
|
*/
|
||||||
getMappedRange(offset = 0, size) {
|
getMappedRange(offset = 0, size) {
|
||||||
webidl.assertBranded(this, GPUBuffer.prototype);
|
webidl.assertBranded(this, GPUBufferPrototype);
|
||||||
const prefix = "Failed to execute 'getMappedRange' on 'GPUBuffer'";
|
const prefix = "Failed to execute 'getMappedRange' on 'GPUBuffer'";
|
||||||
offset = webidl.converters.GPUSize64(offset, {
|
offset = webidl.converters.GPUSize64(offset, {
|
||||||
prefix,
|
prefix,
|
||||||
|
@ -1922,7 +1949,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
unmap() {
|
unmap() {
|
||||||
webidl.assertBranded(this, GPUBuffer.prototype);
|
webidl.assertBranded(this, GPUBufferPrototype);
|
||||||
const prefix = "Failed to execute 'unmap' on 'GPUBuffer'";
|
const prefix = "Failed to execute 'unmap' on 'GPUBuffer'";
|
||||||
const device = assertDevice(this, { prefix, context: "this" });
|
const device = assertDevice(this, { prefix, context: "this" });
|
||||||
const bufferRid = assertResource(this, { prefix, context: "this" });
|
const bufferRid = assertResource(this, { prefix, context: "this" });
|
||||||
|
@ -1932,7 +1959,7 @@
|
||||||
"OperationError",
|
"OperationError",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (this[_state] === "mapping pending") {
|
if (this[_state] === "pending") {
|
||||||
// TODO(lucacasonato): this is not spec compliant.
|
// TODO(lucacasonato): this is not spec compliant.
|
||||||
throw new DOMException(
|
throw new DOMException(
|
||||||
`${prefix}: can not unmap while mapping. This is a Deno limitation.`,
|
`${prefix}: can not unmap while mapping. This is a Deno limitation.`,
|
||||||
|
@ -1980,7 +2007,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
webidl.assertBranded(this, GPUBuffer.prototype);
|
webidl.assertBranded(this, GPUBufferPrototype);
|
||||||
this[_cleanup]();
|
this[_cleanup]();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1993,6 +2020,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GPUObjectBaseMixin("GPUBuffer", GPUBuffer);
|
GPUObjectBaseMixin("GPUBuffer", GPUBuffer);
|
||||||
|
const GPUBufferPrototype = GPUBuffer.prototype;
|
||||||
|
|
||||||
class GPUBufferUsage {
|
class GPUBufferUsage {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -2045,18 +2073,26 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string | null} label
|
* @param {GPUTextureDescriptor} descriptor
|
||||||
* @param {InnerGPUDevice} device
|
* @param {InnerGPUDevice} device
|
||||||
* @param {number} rid
|
* @param {number} rid
|
||||||
* @returns {GPUTexture}
|
* @returns {GPUTexture}
|
||||||
*/
|
*/
|
||||||
function createGPUTexture(label, device, rid) {
|
function createGPUTexture(descriptor, device, rid) {
|
||||||
/** @type {GPUTexture} */
|
/** @type {GPUTexture} */
|
||||||
const texture = webidl.createBranded(GPUTexture);
|
const texture = webidl.createBranded(GPUTexture);
|
||||||
texture[_label] = label;
|
texture[_label] = descriptor.label;
|
||||||
texture[_device] = device;
|
texture[_device] = device;
|
||||||
texture[_rid] = rid;
|
texture[_rid] = rid;
|
||||||
texture[_views] = [];
|
texture[_views] = [];
|
||||||
|
texture[_width] = descriptor.size.width;
|
||||||
|
texture[_height] = descriptor.size.height;
|
||||||
|
texture[_depthOrArrayLayers] = descriptor.size.depthOrArrayLayers;
|
||||||
|
texture[_mipLevelCount] = descriptor.mipLevelCount;
|
||||||
|
texture[_sampleCount] = descriptor.sampleCount;
|
||||||
|
texture[_dimension] = descriptor.dimension;
|
||||||
|
texture[_format] = descriptor.format;
|
||||||
|
texture[_usage] = descriptor.usage;
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2068,6 +2104,23 @@
|
||||||
/** @type {WeakRef<GPUTextureView>[]} */
|
/** @type {WeakRef<GPUTextureView>[]} */
|
||||||
[_views];
|
[_views];
|
||||||
|
|
||||||
|
/** @type {number} */
|
||||||
|
[_width];
|
||||||
|
/** @type {number} */
|
||||||
|
[_height];
|
||||||
|
/** @type {number} */
|
||||||
|
[_depthOrArrayLayers];
|
||||||
|
/** @type {number} */
|
||||||
|
[_mipLevelCount];
|
||||||
|
/** @type {number} */
|
||||||
|
[_sampleCount];
|
||||||
|
/** @type {GPUTextureDimension} */
|
||||||
|
[_dimension];
|
||||||
|
/** @type {GPUTextureFormat} */
|
||||||
|
[_format];
|
||||||
|
/** @type {number} */
|
||||||
|
[_usage];
|
||||||
|
|
||||||
[_cleanup]() {
|
[_cleanup]() {
|
||||||
const views = this[_views];
|
const views = this[_views];
|
||||||
while (views.length > 0) {
|
while (views.length > 0) {
|
||||||
|
@ -2092,7 +2145,7 @@
|
||||||
* @param {GPUTextureViewDescriptor} descriptor
|
* @param {GPUTextureViewDescriptor} descriptor
|
||||||
*/
|
*/
|
||||||
createView(descriptor = {}) {
|
createView(descriptor = {}) {
|
||||||
webidl.assertBranded(this, GPUTexture.prototype);
|
webidl.assertBranded(this, GPUTexturePrototype);
|
||||||
const prefix = "Failed to execute 'createView' on 'GPUTexture'";
|
const prefix = "Failed to execute 'createView' on 'GPUTexture'";
|
||||||
webidl.requiredArguments(arguments.length, 0, { prefix });
|
webidl.requiredArguments(arguments.length, 0, { prefix });
|
||||||
descriptor = webidl.converters.GPUTextureViewDescriptor(descriptor, {
|
descriptor = webidl.converters.GPUTextureViewDescriptor(descriptor, {
|
||||||
|
@ -2108,7 +2161,7 @@
|
||||||
device.pushError(err);
|
device.pushError(err);
|
||||||
|
|
||||||
const textureView = createGPUTextureView(
|
const textureView = createGPUTextureView(
|
||||||
descriptor.label ?? null,
|
descriptor.label,
|
||||||
this,
|
this,
|
||||||
rid,
|
rid,
|
||||||
);
|
);
|
||||||
|
@ -2117,10 +2170,50 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
webidl.assertBranded(this, GPUTexture.prototype);
|
webidl.assertBranded(this, GPUTexturePrototype);
|
||||||
this[_cleanup]();
|
this[_cleanup]();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get width() {
|
||||||
|
webidl.assertBranded(this, GPUTexturePrototype);
|
||||||
|
return this[_width];
|
||||||
|
}
|
||||||
|
|
||||||
|
get height() {
|
||||||
|
webidl.assertBranded(this, GPUTexturePrototype);
|
||||||
|
return this[_height];
|
||||||
|
}
|
||||||
|
|
||||||
|
get depthOrArrayLayers() {
|
||||||
|
webidl.assertBranded(this, GPUTexturePrototype);
|
||||||
|
return this[_depthOrArrayLayers];
|
||||||
|
}
|
||||||
|
|
||||||
|
get mipLevelCount() {
|
||||||
|
webidl.assertBranded(this, GPUTexturePrototype);
|
||||||
|
return this[_mipLevelCount];
|
||||||
|
}
|
||||||
|
|
||||||
|
get sampleCount() {
|
||||||
|
webidl.assertBranded(this, GPUTexturePrototype);
|
||||||
|
return this[_sampleCount];
|
||||||
|
}
|
||||||
|
|
||||||
|
get dimension() {
|
||||||
|
webidl.assertBranded(this, GPUTexturePrototype);
|
||||||
|
return this[_dimension];
|
||||||
|
}
|
||||||
|
|
||||||
|
get format() {
|
||||||
|
webidl.assertBranded(this, GPUTexturePrototype);
|
||||||
|
return this[_format];
|
||||||
|
}
|
||||||
|
|
||||||
|
get usage() {
|
||||||
|
webidl.assertBranded(this, GPUTexturePrototype);
|
||||||
|
return this[_usage];
|
||||||
|
}
|
||||||
|
|
||||||
[SymbolFor("Deno.privateCustomInspect")](inspect) {
|
[SymbolFor("Deno.privateCustomInspect")](inspect) {
|
||||||
return `${this.constructor.name} ${
|
return `${this.constructor.name} ${
|
||||||
inspect({
|
inspect({
|
||||||
|
@ -2130,6 +2223,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GPUObjectBaseMixin("GPUTexture", GPUTexture);
|
GPUObjectBaseMixin("GPUTexture", GPUTexture);
|
||||||
|
const GPUTexturePrototype = GPUTexture.prototype;
|
||||||
|
|
||||||
class GPUTextureUsage {
|
class GPUTextureUsage {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -2763,7 +2857,7 @@
|
||||||
);
|
);
|
||||||
|
|
||||||
const renderPassEncoder = createGPURenderPassEncoder(
|
const renderPassEncoder = createGPURenderPassEncoder(
|
||||||
descriptor.label ?? null,
|
descriptor.label,
|
||||||
this,
|
this,
|
||||||
rid,
|
rid,
|
||||||
);
|
);
|
||||||
|
@ -2795,7 +2889,7 @@
|
||||||
);
|
);
|
||||||
|
|
||||||
const computePassEncoder = createGPUComputePassEncoder(
|
const computePassEncoder = createGPUComputePassEncoder(
|
||||||
descriptor.label ?? null,
|
descriptor.label,
|
||||||
this,
|
this,
|
||||||
rid,
|
rid,
|
||||||
);
|
);
|
||||||
|
@ -3310,7 +3404,7 @@
|
||||||
this[_rid] = undefined;
|
this[_rid] = undefined;
|
||||||
|
|
||||||
const commandBuffer = createGPUCommandBuffer(
|
const commandBuffer = createGPUCommandBuffer(
|
||||||
descriptor.label ?? null,
|
descriptor.label,
|
||||||
device,
|
device,
|
||||||
rid,
|
rid,
|
||||||
);
|
);
|
||||||
|
@ -3573,9 +3667,7 @@
|
||||||
context: "encoder referenced by this",
|
context: "encoder referenced by this",
|
||||||
});
|
});
|
||||||
const renderPassRid = assertResource(this, { prefix, context: "this" });
|
const renderPassRid = assertResource(this, { prefix, context: "this" });
|
||||||
ops.op_webgpu_render_pass_end_pipeline_statistics_query(
|
ops.op_webgpu_render_pass_end_pipeline_statistics_query(renderPassRid);
|
||||||
renderPassRid,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3651,10 +3743,7 @@
|
||||||
});
|
});
|
||||||
return rid;
|
return rid;
|
||||||
});
|
});
|
||||||
ops.op_webgpu_render_pass_execute_bundles(
|
ops.op_webgpu_render_pass_execute_bundles(renderPassRid, bundleRids);
|
||||||
renderPassRid,
|
|
||||||
bundleRids,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
end() {
|
end() {
|
||||||
|
@ -3747,10 +3836,7 @@
|
||||||
context: "encoder referenced by this",
|
context: "encoder referenced by this",
|
||||||
});
|
});
|
||||||
const renderPassRid = assertResource(this, { prefix, context: "this" });
|
const renderPassRid = assertResource(this, { prefix, context: "this" });
|
||||||
ops.op_webgpu_render_pass_push_debug_group(
|
ops.op_webgpu_render_pass_push_debug_group(renderPassRid, groupLabel);
|
||||||
renderPassRid,
|
|
||||||
groupLabel,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
popDebugGroup() {
|
popDebugGroup() {
|
||||||
|
@ -3790,10 +3876,7 @@
|
||||||
context: "encoder referenced by this",
|
context: "encoder referenced by this",
|
||||||
});
|
});
|
||||||
const renderPassRid = assertResource(this, { prefix, context: "this" });
|
const renderPassRid = assertResource(this, { prefix, context: "this" });
|
||||||
ops.op_webgpu_render_pass_insert_debug_marker(
|
ops.op_webgpu_render_pass_insert_debug_marker(renderPassRid, markerLabel);
|
||||||
renderPassRid,
|
|
||||||
markerLabel,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3826,10 +3909,7 @@
|
||||||
resourceContext: "Argument 1",
|
resourceContext: "Argument 1",
|
||||||
selfContext: "this",
|
selfContext: "this",
|
||||||
});
|
});
|
||||||
ops.op_webgpu_render_pass_set_pipeline(
|
ops.op_webgpu_render_pass_set_pipeline(renderPassRid, pipelineRid);
|
||||||
renderPassRid,
|
|
||||||
pipelineRid,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4205,10 +4285,7 @@
|
||||||
resourceContext: "Argument 1",
|
resourceContext: "Argument 1",
|
||||||
selfContext: "this",
|
selfContext: "this",
|
||||||
});
|
});
|
||||||
ops.op_webgpu_compute_pass_set_pipeline(
|
ops.op_webgpu_compute_pass_set_pipeline(computePassRid, pipelineRid);
|
||||||
computePassRid,
|
|
||||||
pipelineRid,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4351,9 +4428,7 @@
|
||||||
context: "encoder referenced by this",
|
context: "encoder referenced by this",
|
||||||
});
|
});
|
||||||
const computePassRid = assertResource(this, { prefix, context: "this" });
|
const computePassRid = assertResource(this, { prefix, context: "this" });
|
||||||
ops.op_webgpu_compute_pass_end_pipeline_statistics_query(
|
ops.op_webgpu_compute_pass_end_pipeline_statistics_query(computePassRid);
|
||||||
computePassRid,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4488,10 +4563,7 @@
|
||||||
context: "encoder referenced by this",
|
context: "encoder referenced by this",
|
||||||
});
|
});
|
||||||
const computePassRid = assertResource(this, { prefix, context: "this" });
|
const computePassRid = assertResource(this, { prefix, context: "this" });
|
||||||
ops.op_webgpu_compute_pass_push_debug_group(
|
ops.op_webgpu_compute_pass_push_debug_group(computePassRid, groupLabel);
|
||||||
computePassRid,
|
|
||||||
groupLabel,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
popDebugGroup() {
|
popDebugGroup() {
|
||||||
|
@ -4630,7 +4702,7 @@
|
||||||
* @param {GPURenderBundleDescriptor} descriptor
|
* @param {GPURenderBundleDescriptor} descriptor
|
||||||
*/
|
*/
|
||||||
finish(descriptor = {}) {
|
finish(descriptor = {}) {
|
||||||
webidl.assertBranded(this, GPURenderBundleEncoder.prototype);
|
webidl.assertBranded(this, GPURenderBundleEncoderPrototype);
|
||||||
const prefix = "Failed to execute 'finish' on 'GPURenderBundleEncoder'";
|
const prefix = "Failed to execute 'finish' on 'GPURenderBundleEncoder'";
|
||||||
descriptor = webidl.converters.GPURenderBundleDescriptor(descriptor, {
|
descriptor = webidl.converters.GPURenderBundleDescriptor(descriptor, {
|
||||||
prefix,
|
prefix,
|
||||||
|
@ -4649,7 +4721,7 @@
|
||||||
this[_rid] = undefined;
|
this[_rid] = undefined;
|
||||||
|
|
||||||
const renderBundle = createGPURenderBundle(
|
const renderBundle = createGPURenderBundle(
|
||||||
descriptor.label ?? null,
|
descriptor.label,
|
||||||
device,
|
device,
|
||||||
rid,
|
rid,
|
||||||
);
|
);
|
||||||
|
@ -4665,7 +4737,7 @@
|
||||||
dynamicOffsetsDataStart,
|
dynamicOffsetsDataStart,
|
||||||
dynamicOffsetsDataLength,
|
dynamicOffsetsDataLength,
|
||||||
) {
|
) {
|
||||||
webidl.assertBranded(this, GPURenderBundleEncoder.prototype);
|
webidl.assertBranded(this, GPURenderBundleEncoderPrototype);
|
||||||
const prefix =
|
const prefix =
|
||||||
"Failed to execute 'setBindGroup' on 'GPURenderBundleEncoder'";
|
"Failed to execute 'setBindGroup' on 'GPURenderBundleEncoder'";
|
||||||
const device = assertDevice(this, { prefix, context: "this" });
|
const device = assertDevice(this, { prefix, context: "this" });
|
||||||
|
@ -4706,7 +4778,7 @@
|
||||||
* @param {string} groupLabel
|
* @param {string} groupLabel
|
||||||
*/
|
*/
|
||||||
pushDebugGroup(groupLabel) {
|
pushDebugGroup(groupLabel) {
|
||||||
webidl.assertBranded(this, GPURenderBundleEncoder.prototype);
|
webidl.assertBranded(this, GPURenderBundleEncoderPrototype);
|
||||||
const prefix =
|
const prefix =
|
||||||
"Failed to execute 'pushDebugGroup' on 'GPURenderBundleEncoder'";
|
"Failed to execute 'pushDebugGroup' on 'GPURenderBundleEncoder'";
|
||||||
webidl.requiredArguments(arguments.length, 1, { prefix });
|
webidl.requiredArguments(arguments.length, 1, { prefix });
|
||||||
|
@ -4726,7 +4798,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
popDebugGroup() {
|
popDebugGroup() {
|
||||||
webidl.assertBranded(this, GPURenderBundleEncoder.prototype);
|
webidl.assertBranded(this, GPURenderBundleEncoderPrototype);
|
||||||
const prefix =
|
const prefix =
|
||||||
"Failed to execute 'popDebugGroup' on 'GPURenderBundleEncoder'";
|
"Failed to execute 'popDebugGroup' on 'GPURenderBundleEncoder'";
|
||||||
assertDevice(this, { prefix, context: "this" });
|
assertDevice(this, { prefix, context: "this" });
|
||||||
|
@ -4743,7 +4815,7 @@
|
||||||
* @param {string} markerLabel
|
* @param {string} markerLabel
|
||||||
*/
|
*/
|
||||||
insertDebugMarker(markerLabel) {
|
insertDebugMarker(markerLabel) {
|
||||||
webidl.assertBranded(this, GPURenderBundleEncoder.prototype);
|
webidl.assertBranded(this, GPURenderBundleEncoderPrototype);
|
||||||
const prefix =
|
const prefix =
|
||||||
"Failed to execute 'insertDebugMarker' on 'GPURenderBundleEncoder'";
|
"Failed to execute 'insertDebugMarker' on 'GPURenderBundleEncoder'";
|
||||||
webidl.requiredArguments(arguments.length, 1, { prefix });
|
webidl.requiredArguments(arguments.length, 1, { prefix });
|
||||||
|
@ -4766,7 +4838,7 @@
|
||||||
* @param {GPURenderPipeline} pipeline
|
* @param {GPURenderPipeline} pipeline
|
||||||
*/
|
*/
|
||||||
setPipeline(pipeline) {
|
setPipeline(pipeline) {
|
||||||
webidl.assertBranded(this, GPURenderBundleEncoder.prototype);
|
webidl.assertBranded(this, GPURenderBundleEncoderPrototype);
|
||||||
const prefix =
|
const prefix =
|
||||||
"Failed to execute 'setPipeline' on 'GPURenderBundleEncoder'";
|
"Failed to execute 'setPipeline' on 'GPURenderBundleEncoder'";
|
||||||
webidl.requiredArguments(arguments.length, 1, { prefix });
|
webidl.requiredArguments(arguments.length, 1, { prefix });
|
||||||
|
@ -4801,7 +4873,7 @@
|
||||||
* @param {number} size
|
* @param {number} size
|
||||||
*/
|
*/
|
||||||
setIndexBuffer(buffer, indexFormat, offset = 0, size = 0) {
|
setIndexBuffer(buffer, indexFormat, offset = 0, size = 0) {
|
||||||
webidl.assertBranded(this, GPURenderBundleEncoder.prototype);
|
webidl.assertBranded(this, GPURenderBundleEncoderPrototype);
|
||||||
const prefix =
|
const prefix =
|
||||||
"Failed to execute 'setIndexBuffer' on 'GPURenderBundleEncoder'";
|
"Failed to execute 'setIndexBuffer' on 'GPURenderBundleEncoder'";
|
||||||
webidl.requiredArguments(arguments.length, 2, { prefix });
|
webidl.requiredArguments(arguments.length, 2, { prefix });
|
||||||
|
@ -4851,7 +4923,7 @@
|
||||||
* @param {number} size
|
* @param {number} size
|
||||||
*/
|
*/
|
||||||
setVertexBuffer(slot, buffer, offset = 0, size = 0) {
|
setVertexBuffer(slot, buffer, offset = 0, size = 0) {
|
||||||
webidl.assertBranded(this, GPURenderBundleEncoder.prototype);
|
webidl.assertBranded(this, GPURenderBundleEncoderPrototype);
|
||||||
const prefix =
|
const prefix =
|
||||||
"Failed to execute 'setVertexBuffer' on 'GPURenderBundleEncoder'";
|
"Failed to execute 'setVertexBuffer' on 'GPURenderBundleEncoder'";
|
||||||
webidl.requiredArguments(arguments.length, 2, { prefix });
|
webidl.requiredArguments(arguments.length, 2, { prefix });
|
||||||
|
@ -4901,7 +4973,7 @@
|
||||||
* @param {number} firstInstance
|
* @param {number} firstInstance
|
||||||
*/
|
*/
|
||||||
draw(vertexCount, instanceCount = 1, firstVertex = 0, firstInstance = 0) {
|
draw(vertexCount, instanceCount = 1, firstVertex = 0, firstInstance = 0) {
|
||||||
webidl.assertBranded(this, GPURenderBundleEncoder.prototype);
|
webidl.assertBranded(this, GPURenderBundleEncoderPrototype);
|
||||||
const prefix = "Failed to execute 'draw' on 'GPURenderBundleEncoder'";
|
const prefix = "Failed to execute 'draw' on 'GPURenderBundleEncoder'";
|
||||||
webidl.requiredArguments(arguments.length, 1, { prefix });
|
webidl.requiredArguments(arguments.length, 1, { prefix });
|
||||||
vertexCount = webidl.converters.GPUSize32(vertexCount, {
|
vertexCount = webidl.converters.GPUSize32(vertexCount, {
|
||||||
|
@ -4948,7 +5020,7 @@
|
||||||
baseVertex = 0,
|
baseVertex = 0,
|
||||||
firstInstance = 0,
|
firstInstance = 0,
|
||||||
) {
|
) {
|
||||||
webidl.assertBranded(this, GPURenderBundleEncoder.prototype);
|
webidl.assertBranded(this, GPURenderBundleEncoderPrototype);
|
||||||
const prefix =
|
const prefix =
|
||||||
"Failed to execute 'drawIndexed' on 'GPURenderBundleEncoder'";
|
"Failed to execute 'drawIndexed' on 'GPURenderBundleEncoder'";
|
||||||
webidl.requiredArguments(arguments.length, 1, { prefix });
|
webidl.requiredArguments(arguments.length, 1, { prefix });
|
||||||
|
@ -4992,7 +5064,7 @@
|
||||||
* @param {number} indirectOffset
|
* @param {number} indirectOffset
|
||||||
*/
|
*/
|
||||||
drawIndirect(indirectBuffer, indirectOffset) {
|
drawIndirect(indirectBuffer, indirectOffset) {
|
||||||
webidl.assertBranded(this, GPURenderBundleEncoder.prototype);
|
webidl.assertBranded(this, GPURenderBundleEncoderPrototype);
|
||||||
const prefix =
|
const prefix =
|
||||||
"Failed to execute 'drawIndirect' on 'GPURenderBundleEncoder'";
|
"Failed to execute 'drawIndirect' on 'GPURenderBundleEncoder'";
|
||||||
webidl.requiredArguments(arguments.length, 2, { prefix });
|
webidl.requiredArguments(arguments.length, 2, { prefix });
|
||||||
|
@ -5038,6 +5110,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GPUObjectBaseMixin("GPURenderBundleEncoder", GPURenderBundleEncoder);
|
GPUObjectBaseMixin("GPURenderBundleEncoder", GPURenderBundleEncoder);
|
||||||
|
const GPURenderBundleEncoderPrototype = GPURenderBundleEncoder.prototype;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string | null} label
|
* @param {string | null} label
|
||||||
|
@ -5106,6 +5179,10 @@
|
||||||
[_rid];
|
[_rid];
|
||||||
/** @type {GPUQuerySetDescriptor} */
|
/** @type {GPUQuerySetDescriptor} */
|
||||||
[_descriptor];
|
[_descriptor];
|
||||||
|
/** @type {GPUQueryType} */
|
||||||
|
[_type];
|
||||||
|
/** @type {number} */
|
||||||
|
[_count];
|
||||||
|
|
||||||
[_cleanup]() {
|
[_cleanup]() {
|
||||||
const rid = this[_rid];
|
const rid = this[_rid];
|
||||||
|
@ -5125,6 +5202,16 @@
|
||||||
this[_cleanup]();
|
this[_cleanup]();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get type() {
|
||||||
|
webidl.assertBranded(this, GPUQuerySetPrototype);
|
||||||
|
return this[_type]();
|
||||||
|
}
|
||||||
|
|
||||||
|
get count() {
|
||||||
|
webidl.assertBranded(this, GPUQuerySetPrototype);
|
||||||
|
return this[_count]();
|
||||||
|
}
|
||||||
|
|
||||||
[SymbolFor("Deno.privateCustomInspect")](inspect) {
|
[SymbolFor("Deno.privateCustomInspect")](inspect) {
|
||||||
return `${this.constructor.name} ${
|
return `${this.constructor.name} ${
|
||||||
inspect({
|
inspect({
|
||||||
|
@ -5137,12 +5224,17 @@
|
||||||
const GPUQuerySetPrototype = GPUQuerySet.prototype;
|
const GPUQuerySetPrototype = GPUQuerySet.prototype;
|
||||||
|
|
||||||
window.__bootstrap.webgpu = {
|
window.__bootstrap.webgpu = {
|
||||||
|
_device,
|
||||||
|
assertDevice,
|
||||||
|
createGPUTexture,
|
||||||
gpu: webidl.createBranded(GPU),
|
gpu: webidl.createBranded(GPU),
|
||||||
GPU,
|
GPU,
|
||||||
GPUAdapter,
|
GPUAdapter,
|
||||||
|
GPUAdapterInfo,
|
||||||
GPUSupportedLimits,
|
GPUSupportedLimits,
|
||||||
GPUSupportedFeatures,
|
GPUSupportedFeatures,
|
||||||
GPUDevice,
|
GPUDevice,
|
||||||
|
GPUDeviceLostInfo,
|
||||||
GPUQueue,
|
GPUQueue,
|
||||||
GPUBuffer,
|
GPUBuffer,
|
||||||
GPUBufferUsage,
|
GPUBufferUsage,
|
||||||
|
@ -5167,7 +5259,7 @@
|
||||||
GPURenderBundle,
|
GPURenderBundle,
|
||||||
GPUQuerySet,
|
GPUQuerySet,
|
||||||
GPUError,
|
GPUError,
|
||||||
GPUOutOfMemoryError,
|
|
||||||
GPUValidationError,
|
GPUValidationError,
|
||||||
|
GPUOutOfMemoryError,
|
||||||
};
|
};
|
||||||
})(this);
|
})(this);
|
||||||
|
|
|
@ -65,12 +65,6 @@
|
||||||
GPUSupportedFeatures.prototype,
|
GPUSupportedFeatures.prototype,
|
||||||
);
|
);
|
||||||
|
|
||||||
// ENUM: GPUPredefinedColorSpace
|
|
||||||
webidl.converters.GPUPredefinedColorSpace = webidl.createEnumConverter(
|
|
||||||
"GPUPredefinedColorSpace",
|
|
||||||
["srgb"],
|
|
||||||
);
|
|
||||||
|
|
||||||
// INTERFACE: GPU
|
// INTERFACE: GPU
|
||||||
webidl.converters.GPU = webidl.createInterfaceConverter("GPU", GPU.prototype);
|
webidl.converters.GPU = webidl.createInterfaceConverter("GPU", GPU.prototype);
|
||||||
|
|
||||||
|
@ -112,7 +106,6 @@
|
||||||
"GPUFeatureName",
|
"GPUFeatureName",
|
||||||
[
|
[
|
||||||
"depth-clip-control",
|
"depth-clip-control",
|
||||||
"depth24unorm-stencil8",
|
|
||||||
"depth32float-stencil8",
|
"depth32float-stencil8",
|
||||||
"pipeline-statistics-query",
|
"pipeline-statistics-query",
|
||||||
"texture-compression-bc",
|
"texture-compression-bc",
|
||||||
|
@ -148,6 +141,10 @@
|
||||||
webidl.converters["GPUSize32"] = (V, opts) =>
|
webidl.converters["GPUSize32"] = (V, opts) =>
|
||||||
webidl.converters["unsigned long"](V, { ...opts, enforceRange: true });
|
webidl.converters["unsigned long"](V, { ...opts, enforceRange: true });
|
||||||
|
|
||||||
|
// TYPEDEF: GPUSize64
|
||||||
|
webidl.converters["GPUSize64"] = (V, opts) =>
|
||||||
|
webidl.converters["unsigned long long"](V, { ...opts, enforceRange: true });
|
||||||
|
|
||||||
// DICTIONARY: GPUDeviceDescriptor
|
// DICTIONARY: GPUDeviceDescriptor
|
||||||
const dictMembersGPUDeviceDescriptor = [
|
const dictMembersGPUDeviceDescriptor = [
|
||||||
{
|
{
|
||||||
|
@ -163,7 +160,7 @@
|
||||||
key: "requiredLimits",
|
key: "requiredLimits",
|
||||||
converter: webidl.createRecordConverter(
|
converter: webidl.createRecordConverter(
|
||||||
webidl.converters["DOMString"],
|
webidl.converters["DOMString"],
|
||||||
webidl.converters["GPUSize32"],
|
webidl.converters["GPUSize64"],
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
@ -185,10 +182,6 @@
|
||||||
GPUBuffer.prototype,
|
GPUBuffer.prototype,
|
||||||
);
|
);
|
||||||
|
|
||||||
// TYPEDEF: GPUSize64
|
|
||||||
webidl.converters["GPUSize64"] = (V, opts) =>
|
|
||||||
webidl.converters["unsigned long long"](V, { ...opts, enforceRange: true });
|
|
||||||
|
|
||||||
// TYPEDEF: GPUBufferUsageFlags
|
// TYPEDEF: GPUBufferUsageFlags
|
||||||
webidl.converters["GPUBufferUsageFlags"] = (V, opts) =>
|
webidl.converters["GPUBufferUsageFlags"] = (V, opts) =>
|
||||||
webidl.converters["unsigned long"](V, { ...opts, enforceRange: true });
|
webidl.converters["unsigned long"](V, { ...opts, enforceRange: true });
|
||||||
|
@ -339,7 +332,6 @@
|
||||||
"depth24plus",
|
"depth24plus",
|
||||||
"depth24plus-stencil8",
|
"depth24plus-stencil8",
|
||||||
"depth32float",
|
"depth32float",
|
||||||
"depth24unorm-stencil8",
|
|
||||||
"depth32float-stencil8",
|
"depth32float-stencil8",
|
||||||
"bc1-rgba-unorm",
|
"bc1-rgba-unorm",
|
||||||
"bc1-rgba-unorm-srgb",
|
"bc1-rgba-unorm-srgb",
|
||||||
|
@ -432,6 +424,15 @@
|
||||||
converter: webidl.converters["GPUTextureUsageFlags"],
|
converter: webidl.converters["GPUTextureUsageFlags"],
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: "viewFormats",
|
||||||
|
converter: webidl.createSequenceConverter(
|
||||||
|
webidl.converters["GPUTextureFormat"],
|
||||||
|
),
|
||||||
|
get defaultValue() {
|
||||||
|
return [];
|
||||||
|
},
|
||||||
|
},
|
||||||
];
|
];
|
||||||
webidl.converters["GPUTextureDescriptor"] = webidl.createDictionaryConverter(
|
webidl.converters["GPUTextureDescriptor"] = webidl.createDictionaryConverter(
|
||||||
"GPUTextureDescriptor",
|
"GPUTextureDescriptor",
|
||||||
|
@ -911,7 +912,6 @@
|
||||||
converter: webidl.converters["DOMString"],
|
converter: webidl.converters["DOMString"],
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
{ key: "sourceMap", converter: webidl.converters["object"] },
|
|
||||||
];
|
];
|
||||||
webidl.converters["GPUShaderModuleDescriptor"] = webidl
|
webidl.converters["GPUShaderModuleDescriptor"] = webidl
|
||||||
.createDictionaryConverter(
|
.createDictionaryConverter(
|
||||||
|
@ -1842,7 +1842,6 @@
|
||||||
key: "depthStencilAttachment",
|
key: "depthStencilAttachment",
|
||||||
converter: webidl.converters["GPURenderPassDepthStencilAttachment"],
|
converter: webidl.converters["GPURenderPassDepthStencilAttachment"],
|
||||||
},
|
},
|
||||||
{ key: "occlusionQuerySet", converter: webidl.converters["GPUQuerySet"] },
|
|
||||||
];
|
];
|
||||||
webidl.converters["GPURenderPassDescriptor"] = webidl
|
webidl.converters["GPURenderPassDescriptor"] = webidl
|
||||||
.createDictionaryConverter(
|
.createDictionaryConverter(
|
||||||
|
|
148
ext/webgpu/src/03_surface.js
Normal file
148
ext/webgpu/src/03_surface.js
Normal file
|
@ -0,0 +1,148 @@
|
||||||
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
|
// @ts-check
|
||||||
|
/// <reference path="../../core/lib.deno_core.d.ts" />
|
||||||
|
/// <reference path="../web/internal.d.ts" />
|
||||||
|
/// <reference path="../web/lib.deno_web.d.ts" />
|
||||||
|
/// <reference path="./lib.deno_webgpu.d.ts" />
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
((window) => {
|
||||||
|
const core = window.Deno.core;
|
||||||
|
const ops = core.ops;
|
||||||
|
const webidl = window.__bootstrap.webidl;
|
||||||
|
const { Symbol } = window.__bootstrap.primordials;
|
||||||
|
const { _device, assertDevice, createGPUTexture } = window.__bootstrap.webgpu;
|
||||||
|
|
||||||
|
const _surfaceRid = Symbol("[[surfaceRid]]");
|
||||||
|
const _configuration = Symbol("[[configuration]]");
|
||||||
|
const _canvas = Symbol("[[canvas]]");
|
||||||
|
const _currentTexture = Symbol("[[currentTexture]]");
|
||||||
|
class GPUCanvasContext {
|
||||||
|
/** @type {number} */
|
||||||
|
[_surfaceRid];
|
||||||
|
/** @type {InnerGPUDevice} */
|
||||||
|
[_device];
|
||||||
|
[_configuration];
|
||||||
|
[_canvas];
|
||||||
|
/** @type {GPUTexture | undefined} */
|
||||||
|
[_currentTexture];
|
||||||
|
|
||||||
|
get canvas() {
|
||||||
|
webidl.assertBranded(this, GPUCanvasContextPrototype);
|
||||||
|
return this[_canvas];
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
webidl.illegalConstructor();
|
||||||
|
}
|
||||||
|
|
||||||
|
configure(configuration) {
|
||||||
|
webidl.assertBranded(this, GPUCanvasContextPrototype);
|
||||||
|
const prefix = "Failed to execute 'configure' on 'GPUCanvasContext'";
|
||||||
|
webidl.requiredArguments(arguments.length, 1, { prefix });
|
||||||
|
configuration = webidl.converters.GPUCanvasConfiguration(configuration, {
|
||||||
|
prefix,
|
||||||
|
context: "Argument 1",
|
||||||
|
});
|
||||||
|
|
||||||
|
this[_device] = configuration.device[_device];
|
||||||
|
this[_configuration] = configuration;
|
||||||
|
const device = assertDevice(this, {
|
||||||
|
prefix,
|
||||||
|
context: "configuration.device",
|
||||||
|
});
|
||||||
|
|
||||||
|
const { err } = ops.op_webgpu_surface_configure({
|
||||||
|
surfaceRid: this[_surfaceRid],
|
||||||
|
deviceRid: device.rid,
|
||||||
|
format: configuration.format,
|
||||||
|
usage: configuration.usage,
|
||||||
|
width: configuration.width,
|
||||||
|
height: configuration.height,
|
||||||
|
alphaMode: configuration.alphaMode,
|
||||||
|
});
|
||||||
|
|
||||||
|
device.pushError(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
unconfigure() {
|
||||||
|
webidl.assertBranded(this, GPUCanvasContextPrototype);
|
||||||
|
|
||||||
|
this[_configuration] = null;
|
||||||
|
this[_device] = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
getCurrentTexture() {
|
||||||
|
webidl.assertBranded(this, GPUCanvasContextPrototype);
|
||||||
|
const prefix =
|
||||||
|
"Failed to execute 'getCurrentTexture' on 'GPUCanvasContext'";
|
||||||
|
|
||||||
|
if (this[_configuration] === null) {
|
||||||
|
throw new DOMException(
|
||||||
|
"context is not configured.",
|
||||||
|
"InvalidStateError",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const device = assertDevice(this, { prefix, context: "this" });
|
||||||
|
|
||||||
|
if (this[_currentTexture]) {
|
||||||
|
return this[_currentTexture];
|
||||||
|
}
|
||||||
|
|
||||||
|
const { rid } = ops.op_webgpu_surface_get_current_texture(
|
||||||
|
device.rid,
|
||||||
|
this[_surfaceRid],
|
||||||
|
);
|
||||||
|
|
||||||
|
const texture = createGPUTexture(
|
||||||
|
{
|
||||||
|
size: {
|
||||||
|
width: this[_configuration].width,
|
||||||
|
height: this[_configuration].height,
|
||||||
|
depthOrArrayLayers: 1,
|
||||||
|
},
|
||||||
|
mipLevelCount: 1,
|
||||||
|
sampleCount: 1,
|
||||||
|
dimension: "2d",
|
||||||
|
format: this[_configuration].format,
|
||||||
|
usage: this[_configuration].usage,
|
||||||
|
},
|
||||||
|
device,
|
||||||
|
rid,
|
||||||
|
);
|
||||||
|
device.trackResource(texture);
|
||||||
|
this[_currentTexture] = texture;
|
||||||
|
return texture;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extended from spec. Required to present the texture; browser don't need this.
|
||||||
|
present() {
|
||||||
|
webidl.assertBranded(this, GPUCanvasContextPrototype);
|
||||||
|
const prefix = "Failed to execute 'present' on 'GPUCanvasContext'";
|
||||||
|
const device = assertDevice(this[_currentTexture], {
|
||||||
|
prefix,
|
||||||
|
context: "this",
|
||||||
|
});
|
||||||
|
ops.op_webgpu_surface_present(device.rid, this[_surfaceRid]);
|
||||||
|
this[_currentTexture].destroy();
|
||||||
|
this[_currentTexture] = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const GPUCanvasContextPrototype = GPUCanvasContext.prototype;
|
||||||
|
|
||||||
|
function createCanvasContext(options) {
|
||||||
|
const canvasContext = webidl.createBranded(GPUCanvasContext);
|
||||||
|
canvasContext[_surfaceRid] = options.surfaceRid;
|
||||||
|
canvasContext[_canvas] = options.canvas;
|
||||||
|
return canvasContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.__bootstrap.webgpu = {
|
||||||
|
...window.__bootstrap.webgpu,
|
||||||
|
GPUCanvasContext,
|
||||||
|
createCanvasContext,
|
||||||
|
};
|
||||||
|
})(this);
|
86
ext/webgpu/src/04_surface_idl_types.js
Normal file
86
ext/webgpu/src/04_surface_idl_types.js
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
|
// @ts-check
|
||||||
|
/// <reference path="../../core/lib.deno_core.d.ts" />
|
||||||
|
/// <reference path="../web/internal.d.ts" />
|
||||||
|
/// <reference path="../web/lib.deno_web.d.ts" />
|
||||||
|
/// <reference path="./lib.deno_webgpu.d.ts" />
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
((window) => {
|
||||||
|
const webidl = window.__bootstrap.webidl;
|
||||||
|
const { GPUTextureUsage } = window.__bootstrap.webgpu;
|
||||||
|
|
||||||
|
// ENUM: GPUCanvasAlphaMode
|
||||||
|
webidl.converters["GPUCanvasAlphaMode"] = webidl.createEnumConverter(
|
||||||
|
"GPUCanvasAlphaMode",
|
||||||
|
[
|
||||||
|
"opaque",
|
||||||
|
"premultiplied",
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
// NON-SPEC: ENUM: GPUPresentMode
|
||||||
|
webidl.converters["GPUPresentMode"] = webidl.createEnumConverter(
|
||||||
|
"GPUPresentMode",
|
||||||
|
[
|
||||||
|
"autoVsync",
|
||||||
|
"autoNoVsync",
|
||||||
|
"fifo",
|
||||||
|
"fifoRelaxed",
|
||||||
|
"immediate",
|
||||||
|
"mailbox",
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
// DICT: GPUCanvasConfiguration
|
||||||
|
const dictMembersGPUCanvasConfiguration = [
|
||||||
|
{ key: "device", converter: webidl.converters.GPUDevice, required: true },
|
||||||
|
{
|
||||||
|
key: "format",
|
||||||
|
converter: webidl.converters.GPUTextureFormat,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "usage",
|
||||||
|
converter: webidl.converters["GPUTextureUsageFlags"],
|
||||||
|
defaultValue: GPUTextureUsage.RENDER_ATTACHMENT,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "alphaMode",
|
||||||
|
converter: webidl.converters["GPUCanvasAlphaMode"],
|
||||||
|
defaultValue: "opaque",
|
||||||
|
},
|
||||||
|
|
||||||
|
// Extended from spec
|
||||||
|
{
|
||||||
|
key: "presentMode",
|
||||||
|
converter: webidl.converters["GPUPresentMode"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "width",
|
||||||
|
converter: webidl.converters["long"],
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "height",
|
||||||
|
converter: webidl.converters["long"],
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "viewFormats",
|
||||||
|
converter: webidl.createSequenceConverter(
|
||||||
|
webidl.converters["GPUTextureFormat"],
|
||||||
|
),
|
||||||
|
get defaultValue() {
|
||||||
|
return [];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
webidl.converters["GPUCanvasConfiguration"] = webidl
|
||||||
|
.createDictionaryConverter(
|
||||||
|
"GPUCanvasConfiguration",
|
||||||
|
dictMembersGPUCanvasConfiguration,
|
||||||
|
);
|
||||||
|
})(this);
|
|
@ -199,7 +199,7 @@ pub fn op_webgpu_create_bind_group_layout(
|
||||||
gfx_put!(device => instance.device_create_bind_group_layout(
|
gfx_put!(device => instance.device_create_bind_group_layout(
|
||||||
device,
|
device,
|
||||||
&descriptor,
|
&descriptor,
|
||||||
std::marker::PhantomData
|
()
|
||||||
) => state, WebGpuBindGroupLayout)
|
) => state, WebGpuBindGroupLayout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ pub fn op_webgpu_create_pipeline_layout(
|
||||||
gfx_put!(device => instance.device_create_pipeline_layout(
|
gfx_put!(device => instance.device_create_pipeline_layout(
|
||||||
device,
|
device,
|
||||||
&descriptor,
|
&descriptor,
|
||||||
std::marker::PhantomData
|
()
|
||||||
) => state, super::pipeline::WebGpuPipelineLayout)
|
) => state, super::pipeline::WebGpuPipelineLayout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,6 +317,6 @@ pub fn op_webgpu_create_bind_group(
|
||||||
gfx_put!(device => instance.device_create_bind_group(
|
gfx_put!(device => instance.device_create_bind_group(
|
||||||
device,
|
device,
|
||||||
&descriptor,
|
&descriptor,
|
||||||
std::marker::PhantomData
|
()
|
||||||
) => state, WebGpuBindGroup)
|
) => state, WebGpuBindGroup)
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ use std::cell::RefCell;
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
use wgpu_core::resource::BufferAccessResult;
|
||||||
|
|
||||||
use super::error::DomExceptionOperationError;
|
use super::error::DomExceptionOperationError;
|
||||||
use super::error::WebGpuResult;
|
use super::error::WebGpuResult;
|
||||||
|
@ -57,7 +58,7 @@ pub fn op_webgpu_create_buffer(
|
||||||
gfx_put!(device => instance.device_create_buffer(
|
gfx_put!(device => instance.device_create_buffer(
|
||||||
device,
|
device,
|
||||||
&descriptor,
|
&descriptor,
|
||||||
std::marker::PhantomData
|
()
|
||||||
) => state, WebGpuBuffer)
|
) => state, WebGpuBuffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +71,7 @@ pub async fn op_webgpu_buffer_get_map_async(
|
||||||
offset: u64,
|
offset: u64,
|
||||||
size: u64,
|
size: u64,
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let (sender, receiver) = oneshot::channel::<Result<(), AnyError>>();
|
let (sender, receiver) = oneshot::channel::<BufferAccessResult>();
|
||||||
|
|
||||||
let device;
|
let device;
|
||||||
{
|
{
|
||||||
|
@ -85,12 +86,7 @@ pub async fn op_webgpu_buffer_get_map_async(
|
||||||
device = device_resource.0;
|
device = device_resource.0;
|
||||||
|
|
||||||
let callback = Box::new(move |status| {
|
let callback = Box::new(move |status| {
|
||||||
sender
|
sender.send(status).unwrap();
|
||||||
.send(match status {
|
|
||||||
wgpu_core::resource::BufferMapAsyncStatus::Success => Ok(()),
|
|
||||||
_ => unreachable!(), // TODO
|
|
||||||
})
|
|
||||||
.unwrap();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO(lucacasonato): error handling
|
// TODO(lucacasonato): error handling
|
||||||
|
@ -120,7 +116,8 @@ pub async fn op_webgpu_buffer_get_map_async(
|
||||||
{
|
{
|
||||||
let state = state.borrow();
|
let state = state.borrow();
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
gfx_select!(device => instance.device_poll(device, wgpu_types::Maintain::Wait)).unwrap();
|
gfx_select!(device => instance.device_poll(device, wgpu_types::Maintain::Wait))
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
tokio::time::sleep(Duration::from_millis(10)).await;
|
tokio::time::sleep(Duration::from_millis(10)).await;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
|
use deno_core::error::type_error;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::op;
|
use deno_core::op;
|
||||||
use deno_core::OpState;
|
use deno_core::OpState;
|
||||||
|
@ -108,7 +109,7 @@ pub fn op_webgpu_render_bundle_encoder_finish(
|
||||||
&wgpu_core::command::RenderBundleDescriptor {
|
&wgpu_core::command::RenderBundleDescriptor {
|
||||||
label: label.map(Cow::from),
|
label: label.map(Cow::from),
|
||||||
},
|
},
|
||||||
std::marker::PhantomData
|
()
|
||||||
) => state, WebGpuRenderBundle)
|
) => state, WebGpuRenderBundle)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,16 +269,15 @@ pub fn op_webgpu_render_bundle_encoder_set_index_buffer(
|
||||||
state
|
state
|
||||||
.resource_table
|
.resource_table
|
||||||
.get::<WebGpuRenderBundleEncoder>(render_bundle_encoder_rid)?;
|
.get::<WebGpuRenderBundleEncoder>(render_bundle_encoder_rid)?;
|
||||||
|
let size = Some(
|
||||||
|
std::num::NonZeroU64::new(size)
|
||||||
|
.ok_or_else(|| type_error("size must be larger than 0"))?,
|
||||||
|
);
|
||||||
|
|
||||||
render_bundle_encoder_resource
|
render_bundle_encoder_resource
|
||||||
.0
|
.0
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.set_index_buffer(
|
.set_index_buffer(buffer_resource.0, index_format, offset, size);
|
||||||
buffer_resource.0,
|
|
||||||
index_format,
|
|
||||||
offset,
|
|
||||||
std::num::NonZeroU64::new(size),
|
|
||||||
);
|
|
||||||
|
|
||||||
Ok(WebGpuResult::empty())
|
Ok(WebGpuResult::empty())
|
||||||
}
|
}
|
||||||
|
@ -298,13 +298,17 @@ pub fn op_webgpu_render_bundle_encoder_set_vertex_buffer(
|
||||||
state
|
state
|
||||||
.resource_table
|
.resource_table
|
||||||
.get::<WebGpuRenderBundleEncoder>(render_bundle_encoder_rid)?;
|
.get::<WebGpuRenderBundleEncoder>(render_bundle_encoder_rid)?;
|
||||||
|
let size = Some(
|
||||||
|
std::num::NonZeroU64::new(size)
|
||||||
|
.ok_or_else(|| type_error("size must be larger than 0"))?,
|
||||||
|
);
|
||||||
|
|
||||||
wgpu_core::command::bundle_ffi::wgpu_render_bundle_set_vertex_buffer(
|
wgpu_core::command::bundle_ffi::wgpu_render_bundle_set_vertex_buffer(
|
||||||
&mut render_bundle_encoder_resource.0.borrow_mut(),
|
&mut render_bundle_encoder_resource.0.borrow_mut(),
|
||||||
slot,
|
slot,
|
||||||
buffer_resource.0,
|
buffer_resource.0,
|
||||||
offset,
|
offset,
|
||||||
std::num::NonZeroU64::new(size),
|
size,
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(WebGpuResult::empty())
|
Ok(WebGpuResult::empty())
|
||||||
|
|
|
@ -49,7 +49,7 @@ pub fn op_webgpu_create_command_encoder(
|
||||||
gfx_put!(device => instance.device_create_command_encoder(
|
gfx_put!(device => instance.device_create_command_encoder(
|
||||||
device,
|
device,
|
||||||
&descriptor,
|
&descriptor,
|
||||||
std::marker::PhantomData
|
()
|
||||||
) => state, WebGpuCommandEncoder)
|
) => state, WebGpuCommandEncoder)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,6 @@ pub fn op_webgpu_command_encoder_begin_render_pass(
|
||||||
label: Option<String>,
|
label: Option<String>,
|
||||||
color_attachments: Vec<Option<GpuRenderPassColorAttachment>>,
|
color_attachments: Vec<Option<GpuRenderPassColorAttachment>>,
|
||||||
depth_stencil_attachment: Option<GpuRenderPassDepthStencilAttachment>,
|
depth_stencil_attachment: Option<GpuRenderPassDepthStencilAttachment>,
|
||||||
_occlusion_query_set: Option<u32>, // not yet implemented
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let command_encoder_resource = state
|
let command_encoder_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
|
|
@ -5,7 +5,6 @@ use serde::Serialize;
|
||||||
use std::convert::From;
|
use std::convert::From;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::fmt::Write;
|
|
||||||
use wgpu_core::binding_model::CreateBindGroupError;
|
use wgpu_core::binding_model::CreateBindGroupError;
|
||||||
use wgpu_core::binding_model::CreateBindGroupLayoutError;
|
use wgpu_core::binding_model::CreateBindGroupLayoutError;
|
||||||
use wgpu_core::binding_model::CreatePipelineLayoutError;
|
use wgpu_core::binding_model::CreatePipelineLayoutError;
|
||||||
|
@ -24,6 +23,8 @@ use wgpu_core::device::DeviceError;
|
||||||
use wgpu_core::pipeline::CreateComputePipelineError;
|
use wgpu_core::pipeline::CreateComputePipelineError;
|
||||||
use wgpu_core::pipeline::CreateRenderPipelineError;
|
use wgpu_core::pipeline::CreateRenderPipelineError;
|
||||||
use wgpu_core::pipeline::CreateShaderModuleError;
|
use wgpu_core::pipeline::CreateShaderModuleError;
|
||||||
|
#[cfg(feature = "surface")]
|
||||||
|
use wgpu_core::present::ConfigureSurfaceError;
|
||||||
use wgpu_core::resource::BufferAccessError;
|
use wgpu_core::resource::BufferAccessError;
|
||||||
use wgpu_core::resource::CreateBufferError;
|
use wgpu_core::resource::CreateBufferError;
|
||||||
use wgpu_core::resource::CreateQuerySetError;
|
use wgpu_core::resource::CreateQuerySetError;
|
||||||
|
@ -36,9 +37,7 @@ fn fmt_err(err: &(dyn Error + 'static)) -> String {
|
||||||
|
|
||||||
let mut e = err.source();
|
let mut e = err.source();
|
||||||
while let Some(source) = e {
|
while let Some(source) = e {
|
||||||
// No error possible, unwrap is fine here.
|
output.push_str(&format!(": {source}"));
|
||||||
// https://github.com/rust-lang/rust/blob/1.47.0/library/alloc/src/string.rs#L2414-L2427
|
|
||||||
write!(output, ": {source}").unwrap();
|
|
||||||
e = source.source();
|
e = source.source();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,6 +280,13 @@ impl From<ClearError> for WebGpuError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "surface")]
|
||||||
|
impl From<ConfigureSurfaceError> for WebGpuError {
|
||||||
|
fn from(err: ConfigureSurfaceError) -> Self {
|
||||||
|
WebGpuError::Validation(fmt_err(&err))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct DomExceptionOperationError {
|
pub struct DomExceptionOperationError {
|
||||||
pub msg: String,
|
pub msg: String,
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
|
#![warn(unsafe_op_in_unsafe_fn)]
|
||||||
|
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::include_js_files;
|
use deno_core::include_js_files;
|
||||||
use deno_core::op;
|
use deno_core::op;
|
||||||
|
@ -25,13 +27,22 @@ mod macros {
|
||||||
macro_rules! gfx_select {
|
macro_rules! gfx_select {
|
||||||
($id:expr => $global:ident.$method:ident( $($param:expr),* )) => {
|
($id:expr => $global:ident.$method:ident( $($param:expr),* )) => {
|
||||||
match $id.backend() {
|
match $id.backend() {
|
||||||
#[cfg(not(target_os = "macos"))]
|
#[cfg(any(
|
||||||
|
all(not(target_arch = "wasm32"), not(target_os = "ios"), not(target_os = "macos")),
|
||||||
|
feature = "vulkan-portability"
|
||||||
|
))]
|
||||||
wgpu_types::Backend::Vulkan => $global.$method::<wgpu_core::api::Vulkan>( $($param),* ),
|
wgpu_types::Backend::Vulkan => $global.$method::<wgpu_core::api::Vulkan>( $($param),* ),
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(all(not(target_arch = "wasm32"), any(target_os = "ios", target_os = "macos")))]
|
||||||
wgpu_types::Backend::Metal => $global.$method::<wgpu_core::api::Metal>( $($param),* ),
|
wgpu_types::Backend::Metal => $global.$method::<wgpu_core::api::Metal>( $($param),* ),
|
||||||
#[cfg(windows)]
|
#[cfg(all(not(target_arch = "wasm32"), windows))]
|
||||||
wgpu_types::Backend::Dx12 => $global.$method::<wgpu_core::api::Dx12>( $($param),* ),
|
wgpu_types::Backend::Dx12 => $global.$method::<wgpu_core::api::Dx12>( $($param),* ),
|
||||||
#[cfg(all(unix, not(target_os = "macos")))]
|
#[cfg(all(not(target_arch = "wasm32"), windows))]
|
||||||
|
wgpu_types::Backend::Dx11 => $global.$method::<wgpu_core::api::Dx11>( $($param),* ),
|
||||||
|
#[cfg(any(
|
||||||
|
all(unix, not(target_os = "macos"), not(target_os = "ios")),
|
||||||
|
feature = "angle",
|
||||||
|
target_arch = "wasm32"
|
||||||
|
))]
|
||||||
wgpu_types::Backend::Gl => $global.$method::<wgpu_core::api::Gles>( $($param),+ ),
|
wgpu_types::Backend::Gl => $global.$method::<wgpu_core::api::Gles>( $($param),+ ),
|
||||||
other => panic!("Unexpected backend {:?}", other),
|
other => panic!("Unexpected backend {:?}", other),
|
||||||
}
|
}
|
||||||
|
@ -65,6 +76,8 @@ pub mod queue;
|
||||||
pub mod render_pass;
|
pub mod render_pass;
|
||||||
pub mod sampler;
|
pub mod sampler;
|
||||||
pub mod shader;
|
pub mod shader;
|
||||||
|
#[cfg(feature = "surface")]
|
||||||
|
pub mod surface;
|
||||||
pub mod texture;
|
pub mod texture;
|
||||||
|
|
||||||
pub struct Unstable(pub bool);
|
pub struct Unstable(pub bool);
|
||||||
|
@ -79,7 +92,8 @@ fn check_unstable(state: &OpState, api_name: &str) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type Instance = wgpu_core::hub::Global<wgpu_core::hub::IdentityManagerFactory>;
|
pub type Instance =
|
||||||
|
wgpu_core::hub::Global<wgpu_core::hub::IdentityManagerFactory>;
|
||||||
|
|
||||||
struct WebGpuAdapter(wgpu_core::id::AdapterId);
|
struct WebGpuAdapter(wgpu_core::id::AdapterId);
|
||||||
impl Resource for WebGpuAdapter {
|
impl Resource for WebGpuAdapter {
|
||||||
|
@ -128,9 +142,6 @@ fn deserialize_features(features: &wgpu_types::Features) -> Vec<&'static str> {
|
||||||
if features.contains(wgpu_types::Features::DEPTH_CLIP_CONTROL) {
|
if features.contains(wgpu_types::Features::DEPTH_CLIP_CONTROL) {
|
||||||
return_features.push("depth-clip-control");
|
return_features.push("depth-clip-control");
|
||||||
}
|
}
|
||||||
if features.contains(wgpu_types::Features::DEPTH24UNORM_STENCIL8) {
|
|
||||||
return_features.push("depth24unorm-stencil8");
|
|
||||||
}
|
|
||||||
if features.contains(wgpu_types::Features::DEPTH32FLOAT_STENCIL8) {
|
if features.contains(wgpu_types::Features::DEPTH32FLOAT_STENCIL8) {
|
||||||
return_features.push("depth32float-stencil8");
|
return_features.push("depth32float-stencil8");
|
||||||
}
|
}
|
||||||
|
@ -243,7 +254,10 @@ pub async fn op_webgpu_request_adapter(
|
||||||
state.put(wgpu_core::hub::Global::new(
|
state.put(wgpu_core::hub::Global::new(
|
||||||
"webgpu",
|
"webgpu",
|
||||||
wgpu_core::hub::IdentityManagerFactory,
|
wgpu_core::hub::IdentityManagerFactory,
|
||||||
|
wgpu_types::InstanceDescriptor {
|
||||||
backends,
|
backends,
|
||||||
|
dx12_shader_compiler: wgpu_types::Dx12Compiler::Fxc,
|
||||||
|
},
|
||||||
));
|
));
|
||||||
state.borrow::<Instance>()
|
state.borrow::<Instance>()
|
||||||
};
|
};
|
||||||
|
@ -255,9 +269,7 @@ pub async fn op_webgpu_request_adapter(
|
||||||
};
|
};
|
||||||
let res = instance.request_adapter(
|
let res = instance.request_adapter(
|
||||||
&descriptor,
|
&descriptor,
|
||||||
wgpu_core::instance::AdapterInputs::Mask(backends, |_| {
|
wgpu_core::instance::AdapterInputs::Mask(backends, |_| ()),
|
||||||
std::marker::PhantomData
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let adapter = match res {
|
let adapter = match res {
|
||||||
|
@ -294,10 +306,6 @@ impl From<GpuRequiredFeatures> for wgpu_types::Features {
|
||||||
wgpu_types::Features::DEPTH_CLIP_CONTROL,
|
wgpu_types::Features::DEPTH_CLIP_CONTROL,
|
||||||
required_features.0.contains("depth-clip-control"),
|
required_features.0.contains("depth-clip-control"),
|
||||||
);
|
);
|
||||||
features.set(
|
|
||||||
wgpu_types::Features::DEPTH24UNORM_STENCIL8,
|
|
||||||
required_features.0.contains("depth24unorm-stencil8"),
|
|
||||||
);
|
|
||||||
features.set(
|
features.set(
|
||||||
wgpu_types::Features::DEPTH32FLOAT_STENCIL8,
|
wgpu_types::Features::DEPTH32FLOAT_STENCIL8,
|
||||||
required_features.0.contains("depth32float-stencil8"),
|
required_features.0.contains("depth32float-stencil8"),
|
||||||
|
@ -427,7 +435,7 @@ pub async fn op_webgpu_request_device(
|
||||||
adapter,
|
adapter,
|
||||||
&descriptor,
|
&descriptor,
|
||||||
std::env::var("DENO_WEBGPU_TRACE").ok().as_ref().map(std::path::Path::new),
|
std::env::var("DENO_WEBGPU_TRACE").ok().as_ref().map(std::path::Path::new),
|
||||||
std::marker::PhantomData
|
()
|
||||||
));
|
));
|
||||||
if let Some(err) = maybe_err {
|
if let Some(err) = maybe_err {
|
||||||
return Err(DomExceptionOperationError::new(&err.to_string()).into());
|
return Err(DomExceptionOperationError::new(&err.to_string()).into());
|
||||||
|
@ -553,7 +561,7 @@ pub fn op_webgpu_create_query_set(
|
||||||
gfx_put!(device => instance.device_create_query_set(
|
gfx_put!(device => instance.device_create_query_set(
|
||||||
device,
|
device,
|
||||||
&descriptor,
|
&descriptor,
|
||||||
std::marker::PhantomData
|
()
|
||||||
) => state, WebGpuQuerySet)
|
) => state, WebGpuQuerySet)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,8 +102,8 @@ pub fn op_webgpu_create_compute_pipeline(
|
||||||
GPUPipelineLayoutOrGPUAutoLayoutMode::Layout(_) => None,
|
GPUPipelineLayoutOrGPUAutoLayoutMode::Layout(_) => None,
|
||||||
GPUPipelineLayoutOrGPUAutoLayoutMode::Auto(GPUAutoLayoutMode::Auto) => {
|
GPUPipelineLayoutOrGPUAutoLayoutMode::Auto(GPUAutoLayoutMode::Auto) => {
|
||||||
Some(wgpu_core::device::ImplicitPipelineIds {
|
Some(wgpu_core::device::ImplicitPipelineIds {
|
||||||
root_id: std::marker::PhantomData,
|
root_id: (),
|
||||||
group_ids: &[std::marker::PhantomData; MAX_BIND_GROUPS],
|
group_ids: &[(); MAX_BIND_GROUPS],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -111,7 +111,7 @@ pub fn op_webgpu_create_compute_pipeline(
|
||||||
let (compute_pipeline, maybe_err) = gfx_select!(device => instance.device_create_compute_pipeline(
|
let (compute_pipeline, maybe_err) = gfx_select!(device => instance.device_create_compute_pipeline(
|
||||||
device,
|
device,
|
||||||
&descriptor,
|
&descriptor,
|
||||||
std::marker::PhantomData,
|
(),
|
||||||
implicit_pipelines
|
implicit_pipelines
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ pub fn op_webgpu_compute_pipeline_get_bind_group_layout(
|
||||||
.get::<WebGpuComputePipeline>(compute_pipeline_rid)?;
|
.get::<WebGpuComputePipeline>(compute_pipeline_rid)?;
|
||||||
let compute_pipeline = compute_pipeline_resource.0;
|
let compute_pipeline = compute_pipeline_resource.0;
|
||||||
|
|
||||||
let (bind_group_layout, maybe_err) = gfx_select!(compute_pipeline => instance.compute_pipeline_get_bind_group_layout(compute_pipeline, index, std::marker::PhantomData));
|
let (bind_group_layout, maybe_err) = gfx_select!(compute_pipeline => instance.compute_pipeline_get_bind_group_layout(compute_pipeline, index, ()));
|
||||||
|
|
||||||
let label = gfx_select!(bind_group_layout => instance.bind_group_layout_label(bind_group_layout));
|
let label = gfx_select!(bind_group_layout => instance.bind_group_layout_label(bind_group_layout));
|
||||||
|
|
||||||
|
@ -376,8 +376,8 @@ pub fn op_webgpu_create_render_pipeline(
|
||||||
GPUPipelineLayoutOrGPUAutoLayoutMode::Layout(_) => None,
|
GPUPipelineLayoutOrGPUAutoLayoutMode::Layout(_) => None,
|
||||||
GPUPipelineLayoutOrGPUAutoLayoutMode::Auto(GPUAutoLayoutMode::Auto) => {
|
GPUPipelineLayoutOrGPUAutoLayoutMode::Auto(GPUAutoLayoutMode::Auto) => {
|
||||||
Some(wgpu_core::device::ImplicitPipelineIds {
|
Some(wgpu_core::device::ImplicitPipelineIds {
|
||||||
root_id: std::marker::PhantomData,
|
root_id: (),
|
||||||
group_ids: &[std::marker::PhantomData; MAX_BIND_GROUPS],
|
group_ids: &[(); MAX_BIND_GROUPS],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -385,7 +385,7 @@ pub fn op_webgpu_create_render_pipeline(
|
||||||
let (render_pipeline, maybe_err) = gfx_select!(device => instance.device_create_render_pipeline(
|
let (render_pipeline, maybe_err) = gfx_select!(device => instance.device_create_render_pipeline(
|
||||||
device,
|
device,
|
||||||
&descriptor,
|
&descriptor,
|
||||||
std::marker::PhantomData,
|
(),
|
||||||
implicit_pipelines
|
implicit_pipelines
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -408,7 +408,7 @@ pub fn op_webgpu_render_pipeline_get_bind_group_layout(
|
||||||
.get::<WebGpuRenderPipeline>(render_pipeline_rid)?;
|
.get::<WebGpuRenderPipeline>(render_pipeline_rid)?;
|
||||||
let render_pipeline = render_pipeline_resource.0;
|
let render_pipeline = render_pipeline_resource.0;
|
||||||
|
|
||||||
let (bind_group_layout, maybe_err) = gfx_select!(render_pipeline => instance.render_pipeline_get_bind_group_layout(render_pipeline, index, std::marker::PhantomData));
|
let (bind_group_layout, maybe_err) = gfx_select!(render_pipeline => instance.render_pipeline_get_bind_group_layout(render_pipeline, index, ()));
|
||||||
|
|
||||||
let label = gfx_select!(bind_group_layout => instance.bind_group_layout_label(bind_group_layout));
|
let label = gfx_select!(bind_group_layout => instance.bind_group_layout_label(bind_group_layout));
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,6 @@ pub fn op_webgpu_create_sampler(
|
||||||
gfx_put!(device => instance.device_create_sampler(
|
gfx_put!(device => instance.device_create_sampler(
|
||||||
device,
|
device,
|
||||||
&descriptor,
|
&descriptor,
|
||||||
std::marker::PhantomData
|
()
|
||||||
) => state, WebGpuSampler)
|
) => state, WebGpuSampler)
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ pub fn op_webgpu_create_shader_module(
|
||||||
device_rid: ResourceId,
|
device_rid: ResourceId,
|
||||||
label: Option<String>,
|
label: Option<String>,
|
||||||
code: String,
|
code: String,
|
||||||
_source_map: Option<()>, // not yet implemented
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let device_resource = state
|
let device_resource = state
|
||||||
|
@ -41,6 +40,6 @@ pub fn op_webgpu_create_shader_module(
|
||||||
device,
|
device,
|
||||||
&descriptor,
|
&descriptor,
|
||||||
source,
|
source,
|
||||||
std::marker::PhantomData
|
()
|
||||||
) => state, WebGpuShaderModule)
|
) => state, WebGpuShaderModule)
|
||||||
}
|
}
|
||||||
|
|
137
ext/webgpu/src/surface.rs
Normal file
137
ext/webgpu/src/surface.rs
Normal file
|
@ -0,0 +1,137 @@
|
||||||
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
|
use super::WebGpuResult;
|
||||||
|
use deno_core::error::AnyError;
|
||||||
|
use deno_core::include_js_files;
|
||||||
|
use deno_core::op;
|
||||||
|
use deno_core::Extension;
|
||||||
|
use deno_core::OpState;
|
||||||
|
use deno_core::Resource;
|
||||||
|
use deno_core::ResourceId;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use std::borrow::Cow;
|
||||||
|
use wgpu_types::SurfaceStatus;
|
||||||
|
|
||||||
|
pub fn init_surface(unstable: bool) -> Extension {
|
||||||
|
Extension::builder("deno_webgpu_surface")
|
||||||
|
.dependencies(vec!["deno_webidl", "deno_web", "deno_webgpu"])
|
||||||
|
.js(include_js_files!(
|
||||||
|
prefix "deno:deno_webgpu",
|
||||||
|
"03_surface.js",
|
||||||
|
"04_surface_idl_types.js",
|
||||||
|
))
|
||||||
|
.ops(vec![
|
||||||
|
op_webgpu_surface_configure::decl(),
|
||||||
|
op_webgpu_surface_get_current_texture::decl(),
|
||||||
|
op_webgpu_surface_present::decl(),
|
||||||
|
])
|
||||||
|
.state(move |state| {
|
||||||
|
// TODO: check & possibly streamline this
|
||||||
|
// Unstable might be able to be OpMiddleware
|
||||||
|
// let unstable_checker = state.borrow::<super::UnstableChecker>();
|
||||||
|
// let unstable = unstable_checker.unstable;
|
||||||
|
state.put(super::Unstable(unstable));
|
||||||
|
Ok(())
|
||||||
|
})
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct WebGpuSurface(pub wgpu_core::id::SurfaceId);
|
||||||
|
impl Resource for WebGpuSurface {
|
||||||
|
fn name(&self) -> Cow<str> {
|
||||||
|
"webGPUSurface".into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct SurfaceConfigureArgs {
|
||||||
|
surface_rid: ResourceId,
|
||||||
|
device_rid: ResourceId,
|
||||||
|
format: wgpu_types::TextureFormat,
|
||||||
|
usage: u32,
|
||||||
|
width: u32,
|
||||||
|
height: u32,
|
||||||
|
present_mode: Option<wgpu_types::PresentMode>,
|
||||||
|
alpha_mode: wgpu_types::CompositeAlphaMode,
|
||||||
|
view_formats: Vec<wgpu_types::TextureFormat>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
|
pub fn op_webgpu_surface_configure(
|
||||||
|
state: &mut OpState,
|
||||||
|
args: SurfaceConfigureArgs,
|
||||||
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
|
let instance = state.borrow::<super::Instance>();
|
||||||
|
let device_resource = state
|
||||||
|
.resource_table
|
||||||
|
.get::<super::WebGpuDevice>(args.device_rid)?;
|
||||||
|
let device = device_resource.0;
|
||||||
|
let surface_resource = state
|
||||||
|
.resource_table
|
||||||
|
.get::<WebGpuSurface>(args.surface_rid)?;
|
||||||
|
let surface = surface_resource.0;
|
||||||
|
|
||||||
|
let conf = wgpu_types::SurfaceConfiguration::<Vec<wgpu_types::TextureFormat>> {
|
||||||
|
usage: wgpu_types::TextureUsages::from_bits_truncate(args.usage),
|
||||||
|
format: args.format,
|
||||||
|
width: args.width,
|
||||||
|
height: args.height,
|
||||||
|
present_mode: args.present_mode.unwrap_or_default(),
|
||||||
|
alpha_mode: args.alpha_mode,
|
||||||
|
view_formats: args.view_formats,
|
||||||
|
};
|
||||||
|
|
||||||
|
let err =
|
||||||
|
gfx_select!(device => instance.surface_configure(surface, device, &conf));
|
||||||
|
|
||||||
|
Ok(WebGpuResult::maybe_err(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
|
pub fn op_webgpu_surface_get_current_texture(
|
||||||
|
state: &mut OpState,
|
||||||
|
device_rid: ResourceId,
|
||||||
|
surface_rid: ResourceId,
|
||||||
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
|
let instance = state.borrow::<super::Instance>();
|
||||||
|
let device_resource = state
|
||||||
|
.resource_table
|
||||||
|
.get::<super::WebGpuDevice>(device_rid)?;
|
||||||
|
let device = device_resource.0;
|
||||||
|
let surface_resource =
|
||||||
|
state.resource_table.get::<WebGpuSurface>(surface_rid)?;
|
||||||
|
let surface = surface_resource.0;
|
||||||
|
|
||||||
|
let output =
|
||||||
|
gfx_select!(device => instance.surface_get_current_texture(surface, ()))?;
|
||||||
|
|
||||||
|
match output.status {
|
||||||
|
SurfaceStatus::Good | SurfaceStatus::Suboptimal => {
|
||||||
|
let id = output.texture_id.unwrap();
|
||||||
|
let rid = state.resource_table.add(crate::texture::WebGpuTexture(id));
|
||||||
|
Ok(WebGpuResult::rid(rid))
|
||||||
|
}
|
||||||
|
_ => Err(AnyError::msg("Invalid Surface Status")),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[op]
|
||||||
|
pub fn op_webgpu_surface_present(
|
||||||
|
state: &mut OpState,
|
||||||
|
device_rid: ResourceId,
|
||||||
|
surface_rid: ResourceId,
|
||||||
|
) -> Result<(), AnyError> {
|
||||||
|
let instance = state.borrow::<super::Instance>();
|
||||||
|
let device_resource = state
|
||||||
|
.resource_table
|
||||||
|
.get::<super::WebGpuDevice>(device_rid)?;
|
||||||
|
let device = device_resource.0;
|
||||||
|
let surface_resource =
|
||||||
|
state.resource_table.get::<WebGpuSurface>(surface_rid)?;
|
||||||
|
let surface = surface_resource.0;
|
||||||
|
|
||||||
|
let _ = gfx_select!(device => instance.surface_present(surface))?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
|
@ -34,6 +34,7 @@ pub struct CreateTextureArgs {
|
||||||
dimension: wgpu_types::TextureDimension,
|
dimension: wgpu_types::TextureDimension,
|
||||||
format: wgpu_types::TextureFormat,
|
format: wgpu_types::TextureFormat,
|
||||||
usage: u32,
|
usage: u32,
|
||||||
|
view_formats: Vec<wgpu_types::TextureFormat>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
|
@ -55,12 +56,13 @@ pub fn op_webgpu_create_texture(
|
||||||
dimension: args.dimension,
|
dimension: args.dimension,
|
||||||
format: args.format,
|
format: args.format,
|
||||||
usage: wgpu_types::TextureUsages::from_bits_truncate(args.usage),
|
usage: wgpu_types::TextureUsages::from_bits_truncate(args.usage),
|
||||||
|
view_formats: args.view_formats,
|
||||||
};
|
};
|
||||||
|
|
||||||
gfx_put!(device => instance.device_create_texture(
|
gfx_put!(device => instance.device_create_texture(
|
||||||
device,
|
device,
|
||||||
&descriptor,
|
&descriptor,
|
||||||
std::marker::PhantomData
|
()
|
||||||
) => state, WebGpuTexture)
|
) => state, WebGpuTexture)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,6 +111,6 @@ pub fn op_webgpu_create_texture_view(
|
||||||
gfx_put!(texture => instance.texture_create_view(
|
gfx_put!(texture => instance.texture_create_view(
|
||||||
texture,
|
texture,
|
||||||
&descriptor,
|
&descriptor,
|
||||||
std::marker::PhantomData
|
()
|
||||||
) => state, WebGpuTextureView)
|
) => state, WebGpuTextureView)
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ interface GPUSupportedLimits {
|
||||||
readonly attribute unsigned long maxTextureDimension3D;
|
readonly attribute unsigned long maxTextureDimension3D;
|
||||||
readonly attribute unsigned long maxTextureArrayLayers;
|
readonly attribute unsigned long maxTextureArrayLayers;
|
||||||
readonly attribute unsigned long maxBindGroups;
|
readonly attribute unsigned long maxBindGroups;
|
||||||
|
readonly attribute unsigned long maxBindingsPerBindGroup;
|
||||||
readonly attribute unsigned long maxDynamicUniformBuffersPerPipelineLayout;
|
readonly attribute unsigned long maxDynamicUniformBuffersPerPipelineLayout;
|
||||||
readonly attribute unsigned long maxDynamicStorageBuffersPerPipelineLayout;
|
readonly attribute unsigned long maxDynamicStorageBuffersPerPipelineLayout;
|
||||||
readonly attribute unsigned long maxSampledTexturesPerShaderStage;
|
readonly attribute unsigned long maxSampledTexturesPerShaderStage;
|
||||||
|
@ -25,6 +26,7 @@ interface GPUSupportedLimits {
|
||||||
readonly attribute unsigned long minUniformBufferOffsetAlignment;
|
readonly attribute unsigned long minUniformBufferOffsetAlignment;
|
||||||
readonly attribute unsigned long minStorageBufferOffsetAlignment;
|
readonly attribute unsigned long minStorageBufferOffsetAlignment;
|
||||||
readonly attribute unsigned long maxVertexBuffers;
|
readonly attribute unsigned long maxVertexBuffers;
|
||||||
|
readonly attribute unsigned long long maxBufferSize;
|
||||||
readonly attribute unsigned long maxVertexAttributes;
|
readonly attribute unsigned long maxVertexAttributes;
|
||||||
readonly attribute unsigned long maxVertexBufferArrayStride;
|
readonly attribute unsigned long maxVertexBufferArrayStride;
|
||||||
readonly attribute unsigned long maxInterStageShaderComponents;
|
readonly attribute unsigned long maxInterStageShaderComponents;
|
||||||
|
@ -49,10 +51,6 @@ interface GPUAdapterInfo {
|
||||||
readonly attribute DOMString description;
|
readonly attribute DOMString description;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum GPUPredefinedColorSpace {
|
|
||||||
"srgb",
|
|
||||||
};
|
|
||||||
|
|
||||||
interface mixin NavigatorGPU {
|
interface mixin NavigatorGPU {
|
||||||
[SameObject, SecureContext] readonly attribute GPU gpu;
|
[SameObject, SecureContext] readonly attribute GPU gpu;
|
||||||
};
|
};
|
||||||
|
@ -71,7 +69,7 @@ dictionary GPURequestAdapterOptions {
|
||||||
|
|
||||||
enum GPUPowerPreference {
|
enum GPUPowerPreference {
|
||||||
"low-power",
|
"low-power",
|
||||||
"high-performance",
|
"high-performance"
|
||||||
};
|
};
|
||||||
|
|
||||||
[Exposed=(Window, DedicatedWorker), SecureContext]
|
[Exposed=(Window, DedicatedWorker), SecureContext]
|
||||||
|
@ -91,7 +89,6 @@ dictionary GPUDeviceDescriptor : GPUObjectDescriptorBase {
|
||||||
|
|
||||||
enum GPUFeatureName {
|
enum GPUFeatureName {
|
||||||
"depth-clip-control",
|
"depth-clip-control",
|
||||||
"depth24unorm-stencil8",
|
|
||||||
"depth32float-stencil8",
|
"depth32float-stencil8",
|
||||||
"texture-compression-bc",
|
"texture-compression-bc",
|
||||||
"texture-compression-etc2",
|
"texture-compression-etc2",
|
||||||
|
@ -133,6 +130,11 @@ GPUDevice includes GPUObjectBase;
|
||||||
|
|
||||||
[Exposed=(Window, DedicatedWorker), SecureContext]
|
[Exposed=(Window, DedicatedWorker), SecureContext]
|
||||||
interface GPUBuffer {
|
interface GPUBuffer {
|
||||||
|
readonly attribute GPUSize64 size;
|
||||||
|
readonly attribute GPUBufferUsageFlags usage;
|
||||||
|
|
||||||
|
readonly attribute GPUBufferMapState mapState;
|
||||||
|
|
||||||
Promise<undefined> mapAsync(GPUMapModeFlags mode, optional GPUSize64 offset = 0, optional GPUSize64 size);
|
Promise<undefined> mapAsync(GPUMapModeFlags mode, optional GPUSize64 offset = 0, optional GPUSize64 size);
|
||||||
ArrayBuffer getMappedRange(optional GPUSize64 offset = 0, optional GPUSize64 size);
|
ArrayBuffer getMappedRange(optional GPUSize64 offset = 0, optional GPUSize64 size);
|
||||||
undefined unmap();
|
undefined unmap();
|
||||||
|
@ -141,6 +143,12 @@ interface GPUBuffer {
|
||||||
};
|
};
|
||||||
GPUBuffer includes GPUObjectBase;
|
GPUBuffer includes GPUObjectBase;
|
||||||
|
|
||||||
|
enum GPUBufferMapState {
|
||||||
|
"unmapped",
|
||||||
|
"pending",
|
||||||
|
"mapped"
|
||||||
|
};
|
||||||
|
|
||||||
dictionary GPUBufferDescriptor : GPUObjectDescriptorBase {
|
dictionary GPUBufferDescriptor : GPUObjectDescriptorBase {
|
||||||
required GPUSize64 size;
|
required GPUSize64 size;
|
||||||
required GPUBufferUsageFlags usage;
|
required GPUBufferUsageFlags usage;
|
||||||
|
@ -174,6 +182,15 @@ interface GPUTexture {
|
||||||
GPUTextureView createView(optional GPUTextureViewDescriptor descriptor = {});
|
GPUTextureView createView(optional GPUTextureViewDescriptor descriptor = {});
|
||||||
|
|
||||||
undefined destroy();
|
undefined destroy();
|
||||||
|
|
||||||
|
readonly attribute GPUIntegerCoordinate width;
|
||||||
|
readonly attribute GPUIntegerCoordinate height;
|
||||||
|
readonly attribute GPUIntegerCoordinate depthOrArrayLayers;
|
||||||
|
readonly attribute GPUIntegerCoordinate mipLevelCount;
|
||||||
|
readonly attribute GPUSize32 sampleCount;
|
||||||
|
readonly attribute GPUTextureDimension dimension;
|
||||||
|
readonly attribute GPUTextureFormat format;
|
||||||
|
readonly attribute GPUTextureUsageFlags usage;
|
||||||
};
|
};
|
||||||
GPUTexture includes GPUObjectBase;
|
GPUTexture includes GPUObjectBase;
|
||||||
|
|
||||||
|
@ -184,12 +201,13 @@ dictionary GPUTextureDescriptor : GPUObjectDescriptorBase {
|
||||||
GPUTextureDimension dimension = "2d";
|
GPUTextureDimension dimension = "2d";
|
||||||
required GPUTextureFormat format;
|
required GPUTextureFormat format;
|
||||||
required GPUTextureUsageFlags usage;
|
required GPUTextureUsageFlags usage;
|
||||||
|
sequence<GPUTextureFormat> viewFormats = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
enum GPUTextureDimension {
|
enum GPUTextureDimension {
|
||||||
"1d",
|
"1d",
|
||||||
"2d",
|
"2d",
|
||||||
"3d",
|
"3d"
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef [EnforceRange] unsigned long GPUTextureUsageFlags;
|
typedef [EnforceRange] unsigned long GPUTextureUsageFlags;
|
||||||
|
@ -223,13 +241,13 @@ enum GPUTextureViewDimension {
|
||||||
"2d-array",
|
"2d-array",
|
||||||
"cube",
|
"cube",
|
||||||
"cube-array",
|
"cube-array",
|
||||||
"3d",
|
"3d"
|
||||||
};
|
};
|
||||||
|
|
||||||
enum GPUTextureAspect {
|
enum GPUTextureAspect {
|
||||||
"all",
|
"all",
|
||||||
"stencil-only",
|
"stencil-only",
|
||||||
"depth-only",
|
"depth-only"
|
||||||
};
|
};
|
||||||
|
|
||||||
enum GPUTextureFormat {
|
enum GPUTextureFormat {
|
||||||
|
@ -287,9 +305,6 @@ enum GPUTextureFormat {
|
||||||
"depth24plus-stencil8",
|
"depth24plus-stencil8",
|
||||||
"depth32float",
|
"depth32float",
|
||||||
|
|
||||||
// "depth24unorm-stencil8" feature
|
|
||||||
"depth24unorm-stencil8",
|
|
||||||
|
|
||||||
// "depth32float-stencil8" feature
|
// "depth32float-stencil8" feature
|
||||||
"depth32float-stencil8",
|
"depth32float-stencil8",
|
||||||
|
|
||||||
|
@ -352,7 +367,7 @@ enum GPUTextureFormat {
|
||||||
"astc-12x10-unorm",
|
"astc-12x10-unorm",
|
||||||
"astc-12x10-unorm-srgb",
|
"astc-12x10-unorm-srgb",
|
||||||
"astc-12x12-unorm",
|
"astc-12x12-unorm",
|
||||||
"astc-12x12-unorm-srgb",
|
"astc-12x12-unorm-srgb"
|
||||||
};
|
};
|
||||||
|
|
||||||
[Exposed=(Window, DedicatedWorker), SecureContext]
|
[Exposed=(Window, DedicatedWorker), SecureContext]
|
||||||
|
@ -376,17 +391,17 @@ dictionary GPUSamplerDescriptor : GPUObjectDescriptorBase {
|
||||||
enum GPUAddressMode {
|
enum GPUAddressMode {
|
||||||
"clamp-to-edge",
|
"clamp-to-edge",
|
||||||
"repeat",
|
"repeat",
|
||||||
"mirror-repeat",
|
"mirror-repeat"
|
||||||
};
|
};
|
||||||
|
|
||||||
enum GPUFilterMode {
|
enum GPUFilterMode {
|
||||||
"nearest",
|
"nearest",
|
||||||
"linear",
|
"linear"
|
||||||
};
|
};
|
||||||
|
|
||||||
enum GPUMipmapFilterMode {
|
enum GPUMipmapFilterMode {
|
||||||
"nearest",
|
"nearest",
|
||||||
"linear",
|
"linear"
|
||||||
};
|
};
|
||||||
|
|
||||||
enum GPUCompareFunction {
|
enum GPUCompareFunction {
|
||||||
|
@ -397,7 +412,7 @@ enum GPUCompareFunction {
|
||||||
"greater",
|
"greater",
|
||||||
"not-equal",
|
"not-equal",
|
||||||
"greater-equal",
|
"greater-equal",
|
||||||
"always",
|
"always"
|
||||||
};
|
};
|
||||||
|
|
||||||
[Exposed=(Window, DedicatedWorker), SecureContext]
|
[Exposed=(Window, DedicatedWorker), SecureContext]
|
||||||
|
@ -430,7 +445,7 @@ namespace GPUShaderStage {
|
||||||
enum GPUBufferBindingType {
|
enum GPUBufferBindingType {
|
||||||
"uniform",
|
"uniform",
|
||||||
"storage",
|
"storage",
|
||||||
"read-only-storage",
|
"read-only-storage"
|
||||||
};
|
};
|
||||||
|
|
||||||
dictionary GPUBufferBindingLayout {
|
dictionary GPUBufferBindingLayout {
|
||||||
|
@ -442,7 +457,7 @@ dictionary GPUBufferBindingLayout {
|
||||||
enum GPUSamplerBindingType {
|
enum GPUSamplerBindingType {
|
||||||
"filtering",
|
"filtering",
|
||||||
"non-filtering",
|
"non-filtering",
|
||||||
"comparison",
|
"comparison"
|
||||||
};
|
};
|
||||||
|
|
||||||
dictionary GPUSamplerBindingLayout {
|
dictionary GPUSamplerBindingLayout {
|
||||||
|
@ -454,7 +469,7 @@ enum GPUTextureSampleType {
|
||||||
"unfilterable-float",
|
"unfilterable-float",
|
||||||
"depth",
|
"depth",
|
||||||
"sint",
|
"sint",
|
||||||
"uint",
|
"uint"
|
||||||
};
|
};
|
||||||
|
|
||||||
dictionary GPUTextureBindingLayout {
|
dictionary GPUTextureBindingLayout {
|
||||||
|
@ -464,7 +479,7 @@ dictionary GPUTextureBindingLayout {
|
||||||
};
|
};
|
||||||
|
|
||||||
enum GPUStorageTextureAccess {
|
enum GPUStorageTextureAccess {
|
||||||
"write-only",
|
"write-only"
|
||||||
};
|
};
|
||||||
|
|
||||||
dictionary GPUStorageTextureBindingLayout {
|
dictionary GPUStorageTextureBindingLayout {
|
||||||
|
@ -513,13 +528,12 @@ GPUShaderModule includes GPUObjectBase;
|
||||||
|
|
||||||
dictionary GPUShaderModuleDescriptor : GPUObjectDescriptorBase {
|
dictionary GPUShaderModuleDescriptor : GPUObjectDescriptorBase {
|
||||||
required USVString code;
|
required USVString code;
|
||||||
object sourceMap;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum GPUCompilationMessageType {
|
enum GPUCompilationMessageType {
|
||||||
"error",
|
"error",
|
||||||
"warning",
|
"warning",
|
||||||
"info",
|
"info"
|
||||||
};
|
};
|
||||||
|
|
||||||
[Exposed=(Window, DedicatedWorker), Serializable, SecureContext]
|
[Exposed=(Window, DedicatedWorker), Serializable, SecureContext]
|
||||||
|
@ -555,7 +569,7 @@ dictionary GPUProgrammableStage {
|
||||||
record<USVString, GPUPipelineConstantValue> constants;
|
record<USVString, GPUPipelineConstantValue> constants;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef double GPUPipelineConstantValue; // May represent WGSL’s bool, f32, i32, u32.
|
typedef double GPUPipelineConstantValue; // May represent WGSL’s bool, f32, i32, u32, and f16 if enabled.
|
||||||
|
|
||||||
[Exposed=(Window, DedicatedWorker), SecureContext]
|
[Exposed=(Window, DedicatedWorker), SecureContext]
|
||||||
interface GPUComputePipeline {
|
interface GPUComputePipeline {
|
||||||
|
@ -596,18 +610,18 @@ enum GPUPrimitiveTopology {
|
||||||
"line-list",
|
"line-list",
|
||||||
"line-strip",
|
"line-strip",
|
||||||
"triangle-list",
|
"triangle-list",
|
||||||
"triangle-strip",
|
"triangle-strip"
|
||||||
};
|
};
|
||||||
|
|
||||||
enum GPUFrontFace {
|
enum GPUFrontFace {
|
||||||
"ccw",
|
"ccw",
|
||||||
"cw",
|
"cw"
|
||||||
};
|
};
|
||||||
|
|
||||||
enum GPUCullMode {
|
enum GPUCullMode {
|
||||||
"none",
|
"none",
|
||||||
"front",
|
"front",
|
||||||
"back",
|
"back"
|
||||||
};
|
};
|
||||||
|
|
||||||
dictionary GPUMultisampleState {
|
dictionary GPUMultisampleState {
|
||||||
|
@ -661,7 +675,7 @@ enum GPUBlendFactor {
|
||||||
"one-minus-dst-alpha",
|
"one-minus-dst-alpha",
|
||||||
"src-alpha-saturated",
|
"src-alpha-saturated",
|
||||||
"constant",
|
"constant",
|
||||||
"one-minus-constant",
|
"one-minus-constant"
|
||||||
};
|
};
|
||||||
|
|
||||||
enum GPUBlendOperation {
|
enum GPUBlendOperation {
|
||||||
|
@ -669,7 +683,7 @@ enum GPUBlendOperation {
|
||||||
"subtract",
|
"subtract",
|
||||||
"reverse-subtract",
|
"reverse-subtract",
|
||||||
"min",
|
"min",
|
||||||
"max",
|
"max"
|
||||||
};
|
};
|
||||||
|
|
||||||
dictionary GPUDepthStencilState {
|
dictionary GPUDepthStencilState {
|
||||||
|
@ -704,12 +718,12 @@ enum GPUStencilOperation {
|
||||||
"increment-clamp",
|
"increment-clamp",
|
||||||
"decrement-clamp",
|
"decrement-clamp",
|
||||||
"increment-wrap",
|
"increment-wrap",
|
||||||
"decrement-wrap",
|
"decrement-wrap"
|
||||||
};
|
};
|
||||||
|
|
||||||
enum GPUIndexFormat {
|
enum GPUIndexFormat {
|
||||||
"uint16",
|
"uint16",
|
||||||
"uint32",
|
"uint32"
|
||||||
};
|
};
|
||||||
|
|
||||||
enum GPUVertexFormat {
|
enum GPUVertexFormat {
|
||||||
|
@ -742,12 +756,12 @@ enum GPUVertexFormat {
|
||||||
"sint32",
|
"sint32",
|
||||||
"sint32x2",
|
"sint32x2",
|
||||||
"sint32x3",
|
"sint32x3",
|
||||||
"sint32x4",
|
"sint32x4"
|
||||||
};
|
};
|
||||||
|
|
||||||
enum GPUVertexStepMode {
|
enum GPUVertexStepMode {
|
||||||
"vertex",
|
"vertex",
|
||||||
"instance",
|
"instance"
|
||||||
};
|
};
|
||||||
|
|
||||||
dictionary GPUVertexState : GPUProgrammableStage {
|
dictionary GPUVertexState : GPUProgrammableStage {
|
||||||
|
@ -767,6 +781,23 @@ dictionary GPUVertexAttribute {
|
||||||
required GPUIndex32 shaderLocation;
|
required GPUIndex32 shaderLocation;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
dictionary GPUImageDataLayout {
|
||||||
|
GPUSize64 offset = 0;
|
||||||
|
GPUSize32 bytesPerRow;
|
||||||
|
GPUSize32 rowsPerImage;
|
||||||
|
};
|
||||||
|
|
||||||
|
dictionary GPUImageCopyBuffer : GPUImageDataLayout {
|
||||||
|
required GPUBuffer buffer;
|
||||||
|
};
|
||||||
|
|
||||||
|
dictionary GPUImageCopyTexture {
|
||||||
|
required GPUTexture texture;
|
||||||
|
GPUIntegerCoordinate mipLevel = 0;
|
||||||
|
GPUOrigin3D origin = {};
|
||||||
|
GPUTextureAspect aspect = "all";
|
||||||
|
};
|
||||||
|
|
||||||
[Exposed=(Window, DedicatedWorker), SecureContext]
|
[Exposed=(Window, DedicatedWorker), SecureContext]
|
||||||
interface GPUCommandBuffer {
|
interface GPUCommandBuffer {
|
||||||
};
|
};
|
||||||
|
@ -828,23 +859,6 @@ GPUCommandEncoder includes GPUDebugCommandsMixin;
|
||||||
dictionary GPUCommandEncoderDescriptor : GPUObjectDescriptorBase {
|
dictionary GPUCommandEncoderDescriptor : GPUObjectDescriptorBase {
|
||||||
};
|
};
|
||||||
|
|
||||||
dictionary GPUImageDataLayout {
|
|
||||||
GPUSize64 offset = 0;
|
|
||||||
GPUSize32 bytesPerRow;
|
|
||||||
GPUSize32 rowsPerImage;
|
|
||||||
};
|
|
||||||
|
|
||||||
dictionary GPUImageCopyBuffer : GPUImageDataLayout {
|
|
||||||
required GPUBuffer buffer;
|
|
||||||
};
|
|
||||||
|
|
||||||
dictionary GPUImageCopyTexture {
|
|
||||||
required GPUTexture texture;
|
|
||||||
GPUIntegerCoordinate mipLevel = 0;
|
|
||||||
GPUOrigin3D origin = {};
|
|
||||||
GPUTextureAspect aspect = "all";
|
|
||||||
};
|
|
||||||
|
|
||||||
interface mixin GPUBindingCommandsMixin {
|
interface mixin GPUBindingCommandsMixin {
|
||||||
undefined setBindGroup(GPUIndex32 index, GPUBindGroup bindGroup,
|
undefined setBindGroup(GPUIndex32 index, GPUBindGroup bindGroup,
|
||||||
optional sequence<GPUBufferDynamicOffset> dynamicOffsets = []);
|
optional sequence<GPUBufferDynamicOffset> dynamicOffsets = []);
|
||||||
|
@ -914,7 +928,6 @@ GPURenderPassEncoder includes GPURenderCommandsMixin;
|
||||||
dictionary GPURenderPassDescriptor : GPUObjectDescriptorBase {
|
dictionary GPURenderPassDescriptor : GPUObjectDescriptorBase {
|
||||||
required sequence<GPURenderPassColorAttachment?> colorAttachments;
|
required sequence<GPURenderPassColorAttachment?> colorAttachments;
|
||||||
GPURenderPassDepthStencilAttachment depthStencilAttachment;
|
GPURenderPassDepthStencilAttachment depthStencilAttachment;
|
||||||
GPUQuerySet occlusionQuerySet;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
dictionary GPURenderPassColorAttachment {
|
dictionary GPURenderPassColorAttachment {
|
||||||
|
@ -942,15 +955,15 @@ dictionary GPURenderPassDepthStencilAttachment {
|
||||||
|
|
||||||
enum GPULoadOp {
|
enum GPULoadOp {
|
||||||
"load",
|
"load",
|
||||||
"clear",
|
"clear"
|
||||||
};
|
};
|
||||||
|
|
||||||
enum GPUStoreOp {
|
enum GPUStoreOp {
|
||||||
"store",
|
"store",
|
||||||
"discard",
|
"discard"
|
||||||
};
|
};
|
||||||
|
|
||||||
dictionary GPURenderPassLayout: GPUObjectDescriptorBase {
|
dictionary GPURenderPassLayout : GPUObjectDescriptorBase {
|
||||||
required sequence<GPUTextureFormat?> colorFormats;
|
required sequence<GPUTextureFormat?> colorFormats;
|
||||||
GPUTextureFormat depthStencilFormat;
|
GPUTextureFormat depthStencilFormat;
|
||||||
GPUSize32 sampleCount = 1;
|
GPUSize32 sampleCount = 1;
|
||||||
|
@ -1020,6 +1033,9 @@ GPUQueue includes GPUObjectBase;
|
||||||
[Exposed=(Window, DedicatedWorker), SecureContext]
|
[Exposed=(Window, DedicatedWorker), SecureContext]
|
||||||
interface GPUQuerySet {
|
interface GPUQuerySet {
|
||||||
undefined destroy();
|
undefined destroy();
|
||||||
|
|
||||||
|
readonly attribute GPUQueryType type;
|
||||||
|
readonly attribute GPUSize32 count;
|
||||||
};
|
};
|
||||||
GPUQuerySet includes GPUObjectBase;
|
GPUQuerySet includes GPUObjectBase;
|
||||||
|
|
||||||
|
@ -1032,7 +1048,7 @@ dictionary GPUQuerySetDescriptor : GPUObjectDescriptorBase {
|
||||||
enum GPUQueryType {
|
enum GPUQueryType {
|
||||||
"occlusion",
|
"occlusion",
|
||||||
"pipeline-statistics",
|
"pipeline-statistics",
|
||||||
"timestamp",
|
"timestamp"
|
||||||
};
|
};
|
||||||
|
|
||||||
enum GPUPipelineStatisticName {
|
enum GPUPipelineStatisticName {
|
||||||
|
@ -1043,8 +1059,31 @@ enum GPUPipelineStatisticName {
|
||||||
"compute-shader-invocations",
|
"compute-shader-invocations",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
[Exposed=(Window, DedicatedWorker), SecureContext]
|
||||||
|
interface GPUCanvasContext {
|
||||||
|
readonly attribute (HTMLCanvasElement or OffscreenCanvas) canvas;
|
||||||
|
|
||||||
|
undefined configure(GPUCanvasConfiguration configuration);
|
||||||
|
undefined unconfigure();
|
||||||
|
|
||||||
|
GPUTexture getCurrentTexture();
|
||||||
|
};
|
||||||
|
|
||||||
|
enum GPUCanvasAlphaMode {
|
||||||
|
"opaque",
|
||||||
|
"premultiplied"
|
||||||
|
};
|
||||||
|
|
||||||
|
dictionary GPUCanvasConfiguration {
|
||||||
|
required GPUDevice device;
|
||||||
|
required GPUTextureFormat format;
|
||||||
|
GPUTextureUsageFlags usage = 0x10; // GPUTextureUsage.RENDER_ATTACHMENT
|
||||||
|
GPUCanvasAlphaMode alphaMode = "opaque";
|
||||||
|
sequence<GPUTextureFormat> viewFormats = [];
|
||||||
|
};
|
||||||
|
|
||||||
enum GPUDeviceLostReason {
|
enum GPUDeviceLostReason {
|
||||||
"destroyed",
|
"destroyed"
|
||||||
};
|
};
|
||||||
|
|
||||||
[Exposed=(Window, DedicatedWorker), SecureContext]
|
[Exposed=(Window, DedicatedWorker), SecureContext]
|
||||||
|
@ -1057,44 +1096,31 @@ partial interface GPUDevice {
|
||||||
readonly attribute Promise<GPUDeviceLostInfo> lost;
|
readonly attribute Promise<GPUDeviceLostInfo> lost;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum GPUErrorFilter {
|
|
||||||
"out-of-memory",
|
|
||||||
"validation",
|
|
||||||
};
|
|
||||||
|
|
||||||
[Exposed=(Window, DedicatedWorker), SecureContext]
|
[Exposed=(Window, DedicatedWorker), SecureContext]
|
||||||
interface GPUError {
|
interface GPUError {
|
||||||
readonly attribute DOMString message;
|
readonly attribute DOMString message;
|
||||||
};
|
};
|
||||||
|
|
||||||
[Exposed=(Window, DedicatedWorker), SecureContext]
|
|
||||||
interface GPUOutOfMemoryError : GPUError {
|
|
||||||
constructor(DOMString message);
|
|
||||||
};
|
|
||||||
|
|
||||||
[Exposed=(Window, DedicatedWorker), SecureContext]
|
[Exposed=(Window, DedicatedWorker), SecureContext]
|
||||||
interface GPUValidationError : GPUError {
|
interface GPUValidationError : GPUError {
|
||||||
constructor(DOMString message);
|
constructor(DOMString message);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
[Exposed=(Window, DedicatedWorker), SecureContext]
|
||||||
|
interface GPUOutOfMemoryError : GPUError {
|
||||||
|
constructor(DOMString message);
|
||||||
|
};
|
||||||
|
|
||||||
|
enum GPUErrorFilter {
|
||||||
|
"validation",
|
||||||
|
"out-of-memory"
|
||||||
|
};
|
||||||
|
|
||||||
partial interface GPUDevice {
|
partial interface GPUDevice {
|
||||||
undefined pushErrorScope(GPUErrorFilter filter);
|
undefined pushErrorScope(GPUErrorFilter filter);
|
||||||
Promise<GPUError?> popErrorScope();
|
Promise<GPUError?> popErrorScope();
|
||||||
};
|
};
|
||||||
|
|
||||||
[Exposed=(Window, DedicatedWorker), SecureContext]
|
|
||||||
interface GPUUncapturedErrorEvent : Event {
|
|
||||||
constructor(
|
|
||||||
DOMString type,
|
|
||||||
GPUUncapturedErrorEventInit gpuUncapturedErrorEventInitDict
|
|
||||||
);
|
|
||||||
readonly attribute GPUError error;
|
|
||||||
};
|
|
||||||
|
|
||||||
dictionary GPUUncapturedErrorEventInit : EventInit {
|
|
||||||
required GPUError error;
|
|
||||||
};
|
|
||||||
|
|
||||||
partial interface GPUDevice {
|
partial interface GPUDevice {
|
||||||
[Exposed=(Window, DedicatedWorker)]
|
[Exposed=(Window, DedicatedWorker)]
|
||||||
attribute EventHandler onuncapturederror;
|
attribute EventHandler onuncapturederror;
|
||||||
|
|
|
@ -144,8 +144,10 @@
|
||||||
|
|
||||||
GPU: util.nonEnumerable(webgpu.GPU),
|
GPU: util.nonEnumerable(webgpu.GPU),
|
||||||
GPUAdapter: util.nonEnumerable(webgpu.GPUAdapter),
|
GPUAdapter: util.nonEnumerable(webgpu.GPUAdapter),
|
||||||
|
GPUAdapterInfo: util.nonEnumerable(webgpu.GPUAdapterInfo),
|
||||||
GPUSupportedLimits: util.nonEnumerable(webgpu.GPUSupportedLimits),
|
GPUSupportedLimits: util.nonEnumerable(webgpu.GPUSupportedLimits),
|
||||||
GPUSupportedFeatures: util.nonEnumerable(webgpu.GPUSupportedFeatures),
|
GPUSupportedFeatures: util.nonEnumerable(webgpu.GPUSupportedFeatures),
|
||||||
|
GPUDeviceLostInfo: util.nonEnumerable(webgpu.GPUDeviceLostInfo),
|
||||||
GPUDevice: util.nonEnumerable(webgpu.GPUDevice),
|
GPUDevice: util.nonEnumerable(webgpu.GPUDevice),
|
||||||
GPUQueue: util.nonEnumerable(webgpu.GPUQueue),
|
GPUQueue: util.nonEnumerable(webgpu.GPUQueue),
|
||||||
GPUBuffer: util.nonEnumerable(webgpu.GPUBuffer),
|
GPUBuffer: util.nonEnumerable(webgpu.GPUBuffer),
|
||||||
|
@ -170,6 +172,7 @@
|
||||||
GPURenderBundleEncoder: util.nonEnumerable(webgpu.GPURenderBundleEncoder),
|
GPURenderBundleEncoder: util.nonEnumerable(webgpu.GPURenderBundleEncoder),
|
||||||
GPURenderBundle: util.nonEnumerable(webgpu.GPURenderBundle),
|
GPURenderBundle: util.nonEnumerable(webgpu.GPURenderBundle),
|
||||||
GPUQuerySet: util.nonEnumerable(webgpu.GPUQuerySet),
|
GPUQuerySet: util.nonEnumerable(webgpu.GPUQuerySet),
|
||||||
|
GPUError: util.nonEnumerable(webgpu.GPUError),
|
||||||
GPUOutOfMemoryError: util.nonEnumerable(webgpu.GPUOutOfMemoryError),
|
GPUOutOfMemoryError: util.nonEnumerable(webgpu.GPUOutOfMemoryError),
|
||||||
GPUValidationError: util.nonEnumerable(webgpu.GPUValidationError),
|
GPUValidationError: util.nonEnumerable(webgpu.GPUValidationError),
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
|
|
||||||
import { join, ROOT_PATH } from "./util.js";
|
import { join, ROOT_PATH } from "./util.js";
|
||||||
|
|
||||||
const COMMIT = "076df1a56812eee01614b7a3a4c88798012e79ab";
|
const COMMIT = "659f6977051345e4e06ab4832c6f7d268f25a1ad";
|
||||||
const REPO = "gfx-rs/wgpu";
|
const REPO = "gfx-rs/wgpu";
|
||||||
const V_WGPU = "0.13";
|
const V_WGPU = "0.15";
|
||||||
const TARGET_DIR = join(ROOT_PATH, "ext", "webgpu");
|
const TARGET_DIR = join(ROOT_PATH, "ext", "webgpu");
|
||||||
|
|
||||||
async function bash(subcmd, opts = {}) {
|
async function bash(subcmd, opts = {}) {
|
||||||
|
@ -59,21 +59,25 @@ async function patchCargo() {
|
||||||
data
|
data
|
||||||
.replace(/^version = .*/m, `version = "${vDenoWebgpu}"`)
|
.replace(/^version = .*/m, `version = "${vDenoWebgpu}"`)
|
||||||
.replace(
|
.replace(
|
||||||
/^wgpu-core \= .*$/gm,
|
/^repository.workspace = true/m,
|
||||||
`wgpu-core = { version = "${V_WGPU}", features = ["trace", "replay", "serde"] }`,
|
`repository = "https://github.com/gfx-rs/wgpu"`,
|
||||||
)
|
)
|
||||||
.replace(
|
.replace(
|
||||||
/^wgpu-types \= .*$/gm,
|
/^serde = { workspace = true, features = ["derive"] }/m,
|
||||||
`wgpu-types = { version = "${V_WGPU}", features = ["trace", "replay", "serde"] }`,
|
`serde.workspace = true`,
|
||||||
|
)
|
||||||
|
.replace(
|
||||||
|
/^tokio = { workspace = true, features = ["full"] }/m,
|
||||||
|
`tokio.workspace = true`,
|
||||||
),
|
),
|
||||||
// .replace(
|
);
|
||||||
// /^wgpu-core \= .*$/gm,
|
|
||||||
// `wgpu-core = { git = "https://github.com/${REPO}", rev = "${COMMIT}", features = ["trace", "replay", "serde"] }`,
|
await patchFile(
|
||||||
// )
|
join(ROOT_PATH, "Cargo.toml"),
|
||||||
// .replace(
|
(data) =>
|
||||||
// /^wgpu-types \= .*$/gm,
|
data
|
||||||
// `wgpu-types = { git = "https://github.com/${REPO}", rev = "${COMMIT}", features = ["trace", "replay", "serde"] }`,
|
.replace(/^wgpu-core = .*/m, `wgpu-core = "${V_WGPU}"`)
|
||||||
// )
|
.replace(/^wgpu-types = .*/m, `wgpu-types = "${V_WGPU}"`),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue