Reputation: 31
I'm working with LibGDX, and I need answers to some general optimization questions:
Upvotes: 1
Views: 280
Reputation: 10320
Upvotes: 2
Reputation: 54642
No. Vertex processing will be the same, but the fragments outside the viewport will be clipped, reducing fragment processing.
This is just an extreme case of question 1. Now there's no fragment processing, but still all the vertex processing. Depending on how cheap/expensive your vertex processing is, this can be very variable. It's certainly more than not drawing at all. On the other hand, if you add a lot of logic in your app to avoid drawing a sprite, you may be adding more overhead than you save by not rendering it.
Once the texture is loaded, the rendering itself should be fairly similar. But of course loading the texture is going to be much more expensive. This is not only for the OpenGL call you make to load the texture data, but also the overhead to map it into the GPU address space before rendering, and other related memory management overhead.
Maybe. But probably not much. GPUs use memory layouts that are optimized for local access, without much dependence on the orientation of the access pattern.
Rendering at 10x10 is certainly much cheaper because there are a lot fewer fragments, and corresponding sampling operations. But it can still be much more expensive than rendering with a 10x10 texture, because access is much less localized, so there will be a lot more cache misses. To avoid that, use mipmapping, which will give you most of the performance of a smaller texture if you render a large texture scaled down.
Upvotes: 1
Reputation: 93759
When talking about performance, the impact depends on what your bottle neck is. Drawing a sprite uses some CPU and a tiny bit of GPU regardless of how much, if any, of it is on screen. In general, the more pixels of a sprite are actually on screen, the more GPU it will use.
In terms of CPU, no difference, but for the GPU, drawing fewer pixels of the sprite is better.
Off screen sprites have a CPU impact and small GPU impact. If you have a lot of off screen sprites, you may need to avoid drawing them, but you should check them in groups instead of one-by-one, or you risk spending more CPU to check them than it would take to draw them off screen.
Drawing a small region of a big texture has same performance hit as drawing a small texture. But the first option allows you to batch a lot of different images into one draw call, which is a big saver.
Some, because you'll recalculating its vertices on each frame.
Drawing it smaller means you're drawing fewer pixels, so that's faster.
Upvotes: 0