Converting SDL2 Tutorials from Parallel Realities
-
- Posts: 475
- Joined: Fri May 15, 2015 5:15 pm
- Location: Waterville, Minnesota USA
Re: Converting SDL2 Tutorials from Parallel Realities
What graphics drivers are you using? What graphics card also? I suspect something is using software rendering somewhere.
I'm on registered MorphOS using FlowStudio.
-
- Posts: 22
- Joined: Wed Mar 03, 2021 8:15 am
Re: Converting SDL2 Tutorials from Parallel Realities
Radeon Polaris 10 (RX580 I think), using RadeonRX.chip Version 2.11
- airsoftsoftwair
- Posts: 5446
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: Converting SDL2 Tutorials from Parallel Realities
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:
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...
Code: Select all
DisableLineHook()
p_DrawNextFrame()
EnableLineHook()
-
- Posts: 22
- Joined: Wed Mar 03, 2021 8:15 am
Re: Converting SDL2 Tutorials from Parallel Realities
I already do this in the main loop.
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.
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
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
Debug prints inside the main game loop are also real performance killers.
-
- Posts: 22
- Joined: Wed Mar 03, 2021 8:15 am
Re: Converting SDL2 Tutorials from Parallel Realities
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
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
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.
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.
-
- Posts: 22
- Joined: Wed Mar 03, 2021 8:15 am
Re: Converting SDL2 Tutorials from Parallel Realities
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.
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.
-
- Posts: 22
- Joined: Wed Mar 03, 2021 8:15 am
Re: Converting SDL2 Tutorials from Parallel Realities
In case anyone is interested. I have posted the Quadtree source code with basic usage to the Code Snippets section on the forums.
- airsoftsoftwair
- Posts: 5446
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact: