From df024b1164ee030e2b42d8691e8ba4ffcd541d2d Mon Sep 17 00:00:00 2001 From: SMG Date: Tue, 17 Dec 2024 20:30:37 -0600 Subject: [PATCH 1/2] Update main.rs --- examples/main.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/examples/main.rs b/examples/main.rs index 688b8ce..a91da01 100644 --- a/examples/main.rs +++ b/examples/main.rs @@ -5,6 +5,7 @@ use image::LumaA; use image::Pixel; use intel_tex_2::bc4; use intel_tex_2::bc5; +use intel_tex_2::bc6h; use intel_tex_2::bc7; use std::fs::File; use std::path::Path; @@ -93,6 +94,35 @@ fn main() { let mut dds_file = File::create("examples/lambertian_bc5.dds").unwrap(); dds.write(&mut dds_file).expect("Failed to write dds file"); } + // BC6 + { + let mut dds = Dds::new_dxgi(NewDxgiParams { + format: DxgiFormat::BC6H_UF16, + ..dds_defaults + }) + .unwrap(); + let rgba_f16_data: Vec = rgba_img + .iter() + .flat_map(|c| half::f16::from_f32(*c as f32 / 255.0).to_le_bytes()) + .collect(); + let surface = intel_tex_2::RgbaSurface { + width, + height, + stride: width * 4 * std::mem::size_of::() as u32, + data: &rgba_f16_data, + }; + + println!("Compressing to BC6..."); + bc6h::compress_blocks_into( + &bc6h::very_fast_settings(), + &surface, + dds.get_mut_data(0 /* layer */).unwrap(), + ); + println!(" Done!"); + println!("Saving lambertian_bc6.dds file"); + let mut dds_file = File::create("examples/lambertian_bc6.dds").unwrap(); + dds.write(&mut dds_file).expect("Failed to write dds file"); + } // BC7 { let mut dds = Dds::new_dxgi(NewDxgiParams { From ad9b7d8ffe5618f16a767aa6ea8970111172e718 Mon Sep 17 00:00:00 2001 From: SMG Date: Tue, 17 Dec 2024 20:31:02 -0600 Subject: [PATCH 2/2] Update Cargo.toml --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index b198f43..94d3620 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,6 +35,7 @@ ispc = ["ispc_compile", "cc"] [dev-dependencies] ddsfile = "0.5.0" image = "0.25.1" +half = "2.4.1" [profile.release] lto = true