use super::*;
#[derive(Clone, Copy, Data, Debug, New, PartialEq)]
pub struct ViewportDescriptor {
pub(crate) x: f32,
pub(crate) y: f32,
pub(crate) width: f32,
pub(crate) height: f32,
#[new(skip)]
pub(crate) min_depth: f32,
#[new(skip)]
pub(crate) max_depth: f32,
}
#[derive(Clone, Copy, Debug, Eq, Getter, Hash, New, PartialEq)]
pub struct VertexAttribute {
#[get(type(copy))]
pub(crate) shader_location: u32,
#[get(type(copy))]
pub(crate) offset: u64,
#[get(type(copy))]
pub(crate) format: VertexAttributeFormat,
}
#[derive(Clone, Debug, Getter, New)]
pub struct VertexBufferLayout {
#[get(type(copy))]
pub(crate) array_stride: u64,
#[get(type(copy))]
pub(crate) step_mode: VertexStepMode,
pub(crate) attributes: Vec<VertexAttribute>,
}
#[derive(Clone, Data, Debug, New)]
pub struct Texture2DDescriptor {
#[get(type(copy))]
pub(crate) width: u32,
#[get(type(copy))]
pub(crate) height: u32,
#[get(type(copy))]
pub(crate) format: GpuTextureFormat,
#[get(type(copy))]
#[new(skip)]
pub(crate) mip_level_count: u32,
#[get(type(copy))]
#[new(skip)]
pub(crate) sample_count: u32,
}
#[derive(Clone, Debug, Getter, New)]
pub struct TextureViewDescriptor {
#[get(type(clone))]
#[new(value = "None")]
pub(crate) format: Option<&'static str>,
#[get(type(clone))]
#[new(value = "None")]
pub(crate) dimension: Option<&'static str>,
#[get(type(copy))]
#[new(value = "0")]
pub(crate) base_mip_level: u32,
#[get(type(copy))]
#[new(value = "0")]
pub(crate) mip_level_count: u32,
#[get(type(copy))]
#[new(value = "0")]
pub(crate) base_array_layer: u32,
#[get(type(copy))]
#[new(value = "0")]
pub(crate) array_layer_count: u32,
#[get(type(clone))]
#[new(value = "None")]
pub(crate) aspect: Option<&'static str>,
}
#[derive(Clone, Debug, Getter, New)]
pub struct TextureWriteDescriptor {
#[get(type(clone))]
pub(crate) data: Vec<u8>,
#[get(type(copy))]
pub(crate) bytes_per_row: u32,
#[get(type(copy))]
pub(crate) rows_per_image: u32,
#[get(type(copy))]
pub(crate) mip_level: u32,
#[get(type(clone))]
pub(crate) texture: JsValue,
#[get(type(clone))]
#[new(value = "None")]
pub(crate) origin: Option<JsValue>,
#[get(type(copy))]
#[new(value = "false")]
pub(crate) flip_y: bool,
}
#[derive(Clone, Debug)]
pub struct BindGroupLayoutEntry {
pub binding: u32,
pub visibility: ShaderStages,
pub ty: BindGroupEntryType,
}
#[derive(Clone, Copy, Data, Debug, New)]
pub struct SamplerDescriptor {
#[get(type(copy))]
#[new(skip)]
pub(crate) filter: FilterMode,
#[get(type(copy))]
#[new(skip)]
pub(crate) mipmap_filter: MipmapFilter,
#[get(type(copy))]
#[new(skip)]
pub(crate) address_mode_u: AddressMode,
#[get(type(copy))]
#[new(skip)]
pub(crate) address_mode_v: AddressMode,
#[get(type(copy))]
#[new(skip)]
pub(crate) address_mode_w: AddressMode,
#[get(type(copy))]
#[new(skip)]
pub(crate) compare: Option<CompareFunction>,
}
#[derive(Clone, Debug, Getter)]
pub struct ColorAttachment {
pub view: Option<JsValue>,
pub resolve_target: Option<JsValue>,
pub clear: Option<Color>,
pub load_op: LoadOp,
pub store_op: StoreOp,
}
#[derive(Clone, Debug, Getter)]
pub struct DepthStencilAttachment {
pub view: Option<JsValue>,
pub depth_clear: Option<f64>,
pub depth_load_op: LoadOp,
pub depth_store_op: StoreOp,
pub depth_read_only: bool,
}
#[derive(Clone, Copy, Data, Debug, Default, New, PartialEq)]
pub struct BlendComponent {
#[get(type(copy))]
#[new(skip)]
pub(crate) operation: BlendOperation,
#[get(type(copy))]
#[new(skip)]
pub(crate) source: BlendFactor,
#[get(type(copy))]
#[new(skip)]
pub(crate) destination: BlendFactor,
}
#[derive(Clone, Copy, Data, Debug, Default, New)]
pub struct BlendState {
#[get(type(copy))]
#[new(skip)]
pub(crate) color: BlendComponent,
#[get(type(copy))]
#[new(skip)]
pub(crate) alpha: BlendComponent,
}
#[derive(Clone, Copy, Data, Debug, Default, New)]
pub struct ColorTargetState {
#[get(type(copy))]
#[new(skip)]
pub(crate) format: GpuTextureFormat,
#[get(type(copy))]
#[new(skip)]
pub(crate) blend: Option<BlendState>,
#[get(type(copy))]
#[new(skip)]
pub(crate) write_mask: u32,
}
#[derive(Clone, Copy, Data, Debug, Default, New)]
pub struct DepthStencilState {
#[get(type(copy))]
#[new(skip)]
pub(crate) format: GpuTextureFormat,
#[get(type(copy))]
#[new(skip)]
pub(crate) depth_write_enabled: bool,
#[get(type(copy))]
#[new(skip)]
pub(crate) depth_compare: CompareFunction,
}
#[derive(Clone, Copy, Data, Debug, Default, New)]
pub struct MultisampleState {
#[get(type(copy))]
#[new(skip)]
pub(crate) count: u32,
#[get(type(copy))]
#[new(skip)]
pub(crate) mask: u32,
}
#[derive(Clone, Copy, Data, Debug, Default, New)]
pub struct PrimitiveState {
#[get(type(copy))]
#[new(skip)]
pub(crate) topology: PrimitiveTopology,
#[get(type(copy))]
#[new(skip)]
pub(crate) front_face: FrontFace,
#[get(type(copy))]
#[new(skip)]
pub(crate) cull_mode: CullMode,
#[get(type(copy))]
#[new(skip)]
pub(crate) strip_index_format: Option<IndexFormat>,
#[get(type(copy))]
#[new(skip)]
pub(crate) unclipped_depth: bool,
}
#[derive(Clone, Debug, Getter, New)]
pub struct VertexState {
#[get(type(clone))]
pub(crate) module: JsValue,
#[get(type(clone))]
pub(crate) entry_point: String,
pub(crate) buffers: Vec<VertexBufferLayout>,
}
#[derive(Clone, Debug, Getter, New)]
pub struct FragmentState {
#[get(type(clone))]
pub(crate) module: JsValue,
#[get(type(clone))]
pub(crate) entry_point: String,
pub(crate) targets: Vec<ColorTargetState>,
}
#[derive(Clone, Debug, Getter, New)]
pub struct RenderPipelineDescriptor {
pub(crate) vertex: VertexState,
pub(crate) primitive: PrimitiveState,
pub(crate) depth_stencil: Option<DepthStencilState>,
pub(crate) multisample: MultisampleState,
pub(crate) fragment: Option<FragmentState>,
}
#[derive(Clone, Debug, Getter, New)]
pub struct ComputePipelineDescriptor {
#[get(type(clone))]
pub(crate) module: JsValue,
#[get(type(clone))]
pub(crate) entry_point: String,
}
#[derive(Clone, Data, Debug, New)]
pub struct TextureDescriptor {
#[get(type(copy))]
pub(crate) width: u32,
#[get(type(copy))]
pub(crate) height: u32,
#[get(type(copy))]
#[new(skip)]
pub(crate) depth_or_layers: u32,
#[get(type(clone))]
pub(crate) dimension: &'static str,
#[get(type(copy))]
pub(crate) format: GpuTextureFormat,
#[get(type(copy))]
pub(crate) usage: u32,
#[get(type(copy))]
#[new(skip)]
pub(crate) mip_level_count: u32,
#[get(type(copy))]
#[new(skip)]
pub(crate) sample_count: u32,
#[get(type(clone))]
#[new(skip)]
pub(crate) label: Option<String>,
}
#[derive(Clone, Debug, Getter, New)]
pub(crate) struct BufferDescriptor {
#[get(type(copy))]
pub(crate) size: u64,
#[get(type(copy))]
pub(crate) usage: u32,
#[get(type(clone))]
#[new(skip)]
pub(crate) label: Option<String>,
}
#[derive(Clone, Copy, Data, Debug, Default, New)]
pub struct UniformSlice {
#[get(type(copy))]
pub(crate) offset: u64,
#[get(type(copy))]
pub(crate) size: u64,
}
#[derive(Clone, Copy, Data, Debug, New)]
pub struct DrawIndexedArgs {
#[get(type(copy))]
#[new(skip)]
pub(crate) index_count: u32,
#[get(type(copy))]
#[new(skip)]
pub(crate) instance_count: u32,
#[get(type(copy))]
#[new(skip)]
pub(crate) first_index: u32,
#[get(type(copy))]
#[new(skip)]
pub(crate) base_vertex: i32,
#[get(type(copy))]
#[new(skip)]
pub(crate) first_instance: u32,
}
#[derive(Clone, Copy, Data, Debug, New)]
pub struct DrawArgs {
#[get(type(copy))]
#[new(skip)]
pub(crate) vertex_count: u32,
#[get(type(copy))]
#[new(skip)]
pub(crate) instance_count: u32,
#[get(type(copy))]
#[new(skip)]
pub(crate) first_vertex: u32,
#[get(type(copy))]
#[new(skip)]
pub(crate) first_instance: u32,
}
#[derive(Clone, Copy, Data, Debug, New)]
pub struct DispatchArgs {
#[get(type(copy))]
#[new(skip)]
pub(crate) x: u32,
#[get(type(copy))]
#[new(skip)]
pub(crate) y: u32,
#[get(type(copy))]
#[new(skip)]
pub(crate) z: u32,
}