2011/8/11 Michael Mc Donnell <mich...@mcdonnell.dk>:
>
> +            dst_ptr[0] = src->x < 0.0f ? (SHORT)ceilf(src->x * SHRT_MAX + 
> 0.5f) :(SHORT)floorf(src->x * SHRT_MAX + 0.5f);

You can use roundf() instead. Actually, notice that maybe what you
actually need for correct rounding is rintf() (which essentially
matches what D3DXFloat32To16Array does). You should probably test this
(even on your own, not necessarily adding those to the testsuite, I'd
say).

Still on the conversion: going on with this "strategy" is going to
require a ton of code to handle every src->dst format combination. You
may look into doing that in two steps: first converting src to float4,
then float4 into dst. I haven't looked into it, so there may be some
detail making this impractical, but still it's worth a try, I guess.


Reply via email to