Search code examples
androidopengl-esdirectx-9monogame

Huge FPS drop when pixel shader is used on android


In my app, there is no frustum culling, objects not seen by camera are drawn anyway. When the camera is not looking at the objects, my fps is near 60 on my android device. When it looks at the objects, my fps drops to about 15.

Therefore I think this is an issue with my pixel shader. Because I use monogame, the shader is actually written with directx shader model 3.0. Below is my texture sampler declaration and my pixel shader. (this is the only pixel shader used)

texture2D tex1;

sampler2D tex1Sampler = sampler_state
{
    Texture = <tex1>;
    MinFilter = Point;   
    MagFilter = Point;   
    MipFilter = Point;   

    AddressU = Clamp;  
    AddressV = Clamp;
};

float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
{
    float4 color =  tex2D(tex1Sampler,input.Texture);
    clip(color.a - .12f);
    color *= input.Tint;
    return color;
}

What could be causing this FPS drop? Some other info: the texture used is size 250 x 250, and it's the only texture used in my tests.

it's not something absurd either, like a billion triangles all lined up behind each other and no back face culling enabled. It's only like 1000 small triangles in the scene, which should not be unreasonable.


Solution

  • removed Clip() from pixel shader and got 30 fps increase.

    Now I can't really do alpha blending without sorting everything.....