0 votes

I have a 46x46 texture and I'm drawing irregular chunks of it 1200 times.
On a PowerVR Rogue GE8100, a budget mobile GPU I'm getting 40 FPS.

It's this performance expected from Godot?
What can I do to speed it up?

Below is a simplified example of my code.

Thanks!

export(Texture) var myTexture

var myTextureRegions = [
    Rect2(0,0,23,23), 
    Rect2(23,0,23,23),
    Rect2(0,23,20,20),
    Rect2(23,23,2,14)
]
var cellSize = 23

func _draw():
    for i in range(0, 40):
        for j in range(0, 30):
            draw_texture_rect_region(myTexture,
                Rect2(i*cellSize,j*cellSize,cellSize,cellSize),
                myTextureRegions[0],Color.white)
in Engine by (12 points)

Just as a comment because I have no clue what exactly you are trying to achieve.

But this sounds like this would be performing much better by using a shader.

Keep in mind that gdscript is an (byte code) interpreted language. 1200 iterations/function calls (single thread) per frame won't be ideal in terms of performance.

Shaders can work in parallel (depending on how many shaders the GPU has) and in the GPU. So the CPU can do other work.

I'm trying to draw something like this (see image below). I have a texture atlas containing sprites for every number from 0 to 9 and a couple of square textures representing grid cells

wikipedia mario picross

Ok, not really a shader specific task (although some poeple would do it).

If I understand correctly, then _draw() is called for every frame.

I guess that you only have to update your screen every now and then and not every frame.

So perhaps you could just show a texture (texturearea or similar) and set the image data of the texture when required for the region which is updated.

https://docs.godotengine.org/en/3.2/classes/class_image.html#class-image-method-blend-rect

Sorry to waste your time, but this engine is not for me. I'm going back to love2d, it can render this kind of things at 60 fps with no problem.

If you're happy with love2d then fine.

New engines usually take some time to figure out the optimal approach. Personally, I use Godot for 3D apps (also on mobile) so my qualification to help you with 3D topics isn't very high. :-)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.