Texture Sampler in Compute Shader


I’m trying to use Texture Sampler in Compute Shader,

but the error code “E_NOTIMPL” is returned from D3DX11CompileFromFile().

OS: Windows 7 64 bit Ultimate

CPU: Xeon W3530

CUDA version: 3.2


DirectX version: 11

The following is my HLSL code.

ByteAddressBuffer src0 : register(t0);

ByteAddressBuffer src1 : register(t1);

RWByteAddressBuffer dst : register(u0);

Texture2D<float> InputTexture : register(t2);

SamplerState LinearSampler


    Filter   = MIN_MAG_MIP_LINEAR;

    AddressU = Clamp;

    AddressV = Clamp;


[numthreads(1, 1, 1)]

void CSMain(uint3 DTid : SV_DispatchThreadID)


	float p=0.0;

	float2 coord;

	coord.x = (float)DTid.x;

	coord.y = (float)DTid.y;

	p += asfloat(InputTexture.Sample(LinearSampler, coord));

	dst.Store(DTid.x*4, asuint(p) );


What is causing this error?

Code, hlsl compiler version, GPU version?

Or, we cannot use texture sampler in ComputeShader?

Please help me.

Thanks in advance!

Instead of Sample(), I tried to use SampleLevel().
Then my code works well !

In ComputeShader, Sample() seems to be not supported.

Yes, this is because texture LOD is not defined in the Compute shader (there’s no fixed mapping between threads and pixels), so you need to specify the LOD.