This project has moved and is read-only. For the latest updates, please go here.

puzzled about LinearClamp of SpriteBatch

Mar 15, 2013 at 9:27 AM
Edited Mar 16, 2013 at 6:29 AM
My Code :
SpriteBatch.Begin(); // sampleState->LinearClamp by default

On Emulator It works as LinearClamp,but on device(Lumia920 or Htc a620e),it works as PointClamp,the texture is smeared when it's big.

Does "Device" support linearclamp?
Mar 15, 2013 at 3:59 PM
Sampler states work the same on Phone as on desktop Windows.

What exactly do you mean by "smeared"? Could you share a screenshot? (point sampling when something is scaled up would result in pixellation)

What format / size / mipcount etc. is your texture? Is the above all the drawing code needed to repro (could you share a simplified repro?) or are there other D3D calls mixed with this SpriteBatch usage?
Mar 16, 2013 at 6:28 AM
Edited Mar 16, 2013 at 8:44 AM
Sorry for my unclear description.

Now I try it again in a simple project "PhoneXamlDirect3DApp1" and show my screenshot:

1 Create a 2×1 Texture (Black And White)
2 Draw it in a Rectangle by SpriteBatch
3 Different performance on "EmulatorWXGA" and "Lumia920"

On Emulator The Color is gradual because LinearClamp works(left picture)
On Lumia920 The color is not gradual because LinearClamp did not work I think(right picture):
why the same code has different performance on device and emulator, seems LinearClamp doesn't works on device(Lumia920).

Here is my code:

// Create Texture


D3D11_SUBRESOURCE_DATA colorData = {0};

XMFLOAT4 a[] ={XMFLOAT4(0,0,0,1),XMFLOAT4(1,1,1,1)}; // Black And White

colorData.pSysMem =&a;
colorData.SysMemPitch = 2 * sizeof(XRTVector4);
colorData.SysMemSlicePitch = 0;
Microsoft::WRL::ComPtr<ID3D11Texture2D> texture;
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> view;

// Draw In a Rectangle

SpriteBatch* sb=new SpriteBatch(m_d3dContext.Get());
Mar 17, 2013 at 5:22 AM
The problem is your use of 32 bit floating point texture format. Windows Phone is feature level 9.3 hardware, which does not support filtering of this format.

Either use a different texture format, or change your design to not require filtering, or implement filtering yourself in the pixel shader (occasionally useful, but often too slow to be practical).
Mar 17, 2013 at 6:26 AM
Mar 18, 2013 at 3:31 AM
ok thank you I'll try it again.
Mar 18, 2013 at 3:32 AM
Edited Mar 18, 2013 at 7:24 AM
thanks for the links~

I found it in the blog:
Feature Level 9.3 devices can optionally support texture filtering for R16G16B16A16_FLOAT formats, but cannot do so for other _FLOAT formats that are only supported for point sampling in the Feature Level 9.3 definition. You have to use Feature Level 10.0 or later to get full-featured floating-point resource support.