[PATCH 3/5] d3dx9_36: Implemented ID3DXConstantTable_SetVector and ID3DXConstantTable_SetVectorArray

Matteo Bruni matteo.mystral at gmail.com
Tue Feb 8 06:27:20 CST 2011

> +            if (is_vertex_shader(This->desc.Version))
> +                IDirect3DDevice9_SetVertexShaderConstantF(device, desc.RegisterIndex + i, (float *)fvector,
> +                        desc.RegisterCount);

You should probably just use 1 instead of desc.RegisterCount in
SetVertexShaderConstantF, as you are already in a loop for each
Also, why are you casting a (float *) to a (float *)? Especially after
creating a float array just for that.

However, making you use a temporary array to convert struct
D3DXVECTOR4 to (float *) was somewhat my bad suggestion I believe. My
concern was that the structure maybe didn't have its fields packed
(with some padding between the fields of the structure for alignment
reasons) and just casting the struct pointer to (float *) would not
give correct results. Looking at the definition of D3DXVECTOR4 (and
assuming it is correct), it appears to not be the case, so you can
simply cast it to (float *). Then you can remove the for loop
altogether and just set min(count, desc.RegisterCount) registers in
the Set{Vertex/Pixel}ShaderConstantF call.
Sorry for not being clear enough / giving wrong directions.

Please add a "(try n)" suffix to the email subject when you're sending
new versions of a patch.

More information about the wine-devel mailing list