… | |
… | |
558 | @OpenCL::Image1DArray::ISA = |
558 | @OpenCL::Image1DArray::ISA = |
559 | @OpenCL::Image1DBuffer::ISA = OpenCL::Image::; |
559 | @OpenCL::Image1DBuffer::ISA = OpenCL::Image::; |
560 | |
560 | |
561 | @OpenCL::UserEvent::ISA = OpenCL::Event::; |
561 | @OpenCL::UserEvent::ISA = OpenCL::Event::; |
562 | |
562 | |
563 | @OpenCL::MappedBuffer = |
563 | @OpenCL::MappedBuffer::ISA = |
564 | @OpenCL::MappedImage = OpenCL::Mapped::; |
564 | @OpenCL::MappedImage::ISA = OpenCL::Mapped::; |
565 | } |
565 | } |
566 | |
566 | |
567 | =head2 THE OpenCL PACKAGE |
567 | =head2 THE OpenCL PACKAGE |
568 | |
568 | |
569 | =over 4 |
569 | =over 4 |
… | |
… | |
1977 | copied. |
1977 | copied. |
1978 | |
1978 | |
1979 | When the object is destroyed it will enqueue an implicit unmap operation |
1979 | When the object is destroyed it will enqueue an implicit unmap operation |
1980 | on the queue that was used to create it. |
1980 | on the queue that was used to create it. |
1981 | |
1981 | |
|
|
1982 | Keep in mind that you I<need> to unmap (or destroy) mapped objects before |
|
|
1983 | OpenCL sees the changes, even if some implementations don't need this |
|
|
1984 | sometimes. |
|
|
1985 | |
1982 | Example, replace the first two floats in the mapped buffer by 1 and 2. |
1986 | Example, replace the first two floats in the mapped buffer by 1 and 2. |
1983 | |
1987 | |
1984 | my $mapped = $queue->map_buffer ($buf, ... |
1988 | my $mapped = $queue->map_buffer ($buf, ... |
1985 | $mapped->event->wait; # make sure it's there |
1989 | $mapped->event->wait; # make sure it's there |
1986 | |
1990 | |
… | |
… | |
1989 | # (and of course, we assume iee 754 single precision floats :) |
1993 | # (and of course, we assume iee 754 single precision floats :) |
1990 | substr $$mapped, 0, 8, pack "f*", 1, 2; |
1994 | substr $$mapped, 0, 8, pack "f*", 1, 2; |
1991 | |
1995 | |
1992 | =over 4 |
1996 | =over 4 |
1993 | |
1997 | |
|
|
1998 | =item $ev = $mapped->unmap ($wait_events...) |
|
|
1999 | |
|
|
2000 | Unmaps the mapped memory object, using the queue originally used to create |
|
|
2001 | it, quite similarly to C<< $queue->unmap ($mapped, ...) >>. |
|
|
2002 | |
1994 | =item $bool = $mapped->mapped |
2003 | =item $bool = $mapped->mapped |
1995 | |
2004 | |
1996 | Returns whether the object is still mapped - true before an C<unmap> is |
2005 | Returns whether the object is still mapped - true before an C<unmap> is |
1997 | enqueued, false afterwards. |
2006 | enqueued, false afterwards. |
1998 | |
2007 | |
… | |
… | |
2013 | |
2022 | |
2014 | =item $ptr = $mapped->ptr |
2023 | =item $ptr = $mapped->ptr |
2015 | |
2024 | |
2016 | Returns the raw memory address of the mapped area - same as C<$mapped+0>. |
2025 | Returns the raw memory address of the mapped area - same as C<$mapped+0>. |
2017 | |
2026 | |
|
|
2027 | =item $mapped->set ($offset, $data) |
|
|
2028 | |
|
|
2029 | Replaces the data at the given C<$offset> in the memory area by the new |
|
|
2030 | C<$data>. This method is safer but slower than direct manipulation of |
|
|
2031 | C<$$mapped> with substr. |
|
|
2032 | |
|
|
2033 | =item $data = $mapped->get ($offset, $length) |
|
|
2034 | |
|
|
2035 | Returns (without copying) a scalar representing the data at the given |
|
|
2036 | C<$offset> and C<$length> in the mapped memory area. This is the same as |
|
|
2037 | the following substr, except much slower: |
|
|
2038 | |
|
|
2039 | $data = substr $$mapped, $offset, $length |
|
|
2040 | |
|
|
2041 | #TODO: really? |
|
|
2042 | |
|
|
2043 | =cut |
|
|
2044 | |
|
|
2045 | sub get { |
|
|
2046 | substr ${$_[0]}, $_[1], $_[2] |
|
|
2047 | } |
|
|
2048 | |
2018 | =back |
2049 | =back |
2019 | |
2050 | |
2020 | =head2 THE OpenCL::MappedBuffer CLASS |
2051 | =head2 THE OpenCL::MappedBuffer CLASS |
2021 | |
2052 | |
2022 | This is a subclass of OpenCL::Mapped, representing mapped buffers. |
2053 | This is a subclass of OpenCL::Mapped, representing mapped buffers. |
2023 | |
2054 | |
|
|
2055 | =head2 THE OpenCL::MappedImage CLASS |
|
|
2056 | |
|
|
2057 | This is a subclass of OpenCL::Mapped, representing mapped images. |
|
|
2058 | |
2024 | =over 4 |
2059 | =over 4 |
2025 | |
2060 | |
2026 | =back |
2061 | =item $bytes = $mapped->row_pitch |
2027 | |
2062 | |
2028 | =head2 THE OpenCL::MappedImage CLASS |
2063 | =item $bytes = $mapped->slice_pitch |
2029 | |
2064 | |
2030 | This is a subclass of OpenCL::Mapped, representing mapped images. |
2065 | Return the row or slice pitch of the image that has been mapped. |
2031 | |
|
|
2032 | =over 4 |
|
|
2033 | |
2066 | |
2034 | =back |
2067 | =back |
2035 | |
2068 | |
2036 | |
2069 | |
2037 | =cut |
2070 | =cut |