In particular, is it the fixup for DIFFUSE, SPECULAR or either that causes the problem? What are the values for reg, arrayUsageMap[WINED3DSHADERDECLUSAGE_DIFFUSE] and arrayUsageMap[WINED3DSHADERDECLUSAGE_SPECULAR]?
It looks like texture coordinates are wrong, but those shouldn't be affected by this patch, do you initialise arrayUsageMap correctly?
I have walked through the code. This small demo (dolphinvs from dx8.1 sdk) uses the following vertex declaration for the seafloor: D3DVSD_STREAM( 0 ), D3DVSD_REG( 0, D3DVSDT_FLOAT3 ), // Position of first mesh D3DVSD_REG( 3, D3DVSDT_FLOAT3 ), // Normal D3DVSD_REG( 6, D3DVSDT_FLOAT2 ), // Tex coords D3DVSD_END()
It stores texture coordinates in register 6 (D3DVSD_SPECULAR). Registers should be general purpose I think and this should work fine. Your patch assumes that 'D3DVSD_SPECULAR' is allways used for colors which should be swizzled. Because we are storing texture coordinates in them they shouldn't be swizzled but we don't know what is stored in them. I'm not sure how to fix this bug but I think the code should be moved to a later stage. Swizzling won't be done in the shader then :(
Roderick