Skip to content

Commit c2d0043

Browse files
authored
Add specification for cl_ext_image_from_buffer (#752)
Change-Id: Ieca35aedd775379310417b94387ea0776c4a0d55 Signed-off-by: Kevin Petit <kevin.petit@arm.com> Signed-off-by: Kevin Petit <kevin.petit@arm.com>
1 parent c879a73 commit c2d0043

2 files changed

Lines changed: 310 additions & 1 deletion

File tree

Lines changed: 304 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,304 @@
1+
// Copyright 2018-2022 The Khronos Group. This work is licensed under a
2+
// Creative Commons Attribution 4.0 International License; see
3+
// http://creativecommons.org/licenses/by/4.0/
4+
5+
:data-uri:
6+
:icons: font
7+
include::../config/attribs.txt[]
8+
include::{generated}/api/api-dictionary-no-links.asciidoc[]
9+
:source-highlighter: coderay
10+
11+
= cl_ext_image_from_buffer
12+
:R: pass:q,r[^(R)^]
13+
Khronos{R} OpenCL Working Group
14+
15+
<<<<
16+
17+
== Name Strings
18+
19+
`cl_ext_image_from_buffer`
20+
21+
== Contact
22+
23+
Please see the *Issues* list in the Khronos *OpenCL-Docs* repository: +
24+
https://github.com/KhronosGroup/OpenCL-Docs
25+
26+
== Contributors
27+
28+
Kevin Petit, Arm Ltd. +
29+
Jeremy Kemp, Imagination Technologies +
30+
Alastair Murray, Codeplay Software Ltd. +
31+
Balaji Calidas, Qualcomm +
32+
33+
== Notice
34+
35+
include::../copyrights.txt[]
36+
37+
== Status
38+
39+
Shipping.
40+
41+
== Version
42+
43+
Built On: {docdate} +
44+
Version: 1.0.0
45+
46+
== Dependencies
47+
48+
This extension is written against the OpenCL Specification version 3.0.9.
49+
50+
This extension requires OpenCL 3.0.
51+
52+
This extension requires `cl_ext_image_requirements_info`.
53+
54+
== Overview
55+
56+
This extension enables all types of images to be created from an existing buffer
57+
object.
58+
59+
== New API Enums
60+
61+
Accepted value for the _param_name_ parameter to *clGetRequirementsInfoEXT*:
62+
63+
[source,c]
64+
----
65+
CL_IMAGE_REQUIREMENTS_SLICE_PITCH_ALIGNMENT_EXT 0x1291
66+
----
67+
68+
== Modifications to the OpenCL API Specification
69+
70+
(Modify Section 5.3.1, *Creating Image Objects*) ::
71+
+
72+
--
73+
The following text:
74+
75+
--
76+
_image_format_ is a pointer to a structure that describes format properties of the image to be
77+
allocated. A 1D image buffer or 2D image can be created from a buffer by specifying a buffer
78+
object in the image_desc→mem_object. A 2D image can be created from another 2D image object
79+
by specifying an image object in the image_desc→mem_object. Refer to the Image Format
80+
Descriptor section for a detailed description of the image format descriptor.
81+
--
82+
83+
is replaced with:
84+
85+
--
86+
_image_format_ is a pointer to a structure that describes format properties of
87+
the image to be allocated. An image can be created from a buffer by specifying
88+
a buffer object in the _image_desc_->_mem_object_. A 2D image can be created from
89+
another 2D image object by specifying an image object in the
90+
_image_desc_->_mem_object_. Refer to the Image Format Descriptor section for a
91+
detailed description of the image format descriptor.
92+
--
93+
94+
The following text:
95+
96+
--
97+
{CL_INVALID_IMAGE_FORMAT_DESCRIPTOR} if a 2D image is created from a buffer and
98+
the row pitch and base address alignment does not follow the rules described
99+
for creating a 2D image from a buffer.
100+
--
101+
102+
is replaced with:
103+
104+
--
105+
{CL_INVALID_IMAGE_FORMAT_DESCRIPTOR} if an image is created from a buffer and
106+
the row or slice pitch and base address alignment do not follow the rules
107+
described for creating an image from a buffer.
108+
--
109+
110+
The following text is added to the list of error conditions for {clCreateImageWithProperties}:
111+
112+
--
113+
{CL_INVALID_IMAGE_SIZE} if an image is created from a buffer and the buffer
114+
passed in _image_desc->_mem_object_ is too small to be used as a data store
115+
for the image, e.g. if its size is smaller than the value returned for
116+
{CL_IMAGE_REQUIREMENTS_SIZE_EXT} for the parameters used to create the image.
117+
--
118+
119+
120+
The following text:
121+
122+
--
123+
For a 2D image created from a buffer, the pitch specified (or computed if
124+
pitch specified is 0) must be a multiple of the maximum of the
125+
{CL_DEVICE_IMAGE_PITCH_ALIGNMENT} value for all devices in the context associated
126+
with the buffer specified by mem_object that support images.
127+
--
128+
129+
is replaced with:
130+
131+
--
132+
For an image created from a buffer, the pitch specified (or computed if
133+
pitch specified is 0) must be a multiple of the
134+
{CL_IMAGE_REQUIREMENTS_ROW_PITCH_ALIGNMENT_EXT} value for the _image_format_,
135+
_image_type_ and _flags_ used to create the image.
136+
--
137+
138+
139+
The following text is added to the description for `image_slice_pitch`:
140+
141+
--
142+
For an image created from a buffer, the pitch specified (or computed if
143+
pitch specified is 0) must be a multiple of the
144+
{CL_IMAGE_REQUIREMENTS_SLICE_PITCH_ALIGNMENT_EXT} value for the _image_format_,
145+
_image_type_ and _flags_ used to create the image.
146+
--
147+
148+
The following text:
149+
150+
--
151+
`mem_object` may refer to a valid buffer or image memory object. `mem_object`
152+
can be a buffer memory object if image_type is {CL_MEM_OBJECT_IMAGE1D_BUFFER}
153+
or {CL_MEM_OBJECT_IMAGE2D}. `mem_object` can be an image object if _image_type_
154+
is {CL_MEM_OBJECT_IMAGE2D}. Otherwise it must be `NULL`. The image pixels are
155+
taken from the memory objects data store. When the contents of the specified
156+
memory objects data store are modified, those changes are reflected in the
157+
contents of the image object and vice-versa at corresponding synchronization
158+
points.
159+
--
160+
161+
is replaced with:
162+
163+
--
164+
`mem_object` may refer to a valid buffer or image memory object. `mem_object`
165+
can be an image object if _image_type_ is {CL_MEM_OBJECT_IMAGE2D}.
166+
Otherwise it must be `NULL`. The image pixels are taken from the memory objects
167+
data store. When the contents of the specified memory objects data store are
168+
modified, those changes are reflected in the contents of the image object and
169+
vice-versa at corresponding synchronization points.
170+
--
171+
172+
The following text is added:
173+
174+
--
175+
For a 1D image created from a buffer object, the `image_width` {times} size of
176+
element in bytes must be {leq} size of the buffer object. The image data in the
177+
buffer object is stored as a single scanline which is a linear sequence of
178+
adjacent elements.
179+
180+
For a 1D image array created from a buffer object, the `image_slice_pitch` {times}
181+
`image_array_size` must be {leq} size of the buffer object specified by `mem_object`.
182+
The image data in the buffer object is stored as a linear sequence of adjacent 1D
183+
slices. Each slice is a single scanline padded to `image_slice_pitch` bytes.
184+
Each scanline is a linear sequence of image elements.
185+
186+
For a 2D image array created from a buffer object, the `image_slice_pitch` {times}
187+
`image_array_size` must be {leq} size of the buffer object specified by `mem_object`.
188+
The image data in the buffer object is stored as a linear sequence of adjacent 2D
189+
slices. Each slice is a linear sequence of adjacent scanlines padded to
190+
`image_slice_pitch` bytes. Each scanline is a linear sequence of image elements padded
191+
to `image_row_pitch` bytes.
192+
193+
For a 3D image created from a buffer object, the `image_slice_pitch` {times}
194+
`image_depth` must be {leq} size of the buffer object specified by `mem_object`.
195+
The image data in the buffer object is stored as a linear sequence of adjacent 2D
196+
slices padded to `image_slice_pitch` bytes. Each slice is a linear sequence of adjacent
197+
scanlines. Each scanline is a linear sequence of image elements padded to
198+
`image_row_pitch` bytes.
199+
--
200+
201+
The following text:
202+
203+
--
204+
Concurrent reading from, writing to and copying between both a buffer object and
205+
1D image buffer or 2D image object associated with the buffer object is undefined.
206+
Only reading from both a buffer object and 1D image buffer or 2D image object
207+
associated with the buffer object is defined.
208+
--
209+
210+
is replaced with:
211+
212+
--
213+
Concurrent reading from, writing to and copying between both a buffer object and
214+
an image object associated with the buffer object is undefined. Only reading from
215+
both a buffer object and image object associated with the buffer object is defined.
216+
--
217+
218+
(Modify section 5.3.X, *Querying image requirements*) ::
219+
+
220+
--
221+
The following is added to the _List of supported param_names by
222+
*clGetImageRequirementsInfoEXT*:
223+
224+
[width="100%",cols="<34%,<33%,<33%",options="header"]
225+
|====
226+
| Image Requirement Info | Return type | Info. returned in _param_value_
227+
228+
| {CL_IMAGE_REQUIREMENTS_SLICE_PITCH_ALIGNMENT_EXT}
229+
| `size_t`
230+
| Returns the slice pitch alignment required in bytes for images created from
231+
a buffer with the parameters passed to {clGetImageRequirementsInfoEXT}.
232+
The value returned is a power of two. _image_format_ and _image_desc_ are
233+
allowed to be `NULL`. When either or both is `NULL` the value returned is
234+
the minimum slice pitch alignment that is supported for all possible values
235+
of the missing argument(s).
236+
237+
|====
238+
--
239+
--
240+
241+
== Interactions with Other Extensions
242+
243+
None.
244+
245+
== Conformance tests
246+
247+
248+
. Test access from kernel
249+
- For all image types
250+
- For a few/all image formats
251+
- For several values of row/slice pitch
252+
- With or without a host_ptr
253+
- Create buffer and fill with data
254+
- Optionally create a sub-buffer with a randomly selected offset?
255+
- Create an image from the buffer
256+
- Read the image from a kernel and compare with values read using the buffer and direct addressing. They must match.
257+
258+
. TODO Test access via read/write/map commands?
259+
260+
. TODO Test copy to/from buffer?
261+
262+
. TODO Test fill?
263+
264+
. TODO Test copy to/from another image?
265+
266+
. Test clGetImageInfo
267+
- For all image types (one format per element size)
268+
- For a few different row/pitch sizes (image dimensions being equal or not)
269+
- Create an image from a buffer
270+
- Check that the returned values for {CL_IMAGE_ROW_PITCH} and {CL_IMAGE_SLICE_PICTH} are correct.
271+
272+
. Test clGetMemObjectInfo
273+
- For all image types (1 format only)
274+
- Create an image from a buffer
275+
- Check that {CL_MEM_ASSOCIATED_MEMOBJECT} correctly returns the buffer that was used.
276+
277+
. Negative testing for {clCreateImage} (alignment)
278+
- For a few/all image formats
279+
- For all image types
280+
- Query row pitch, slice pitch and base image address alignment for the format
281+
- Create an image from a buffer with invalid row pitch (not a multiple of required alignment) and check that {CL_INVALID_IMAGE_FORMAT_DESCRIPTOR} is returned.
282+
- Create an image from a buffer with invalid slice pitch (not a multiple of required alignment) and check that {CL_INVALID_IMAGE_FORMAT_DESCRIPTOR} is returned.
283+
- Create an image from a buffer with invalid base address alignment (not a multiple of required alignment) and check that {CL_INVALID_IMAGE_FORMAT_DESCRIPTOR} is returned.
284+
285+
. Negative testing for {clCreateImage} (buffer size)
286+
- For a few image formats (at least smallest and biggest element types)
287+
- For all image types
288+
- Create a buffer too small
289+
- Check that image creation from that buffer is rejected with {CL_INVALID_IMAGE_SIZE}
290+
291+
== Issues
292+
293+
None.
294+
295+
== Version History
296+
297+
[cols="5,15,15,70"]
298+
[grid="rows"]
299+
[options="header"]
300+
|====
301+
| Version | Date | Author | Changes
302+
| 1.0.0 | 2022-01-25 | Kevin Petit | *Initial EXT revision*
303+
|====
304+

xml/cl.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1718,7 +1718,7 @@ server's OpenCL/api-docs repository.
17181718
<enum value="0x1284" name="CL_PROFILING_COMMAND_COMPLETE"/>
17191719
<unused start="0x1285" end="0x128F" comment="Reserved for cl_profiling_info"/>
17201720
<enum value="0x1290" name="CL_IMAGE_REQUIREMENTS_ROW_PITCH_ALIGNMENT_EXT"/>
1721-
<unused start="0x1291" end="0x1291" comment="Reserved for MR179"/>
1721+
<enum value="0x1291" name="CL_IMAGE_REQUIREMENTS_SLICE_PITCH_ALIGNMENT_EXT"/>
17221722
<enum value="0x1292" name="CL_IMAGE_REQUIREMENTS_BASE_ADDRESS_ALIGNMENT_EXT"/>
17231723
<enum value="0x1293" name="CL_COMMAND_BUFFER_FLAGS_KHR"/>
17241724
<enum value="0x1294" name="CL_COMMAND_BUFFER_QUEUES_KHR"/>
@@ -7200,5 +7200,10 @@ server's OpenCL/api-docs repository.
72007200
<command name="clGetMutableCommandInfoKHR"/>
72017201
</require>
72027202
</extension>
7203+
<extension name="cl_ext_image_from_buffer" supported="opencl">
7204+
<require comment="cl_image_requirements_info_ext">
7205+
<enum name="CL_IMAGE_REQUIREMENTS_SLICE_PITCH_ALIGNMENT_EXT"/>
7206+
</require>
7207+
</extension>
72037208
</extensions>
72047209
</registry>

0 commit comments

Comments
 (0)