Skip to main content

webgpu_traits/messages/
to_script.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//! IPC messages that are sent to the ScriptThread.
6
7use serde::{Deserialize, Serialize};
8use servo_base::id::PipelineId;
9use wgpu_core::id::{
10    AdapterId, BindGroupId, BindGroupLayoutId, BufferId, CommandBufferId, CommandEncoderId,
11    ComputePassEncoderId, ComputePipelineId, DeviceId, ExternalTextureId, PipelineLayoutId,
12    QuerySetId, RenderBundleId, RenderPassEncoderId, RenderPipelineId, SamplerId, ShaderModuleId,
13    StagingBufferId, SurfaceId, TextureId, TextureViewId,
14};
15
16use crate::{DeviceLostReason, Error, WebGPUDevice};
17
18#[derive(Clone, Debug, Deserialize, Serialize)]
19pub enum WebGPUMsg {
20    FreeAdapter(AdapterId),
21    FreeDevice {
22        device_id: DeviceId,
23        pipeline_id: PipelineId,
24    },
25    FreeBuffer(BufferId),
26    FreePipelineLayout(PipelineLayoutId),
27    FreeComputePipeline(ComputePipelineId),
28    FreeRenderPipeline(RenderPipelineId),
29    FreeBindGroup(BindGroupId),
30    FreeBindGroupLayout(BindGroupLayoutId),
31    FreeCommandEncoder(CommandEncoderId),
32    FreeCommandBuffer(CommandBufferId),
33    FreeTexture(TextureId),
34    FreeTextureView(TextureViewId),
35    FreeSampler(SamplerId),
36    FreeSurface(SurfaceId),
37    FreeShaderModule(ShaderModuleId),
38    FreeRenderBundle(RenderBundleId),
39    FreeStagingBuffer(StagingBufferId),
40    FreeQuerySet(QuerySetId),
41    FreeComputePass(ComputePassEncoderId),
42    FreeRenderPass(RenderPassEncoderId),
43    FreeExternalTexture(ExternalTextureId),
44    UncapturedError {
45        device: WebGPUDevice,
46        pipeline_id: PipelineId,
47        error: Error,
48    },
49    DeviceLost {
50        device: WebGPUDevice,
51        pipeline_id: PipelineId,
52        reason: DeviceLostReason,
53        msg: String,
54    },
55    Exit,
56}