Declaring comparison samplers

Started by
1 comment, last by eppo 13 years, 7 months ago
How do I declare a sampler (ps_4_0, outside of the effects framework) to pass as the first argument to SampleCmpLevelZero()?

If I use a sampler I normally use to sample a texture object, the compiler gives me:
error X3017: 'SampleCmpLevelZero': cannot implicitly convert from 'const SamplerState' to 'const SamplerComparisonState'.

The SDK documentation only has pages on how they are either declared in an effect or in assembly: dcl_sampler sN, comparison.

Thanks
Advertisement
In your app code, you create an ID3D10SamplerState with a D3D10_SAMPLER_DESC containing your sampling and comparison states. Then when you want to use it, you bind it to a slot for a shader stage using ID3D10Device::PSSetSamplers (or the equivalent for the stage you want). Then in your HLSL, you declare a SamplerComparisonState bound to the slot you specified for your sampler state. So if you bound it to 0, you would do this:
SamplerComparisonState ShadowSampler : register(s0);

Then you can pass that state to SampleCmp.
I was trying to SampleCmp() from a Texture2DArray, which is not supported for ps_4_0.

The SDK mentions both the keywords "sampler" and "SamplerState" and when passing a SamplerComparisonState object didn't work for me, I falsely assumed the capitalized versions had to be only valid inside the scope of the effect system.

This topic is closed to new replies.

Advertisement