Drawing Thousands of Textures
When running a performance test on drawing textures using draw_scaled_texture_rectangle, I found it laggy and slow. Is there an efficient way to draw thousands of images? I could try using pyglet's images and draw them in a batch, but I don't know if arcade supports batch drawing images. Could this be implemented, so that performance is much better than drawing textures individually?
I'm not sure if I understand your use case, but wouldn't sprites cover this?
Using Sprites in a SpriteList you should be able to draw millions of sprites(though you probably have a long startup time for that) but the actual drawing should be fine.
That draw command doesn't do any sort of batch drawing. It will be very slow. Really, we should update the docs to reflect that.
Don't sprites take up a bunch of memory? It would take forever to start up. Hopefully, this could be optimized in the future.
It takes memory to store the image. But if you load multiple of the same image, it reuses the image data.
@eschan145 I think we need to know more about the use case to give useful advice:
- How many images do you need to draw?
- How big are the original sizes?
- How many of the images are unique, and how many are repeated?
Can you tell us more about what you're trying to build?
I had roughly four thousand textures the size of 1x7 pixels. The scale was 1.0. The fps was about three or four. All of the images were repeated. Along with them, there were about four hundred sprites, although those wouldn't have made any difference.
Do it up as sprites. Are you loading the images from a file, or from a dynamic image?
I had roughly four thousand textures the size of 1x7 pixels. The scale was 1.0. The fps was about three or four.
Are these the arrows you mentioned in #1264?
Sprites were created exactly for what you are describing here. docs also describe texture caching and reuse: https://api.arcade.academy/en/latest/advanced/textures.html
Like already mentioned, you can probably do a million of them just fine.
In arcade 2.7 (development branch) you can also mix aracde and pyglet rendering freely if you are more comfortable with the pyglet way of doing things, but sprites in arcade are kind of the same.
In gpu based libraries you can't get away with that many draw calls. I'd say 400-500 is the practical limit with python before things really start to lag.
There's also an option to use custom shaders to speed things up even more, but that depends on the exact details.
Could Cython be used to speed things up in drawing?
Could Cython be used to speed things up in drawing?
SpriteList will batch draw all your images, so you shouldn't really need cython. It's incredibly fastl. Like adding sprites to a batch in pyglet. There might of course be some details about your implementation we haven't taken into account. For example if you are moving thigs around a lot.
It could be useful to add more information about what you are trying to achieve here. Also we do have a discord server were discusstions like this are much more productuve.
Closing, as this seems to have more to do with poor performance in drawing shapes.