3

I'm implementing blur effect on windows phone using native C++ with DirectX, but it looks like even the simplest blur with small kernel causes visible FPS drop.

float4 main(PixelShaderInput input) : SV_TARGET
{ 
    float4 source = screen.Sample(LinearSampler, input.texcoord);
    float4 sum = float4(0,0,0,0);
    float2 sizeFactor = float2(0.00117, 0.00208);

    for (int x = -2; x <= 2; x ++)
    {
        float2 offset = float2(x, 0) *sizeFactor;
        sum += screen.Sample(LinearSampler, input.texcoord + offset);
    }
    return ((sum / 5) + source);
}

I'm currently using this pixel shader for 1D blur and it's visibily slower than without blur. Is it really so that WP8 phone hardware is that slow or am I making some mistake? If so, could you point me where to look for error?

Thank you.

Petr Abdulin
  • 33,883
  • 9
  • 62
  • 96
user1760770
  • 365
  • 5
  • 17

1 Answers1

1

Phones often don't have the best fill-rate, and blur is one of the worst things you can do if you're fill-rate bound. Using some numbers from gfxbench.com's Fill test, a typical phone fill rate is around 600MTex/s. With some rough math:

(600M texels/s) / (1280*720 texels/op) / (60 frames/s) ~= 11 ops/frame

So in your loop, if your surface is the entire screen, and you're doing 5 reads and 1 write, that's 6 of your 11 ops used, just for the blur. So I would say a framerate drop is expected. One way around this is to dynamically lower your resolution, and do a single linear upscale - you'll get a different kind of natural blur from the linear interpolation, which might be passable depending on the visual effect you're going for.

MooseBoys
  • 6,641
  • 1
  • 19
  • 43