Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have an almost unmodified copy of the bloom sample in my project. I pass it a texture to apply the bloom post process on.

The only modification is that, instead of calling BeginDraw() (to set a render target) in the bloom sample and then doing all of my drawing, I simply do all of my drawing to a rendertarget outside of the bloom sample, and then pass that rendertarget to the bloom sample's Draw() method, which the bloom sample can then use to perform the bloom postprocess.

The texture that I pass to the bloom sample Draw() has format Color, according to the debugger (and by code inspection).

However, on the first draw call in the bloom sample, I get the following error:

The framework produces the error "XNA Framework HiDef profile requires TextureFilter to be Point when using texture format Single."

The code that produces this is as follows:

1   public void Draw(RenderTarget2D sceneRenderTarget) 
2   { 
3       GraphicsDevice gd = Game3.GDM.GraphicsDevice; 
4    
5       gd.SamplerStates[1] = SamplerState.LinearClamp; 
6    
7       //gd.SamplerStates[1] = SamplerState.PointClamp; 
8    
9       // Pass 1: draw the scene into rendertarget 1, using a 
10      // shader that extracts only the brightest parts of the image. 
11      _bloomExtractEffect.Parameters["BloomThreshold"].SetValue( 
12      Settings.BloomThreshold); 
13   
14      DrawFullscreenQuad(sceneRenderTarget, _renderTarget1, 
15                 _bloomExtractEffect, 
16                 IntermediateBuffer.PreBloom); 

If I uncomment line 7 above, then the code runs without error (as point sampling will be enabled), but this should be unnecessary (and is not desired) as all rendertargets involved here are SurfaceFormat.Color -- which is not a floating point format!

Does anyone have any idea what might be going on? Perhaps someone has seen this before, and can give me a clue where to look next.

I have some experience with PIX, but I don't know how to use PIX to debug when the program crashes (basically I only know how to take single frame captures in PIX).

share|improve this question
    
Turn the point filter on and do a single frame capture with PIX. That should let you examine the types of all the textures and render targets to make sure they are of the type you think they are. –  Adam May 25 '11 at 23:22
    
Adam: Read the last sentence of my question. Anyways, the render targets all were the types that I thought, that wasn't the problem. See my answer below. –  Olhovsky May 26 '11 at 11:16

2 Answers 2

up vote 5 down vote accepted

The problem is that although spritebatch only uses texture sampler 0, XNA still complains if texture sampler 1 is set to a floating point format texture.

So when spritebatch was called, to draw using sampler0 as input, XNA produced an error complaining about sampler1 using linear sampling (even though spritebatch wouldn't have used sampler1).

The solution is to make sure that all texture samplers that are bound to floating point textures are set to linear sampling before calling spritebatch.

I.e.:

graphicsDevice.SamplerStates[1] = SamplerState.LinearClamp;

To me this is pretty silly as it causes unecessary sampler state changes and complexity. Hopefully this is being changed in the next version of XNA.

share|improve this answer

Something else to keep in mind is there is a bug in XNA4 which will cause this error to come up during device resets. I know your problem is slightly different and already resolved, but perhaps people will discover this page looking for possible solutions related to the same error message caused by slightly different reasons.

http://forums.create.msdn.com/forums/p/63992/392134.aspx#392134

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.