From 062a0fc581e5c0e56bf30d3e52c781d6087f6492 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Wed, 22 Jun 2016 22:27:39 +0200 Subject: [PATCH] Add some documentation, plus minor changes --- vulkano/src/lib.rs | 15 --------------- vulkano/src/pipeline/raster.rs | 4 ++++ vulkano/src/pipeline/shader.rs | 1 + vulkano/src/pipeline/vertex.rs | 4 ++++ vulkano/src/swapchain/display.rs | 3 +++ vulkano/src/swapchain/surface.rs | 21 ++++++++++++++++++--- vulkano/src/swapchain/swapchain.rs | 3 ++- vulkano/src/sync/mod.rs | 5 +++++ 8 files changed, 37 insertions(+), 19 deletions(-) diff --git a/vulkano/src/lib.rs b/vulkano/src/lib.rs index df054518..d02e489e 100644 --- a/vulkano/src/lib.rs +++ b/vulkano/src/lib.rs @@ -107,21 +107,6 @@ pub unsafe trait SynchronizedVulkanObject { fn internal_object_guard(&self) -> MutexGuard; } -// TODO: remove eventually -// https://github.com/rust-lang/rust/issues/29328 -pub unsafe trait VulkanObjectU64 { fn internal_object(&self) -> u64; } -unsafe impl VulkanObjectU64 for T where T: VulkanObject { - #[inline] - fn internal_object(&self) -> u64 { VulkanObject::internal_object(self) } -} -// TODO: remove eventually -// https://github.com/rust-lang/rust/issues/29328 -pub unsafe trait VulkanObjectUsize { fn internal_object(&self) -> usize; } -unsafe impl VulkanObjectUsize for T where T: VulkanObject { - #[inline] - fn internal_object(&self) -> usize { VulkanObject::internal_object(self) } -} - /// Gives access to the Vulkan function pointers stored in this object. trait VulkanPointers { /// The struct that provides access to the function pointers. diff --git a/vulkano/src/pipeline/raster.rs b/vulkano/src/pipeline/raster.rs index b5a7b978..a3fd4ea5 100644 --- a/vulkano/src/pipeline/raster.rs +++ b/vulkano/src/pipeline/raster.rs @@ -93,9 +93,13 @@ pub struct DepthBias { #[derive(Copy, Clone, Debug)] #[repr(u32)] pub enum CullMode { + /// No culling. None = vk::CULL_MODE_NONE, + /// The faces facing the front of the screen (ie. facing the user) will be removed. Front = vk::CULL_MODE_FRONT_BIT, + /// The faces facing the back of the screen will be removed. Back = vk::CULL_MODE_BACK_BIT, + /// All faces will be removed. FrontAndBack = vk::CULL_MODE_FRONT_AND_BACK, } diff --git a/vulkano/src/pipeline/shader.rs b/vulkano/src/pipeline/shader.rs index 557f1c98..a941e23f 100644 --- a/vulkano/src/pipeline/shader.rs +++ b/vulkano/src/pipeline/shader.rs @@ -448,6 +448,7 @@ impl<'a, S, I, O, L> GeometryShaderEntryPoint<'a, S, I, O, L> { /// Declares which type of primitives are expected by the geometry shader. #[derive(Debug, Copy, Clone, PartialEq, Eq)] +#[doc(hidden)] pub enum GeometryShaderExecutionMode { Points, Lines, diff --git a/vulkano/src/pipeline/vertex.rs b/vulkano/src/pipeline/vertex.rs index 03c58862..a831a92d 100644 --- a/vulkano/src/pipeline/vertex.rs +++ b/vulkano/src/pipeline/vertex.rs @@ -75,10 +75,13 @@ use format::Format; use pipeline::shader::ShaderInterfaceDef; use vk; +/// How the vertex source should be unrolled. #[derive(Copy, Clone, Debug)] #[repr(u32)] pub enum InputRate { + /// Each element of the source corresponds to a vertex. Vertex = vk::VERTEX_INPUT_RATE_VERTEX, + /// Each element of the source corresponds to an instance. Instance = vk::VERTEX_INPUT_RATE_INSTANCE, } @@ -110,6 +113,7 @@ pub struct VertexMemberInfo { } /// Type of a member of a vertex struct. +#[allow(missing_docs)] pub enum VertexMemberTy { I8, U8, diff --git a/vulkano/src/swapchain/display.rs b/vulkano/src/swapchain/display.rs index 4d8553bd..dd64c377 100644 --- a/vulkano/src/swapchain/display.rs +++ b/vulkano/src/swapchain/display.rs @@ -12,6 +12,9 @@ //! As far as the author knows, no existing device supports these features. Therefore the code here //! is mostly a draft and needs rework in both the API and the implementation. +#![allow(dead_code)] // TODO: this module isn't finished +#![allow(unused_variables)] // TODO: this module isn't finished + use std::ffi::CStr; use std::ptr; use std::sync::Arc; diff --git a/vulkano/src/swapchain/surface.rs b/vulkano/src/swapchain/surface.rs index cd00eb8d..fc63351d 100644 --- a/vulkano/src/swapchain/surface.rs +++ b/vulkano/src/swapchain/surface.rs @@ -463,7 +463,10 @@ pub enum SurfaceCreationError { OomError(OomError), /// The extension required for this function was not enabled. - MissingExtension { name: &'static str }, + MissingExtension { + /// Name of the missing extension. + name: &'static str + }, } impl error::Error for SurfaceCreationError { @@ -658,15 +661,22 @@ impl Iterator for SupportedPresentModesIter { #[derive(Copy, Clone, Debug, PartialEq, Eq)] #[repr(u32)] pub enum SurfaceTransform { + /// Don't transform the image. Identity = vk::SURFACE_TRANSFORM_IDENTITY_BIT_KHR, + /// Rotate 90 degrees. Rotate90 = vk::SURFACE_TRANSFORM_ROTATE_90_BIT_KHR, + /// Rotate 180 degrees. Rotate180 = vk::SURFACE_TRANSFORM_ROTATE_180_BIT_KHR, + /// Rotate 270 degrees. Rotate270 = vk::SURFACE_TRANSFORM_ROTATE_270_BIT_KHR, + /// Mirror the image horizontally. HorizontalMirror = vk::SURFACE_TRANSFORM_HORIZONTAL_MIRROR_BIT_KHR, + /// Mirror the image horizontally and rotate 90 degrees. HorizontalMirrorRotate90 = vk::SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_90_BIT_KHR, + /// Mirror the image horizontally and rotate 180 degrees. HorizontalMirrorRotate180 = vk::SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_180_BIT_KHR, + /// Mirror the image horizontally and rotate 270 degrees. HorizontalMirrorRotate270 = vk::SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_270_BIT_KHR, - /// Let the operating system or driver implementation choose. Inherit = vk::SURFACE_TRANSFORM_INHERIT_BIT_KHR, } @@ -778,7 +788,7 @@ impl Default for SurfaceTransform { } } -// How the alpha values of the pixels of the window are treated. +/// How the alpha values of the pixels of the window are treated. #[derive(Copy, Clone, Debug, PartialEq, Eq)] #[repr(u32)] pub enum CompositeAlpha { @@ -799,7 +809,10 @@ pub enum CompositeAlpha { } /// List of supported composite alpha modes. +/// +/// See the docs of `CompositeAlpha`. #[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[allow(missing_docs)] pub struct SupportedCompositeAlpha { pub opaque: bool, pub pre_multiplied: bool, @@ -864,8 +877,10 @@ impl Iterator for SupportedCompositeAlphaIter { } } +/// How the presentation engine should interpret the data. #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum ColorSpace { + /// Interpret it as sRGB. SrgbNonLinear, } diff --git a/vulkano/src/swapchain/swapchain.rs b/vulkano/src/swapchain/swapchain.rs index 47811852..6176c036 100644 --- a/vulkano/src/swapchain/swapchain.rs +++ b/vulkano/src/swapchain/swapchain.rs @@ -154,7 +154,7 @@ impl Swapchain { let swapchain = unsafe { let (sh_mode, sh_count, sh_indices) = match sharing { - SharingMode::Exclusive(id) => (vk::SHARING_MODE_EXCLUSIVE, 0, ptr::null()), + SharingMode::Exclusive(_) => (vk::SHARING_MODE_EXCLUSIVE, 0, ptr::null()), SharingMode::Concurrent(ref ids) => (vk::SHARING_MODE_CONCURRENT, ids.len() as u32, ids.as_ptr()), }; @@ -334,6 +334,7 @@ impl Swapchain { }*/ // TODO: the design of this functions depends on https://github.com/KhronosGroup/Vulkan-Docs/issues/155 #[inline] + #[doc(hidden)] pub fn image_semaphore(&self, id: u32, semaphore: Arc) -> Option> { let mut semaphores = self.images_semaphores.lock().unwrap(); mem::replace(&mut semaphores[id as usize], Some(semaphore)) diff --git a/vulkano/src/sync/mod.rs b/vulkano/src/sync/mod.rs index 8feb7da3..aeb6f556 100644 --- a/vulkano/src/sync/mod.rs +++ b/vulkano/src/sync/mod.rs @@ -92,6 +92,7 @@ pub enum Sharing where I: Iterator { macro_rules! pipeline_stages { ($($elem:ident => $val:expr,)+) => ( #[derive(Debug, Copy, Clone)] + #[allow(missing_docs)] pub struct PipelineStages { $( pub $elem: bool, @@ -99,6 +100,7 @@ macro_rules! pipeline_stages { } impl PipelineStages { + /// Builds an `PipelineStages` struct with none of the stages set. pub fn none() -> PipelineStages { PipelineStages { $( @@ -145,6 +147,7 @@ pipeline_stages!{ macro_rules! access_flags { ($($elem:ident => $val:expr,)+) => ( #[derive(Debug, Copy, Clone)] + #[allow(missing_docs)] pub struct AccessFlagBits { $( pub $elem: bool, @@ -152,6 +155,7 @@ macro_rules! access_flags { } impl AccessFlagBits { + /// Builds an `AccessFlagBits` struct with all bits set. pub fn all() -> AccessFlagBits { AccessFlagBits { $( @@ -160,6 +164,7 @@ macro_rules! access_flags { } } + /// Builds an `AccessFlagBits` struct with none of the bits set. pub fn none() -> AccessFlagBits { AccessFlagBits { $(