1 /*
2  * Copyright (C) 2011-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 #include "rsdCore.h"
18 #include "../cpu_ref/rsd_cpu.h"
19 
20 
21 #include "rsScript.h"
22 #include "rsScriptGroup.h"
23 #include "rsdScriptGroup.h"
24 #include "rsdBcc.h"
25 #include "rsdAllocation.h"
26 
27 using namespace android;
28 using namespace android::renderscript;
29 
30 
rsdScriptGroupInit(const Context * rsc,ScriptGroupBase * sg)31 bool rsdScriptGroupInit(const Context *rsc, ScriptGroupBase *sg) {
32     RsdHal *dc = (RsdHal *)rsc->mHal.drv;
33 
34     sg->mHal.drv = dc->mCpuRef->createScriptGroup(sg);
35     return sg->mHal.drv != nullptr;
36 }
37 
rsdScriptGroupSetInput(const Context * rsc,const ScriptGroup * sg,const ScriptKernelID * kid,Allocation *)38 void rsdScriptGroupSetInput(const Context *rsc, const ScriptGroup *sg,
39                             const ScriptKernelID *kid, Allocation *) {
40 }
41 
rsdScriptGroupSetOutput(const Context * rsc,const ScriptGroup * sg,const ScriptKernelID * kid,Allocation *)42 void rsdScriptGroupSetOutput(const Context *rsc, const ScriptGroup *sg,
43                              const ScriptKernelID *kid, Allocation *) {
44 }
45 
rsdScriptGroupExecute(const Context * rsc,const ScriptGroupBase * sg)46 void rsdScriptGroupExecute(const Context *rsc, const ScriptGroupBase *sg) {
47     RsdCpuReference::CpuScriptGroupBase *sgi =
48         (RsdCpuReference::CpuScriptGroupBase *)sg->mHal.drv;
49     sgi->execute();
50 }
51 
rsdScriptGroupDestroy(const Context * rsc,const ScriptGroupBase * sg)52 void rsdScriptGroupDestroy(const Context *rsc, const ScriptGroupBase *sg) {
53     RsdCpuReference::CpuScriptGroupBase *sgi =
54         (RsdCpuReference::CpuScriptGroupBase *)sg->mHal.drv;
55     delete sgi;
56 }
57 
rsdScriptGroupUpdateCachedObject(const Context * rsc,const ScriptGroup * sg,rs_script_group * obj)58 void rsdScriptGroupUpdateCachedObject(const Context *rsc,
59                                       const ScriptGroup *sg,
60                                       rs_script_group *obj)
61 {
62     obj->p = sg;
63 #ifdef __LP64__
64     obj->r = nullptr;
65     if (sg != nullptr) {
66         obj->v1 = sg->mHal.drv;
67     } else {
68         obj->v1 = nullptr;
69     }
70     obj->v2 = nullptr;
71 #endif
72 }
73