On Thu, Jul 28, 2011 at 4:01 PM, Stefan Dösinger stefandoesinger@gmx.at wrote:
Am 26.07.2011 um 11:29 schrieb Michael Mc Donnell:
Wrt the D3DDECLTYPE epsilon, it may be more efficient to scale the epsilon and calculate the diff and comparison as UBYTEs rather than floats. You'll need the diff functions for the other types like *BYTE*, *SHORT* anyway. Also tests would be helpful here, especially how the epsilon is treated in normalized values like D3DCOLOR and UBYTE4N and how it is treated in non-normalized values like UBYTE4.
Ok I'll look into that and get back to you later.
I've implemented D3DCOLOR welding as UBYTE4N welding as you described. Test 14 improves the color comparison to check that it is correct.
Wrt the usage/index fields, what happens when a combination that isn't supported by the fixed function pipeline is used, e.g. NORMAL3 or POSITION5? Those are valid in a vertex declaration and can be used with shaders.
It works because the code does not check the UsageIndex field, except for differentiating between DIFFUSE and SPECULAR. I've added test 13 that shows this (tested on Windows 7 and Linux).
You may still get into trouble with something like TEXCOORD10
I'd recommend to change test 13(or add a new one) that tests a TEXCOORD > 7 and COLOR > 1
Good catch. I've added test 25 that shows TEXCOORD is capped at 7 so it uses the epsilon for TEXCOORD7 when it welds TEXCOORD10. I've also updated the implementation to cap it at 7.
I've also added tests 25 and 27 for color usage index larger than 1. The usage index is not capped like TEXCOORD > 7. It instead uses the default value of 1e-6f. I've changed the implementation so it uses the default value instead of printing out an error message.
Test 15 to 23 tests welding of UBYTE4N, UBYTE4, SHORT2, SHORT2N, SHORT4, SHORT4N, FLOAT16_2, and FLOAT16_4. I've also improved the implementation to weld these types.
I still haven't figured out how to weld UDEC3 and DEC3N as I'm unsure how to convert three integers to the 3*10-bit + 2-bit format. Do you know any good sources?