From dfbae28c58db156e928c84a676c8290a3deec72f Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Sat, 12 Sep 2009 04:36:04 -0400 Subject: [PATCH] Doc updates. Add ImageFormat() constructor as suggested by David Garcia. --- doc/source/misc.rst | 4 +++- doc/source/reference.rst | 21 ++++++++++++++++++++- src/wrapper/wrap_cl.cpp | 1 + src/wrapper/wrap_cl.hpp | 8 ++++++++ test/test_wrapper.py | 8 ++++++++ 5 files changed, 40 insertions(+), 2 deletions(-) diff --git a/doc/source/misc.rst b/doc/source/misc.rst index bad0cf5c..0b06f942 100644 --- a/doc/source/misc.rst +++ b/doc/source/misc.rst @@ -16,6 +16,7 @@ User-visible Changes Version 0.91 ------------ +* Add :ref:`gl-interop`. * Add a test suite. * Fix numerous `get_info` bugs. (reports by David Garcia and the test suite) * Add :meth:`pyopencl.ImageFormat.__repr__`. @@ -30,7 +31,8 @@ Version 0.91 * :meth:`pyopencl.MemoryObject.get_image_info` now actually exists. * Add :attr:`pyopencl.MemoryObject.image.info`. * Fix API tracing. -* Add :ref:`gl-interop`. +* Add constructor arguments to :class:`pyopencl.ImageFormat`. + (suggested by David Garcia) Version 0.90.4 -------------- diff --git a/doc/source/reference.rst b/doc/source/reference.rst index 8a0b9176..caa215e3 100644 --- a/doc/source/reference.rst +++ b/doc/source/reference.rst @@ -194,6 +194,8 @@ Memory See :class:`image_info` for values of *param*. + .. versionadded:: 0.91 + .. attribute:: info Lower case versions of the :class:`mem_info` constants @@ -248,7 +250,10 @@ Buffers Image Formats ^^^^^^^^^^^^^ -.. class:: ImageFormat +.. class:: ImageFormat([channel_order, channel_type]) + + .. versionchanged:: 0.91 + Constructor arguments added. .. attribute:: channel_order @@ -277,19 +282,31 @@ Images See :class:`mem_flags` for possible values of *flags*. Returns a new image-type :class:`MemoryObject`. + .. versionchanged:: 0.91 + *pitch* argument defaults to zero, moved. + .. function:: create_image_3d(context, flags, format, width, height, depth, row_pitch=0, slice_pitch=0, host_buffer=None) See :class:`mem_flags` for possible values of *flags*. Returns a new image-type :class:`MemoryObject`. + .. versionchanged:: 0.91 + *pitch* arguments defaults to zero, moved. + .. function:: enqueue_read_image(queue, mem, origin, region, host_buffer, row_pitch=0, slice_pitch=0, wait_for=None, is_blocking=False) |enqueue-waitfor| + .. versionchanged:: 0.91 + *pitch* arguments defaults to zero, moved. + .. function:: enqueue_write_image(queue, mem, origin, region, host_buffer, row_pitch=0, slice_pitch=0, wait_for=None, is_blocking=False) |enqueue-waitfor| + .. versionchanged:: 0.91 + *pitch* arguments defaults to zero, moved. + .. function:: enqueue_copy_image(queue, src, dest, src_origin, dest_origin, region, wait_for=None) |enqueue-waitfor| @@ -430,6 +447,8 @@ GL Interoperability Functionality in this section is only available when PyOpenCL is compiled with GL support. See :func:`have_gl`. +.. versionadded:: 0.91 + .. function:: have_gl() Return *True* if PyOpenCL was compiled with OpenGL interoperability, otherwise *False*. diff --git a/src/wrapper/wrap_cl.cpp b/src/wrapper/wrap_cl.cpp index 75ebe350..d8bfcb80 100644 --- a/src/wrapper/wrap_cl.cpp +++ b/src/wrapper/wrap_cl.cpp @@ -503,6 +503,7 @@ BOOST_PYTHON_MODULE(_cl) { typedef cl_image_format cls; py::class_<cls>("ImageFormat") + .def("__init__", py::make_constructor(make_image_format)) .def_readwrite("channel_order", &cls::image_channel_order) .def_readwrite("channel_data_type", &cls::image_channel_data_type) ; diff --git a/src/wrapper/wrap_cl.hpp b/src/wrapper/wrap_cl.hpp index 8c03a9b0..19f77a5e 100644 --- a/src/wrapper/wrap_cl.hpp +++ b/src/wrapper/wrap_cl.hpp @@ -1145,6 +1145,14 @@ namespace pyopencl // images ------------------------------------------------------------------- + cl_image_format *make_image_format(cl_channel_order ord, cl_channel_type tp) + { + std::auto_ptr<cl_image_format> result(new cl_image_format); + result->image_channel_order = ord; + result->image_channel_data_type = tp; + return result.release(); + } + py::list get_supported_image_formats( context const &ctx, cl_mem_flags flags, diff --git a/test/test_wrapper.py b/test/test_wrapper.py index 83c81b6e..b2d39f7d 100644 --- a/test/test_wrapper.py +++ b/test/test_wrapper.py @@ -141,6 +141,14 @@ class TestCL: except AttributeError: pass + def test_image_format_constructor(self): + iform = cl.ImageFormat(cl.channel_order.RGBA, cl.channel_type.FLOAT) + + assert iform.channel_order == cl.channel_order.RGBA + assert iform.channel_data_type == cl.channel_type.FLOAT + assert not iform.__dict__ + + -- GitLab