Re: [PyOpenGL-Users] Pointer functions copying memory.
Brought to you by:
mcfletch
From: <il...@ya...> - 2003-02-03 21:36:22
|
I didn't know the buffer api was dying. Glad to find out now. Maybe we could get the thing to raise an exception, or print a warning if prefered. It would raise every time there is memory copied. The exception should definitely be an option, defaulting to not raising. Something like OpenGL.raise_error_on_memory_copy = 1 Or maybe we could get it to do that in debugging mode? Your suggestion of a function to return a contiguous array to the user could be good. So they could save it for future passes of the same data. Some opengl functions can use stride arguments. eg most of the gl*Pointer functions. So maybe we could do some automagical things for eg glVertexPointerd(x) to use the correct stride if possible. ps, the float versions of these functions are often quite faster, if you are careful with numeric casting. --- "Mike C. Fletcher" <mcf...@ro...> wrote: > The biggest problem I see is that the buffer API is > loosely considered > deprecated. BTW I could've sworn that we were > already using the > PyArray_ functions to get contiguous array > pointers... > > See the NUMERIC_PyObject_As macro in > interface_util.c, as far as I'm > aware, this should be getting used everywhere. > However, if I understand > the mechanism behind the > (PyArrayObject*)PyArray_ContiguousFromObject(source, > TYPECODE | > SAVESPACEBIT, 0, 0); function, it's going to do a > copy of the source > array is not contiguous, which would give us the > copying overhead we're > seeing. > > What I would prefer to see (instead of using a > pseudo-deprecated API, or > using functions to access the non-contiguous array > (which likely won't > work for OpenGL, as I believe it requires a true > contiguous array)) is a > function that, given a Numeric array, returns a > contiguous version of > that array to Python (or raises a memory error if > it's not possible). > That should, if I understand correctly, make > further > PyArray_ContiguousFromObject calls on the > _resulting_ array null > operations. The "problem" being that the current > code doesn't modify > the Python pointer to the array to point to the new, > contiguous array > (and obviously it shouldn't do so in the middle of > an OpenGL call), so > the effort isn't saved between rendering passes. > > Just my thoughts, > Mike > > > Rene Dudfield wrote: > > >Hi, > > > >I had a look at the pointer functions and it > appears > >they copy memory before passing it to the gl > function, > >making them quite slow. > > > >I was thinking of using the buffer api instead. > > > >http://python.org/doc/current/api/bufferObjects.html > > > >Not sure if numeric supports it. If it doesn't > I'll > >use the PyArray_ContiguousFromObject functions. > > > > > >Any thoughts on this? Any compatibility problems > with > >the buffer api? > > > > > > __________________________________________________ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com |