1/*
2 * Copyright (C) 2017 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
17package com.android.rs.unittest;
18
19import android.content.Context;
20import android.renderscript.RenderScript;
21import android.renderscript.Short2;
22import android.renderscript.Short3;
23import android.renderscript.Short4;
24
25public class UT_fp16_globals extends UnitTest {
26    private static final short mHalfConst0 = (short) 0x4900; // 10.f
27    private static final short mHalfConst1 = (short) 0x4980; // 11.f
28    private static final short mHalfConst2 = (short) 0xca00; // -12.f
29    private static final short mHalfConst3 = (short) 0xca80; // -13.f
30
31    public UT_fp16_globals(Context ctx) {
32        super("Fp16 Globals", ctx);
33    }
34
35    public void run() {
36        RenderScript pRS = createRenderScript(true);
37        ScriptC_fp16_globals s = new ScriptC_fp16_globals(pRS);
38
39        Short2 half2Value = new Short2(mHalfConst0, mHalfConst1);
40        Short3 half3Value = new Short3(mHalfConst0, mHalfConst1, mHalfConst2);
41        Short4 half4Value = new Short4(mHalfConst0, mHalfConst1, mHalfConst2, mHalfConst3);
42
43        s.set_gHalf(mHalfConst0);
44        s.set_gHalf2(half2Value);
45        s.set_gHalf3(half3Value);
46        s.set_gHalf4(half4Value);
47
48        s.invoke_test(mHalfConst0, half2Value, half3Value, half4Value);
49        s.invoke_validateHalf(mHalfConst0);
50        s.invoke_validateHalf2(half2Value);
51        s.invoke_validateHalf3(half3Value);
52        s.invoke_validateHalf4(half4Value);
53
54        pRS.finish();
55        s.destroy();
56        pRS.destroy();
57    }
58}
59