Blur on Windows Phone 8 is too slow

I am implementing a blur effect on a Windows phone using native C ++ with DirectX, but it looks like even the simplest blur with a small kernel causes a noticeable drop in FPS.

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 am currently using this pixel shader for 1D blur and it is noticeably slower than no blur. Is it really that the WP8 hardware is slow or am I wrong? If so, could you please point me to where to look for the error?

Thank.

+3


source to share


1 answer


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

(600 m texels / s) / (1280 * 720 texels / op) / (60 frames / s) ~ = 11 op / frames



So in your loop if your surface is the whole screen and you do 5 reads and 1 write that 6 of your 11 options are used, just for blur. So I would say that a drop in frame rate is expected. One way is to dynamically lower the resolution and do one linear scaling - you will get different natural blur from linear interpolation, which can be passable depending on the visual effect you intend to use.

+1


source







All Articles