Sign in to follow this  
M_Johnson

"XNA Framework HiDef profile requires TextureFilter to be Point when using texture format Single."

Recommended Posts

M_Johnson    129
I'm having issues with this message in XNA 4. If I set the TextureFilter to point it fixes it for a few calls to the same object (I'm doing multi-pass lighting), but the EffectPass::Apply() function seems eventually to modify the sampler states so that sampler state 0 becomes null. I can get around that by setting the sampler state after the call to EffectPass:.Apply() however I then receieve the error on ModelMesh::Draw() (a different object that's represented by a loaded model instead of drawing the mesh manually) since the same thing seems to be happening but obviously hidden in the Draw call.

[code]
public void DrawGeometry(Effect effectToUse)
{
GraphicsDevice.SamplerStates[0] = SamplerState.PointClamp;
GraphicsDevice.BlendState = BlendState.Opaque;
GraphicsDevice.DepthStencilState = DepthStencilState.Default;
GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;

GraphicsDevice.SetVertexBuffer(vertexBuffer);
GraphicsDevice.Indices = indexBuffer;

foreach (EffectPass pass in effectToUse.CurrentTechnique.Passes)
{
pass.Apply();

GraphicsDevice.DrawIndexedPrimitives(Microsoft.Xna.Framework.Graphics.PrimitiveType.TriangleList,
0,
0,
numVertices, 0, (numVerticesWidth - 1) * (numVerticesHigh - 1) * 2);
}
}
[/code]

So in one frame I call this function multiple times, once for each light in my scene, like I say, the first few calls work ok but eventually after pass.Apply() and before GraphicsDevice.DrawIndexedPrimitives the sampler states all get messed up. I thought it would be something in my shader but the fact that the first few calls work makes me doubt that's the cause. Is this a bug in XNA 4 or am I missing something?

Share this post


Link to post
Share on other sites
IntegralKing    105
I believe that there is a bug in the current XNA build where in some cases sampler states don't change properly. You can work around this for now by setting a different state before setting the state that you want, to force the change. I wouldn't bet that this is your problem, but it's worth checking.

I have also run into the error you mention when I had sampler state 1 set to LINEAR even though I was only using sampler 0 in my shader.

XNA will complain if *any* sampler states are set to linear if that sampler also still has a texture set on it that has a floating point format, even if you aren't going to use that sampler in your shader. Remember that this applies to spritebatch as well.

I notice that you only modify sampler state 0 in that code. Are you sure that no other sampler states are set (check in PIX).

Note that with this type of error, if the debugger is giving you an error at a particular line, it doesn't necessarily mean that the error is occuring at that line.

Are you completely single threaded?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this