• Advertisement
Sign in to follow this  

SamplerState within shader sn't working in D3D10

This topic is 3095 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
Setting values to state objects works only when you use the effect framework. If you only compile the shaders these information is lost.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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++.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement