Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature for basis u compilation with SSE 4.1 on supported platforms #14

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
5 changes: 4 additions & 1 deletion basis-universal-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "basis-universal-sys"
version = "0.3.0"
version = "0.3.1"
authors = ["Philip Degarmo <[email protected]>"]
edition = "2018"
license = "MIT OR Apache-2.0"
Expand All @@ -16,3 +16,6 @@ exclude = ["vendor/basis_universal/test_files", "vendor/basis_universal/webgl",

[build-dependencies]
cc = "1.0"

[features]
hint_sse4_1 = []
13 changes: 12 additions & 1 deletion basis-universal-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,21 @@ fn build_with_common_settings() -> cc::Build {
}

fn main() {
// Only allow the SSE flag if we compile for x86/x86_64
// See: https://github.com/aclysma/basis-universal-rs/pull/14#discussion_r1200978360
let build_with_sse4_1 = cfg!(feature = "hint_sse4_1")
&& std::env::var("CARGO_CFG_TARGET_ARCH")
.expect("Cargo didn't set the CARGO_CFG_TARGET_ARCH env var")
.split(',')
.any(|arch| arch == "x86_64" || arch == "x86");

build_with_common_settings()
.cpp(true)
.define("BASISD_SUPPORT_KTX2_ZSTD", "0")
//.define("BASISU_SUPPORT_SSE", "1") TODO: expose this in a futher release
.define(
"BASISU_SUPPORT_SSE",
if build_with_sse4_1 { "1" } else { "0" },
)
.flag_if_supported("--std=c++11")
.file("vendor/basis_universal/encoder/pvpngreader.cpp")
.file("vendor/basis_universal/encoder/jpgd.cpp")
Expand Down
7 changes: 5 additions & 2 deletions basis-universal/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "basis-universal"
version = "0.3.0"
version = "0.3.1"
authors = ["Philip Degarmo <[email protected]>"]
edition = "2018"
license = "MIT OR Apache-2.0"
Expand All @@ -12,10 +12,13 @@ keywords = ["game", "basis-universal", "texture", "compression", "gpu"]
categories = ["game-development", "graphics", "api-bindings", "compression", "encoding"]

[dependencies]
basis-universal-sys = { version = "0.3.0", path = "../basis-universal-sys" }
basis-universal-sys = { version = "0.3.1", path = "../basis-universal-sys" }
lazy_static = "1.4.0"
bitflags = "1.2.1"

[dev-dependencies]
image = "0.23.13"
lz4 = "1.23"

[features]
hint_sse4_1 = ["basis-universal-sys/hint_sse4_1"]