The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
SDL2 WinRT performance issues
Meldryt


Joined: 22 Oct 2014
Posts: 36
Location: Munich
We develop a simple 2D game for ios and windows phone. Both versions are quiet similar
The game runs fluenty on an old IPhone with 50-60 fps but on windows phone it runs only at 20-25fps.

Maybe it has something to do with the multitouch handling or draw calls.
We use some SDL draw functions for simple primitives like SDL_RenderFillRect, filled circles (filledPolygonRGBA from gfxprimitives) or draw text functions like TTF_RenderText_Solid.
I have already tried to gain more performance by reducing draw calls for single primitives, but it didnt help.
Re: SDL2 WinRT performance issues
DLudwig


Joined: 09 Feb 2012
Posts: 179
Meldryt wrote:
We develop a simple 2D game for ios and windows phone. Both versions are quiet similar
The game runs fluenty on an old IPhone with 50-60 fps but on windows phone it runs only at 20-25fps.

Maybe it has something to do with the multitouch handling or draw calls.
We use some SDL draw functions for simple primitives like SDL_RenderFillRect, filled circles (filledPolygonRGBA from gfxprimitives) or draw text functions like TTF_RenderText_Solid.
I have already tried to gain more performance by reducing draw calls for single primitives, but it didnt help.


I'd be surprised if it had to do with multitouch code, and suspect the D3D11 renderer could use some additional optimization.

Might you be able to provide some sample code that illustrates the issue?

-- David L.
Meldryt


Joined: 22 Oct 2014
Posts: 36
Location: Munich
edit:
found the problem. it must be something inside filledPolygonRGBA function from gfxprimitives
Meldryt


Joined: 22 Oct 2014
Posts: 36
Location: Munich
ups. i meant filledCircleRGBA.
Code:
void Painter::DrawFilledCircle(SDL_Renderer *renderer, const float centerPoint[], const float radius, const int color,bool bPlayerRelative)
{
   float drawpoint[2];

   if(bPlayerRelative)
   {
      drawpoint[0]=centerPoint[0]+m_playerpos[0];
      drawpoint[1]=centerPoint[1]+m_playerpos[1];
   }
   else
   {
      drawpoint[0]=centerPoint[0];
      drawpoint[1]=centerPoint[1];
   }
   SetDrawColor(renderer,color);
   filledCircleRGBA(renderer, Sint16(drawpoint[0]), Sint16(drawpoint[1]),Sint16(radius),m_paintColor.r,m_paintColor.g,m_paintColor.b,m_paintColor.a);
}

i call this function around six times per frame, and it dropped from 60 fps to 20-25 fps.
well, drawing filled circles with sdl seem to be a problem for me, so i draw preinitialized textures instead. now it runs at constant 60 fps.
mr_tawan


Joined: 13 Jan 2014
Posts: 161
I supposed you're using SDL2_gfx. I've skimmed through the code, and found that this library draw each pixel in the circle individually (by calling SDL_RenderDrawPoint()). I cannot be so sure as I haven't really benchmark it, but I think doing so can really hurt performance. You might want to try benchmark it.

If it's really the case then I think you might want to reconsider using filled circles. Or may be you can do the caching by drawing circle in to a texture and reusing the texture instead of redrawing circle every frame.

My statement above is not based on any kinds of test or benchmark. It might be incorrect.
SDL2 WinRT performance issues
Andreas Schiffler
Guest

SDL2_gfx uses DrawPoint (circle, aaCircle) or DrawLine (filled circle) which may incur a severe performance penalty depending on the renderer. The library was not designed to be very performant, but rather to provide backwards compatibility for SDL_gfx and some uses which don't require a lot of primitives to be rendered.

You can run TestGfx to get a benchmark ... here are my numbers from my PC with i7 CPU and a low end NVidia card.

Win32\Release>TestGfx.exe
INFO: SDL2_gfx 1.0.2: testgfx
INFO: Platform: Windows
INFO: Renderer 0: direct3d (Accelerated)
INFO: Test 0 Pixel: 2730666.6 /sec
INFO: Test 1 Hline: 2048000.0 /sec
INFO: Test 2 Vline: 2048000.0 /sec
INFO: Test 3 Rectangle: 4096000.0 /sec
INFO: Test 4 RoundedRectangle: 126030.7 /sec
INFO: Test 5 Box: 4096000.0 /sec
INFO: Test 6 Line: 1638400.0 /sec
INFO: Test 7 Circle: 43574.4 /sec
INFO: Test 8 AACircle: 19366.4 /sec
INFO: Test 9 FilledCircle: 59362.3 /sec
INFO: Test 10 Ellipse: 40554.4 /sec
INFO: Test 11 AAEllipse: 18492.0 /sec
INFO: Test 12 FilledEllipse: 60681.4 /sec
INFO: Test 13 Bezier: 5142.8 /sec
INFO: Test 14 Polygon: 2730500.0 /sec
INFO: Test 15 AAPolygon: 5696.8 /sec
INFO: Test 16 FilledPolygon: 19320.7 /sec
INFO: Test 17 Trigon: 3276800.0 /sec
INFO: Test 18 Arc: 92564.9 /sec
INFO: Test 19 Pie: 682666.6 /sec
INFO: Test 20 FilledPie: 60457.5 /sec
INFO: Test 21 ThickLine: 27029.7 /sec


--Andreas

On 11/28/2014 1:53 PM, mr_tawan wrote:

Quote:
I supposed you're using SDL2_gfx. I've skimmed through the code, and found that this library draw each pixel in the circle individually (by calling SDL_RenderDrawPoint()). I cannot be so sure as I haven't really benchmark it, but I think doing so can really hurt performance. You might want to try benchmark it.

If it's really the case then I think you might want to reconsider using filled circles. Or may be you can do the caching by drawing circle in to a texture and reusing the texture instead of redrawing circle every frame.

My statement above is not based on any kinds of test or benchmark. It might be incorrect.


Quote:
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Meldryt


Joined: 22 Oct 2014
Posts: 36
Location: Munich
Yeah there s lot of code for one little circle -,- Using textures is definitely the better option for me as long as i dont have to change primitive dimensions dynamically.