O.Nyman

Hello,

I am trying to use the function SampleCmpLevelZero on a Texture2DArray. It seems this function is not implemented, even though the documentation would suggest that it is available for all texture types.

I receive the error:
error X3088: Texture2DArray object does not have method 'SampleCmpLevelZero'

Also, as the documentation is rather minimalistic, could someone point me to the correct usage of SampleCmp This is how I would imagine it to work for a single-channel texture:

Texture2D <float> myTexture;
SamplerState mySampler
{
ComparisonFunc = Less;
};
...
float2 texcoord = ...
float comparison = ...
result = myTexture.SampleCmp(mySampler, texcoord, comparison);

However, this doesn't compile:
error X3088: SampleCmp method of object Texture2D does not take these arguments



Re: Direct3D 10 SampleCmpLevelZero availability in Feb. 2007 SDK

Kapoulkine Arseny

Can't say anything about texture array, but for simple sampling with comparison, you have to use SamplerComparisonState instead of SamplerState. It seems that even now it's not in the documentation, I got this name from fxc10.exe like 6 months ago.



Re: Direct3D 10 SampleCmpLevelZero availability in Feb. 2007 SDK

O.Nyman

Thanks. It seems for a Texture2D you can use SampleCmpLevelZero like this:

Texture2D <float> myTexture;
SamplerComparisonState mySampler
{
ComparisonFunc = Less;
Filter = COMPARISON_MIN_MAG_LINEAR_MIP_POINT;
};
...
float2 texcoord = ...
float comparison = ...
result = myTexture.SampleCmpLevelZero(mySampler, texcoord, comparison);


This works for shadow mapping, and the filter state can be used to get PCF. There are a bunch of different ones in fxc.exe.

Anyway, I can only assume this is how it would work for Texture2DArray too, only that texcoord will be a float3 (where 3rd float is for texture index). But it is clearly not implemented in the current compiler.