z-clear performance

Discussion in 'Rendering Technology and APIs' started by silenius, Apr 16, 2004.

  1. silenius

    Newcomer

    Joined:
    Apr 16, 2004
    Messages:
    21
    Likes Received:
    0
    Hi

    i know it clearing a z buffer is expensive, but I still have a strange behaviour. I use shadow map so i need to use a z buffer for the shadow.

    my shadow map is quite big (2048*2048), i know me crazy. I should off course clear this buffer each frame, but if i do so the performance drop (from 200 fps to 70 fps). So i simulate a fast clear with a pixel shader. In fact this allow me a lot of other optimisations wich make the shadow map generation very fast (like 5% of the total rendering time), so I am pretty happy with it.

    anyway i wonder if its normal for the z clear to be so slow. (because some time i need to clear the buffer, and when i do we can feel a little break in the animation).

    is there an optimum time to make the zclear (curently it's made in the middle of the render). I tried to make it at the begining of the render, but as I need to change the rendertarget to clear the z that wasn't efficient.

    is there a way to clear the z even if it's not the active zbuffer?

    thanks
     
  2. Simon F

    Simon F Tea maker
    Moderator Veteran

    Joined:
    Feb 8, 2002
    Messages:
    4,560
    Likes Received:
    157
    Location:
    In the Island of Sodor, where the steam trains lie
    Not necessarily. It can be extremely fast - certainly on PowerVR cards and I think I've also seen recommendations by the other IHVs for developers to use clears rather than the old hack of splitting Z space into 2 halves and only clearing every second frame.
    Could you elaborate?
     
  3. ector

    Newcomer

    Joined:
    Nov 3, 2002
    Messages:
    111
    Likes Received:
    2
    Location:
    Sweden
    Clearing only Z without clearing Stencil at the same time is very slow. This is likely the cause of your problem.
     
  4. silenius

    Newcomer

    Joined:
    Apr 16, 2004
    Messages:
    21
    Likes Received:
    0
    the principle is very easy i use a frame counter.

    at the begining of the frame i increase the frame counter by one.

    once in the pixel shader as the texture contain the depth value I can do a ztest on the texture.

    if (current pixel frame counter > stored framecounter)
    keep new pixel
    else
    keep new pixel if ztest succed


    so i don't need to clear the z buffer (i wonder if it's this way they do fast clear but it seems very easy and fast for me (you need to really clear the zbuffer from time to time (when you reach the max of the framecounter))

    in fact there is a way to make it without any clear, but you need to be sure all screen is redraw at least once every max_framecount time.
     
  5. silenius

    Newcomer

    Joined:
    Apr 16, 2004
    Messages:
    21
    Likes Received:
    0
    me don't use stencil, should I use clear_stencil too? even if I don't have stencil buffer?
     
  6. ector

    Newcomer

    Joined:
    Nov 3, 2002
    Messages:
    111
    Likes Received:
    2
    Location:
    Sweden
    If you are SURE that you don't have a stencil buffer, then my suggestion is wrong :)
    But try passing D3DCLEAR_STENCIL (from memory, could be wrong) and see if it makes any speed difference.
     
  7. silenius

    Newcomer

    Joined:
    Apr 16, 2004
    Messages:
    21
    Likes Received:
    0
    tested = result: crappy rendering and no speed increase
     
Loading...

Share This Page

  • About Us

    Beyond3D has been around for over a decade and prides itself on being the best place on the web for in-depth, technically-driven discussion and analysis of 3D graphics hardware. If you love pixels and transistors, you've come to the right place!

    Beyond3D is proudly published by GPU Tools Ltd.
Loading...