Skip to content

Commit

Permalink
Upgrade vulkano-win and vulkano-shaders to rust 2018 (#1134)
Browse files Browse the repository at this point in the history
* Upgrade vulkano-shaders to rust 2018
* Upgrade vulkano-win to rust 2018
  • Loading branch information
rukai authored Dec 11, 2018
1 parent 34eeea6 commit 9a08414
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 54 deletions.
7 changes: 2 additions & 5 deletions examples/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions vulkano-shaders/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[package]
name = "vulkano-shaders"
version = "0.11.1"
edition = "2018"
authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>", "The vulkano contributors"]
repository = "https://github.com/vulkano-rs/vulkano"
description = "Shaders rust code generation macro"
Expand Down
18 changes: 9 additions & 9 deletions vulkano-shaders/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions vulkano-shaders/src/descriptor_sets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down
8 changes: 4 additions & 4 deletions vulkano-shaders/src/entry_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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!{ () }
Expand Down
2 changes: 1 addition & 1 deletion vulkano-shaders/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;)+) => (
Expand Down
12 changes: 2 additions & 10 deletions vulkano-shaders/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
//! # Basic usage
//!
//! ```
//! extern crate vulkano;
//! extern crate vulkano_shaders;
//!
//! mod vs {
//! vulkano_shaders::shader!{
//! ty: "vertex",
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -181,7 +173,7 @@ mod spec_consts;
mod structs;
mod spirv_search;

use codegen::ShaderKind;
use crate::codegen::ShaderKind;

enum SourceKind {
Src(String),
Expand Down
4 changes: 2 additions & 2 deletions vulkano-shaders/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Spirv, ParseError> {
Expand Down Expand Up @@ -526,7 +526,7 @@ impl Spirv {

#[cfg(test)]
mod test {
use parse;
use crate::parse;

#[test]
fn test() {
Expand Down
8 changes: 4 additions & 4 deletions vulkano-shaders/src/spec_consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions vulkano-shaders/src/spirv_search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down
6 changes: 3 additions & 3 deletions vulkano-shaders/src/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions vulkano-win/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[package]
name = "vulkano-win"
version = "0.11.1"
edition = "2018"
authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>", "The vulkano contributors"]
repository = "https://github.com/vulkano-rs/vulkano"
description = "Link between vulkano and winit"
Expand Down
10 changes: 0 additions & 10 deletions vulkano-win/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 9a08414

Please sign in to comment.