From 9a08414054fadfc534abfb63102da04b6446f877 Mon Sep 17 00:00:00 2001 From: Lucas Kent Date: Tue, 11 Dec 2018 18:26:04 +1100 Subject: [PATCH] Upgrade vulkano-win and vulkano-shaders to rust 2018 (#1134) * Upgrade vulkano-shaders to rust 2018 * Upgrade vulkano-win to rust 2018 --- examples/src/lib.rs | 7 ++----- vulkano-shaders/Cargo.toml | 1 + vulkano-shaders/src/codegen.rs | 18 +++++++++--------- vulkano-shaders/src/descriptor_sets.rs | 8 ++++---- vulkano-shaders/src/entry_point.rs | 8 ++++---- vulkano-shaders/src/enums.rs | 2 +- vulkano-shaders/src/lib.rs | 12 ++---------- vulkano-shaders/src/parse.rs | 4 ++-- vulkano-shaders/src/spec_consts.rs | 8 ++++---- vulkano-shaders/src/spirv_search.rs | 4 ++-- vulkano-shaders/src/structs.rs | 6 +++--- vulkano-win/Cargo.toml | 1 + vulkano-win/src/lib.rs | 10 ---------- 13 files changed, 35 insertions(+), 54 deletions(-) diff --git a/examples/src/lib.rs b/examples/src/lib.rs index de3c3d0f70..c9444beea5 100644 --- a/examples/src/lib.rs +++ b/examples/src/lib.rs @@ -7,15 +7,12 @@ // notice may not be copied, modified, or distributed except // according to those terms. -#[macro_use] -extern crate vulkano; - #[derive(Copy, Clone)] pub struct Vertex { position: (f32, f32, f32) } -impl_vertex!(Vertex, position); +vulkano::impl_vertex!(Vertex, position); pub const VERTICES: [Vertex; 531] = [ Vertex { position: (0.0, 0.0, 0.0) }, // dummy vector because in the original model indices @@ -557,7 +554,7 @@ pub struct Normal { normal: (f32, f32, f32) } -impl_vertex!(Normal, normal); +vulkano::impl_vertex!(Normal, normal); pub const NORMALS: [Normal; 531] = [ Normal { normal: (0.0, 0.0, 0.0) }, // dummy vector because in the original model indices diff --git a/vulkano-shaders/Cargo.toml b/vulkano-shaders/Cargo.toml index 0d274987dc..84afa6bcf7 100644 --- a/vulkano-shaders/Cargo.toml +++ b/vulkano-shaders/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "vulkano-shaders" version = "0.11.1" +edition = "2018" authors = ["Pierre Krieger ", "The vulkano contributors"] repository = "https://github.com/vulkano-rs/vulkano" description = "Shaders rust code generation macro" diff --git a/vulkano-shaders/src/codegen.rs b/vulkano-shaders/src/codegen.rs index 065cc229a7..eee07dc0f0 100644 --- a/vulkano-shaders/src/codegen.rs +++ b/vulkano-shaders/src/codegen.rs @@ -15,17 +15,17 @@ use proc_macro2::{Span, TokenStream}; use shaderc::{Compiler, CompileOptions}; pub use shaderc::{CompilationArtifact, ShaderKind, IncludeType, ResolvedInclude}; -pub use parse::ParseError; +pub use crate::parse::ParseError; -use parse::Instruction; -use enums::Capability; +use crate::parse::Instruction; +use crate::enums::Capability; -use parse; -use entry_point; -use structs; -use descriptor_sets; -use spec_consts; -use read_file_to_string; +use crate::parse; +use crate::entry_point; +use crate::structs; +use crate::descriptor_sets; +use crate::spec_consts; +use crate::read_file_to_string; fn include_callback(requested_source_path_raw: &str, directive_type: IncludeType, contained_within_path_raw: &str, recursion_depth: usize, diff --git a/vulkano-shaders/src/descriptor_sets.rs b/vulkano-shaders/src/descriptor_sets.rs index c2648ebfc9..4f84a670a7 100644 --- a/vulkano-shaders/src/descriptor_sets.rs +++ b/vulkano-shaders/src/descriptor_sets.rs @@ -11,9 +11,9 @@ use std::cmp; use proc_macro2::TokenStream; -use enums::{Dim, Decoration, StorageClass, ImageFormat}; -use parse::{Instruction, Spirv}; -use spirv_search; +use crate::enums::{Dim, Decoration, StorageClass, ImageFormat}; +use crate::parse::{Instruction, Spirv}; +use crate::spirv_search; pub fn write_descriptor_sets(doc: &Spirv) -> TokenStream { // TODO: not implemented correctly @@ -61,7 +61,7 @@ pub fn write_descriptor_sets(doc: &Spirv) -> TokenStream { _ => continue, }; - let (_, size, _) = ::structs::type_from_id(doc, type_id); + let (_, size, _) = crate::structs::type_from_id(doc, type_id); let size = size.expect("Found runtime-sized push constants"); push_constants_size = cmp::max(push_constants_size, size); } diff --git a/vulkano-shaders/src/entry_point.rs b/vulkano-shaders/src/entry_point.rs index ff775c2f0e..2b77eaf9c4 100644 --- a/vulkano-shaders/src/entry_point.rs +++ b/vulkano-shaders/src/entry_point.rs @@ -10,9 +10,9 @@ use syn::Ident; use proc_macro2::{Span, TokenStream}; -use enums::{StorageClass, ExecutionModel, ExecutionMode, Decoration}; -use parse::{Instruction, Spirv}; -use spirv_search; +use crate::enums::{StorageClass, ExecutionModel, ExecutionMode, Decoration}; +use crate::parse::{Instruction, Spirv}; +use crate::spirv_search; pub fn write_entry_point(doc: &Spirv, instruction: &Instruction) -> (TokenStream, TokenStream) { let (execution, id, ep_name, interface) = match instruction { @@ -47,7 +47,7 @@ pub fn write_entry_point(doc: &Spirv, instruction: &Instruction) -> (TokenStream ignore_first_array_out ); - let spec_consts_struct = if ::spec_consts::has_specialization_constants(doc) { + let spec_consts_struct = if crate::spec_consts::has_specialization_constants(doc) { quote!{ SpecializationConstants } } else { quote!{ () } diff --git a/vulkano-shaders/src/enums.rs b/vulkano-shaders/src/enums.rs index b3fde8610f..23d6f89ff6 100644 --- a/vulkano-shaders/src/enums.rs +++ b/vulkano-shaders/src/enums.rs @@ -10,7 +10,7 @@ #![allow(dead_code)] #![allow(non_camel_case_types)] -use parse::ParseError; +use crate::parse::ParseError; macro_rules! enumeration { ($(typedef enum $unused:ident { $($elem:ident = $value:expr,)+ } $name:ident;)+) => ( diff --git a/vulkano-shaders/src/lib.rs b/vulkano-shaders/src/lib.rs index 63c462e4bd..eabd9d86ed 100644 --- a/vulkano-shaders/src/lib.rs +++ b/vulkano-shaders/src/lib.rs @@ -4,9 +4,6 @@ //! # Basic usage //! //! ``` -//! extern crate vulkano; -//! extern crate vulkano_shaders; -//! //! mod vs { //! vulkano_shaders::shader!{ //! ty: "vertex", @@ -67,8 +64,6 @@ //! you could do something like this: //! //! ``` -//! # extern crate vulkano_shaders; -//! # extern crate vulkano; //! # fn main() {} //! # use std::sync::Arc; //! # use vulkano::OomError; @@ -158,11 +153,8 @@ #![recursion_limit = "1024"] #[macro_use] extern crate quote; - extern crate shaderc; - extern crate proc_macro; - extern crate proc_macro2; #[macro_use] extern crate syn; - + extern crate proc_macro; use std::env; use std::fs::File; @@ -181,7 +173,7 @@ mod spec_consts; mod structs; mod spirv_search; -use codegen::ShaderKind; +use crate::codegen::ShaderKind; enum SourceKind { Src(String), diff --git a/vulkano-shaders/src/parse.rs b/vulkano-shaders/src/parse.rs index 9aff2313e7..505b454321 100644 --- a/vulkano-shaders/src/parse.rs +++ b/vulkano-shaders/src/parse.rs @@ -7,7 +7,7 @@ // notice may not be copied, modified, or distributed except // according to those terms. -use enums::*; +use crate::enums::*; /// Parses a SPIR-V document from a list of words. pub fn parse_spirv(i: &[u32]) -> Result { @@ -526,7 +526,7 @@ impl Spirv { #[cfg(test)] mod test { - use parse; + use crate::parse; #[test] fn test() { diff --git a/vulkano-shaders/src/spec_consts.rs b/vulkano-shaders/src/spec_consts.rs index 682688e856..791ba93339 100644 --- a/vulkano-shaders/src/spec_consts.rs +++ b/vulkano-shaders/src/spec_consts.rs @@ -12,10 +12,10 @@ use std::mem; use syn::Ident; use proc_macro2::{Span, TokenStream}; -use enums::Decoration; -use parse::{Instruction, Spirv}; -use spirv_search; -use structs; +use crate::enums::Decoration; +use crate::parse::{Instruction, Spirv}; +use crate::spirv_search; +use crate::structs; /// Returns true if the document has specialization constants. pub fn has_specialization_constants(doc: &Spirv) -> bool { diff --git a/vulkano-shaders/src/spirv_search.rs b/vulkano-shaders/src/spirv_search.rs index 023957e0ce..44741105fd 100644 --- a/vulkano-shaders/src/spirv_search.rs +++ b/vulkano-shaders/src/spirv_search.rs @@ -7,8 +7,8 @@ // notice may not be copied, modified, or distributed except // according to those terms. -use parse::{Instruction, Spirv}; -use enums::Decoration; +use crate::parse::{Instruction, Spirv}; +use crate::enums::Decoration; /// Returns the vulkano `Format` and number of occupied locations from an id. /// diff --git a/vulkano-shaders/src/structs.rs b/vulkano-shaders/src/structs.rs index dc2d98438d..d7ef54ca30 100644 --- a/vulkano-shaders/src/structs.rs +++ b/vulkano-shaders/src/structs.rs @@ -12,9 +12,9 @@ use std::mem; use syn::Ident; use proc_macro2::{Span, TokenStream}; -use parse::{Instruction, Spirv}; -use enums::Decoration; -use spirv_search; +use crate::parse::{Instruction, Spirv}; +use crate::enums::Decoration; +use crate::spirv_search; /// Translates all the structs that are contained in the SPIR-V document as Rust structs. pub fn write_structs(doc: &Spirv) -> TokenStream { diff --git a/vulkano-win/Cargo.toml b/vulkano-win/Cargo.toml index cb20fa4076..603c03e745 100644 --- a/vulkano-win/Cargo.toml +++ b/vulkano-win/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "vulkano-win" version = "0.11.1" +edition = "2018" authors = ["Pierre Krieger ", "The vulkano contributors"] repository = "https://github.com/vulkano-rs/vulkano" description = "Link between vulkano and winit" diff --git a/vulkano-win/src/lib.rs b/vulkano-win/src/lib.rs index fa209e6312..13f2a9cffa 100644 --- a/vulkano-win/src/lib.rs +++ b/vulkano-win/src/lib.rs @@ -1,15 +1,5 @@ #![doc(html_logo_url = "https://raw.githubusercontent.com/vulkano-rs/vulkano/master/logo.png")] -extern crate vulkano; -extern crate winit; - -#[cfg(target_os = "macos")] -extern crate objc; -#[cfg(target_os = "macos")] -extern crate cocoa; -#[cfg(target_os = "macos")] -extern crate metal; - use std::borrow::Borrow; use std::error; use std::fmt;