Possible V43 fix...

Monkey Targets Forums/Android/Possible V43 fix...

marksibly(Posted 2011) [#1]
Hi,

Could everyone suffering from slowdown in V43 please try the following fix?

Replace the following 2 lines in mojo.android.java...

		gl.glBufferSubData( GL11.GL_ARRAY_BUFFER,0,rcount*16,vbuffer );
		gl.glBufferSubData( GL11.GL_ARRAY_BUFFER,MAX_VERTICES*16,rcount*4,cbuffer );

...with...
		gl.glBufferData( GL11.GL_ARRAY_BUFFER,rcount*20,null,GL11.GL_DYNAMIC_DRAW );
		gl.glBufferSubData( GL11.GL_ARRAY_BUFFER,0,rcount*16,vbuffer );
		gl.glBufferSubData( GL11.GL_ARRAY_BUFFER,rcount*16,rcount*4,cbuffer );
		gl.glColorPointer( 4,GL11.GL_UNSIGNED_BYTE,0,rcount*16 );

That's it!


Samah(Posted 2011) [#2]
Using the Diddy tile engine demo on my Desire HD, I was getting ~35fps with vanilla mojo, and ~50fps with your changes.

I also tried RenderTest, but unfortunately I got 59fps on all the tests, both before and after the fix... >_>


therevills(Posted 2011) [#3]
Using the RenderTest here: http://www.monkeycoder.co.nz/Community/post.php?topic=1120&post=10120 and running just the colorize test:

Objs| v43 | Fix
----+-----+-----
 10 |  58 |  58
100 |  44 |  50
200 |  30 |  36
300 |  24 |  26


So some improvements there :)

Now testing Pirates...

    | FPS
----+---------
42b | 31-35
43  | 22-28
Fix | 36-50 (but keeps around 40+ alot)


\o/

On a simple map using the Diddy Tile Engine I was getting 32FPS and with the fix Im now getting 42FPS.


dave.h(Posted 2011) [#4]
ive compared it to v40 and while there is a slight improvement for me when my game has around 60 moving aliens and 12 towers the fps drops to around 14 but in v40 it never drops below 25 with everything blazing away.Also still getting bad stuttering.


dave.h(Posted 2011) [#5]
ps probobably should have mention it was tested on an experia x10. I also tested it on my galaxy tab and v40 was throwing out over 60 fps but v43 went as low as 28 fps with slight stuttering.


devolonter(Posted 2011) [#6]
It works! In the Impact game, I have 56-58 FPS. Also the problem of a sharp slowdown FPS disappeared. In my tests ( http://www.monkeycoder.co.nz/Community/post.php?topic=1120&post=10120 ) I get a stable 58 FPS. But... still the movement of objects is not smooth. Setting the update rate equal to 58 or using my alternative version eliminates this problem on my device.

Thanks Mark!


dave.h(Posted 2011) [#7]
also tested this with a diffent game with 40 buttons on screen at one time and a scrolling background (its set up like a piano) and the fsp was the same in both versions at around 31 fps with no stuttering.


anawiki(Posted 2011) [#8]
No change in Avalon Legends. Still around 22-24 FPS (but when I switched from DrawText to AngelFont to draw FPS on the screen it went down to as low as 12 FPS). My device:

Samsung Galaxy Tab 7" gt-p1010, Android 2.2, Froyo, 1GHz A8 Cortex Processor, PowerVR SGX540.


therevills(Posted 2011) [#9]
So no change at all anawiki? You sure you saved the changes? ;)

Also did you do a clean before hand?


anawiki(Posted 2011) [#10]
Yes, no change at all, which surprised me (well, initially there was a change due to usage of AngelFont for FPS printing). I even checked java source of my game to make sure that those 4 lines are there.

After so much hype around android tablets I expected them to be at least a bit better than iPods, but they don't stand a chance so far...


pantson(Posted 2011) [#11]
I have no FPS output code in my game.. but I can say the update above is a lot smoother.
I may put some i later today

I don't seem to be getting any Admob ads now though... but thats a different issue.

Spec: Sony X8, Android 2.1, resolution 320*480


MonkeyPig(Posted 2011) [#12]
Device: LGE VM670 (LG OPTIMUS V)
V43 - 10-14 fps
V43 Fix - 19-24 FPS

My Android App FPS are kinda all of the place on a full level play-through at the moment, but standings still at the level start I see huge FPS gains.


pantson(Posted 2011) [#13]
what I should have said is that *I* broke the ads :-p
These are now fixed in the v43 with this fix.


DGuy(Posted 2011) [#14]
v41    : ~38 fps
v42b   : ~40 fps
v43    : ~25 fps
v43 fix: ~26 fps



therevills(Posted 2011) [#15]
Hey DGuy, what app were you running to get those numbers?


marksibly(Posted 2011) [#16]
Hi,

This fix probably only applies to qualcomm/adreno chipset phones, not powervr based ones like the Samsung.

In all my tests here on the (powervr) Samsung, v43 is *faster* than any previous version, while v43+ (ie: v43 with fixe above) is a tiny bit slower (my new bouncyaliens loses 1-2 FPS here and there), which I think's worth it if it's significantly faster on the (slower) adreno.

So I'm not sure why DGuy's or Anawiki's apps are slower under v43 than v42b. I can only assume older/crapper drivers. If you guys want me to take a look, please email me your projects.

The next step is probably to go native, thereby bypassing any Java crapulence entirely. This is how libgdx seems to have gotten around the adreno VBO issue, and will be faster all round regardless of gpu. But at that point, I'd rather spend the effort unifying all the GL versions which'll take a bit longer.


DGuy(Posted 2011) [#17]
@Therevills
Hey DGuy, what app were you running to get those numbers?

My current, unreleased, klondike solitair app.


BTW, I'm currently using a mash-up version of android mojo: v43 w/ a custom version of the gxtkGraphics class (based on v40 w/ interleaved arrays). It also make auto-use of the depth buffer (don't have to specify depth in your monkey code just draw in the normal back to front order) and sorts/draws non-alpha stuff first (draws front to back) and alpha stuff second (draws back to front).

In the same test as above it eeks out ~43 fps, but as all my graphics use alpha I expect to see a few more fps when I optimizes alpha usage a bit more ...

Not saying it will be faster on anyone elses device (the joys of fragmentation ... ) but if anyone wants to have a look, and Mark says its ok, I'll post it ...


anawiki(Posted 2011) [#18]
Mark, I've sent you an email asking for what you need from my project (writing it here just in case you didn't get it).


AdamRedwoods(Posted 2011) [#19]
I didn't have much change with my Galaxy Tab, but in my tests I haven't experienced TOO much of a drop for any versions.


(but when I switched from DrawText to AngelFont to draw FPS on the screen it went down to as low as 12 FPS).


My thought is that Monkey will need (at some point) a bitmap/texture creator, so we can create text ahead of time and draw it as a single texture+quad instead of AngelFont's method which is a series of quads.


dave.h(Posted 2011) [#20]
i must be programming something wrong because i use a galaxy tab as well and have noticed about a 40% drop in frame rates from v40 to v43.


therevills(Posted 2011) [#21]

The next step is probably to go native, thereby bypassing any Java crapulence entirely.


I've read that sometimes native isnt always going to be faster. Hopefully you will find a way to get Monkey pretty fast on "most" devices. My LG can play most of them fine, its just when I touch the bloody screen it starts to weep... waiting for 2.3 update. HTC Wildfire is meant to be one of the worst devices to play games on.


I'd rather spend the effort unifying all the GL versions which'll take a bit longer.



Hope this doesnt mean that the same OpenGL commands are going to be used across each target... OpenGL ES is a subset of OpenGL - some of the assumptions going from one platform to another doesnt quite work well.


anawiki(Posted 2011) [#22]
To make sure it's not Garbage Collector that makes the slowdown I watched memory allocations and after few hours I optimized the code so GC kicks in only every 10 seconds. Still performance is lower in v43 (with optimization of my code) than in v42b (before optimization of my code).

We're still talking about Galaxy Tab here.


marksibly(Posted 2011) [#23]
Hi,

> I've read that sometimes native isnt always going to be faster.

I strongly suspect that using native code for the vertex data copy is likely to give us a substantial speed boost - my fix above is sort of emulating that.

Beyond that, translating the monkey code to C++ should provide a further big boost for compute intense games, and would hopefully minimize GC stalls. However, after installing the NDK yesterday, I don't think I want to put the community through that just yet! The vertex data copy fix shouldn't require the NDK though, just an extra .so file in the android target.

You can also now write entire android activities in native code, but it's a 2.3 only feature. Perhaps a good starting point for a future additional native target though?


matt(Posted 2011) [#24]
Any sign of an "official" benchmark app?

Anyway, here are my results running mak/BouncyAliens with 200 sprites:

v38 with non-native resolution = 28fps
v42 = 16fps
v43 = 32fps
v43 with above fix: 36fps

ZTE Blade running CyanogenMod 7.0.3