Hardware acceleration?

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.

60 fps here in log cat here.

HTC Hero (TMobile G2 Touch)
Android 1.5

Kev

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

Kev

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

Kev

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?

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.

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:

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

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).

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…

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.

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

Cas :slight_smile:

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…:slight_smile:

Brilliant idea! So I did this:

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:

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:

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

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)… ???

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

HTC Hero:

Kev

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):


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):


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…

Update: Got a mail from Samsung that they have send the request to the responsible division…took them over a week to do so… ???