Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  FloatBuffers killing Vertex Array performance?  (Read 1534 times)
0 Members and 1 Guest are viewing this topic.
Offline Jacko

Junior Member





« Posted 2003-10-06 02:01:41 »

Has anyone out there run into something like this?

I'm trying to build my renderer from the ground up to use vertex arrays for all rendering. I'm getting a big chunk of agp memory using the nvidia extension and splitting it into 2 vertex arrays. When one fills, or runs out of data, I set a fence and swap to using the other vertex array. I think that this should in theory give me pretty optimal vertex submission, as the GPU can chew over what I've just sent it while I'm filling the other buffer.

That was the theory anyway....

When I come to run it I can get about 50 fps with 4000 triangles on screen. When I profile to see wtf is going on, it's spending 50% of its time copying into the floatbuffer that is used for the vertex array!!

Now I'm only running a GF2 but it seems like a long way off the pace to me, when something like benmark is doing in the order of 30 or 40 times that.

I am just using drawArrays which seems to be discouraged, and just drawing random triangles could be a pretty pathological case but does anyone have any ideas?
Offline princec

JGO Kernel


Medals: 282
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #1 - Posted 2003-10-06 08:46:16 »

Post up the -Xprof output.
Drawing random triangles is a pathological case, and indeed, the worst possible use.
You should be able to get performance identical to C with float buffers.

Cas Smiley

Offline abies

Senior Member





« Reply #2 - Posted 2003-10-06 09:05:24 »

Please try using display lists and check how many fps you will get with them.

It is perfectly possible to get any number of frames with any number of triangles. I have managed to get few fps per second with 256 quads - they were just occuping entire screen each, sorted in worst order...

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

Junior Member




I love my Java


« Reply #3 - Posted 2003-10-13 15:54:20 »

Hi,`

Can someone post some VertexArray usage Code, im not sure how to get this working, using plain OpenGL 1.1 code.

My problems are occure if i call
GL.glDrawElements(GL.GL_QUADS,indexesBuffer);

Mostly the VM crashed if i try to Draw the Elements with a given array. Also i flip the Buffer before calling DrawElements !

- jens




The Network is the Music
http://www.mac-systems.de
Offline Mojomonkey

Senior Member




ooh ooh eee eeee


« Reply #4 - Posted 2003-10-13 15:57:21 »

Jacko - make sure you aren't creating the float buffer each frame. Create it once, then clear/put/flip each frame.

Mac-Systems - I can give you some code if you want. E-mail?

Don't send a man to do a monkey's work.
Offline Mojomonkey

Senior Member




ooh ooh eee eeee


« Reply #5 - Posted 2003-10-13 16:52:33 »

Here's the method of my renderer that handles rendering of meshes. This uses Vertex Arrays. Perhaps this can help you out. TriMesh is a class that contains all the buffers.

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  
66  
67  
68  
69  
70  
71  
/**
     * <code>draw</code> renders a <code>TriMesh</code> object including it's
     * normals, colors, textures and vertices.
     * @see com.jme.renderer.Renderer#draw(com.jme.scene.TriMesh)
     * @param t the mesh to render.
     */

    public void draw(TriMesh t) {
        // set world matrix
       Matrix3f rotation = t.getWorldRotation();
        Vector3f translation = t.getWorldTranslation();
        float scale = t.getWorldScale();
        float[] modelToWorld =
            {
                scale * rotation.get(0, 0),
                scale * rotation.get(1, 0),
                scale * rotation.get(2, 0),
                0.0f,
                scale * rotation.get(0, 1),
                scale * rotation.get(1, 1),
                scale * rotation.get(2, 1),
                0.0f,
                scale * rotation.get(0, 2),
                scale * rotation.get(1, 2),
                scale * rotation.get(2, 2),
                0.0f,
                translation.x,
                translation.y,
                translation.z,
                1.0f };

        GL.glMatrixMode(GL.GL_MODELVIEW);
        GL.glPushMatrix();
        worldBuffer.clear();
        worldBuffer.put(modelToWorld);
        worldBuffer.flip();
        GL.glMultMatrixf(worldBuffer);

        // render the object

        GL.glVertexPointer(3, 0, t.getVerticeAsFloatBuffer());
        GL.glEnableClientState(GL.GL_VERTEX_ARRAY);

        FloatBuffer afNormals = t.getNormalAsFloatBuffer();
        if (afNormals != null) {
            GL.glEnableClientState(GL.GL_NORMAL_ARRAY);
            GL.glNormalPointer(0, afNormals);
        } else {
            GL.glDisableClientState(GL.GL_NORMAL_ARRAY);
        }

        FloatBuffer afColors = t.getColorAsFloatBuffer();
        if (afColors != null) {
            GL.glEnableClientState(GL.GL_COLOR_ARRAY);
            GL.glColorPointer(4, 0, afColors);
        } else {
            GL.glDisableClientState(GL.GL_COLOR_ARRAY);
        }

        FloatBuffer afTextures = t.getTextureAsFloatBuffer();
        if (afTextures != null) {
            GL.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY);
            GL.glTexCoordPointer(2, 0, afTextures);
        } else {
            GL.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY);
        }

        GL.glDrawElements(GL.GL_TRIANGLES, t.getIndexAsBuffer());

        GL.glMatrixMode(GL.GL_MODELVIEW);
        GL.glPopMatrix();
    }

Don't send a man to do a monkey's work.
Offline Mac_Systems

Junior Member




I love my Java


« Reply #6 - Posted 2003-10-13 18:10:57 »

Interresting ...

you made a call

GL.glVertexPointer(3, 0, t.getVerticeAsFloatBuffer());
GL.glEnableClientState(GL.GL_VERTEX_ARRAY);

..i thought the glEnableClientState should be called
before glVertexPointer...

thx,
Jens


The Network is the Music
http://www.mac-systems.de
Offline Mojomonkey

Senior Member




ooh ooh eee eeee


« Reply #7 - Posted 2003-10-13 18:25:56 »

The only order that is important is that the states are enabled before the call to glDrawElements

Don't send a man to do a monkey's work.
Offline Mac_Systems

Junior Member




I love my Java


« Reply #8 - Posted 2003-10-14 15:03:58 »

Simple Question:

GL.glVertexPointer(3, 0, t.getVerticeAsFloatBuffer());

You are drawing Triangles ?

- Jens

The Network is the Music
http://www.mac-systems.de
Offline Mojomonkey

Senior Member




ooh ooh eee eeee


« Reply #9 - Posted 2003-10-14 15:08:00 »

yes

GL.glDrawElements(GL.GL_TRIANGLES, t.getIndexAsBuffer());

Don't send a man to do a monkey's work.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Mac_Systems

Junior Member




I love my Java


« Reply #10 - Posted 2003-10-14 16:33:31 »

Ok,
my problem was that had some parameter problems, mostly because the Syntax differs a bit from the Orginal GL Method. So i  called it with some other parameters.

Fazit: We need some better Docu, but this should be allready in work, if i understood princec and Matzon right ?

- Jens

The Network is the Music
http://www.mac-systems.de
Pages: [1]
  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.

xsi3rr4x (53 views)
2014-04-15 18:08:23

BurntPizza (51 views)
2014-04-15 03:46:01

UprightPath (65 views)
2014-04-14 17:39:50

UprightPath (47 views)
2014-04-14 17:35:47

Porlus (65 views)
2014-04-14 15:48:38

tom_mai78101 (89 views)
2014-04-10 04:04:31

BurntPizza (149 views)
2014-04-08 23:06:04

tom_mai78101 (245 views)
2014-04-05 13:34:39

trollwarrior1 (203 views)
2014-04-04 12:06:45

CJLetsGame (210 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!