Skip to content

Commit

Permalink
Upgrade to ispc 1.1.0 with cleaned up bindings file (#7)
Browse files Browse the repository at this point in the history
* Upgrade to `ispc 1.1.0` with cleaned up bindings file

`ispc_compile` can now be configured to omit irrelevant bindings from
the bindings file and leave only the function(s) in place that are
relevant to interface with the ISPC kernel
(Twinklebear/ispc-rs#20).  This makes the file
less busy/noisy, and it won't change when regenerating across OS-es
anymore.

* Edition 2018 cleanup
  • Loading branch information
MarijnS95 committed Jun 30, 2022
1 parent 1080a9d commit e93de15
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 285 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ edition = "2021"
maintenance = { status = "actively-developed" }

[dependencies]
ispc_rt = "1.0.7"
ispc_rt = "1.1"

[build-dependencies]
ispc_compile = { version = "1.0.4", optional = true }
ispc_compile = { version = "1.1", optional = true }
cc = { version = "1", optional = true }
ispc_rt = "1.0.7"
ispc_rt = "1.1"

[features]
ispc = ["ispc_compile", "cc"]
Expand Down
26 changes: 21 additions & 5 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate ispc_rt;

/*
ISPC project file builds the kernels as such:
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">ispc -O2 "%(Filename).ispc" -o "$(TargetDir)%(Filename).obj" -h "$(ProjectDir)%(Filename)_ispc.h" --target=sse2,sse4,avx,avx2 --opt=fast-math</Command>
Expand All @@ -8,9 +6,9 @@ ISPC project file builds the kernels as such:

#[cfg(feature = "ispc")]
fn compile_kernel() {
use ispc_compile::TargetISA;
use ispc_compile::{BindgenOptions, Config, TargetISA};

ispc_compile::Config::new()
Config::new()
.file("vendor/ispc_texcomp/kernel.ispc")
.opt_level(2)
.woff()
Expand All @@ -22,10 +20,21 @@ fn compile_kernel() {
TargetISA::AVX512KNLi32x16,
TargetISA::AVX512SKXi32x16,
])
.bindgen_options(BindgenOptions {
allowlist_functions: vec![
"CompressBlocksBC1_ispc".into(),
"CompressBlocksBC3_ispc".into(),
"CompressBlocksBC4_ispc".into(),
"CompressBlocksBC5_ispc".into(),
"CompressBlocksBC7_ispc".into(),
"CompressBlocksBC6H_ispc".into(),
"CompressBlocksETC1_ispc".into(),
],
})
.out_dir("src/ispc")
.compile("kernel");

ispc_compile::Config::new()
Config::new()
.file("vendor/ispc_texcomp/kernel_astc.ispc")
.opt_level(2)
.woff()
Expand All @@ -37,6 +46,13 @@ fn compile_kernel() {
TargetISA::AVX512KNLi32x16,
TargetISA::AVX512SKXi32x16,
])
.bindgen_options(BindgenOptions {
allowlist_functions: vec![
"astc_rank_ispc".into(),
"astc_encode_ispc".into(),
"get_programCount".into(),
],
})
.out_dir("src/ispc")
.compile("kernel_astc");

Expand Down
58 changes: 2 additions & 56 deletions src/ispc/kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,8 @@
pub mod kernel {
/* automatically generated by rust-bindgen 0.59.2 */

pub const _VCRT_COMPILER_PREPROCESSOR: u32 = 1;
pub const _SAL_VERSION: u32 = 20;
pub const __SAL_H_VERSION: u32 = 180000000;
pub const _USE_DECLSPECS_FOR_SAL: u32 = 0;
pub const _USE_ATTRIBUTES_FOR_SAL: u32 = 0;
pub const _CRT_PACKING: u32 = 8;
pub const _HAS_EXCEPTIONS: u32 = 1;
pub const _STL_LANG: u32 = 0;
pub const _HAS_CXX17: u32 = 0;
pub const _HAS_CXX20: u32 = 0;
pub const _HAS_CXX23: u32 = 0;
pub const _HAS_NODISCARD: u32 = 0;
pub const WCHAR_MIN: u32 = 0;
pub const WCHAR_MAX: u32 = 65535;
pub const WINT_MIN: u32 = 0;
pub const WINT_MAX: u32 = 65535;
pub const true_: u32 = 1;
pub const false_: u32 = 0;
pub const __bool_true_false_are_defined: u32 = 1;
pub type va_list = *mut ::std::os::raw::c_char;
extern "C" {
pub fn __va_start(arg1: *mut *mut ::std::os::raw::c_char, ...);
}
pub type size_t = ::std::os::raw::c_ulonglong;
pub type __vcrt_bool = bool;
pub type wchar_t = ::std::os::raw::c_ushort;
extern "C" {
pub fn __security_init_cookie();
}
extern "C" {
pub fn __security_check_cookie(_StackCookie: usize);
}
extern "C" {
pub fn __report_gsfailure(_StackCookie: usize);
}
extern "C" {
pub static mut __security_cookie: usize;
}
pub type int_least8_t = ::std::os::raw::c_schar;
pub type int_least16_t = ::std::os::raw::c_short;
pub type int_least32_t = ::std::os::raw::c_int;
pub type int_least64_t = ::std::os::raw::c_longlong;
pub type uint_least8_t = ::std::os::raw::c_uchar;
pub type uint_least16_t = ::std::os::raw::c_ushort;
pub type uint_least32_t = ::std::os::raw::c_uint;
pub type uint_least64_t = ::std::os::raw::c_ulonglong;
pub type int_fast8_t = ::std::os::raw::c_schar;
pub type int_fast16_t = ::std::os::raw::c_int;
pub type int_fast32_t = ::std::os::raw::c_int;
pub type int_fast64_t = ::std::os::raw::c_longlong;
pub type uint_fast8_t = ::std::os::raw::c_uchar;
pub type uint_fast16_t = ::std::os::raw::c_uint;
pub type uint_fast32_t = ::std::os::raw::c_uint;
pub type uint_fast64_t = ::std::os::raw::c_ulonglong;
pub type intmax_t = ::std::os::raw::c_longlong;
pub type uintmax_t = ::std::os::raw::c_ulonglong;
pub type __uint8_t = ::std::os::raw::c_uchar;
pub type __int32_t = ::std::os::raw::c_int;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct rgba_surface {
Expand Down
222 changes: 4 additions & 218 deletions src/ispc/kernel_astc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,10 @@
pub mod kernel_astc {
/* automatically generated by rust-bindgen 0.59.2 */

pub const _VCRT_COMPILER_PREPROCESSOR: u32 = 1;
pub const _SAL_VERSION: u32 = 20;
pub const __SAL_H_VERSION: u32 = 180000000;
pub const _USE_DECLSPECS_FOR_SAL: u32 = 0;
pub const _USE_ATTRIBUTES_FOR_SAL: u32 = 0;
pub const _CRT_PACKING: u32 = 8;
pub const _HAS_EXCEPTIONS: u32 = 1;
pub const _STL_LANG: u32 = 0;
pub const _HAS_CXX17: u32 = 0;
pub const _HAS_CXX20: u32 = 0;
pub const _HAS_CXX23: u32 = 0;
pub const _HAS_NODISCARD: u32 = 0;
pub const WCHAR_MIN: u32 = 0;
pub const WCHAR_MAX: u32 = 65535;
pub const WINT_MIN: u32 = 0;
pub const WINT_MAX: u32 = 65535;
pub const true_: u32 = 1;
pub const false_: u32 = 0;
pub const __bool_true_false_are_defined: u32 = 1;
pub type va_list = *mut ::std::os::raw::c_char;
extern "C" {
pub fn __va_start(arg1: *mut *mut ::std::os::raw::c_char, ...);
}
pub type size_t = ::std::os::raw::c_ulonglong;
pub type __vcrt_bool = bool;
pub type wchar_t = ::std::os::raw::c_ushort;
extern "C" {
pub fn __security_init_cookie();
}
extern "C" {
pub fn __security_check_cookie(_StackCookie: usize);
}
extern "C" {
pub fn __report_gsfailure(_StackCookie: usize);
}
extern "C" {
pub static mut __security_cookie: usize;
}
pub type int_least8_t = ::std::os::raw::c_schar;
pub type int_least16_t = ::std::os::raw::c_short;
pub type int_least32_t = ::std::os::raw::c_int;
pub type int_least64_t = ::std::os::raw::c_longlong;
pub type uint_least8_t = ::std::os::raw::c_uchar;
pub type uint_least16_t = ::std::os::raw::c_ushort;
pub type uint_least32_t = ::std::os::raw::c_uint;
pub type uint_least64_t = ::std::os::raw::c_ulonglong;
pub type int_fast8_t = ::std::os::raw::c_schar;
pub type int_fast16_t = ::std::os::raw::c_int;
pub type int_fast32_t = ::std::os::raw::c_int;
pub type int_fast64_t = ::std::os::raw::c_longlong;
pub type uint_fast8_t = ::std::os::raw::c_uchar;
pub type uint_fast16_t = ::std::os::raw::c_uint;
pub type uint_fast32_t = ::std::os::raw::c_uint;
pub type uint_fast64_t = ::std::os::raw::c_ulonglong;
pub type intmax_t = ::std::os::raw::c_longlong;
pub type uintmax_t = ::std::os::raw::c_ulonglong;
pub type __uint8_t = ::std::os::raw::c_uchar;
pub type __int32_t = ::std::os::raw::c_int;
pub type __uint32_t = ::std::os::raw::c_uint;
pub type __uint64_t = ::std::os::raw::c_ulong;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct rgba_surface {
Expand Down Expand Up @@ -280,168 +228,6 @@ fn bindgen_test_layout_astc_enc_settings() {
)
);
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct astc_block {
pub width: i32,
pub height: i32,
pub dual_plane: u8,
pub weight_range: i32,
pub weights: [u8; 64usize],
pub color_component_selector: i32,
pub partitions: i32,
pub partition_id: i32,
pub color_endpoint_pairs: i32,
pub channels: i32,
pub color_endpoint_modes: [i32; 4usize],
pub endpoint_range: i32,
pub endpoints: [u8; 18usize],
}
#[test]
fn bindgen_test_layout_astc_block() {
assert_eq!(
::std::mem::size_of::<astc_block>(),
140usize,
concat!("Size of: ", stringify!(astc_block))
);
assert_eq!(
::std::mem::align_of::<astc_block>(),
4usize,
concat!("Alignment of ", stringify!(astc_block))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<astc_block>())).width as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(astc_block),
"::",
stringify!(width)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<astc_block>())).height as *const _ as usize },
4usize,
concat!(
"Offset of field: ",
stringify!(astc_block),
"::",
stringify!(height)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<astc_block>())).dual_plane as *const _ as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(astc_block),
"::",
stringify!(dual_plane)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<astc_block>())).weight_range as *const _ as usize },
12usize,
concat!(
"Offset of field: ",
stringify!(astc_block),
"::",
stringify!(weight_range)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<astc_block>())).weights as *const _ as usize },
16usize,
concat!(
"Offset of field: ",
stringify!(astc_block),
"::",
stringify!(weights)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<astc_block>())).color_component_selector as *const _ as usize
},
80usize,
concat!(
"Offset of field: ",
stringify!(astc_block),
"::",
stringify!(color_component_selector)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<astc_block>())).partitions as *const _ as usize },
84usize,
concat!(
"Offset of field: ",
stringify!(astc_block),
"::",
stringify!(partitions)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<astc_block>())).partition_id as *const _ as usize },
88usize,
concat!(
"Offset of field: ",
stringify!(astc_block),
"::",
stringify!(partition_id)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<astc_block>())).color_endpoint_pairs as *const _ as usize },
92usize,
concat!(
"Offset of field: ",
stringify!(astc_block),
"::",
stringify!(color_endpoint_pairs)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<astc_block>())).channels as *const _ as usize },
96usize,
concat!(
"Offset of field: ",
stringify!(astc_block),
"::",
stringify!(channels)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<astc_block>())).color_endpoint_modes as *const _ as usize },
100usize,
concat!(
"Offset of field: ",
stringify!(astc_block),
"::",
stringify!(color_endpoint_modes)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<astc_block>())).endpoint_range as *const _ as usize },
116usize,
concat!(
"Offset of field: ",
stringify!(astc_block),
"::",
stringify!(endpoint_range)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<astc_block>())).endpoints as *const _ as usize },
120usize,
concat!(
"Offset of field: ",
stringify!(astc_block),
"::",
stringify!(endpoints)
)
);
}
extern "C" {
pub fn astc_encode_ispc(
src: *mut rgba_surface,
Expand Down
Binary file modified src/ispc/libispc_texcomp_astcx86_64-unknown-linux-gnu.a
Binary file not shown.
Binary file modified src/ispc/libkernel_astcx86_64-unknown-linux-gnu.a
Binary file not shown.
Binary file modified src/ispc/libkernelx86_64-unknown-linux-gnu.a
Binary file not shown.
4 changes: 1 addition & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#[macro_use]
extern crate ispc_rt;

#[allow(deref_nullptr)]
pub mod bindings {
use ispc_rt::ispc_module;
ispc_module!(kernel);
ispc_module!(kernel_astc);
}
Expand Down

0 comments on commit e93de15

Please sign in to comment.