I've quickly skimmed over your code and noticed a few things:

- in setup_scene, it seems that you call initialise_cube for each
position, so you create 121 batches (and display lists) containing one
cube, but only the last one gets stored in the global variable (but
this shouldn't affect the performance, it's just wasted work)

- in your render function, you draw the batch for each cube separately
- this amounts to 121 draw calls, each only drawing a single cube (and
possibly the vertex buffer for the batch gets rebound for each draw
call too, which can be expensive)

The idea of batches is to draw as much geometry as possible in a
single draw call, so I guess you would get much better performance if
you put all your cubes into a single batch and draw them with a single
draw call.
Your current way of rendering might be acceptable if you have some
complex geometry in each batch, but I think the cube is just too
simple to take advantage of batched rendering - the overhead of the
batch is probably bigger than the actual render work.


On Thu, Sep 6, 2012 at 4:07 AM, Adam Griffiths
<[email protected]> wrote:
> I'm running Pyglet on OS-X (previously 10.7 and now 10.8).
> The entire time I've been developing, I've found using Pyglet's Batch
> objects to be horrendously slow.
>
> I have a demo program (it uses my framework PyGLy and Pyrr) which shows
> this.
> https://github.com/adamlwgriffiths/PyGLy/tree/master/examples/render_methods
>
> The example renders 121 transparent cubes and allows you to toggle between
> render methods (Immediate, Batch, DL).
> It also disables VSync and runs the render method as fast as possible
>
> I get the following results:
>
> OpenGL immediate mode: 38 fps
> pyglet.graphics.Batch: 51 fps
> OpenGL Display List: 99 fps
>
> In my other demos (mesh_md2) using Batch made the performance drop to 10
> fps.
>
> Is this a known issue?
>
> I see bug #314 was closed due to age. I have a feeling it wasn't really
> resolved.
> http://code.google.com/p/pyglet/issues/detail?id=314
>
> Cheers,
> Adam
>
> --
> You received this message because you are subscribed to the Google Groups
> "pyglet-users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/pyglet-users/-/dtmgnj7yn60J.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/pyglet-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pyglet-users?hl=en.

Reply via email to