Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (524)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (592)
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
  ignore  |  Print  
  Hardware acceleration?  (Read 13240 times)
0 Members and 1 Guest are viewing this topic.
Offline EgonOlsen
« Posted 2009-07-29 08:33:51 »

As mentioned in this thread: http://www.java-gaming.org/topics/android-section/20886/view.html

...there seems to be a problem with hardware support for 3D acceleration on Android. I couldn't get it to work on a Samsung Galaxy. Not with my own code, not with the examples from Google's SDK...it's all rendered in software. I've seen some demos/games (Omnigsoft) that use it even on my phone, but they seem to rely on their own, native libraries (judging from the debug output) and i've found a lot of blah on the internet that it is possible...but none of those posters has actually tried it or at least not with something more complex than a spinning cube.
I've also found a post from Google, that 1.0 couldn't do it and i found a statement in a german forum, that the native SDK (NDK) can't do it either even with Android 1.5. So my guess is, that just isn't possible right now.

Has anybody found a statement from Google on this? 3D on Android seems to be low on priority for them...

Offline EgonOlsen
« Reply #1 - Posted 2009-07-29 08:34:09 »

---deleted...double post.

Offline Ranger
« Reply #2 - Posted 2009-07-29 10:58:19 »

My Android game uses OpenGL no problems on the G1 and Magic:  "CraigsRace" http://www.cyrket.com/package/com.dlinkddns.craig

Would be interested to know if it works ok on the Galaxy.  I put an "OpenGL" checkbox on the main screen of the game so you can run the game without OpenGL.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline EgonOlsen
« Reply #3 - Posted 2009-07-29 12:08:17 »

It works fine on the Galaxy. The point isn't that OpenGL doesn't work, the point is that i can't get hardware acceleration for it to work. I'm unable to decide if your game uses the GPU of the device or not. I've to have a look at the debugger when i'm at home again to make a more educated guess. Performance is fine tough.

Offline Ranger
« Reply #4 - Posted 2009-07-29 12:33:01 »

It works fine on the Galaxy. The point isn't that OpenGL doesn't work, the point is that i can't get hardware acceleration for it to work. I'm unable to decide if your game uses the GPU of the device or not. I've to have a look at the debugger when i'm at home again to make a more educated guess. Performance is fine tough.

Cool, thanks EgonOlsen!  My game scales and rotates around 2,000 vertices with textures every frame (about 30fps), so... err... actually, I don't know if that is a lot or not.
Offline EgonOlsen
« Reply #5 - Posted 2009-07-29 12:45:47 »

The problem of the software renderer is fillrate, not vertex count. Judging from the look and feel of your game, it seems to use hardware IMHO, but i'll check it out in the debugger later.

Offline princec

« JGO Spiffy Duke »


Medals: 422
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #6 - Posted 2009-07-29 14:08:10 »

I expect vertex count might be a bit of a problem when you start getting fancy... we've got about 1,000-2,000 sprites per frame - between 4,000 and 8,000 vertices, none of which are shared - and we want 60fps :/

Cas Smiley

Offline EgonOlsen
« Reply #7 - Posted 2009-07-29 14:27:28 »

I ran Craigs Race using ddms to see the console output...looks like software rendering to me. My guess (again, i have no real prove for this...) is, that lines like this one

1  
07-29 16:19:12.637: INFO/ARMAssembler(1051): generated scanline__00000077:03010104_00000504_00000000 [ 18 ipp] (37 ins) at [0x38a518:0x38a5ac] in 1641668 ns


indicate that the software renderer has assembled a new, optimized scanline renderer for the particular texture/mode combination. The first Android version used to crash in this method when using multi texturing. It seems to be the case, that for each texture/mode, such thing is being generated (and cached somehow...if you rerun the application without applying a change, it may not happen).
However, the fillrate in this game is far better than in my example code. Is it using ortho-mode? In that case, the renderer can skip the expensive perspective correction, which will speed up things.

Offline Ranger
« Reply #8 - Posted 2009-07-29 22:30:10 »

Is it using ortho-mode?

Yes (I think).  Because I converted it from my 4K entry.  I do this:

1  
gl.glOrthof(0, widthScreen, heightScreen, 0, 0, 1);


I also do this:
1  
2  
3  
gl.glDisable(GL10.GL_DEPTH_TEST);
gl.glDisable(GL10.GL_DITHER);
gl.glDisable(GL10.GL_LIGHTING);


Not sure if this is important or not, however, the game does not run properly using OpenGL in the Android emulator.  When running in the emulator it only gets about 1 fps, it draws the vertices all over the place, and the screen goes completely white after a few seconds.
Offline EgonOlsen
« Reply #9 - Posted 2009-07-30 05:07:08 »

Not sure if this is important or not, however, the game does not run properly using OpenGL in the Android emulator.  When running in the emulator it only gets about 1 fps, it draws the vertices all over the place, and the screen goes completely white after a few seconds.
The emulator has other bugs too, like wrong lighting.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #10 - Posted 2009-07-30 14:40:55 »

I expect vertex count might be a bit of a problem when you start getting fancy... we've got about 1,000-2,000 sprites per frame - between 4,000 and 8,000 vertices, none of which are shared - and we want 60fps :/

Cas Smiley
If the Android phones are comparable to the iPhone in terms of horsepower, you should be able to get that count easily if you are smart about when you're binding textures, and maybe use PVRTC. Our game can run at 30 fps with a lot of pathfinding and stuff going on, as well as 8,000 vertices for 3D models in the game. Each 400 vertices is a single draw call, but I've also been able to fit hundreds of particles (just TRIANGLE_STRIPs with a texture) on the screen, but that was with a single shared texture. And I haven't spent nearly as much time optimizing as I could have.

So a long story short, I think that's totally doable.

See my work:
OTC Software
Offline EgonOlsen
« Reply #11 - Posted 2009-07-30 19:55:46 »

Ok, i've written a little test case based on the cube-sources from the SDK. You can find the modified sources here: http://www.jpct.net/download/misc/android_test.zip. To run it, you'll have to replace the texture with some other of yours (line 155 in CubeRenderer). It renders two textured and statically lit cubes. Run it with the phone turned upright, so that both cubes fill the whole screen. On my phone, it "runs" with 10fps that way.

Offline kevglass

« JGO Spiffy Duke »


Medals: 208
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #12 - Posted 2009-07-30 20:02:56 »

60 fps here in log cat here.

HTC Hero (TMobile G2 Touch)
Android 1.5

Kev

Offline kevglass

« JGO Spiffy Duke »


Medals: 208
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #13 - Posted 2009-07-30 20:11:48 »

Should add the textures look odd though. Colours don't look right and texture mapping seems wrong?

Kev

Offline kevglass

« JGO Spiffy Duke »


Medals: 208
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #14 - Posted 2009-07-30 20:17:40 »

For interest it also crashed (and hung out the phone) once I tried to rotate the screen back.

Kev

Offline EgonOlsen
« Reply #15 - Posted 2009-07-30 20:34:38 »

Should add the textures look odd though. Colours don't look right and texture mapping seems wrong?
Colors are taken directly from the cube example, texture coordinates are more or less random. I had that crash too once, but i really don't care. It's simply a modified cube-example...all i did was to add the texture loading and -rendering stuff.
60 fps is with a texture loaded and the phone upright?

Offline Ranger
« Reply #16 - Posted 2009-07-30 21:12:24 »

Re: egl.eglTerminate(dpy);

I've no idea where to put this and i don't think that i need it, when using a GLSurfaceView. I've based my stuff on this example: http://android-developers.blogspot.com/2009/04/introducing-glsurfaceview.html...anyway, maybe we should move this discussion back into the other thread: http://www.java-gaming.org/topics/hardware-acceleration/20910/view.html

My phone is still on Android 1.1, and I wanted to make my game 1.1 compatible, so I had to do all the eglCreateContext, eglCreateWindowSurface, eglMakeCurrent, ... and at the end eglDestroySurface, eglDestroyContext, and finally eglTerminate.  By the look of it, this is all now handled for you in Android 1.5.
Offline EgonOlsen
« Reply #17 - Posted 2009-07-30 21:16:27 »

Re: egl.eglTerminate(dpy);

My phone is still on Android 1.1, and I wanted to make my game 1.1 compatible, so I had to do all the eglCreateContext, eglCreateWindowSurface, eglMakeCurrent, ... and at the end eglDestroySurface, eglDestroyContext, and finally eglTerminate.  By the look of it, this is all now handled for you in Android 1.5.
I see. I've removed all that 1.1 related stuff from my code. The way 1.5 does it is waaaay easier to use.

Offline Ranger
« Reply #18 - Posted 2009-07-30 21:40:26 »

I see. I've removed all that 1.1 related stuff from my code. The way 1.5 does it is waaaay easier to use.

Very true.  One advantage of the old way, is I can see what is taking all the time.  And I can tell you, in the Android framework, when it wants to push the update to the OpenGL chip, it calls:
1  
egl.eglSwapBuffers(dpy, surface);

And this, on my game anyway, takes a minimum of 6ms, but it is not uncommon for it to take 15ms!

If you haven't seen it already.  A Google Android game developer gave a presentation about writing games for Android at the last Google I/O.  I found his talk very helpful:  http://www.youtube.com/watch?v=U4Bk5rmIpic
Offline EgonOlsen
« Reply #19 - Posted 2009-07-31 19:46:51 »

Very true.  One advantage of the old way, is I can see what is taking all the time.  And I can tell you, in the Android framework, when it wants to push the update to the OpenGL chip, it calls:
1  
egl.eglSwapBuffers(dpy, surface);

And this, on my game anyway, takes a minimum of 6ms, but it is not uncommon for it to take 15ms!
Ok, but if, as in my example, the rendering of one frame alone takes 100ms, it doesn't really matter. I still don't get it...if the test case runs @60fps on kev's HTC Hero, it obviously uses the GPU on that device. But the Hero uses (according to HTC's hoempage) the exact same chipset as the Samsung Galaxy does (Qualcomm® MSM7200A™, 528 MHz). The Samsung also does hardware 3D when running Omnigsoft's games or the Neocore demo...it just doesn't seem to be able to use it in combination with the Dalvik VM. Why is that and who has to do what to change this? Can i do something about it? Or Samsung? Or Google? I got this phone solely for doing 3D on it and now i obviously got the only phone that can't do it correctly...this is so annoying.

Offline Ranger
« Reply #20 - Posted 2009-07-31 21:10:10 »

Ok, but if, as in my example, the rendering of one frame alone takes 100ms, it doesn't really matter. I still don't get it...if the test case runs @60fps on kev's HTC Hero, it obviously uses the GPU on that device. But the Hero uses (according to HTC's hoempage) the exact same chipset as the Samsung Galaxy does (Qualcomm® MSM7200A™, 528 MHz). The Samsung also does hardware 3D when running Omnigsoft's games or the Neocore demo...it just doesn't seem to be able to use it in combination with the Dalvik VM. Why is that and who has to do what to change this? Can i do something about it? Or Samsung? Or Google? I got this phone solely for doing 3D on it and now i obviously got the only phone that can't do it correctly...this is so annoying.
Sorry, I gave a bit too much information and didn't explain my point at all.  I was thinking if you ran one of the OpenGL examples from Android 1.1 (the Kube demo is a good one), you could put timings in around eglSwapBuffers to see if that is sucking up all the time.  If it is not that, you can then work out what it is (In Android 1.1, you have control of the draw loop.  In the Kube demo, the draw loop is in GLSurfaceView.java GLThread.guardedRun()).  If it turns out to be eglSwapBuffers, I'd recommend posting a message on http://groups.google.com/group/android-developers to see what Google says.  Just an idea, it is definitely odd.  Oh, and when you output your timings, use the Log class (apparently, using System.out.println is really slow).
Offline EgonOlsen
« Reply #21 - Posted 2009-07-31 21:30:43 »

It's not caused by eglSwapBuffers or something like that. The problem is that everything runs in software mode and that consumes all the time. Even your game runs in software mode when enabling OpenGL (judging from the console output). It's just that the software mode is fast enough to handle that game. I've ported one of my example programs (a simple fps world based on a pretty simple and low poly Quake3 level) for jPCT. If i do all computations and GL-calls but omit the final call to glDrawElements, i get 40-50fps on the phone. If i add the glDrawElements-call, i get 3-5fps(!!)...and that's just for one single reason: It runs in software emulation mode even when the device could do better as it shows in the Neocore demo....and i have no idea why!?
Another indicator for software mode: The current software emulation of 1.5 has a confirmed bug in the lighting code. Lights are not transformed correctly, so vertex lighting is all screwed up in the emulation. This happens in the emulator (of course). On a real device using a real GPU, it looks fine. On the Samsung, it's all screwed up too...because, again, it uses software emulation. If it wouldn't be a pretty nifty device apart from that flaw, i would have already thrown it out of the window...

Offline Ranger
« Reply #22 - Posted 2009-07-31 21:44:09 »

Well, my game does not run properly on the Android emulator (both 1.1 and 1.5) with OpenGL.  So I don't know why it would run ok on the Samsung if it was using software rendering.
Offline princec

« JGO Spiffy Duke »


Medals: 422
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #23 - Posted 2009-07-31 23:22:23 »

Best get on the phone to Samsung and be asking them, for I expect they have the answers....

Cas Smiley

Offline EgonOlsen
« Reply #24 - Posted 2009-08-01 18:57:51 »

Well, my game does not run properly on the Android emulator (both 1.1 and 1.5) with OpenGL.  So I don't know why it would run ok on the Samsung if it was using software rendering.
No idea, but i'm pretty sure that it does, because it prints out these scanline messages like the emulator does. The software renderer seems to assemble an optimized scanline renderer for each texture/mode. You can easily see this when adding more textures with different blending modes. Every new combination causes a new log entry. And you only need a scanline renderer when doing software rendering...i should know, i did that long enough.
Do you know a way to query the gl driver for its or the chipsets name? That would clear things up.

About contacting Samsung: i'll do so in two weeks when i'm back from vacation...i'm posting this on the phone right now...pretty hard...Smiley

Offline Ranger
« Reply #25 - Posted 2009-08-02 03:40:40 »

Brilliant idea!  So I did this:
1  
2  
3  
Log.v("CraigsRace", "OpenGL Vendor:     "+gl.glGetString(GL10.GL_VENDOR));
Log.v("CraigsRace", "OpenGL Renderer:   "+gl.glGetString(GL10.GL_RENDERER));
Log.v("CraigsRace", "OpenGL Version:    "+gl.glGetString(GL10.GL_VERSION));


On the Android Emulator I got this:
1  
2  
3  
08-02 13:34:55.396: VERBOSE/CraigsRace(770): OpenGL Vendor:     Android
08-02 13:34:55.416: VERBOSE/CraigsRace(770): OpenGL Renderer:   Android PixelFlinger 1.0
08-02 13:34:55.426: VERBOSE/CraigsRace(770): OpenGL Version:    OpenGL ES-CM 1.0


On my G1 I got this:
1  
2  
3  
08-02 13:35:45.600: VERBOSE/CraigsRace(16375): OpenGL Vendor:     QUALCOMM, Inc.
08-02 13:35:45.620: VERBOSE/CraigsRace(16375): OpenGL Renderer:   Q3Dimension MSM7500 01.02.08 0 4.0.0
08-02 13:35:08.520: VERBOSE/CraigsRace(16334): OpenGL Version:    OpenGL ES 1.0-CM

Offline EgonOlsen
« Reply #26 - Posted 2009-08-02 07:02:14 »

Great. Is there some way for me to try it on the phone and how do i get the console output without attaching the phone to s pc (which i can't do atm)...  Huh

Offline Nate

« JGO Bitwise Duke »


Medals: 158
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #27 - Posted 2009-08-04 19:02:35 »

Good idea. On my G1 I got the same as Ranger.

Offline kevglass

« JGO Spiffy Duke »


Medals: 208
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #28 - Posted 2009-08-04 19:09:36 »

HTC Hero:

Quote
08-04 20:07:53.331: VERBOSE/CraigsRace(2811): OpenGL Vendor:     QUALCOMM, Inc.
08-04 20:07:53.341: VERBOSE/CraigsRace(2811): OpenGL Renderer:   Q3Dimension MSM7500 01.02.08 0 4.0.0
08-04 20:07:53.351: VERBOSE/CraigsRace(2811): OpenGL Version:    OpenGL ES 1.0-CM

Kev

Offline EgonOlsen
« Reply #29 - Posted 2009-08-15 20:55:01 »

I back from vacation and finally had the chance to try it. This is the code i was using (derived from a simple example from google):

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  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
package com.threed.jpct.example;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

import android.app.Activity;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.util.Log;

public class TestActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mGLView = new GLSurfaceView(this);
        mGLView.setRenderer(new TestRenderer());
        setContentView(mGLView);
    }

    @Override
    protected void onPause() {
        super.onPause();
        mGLView.onPause();
    }

    @Override
    protected void onResume() {
        super.onResume();
        mGLView.onResume();
    }

    private GLSurfaceView mGLView;
}

class TestRenderer implements GLSurfaceView.Renderer {
   
   private boolean printed=false;
   private int fps=0;
   private long time=System.currentTimeMillis();
   
    public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    }

    public void onSurfaceChanged(GL10 gl, int w, int h) {
        gl.glViewport(0, 0, w, h);
    }

    public void onDrawFrame(GL10 gl) {
        gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
       
        if (System.currentTimeMillis()-time>=1000) {
           time=System.currentTimeMillis();
           Log.i("TestRenderer", fps+"fps");
           fps=0;
        }
       
        if (!printed) {
           printed=true;
           Log.i("TestRenderer", "OpenGL Vendor:     "+gl.glGetString(GL10.GL_VENDOR));
           Log.i("TestRenderer", "OpenGL Renderer:   "+gl.glGetString(GL10.GL_RENDERER));
           Log.i("TestRenderer", "OpenGL Version:    "+gl.glGetString(GL10.GL_VERSION));
        }
        fps++;
    }
}


And this is what the phone says (like i expected):

1  
2  
3  
08-15 22:44:04.915: INFO/TestRenderer(4740): OpenGL Vendor:     Android
08-15 22:44:04.915: INFO/TestRenderer(4740): OpenGL Renderer:   Android PixelFlinger 1.0
08-15 22:44:04.925: INFO/TestRenderer(4740): OpenGL Version:    OpenGL ES-CM 1.0


That code runs @56fps on the phone.

So the situation is, that the Samsung can do 3D (as proofed by the Neocore demo and Omnigsofts race games) but inside the Dalvik VM, it does software rendering in all its glory. I'll try to contact Samsung about this...i can't wait to receive a nonsense response from an underpaid and overworked hotliner who didn't even understand my problem...stay tuned!

Edit: I've written an support request...it started out very promising: I couldn't even select my phone from their list...

Pages: [1] 2
  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.

toopeicgaming1999 (58 views)
2014-11-26 15:22:04

toopeicgaming1999 (52 views)
2014-11-26 15:20:36

toopeicgaming1999 (10 views)
2014-11-26 15:20:08

SHC (24 views)
2014-11-25 12:00:59

SHC (24 views)
2014-11-25 11:53:45

Norakomi (27 views)
2014-11-25 11:26:43

Gibbo3771 (24 views)
2014-11-24 19:59:16

trollwarrior1 (37 views)
2014-11-22 12:13:56

xFryIx (76 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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
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!