SamplerState within shader sn't working in D3D10

Started by
4 comments, last by darkelf2k5 14 years, 8 months ago
If I specify this in my shader (I am not using the effects system): Texture2D fullscreenTex; SamplerState fullscreenS { AddressU = CLAMP; AddressV = CLAMP; AddressW = CLAMP; Filter = MIN_MAG_MIP_POINT; }; And then later sample via: outColor = fullscreenTex.Sample(fullscreenS, inTexture); The runtime complains that I don't have a sampler bound to slot 0. I don't want to bind a sampler: since the state is declared in the shader it should use that shouldn't it? Can someone shed some light on this problem? If I do have to bind a sampler than: A) what's the point of specifying the state in the shader. And B) I can't seem to get the initial state via reflection. Thanks, Jeremy
Advertisement
Setting values to state objects works only when you use the effect framework. If you only compile the shaders these information is lost.
Quote:Original post by Demirug
Setting values to state objects works only when you use the effect framework. If you only compile the shaders these information is lost.


Then can I get the sampler state using shader reflection and create the sampler based on that?
Even if you compile it to an effect the data are stored in the compiled effect but there is no method to read it from the compiled effect.

If you don’t want to use the effect framework you need to write your own parser or a custom format.
Using Effects is the only way to do state assignment in shader code. Using HLSL directly means that you have to manage the state objects yourself. So, in this instance the code you wrote in the shader is doing nothing other then indicating that a sampler needs to be bound for the shader to work.

A) The assignment is maintained in reflection, but ignored from a code standpoint.
B) Samplers are resources and have bindings. There is currently no way to get the state info for the default assignment from it. The default value would only be available for variables.

EDIT: Turns out that there is a bug and that the DefaultValue in the D3DXX_SHADER_VARIABLE_DESC currently never gets filled in.

[Edited by - DieterVW on July 29, 2009 12:44:14 PM]
You can compile an effect and use the result to get the samplers, and other non-shader states, values etc. It works even without a shader. I could pass a string containing only a raster state description to the effect compile function and then could get a valid version of it in C++.
Every time you implement a singleton, God kills a kitten. Please, think of the kittens!

This topic is closed to new replies.

Advertisement