Page 2 of 2
Re: Converting SDL2 Tutorials from Parallel Realities
Posted: Wed Apr 19, 2023 4:59 am
by SamuraiCrow
What graphics drivers are you using? What graphics card also? I suspect something is using software rendering somewhere.
Re: Converting SDL2 Tutorials from Parallel Realities
Posted: Wed Apr 19, 2023 8:26 am
by dwayne_jarvis
Radeon Polaris 10 (RX580 I think), using RadeonRX.chip Version 2.11
Re: Converting SDL2 Tutorials from Parallel Realities
Posted: Sat Apr 22, 2023 7:23 pm
by airsoftsoftwair
The natural thing to try would be to disable things one by one in the engine and see where the throttle is. If a lot of code is involved for drawing a single frame, it would also make sense to disable the linehook while drawing each frame, e.g. something like this:
Code: Select all
DisableLineHook()
p_DrawNextFrame()
EnableLineHook()
I'd also suspect that something falls back to software rendering, though, because it is so very slow. I'd try to find out the bottleneck by disabling things in the engine one by one...
Re: Converting SDL2 Tutorials from Parallel Realities
Posted: Sun Apr 23, 2023 3:21 am
by dwayne_jarvis
I already do this in the main loop.
Code: Select all
While Not (app.quit)
Debug.Print ("--> MAIN:GAMELOOP")
DisableLineHook ()
Local past = GetTimer (app.timer)
Scene.Prepare ()
App.EventCheck ()
Logic ()
App.Delegate.Draw ()
EnableLineHook ()
Scene.Present ()
app.deltaTime = #LOGIC_RATE * (GetTimer (app.timer) - past)
App.Update ()
Debug.Print ("<-- MAIN:GAMELOOP")
Wend
App.Update is not doing much except dealing with the timer so I didn't DisableLineHook before this. Main game calculations are happening within Logic () which has DisableLineHook before it is processed.
I might turn off the font routines to see if it is because I am not using font textures that are to the power of two. I read somewhere this is an issue for OpenGL on some platforms, so perhaps SDL is using OpenGL to render?
Regards.
Re: Converting SDL2 Tutorials from Parallel Realities
Posted: Sun Apr 23, 2023 7:10 pm
by jalih
Debug prints inside the main game loop are also real performance killers.
Re: Converting SDL2 Tutorials from Parallel Realities
Posted: Mon Apr 24, 2023 5:56 am
by dwayne_jarvis
Those don't actually print unless I turn debugging on becuase it is not using the Hollywood DebugPrint command, but my own routines. I will remove all references so it doesn't even run my Debug.Print command and see. Again these are rewritten Debug commands that only output when I have Debug.On () beforehand or Debug.SetTarget ({"MAIN"}) where the Debug.Print command will print lines that have keywords in it.
The keyword helps me track specific function or files as I use Debug.Print ("--> FILENAME:Function Filename.FunctionName (a, b)",a ,b)
So if I turn on debug I get every function call and return printed to the console and when I specify SetTarget I can show all function results from a File by specifying either FILENAME or just the FunctionName (The keywords aren't actually FILENAME or FunctionName, but the actual modules FILENAME and the Functions function name).
For instance I am debugging aStar Path Finding at the moment, so my keyword for Debugging is ASTARPATHFIND so I can debug output from this module only. At the start of my code I uses Debug.SetTarget ({"ASTARPATHFIND"}). This is in a table so I can debug multiple modules or functions by adding more keywords to the SetTarget Table.
Sorry for the lengthy exposition, but without seeing the source code you wouldn't have known this. I do appreciate your assistance and will probably comment out the all of the Debug.Print lines in the source code as it should give a small speed increase.
Thanks Dwayne
Re: Converting SDL2 Tutorials from Parallel Realities
Posted: Mon Apr 24, 2023 6:37 pm
by jalih
Have you tested performance on a Raspberry Pi 4? Does Hollywood support kms/drm driver with Linux versions, so programs can run hardware accelerated without X11?
How is your collision detection done? I use a collision map and a few collision points to test tilemap collisions. With enemies and game objects I cheat a little and game characters are almost rectangular, so I can just clip rectangles into viewport and test if rectangles overlap. There are usually not that many objects visible inside the viewport, so the performance is good enough.
Re: Converting SDL2 Tutorials from Parallel Realities
Posted: Sun Apr 30, 2023 7:41 am
by dwayne_jarvis
I haven't tested on Rasberry Pi, but I do have a Crow Pi Laptop and can look into this.
Happy to share my Quadtree code that I adapted from
https://github.com/samuel/lua-quadtree and explain how it improves over the original and provides a goodway to implement collision checks with you.
I am currently doing something similar with the next demo that uses astar path finding. Again I found the orignal C source code to be slow and I am looking at adopting pure lua algorithm to achieve the same thing, but cache the patrol movements for the monsters. For some reason the original code constantly updates the route for each movement even though they follow the same path?
I think this can be improved upon but this is a separate topic of conversation.
Let me know if you want more info for the quadtree and how I implemented it in the demo.
Re: Converting SDL2 Tutorials from Parallel Realities
Posted: Sun Apr 30, 2023 10:19 am
by dwayne_jarvis
In case anyone is interested. I have posted the Quadtree source code with basic usage to the Code Snippets section on the forums.
Re: Converting SDL2 Tutorials from Parallel Realities
Posted: Sun Apr 30, 2023 6:31 pm
by airsoftsoftwair
jalih wrote: ↑Mon Apr 24, 2023 6:37 pm
Have you tested performance on a Raspberry Pi 4? Does Hollywood support kms/drm driver with Linux versions, so programs can run hardware accelerated without X11?
Yes, RebelSDL supports hardware-acceleration on the Pi using kms/drm. See
here.