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