#![deny(missing_docs, unused)]
#[macro_use]
extern crate bitflags;
#[macro_use]
extern crate failure;
#[cfg(feature = "mint")]
extern crate mint;
#[cfg(feature = "serde")]
#[macro_use]
extern crate serde;
use std::any::Any;
use std::error::Error;
use std::fmt;
use std::hash::Hash;
pub use self::adapter::{
Adapter, AdapterInfo, MemoryProperties, MemoryType, MemoryTypeId, PhysicalDevice, QueuePriority,
};
pub use self::device::Device;
pub use self::pool::CommandPool;
pub use self::pso::DescriptorPool;
pub use self::queue::{
Capability, CommandQueue, Compute, General, Graphics, QueueFamily, QueueGroup, QueueType,
Submission, Supports, Transfer,
};
pub use self::window::{
AcquireError, CompositeAlpha, PresentMode, Surface, SurfaceCapabilities,
SwapImageIndex, Swapchain, SwapchainConfig,
};
pub mod adapter;
pub mod buffer;
pub mod command;
pub mod device;
pub mod error;
pub mod format;
pub mod image;
pub mod mapping;
pub mod memory;
pub mod pass;
pub mod pool;
pub mod pso;
pub mod query;
pub mod queue;
pub mod range;
pub mod window;
#[doc(hidden)]
pub mod backend;
pub type VertexCount = u32;
pub type VertexOffset = i32;
pub type IndexCount = u32;
pub type InstanceCount = u32;
pub type DrawCount = u32;
pub type PatchSize = u8;
pub type WorkGroupCount = [u32; 3];
pub type AttributeSlot = u8;
pub type ConstantBufferSlot = u8;
pub type ResourceViewSlot = u8;
pub type UnorderedViewSlot = u8;
pub type ColorSlot = u8;
pub type SamplerSlot = u8;
bitflags! {
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Features: u64 {
const CORE_MASK = 0x0FFF_FFFF_FFFF_FFFF;
const PORTABILITY_MASK = 0xF000_0000_0000_0000;
const ROBUST_BUFFER_ACCESS = 0x000_0000_0000_0001;
const FULL_DRAW_INDEX_U32 = 0x000_0000_0000_0002;
const IMAGE_CUBE_ARRAY = 0x000_0000_0000_0004;
const INDEPENDENT_BLENDING = 0x000_0000_0000_0008;
const GEOMETRY_SHADER = 0x000_0000_0000_0010;
const TESSELLATION_SHADER = 0x000_0000_0000_0020;
const SAMPLE_RATE_SHADING = 0x000_0000_0000_0040;
const DUAL_SRC_BLENDING = 0x000_0000_0000_0080;
const LOGIC_OP = 0x000_0000_0000_0100;
const MULTI_DRAW_INDIRECT = 0x000_0000_0000_0200;
const DRAW_INDIRECT_FIRST_INSTANCE = 0x00_0000_0000_0400;
const DEPTH_CLAMP = 0x000_0000_0000_0800;
const DEPTH_BIAS_CLAMP = 0x000_0000_0000_1000;
const NON_FILL_POLYGON_MODE = 0x000_0000_0000_2000;
const DEPTH_BOUNDS = 0x000_0000_0000_4000;
const LINE_WIDTH = 0x000_0000_0000_8000;
const POINT_SIZE = 0x000_0000_0001_0000;
const ALPHA_TO_ONE = 0x000_0000_0002_0000;
const MULTI_VIEWPORTS = 0x000_0000_0004_0000;
const SAMPLER_ANISOTROPY = 0x000_0000_0008_0000;
const FORMAT_ETC2 = 0x000_0000_0010_0000;
const FORMAT_ASTC_LDR = 0x000_0000_0020_0000;
const FORMAT_BC = 0x000_0000_0040_0000;
const PRECISE_OCCLUSION_QUERY = 0x000_0000_0080_0000;
const PIPELINE_STATISTICS_QUERY = 0x000_0000_0100_0000;
const VERTEX_STORES_AND_ATOMICS = 0x000_0000_0200_0000;
const FRAGMENT_STORES_AND_ATOMICS = 0x000_0000_0400_0000;
const SHADER_TESSELLATION_AND_GEOMETRY_POINT_SIZE = 0x000_0000_0800_0000;
const SHADER_IMAGE_GATHER_EXTENDED = 0x000_0000_1000_0000;
const SHADER_STORAGE_IMAGE_EXTENDED_FORMATS = 0x000_0000_2000_0000;
const SHADER_STORAGE_IMAGE_MULTISAMPLE = 0x000_0000_4000_0000;
const SHADER_STORAGE_IMAGE_READ_WITHOUT_FORMAT = 0x000_0000_8000_0000;
const SHADER_STORAGE_IMAGE_WRITE_WITHOUT_FORMAT = 0x000_0001_0000_0000;
const SHADER_UNIFORM_BUFFER_ARRAY_DYNAMIC_INDEXING = 0x000_0002_0000_0000;
const SHADER_SAMPLED_IMAGE_ARRAY_DYNAMIC_INDEXING = 0x000_0004_0000_0000;
const SHADER_STORAGE_BUFFER_ARRAY_DYNAMIC_INDEXING = 0x000_0008_0000_0000;
const SHADER_STORAGE_IMAGE_ARRAY_DYNAMIC_INDEXING = 0x000_0010_0000_0000;
const SHADER_CLIP_DISTANCE = 0x000_0020_0000_0000;
const SHADER_CULL_DISTANCE = 0x000_0040_0000_0000;
const SHADER_FLOAT64 = 0x000_0080_0000_0000;
const SHADER_INT64 = 0x000_0100_0000_0000;
const SHADER_INT16 = 0x000_0200_0000_0000;
const SHADER_RESOURCE_RESIDENCY = 0x000_0400_0000_0000;
const SHADER_RESOURCE_MIN_LOD = 0x000_0800_0000_0000;
const SPARSE_BINDING = 0x000_1000_0000_0000;
const SPARSE_RESIDENCY_BUFFER = 0x000_2000_0000_0000;
const SPARSE_RESIDENCY_IMAGE_2D = 0x000_4000_0000_0000;
const SPARSE_RESIDENCY_IMAGE_3D = 0x000_8000_0000_0000;
const SPARSE_RESIDENCY_2_SAMPLES = 0x001_0000_0000_0000;
const SPARSE_RESIDENCY_4_SAMPLES = 0x002_0000_0000_0000;
const SPARSE_RESIDENCY_8_SAMPLES = 0x004_0000_0000_0000;
const SPARSE_RESIDENCY_16_SAMPLES = 0x008_0000_0000_0000;
const SPARSE_RESIDENCY_ALIASED = 0x010_0000_0000_0000;
const VARIABLE_MULTISAMPLE_RATE = 0x020_0000_0000_0000;
const INHERITED_QUERIES = 0x040_0000_0000_0000;
const TRIANGLE_FAN = 0x1000_0000_0000_0000;
const SEPARATE_STENCIL_REF_VALUES = 0x2000_0000_0000_0000;
const INSTANCE_RATE = 0x4000_0000_0000_0000;
const SAMPLER_MIP_LOD_BIAS = 0x8000_0000_0000_0000;
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Limits {
pub max_image_1d_size: image::Size,
pub max_image_2d_size: image::Size,
pub max_image_3d_size: image::Size,
pub max_image_cube_size: image::Size,
pub max_image_array_layers: image::Layer,
pub max_texel_elements: usize,
pub max_uniform_buffer_range: buffer::Offset,
pub max_storage_buffer_range: buffer::Offset,
pub max_push_constants_size: usize,
pub max_memory_allocation_count: usize,
pub max_sampler_allocation_count: usize,
pub max_bound_descriptor_sets: pso::DescriptorSetIndex,
pub max_per_stage_descriptor_samplers: usize,
pub max_per_stage_descriptor_uniform_buffers: usize,
pub max_per_stage_descriptor_storage_buffers: usize,
pub max_per_stage_descriptor_sampled_images: usize,
pub max_per_stage_descriptor_storage_images: usize,
pub max_per_stage_descriptor_input_attachments: usize,
pub max_per_stage_resources: usize,
pub max_descriptor_set_samplers: usize,
pub max_descriptor_set_uniform_buffers: usize,
pub max_descriptor_set_uniform_buffers_dynamic: usize,
pub max_descriptor_set_storage_buffers: usize,
pub max_descriptor_set_storage_buffers_dynamic: usize,
pub max_descriptor_set_sampled_images: usize,
pub max_descriptor_set_storage_images: usize,
pub max_descriptor_set_input_attachments: usize,
pub max_vertex_input_attributes: usize,
pub max_vertex_input_bindings: usize,
pub max_vertex_input_attribute_offset: usize,
pub max_vertex_input_binding_stride: usize,
pub max_vertex_output_components: usize,
pub max_patch_size: PatchSize,
pub max_geometry_shader_invocations: usize,
pub max_geometry_input_components: usize,
pub max_geometry_output_components: usize,
pub max_geometry_output_vertices: usize,
pub max_geometry_total_output_components: usize,
pub max_fragment_input_components: usize,
pub max_fragment_output_attachments: usize,
pub max_fragment_dual_source_attachments: usize,
pub max_fragment_combined_output_resources: usize,
pub max_compute_shared_memory_size: usize,
pub max_compute_work_group_count: WorkGroupCount,
pub max_compute_work_group_invocations: usize,
pub max_compute_work_group_size: [u32; 3],
pub max_draw_indexed_index_value: IndexCount,
pub max_draw_indirect_count: InstanceCount,
pub max_sampler_lod_bias: f32,
pub max_sampler_anisotropy: f32,
pub max_viewports: usize,
pub max_viewport_dimensions: [image::Size; 2],
pub max_framebuffer_extent: image::Extent,
pub min_memory_map_alignment: usize,
pub buffer_image_granularity: buffer::Offset,
pub min_texel_buffer_offset_alignment: buffer::Offset,
pub min_uniform_buffer_offset_alignment: buffer::Offset,
pub min_storage_buffer_offset_alignment: buffer::Offset,
pub framebuffer_color_samples_count: image::NumSamples,
pub framebuffer_depth_samples_count: image::NumSamples,
pub framebuffer_stencil_samples_count: image::NumSamples,
pub max_color_attachments: usize,
pub standard_sample_locations: bool,
pub optimal_buffer_copy_offset_alignment: buffer::Offset,
pub optimal_buffer_copy_pitch_alignment: buffer::Offset,
pub non_coherent_atom_size: usize,
pub min_vertex_input_binding_stride_alignment: buffer::Offset,
}
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[repr(u8)]
pub enum Primitive {
PointList,
LineList,
LineStrip,
TriangleList,
TriangleStrip,
LineListAdjacency,
LineStripAdjacency,
TriangleListAdjacency,
TriangleStripAdjacency,
PatchList(PatchSize),
}
#[allow(missing_docs)]
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[repr(u8)]
pub enum IndexType {
U16,
U32,
}
pub trait Instance: Any + Send + Sync {
type Backend: Backend;
fn enumerate_adapters(&self) -> Vec<Adapter<Self::Backend>>;
}
#[allow(missing_docs)]
pub trait Backend: 'static + Sized + Eq + Clone + Hash + fmt::Debug + Any + Send + Sync {
type PhysicalDevice: PhysicalDevice<Self>;
type Device: Device<Self>;
type Surface: Surface<Self>;
type Swapchain: Swapchain<Self>;
type QueueFamily: QueueFamily;
type CommandQueue: queue::RawCommandQueue<Self>;
type CommandBuffer: command::RawCommandBuffer<Self>;
type ShaderModule: fmt::Debug + Any + Send + Sync;
type RenderPass: fmt::Debug + Any + Send + Sync;
type Framebuffer: fmt::Debug + Any + Send + Sync;
type Memory: fmt::Debug + Any + Send + Sync;
type CommandPool: pool::RawCommandPool<Self>;
type Buffer: fmt::Debug + Any + Send + Sync;
type BufferView: fmt::Debug + Any + Send + Sync;
type Image: fmt::Debug + Any + Send + Sync;
type ImageView: fmt::Debug + Any + Send + Sync;
type Sampler: fmt::Debug + Any + Send + Sync;
type ComputePipeline: fmt::Debug + Any + Send + Sync;
type GraphicsPipeline: fmt::Debug + Any + Send + Sync;
type PipelineCache: fmt::Debug + Any + Send + Sync;
type PipelineLayout: fmt::Debug + Any + Send + Sync;
type DescriptorPool: pso::DescriptorPool<Self>;
type DescriptorSet: fmt::Debug + Any + Send + Sync;
type DescriptorSetLayout: fmt::Debug + Any + Send + Sync;
type Fence: fmt::Debug + Any + Send + Sync;
type Semaphore: fmt::Debug + Any + Send + Sync;
type QueryPool: fmt::Debug + Any + Send + Sync;
}
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum SubmissionError {}
impl fmt::Display for SubmissionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for SubmissionError {
fn description(&self) -> &str {
"Submission error"
}
}
pub type SubmissionResult<T> = Result<T, SubmissionError>;
pub struct Gpu<B: Backend> {
pub device: B::Device,
pub queues: queue::Queues<B>,
}