On Fri Aug 30 21:46:53 2024 +0000, Matteo Bruni wrote:
This works, but I think it would be better if we stored the "range" (e.g. UNORM, SNORM, full range) as a property of the value itself (or, specifically, of each component) instead of having to bring around the source type as separate, additional data. So perhaps something like
struct d3dx_color { vec4 value; enum range range[4]; };
which `format_to_vec4()` generates and `format_from_vec4()` consumes. I haven't really thought it through, so this might be all kinds of ugly or impractical.
So, this one has taken me awhile to work through, because I used to have a similar system to this (although I called it `struct d3dx_pixel`). The thing I realized after getting further into implementation is that for formats with mixed ranges (i.e `D3DFMT_X8L8V8U8`, `D3DFMT_A8P8`) the ranges are only split between the alpha channels and the color channels. It's easier to categorize this way IMO. I've added a structure for this in the most recent revision, but kept it as a single range value. Once we add support for formats with split ranges, I'll add a separate range value to the structure for the alpha channel.