1/*
2* Copyright (C) 2016 The Android Open Source Project
3*
4* Licensed under the Apache License, Version 2.0 (the "License");
5* you may not use this file except in compliance with the License.
6* You may obtain a copy of the License at
7*
8*      http://www.apache.org/licenses/LICENSE-2.0
9*
10* Unless required by applicable law or agreed to in writing, software
11* distributed under the License is distributed on an "AS IS" BASIS,
12* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13* See the License for the specific language governing permissions and
14* limitations under the License.
15*/
16
17#pragma version(1)
18#pragma rs java_package_name(com.android.rs.cppkernelvariables)
19
20char char_global = 12;
21uchar uchar_global = 234;
22short short_global = -321;
23ushort ushort_global = 432;
24int int_global = 1234;
25uint uint_global = 2345;
26float float_global = 4.5f;
27long long_global = -77777;
28ulong ulong_global = 8888;
29double double_global = -456.5f;
30
31char2 char2_global = {11, -22};
32uchar2 uchar2_global = {33, 44};
33short2 short2_global = {-555, 666};
34ushort2 ushort2_global = {777, 888};
35int2 int2_global = {999, -1111};
36uint2 uint2_global = {2222, 3333};
37float2 float2_global = {4.5f, -5.0f};
38long2 long2_global = {-4444, 5555};
39ulong2 ulong2_global = {6666, 7777};
40double2 double2_global = {88.5f, -99.0f};
41
42char3 char3_global = {11, -22, -33};
43uchar3 uchar3_global = {33, 44, 55};
44short3 short3_global = {-555, 666, 777};
45ushort3 ushort3_global = {777, 888, 999};
46int3 int3_global = {999, -1111, 2222};
47uint3 uint3_global = {2222, 3333, 4444};
48float3 float3_global = {4.5f, -5.0f, -6.5f};
49long3 long3_global = {-4444, 5555, 6666};
50ulong3 ulong3_global = {6666, 7777, 8888};
51double3 double3_global = {88.5f, -99.0f, 111.5f};
52
53char4 char4_global = {55, 11, -22, -33};
54uchar4 uchar4_global = {222, 33, 44, 55};
55short4 short4_global = {-444, -555, 666, 777};
56ushort4 ushort4_global = {666, 777, 888, 999};
57int4 int4_global = {888, 999, -1111, 2222};
58uint4 uint4_global = {1111, 2222, 3333, 4444};
59float4 float4_global = {3.0f, 4.5f, -5.0f, -6.5f};
60long4 long4_global = {-3333, -4444, 5555, 6666};
61ulong4 ulong4_global = {5555, 6666, 7777, 8888};
62double4 double4_global = {-77.0f, 88.5f, -99.0f, 111.5f};
63
64rs_matrix2x2 matrix2x2_global;
65rs_matrix3x3 matrix3x3_global;
66rs_matrix4x4 matrix4x4_global;
67
68rs_quaternion quaternion_global;
69
70rs_allocation allocation_1D_global;
71rs_allocation allocation_1D_global2;
72rs_allocation allocation_2D_global;
73rs_allocation allocation_2D_global2;
74rs_allocation allocation_3D_global;
75rs_allocation allocation_YUV_2D_global;
76
77rs_allocation_cubemap_face cubemap_face_global;
78rs_sampler sampler_global;
79
80uchar4 __attribute__((kernel)) kernel(uchar4 in)
81{
82    char char_local = 'a';
83    uchar uchar_local = 'b';
84    short short_local = -321;
85    ushort ushort_local = 432;
86    int int_local = 1234;
87    uint uint_local = 2345;
88    float float_local = 4.5f;
89    long long_local = -77777;
90    ulong ulong_local = 8888;
91    double double_local = -456.5f;
92
93    char2 char2_local = {-11, -22};
94    uchar2 uchar2_local = {33, 44};
95    short2 short2_local = {-555, 666};
96    ushort2 ushort2_local = {777, 888};
97    int2 int2_local = {999, -1111};
98    uint2 uint2_local = {2222, 3333};
99    float2 float2_local = {4.5f, -5.0f};
100    long2 long2_local = {-4444, 5555};
101    ulong2 ulong2_local = {6666, 7777};
102    double2 double2_local = {88.5f, -99.0f};
103
104    char3 char3_local = {11, -22, -33};
105    uchar3 uchar3_local = {33, 44, 55};
106    short3 short3_local = {-555, 666, 777};
107    ushort3 ushort3_local = {777, 888, 999};
108    int3 int3_local = {999, -1111, 2222};
109    uint3 uint3_local = {2222, 3333, 4444};
110    float3 float3_local = {4.5f, -5.0f, -6.5f};
111    long3 long3_local = {-4444, 5555, 6666};
112    ulong3 ulong3_local = {6666, 7777, 8888};
113    double3 double3_local = {88.5f, -99.0f, 111.5f};
114
115    char4 char4_local = {55, 11, -22, -33};
116    uchar4 uchar4_local = {22, 33, 44, 55};
117    short4 short4_local = {-444, -555, 666, 777};
118    ushort4 ushort4_local = {666, 777, 888, 999};
119    int4 int4_local = {888, 999, -1111, 2222};
120    uint4 uint4_local = {1111, 2222, 3333, 4444};
121    float4 float4_local = {3.0f, 4.5f, -5.0f, -6.5f};
122    long4 long4_local = {-3333, -4444, 5555, 6666};
123    ulong4 ulong4_local = {5555, 6666, 7777, 8888};
124    double4 double4_local = {-77.0f, 88.5f, -99.0f, 111.5f};
125
126    rs_matrix2x2 matrix2x2_local = {{1., 2.5,
127                                     3., 4.5}};
128    rs_matrix3x3 matrix3x3_local = {{5., 6.5, 7.,
129                                     8.5, 9., 1.5,
130                                     2., 3.5, 4.}};
131    rs_matrix4x4 matrix4x4_local = {{5.5, 6., 7.5, 8.,
132                                     9., 1.5, 2., 3.5,
133                                     4.5, 5.5, 6.5, 7.,
134                                     8., 9.5, 1.5, 2.5}};
135
136    matrix2x2_global = matrix2x2_local;
137    matrix3x3_global = matrix3x3_local;
138    matrix4x4_global = matrix4x4_local;
139
140    rsQuaternionSet(&quaternion_global, 3.0, 4.5, 5.5, 6.0);
141
142    rs_quaternion quaternion_local;
143    rsQuaternionSet(&quaternion_local, 7.5, 8.0, 9.0, 0.5);
144
145    char char_combined = char_local + (char)uchar_local + char2_local.x +
146        (char)uchar2_local.x + char3_local.x - (char)uchar3_local.x +
147        char4_local.x + (char)uchar4_local.x;
148
149    short short_combined = short_local + (short)ushort_local + short2_local.x +
150        (short)ushort2_local.x + short3_local.x + (short)ushort3_local.x +
151        short4_local.x + (short)ushort4_local.x;
152
153    int int_combined = int_local + (int)uint_local + int2_local.x +
154        (int)uint2_local.x + int3_local.x + (int)uint3_local.x + int4_local.x +
155        (int)uint4_local.x;
156
157    float float_combined = float_local + float2_local.x + float3_local.x +
158        float4_local.x;
159
160    long long_combined = long_local + (long)ulong_local + long2_local.x +
161        (long)ulong2_local.x + long3_local.x + (long)ulong3_local.x +
162        long4_local.x + (long)ulong4_local.x;
163
164    double double_combined = double_local + double2_local.x + double3_local.x +
165        double4_local.x;
166
167    char_global = char_combined;
168    short_global = short_combined;
169    int_global = int_combined;
170    float_global = float_combined;
171    long_global = long_combined;
172    double_global = double_combined;
173
174    uchar4 result = {1,2,3,4};
175    return result;
176}
177
178float use_constants_global;
179
180void setup(void)
181{
182  use_constants_global =
183      M_1_PI +
184      M_2_PI +
185      M_2_PIl +
186      M_2_SQRTPI +
187      M_E +
188      M_LN10 +
189      M_LN2 +
190      M_LOG10E +
191      M_LOG2E +
192      M_PI +
193      M_PI_2 +
194      M_PI_4 +
195      M_SQRT1_2 +
196      M_SQRT2;
197}
198