Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (481)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (548)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 2 [3] 4 5
  ignore  |  Print  
  Crabs!  (Read 13251 times)
0 Members and 1 Guest are viewing this topic.
Offline theagentd
« Reply #60 - Posted 2011-10-09 19:29:32 »

I'm not entirely sure how many phones have dual core processors, but as you seem to have done everything you can (according to you xd) why not just multithread it? Well, it wouldn't improve performance on older phones (which I suppose is what you want most) but basic number crunching like this scales almost linearly with the number of cores. If the program is just memory bandwidth limited hyperthreading can provide a bigger boost than a second core! For example when I was experimenting with particle engines, I used Riven's MappedObject library (which you really should use if you can) and multithreading. Using 2 threads on my dual core and got a mere 1.5x speedup, but using 4 threads with hyperthreading gave me a 1.95x speedup. This was without drawing anything though (scaling gets a little worse as the drawing has to be done singlethreaded) but at the same time the numbers are a little biased by Turbo Boost, so scaling should at least get to 2x using hyperthreading. Basically cores can increase computation performance while hyperthreading compensates (more than expected actually) for memory bottlenecks.
Well, I'm not entirely sure this is very attractive for phones though... xd

Myomyomyo.
Offline ruben01

Senior Member


Medals: 4
Projects: 3



« Reply #61 - Posted 2011-10-09 23:00:46 »

princec, have you tried the libgdx library for doing android stuff? it is made by badlogic and now Nate is also working on it.

if I remember correctly the libgdx library fixes some performance issues with bytebuffers and the opengl apis that were present in earlier versions of android (not 1.6 early but 2.0, 2.1 early)

Offline Riven
« League of Dukes »

JGO Overlord


Medals: 781
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #62 - Posted 2011-10-09 23:11:20 »

Cas already applies that 'workaround' by pushing all data into an int[]

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline pitbuller
« Reply #63 - Posted 2011-10-10 06:21:46 »

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
10-10 09:17:47.844: DEBUG/libEGL(1488): loaded /system/lib/egl/libGLES_android.so
10-10 09:17:47.854: DEBUG/libEGL(1488): loaded /system/lib/egl/libEGL_adreno200.so
10-10 09:17:47.854: DEBUG/libEGL(1488): loaded /system/lib/egl/libGLESv1_CM_adreno200.so
10-10 09:17:47.854: DEBUG/libEGL(1488): loaded /system/lib/egl/libGLESv2_adreno200.so
10-10 09:17:47.874: INFO/System.out(1488): Surface created
10-10 09:17:47.874: INFO/System.out(1488): init
10-10 09:17:47.874: INFO/global(1488): Default buffer size used in BufferedInputStream constructor. It would be better to be explicit if an 8k buffer is required.
10-10 09:17:47.874: INFO/global(1488): Default buffer size used in BufferedInputStream constructor. It would be better to be explicit if an 8k buffer is required.
10-10 09:17:47.994: INFO/System.out(1488): LOADING sprites0.mp3 from assets
10-10 09:17:47.994: INFO/global(1488): Default buffer size used in BufferedInputStream constructor. It would be better to be explicit if an 8k buffer is required.
10-10 09:17:48.054: INFO/dalvikvm-heap(1488): Grow heap (frag case) to 3.217MB for 262160-byte allocation
10-10 09:17:48.094: INFO/System.out(1488): Loaded an image 256x256
10-10 09:17:48.144: INFO/global(1488): Default buffer size used in BufferedInputStream constructor. It would be better to be explicit if an 8k buffer is required.
10-10 09:17:48.154: INFO/System.out(1488): LOADING sprites1.mp3 from assets
10-10 09:17:48.164: INFO/global(1488): Default buffer size used in BufferedInputStream constructor. It would be better to be explicit if an 8k buffer is required.
10-10 09:17:48.204: INFO/System.out(1488): Loaded an image 256x256
10-10 09:17:48.214: INFO/global(1488): Default buffer size used in BufferedInputStream constructor. It would be better to be explicit if an 8k buffer is required.
10-10 09:17:48.264: INFO/System.out(1488): LOADING range.jgimage from assets
10-10 09:17:48.264: INFO/global(1488): Default buffer size used in BufferedInputStream constructor. It would be better to be explicit if an 8k buffer is required.
10-10 09:17:48.264: INFO/System.out(1488): Loaded an image 16x1
10-10 09:17:48.264: INFO/global(1488): Default buffer size used in BufferedInputStream constructor. It would be better to be explicit if an 8k buffer is required.
10-10 09:17:48.464: INFO/dalvikvm-heap(1488): Grow heap (frag case) to 11.022MB for 4194320-byte allocation
10-10 09:17:48.684: INFO/dalvikvm-heap(1488): Grow heap (frag case) to 21.441MB for 4194320-byte allocation
10-10 09:17:48.714: ERROR/dalvikvm-heap(1488): 2516580-byte external allocation too large for this process.
10-10 09:17:48.714: WARN/OSMemory(1488): External allocation of 2516580 bytes was rejected
10-10 09:17:48.734: INFO/ActivityManager(150): Displayed activity net.puppygames.minandroid/.MinimalAndroidActivity: 1047 ms (total 1047 ms)
10-10 09:17:48.744: ERROR/AndroidRuntime(1488): FATAL EXCEPTION: GLThread 10
10-10 09:17:48.744: ERROR/AndroidRuntime(1488): java.lang.OutOfMemoryError
10-10 09:17:48.744: ERROR/AndroidRuntime(1488):     at org.apache.harmony.luni.platform.OSMemory.malloc(Native Method)
10-10 09:17:48.744: ERROR/AndroidRuntime(1488):     at org.apache.harmony.luni.platform.PlatformAddressFactory.alloc(PlatformAddressFactory.java:150)
10-10 09:17:48.744: ERROR/AndroidRuntime(1488):     at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:66)
10-10 09:17:48.744: ERROR/AndroidRuntime(1488):     at java.nio.ReadWriteDirectByteBuffer.<init>(ReadWriteDirectByteBuffer.java:51)
10-10 09:17:48.744: ERROR/AndroidRuntime(1488):     at java.nio.BufferFactory.newDirectByteBuffer(BufferFactory.java:93)
10-10 09:17:48.744: ERROR/AndroidRuntime(1488):     at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:68)
10-10 09:17:48.744: ERROR/AndroidRuntime(1488):     at com.shavenpuppy.jglib.sprites.SpriteEngine$RenderQueue.create(SpriteEngine.java:159)
10-10 09:17:48.744: ERROR/AndroidRuntime(1488):     at com.shavenpuppy.jglib.sprites.SpriteEngine$RingBuffer.create(SpriteEngine.java:420)
10-10 09:17:48.744: ERROR/AndroidRuntime(1488):     at com.shavenpuppy.jglib.sprites.SpriteEngine.doCreate(SpriteEngine.java:666)
10-10 09:17:48.744: ERROR/AndroidRuntime(1488):     at com.shavenpuppy.jglib.Feature.create(Feature.java:131)
10-10 09:17:48.744: ERROR/AndroidRuntime(1488):     at net.puppygames.minandroid.MinimalAndroidActivity.init(MinimalAndroidActivity.java:527)
10-10 09:17:48.744: ERROR/AndroidRuntime(1488):     at net.puppygames.minandroid.MinimalAndroidActivity$3.onSurfaceCreated(MinimalAndroidActivity.java:239)
10-10 09:17:48.744: ERROR/AndroidRuntime(1488):     at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1317)
10-10 09:17:48.744: ERROR/AndroidRuntime(1488):     at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1116)
10-10 09:17:48.774: WARN/ActivityManager(150):   Force finishing activity net.puppygames.minandroid/.MinimalAndroidActivity
10-10 09:17:48.794: INFO/System.out(1488): onPause
10-10 09:17:48.794: INFO/System.out(1488): We're finishing!
10-10 09:17:48.794: INFO/System.out(1488): Saving application state
10-10 09:17:48.794: INFO/System.out(1488): cleanup


Huawei ideos x5
Android 2.21
512mb memory, booted the phone just for testing so nothing was on background.
Offline princec

JGO Kernel


Medals: 362
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #64 - Posted 2011-10-10 07:34:31 »

Yeah, I do need to sort out the lifecycle stuff as it's not shutting down cleanly. It also allocates a bit more RAM than it really needs... (16mb for a single sprite engine Smiley)

Cas Smiley

Offline princec

JGO Kernel


Medals: 362
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #65 - Posted 2011-10-10 07:47:33 »

I'm not entirely sure how many phones have dual core processors, but as you seem to have done everything you can (according to you xd) why not just multithread it? Well, it wouldn't improve performance on older phones (which I suppose is what you want most) but basic number crunching like this scales almost linearly with the number of cores. If the program is just memory bandwidth limited hyperthreading can provide a bigger boost than a second core! For example when I was experimenting with particle engines, I used Riven's MappedObject library (which you really should use if you can) and multithreading. Using 2 threads on my dual core and got a mere 1.5x speedup, but using 4 threads with hyperthreading gave me a 1.95x speedup. This was without drawing anything though (scaling gets a little worse as the drawing has to be done singlethreaded) but at the same time the numbers are a little biased by Turbo Boost, so scaling should at least get to 2x using hyperthreading. Basically cores can increase computation performance while hyperthreading compensates (more than expected actually) for memory bottlenecks.
Well, I'm not entirely sure this is very attractive for phones though... xd

"Just multithread" eh? LOL

Actually it already is, but I wouldn't trivialise the task like that if I were you.

MappedObject is unavailable on Dalvik. Hyperthreading is not available on ARM. I don't think we're near memory bandwidth saturation yet. The reason it's slow right now is because the Dalvik VM isn't very good and does no inlining or bounds check elimination or intrinsification of Buffer writes. Also I notice that VBOs in OpenGLES1.1 don't seem to have a flag that allows you to specify that they are write-only, so all those buffer writes are polluting the cache unnecessarily. Mind you the cache is already buggered from having to write everything to an array first anyway.

Cas Smiley

Offline princec

JGO Kernel


Medals: 362
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #66 - Posted 2011-10-10 08:24:41 »

Incredibly I got another 50% speedup by doing the same thing to the index buffer (not sure why I forgot to do that last iteration but there we go). Up to approx 7500 sprites @ 15fps on the Galaxy, so we're 3x faster than where I started without resorting to native code. I think that'll do! Realistically that's going to be about 3,000 sprites at my target framerate of 30fps on the Galaxy, or if I widen the net to cheapy phones, 1000 sprites - enough for Titan Attacks. Job's a good 'un.

Now to fix all the lifecycle problems.

I'll open the source to this lot later, not that it's probably much use to many people (everyone else: you are better off with libgdx!) Many thanks for the fast cos/sin Riven - surprising how much faster it is than the intrinsics on Dalvik.

Cas Smiley

Offline Riven
« League of Dukes »

JGO Overlord


Medals: 781
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #67 - Posted 2011-10-10 08:26:22 »

MappedObject is unavailable on Dalvik.
MappedObject could be reworked to dump data in an int[] (dropping support for long and double)

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline princec

JGO Kernel


Medals: 362
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #68 - Posted 2011-10-10 08:28:05 »

Hm, I'm not really sure MappedObject will help me as basically all of the data needs processing on the way out of the sprite anyway. I suppose it might help data locality if all the sprites are contiguous in memory but they probably are, by and large, anyway.

Cas Smiley

Offline Riven
« League of Dukes »

JGO Overlord


Medals: 781
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #69 - Posted 2011-10-10 08:45:17 »

Many thanks for the fast cos/sin Riven - surprising how much faster it is than the intrinsics on Dalvik.
You should fiddle with SIN_BITS to reduce cache trashing.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline endolf

JGO Coder


Medals: 7


Current project release date: sometime in 3003


« Reply #70 - Posted 2011-10-10 08:54:36 »

I downloaded a fresh apk this morning. I get a brief flash of the text at the top of the screen, then it all goes black. I know it's still running as i can hear the effects when i tap the screen.

Endolf

Offline princec

JGO Kernel


Medals: 362
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #71 - Posted 2011-10-10 09:00:01 »

Yeah that's the OOME. I'll upload a new one soon when I get lifecycle figured out. I'm sure I'm doing something fundamentally wrong.

Cas Smiley

Offline Evil-Devil

Senior Member


Medals: 2


Fir Tree Master


« Reply #72 - Posted 2011-10-10 09:17:06 »

Installed and all i could do was hearing the tapping sound.
HTC Desire HD @android 2.3.3
Offline pitbuller
« Reply #73 - Posted 2011-10-10 16:01:58 »

Many thanks for the fast cos/sin Riven - surprising how much faster it is than the intrinsics on Dalvik.
You should fiddle with SIN_BITS to reduce cache trashing.
Can you explain this a little more. I use a lot sin/cos look up table in my Boxtrix(physic tetris game, http://code.google.com/p/boxtris/ ) and every performance stuff is needed.

Princec: It would be nice to see performance comparision beetween your sprite engine and Libgdx spriteBatch. Maybe this could benefit both systems.
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 781
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #74 - Posted 2011-10-10 17:09:57 »

With 12 bits, two float[2^12]s are allocated: 32KB

By changing the SIN_BITS you trade memory-footprint for accuracy and performance.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline princec

JGO Kernel


Medals: 362
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #75 - Posted 2011-10-10 22:51:11 »

8 bits seems to be indistinguishable for the purposes of rotating little sprites.

The latest version is here, and now should have proper application lifecycle management. And more sprites Smiley As before, if you could let me know the point at which it reaches 15fps on your phone steadily that'd be grand. And any other weirdness. This looks like I've cracked it now, so if this test goes well, on with a game!

Cas Smiley

Offline Riven
« League of Dukes »

JGO Overlord


Medals: 781
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #76 - Posted 2011-10-10 22:55:14 »

Samsung Galaxy Gio: black screen, audio when touching and background music. Crashed a bit later, when I started touching the black surface again.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline princec

JGO Kernel


Medals: 362
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #77 - Posted 2011-10-10 22:58:16 »

Damn Sad Anything interesting in logcat?

Cas Smiley

Offline sproingie

JGO Kernel


Medals: 202



« Reply #78 - Posted 2011-10-10 23:06:43 »

Same here: sound is ok, but just a black screen.  Very occasionally flashes a screen full of random colored blobs.  Samsung Fascinate with CM7

Offline princec

JGO Kernel


Medals: 362
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #79 - Posted 2011-10-10 23:10:19 »

Oh dear, this is beginning to look like vertex buffer objects don't work.

Cas Smiley

Offline Riven
« League of Dukes »

JGO Overlord


Medals: 781
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #80 - Posted 2011-10-10 23:11:35 »

Nothing interesting in (flooded) logcat.

"thread=9: thread exiting with uncaught exception" and ramblings about "keyboard id 65536 invalid"

I saw one green pixel for a split second...  Cranky

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline princec

JGO Kernel


Medals: 362
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #81 - Posted 2011-10-10 23:12:51 »

I'll remove the VBO code....

Cas Smiley

Offline theagentd
« Reply #82 - Posted 2011-10-11 01:14:49 »

Haha, messing up VBOs is about as funny as it can get. Seeing a snapshot of the last time you ran the game, random colors, flickering for static screens. Just as fun as reading and drawing to the same texture at the same time with FBOs.  Grin

Myomyomyo.
Offline princec

JGO Kernel


Medals: 362
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #83 - Posted 2011-10-11 01:27:54 »

Hm I'm surprised it ran properly on the Galaxy actually - there was a pretty significant bug in the code. Come to think of it there's no way it could have run properly. Bizarre. I've uploaded a newer one - anyone care to try?

Cas Smiley

Offline sproingie

JGO Kernel


Medals: 202



« Reply #84 - Posted 2011-10-11 01:35:09 »

404 - did you put it at a new URL?
Offline princec

JGO Kernel


Medals: 362
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #85 - Posted 2011-10-11 01:42:40 »

Oh looks like Dropbox gives every incarnation of a file a unique url: http://dl.dropbox.com/u/1199028/MinimalAndroid.apk
Hm except that looks the same to me. Works, too.

Cas Smiley

Offline sproingie

JGO Kernel


Medals: 202



« Reply #86 - Posted 2011-10-11 01:50:03 »

Just my 3G being fussy again, FYVM Verizon.  WiFi is working fine tho.  Anyway here's the QR code again so I don't have to keep scrolling up to it.  Maybe you could edit the top post to include it?


Offline sproingie

JGO Kernel


Medals: 202



« Reply #87 - Posted 2011-10-11 01:52:57 »

Unfortunately, I tried it again and still got the same black screen Sad
Offline princec

JGO Kernel


Medals: 362
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #88 - Posted 2011-10-11 01:55:39 »

Ok, VBO-free version now uploaded.

Cas Smiley

Offline sproingie

JGO Kernel


Medals: 202



« Reply #89 - Posted 2011-10-11 02:06:21 »

Works great now.  I get a stable 15FPS at 1700 sprites (looks like you have more than crabs going on now).

Does it really not support VBOs?  I thought that was just about the only way to pass vertices to shaders...


Pages: 1 2 [3] 4 5
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

atombrot (26 views)
2014-08-19 09:29:53

Tekkerue (24 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (14 views)
2014-08-16 06:20:21

Tekkerue (22 views)
2014-08-16 06:12:11

Rayexar (60 views)
2014-08-11 02:49:23

BurntPizza (38 views)
2014-08-09 21:09:32

BurntPizza (30 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38

BurntPizza (67 views)
2014-08-03 02:57:17
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!