Wednesday, August 9, 2006

[GPU/Cg] tips of the day

For those using Cg and D3D, there is a trap in the API.
Using the following Cg(Fx) code:
uniform sampler2D Tex = sampler_state {MinFilter = Linear;MipFilter = Linear;MagFilter = Linear;};

The Tex parameter must be set with cgD3D9SetTextureParameter and not with cgD3D9SetTexture, even though according to the current documentation cgD3D9SetTexture is the one to be used for samplers. When using it, Cg returns an error ...
Quick edit: cgD3D9SetupSampler can also be used. It does both cgD3D9SetTextureParameter and cgSetSamplerState.