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;
9
10use crate::id::{
11    AdapterId, BindGroupId, BindGroupLayoutId, BufferId, CommandBufferId, CommandEncoderId,
12    ComputePassEncoderId, ComputePipelineId, DeviceId, ExternalTextureId, PipelineLayoutId,
13    QuerySetId, RenderBundleEncoderId, RenderBundleId, RenderPassEncoderId, RenderPipelineId,
14    SamplerId, ShaderModuleId, TextureId, TextureViewId,
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    FreeShaderModule(ShaderModuleId),
37    FreeRenderBundle(RenderBundleId),
38    FreeQuerySet(QuerySetId),
39    FreeComputePass(ComputePassEncoderId),
40    FreeRenderPass(RenderPassEncoderId),
41    FreeExternalTexture(ExternalTextureId),
42    FreeRenderBundleEncoder(RenderBundleEncoderId),
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}