Skip to main content

script_webgpu/
lib.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5#![cfg_attr(crown, feature(register_tool))]
6// Register the linter `crown`, which is the Servo-specific linter for the script crate.
7#![cfg_attr(crown, register_tool(crown))]
8
9pub mod datablock;
10pub mod gpu;
11pub mod gpuadapter;
12pub mod gpuadapterinfo;
13pub mod gpubindgroup;
14pub mod gpubindgrouplayout;
15pub mod gpubuffer;
16pub mod gpubufferusage;
17pub mod gpucolorwrite;
18pub mod gpucommandbuffer;
19pub mod gpucommandencoder;
20pub mod gpucompilationinfo;
21pub mod gpucompilationmessage;
22pub mod gpucomputepassencoder;
23pub mod gpucomputepipeline;
24pub mod gpuconvert;
25pub mod gpudevice;
26pub mod gpudevicelostinfo;
27pub mod gpuerror;
28pub mod gpuexternaltexture;
29pub mod gpuinternalerror;
30pub mod gpumapmode;
31pub mod gpuoutofmemoryerror;
32pub mod gpupipelineerror;
33pub mod gpupipelinelayout;
34pub mod gpuqueryset;
35pub mod gpuqueue;
36pub mod gpurenderbundle;
37pub mod gpurenderbundleencoder;
38pub mod gpurenderpassencoder;
39pub mod gpurenderpipeline;
40pub mod gpusampler;
41pub mod gpushadermodule;
42pub mod gpushaderstage;
43pub mod gpusupportedfeatures;
44pub mod gpusupportedlimits;
45pub mod gputexture;
46pub mod gputextureusage;
47pub mod gputextureview;
48pub mod gpuuncapturederrorevent;
49pub mod gpuvalidationerror;
50pub mod identityhub;
51pub mod traits;
52pub mod wgsllanguagefeatures;
53
54pub(crate) use js::gc::Traceable as JSTraceable;
55pub(crate) use jstraceable_derive::JSTraceable;
56pub(crate) use script_bindings::reflector::{DomObject, MutDomObject, Reflector};
57pub(crate) use script_bindings::trace::CustomTraceable;
58use webgpu_traits::id::PipelineLayoutId;
59
60pub(crate) use crate::dom::bindings::inheritance::HasParent;
61
62pub enum PipelineLayout {
63    Implicit,
64    Explicit(PipelineLayoutId),
65}
66
67impl PipelineLayout {
68    pub fn explicit(&self) -> Option<PipelineLayoutId> {
69        match self {
70            PipelineLayout::Explicit(layout_id) => Some(*layout_id),
71            PipelineLayout::Implicit => None,
72        }
73    }
74}
75
76// Reexports
77pub(crate) mod dom {
78    pub(crate) mod types {}
79    pub(crate) mod bindings {
80        pub(crate) use script_bindings::*;
81    }
82}
83
84/// Generated JS-Rust bindings.
85#[allow(missing_docs, non_snake_case)]
86pub(crate) mod codegen {
87    #[expect(unused)]
88    pub(crate) mod Bindings {
89        use std::ptr;
90
91        use js::context::JSContext;
92        use js::gc::HandleObject;
93        pub(crate) use script_bindings::DomTypes;
94        use script_bindings::codegen::PrototypeList;
95        use script_bindings::conversions::IDLInterface;
96        use script_bindings::reflector::DomObjectWrap;
97        pub(crate) use script_bindings::reflector::Reflector;
98        use script_bindings::root::{Dom, DomRoot, Root};
99        use script_bindings::utils::DOMClass;
100        use script_bindings::weakref::WeakReferenceable;
101
102        use crate::gpu::GPU;
103        use crate::gpuadapter::GPUAdapter;
104        use crate::gpuadapterinfo::GPUAdapterInfo;
105        use crate::gpubindgroup::GPUBindGroup;
106        use crate::gpubindgrouplayout::GPUBindGroupLayout;
107        use crate::gpubuffer::GPUBuffer;
108        use crate::gpubufferusage::GPUBufferUsage;
109        use crate::gpucolorwrite::GPUColorWrite;
110        use crate::gpucommandbuffer::GPUCommandBuffer;
111        use crate::gpucommandencoder::GPUCommandEncoder;
112        use crate::gpucompilationinfo::GPUCompilationInfo;
113        use crate::gpucompilationmessage::GPUCompilationMessage;
114        use crate::gpucomputepassencoder::GPUComputePassEncoder;
115        use crate::gpucomputepipeline::GPUComputePipeline;
116        use crate::gpudevice::GPUDevice;
117        use crate::gpudevicelostinfo::GPUDeviceLostInfo;
118        use crate::gpuerror::GPUError;
119        use crate::gpuexternaltexture::GPUExternalTexture;
120        use crate::gpuinternalerror::GPUInternalError;
121        use crate::gpumapmode::GPUMapMode;
122        use crate::gpuoutofmemoryerror::GPUOutOfMemoryError;
123        use crate::gpupipelineerror::GPUPipelineError;
124        use crate::gpupipelinelayout::GPUPipelineLayout;
125        use crate::gpuqueryset::GPUQuerySet;
126        use crate::gpuqueue::GPUQueue;
127        use crate::gpurenderbundle::GPURenderBundle;
128        use crate::gpurenderbundleencoder::GPURenderBundleEncoder;
129        use crate::gpurenderpassencoder::GPURenderPassEncoder;
130        use crate::gpurenderpipeline::GPURenderPipeline;
131        use crate::gpusampler::GPUSampler;
132        use crate::gpushadermodule::GPUShaderModule;
133        use crate::gpushaderstage::GPUShaderStage;
134        use crate::gpusupportedfeatures::GPUSupportedFeatures;
135        use crate::gpusupportedlimits::GPUSupportedLimits;
136        use crate::gputexture::GPUTexture;
137        use crate::gputextureusage::GPUTextureUsage;
138        use crate::gputextureview::GPUTextureView;
139        use crate::gpuuncapturederrorevent::GPUUncapturedErrorEvent;
140        use crate::gpuvalidationerror::GPUValidationError;
141        use crate::traits::Equivalence;
142        use crate::wgsllanguagefeatures::WGSLLanguageFeatures;
143        include!(concat!(
144            env!("OUT_DIR"),
145            "/ConcreteBindings/WebGPUBinding.rs"
146        ));
147        include!(concat!(env!("OUT_DIR"), "/ConcreteInheritTypes.rs"));
148    }
149}