blob: 11c0556d2348b6e2f2f2b9567474d1e69436fe06 [file] [log] [blame]
Tim Murray16b95122012-10-31 16:02:59 -07001/*
2 * Copyright (C) 2012 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)
Tim Murray4a92d122013-07-22 10:56:18 -070018#pragma rs java_package_name(com.android.rs.cppbasic)
Tim Murray16b95122012-10-31 16:02:59 -070019#pragma rs_fp_relaxed
20
Stephen Hines43514cd2012-11-16 14:33:47 -080021int g_i = 4;
22
23float g_f = 5.9;
24
Tim Murray16b95122012-10-31 16:02:59 -070025const static float3 gMonoMult = {0.299f, 0.587f, 0.114f};
26
Stephen Hines43514cd2012-11-16 14:33:47 -080027bool *failed;
28
29#define _RS_ASSERT(b) \
30do { \
31 if (!(b)) { \
32 *failed = true; \
33 rsDebug(#b " FAILED", 0); \
34 } \
35\
36} while (0)
37
38struct myStruct {
39 int i;
40 int j;
41 float f;
42 char c[3];
43};
44
Stephen Hines8a588bd2013-11-26 15:38:31 -080045rs_allocation alloc;
46rs_element elem;
47rs_type type;
48rs_sampler sampler;
49rs_script script;
50
Tim Murray16b95122012-10-31 16:02:59 -070051void root(const uchar4 *v_in, uchar4 *v_out) {
52 float4 f4 = rsUnpackColor8888(*v_in);
53
54 float3 mono = dot(f4.rgb, gMonoMult);
55 *v_out = rsPackColorTo8888(mono);
56}
57
Stephen Hines43514cd2012-11-16 14:33:47 -080058void foo(int i, float f) {
59 rsDebug("g_i", g_i);
60 rsDebug("g_f", g_f);
61 rsDebug("i", i);
62 rsDebug("f", f);
63}
64
65void bar(int i, int j, char k, int l, int m, int n) {
66 _RS_ASSERT(i == 47);
67 _RS_ASSERT(j == -3);
68 _RS_ASSERT(k == 'c');
69 _RS_ASSERT(l == -7);
70 _RS_ASSERT(m == 14);
71 _RS_ASSERT(n == -8);
72}
73
Chris Wailes025b5f82014-05-22 16:28:59 -070074int RS_KERNEL kern1(int i, uint32_t x, uint32_t y) {
Stephen Hines43514cd2012-11-16 14:33:47 -080075 return i + 10 * x + 100 *y;
76}
77
Chris Wailes025b5f82014-05-22 16:28:59 -070078void RS_KERNEL verify_kern1(int i, uint32_t x, uint32_t y) {
Stephen Hinesa1302e22013-09-04 15:53:03 -070079 _RS_ASSERT(i == (5 + 10 * x + 100 * y));
Stephen Hines43514cd2012-11-16 14:33:47 -080080 rsDebug("i ", i);
81}
Tim Murray16b95122012-10-31 16:02:59 -070082