1pub use wgpu::Extent3d;
14pub use wgpu::Origin3d;
15pub use wgpu::StorageTextureAccess;
16pub use wgpu::TextureAspect;
17pub use wgpu::TextureDimension;
18pub use wgpu::TextureFormat;
19pub use wgpu::TextureSampleType;
20pub use wgpu::TextureUsages;
21pub use wgpu::TextureViewDimension;
22
23pub use wgpu::BufferAddress;
25pub use wgpu::BufferSize;
26pub use wgpu::BufferUsages;
27
28pub use wgpu::DepthBiasState;
30pub use wgpu::DepthStencilState;
31pub use wgpu::Face;
32pub use wgpu::FrontFace;
33pub use wgpu::IndexFormat;
34pub use wgpu::MultisampleState;
35pub use wgpu::PipelineCompilationOptions;
36pub use wgpu::PolygonMode;
37pub use wgpu::PrimitiveState;
38pub use wgpu::PrimitiveTopology;
39pub use wgpu::StencilFaceState;
40pub use wgpu::StencilOperation;
41pub use wgpu::StencilState;
42
43pub use wgpu::BlendComponent;
45pub use wgpu::BlendFactor;
46pub use wgpu::BlendOperation;
47pub use wgpu::BlendState;
48pub use wgpu::Color;
49pub use wgpu::ColorTargetState;
50pub use wgpu::ColorWrites;
51
52pub use wgpu::ShaderSource;
54pub use wgpu::ShaderStages;
55
56pub use wgpu::BindingType;
58pub use wgpu::BufferBindingType;
59pub use wgpu::SamplerBindingType;
60
61pub use wgpu::VertexAttribute;
63pub use wgpu::VertexBufferLayout;
64pub use wgpu::VertexFormat;
65pub use wgpu::VertexStepMode;
66
67pub use wgpu::LoadOp;
69pub use wgpu::Operations;
70pub use wgpu::StoreOp;
71
72pub use wgpu::AddressMode;
74pub use wgpu::CompareFunction;
75pub use wgpu::FilterMode;
76
77pub use wgpu::PresentMode;
79pub use wgpu::SurfaceConfiguration;
80
81pub use wgpu::Features;
83pub use wgpu::Limits;
84pub use wgpu::Maintain;
85pub use wgpu::MemoryHints;
86pub use wgpu::PowerPreference;
87
88pub use wgpu::Backends;
90
91pub use wgpu::CommandEncoderDescriptor;
93pub use wgpu::MapMode;
94pub use wgpu::RenderPassColorAttachment;
95pub use wgpu::RenderPassDepthStencilAttachment;
96pub use wgpu::RenderPassDescriptor;
97pub use wgpu::RenderPassTimestampWrites;
98pub use wgpu::SurfaceError;
99pub use wgpu::TextureViewDescriptor;
100
101pub use wgpu::Device;
103pub use wgpu::Instance;
104pub use wgpu::InstanceDescriptor;
105pub use wgpu::Queue;
106pub use wgpu::Surface;
107pub use wgpu::TextureDescriptor;
108pub use wgpu::TextureView;
109
110#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
118pub enum BackendPreference {
119 VulkanPreferred,
121 OpenGLPreferred,
123 #[default]
125 PlatformDefault,
126
127 Specific(Backends),
129}
130
131impl BackendPreference {
132 pub fn to_backends(self) -> Backends {
137 match self {
138 Self::VulkanPreferred => Backends::VULKAN,
139 Self::OpenGLPreferred => Backends::GL,
140 Self::PlatformDefault => {
141 #[cfg(target_os = "windows")]
142 {
143 Backends::DX12
144 }
145 #[cfg(target_os = "macos")]
146 {
147 Backends::METAL
148 }
149 #[cfg(not(any(target_os = "windows", target_os = "macos")))]
150 {
151 Backends::VULKAN
152 }
153 }
154 Self::Specific(b) => b,
155 }
156 }
157}
158
159#[derive(Debug, Clone)]
161pub struct GpuBufferDescriptor {
162 pub label: Option<String>,
163 pub size: u64,
164 pub usage: BufferUsages,
165 pub mapped_at_creation: bool,
166}
167
168impl Default for GpuBufferDescriptor {
169 fn default() -> Self {
170 Self {
171 label: None,
172 size: 0,
173 usage: BufferUsages::empty(),
174 mapped_at_creation: false,
175 }
176 }
177}
178
179#[derive(Debug, Clone)]
181pub struct GpuTextureDescriptor {
182 pub label: Option<String>,
183 pub size: Extent3d,
184 pub mip_level_count: u32,
185 pub sample_count: u32,
186 pub dimension: TextureDimension,
187 pub format: TextureFormat,
188 pub usage: TextureUsages,
189 pub view_formats: Vec<TextureFormat>,
190}
191
192impl Default for GpuTextureDescriptor {
193 fn default() -> Self {
194 Self {
195 label: None,
196 size: Extent3d {
197 width: 1,
198 height: 1,
199 depth_or_array_layers: 1,
200 },
201 mip_level_count: 1,
202 sample_count: 1,
203 dimension: TextureDimension::D2,
204 format: TextureFormat::Rgba8UnormSrgb,
205 usage: TextureUsages::empty(),
206 view_formats: Vec::new(),
207 }
208 }
209}
210
211#[derive(Debug, Clone)]
213pub struct GpuSamplerDescriptor {
214 pub label: Option<String>,
215 pub address_mode_u: AddressMode,
216 pub address_mode_v: AddressMode,
217 pub address_mode_w: AddressMode,
218 pub mag_filter: FilterMode,
219 pub min_filter: FilterMode,
220 pub mipmap_filter: FilterMode,
221 pub compare: Option<CompareFunction>,
222 pub anisotropy_clamp: u16,
223 pub lod_min_clamp: f32,
224 pub lod_max_clamp: f32,
225}
226
227impl Default for GpuSamplerDescriptor {
228 fn default() -> Self {
229 Self {
230 label: None,
231 address_mode_u: AddressMode::ClampToEdge,
232 address_mode_v: AddressMode::ClampToEdge,
233 address_mode_w: AddressMode::ClampToEdge,
234 mag_filter: FilterMode::Linear,
235 min_filter: FilterMode::Linear,
236 mipmap_filter: FilterMode::Nearest,
237 compare: None,
238 anisotropy_clamp: 1,
239 lod_min_clamp: 0.0,
240 lod_max_clamp: 32.0,
241 }
242 }
243}
244
245#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Serialize)]
247pub enum GpuResourceKind {
248 Buffer,
249 Texture,
250 TextureView,
251 Sampler,
252 ShaderModule,
253 BindGroupLayout,
254 BindGroup,
255 PipelineLayout,
256 RenderPipeline,
257 ComputePipeline,
258 QuerySet,
259 CommandBuffer,
260}
261
262impl std::fmt::Display for GpuResourceKind {
263 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
264 write!(f, "{self:?}")
265 }
266}