Dnia 2010-11-26, piÄ… o godzinie 14:52 -0500, Andreas Kloeckner pisze: > Hi Tomasz, > > I've committed your patch, with a few changes. > > git diff 69a355d0 master > > will show you what I changed. Some comments below. I'd appreciate your > feedback on my changes. > > Thanks for your contribution, > Andreas >
I like those changes, but there are still some problems.
The fist problem is that you have left old names in pycuda/gl/__init.py:
$ ./cuda.py
/usr/lib/pymodules/python2.6/pycuda/driver.py:2: RuntimeWarning:
to-Python converter for CUgraphicsMapResourceFlags_enum already
registered; second conversion method ignored.
from pycuda._driver import *
Traceback (most recent call last):
File "./cuda.py", line 13, in <module>
import pycuda.gl
File "/usr/lib/pymodules/python2.6/pycuda/gl/__init__.py", line 8, in
<module>
map_flags = _drv.map_flags
AttributeError: 'module' object has no attribute 'map_flags'
$ ./cuda.py
/usr/lib/pymodules/python2.6/pycuda/driver.py:2: RuntimeWarning:
to-Python converter for CUgraphicsMapResourceFlags_enum already
registered; second conversion method ignored.
from pycuda._driver import *
Traceback (most recent call last):
File "./cuda.py", line 13, in <module>
import pycuda.gl
File "/usr/lib/pymodules/python2.6/pycuda/gl/__init__.py", line 9, in
<module>
target_flags = _drv.target_flags
AttributeError: 'module' object has no attribute 'target_flags
The second problem is with the map function:
$ ./cuda.py
Traceback (most recent call last):
File "./cuda.py", line 103, in paintGL
cuda_object = self.cuda_buffer.map()
Boost.Python.ArgumentError: Python argument types in
RegisteredObject.map(RegisteredBuffer)
did not match C++ signature:
map(boost::shared_ptr<cuda::gl::buffer_object>)
I do not know how to force Boost::Python to allow
for accepting optional argument for map(stream) function,
so I changed documentation to say that stream is mandatory
argument.
I attach the patch that solves those problems.
This patch also removes CUgraphicsMapResourceFlags from
src/wrapper/wrap_cudadrv.cpp - it was generating warning
seen above.
> On Wed, 24 Nov 2010 23:58:01 +0100, Tomasz Rybak <[email protected]> wrote:
> > Sending patch once again - it looks line not everyone received
> > previous email, and I got no feedback on patch.
> >
> > --
> > Tomasz Rybak <[email protected]> GPG/PGP key ID: 2AD5 9860
> > Fingerprint A481 824E 7DD3 9C0E C40A 488E C654 FB33 2AD5 9860
> > http://member.acm.org/~tomaszrybak
> > diff --git a/doc/source/gl.rst b/doc/source/gl.rst
> > index e5d196f..6d7b42c 100644
> > --- a/doc/source/gl.rst
> > +++ b/doc/source/gl.rst
> > @@ -19,6 +19,8 @@ GL Interoperability
> >
> > .. warning ::
> >
> > + This function is deprecated since CUDA 3.0 and PyCUDA 0.95.
> > +
> > This will fail with a rather unhelpful error message if you don't
> > already
> > have a GL context created and active.
> >
> > @@ -33,11 +35,43 @@ GL Interoperability
> > This will fail with a rather unhelpful error message if you don't
> > already
> > have a GL context created and active.
> >
> > +.. class :: map_flags
> > +
> > + Usage of OpenGL object from CUDA.
> > +
> > + .. attribute :: CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE
> > +
> > + Read and write access to mapped OpenGL object from CUDA code.
> > +
> > + .. attribute :: CU_GRAPHICS_MAP_RESOURCE_FLAGS_READ_ONLY
> > +
> > + Read only access to mapped OpenGL object from CUDA code.
> > +
> > + .. attribute :: CU_GRAPHICS_MAP_RESOURCE_FLAGS_WRITE_DISCARD
> > +
> > + Write only access to mapped OpenGL object from CUDA code. Reading
> > + is prohibited.
>
> Changed/shortened names.
OK.
>
> > +
> > +.. class :: map_targets
> > +
> > + Type of OpenGL Image object that is mapped to CUDA.
> > +
> > + .. attribute :: GL_TEXTURE_2D
> > + .. attribute :: GL_TEXTURE_RECTANGLE
> > + .. attribute :: GL_TEXTURE_CUBE_MAP
> > + .. attribute :: GL_TEXTURE_3D
> > + .. attribute :: GL_TEXTURE_2D_ARRAY
> > + .. attribute :: GL_RENDERBUFFER
> > +
>
> I'd argue these are the GL wrapper's business, since they're defined in
> the GL header. Removed.
>
> > .. class :: BufferObject(bufobj)
> >
> > .. method :: unregister()
> > .. method :: handle()
> > .. method :: map()
> > +
> > + .. warning ::
> > +
> > + This class is deprecated since CUDA 3.0 and PyCUDA 0.95.
> >
>
> I've made a nice separate section for the old-style API in the docs, so
> no-one uses it by accident.
OK - makes sense.
>
> > .. class :: BufferObjectMapping
> >
> > @@ -45,6 +79,33 @@ GL Interoperability
> > .. method :: device_ptr()
> > .. method :: size()
> >
> > + .. warning ::
> > +
> > + This class is deprecated since CUDA 3.0 and PyCUDA 0.95.
> > +
> > +.. class :: RegisteredBuffer(bufobj, flags =
> > CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE)
> > +
> > + Object managing mapping of OpenGL buffers to CUDA. Cannot be used to
> > + map images.
> > +
> > + .. method :: unregister()
> > + .. method :: handle()
> > + .. method :: map()
> > +
> > +.. class :: RegisteredImage(bufobj, target, flags =
> > CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE)
> > +
> > + Object managing mapping of OpenGL textures and render buffers to CUDA.
> > +
> > + .. method :: unregister()
> > + .. method :: handle()
> > + .. method :: map()
> > +
> > +.. class :: RegisteredMapping
> > +
> > + .. method :: unmap()
> > + .. method :: device_ptr()
> > + .. method :: size()
> > +
>
> Renamed handle() -> gl_handle() for clarity. Added stream arguments to
> map()/unmap(). Since Nvidia saw it fit to have a batch interface to
> map/unmap, we might need one at some point, too.
>
Yes - but maybe add some documentation for it, like in the new patch?
--
Tomasz Rybak <[email protected]> GPG/PGP key ID: 2AD5 9860
Fingerprint A481 824E 7DD3 9C0E C40A 488E C654 FB33 2AD5 9860
http://member.acm.org/~tomaszrybak
diff --git a/doc/source/gl.rst b/doc/source/gl.rst
index e8231bf..f0c2b7b 100644
--- a/doc/source/gl.rst
+++ b/doc/source/gl.rst
@@ -60,9 +60,11 @@ GL Interoperability
.. method :: gl_handle()
.. method :: unregister()
- .. method :: map(stream=None)
+ .. method :: map(stream)
- Return a :class:`RegisteredMapping`.
+ Return a :class:`RegisteredMapping`. Requires stream in which
+ mapping will be done; stream can be None, in which case mapping
+ will occur in the same stream object was created.
.. class :: RegisteredMapping
diff --git a/pycuda/gl/__init__.py b/pycuda/gl/__init__.py
index 9d518a5..af6a101 100644
--- a/pycuda/gl/__init__.py
+++ b/pycuda/gl/__init__.py
@@ -5,8 +5,7 @@ if not _drv.have_gl_ext():
init = _drv.gl_init
make_context = _drv.make_gl_context
-map_flags = _drv.map_flags
-target_flags = _drv.target_flags
+graphics_map_flags = _drv.graphics_map_flags
BufferObject = _drv.BufferObject
BufferObjectMapping = _drv.BufferObjectMapping
RegisteredBuffer = _drv.RegisteredBuffer
diff --git a/src/cpp/cuda_gl.hpp b/src/cpp/cuda_gl.hpp
index 1cfe4f8..668a2f3 100644
--- a/src/cpp/cuda_gl.hpp
+++ b/src/cpp/cuda_gl.hpp
@@ -159,6 +159,7 @@ namespace cuda { namespace gl {
// {{{ new-style (3.0+) API
+#if CUDAPP_CUDA_VERSION >= 3000
class registered_object : public context_dependent
{
protected:
@@ -307,6 +308,7 @@ namespace cuda { namespace gl {
return new registered_mapping(robj, strm);
}
+#endif
// }}}
diff --git a/src/wrapper/wrap_cudadrv.cpp b/src/wrapper/wrap_cudadrv.cpp
index 972f40f..35fa615 100644
--- a/src/wrapper/wrap_cudadrv.cpp
+++ b/src/wrapper/wrap_cudadrv.cpp
@@ -669,12 +669,6 @@ BOOST_PYTHON_MODULE(_driver)
.value("NONE", CU_GRAPHICS_REGISTER_FLAGS_NONE)
;
- py::enum_<CUgraphicsMapResourceFlags>("graphics_map_resource_flags")
- .value("NONE", CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE)
- .value("READ_ONLY", CU_GRAPHICS_MAP_RESOURCE_FLAGS_READ_ONLY)
- .value("WRITE_DISCARD", CU_GRAPHICS_MAP_RESOURCE_FLAGS_WRITE_DISCARD)
- ;
-
py::enum_<CUarray_cubemap_face_enum>("array_cubemap_face")
.value("POSITIVE_X", CU_CUBEMAP_FACE_POSITIVE_X)
.value("NEGATIVE_X", CU_CUBEMAP_FACE_NEGATIVE_X)
diff --git a/src/wrapper/wrap_cudagl.cpp b/src/wrapper/wrap_cudagl.cpp
index 30cef47..114eee9 100644
--- a/src/wrapper/wrap_cudagl.cpp
+++ b/src/wrapper/wrap_cudagl.cpp
@@ -24,6 +24,7 @@ void pycuda_expose_gl()
// {{{ new-style
+#if CUDAPP_CUDA_VERSION >= 3000
py::enum_<CUgraphicsMapResourceFlags>("graphics_map_flags")
.value("NONE", CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE)
.value("READ_ONLY", CU_GRAPHICS_MAP_RESOURCE_FLAGS_READ_ONLY)
@@ -35,7 +36,7 @@ void pycuda_expose_gl()
py::class_<cl, shared_ptr<cl> >("RegisteredObject", py::no_init)
.DEF_SIMPLE_METHOD(gl_handle)
.DEF_SIMPLE_METHOD(unregister)
- .def("map", map_buffer_object,
+ .def("map", map_registered_object,
py::return_value_policy<py::manage_new_object>())
;
}
@@ -64,6 +65,7 @@ void pycuda_expose_gl()
.DEF_SIMPLE_METHOD(device_ptr_and_size)
;
}
+#endif
// }}}
signature.asc
Description: This is a digitally signed message part
_______________________________________________ PyCUDA mailing list [email protected] http://lists.tiker.net/listinfo/pycuda
