mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-25 00:04:15 +00:00
Fix width of integers and floating-points reflected from SPIR-V
This commit is contained in:
parent
38538e20e6
commit
231ea5c531
@ -198,11 +198,25 @@ fn format_from_id(doc: &parse::Spirv, searched: u32, ignore_first_array: bool) -
|
||||
match instruction {
|
||||
&parse::Instruction::TypeInt { result_id, width, signedness } if result_id == searched => {
|
||||
assert!(!ignore_first_array);
|
||||
return ("R32Sint".to_owned(), 1);
|
||||
return (match (width, signedness) {
|
||||
(8, true) => "R8Sint",
|
||||
(8, false) => "R8Uint",
|
||||
(16, true) => "R16Sint",
|
||||
(16, false) => "R16Uint",
|
||||
(32, true) => "R32Sint",
|
||||
(32, false) => "R32Uint",
|
||||
(64, true) => "R64Sint",
|
||||
(64, false) => "R64Uint",
|
||||
_ => panic!()
|
||||
}.to_owned(), 1);
|
||||
},
|
||||
&parse::Instruction::TypeFloat { result_id, width } if result_id == searched => {
|
||||
assert!(!ignore_first_array);
|
||||
return ("R32Sfloat".to_owned(), 1);
|
||||
return (match width {
|
||||
32 => "R32Sfloat",
|
||||
64 => "R64Sfloat",
|
||||
_ => panic!()
|
||||
}.to_owned(), 1);
|
||||
},
|
||||
&parse::Instruction::TypeVector { result_id, component_id, count } if result_id == searched => {
|
||||
assert!(!ignore_first_array);
|
||||
@ -261,10 +275,24 @@ fn type_from_id(doc: &parse::Spirv, searched: u32) -> String {
|
||||
return "bool".to_owned()
|
||||
},
|
||||
&parse::Instruction::TypeInt { result_id, width, signedness } if result_id == searched => {
|
||||
return "i32".to_owned()
|
||||
return match (width, signedness) {
|
||||
(8, true) => "i8",
|
||||
(8, false) => "u8",
|
||||
(16, true) => "i16",
|
||||
(16, false) => "u16",
|
||||
(32, true) => "i32",
|
||||
(32, false) => "u32",
|
||||
(64, true) => "i64",
|
||||
(64, false) => "u64",
|
||||
_ => panic!()
|
||||
}.to_owned();
|
||||
},
|
||||
&parse::Instruction::TypeFloat { result_id, width } if result_id == searched => {
|
||||
return "f32".to_owned()
|
||||
return match width {
|
||||
32 => "f32",
|
||||
64 => "f64",
|
||||
_ => panic!()
|
||||
}.to_owned();
|
||||
},
|
||||
&parse::Instruction::TypeVector { result_id, component_id, count } if result_id == searched => {
|
||||
let t = type_from_id(doc, component_id);
|
||||
|
@ -185,16 +185,64 @@ fn type_from_id(doc: &parse::Spirv, searched: u32) -> (String, Option<usize>, us
|
||||
return ("bool".to_owned(), Some(size), mem::align_of::<Foo>())
|
||||
},
|
||||
&parse::Instruction::TypeInt { result_id, width, signedness } if result_id == searched => {
|
||||
// FIXME: width
|
||||
#[repr(C)] struct Foo { data: i32, after: u8 }
|
||||
let size = unsafe { (&(&*(0 as *const Foo)).after) as *const u8 as usize };
|
||||
return ("i32".to_owned(), Some(size), mem::align_of::<Foo>())
|
||||
match (width, signedness) {
|
||||
(8, true) => {
|
||||
#[repr(C)] struct Foo { data: i8, after: u8 }
|
||||
let size = unsafe { (&(&*(0 as *const Foo)).after) as *const u8 as usize };
|
||||
return ("i8".to_owned(), Some(size), mem::align_of::<Foo>())
|
||||
},
|
||||
(8, false) => {
|
||||
#[repr(C)] struct Foo { data: u8, after: u8 }
|
||||
let size = unsafe { (&(&*(0 as *const Foo)).after) as *const u8 as usize };
|
||||
return ("u8".to_owned(), Some(size), mem::align_of::<Foo>())
|
||||
},
|
||||
(16, true) => {
|
||||
#[repr(C)] struct Foo { data: i16, after: u8 }
|
||||
let size = unsafe { (&(&*(0 as *const Foo)).after) as *const u8 as usize };
|
||||
return ("i16".to_owned(), Some(size), mem::align_of::<Foo>())
|
||||
},
|
||||
(16, false) => {
|
||||
#[repr(C)] struct Foo { data: u16, after: u8 }
|
||||
let size = unsafe { (&(&*(0 as *const Foo)).after) as *const u8 as usize };
|
||||
return ("u16".to_owned(), Some(size), mem::align_of::<Foo>())
|
||||
},
|
||||
(32, true) => {
|
||||
#[repr(C)] struct Foo { data: i32, after: u8 }
|
||||
let size = unsafe { (&(&*(0 as *const Foo)).after) as *const u8 as usize };
|
||||
return ("i32".to_owned(), Some(size), mem::align_of::<Foo>())
|
||||
},
|
||||
(32, false) => {
|
||||
#[repr(C)] struct Foo { data: u32, after: u8 }
|
||||
let size = unsafe { (&(&*(0 as *const Foo)).after) as *const u8 as usize };
|
||||
return ("u32".to_owned(), Some(size), mem::align_of::<Foo>())
|
||||
},
|
||||
(64, true) => {
|
||||
#[repr(C)] struct Foo { data: i64, after: u8 }
|
||||
let size = unsafe { (&(&*(0 as *const Foo)).after) as *const u8 as usize };
|
||||
return ("i64".to_owned(), Some(size), mem::align_of::<Foo>())
|
||||
},
|
||||
(64, false) => {
|
||||
#[repr(C)] struct Foo { data: u64, after: u8 }
|
||||
let size = unsafe { (&(&*(0 as *const Foo)).after) as *const u8 as usize };
|
||||
return ("u64".to_owned(), Some(size), mem::align_of::<Foo>())
|
||||
},
|
||||
_ => panic!("No Rust equivalent for an integer of width {}", width)
|
||||
}
|
||||
},
|
||||
&parse::Instruction::TypeFloat { result_id, width } if result_id == searched => {
|
||||
// FIXME: width
|
||||
#[repr(C)] struct Foo { data: f32, after: u8 }
|
||||
let size = unsafe { (&(&*(0 as *const Foo)).after) as *const u8 as usize };
|
||||
return ("f32".to_owned(), Some(size), mem::align_of::<Foo>())
|
||||
match width {
|
||||
32 => {
|
||||
#[repr(C)] struct Foo { data: f32, after: u8 }
|
||||
let size = unsafe { (&(&*(0 as *const Foo)).after) as *const u8 as usize };
|
||||
return ("f32".to_owned(), Some(size), mem::align_of::<Foo>())
|
||||
},
|
||||
64 => {
|
||||
#[repr(C)] struct Foo { data: f64, after: u8 }
|
||||
let size = unsafe { (&(&*(0 as *const Foo)).after) as *const u8 as usize };
|
||||
return ("f64".to_owned(), Some(size), mem::align_of::<Foo>())
|
||||
},
|
||||
_ => panic!("No Rust equivalent for a floating-point of width {}", width)
|
||||
}
|
||||
},
|
||||
&parse::Instruction::TypeVector { result_id, component_id, count } if result_id == searched => {
|
||||
debug_assert_eq!(mem::align_of::<[u32; 3]>(), mem::align_of::<u32>());
|
||||
|
Loading…
Reference in New Issue
Block a user