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, PipelineLayoutId, QuerySetId,
12    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    UncapturedError {
44        device: WebGPUDevice,
45        pipeline_id: PipelineId,
46        error: Error,
47    },
48    DeviceLost {
49        device: WebGPUDevice,
50        pipeline_id: PipelineId,
51        reason: DeviceLostReason,
52        msg: String,
53    },
54    Exit,
55}