diff --git a/doc/source/misc.rst b/doc/source/misc.rst index bad0cf5c0cbc18de5661d51776657c31fccda8e3..0b06f9426049a9202a2d117a095018b6de680bbe 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 8a0b91761d4ed33e7db7f13520302921cbdb6acc..caa215e3f34bc8eea8d60021042176bf9d432d9a 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 75ebe35039999ad6c7a380d4d7c2c776f8a4a58f..d8bfcb80c1bc5eed7635927263aae5d252b960e2 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 8c03a9b0617d4b9114da65e6857210e8a0d3d34f..19f77a5e5ffda56da26cc2ef56cf778702a23a4d 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 83c81b6eaf024162629443c21eb1276a77edf59b..b2d39f7d2bca66beb4d917c4c94559d2f2e638b3 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__ + +