Skip to content

Commit 7669ac7

Browse files
authored
Fix image conversion rules for signed and unsigned image channel data types (KhronosGroup#1348)
The returned values are always 32-bit integers. Pixel values are sign- or zero-extended to 32 bits when the data type is smaller than 32-bit. Also fix a typo in the description of single precision FP values to normalized integer values (the description erroneously referred to half precision floating point). Change-Id: Idaa61a77949530e18442df680175de04347af9fa Signed-off-by: Kevin Petit <kevin.petit@arm.com>
1 parent 10d8f8f commit 7669ac7

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

OpenCL_C.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17390,12 +17390,14 @@ channel data type of {CL_FLOAT}.
1739017390
=== Conversion Rules for Signed and Unsigned 8-Bit, 16-Bit and 32-Bit Integer Channel Data Types
1739117391

1739217392
Calls to *read_imagei* with channel data type values of {CL_SIGNED_INT8},
17393-
{CL_SIGNED_INT16} and {CL_SIGNED_INT32} return the unmodified integer values
17394-
stored in the image at specified location.
17393+
{CL_SIGNED_INT16} and {CL_SIGNED_INT32} return the integer values
17394+
stored in the image at specified location, after sign extension to 32 bits for
17395+
integer values smaller than 32 bits.
1739517396

1739617397
Calls to *read_imageui* with channel data type values of {CL_UNSIGNED_INT8},
17397-
{CL_UNSIGNED_INT16} and {CL_UNSIGNED_INT32} return the unmodified integer
17398-
values stored in the image at specified location.
17398+
{CL_UNSIGNED_INT16} and {CL_UNSIGNED_INT32} return the integer values stored in
17399+
the image at specified location, after zero extension to 32 bits for integer
17400+
values smaller than 32 bits.
1739917401

1740017402
Calls to *write_imagei* will perform one of the following conversions:
1740117403

env/image_addressing_and_filtering.asciidoc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ For images created with image channel data type of {CL_SNORM_INT8} and {CL_SNORM
651651
OpenCL implementations may choose to approximate the rounding mode used in the conversions described below.
652652
When approximate rounding is used instead of the preferred rounding, the result of the conversion must satisfy the bound given below.
653653

654-
The conversions from half precision floating-point values to normalized integer values are performed is as follows:
654+
The conversions from single precision floating-point values to normalized integer values are performed is as follows:
655655

656656
* `float` -> {CL_UNORM_INT8} (8-bit unsigned integer)
657657
+
@@ -784,9 +784,15 @@ The following rules apply for reading and writing images created with channel da
784784
[[conversion-rules-for-signed-and-unsigned-8-bit-16-bit-and-32-bit-integer-channel-data-types]]
785785
==== Conversion Rules for Signed and Unsigned 8-bit, 16-bit and 32-bit Integer Channel Data Types
786786

787-
For images created with image channel data type of {CL_SIGNED_INT8}, {CL_SIGNED_INT16} and {CL_SIGNED_INT32}, image read instructions will return the unmodified integer values stored in the image at specified location.
787+
For images created with image channel data type of {CL_SIGNED_INT8},
788+
{CL_SIGNED_INT16} and {CL_SIGNED_INT32}, image read instructions will
789+
return the integer values stored in the image at specified location, after
790+
sign extension to 32 bits for integer values smaller than 32 bits.
788791

789-
Likewise, for images created with image channel data type of {CL_UNSIGNED_INT8}, {CL_UNSIGNED_INT16} and {CL_UNSIGNED_INT32}, image read instructions will return the unmodified unsigned integer values stored in the image at specified location.
792+
Likewise, for images created with image channel data type of {CL_UNSIGNED_INT8},
793+
{CL_UNSIGNED_INT16} and {CL_UNSIGNED_INT32}, image read instructions will return
794+
the integer values stored in the image at specified location, after
795+
zero extension to 32 bits for integer values smaller than 32 bits.
790796

791797
Image write instructions will perform one of the following conversions:
792798

0 commit comments

Comments
 (0)