use std::sync::Arc;
#[cfg(feature = "webgpu")]
use wgpu::*;
#[derive(Debug, thiserror::Error)]
pub enum RenderError {
#[error("WebGPU error: {0}")]
WebGPU(String),
#[error("WebGL error: {0}")]
WebGL(String),
#[error("Canvas error: {0}")]
Canvas(String),
#[error("Buffer error: {0}")]
Buffer(String),
#[error("Shader error: {0}")]
Shader(String),
#[error("Performance error: {0}")]
Performance(String),
}
#[derive(Debug, Clone)]
pub enum RenderBackend {
WebGPU {
device: Option<Arc<Device>>,
queue: Option<Arc<Queue>>,
surface: Option<Arc<Surface<'static>>>,
compute_capability: bool,
memory_budget: usize,
adapter_info: AdapterInfo,
},
WebGL2 {
context: Option<String>, extensions: Vec<String>,
capabilities: WebGL2Capabilities,
},
Canvas2D {
context: Option<String>, },
}
#[derive(Debug, Clone)]
pub struct AdapterInfo {
pub name: String,
pub vendor: String,
pub device_type: DeviceType,
pub backend: Backend,
}
#[derive(Debug, Clone)]
pub struct WebGL2Capabilities {
pub max_texture_size: u32,
pub max_vertex_attribs: u32,
pub max_varying_vectors: u32,
pub max_fragment_uniform_vectors: u32,
pub max_vertex_uniform_vectors: u32,
}
pub struct WebGpuCapabilities {
pub max_texture_size: u32,
pub max_buffer_size: u64,
pub supported_formats: Vec<String>,
pub compute_shader_support: bool,
}
#[derive(Debug, Clone)]
pub enum DeviceType {
Discrete,
Integrated,
Virtual,
Cpu,
}
#[derive(Debug, Clone)]
pub enum Backend {
Vulkan,
Metal,
Dx12,
Dx11,
Gl,
BrowserWebGpu,
}