Order of Tex2D in shader


Texture2D FirstTexture;
SamplerState FirstSampler
    Texture = <FirstTexture>;
	MinFilter = Linear;
	MagFilter = Linear;
	MipFilter = Linear;
	AddressU = Wrap;
	AddressV = Wrap;

actually works with ps_4_0 and ps_4_0_level_9_1. Look at my code in the repo linked in an older post…
(at least with DX)

When i downgrade to ps_4_0_level_9_1 or ps_4_0_level_9_3, and build the shader, I get:

texlod not supported on this target

(HIDef profile) so i always use SM5 when declaring to avoid this :confused:

What the…???
Check out the repo and hit F5.
It has to be something else you use in the shader…

don’t use texlod,

use SampleLevel

(same as don’t use tex, use Sample)

Oh. Tex2dlod. Shame on me. :blush:

The thing is I use SampleLevel not tex2D nor texlod.

I’ve just made some tests:
ps_4_0 -> No error
ps_4_0_level_9_1 -> texlod not supported on this target
ps_4_0_level_9_3 -> texlod not supported on this target
ps_5_0 -> No error

At least I can use ps_4_0 :slight_smile: (as i was using ps_4_0_level_9_1 before, I went only up in the shadermodels, what can the most can the least, seems false now)

The declaration is the same as above:

Texture2D brightpass;
SamplerState downsampler
    Texture = <brightpass>;
    MinFilter = LINEAR;
    MagFilter = LINEAR;
    MipFilter = LINEAR;
    AddressU = CLAMP;
    AddressV = CLAMP;

and in the code (this is the ONLY texture sampling use in the whole code):

result += brightpass.SampleLevel(downsampler, input.tex + texOffset, 0).rgba;

So… would it be MojoShader that translates SampleLevel to texlod with ps_4_0_level_9_1 and ps_4_0_level_9_3 internally ?

4_0 is much, much higher level than 4_0_level_9_1 (… and 9_3 etc.), not sure if that came across in case someone is reading this.

The 4_0_level_9_1 level is basically 2002 or so, 4_0 is proper directx 9.0.

Might be confusing to newbies.

Hum. I’ve always thought level_x was adding more features to 4_0. I admit I’ve never read all the details in directx doc.
Never noticed until you wrote it, the “9” :slight_smile: Now it makes sense.

Nonetheless, this doesn’t explain why the error is talking about texlod() instead of samplelevel() :confused:

Is there any documentation about this somewhere with a bit of background information?

You can start here:

Further links are at the bottom.

1 Like