IMAGEFUNCTIONS(3clc)
okay so this is IMAGE READ, WRITE, A, page 3 of the OpenCL Manual (you'll see it written as 3clc). It's the glow-up index page for the image read/write/query built-ins β every single one of them, and clicking any item in the original table takes you to that function's own page. Bestie, consider this your map. πΊοΈβ¨
β¨ NAME β¨
Image_Read_and_Write_Functions β built-in functions to read, write, and query image memory objects. Tap any item below and it'll spill the details on that function. π«Ά
πΈ the whole roster πΈ
π 1D girlies
read_imagef1d(3clc)for 1D β do an element lookup in the 1D image object, with or without a sampler, and get back floating-point values. πread_imagei1d(3clc)for 1D β do an element lookup in the 1D image object, with or without a sampler, and get back unnormalized signed integer and unsigned integer values. π’read_imageh1d(3clc)for 1D β OPTIONAL function that does an element lookup in the 1D image object, with or without a sampler, returning floating-point values. It's enabled withcl_khr_fp16(3clc). β¨write_image1d(3clc)for 1D β write a color value to a location in the 2D image object. Thehalftype is enabled withcl_khr_fp16(3clc). ποΈ
π¦ 2D besties
read_imagef2d(3clc)for 2D β do an element lookup in the 2D image object, with or without a sampler, and get back floating-point values. πread_imagei2d(3clc)for 2D β do an element lookup in the 2D image object, with or without a sampler, and get back unnormalized signed integer and unsigned integer values. π’read_imageh2d(3clc)for 2D β OPTIONAL function that does an element lookup in the 2D image object, with or without a sampler, returning floating-point values. It's enabled withcl_khr_fp16(3clc). β¨write_image2d(3clc)for 2D β write a color value to a location in the 2D image object. Thehalftype is enabled withcl_khr_fp16(3clc). ποΈ
π§ 3D main characters
read_imagef3d(3clc)for 3D β do an element lookup in the 3D image object, with or without a sampler, and get back floating-point values. πread_imagei3d(3clc)for 3D β do an element lookup in the 3D image object, with or without a sampler, and get back unnormalized signed integer and unsigned integer values. π’read_imageh3d(3clc)for 3D β OPTIONAL function that does an element lookup in the 3D image object, with or without a sampler, returning floating-point values. It's enabled withcl_khr_fp16(3clc). β¨write_image3d(3clc)for 3D β write a color value to a location in the 2D image object. Thehalftype is enabled withcl_khr_fp16(3clc). ποΈ
π the little getters that could (query squad)
get_image_width(3clc)β return the image width in pixels. πget_image_height(3clc)β return the image height in pixels. πget_image_depth(3clc)β return the 3D image depth in pixels. π³οΈget_image_channel_data_type(3clc)β return the image channel data type. π§¬get_image_channel_order(3clc)β return the image channel order. πget_image_dim(3clc)β return the image dimensions. π¦get_image_array_size(3clc)β return the number of images in an image array. π’
fr fr, that's the entire table, no skips, no cuts. π
π NOTES π
okay bestie, listen up, because this is the part where it gets specific. The built-in functions defined in this section can only be used with image memory objects. And an image memory object? It gets accessed by specific function calls that read from and/or write to specific locations in the image. That's the whole vibe. πΌοΈβ¨
Image memory objects that are being read by a kernel should be declared with the accessQualifiers(3clc) qualifier. And if you go and do write_image calls on image memory objects declared with the accessQualifiers(3clc) qualifier? π Compilation error. Straight up. No warning, no mercy.
Image memory objects that are being written to by a kernel should be declared with the accessQualifiers(3clc) qualifier. And flip it: read_image calls to image memory objects declared with the accessQualifiers(3clc) qualifier will generate a compilation error too. π
π¨ and bestie, hear me on this one:read_imageandwrite_imagecalls to the same image memory object in a kernel are not supported. Not "discouraged". Not "a little sketchy". Not supported. periodt.
The read_image calls return a four component floating-point, integer or unsigned integer color value. Those color values are identified as x, y, z, w where:
xβ the red component πyβ the green component πΏzβ the blue component π¦wβ the alpha component π
like, the alphabet soup is just RGBA wearing a lil disguise. iykyk. π
π SPECIFICATION π
OpenCL Specification[1]
π SEE ALSO π
go read those too, they're part of the lore π«Ά
βοΈ AUTHORS βοΈ
The Khronos Group
βοΈ COPYRIGHT βοΈ
Copyright Β© 2007-2011 The Khronos Group Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and/or associated documentation files (the "Materials"), to deal in the Materials without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Materials, and to permit persons to whom the Materials are furnished to do so, subject to the following condition:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Materials.
π NOTES (yes, again β these are the footnote ones) π
- OpenCL Specification β page 292, section 6.12.14 - Image Read and Write Functions
and that's a wrap, bestie π this page is brought to you by The Khronos Group, dated 01/14/2021, filed under IMAGE READ, WRITE, A(3clc) β go forth and slay your image reads, but for real, do not read and write the same image object in one kernel, i love u, bye πβ¨
π¦ where this page comes from
- ubuntu jammy: opencl-1.2-man-doc 1.0~svn33624-5 Β· other
- ubuntu noble: opencl-1.2-man-doc 1.0~svn33624-5 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms