diff options
author | Jean-Luc Brouillet <jeanluc@google.com> | 2015-04-10 09:36:15 -0700 |
---|---|---|
committer | Pirama Arumuga Nainar <pirama@google.com> | 2015-06-03 09:40:52 -0700 |
commit | 9c850612691e0b16f3974dd672f8eeb343a78aee (patch) | |
tree | c784c0a9ea1caa3de071c7029acf22648b868f98 | |
parent | 9c8e3403d07a2347435ed58d8aa52d9dc4346f16 (diff) | |
download | rs-9c850612691e0b16f3974dd672f8eeb343a78aee.tar.gz |
Add half (fp16) to runtime API.
Bug: 7342860
Change-Id: I25c6e1a9102cb193ed47f7d0c87f5948f59b8036
(cherry picked from commit 6119da9273f88e838b2e8648bde0d40fabe51f5f)
-rw-r--r-- | api/Specification.cpp | 2 | ||||
-rw-r--r-- | api/rs_allocation_data.spec | 69 | ||||
-rw-r--r-- | api/rs_value_types.spec | 38 | ||||
-rw-r--r-- | scriptc/rs_allocation_data.rsh | 120 | ||||
-rw-r--r-- | scriptc/rs_value_types.rsh | 41 |
5 files changed, 267 insertions, 3 deletions
diff --git a/api/Specification.cpp b/api/Specification.cpp index b36acaeb..09a0663d 100644 --- a/api/Specification.cpp +++ b/api/Specification.cpp @@ -35,7 +35,7 @@ using namespace std; const int MIN_API_LEVEL = 9; const NumericalType TYPES[] = { - {"f16", "FLOAT_16", "half", "half", FLOATING_POINT, 11, 5}, + {"f16", "FLOAT_16", "half", "float", FLOATING_POINT, 11, 5}, {"f32", "FLOAT_32", "float", "float", FLOATING_POINT, 24, 8}, {"f64", "FLOAT_64", "double", "double", FLOATING_POINT, 53, 11}, {"i8", "SIGNED_8", "char", "byte", SIGNED_INTEGER, 7, 0}, diff --git a/api/rs_allocation_data.spec b/api/rs_allocation_data.spec index 31fa58d1..a1d76630 100644 --- a/api/rs_allocation_data.spec +++ b/api/rs_allocation_data.spec @@ -306,6 +306,39 @@ arg: uint32_t z test: none end: +function: rsGetElementAt_#2#1 +version: 23 +w: 1, 2, 3, 4 +t: f16 +ret: #2#1 +arg: rs_allocation a +arg: uint32_t x +test: none +end: + +function: rsGetElementAt_#2#1 +version: 23 +w: 1, 2, 3, 4 +t: f16 +ret: #2#1 +arg: rs_allocation a +arg: uint32_t x +arg: uint32_t y +test: none +end: + +function: rsGetElementAt_#2#1 +version: 23 +w: 1, 2, 3, 4 +t: f16 +ret: #2#1 +arg: rs_allocation a +arg: uint32_t x +arg: uint32_t y +arg: uint32_t z +test: none +end: + function: rsGetElementAtYuv_uchar_U version: 18 ret: uchar @@ -474,3 +507,39 @@ arg: uint32_t y arg: uint32_t z test: none end: + +function: rsSetElementAt_#2#1 +version: 23 +w: 1, 2, 3, 4 +t: f16 +ret: void +arg: rs_allocation a +arg: #2#1 val +arg: uint32_t x +test: none +end: + +function: rsSetElementAt_#2#1 +version: 23 +w: 1, 2, 3, 4 +t: f16 +ret: void +arg: rs_allocation a +arg: #2#1 val +arg: uint32_t x +arg: uint32_t y +test: none +end: + +function: rsSetElementAt_#2#1 +version: 23 +w: 1, 2, 3, 4 +t: f16 +ret: void +arg: rs_allocation a +arg: #2#1 val +arg: uint32_t x +arg: uint32_t y +arg: uint32_t z +test: none +end: diff --git a/api/rs_value_types.spec b/api/rs_value_types.spec index a4f303af..d559157a 100644 --- a/api/rs_value_types.spec +++ b/api/rs_value_types.spec @@ -24,7 +24,7 @@ description: <tr><td> </td> <td>8 bits </td> <td>16 bits </td> <td>32 bits </td> <td>64 bits</td></tr> <tr><td>Integer: </td> <td>char, @int8_t </td> <td>short, @int16_t </td> <td>@int32_t </td> <td>long, long long, @int64_t</td></tr> <tr><td>Unsigned integer:</td> <td>uchar, @uint8_t</td> <td>ushort, @uint16_t</td> <td>uint, @uint32_t</td> <td>ulong, @uint64_t</td></tr> - <tr><td>Floating point: </td> <td> </td> <td> </td> <td>float </td> <td>double</td></tr> + <tr><td>Floating point: </td> <td> </td> <td>half </td> <td>float </td> <td>double</td></tr> </table> <h5>Vectors:</h5> @@ -86,6 +86,42 @@ description: of operations. end: +type: half +version: 23 +simple: __fp16 +summary: 16 bit floating point value +description: + A 16 bit floating point value. +end: + +type: half2 +version: 23 +simple: half __attribute__((ext_vector_type(2))) +summary: Two 16 bit floats +description: + Vector version of the half float type. Provides two half fields packed + into a single 32 bit field with 32 bit alignment. +end: + +type: half3 +version: 23 +simple: half __attribute__((ext_vector_type(3))) +summary: Three 16 bit floats +description: + Vector version of the half float type. Provides three half fields packed + into a single 64 bit field with 64 bit alignment. +end: + +type: half4 +version: 23 +simple: half __attribute__((ext_vector_type(4))) +summary: Four 16 bit floats +description: + Vector version of the half float type. Provides four half fields packed + into a single 64 bit field with 64 bit alignment. +end: + + type: int8_t simple: char summary: 8 bit signed integer diff --git a/scriptc/rs_allocation_data.rsh b/scriptc/rs_allocation_data.rsh index d8785a22..69e9baf8 100644 --- a/scriptc/rs_allocation_data.rsh +++ b/scriptc/rs_allocation_data.rsh @@ -2524,6 +2524,66 @@ extern ulong4 __attribute__((overloadable)) rsGetElementAt_ulong4(rs_allocation a, uint32_t x, uint32_t y, uint32_t z); #endif +#if (defined(RS_VERSION) && (RS_VERSION >= 23)) +extern half __attribute__((overloadable)) + rsGetElementAt_half(rs_allocation a, uint32_t x); +#endif + +#if (defined(RS_VERSION) && (RS_VERSION >= 23)) +extern half2 __attribute__((overloadable)) + rsGetElementAt_half2(rs_allocation a, uint32_t x); +#endif + +#if (defined(RS_VERSION) && (RS_VERSION >= 23)) +extern half3 __attribute__((overloadable)) + rsGetElementAt_half3(rs_allocation a, uint32_t x); +#endif + +#if (defined(RS_VERSION) && (RS_VERSION >= 23)) +extern half4 __attribute__((overloadable)) + rsGetElementAt_half4(rs_allocation a, uint32_t x); +#endif + +#if (defined(RS_VERSION) && (RS_VERSION >= 23)) +extern half __attribute__((overloadable)) + rsGetElementAt_half(rs_allocation a, uint32_t x, uint32_t y); +#endif + +#if (defined(RS_VERSION) && (RS_VERSION >= 23)) +extern half2 __attribute__((overloadable)) + rsGetElementAt_half2(rs_allocation a, uint32_t x, uint32_t y); +#endif + +#if (defined(RS_VERSION) && (RS_VERSION >= 23)) +extern half3 __attribute__((overloadable)) + rsGetElementAt_half3(rs_allocation a, uint32_t x, uint32_t y); +#endif + +#if (defined(RS_VERSION) && (RS_VERSION >= 23)) +extern half4 __attribute__((overloadable)) + rsGetElementAt_half4(rs_allocation a, uint32_t x, uint32_t y); +#endif + +#if (defined(RS_VERSION) && (RS_VERSION >= 23)) +extern half __attribute__((overloadable)) + rsGetElementAt_half(rs_allocation a, uint32_t x, uint32_t y, uint32_t z); +#endif + +#if (defined(RS_VERSION) && (RS_VERSION >= 23)) +extern half2 __attribute__((overloadable)) + rsGetElementAt_half2(rs_allocation a, uint32_t x, uint32_t y, uint32_t z); +#endif + +#if (defined(RS_VERSION) && (RS_VERSION >= 23)) +extern half3 __attribute__((overloadable)) + rsGetElementAt_half3(rs_allocation a, uint32_t x, uint32_t y, uint32_t z); +#endif + +#if (defined(RS_VERSION) && (RS_VERSION >= 23)) +extern half4 __attribute__((overloadable)) + rsGetElementAt_half4(rs_allocation a, uint32_t x, uint32_t y, uint32_t z); +#endif + /* * rsGetElementAtYuv_uchar_U: Get the U component of an allocation of YUVs * @@ -3234,4 +3294,64 @@ extern void __attribute__((overloadable)) rsSetElementAt_ulong4(rs_allocation a, ulong4 val, uint32_t x, uint32_t y, uint32_t z); #endif +#if (defined(RS_VERSION) && (RS_VERSION >= 23)) +extern void __attribute__((overloadable)) + rsSetElementAt_half(rs_allocation a, half val, uint32_t x); +#endif + +#if (defined(RS_VERSION) && (RS_VERSION >= 23)) +extern void __attribute__((overloadable)) + rsSetElementAt_half2(rs_allocation a, half2 val, uint32_t x); +#endif + +#if (defined(RS_VERSION) && (RS_VERSION >= 23)) +extern void __attribute__((overloadable)) + rsSetElementAt_half3(rs_allocation a, half3 val, uint32_t x); +#endif + +#if (defined(RS_VERSION) && (RS_VERSION >= 23)) +extern void __attribute__((overloadable)) + rsSetElementAt_half4(rs_allocation a, half4 val, uint32_t x); +#endif + +#if (defined(RS_VERSION) && (RS_VERSION >= 23)) +extern void __attribute__((overloadable)) + rsSetElementAt_half(rs_allocation a, half val, uint32_t x, uint32_t y); +#endif + +#if (defined(RS_VERSION) && (RS_VERSION >= 23)) +extern void __attribute__((overloadable)) + rsSetElementAt_half2(rs_allocation a, half2 val, uint32_t x, uint32_t y); +#endif + +#if (defined(RS_VERSION) && (RS_VERSION >= 23)) +extern void __attribute__((overloadable)) + rsSetElementAt_half3(rs_allocation a, half3 val, uint32_t x, uint32_t y); +#endif + +#if (defined(RS_VERSION) && (RS_VERSION >= 23)) +extern void __attribute__((overloadable)) + rsSetElementAt_half4(rs_allocation a, half4 val, uint32_t x, uint32_t y); +#endif + +#if (defined(RS_VERSION) && (RS_VERSION >= 23)) +extern void __attribute__((overloadable)) + rsSetElementAt_half(rs_allocation a, half val, uint32_t x, uint32_t y, uint32_t z); +#endif + +#if (defined(RS_VERSION) && (RS_VERSION >= 23)) +extern void __attribute__((overloadable)) + rsSetElementAt_half2(rs_allocation a, half2 val, uint32_t x, uint32_t y, uint32_t z); +#endif + +#if (defined(RS_VERSION) && (RS_VERSION >= 23)) +extern void __attribute__((overloadable)) + rsSetElementAt_half3(rs_allocation a, half3 val, uint32_t x, uint32_t y, uint32_t z); +#endif + +#if (defined(RS_VERSION) && (RS_VERSION >= 23)) +extern void __attribute__((overloadable)) + rsSetElementAt_half4(rs_allocation a, half4 val, uint32_t x, uint32_t y, uint32_t z); +#endif + #endif // RENDERSCRIPT_RS_ALLOCATION_DATA_RSH diff --git a/scriptc/rs_value_types.rsh b/scriptc/rs_value_types.rsh index 9dc7259e..faf397cd 100644 --- a/scriptc/rs_value_types.rsh +++ b/scriptc/rs_value_types.rsh @@ -26,7 +26,7 @@ * 8 bits 16 bits 32 bits 64 bits * Integer: char, int8_t short, int16_t int32_t long, long long, int64_t * Unsigned integer: uchar, uint8_t ushort, uint16_t uint, uint32_t ulong, uint64_t - * Floating point: float double + * Floating point: half float double * * * Vectors: @@ -92,6 +92,45 @@ #define RENDERSCRIPT_RS_VALUE_TYPES_RSH /* + * half: 16 bit floating point value + * + * A 16 bit floating point value. + */ +#if (defined(RS_VERSION) && (RS_VERSION >= 23)) +typedef __fp16 half; +#endif + +/* + * half2: Two 16 bit floats + * + * Vector version of the half float type. Provides two half fields packed + * into a single 32 bit field with 32 bit alignment. + */ +#if (defined(RS_VERSION) && (RS_VERSION >= 23)) +typedef half __attribute__((ext_vector_type(2))) half2; +#endif + +/* + * half3: Three 16 bit floats + * + * Vector version of the half float type. Provides three half fields packed + * into a single 64 bit field with 64 bit alignment. + */ +#if (defined(RS_VERSION) && (RS_VERSION >= 23)) +typedef half __attribute__((ext_vector_type(3))) half3; +#endif + +/* + * half4: Four 16 bit floats + * + * Vector version of the half float type. Provides four half fields packed + * into a single 64 bit field with 64 bit alignment. + */ +#if (defined(RS_VERSION) && (RS_VERSION >= 23)) +typedef half __attribute__((ext_vector_type(4))) half4; +#endif + +/* * int8_t: 8 bit signed integer * * 8 bit signed integer type. |