Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Drawing outside window  (Read 1973 times)

0 Members and 1 Guest are viewing this topic.

flashrocket

  • Newbie
  • *
  • Posts: 21
    • View Profile
Drawing outside window
« on: April 30, 2014, 08:01:48 am »
Does drawing outside the window give a performance hit?
is it worth it to check whether an object is visible then draw it?

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Drawing outside window
« Reply #1 on: April 30, 2014, 08:09:24 am »
It might, and it might be.  I believe OpenGL will attempt this same optimization somewhere in its pipeline, but it still has to go through a few stages before it knows for sure where the vertices will be so sometimes you can save it a bit of time by testing that on your end.

Of course, always test to see if there's a significant improvement before actually using optimizations like this.

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Drawing outside window
« Reply #2 on: April 30, 2014, 02:25:24 pm »
Like Ixrec said, you need to test/profile this yourself. If CPU to GPU data transfer is your bottleneck, then CPU-side culling would benefit you. If profiling suggests that a lot of time is wasted during vertex processing because most of the vertices are outside the clipping planes and discarded then CPU-side culling would also benefit you. The GPU is smart when it comes to this. It doesn't really "draw" primitives that are outside the view frustum. Vertices are discarded early to save the rest of the pipeline from rendering primitives that aren't going to contribute to the final framebuffer anyway.

As a general rule of thumb, the earlier you discard data, the more processing you can save. Just don't do this unless there is an imbalance between CPU and GPU load already. It makes little sense to do CPU culling if the CPU is already at 100% load and the GPU is idle most of the time.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

 

anything