• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 android::renderscript::Allocation;
28 using android::renderscript::Context;
29 using android::renderscript::RsdCpuReference;
30 using android::renderscript::ScriptGroup;
31 using android::renderscript::ScriptGroupBase;
32 using android::renderscript::ScriptKernelID;
33 using android::renderscript::rs_script_group;
34 
rsdScriptGroupInit(const Context * rsc,ScriptGroupBase * sg)35 bool rsdScriptGroupInit(const Context *rsc, ScriptGroupBase *sg) {
36     RsdHal *dc = (RsdHal *)rsc->mHal.drv;
37 
38     sg->mHal.drv = dc->mCpuRef->createScriptGroup(sg);
39     return sg->mHal.drv != nullptr;
40 }
41 
rsdScriptGroupSetInput(const Context * rsc,const ScriptGroup * sg,const ScriptKernelID * kid,Allocation *)42 void rsdScriptGroupSetInput(const Context *rsc, const ScriptGroup *sg,
43                             const ScriptKernelID *kid, Allocation *) {
44 }
45 
rsdScriptGroupSetOutput(const Context * rsc,const ScriptGroup * sg,const ScriptKernelID * kid,Allocation *)46 void rsdScriptGroupSetOutput(const Context *rsc, const ScriptGroup *sg,
47                              const ScriptKernelID *kid, Allocation *) {
48 }
49 
rsdScriptGroupExecute(const Context * rsc,const ScriptGroupBase * sg)50 void rsdScriptGroupExecute(const Context *rsc, const ScriptGroupBase *sg) {
51     RsdCpuReference::CpuScriptGroupBase *sgi =
52         (RsdCpuReference::CpuScriptGroupBase *)sg->mHal.drv;
53     sgi->execute();
54 }
55 
rsdScriptGroupDestroy(const Context * rsc,const ScriptGroupBase * sg)56 void rsdScriptGroupDestroy(const Context *rsc, const ScriptGroupBase *sg) {
57     RsdCpuReference::CpuScriptGroupBase *sgi =
58         (RsdCpuReference::CpuScriptGroupBase *)sg->mHal.drv;
59     delete sgi;
60 }
61 
rsdScriptGroupUpdateCachedObject(const Context * rsc,const ScriptGroup * sg,rs_script_group * obj)62 void rsdScriptGroupUpdateCachedObject(const Context *rsc,
63                                       const ScriptGroup *sg,
64                                       rs_script_group *obj)
65 {
66     obj->p = sg;
67 #ifdef __LP64__
68     obj->unused1 = nullptr;
69     obj->unused2 = nullptr;
70     obj->unused3 = nullptr;
71 #endif
72 }
73