1use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
6use serde::{Deserialize, Serialize};
7pub use wgpu_core::id::markers::{
8 ComputePassEncoder as ComputePass, RenderPassEncoder as RenderPass,
9};
10use wgpu_core::id::{
11 AdapterId, BindGroupId, BindGroupLayoutId, BufferId, CommandBufferId, CommandEncoderId,
12 ComputePipelineId, DeviceId, PipelineLayoutId, QueueId, RenderBundleId, RenderPipelineId,
13 SamplerId, ShaderModuleId, SurfaceId, TextureId, TextureViewId,
14};
15pub use wgpu_core::id::{
16 ComputePassEncoderId as ComputePassId, RenderPassEncoderId as RenderPassId,
17};
18
19macro_rules! webgpu_resource {
20 ($name:ident, $id:ty) => {
21 #[derive(Clone, Copy, Debug, Deserialize, Hash, PartialEq, PartialOrd, Serialize)]
22 pub struct $name(pub $id);
23
24 impl MallocSizeOf for $name {
25 fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize {
26 0
27 }
28 }
29
30 impl Eq for $name {}
31 };
32}
33
34webgpu_resource!(WebGPUAdapter, AdapterId);
35webgpu_resource!(WebGPUBindGroup, BindGroupId);
36webgpu_resource!(WebGPUBindGroupLayout, BindGroupLayoutId);
37webgpu_resource!(WebGPUBuffer, BufferId);
38webgpu_resource!(WebGPUCommandBuffer, CommandBufferId);
39webgpu_resource!(WebGPUCommandEncoder, CommandEncoderId);
40webgpu_resource!(WebGPUComputePipeline, ComputePipelineId);
41webgpu_resource!(WebGPUDevice, DeviceId);
42webgpu_resource!(WebGPUPipelineLayout, PipelineLayoutId);
43webgpu_resource!(WebGPUQueue, QueueId);
44webgpu_resource!(WebGPURenderBundle, RenderBundleId);
45webgpu_resource!(WebGPURenderPipeline, RenderPipelineId);
46webgpu_resource!(WebGPUSampler, SamplerId);
47webgpu_resource!(WebGPUShaderModule, ShaderModuleId);
48webgpu_resource!(WebGPUSurface, SurfaceId);
49webgpu_resource!(WebGPUTexture, TextureId);
50webgpu_resource!(WebGPUTextureView, TextureViewId);
51webgpu_resource!(WebGPUComputePass, ComputePassId);
52webgpu_resource!(WebGPURenderPass, RenderPassId);
53webgpu_resource!(WebGPUContextId, u64);