1use alloc::vec::Vec;
2use bitflags::bitflags;
3use core::ops::Deref;
4
5use crate::primitive::{Extent2D, PowerPreference, TextureDimension, TextureFormat};
6
7bitflags! {
8 #[repr(transparent)]
10 pub struct WGPUFeatures: u32 {
11 }
12}
13
14#[derive(Clone, Copy, Debug, Default)]
16pub struct WGPUDeviceDescriptor {
17 pub power_preference: PowerPreference,
18 pub force_fallback_adapter: bool,
19}
20
21#[derive(Clone, Copy, Debug)]
23pub struct WGPUSurfaceDescriptor {
24 pub depth_stencil_format: Option<TextureFormat>,
25 pub sample_count: u32,
26 pub size: Extent2D,
27}
28
29impl Default for WGPUSurfaceDescriptor {
30 fn default() -> Self {
31 Self {
32 depth_stencil_format: Some(TextureFormat::DEPTH24STENCIL8),
33 sample_count: 1,
34 size: Extent2D::default(),
35 }
36 }
37}
38
39#[derive(Debug)]
41pub struct WGPUBuffer {
42 pub(super) buffer: wgpu::Buffer,
43}
44
45#[derive(Debug)]
47pub struct WGPUBufferView<'a> {
48 pub(super) buffer: &'a wgpu::Buffer,
49 pub(super) view: Option<wgpu::BufferView<'a>>,
50}
51
52impl<'a> Deref for WGPUBufferView<'a> {
53 type Target = [u8];
54
55 fn deref(&self) -> &Self::Target {
56 if let Some(ref view) = self.view {
57 view
58 } else {
59 &[]
60 }
61 }
62}
63
64impl<'a> Drop for WGPUBufferView<'a> {
65 fn drop(&mut self) {
66 self.buffer.unmap();
67 }
68}
69
70#[derive(Debug)]
72pub struct WGPUTexture {
73 pub(super) texture: wgpu::Texture,
74 pub(super) view: wgpu::TextureView,
75 pub(super) msaa_texture: Option<wgpu::Texture>,
76 pub(super) format: TextureFormat,
77 pub(super) dimension: TextureDimension,
78}
79
80#[derive(Debug)]
82pub struct WGPUSampler {
83 pub(super) sampler: wgpu::Sampler,
84}
85
86#[derive(Debug)]
88pub struct WGPUShader {
89 pub(super) shader: wgpu::ShaderModule,
90}
91
92#[derive(Debug)]
94pub struct WGPURenderPipeline {
95 pub(super) pipeline: wgpu::RenderPipeline,
96 pub(super) index_format: wgpu::IndexFormat,
97}
98
99#[derive(Debug)]
101pub struct WGPURenderPass {
102 pub(super) color_views: Vec<wgpu::TextureView>,
103 pub(super) resolve_targets: Vec<Option<wgpu::TextureView>>,
104 pub(super) color_ops: Vec<wgpu::Operations<wgpu::Color>>,
105 pub(super) depth_view: Option<wgpu::TextureView>,
106 pub(super) depth_ops: Option<wgpu::Operations<f32>>,
107 pub(super) stencil_ops: Option<wgpu::Operations<u32>>,
108}
109
110#[derive(Debug)]
112pub struct WGPUBindGroup {
113 pub(super) bind_group: wgpu::BindGroup,
114}
115
116#[derive(Debug)]
118pub struct WGPUBindGroupLayout {
119 pub(super) layout: wgpu::BindGroupLayout,
120}