Closed stefnotch closed 6 months ago
I fixed and tested the glam type_for_format
code.
I used this for testing. I'll happily add some testing code along these lines, but am unsure of where one would add it.
fn print_type_of<T>(_: &T) {
println!("{}", std::any::type_name::<T>())
}
let x: vulkano::type_for_format!(glam, R8G8_UNORM) = Default::default();
print_type_of(&x); // [u8; 2]
let x: vulkano::type_for_format!(glam, R16G16_UNORM) = Default::default();
print_type_of(&x); // glam::u16::u16vec2::U16Vec2
let x: vulkano::type_for_format!(glam, R16G16_UINT) = Default::default();
print_type_of(&x); // glam::u16::u16vec2::U16Vec2
let x: vulkano::type_for_format!(glam, R16G16_SINT) = Default::default();
print_type_of(&x); // glam::i16::i16vec2::I16Vec2
// let x: vulkano::type_for_format!(glam, R16G16_SFLOAT) = Default::default();
// print_type_of(&x); // Rust doesn't have a f16 type
let x: vulkano::type_for_format!(glam, R32G32_UINT) = Default::default();
print_type_of(&x); // glam::u32::uvec2::UVec2
let x: vulkano::type_for_format!(glam, R32G32_SINT) = Default::default();
print_type_of(&x); // glam::i32::ivec2::IVec2
let x: vulkano::type_for_format!(glam, R32G32_SFLOAT) = Default::default();
print_type_of(&x); // glam::f32::vec2::Vec2
let x: vulkano::type_for_format!(glam, R64G64B64_UINT) = Default::default();
print_type_of(&x); // glam::u64::u64vec3::U64Vec3
let x: vulkano::type_for_format!(glam, R64G64B64_SINT) = Default::default();
print_type_of(&x); // glam::i64::i64vec3::I64Vec3
let x: vulkano::type_for_format!(glam, R64G64B64_SFLOAT) = Default::default();
print_type_of(&x); // glam::f64::dvec3::DVec3
let x: vulkano::type_for_format!(glam, ASTC_12x10_SFLOAT_BLOCK) = Default::default();
print_type_of(&x); // [u8; 16]
We used to have a doc test for each of the crates but I removed it because it felt silly to pull in the behemoth that is nalgebra for one test.
Thank you for the work!
[x] Update documentation to reflect any user-facing changes - in this repository.
[x] Make sure that the changes are covered by unit-tests.
[x] Run
cargo clippy
on the changes.[x] Run
cargo +nightly fmt
on the changes.[x] Please put changelog entries in the description of this Pull Request if knowledge of this change could be valuable to users. No need to put the entries to the changelog directly, they will be transferred to the changelog file by maintainers right after the Pull Request merge.
Please remove any items from the template below that are not applicable.
[x] Describe in common words what is the purpose of this change, related Github Issues, and highlight important implementation aspects.
Changelog:
Changes the examples to use
glam
instead ofcgmath
.I also added support for the
glam
crate in the type_for_format! macro. However, I did not do any checking. Which means that code likewill fail, since glam doesn't have a f16 floating point type. Is that fine?
The error message does tell the user roughly what went wrong, which is better than nothing.