SDL_RenderCopy very slow on Lumia 520 Windows Phone 8.1

Hi,

I made a simple “BunnyMark” style benchmark with SDL2.0.4 based on
SDL_RenderCopy-ing as many moving 32x32 sprites to the screen as
possible while maintaining 60fps. An iPod 4 can manage about 1100 such
sprites before slowing down, but when I tried the same code on a Lumia
520 it could barely manage 10% of that. The Lumia benchmarks a little
faster than an iPod 5 in general, so something seems off here.

The device was running the latest Windows Phone 8.1 and everything was
built from source in release mode.

I confirmed SDL was using the D3D11 render path, but I also got the same
ballpark result when using the OpenGLES renderer via ANGLE.

I ran a similar Cocos2DX benchmark that could animate 2200 sprites @
60fps on the same device, I believe with an OpenGLES render path.

This is a profiling run of the SDL code:
Imgur
D3D11_UpdateVertexBuffer is the major CPU hog. I don’t know anything
about D3D programming so I stopped there.

Main File:

Complete VS2015 Community Solution:
https://dl.dropboxusercontent.com/u/593090/BunnyMarkSDL.zip

Am I doing something stupid here (other than running contrived
benchmarks, obv) ?
Any suggestions?

John–
@nivrig

Hello,

I got a similar issue on Windows 10, on a Lumia 1320 phone.
Rendering was jerky, compared to IOS, and compared to Android.
And also compared with the same phone running an old Windows 8 app build
(with SDL2 code like it was 1.5 year ago).

I found out (and reported) this small modification :

in the file “SDL_render_d3d11.c” (line 1423), change the “BufferCount” from
"2" to “3”.

Cheers,
SylvainOn 27 January 2016 at 23:28, John Girvin wrote:

Hi,

I made a simple “BunnyMark” style benchmark with SDL2.0.4 based on
SDL_RenderCopy-ing as many moving 32x32 sprites to the screen as
possible while maintaining 60fps. An iPod 4 can manage about 1100 such
sprites before slowing down, but when I tried the same code on a Lumia
520 it could barely manage 10% of that. The Lumia benchmarks a little
faster than an iPod 5 in general, so something seems off here.

The device was running the latest Windows Phone 8.1 and everything was
built from source in release mode.

I confirmed SDL was using the D3D11 render path, but I also got the same
ballpark result when using the OpenGLES renderer via ANGLE.

I ran a similar Cocos2DX benchmark that could animate 2200 sprites @
60fps on the same device, I believe with an OpenGLES render path.

This is a profiling run of the SDL code:http://imgur.com/oRyc0Sm
D3D11_UpdateVertexBuffer is the major CPU hog. I don’t know anything
about D3D programming so I stopped there.

Main File:https://gist.github.com/johngirvin/fdf60a6e6a9d735b563c

Complete VS2015 Community Solution:https://dl.dropboxusercontent.com/u/593090/BunnyMarkSDL.zip

Am I doing something stupid here (other than running contrived
benchmarks, obv) ?
Any suggestions?

John

@nivrig


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Thanks, but I just tried that and it made no difference.

Sylvain Becker wrote:> in the file “SDL_render_d3d11.c” (line 1423), change the “BufferCount”

from “2” to “3”.

Strange, because it definitively solves a very similar issue for me !
I will send you a test case.On 28 January 2016 at 12:15, John Girvin wrote:

Thanks, but I just tried that and it made no difference.

Sylvain Becker wrote:

in the file “SDL_render_d3d11.c” (line 1423), change the "BufferCount"
from “2” to “3”.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I don’t think we’re having the same problem. I’m CPU bound in SDL with ~100 sprites, which seems way out of line with the device’s general performance and its performance with other rendering engines.

SDL_RenderCopy (mostly D3D11_RenderCopy) accounts for 85% of this CPU time: 60% in D3D11_UpdateVertexBuffer “external code”, 25% in “external code” in other parts of D3D11_RenderCopy.

Should I report this as a bug?

I tried your test case and my Lumia 1320 + win10, it could reach almost 300
sprites, before going under 60 fps.

On android (htc m7), it was better with 700 sprites.

Don’t know what performance should be expected though.

Lumia 1320 has a 1.7Ghz core speed compared to the Lumia 520’s 1.0Ghz, so your result of 300 sprites is consistent with the Windows version being CPU bound at a very low number of sprites.

Maybe someone more experienced could help or suggest something to try …

nivrig2 wrote:

Should I report this as a bug?

Hi John,

This is David Ludwig. I wrote much of SDL’s D3D11 renderer.

Admittedly, SDL’s D3D11 renderer is a pretty naive implementation, and could -definitely- use some performance work. :slight_smile:

A bug report sounds fine. Tested patch(es) would be better. :wink:

Cheers!
– David L.

Bug 3254 (https://bugzilla.libsdl.org/show_bug.cgi?id=3254) posted. I’m afraid I can’t help with the patches though…

I found that the change also bumps the frame rate from 30 to 60 fps when
rendering with vsync enabled on the Lumia 550. If there are no downsides,
shoudn’t the change be applied in general?

---------- P?vodn? zpr?va ----------
Od: Sylvain Becker <sylvain.becker at gmail.com>
Komu: SDL Development List
Datum: 28. 1. 2016 8:48:23
P?edm?t: Re: [SDL] SDL_RenderCopy very slow on Lumia 520 Windows Phone 8.1

"

Hello,

I got a similar issue on Windows 10, on a Lumia 1320 phone.

Rendering was jerky, compared to IOS, and compared to Android.

And also compared with the same phone running an old Windows 8 app build
(with SDL2 code like it was 1.5 year ago).

I found out (and reported) this small modification :

in the file “SDL_render_d3d11.c” (line 1423), change the “BufferCount” from
"2" to “3”.

Cheers,

SylvainOn 27 January 2016 at 23:28, John Girvin <hello at nivrig.com (mailto:hello at nivrig.com)> wrote:
"

Hi,

I made a simple “BunnyMark” style benchmark with SDL2.0.4 based on
SDL_RenderCopy-ing as many moving 32x32 sprites to the screen as
possible while maintaining 60fps. An iPod 4 can manage about 1100 such
sprites before slowing down, but when I tried the same code on a Lumia
520 it could barely manage 10% of that. The Lumia benchmarks a little
faster than an iPod 5 in general, so something seems off here.

The device was running the latest Windows Phone 8.1 and everything was
built from source in release mode.

I confirmed SDL was using the D3D11 render path, but I also got the same
ballpark result when using the OpenGLES renderer via ANGLE.

I ran a similar Cocos2DX benchmark that could animate 2200 sprites @
60fps on the same device, I believe with an OpenGLES render path.

This is a profiling run of the SDL code:
http://imgur.com/oRyc0Sm
D3D11_UpdateVertexBuffer is the major CPU hog. I don’t know anything
about D3D programming so I stopped there.

Main File:
https://gist.github.com/johngirvin/fdf60a6e6a9d735b563c

Complete VS2015 Community Solution:
https://dl.dropboxusercontent.com/u/593090/BunnyMarkSDL.zip

Am I doing something stupid here (other than running contrived
benchmarks, obv) ?
Any suggestions?

John

@nivrig


SDL mailing list
SDL at lists.libsdl.org(mailto:SDL at lists.libsdl.org)
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
(http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)

"


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org"

I found that the change also bumps the frame rate from 30 to 60 fps when
rendering with vsync enabled on the Lumia 550. If there are no downsides,
shoudn’t the change be applied in general?

---------- P?vodn? zpr?va ----------
Od: Sylvain Becker <sylvain.becker at gmail.com>
Komu: SDL Development List
Datum: 28. 1. 2016 8:48:23
P?edm?t: Re: [SDL] SDL_RenderCopy very slow on Lumia 520 Windows Phone 8.1

"

Hello,

I got a similar issue on Windows 10, on a Lumia 1320 phone.

Rendering was jerky, compared to IOS, and compared to Android.

And also compared with the same phone running an old Windows 8 app build
(with SDL2 code like it was 1.5 year ago).

I found out (and reported) this small modification :

in the file “SDL_render_d3d11.c” (line 1423), change the “BufferCount” from
"2" to “3”.

Cheers,

SylvainOn 27 January 2016 at 23:28, John Girvin <hello at nivrig.com (mailto:hello at nivrig.com)> wrote:
"

Hi,

I made a simple “BunnyMark” style benchmark with SDL2.0.4 based on
SDL_RenderCopy-ing as many moving 32x32 sprites to the screen as
possible while maintaining 60fps. An iPod 4 can manage about 1100 such
sprites before slowing down, but when I tried the same code on a Lumia
520 it could barely manage 10% of that. The Lumia benchmarks a little
faster than an iPod 5 in general, so something seems off here.

The device was running the latest Windows Phone 8.1 and everything was
built from source in release mode.

I confirmed SDL was using the D3D11 render path, but I also got the same
ballpark result when using the OpenGLES renderer via ANGLE.

I ran a similar Cocos2DX benchmark that could animate 2200 sprites @
60fps on the same device, I believe with an OpenGLES render path.

This is a profiling run of the SDL code:
http://imgur.com/oRyc0Sm
D3D11_UpdateVertexBuffer is the major CPU hog. I don’t know anything
about D3D programming so I stopped there.

Main File:
https://gist.github.com/johngirvin/fdf60a6e6a9d735b563c

Complete VS2015 Community Solution:
https://dl.dropboxusercontent.com/u/593090/BunnyMarkSDL.zip

Am I doing something stupid here (other than running contrived
benchmarks, obv) ?
Any suggestions?

John

@nivrig


SDL mailing list
SDL at lists.libsdl.org(mailto:SDL at lists.libsdl.org)
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
(http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)

"


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org"

hardcoredaniel wrote:

I found that the change also bumps the frame rate from 30 to 60 fps when rendering with vsync enabled on the Lumia 550. If there are no downsides, shoudn’t the change be applied in general?

I’ll look into applying it later this week. I’ve got a few devices I want to test it on first, before submitting it though.

– David L.

hardcoredaniel wrote:

I found that the change also bumps the frame rate from 30 to 60 fps when rendering with vsync enabled on the Lumia 550. If there are no downsides, shoudn’t the change be applied in general?

I’ve been giving this a bit more thought. I like the idea of being able to use triple-buffering, but am not entirely sold on enabling it in all cases, for all apps, as it would use up more memory.

What about an SDL_HINT (set via a call to SDL_SetHint()) to adjust the D3D11 renderer’s buffer-count?

– David L.

Hello,

Just wanted to remind my investigations when using the triple buffering:

I saw improvements with the test I sent you before, that draw full-speed a
square moving in one direction.
With double-buffering, line was like “interrupted”, and the squares were
scattered as packet.
Like if a function was sometimes a little bit more blocking ? or like a
vsync missed ? (but the gap between two packages seems to be more than a
vsync).
Maybe it could also be some GC, or some thread underneath …

With triple-buffering, line was smooth and homogeneous.
Please give a try to this test-case if you haven’t tested yet.

I remind also what I tested:
My old WP8 (2-buffering) app that was running smoothly on WP phone, still
ran smoothly after the phone upgraded to Win10.
As soon as, I re-compiled the app for Win10 (with some new SDL2 code), and
tested it on win10 phone, it started to be non-smooth.
After adding 3-buffering, it became smooth again.

Could the V-Sync be not enable before ?
Could the app be automatically promoted to 3-buffering before ? (Maybe
there is a way to query buffering/vsync ?)

Cheers,
SylvainOn 12 June 2016 at 23:57, DLudwig wrote:

hardcoredaniel wrote:

I found that the change also bumps the frame rate from 30 to 60 fps when
rendering with vsync enabled on the Lumia 550. If there are no downsides,
shoudn’t the change be applied in general?

I’ve been giving this a bit more thought. I like the idea of being able to
use triple-buffering, but am not entirely sold on enabling it in all cases,
for all apps, as it would use up more memory.

What about an SDL_HINT (set via a call to SDL_SetHint()) to adjust the
D3D11 renderer’s buffer-count?

– David L.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Sylvain Becker

I like the idea of a hint, so that people can make a choice and trade memory
for FPS. Although some years from now we probably won’t mind the additional
memory anymore.

---------- P?vodn? zpr?va ----------
Od: DLudwig
Komu: sdl at lists.libsdl.org
Datum: 12. 6. 2016 23:58:12
P?edm?t: Re: [SDL] SDL_RenderCopy very slow on Lumia 520 Windows Phone 8.1

"

                      hardcoredaniel wrote:	 

I found that the change also bumps the frame rate from 30 to 60 fps when
rendering with vsync enabled on the Lumia 550. If there are no downsides,
shoudn’t the change be applied in general?

I’ve been giving this a bit more thought. I like the idea of being able to
use triple-buffering, but am not entirely sold on enabling it in all cases,
for all apps, as it would use up more memory.

What about an SDL_HINT (set via a call to SDL_SetHint()) to adjust the D3D11
renderer’s buffer-count?

– David L._______________________________________________
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org"

We are already some years, from some years, from caring about additional
memory :slight_smile:
I agree the hint is the fastest way to please anyone and to be more
flexible.
But that’s one more legacy hint …

Maybe, a little bit more investigation before choosing the hint solution …
btw, there is a VC2015 RC 3, could this have some positive effect ?On 13 June 2016 at 09:40, hardcoredaniel wrote:

I like the idea of a hint, so that people can make a choice and trade
memory for FPS. Although some years from now we probably won’t mind the
additional memory anymore.

---------- P?vodn? zpr?va ----------
Od: DLudwig
Komu: sdl at lists.libsdl.org
Datum: 12. 6. 2016 23:58:12
P?edm?t: Re: [SDL] SDL_RenderCopy very slow on Lumia 520 Windows Phone 8.1

hardcoredaniel wrote:
I found that the change also bumps the frame rate from 30 to 60 fps when
rendering with vsync enabled on the Lumia 550. If there are no downsides,
shoudn’t the change be applied in general?

I’ve been giving this a bit more thought. I like the idea of being able to
use triple-buffering, but am not entirely sold on enabling it in all cases,
for all apps, as it would use up more memory.

What about an SDL_HINT (set via a call to SDL_SetHint()) to adjust the
D3D11 renderer’s buffer-count?

– David L.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Sylvain Becker