Closed Alphapage closed 9 months ago
See also https://github.com/rust-windowing/softbuffer/issues/98.
The u32
is actually roughly something like the following (probably depends on endianness):
#[repr(C)]
#[align(4)]
struct Color {
reserved: u8,
red: u8,
green: u8,
blue: u8,
}
So it doesn't actually have anything to do with the f32
s that GPUs use.
I thought it would be better to be able to have a vec4 of f32 buffer instead of having to convert vec4 f32 color to u32 at each pixel. But it is strange that the api doesn't give a vec4 of f32 for color because gpu handles colors with a vec4 instead of the old RGBA of u8. The buffer will increase a lot, so maybe it is more a performance problem and you prefer sacrify color precision in favour of speed.
Most windowing systems use 8-bit per channel color when doing software rendering, which is why this crate exposes that. It would be a significant performance hit to use anything else.
Hello,
Why softbuffer provides u32 for the pixel color ? Wouldn't it be better to provide f32 color to be aligned to gpu ?
Thank you in advance for your answers.