Forgot to add that the monkeypatch appears to be around 10 - 20x faster for 
a large vertex list

On Sunday, May 4, 2014 10:21:10 PM UTC-4, Damien Moore wrote:
>
> Thanks, that's what I suspected.
>
> My workaround is to use a single vertexlist per sector of the map. This is 
> much faster, but there's still a bit of a bottleneck copying the texture 
> data into the batch when using batch.add because of the way 
> IndirectArrayRegion works. I used the following workaround (monkey patch)...
>
> orig_indirect_array_region_setitem__ = 
> pyglet.graphics.vertexbuffer.IndirectArrayRegion.__setitem__
> def numpy__setitem__(self, index, value):
>     if isinstance(value, numpy.ndarray) and isinstance(index, slice) \
>           and index.start is None and index.stop is None and index.step is 
> None:
>         arr = numpy.ctypeslib.as_array(self.region.array)
>         for i in range(self.count):
>             arr[i::self.stride] = value[i::self.count]
>         return
>     orig_indirect_array_region_setitem__(self, index, value)
> pyglet.graphics.vertexbuffer.IndirectArrayRegion.__setitem__ = 
> numpy__setitem__
>
>
> On Friday, May 2, 2014 7:17:47 PM UTC-4, Richard Jones wrote:
>>
>> Python function calls are slow. Throw in ctypes for extra slowness. 
>> There's really nothing you can do except limit the number of calls.
>>
>> Sent from my mobile - please excuse any brevity.
>> On 3 May 2014 00:27, "Damien Moore" <[email protected]> wrote:
>>
>>> I dont think the profiler will tell me much other than looping through 
>>> lists of objects in python is slow (which is why I am using numpy). I think 
>>> the problem is that, in a typical scene, there are about 10000 voxels each 
>>> with quads that need to be drawn. 10000 calls of batch.add with all the 
>>> python object creation (e.g. domain.create) that goes with it is just slow. 
>>> I think I will just use gl drawarray calls and avoid batches altogether for 
>>> this part of the code.
>>>
>>> --
>>> You received this message because you are subscribed to the Google 
>>> Groups "pyglet-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at http://groups.google.com/group/pyglet-users.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to