mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-25 08:14:20 +00:00
Upgrade vulkano-win and vulkano-shaders to rust 2018 (#1134)
* Upgrade vulkano-shaders to rust 2018 * Upgrade vulkano-win to rust 2018
This commit is contained in:
parent
34eeea6b52
commit
9a08414054
@ -7,15 +7,12 @@
|
|||||||
// notice may not be copied, modified, or distributed except
|
// notice may not be copied, modified, or distributed except
|
||||||
// according to those terms.
|
// according to those terms.
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate vulkano;
|
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct Vertex {
|
pub struct Vertex {
|
||||||
position: (f32, f32, f32)
|
position: (f32, f32, f32)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_vertex!(Vertex, position);
|
vulkano::impl_vertex!(Vertex, position);
|
||||||
|
|
||||||
pub const VERTICES: [Vertex; 531] = [
|
pub const VERTICES: [Vertex; 531] = [
|
||||||
Vertex { position: (0.0, 0.0, 0.0) }, // dummy vector because in the original model indices
|
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)
|
normal: (f32, f32, f32)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_vertex!(Normal, normal);
|
vulkano::impl_vertex!(Normal, normal);
|
||||||
|
|
||||||
pub const NORMALS: [Normal; 531] = [
|
pub const NORMALS: [Normal; 531] = [
|
||||||
Normal { normal: (0.0, 0.0, 0.0) }, // dummy vector because in the original model indices
|
Normal { normal: (0.0, 0.0, 0.0) }, // dummy vector because in the original model indices
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "vulkano-shaders"
|
name = "vulkano-shaders"
|
||||||
version = "0.11.1"
|
version = "0.11.1"
|
||||||
|
edition = "2018"
|
||||||
authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>", "The vulkano contributors"]
|
authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>", "The vulkano contributors"]
|
||||||
repository = "https://github.com/vulkano-rs/vulkano"
|
repository = "https://github.com/vulkano-rs/vulkano"
|
||||||
description = "Shaders rust code generation macro"
|
description = "Shaders rust code generation macro"
|
||||||
|
@ -15,17 +15,17 @@ use proc_macro2::{Span, TokenStream};
|
|||||||
use shaderc::{Compiler, CompileOptions};
|
use shaderc::{Compiler, CompileOptions};
|
||||||
|
|
||||||
pub use shaderc::{CompilationArtifact, ShaderKind, IncludeType, ResolvedInclude};
|
pub use shaderc::{CompilationArtifact, ShaderKind, IncludeType, ResolvedInclude};
|
||||||
pub use parse::ParseError;
|
pub use crate::parse::ParseError;
|
||||||
|
|
||||||
use parse::Instruction;
|
use crate::parse::Instruction;
|
||||||
use enums::Capability;
|
use crate::enums::Capability;
|
||||||
|
|
||||||
use parse;
|
use crate::parse;
|
||||||
use entry_point;
|
use crate::entry_point;
|
||||||
use structs;
|
use crate::structs;
|
||||||
use descriptor_sets;
|
use crate::descriptor_sets;
|
||||||
use spec_consts;
|
use crate::spec_consts;
|
||||||
use read_file_to_string;
|
use crate::read_file_to_string;
|
||||||
|
|
||||||
fn include_callback(requested_source_path_raw: &str, directive_type: IncludeType,
|
fn include_callback(requested_source_path_raw: &str, directive_type: IncludeType,
|
||||||
contained_within_path_raw: &str, recursion_depth: usize,
|
contained_within_path_raw: &str, recursion_depth: usize,
|
||||||
|
@ -11,9 +11,9 @@ use std::cmp;
|
|||||||
|
|
||||||
use proc_macro2::TokenStream;
|
use proc_macro2::TokenStream;
|
||||||
|
|
||||||
use enums::{Dim, Decoration, StorageClass, ImageFormat};
|
use crate::enums::{Dim, Decoration, StorageClass, ImageFormat};
|
||||||
use parse::{Instruction, Spirv};
|
use crate::parse::{Instruction, Spirv};
|
||||||
use spirv_search;
|
use crate::spirv_search;
|
||||||
|
|
||||||
pub fn write_descriptor_sets(doc: &Spirv) -> TokenStream {
|
pub fn write_descriptor_sets(doc: &Spirv) -> TokenStream {
|
||||||
// TODO: not implemented correctly
|
// TODO: not implemented correctly
|
||||||
@ -61,7 +61,7 @@ pub fn write_descriptor_sets(doc: &Spirv) -> TokenStream {
|
|||||||
_ => continue,
|
_ => 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");
|
let size = size.expect("Found runtime-sized push constants");
|
||||||
push_constants_size = cmp::max(push_constants_size, size);
|
push_constants_size = cmp::max(push_constants_size, size);
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,9 @@
|
|||||||
use syn::Ident;
|
use syn::Ident;
|
||||||
use proc_macro2::{Span, TokenStream};
|
use proc_macro2::{Span, TokenStream};
|
||||||
|
|
||||||
use enums::{StorageClass, ExecutionModel, ExecutionMode, Decoration};
|
use crate::enums::{StorageClass, ExecutionModel, ExecutionMode, Decoration};
|
||||||
use parse::{Instruction, Spirv};
|
use crate::parse::{Instruction, Spirv};
|
||||||
use spirv_search;
|
use crate::spirv_search;
|
||||||
|
|
||||||
pub fn write_entry_point(doc: &Spirv, instruction: &Instruction) -> (TokenStream, TokenStream) {
|
pub fn write_entry_point(doc: &Spirv, instruction: &Instruction) -> (TokenStream, TokenStream) {
|
||||||
let (execution, id, ep_name, interface) = match instruction {
|
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
|
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 }
|
quote!{ SpecializationConstants }
|
||||||
} else {
|
} else {
|
||||||
quote!{ () }
|
quote!{ () }
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
#![allow(non_camel_case_types)]
|
#![allow(non_camel_case_types)]
|
||||||
|
|
||||||
use parse::ParseError;
|
use crate::parse::ParseError;
|
||||||
|
|
||||||
macro_rules! enumeration {
|
macro_rules! enumeration {
|
||||||
($(typedef enum $unused:ident { $($elem:ident = $value:expr,)+ } $name:ident;)+) => (
|
($(typedef enum $unused:ident { $($elem:ident = $value:expr,)+ } $name:ident;)+) => (
|
||||||
|
@ -4,9 +4,6 @@
|
|||||||
//! # Basic usage
|
//! # Basic usage
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! extern crate vulkano;
|
|
||||||
//! extern crate vulkano_shaders;
|
|
||||||
//!
|
|
||||||
//! mod vs {
|
//! mod vs {
|
||||||
//! vulkano_shaders::shader!{
|
//! vulkano_shaders::shader!{
|
||||||
//! ty: "vertex",
|
//! ty: "vertex",
|
||||||
@ -67,8 +64,6 @@
|
|||||||
//! you could do something like this:
|
//! you could do something like this:
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! # extern crate vulkano_shaders;
|
|
||||||
//! # extern crate vulkano;
|
|
||||||
//! # fn main() {}
|
//! # fn main() {}
|
||||||
//! # use std::sync::Arc;
|
//! # use std::sync::Arc;
|
||||||
//! # use vulkano::OomError;
|
//! # use vulkano::OomError;
|
||||||
@ -158,11 +153,8 @@
|
|||||||
|
|
||||||
#![recursion_limit = "1024"]
|
#![recursion_limit = "1024"]
|
||||||
#[macro_use] extern crate quote;
|
#[macro_use] extern crate quote;
|
||||||
extern crate shaderc;
|
|
||||||
extern crate proc_macro;
|
|
||||||
extern crate proc_macro2;
|
|
||||||
#[macro_use] extern crate syn;
|
#[macro_use] extern crate syn;
|
||||||
|
extern crate proc_macro;
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
@ -181,7 +173,7 @@ mod spec_consts;
|
|||||||
mod structs;
|
mod structs;
|
||||||
mod spirv_search;
|
mod spirv_search;
|
||||||
|
|
||||||
use codegen::ShaderKind;
|
use crate::codegen::ShaderKind;
|
||||||
|
|
||||||
enum SourceKind {
|
enum SourceKind {
|
||||||
Src(String),
|
Src(String),
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
// notice may not be copied, modified, or distributed except
|
// notice may not be copied, modified, or distributed except
|
||||||
// according to those terms.
|
// according to those terms.
|
||||||
|
|
||||||
use enums::*;
|
use crate::enums::*;
|
||||||
|
|
||||||
/// Parses a SPIR-V document from a list of words.
|
/// Parses a SPIR-V document from a list of words.
|
||||||
pub fn parse_spirv(i: &[u32]) -> Result<Spirv, ParseError> {
|
pub fn parse_spirv(i: &[u32]) -> Result<Spirv, ParseError> {
|
||||||
@ -526,7 +526,7 @@ impl Spirv {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use parse;
|
use crate::parse;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test() {
|
fn test() {
|
||||||
|
@ -12,10 +12,10 @@ use std::mem;
|
|||||||
use syn::Ident;
|
use syn::Ident;
|
||||||
use proc_macro2::{Span, TokenStream};
|
use proc_macro2::{Span, TokenStream};
|
||||||
|
|
||||||
use enums::Decoration;
|
use crate::enums::Decoration;
|
||||||
use parse::{Instruction, Spirv};
|
use crate::parse::{Instruction, Spirv};
|
||||||
use spirv_search;
|
use crate::spirv_search;
|
||||||
use structs;
|
use crate::structs;
|
||||||
|
|
||||||
/// Returns true if the document has specialization constants.
|
/// Returns true if the document has specialization constants.
|
||||||
pub fn has_specialization_constants(doc: &Spirv) -> bool {
|
pub fn has_specialization_constants(doc: &Spirv) -> bool {
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
// notice may not be copied, modified, or distributed except
|
// notice may not be copied, modified, or distributed except
|
||||||
// according to those terms.
|
// according to those terms.
|
||||||
|
|
||||||
use parse::{Instruction, Spirv};
|
use crate::parse::{Instruction, Spirv};
|
||||||
use enums::Decoration;
|
use crate::enums::Decoration;
|
||||||
|
|
||||||
/// Returns the vulkano `Format` and number of occupied locations from an id.
|
/// Returns the vulkano `Format` and number of occupied locations from an id.
|
||||||
///
|
///
|
||||||
|
@ -12,9 +12,9 @@ use std::mem;
|
|||||||
use syn::Ident;
|
use syn::Ident;
|
||||||
use proc_macro2::{Span, TokenStream};
|
use proc_macro2::{Span, TokenStream};
|
||||||
|
|
||||||
use parse::{Instruction, Spirv};
|
use crate::parse::{Instruction, Spirv};
|
||||||
use enums::Decoration;
|
use crate::enums::Decoration;
|
||||||
use spirv_search;
|
use crate::spirv_search;
|
||||||
|
|
||||||
/// Translates all the structs that are contained in the SPIR-V document as Rust structs.
|
/// Translates all the structs that are contained in the SPIR-V document as Rust structs.
|
||||||
pub fn write_structs(doc: &Spirv) -> TokenStream {
|
pub fn write_structs(doc: &Spirv) -> TokenStream {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "vulkano-win"
|
name = "vulkano-win"
|
||||||
version = "0.11.1"
|
version = "0.11.1"
|
||||||
|
edition = "2018"
|
||||||
authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>", "The vulkano contributors"]
|
authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>", "The vulkano contributors"]
|
||||||
repository = "https://github.com/vulkano-rs/vulkano"
|
repository = "https://github.com/vulkano-rs/vulkano"
|
||||||
description = "Link between vulkano and winit"
|
description = "Link between vulkano and winit"
|
||||||
|
@ -1,15 +1,5 @@
|
|||||||
#![doc(html_logo_url = "https://raw.githubusercontent.com/vulkano-rs/vulkano/master/logo.png")]
|
#![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::borrow::Borrow;
|
||||||
use std::error;
|
use std::error;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
Loading…
Reference in New Issue
Block a user