Skip to content

Commit

Permalink
Update submodule, types, and MSL options
Browse files Browse the repository at this point in the history
  • Loading branch information
grovesNL committed Dec 5, 2018
1 parent 6643c4b commit 590de91
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 21 deletions.
2 changes: 2 additions & 0 deletions spirv_cross/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ fn main() {
.file("src/wrapper.cpp")
.file("src/vendor/SPIRV-Cross/spirv_cfg.cpp")
.file("src/vendor/SPIRV-Cross/spirv_cross.cpp")
.file("src/vendor/SPIRV-Cross/spirv_cross_parsed_ir.cpp")
.file("src/vendor/SPIRV-Cross/spirv_parser.cpp")
.file("src/vendor/SPIRV-Cross/spirv_cross_util.cpp")
.file("src/vendor/SPIRV-Cross/spirv_glsl.cpp")
.file("src/vendor/SPIRV-Cross/spirv_hlsl.cpp")
Expand Down
37 changes: 24 additions & 13 deletions spirv_cross/src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1481,18 +1481,22 @@ pub mod root {
Void = 1,
Boolean = 2,
Char = 3,
Int = 4,
UInt = 5,
Int64 = 6,
UInt64 = 7,
AtomicCounter = 8,
Half = 9,
Float = 10,
Double = 11,
Struct = 12,
Image = 13,
SampledImage = 14,
Sampler = 15,
SByte = 4,
UByte = 5,
Short = 6,
UShort = 7,
Int = 8,
UInt = 9,
Int64 = 10,
UInt64 = 11,
AtomicCounter = 12,
Half = 13,
Float = 14,
Double = 15,
Struct = 16,
Image = 17,
SampledImage = 18,
Sampler = 19,
}
#[repr(C)]
#[derive(Debug, Copy)]
Expand All @@ -1505,6 +1509,13 @@ pub mod root {
impl Clone for Resource {
fn clone(&self) -> Self { *self }
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum MSLVertexFormat {
MSL_VERTEX_FORMAT_OTHER = 0,
MSL_VERTEX_FORMAT_UINT8 = 1,
MSL_VERTEX_FORMAT_UINT16 = 2,
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct MSLVertexAttr {
Expand All @@ -1513,6 +1524,7 @@ pub mod root {
pub msl_offset: u32,
pub msl_stride: u32,
pub per_instance: bool,
pub format: root::spirv_cross::MSLVertexFormat,
pub used_by_shader: bool,
}
impl Clone for MSLVertexAttr {
Expand Down Expand Up @@ -1597,7 +1609,6 @@ pub mod root {
pub platform: u8,
pub version: u32,
pub enable_point_size_builtin: bool,
pub resolve_specialized_array_lengths: bool,
pub disable_rasterization: bool,
}
impl Clone for ScMslCompilerOptions {
Expand Down
4 changes: 4 additions & 0 deletions spirv_cross/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ impl spirv::Type {
b::Image => Image { array },
b::SampledImage => SampledImage { array },
b::Sampler => Sampler { array },
b::SByte => SByte { array },
b::UByte => UByte { array },
b::Short => Short { array },
b::UShort => UShort { array },
}
}
}
Expand Down
26 changes: 22 additions & 4 deletions spirv_cross/src/msl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,26 @@ impl spirv::Target for Target {
#[derive(Debug, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
pub struct VertexAttributeLocation(pub u32);

/// Format of the vertex attribute
#[derive(Debug, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
pub enum Format {
Other,
Uint8,
Uint16,
}

impl Format {
fn as_raw(&self) -> spirv_cross::MSLVertexFormat {
use self::Format::*;
use self::spirv_cross::MSLVertexFormat as R;
match self {
Other => R::MSL_VERTEX_FORMAT_OTHER,
Uint8 => R::MSL_VERTEX_FORMAT_UINT8,
Uint16 => R::MSL_VERTEX_FORMAT_UINT16,
}
}
}

/// Vertex attribute description for overriding
#[derive(Debug, Clone, Hash, Eq, PartialEq)]
pub struct VertexAttribute {
Expand All @@ -30,6 +50,7 @@ pub struct VertexAttribute {
pub stride: u32,
pub step: spirv::VertexAttributeStep,
pub force_used: bool,
pub format: Format,
}

/// Location of a resource binding to override
Expand Down Expand Up @@ -107,8 +128,6 @@ pub struct CompilerOptions {
pub vertex: CompilerVertexOptions,
/// Whether the built-in point size should be enabled.
pub enable_point_size_builtin: bool,
/// Whether array lengths should be resolved instead of specialized.
pub resolve_specialized_array_lengths: bool,
/// Whether rasterization should be enabled.
pub enable_rasterization: bool,
/// MSL resource bindings overrides.
Expand All @@ -125,7 +144,6 @@ impl CompilerOptions {
platform: self.platform as _,
version: self.version.as_raw(),
enable_point_size_builtin: self.enable_point_size_builtin,
resolve_specialized_array_lengths: self.resolve_specialized_array_lengths,
disable_rasterization: !self.enable_rasterization,
}
}
Expand All @@ -138,7 +156,6 @@ impl Default for CompilerOptions {
version: Version::V1_2,
vertex: CompilerVertexOptions::default(),
enable_point_size_builtin: true,
resolve_specialized_array_lengths: true,
enable_rasterization: true,
resource_binding_overrides: Default::default(),
vertex_attribute_overrides: Default::default(),
Expand Down Expand Up @@ -213,6 +230,7 @@ impl spirv::Compile<Target> for spirv::Ast<Target> {
spirv::VertexAttributeStep::Instance => true,
},
used_by_shader: vat.force_used,
format: vat.format.as_raw(),
})
);

Expand Down
12 changes: 12 additions & 0 deletions spirv_cross/src/spirv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,18 @@ pub enum Type {
Sampler {
array: Vec<u32>,
},
SByte {
array: Vec<u32>,
},
UByte {
array: Vec<u32>,
},
Short {
array: Vec<u32>,
},
UShort {
array: Vec<u32>,
},
}

/// A SPIR-V shader module.
Expand Down
2 changes: 1 addition & 1 deletion spirv_cross/src/vendor/SPIRV-Cross
Submodule SPIRV-Cross updated 319 files
1 change: 0 additions & 1 deletion spirv_cross/src/wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ extern "C"
msl_options.platform = static_cast<spirv_cross::CompilerMSL::Options::Platform>(options->platform);
msl_options.msl_version = options->version;
msl_options.enable_point_size_builtin = options->enable_point_size_builtin;
msl_options.resolve_specialized_array_lengths = options->resolve_specialized_array_lengths;
msl_options.disable_rasterization = options->disable_rasterization;
compiler_msl->set_msl_options(msl_options);
} while (0);)
Expand Down
1 change: 0 additions & 1 deletion spirv_cross/src/wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ extern "C"
uint8_t platform;
uint32_t version;
bool enable_point_size_builtin;
bool resolve_specialized_array_lengths;
bool disable_rasterization;
} ScMslCompilerOptions;

Expand Down
3 changes: 2 additions & 1 deletion spirv_cross/tests/hlsl_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ fn ast_compiles_to_hlsl() {
assert_eq!(
ast.compile().unwrap(),
"\
cbuffer _22
cbuffer uniform_buffer_object
{
row_major float4x4 _22_u_model_view_projection : packoffset(c0);
float _22_u_scale : packoffset(c4);
};
static float4 gl_Position;
static float3 v_normal;
static float3 a_normal;
Expand Down

0 comments on commit 590de91

Please sign in to comment.