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 #include "rsovCore.h"
18
19 #include "rsAllocation.h"
20 #include "rsContext.h"
21 #include "rsScript.h"
22 #include "rsScriptGroup.h"
23 #include "rsd_cpu.h"
24
25 using android::renderscript::Allocation;
26 using android::renderscript::Context;
27 using android::renderscript::RsdCpuReference;
28 using android::renderscript::ScriptGroup;
29 using android::renderscript::ScriptGroupBase;
30 using android::renderscript::ScriptKernelID;
31 using android::renderscript::rs_script_group;
32
rsovScriptGroupInit(const Context * rsc,ScriptGroupBase * sg)33 bool rsovScriptGroupInit(const Context *rsc, ScriptGroupBase *sg) {
34 // Always falls back to CPU implmentation of ScriptGroup
35 RSoVHal *dc = (RSoVHal *)rsc->mHal.drv;
36
37 sg->mHal.drv = dc->mCpuRef->createScriptGroup(sg);
38 return sg->mHal.drv != nullptr;
39 }
40
rsovScriptGroupSetInput(const Context * rsc,const ScriptGroup * sg,const ScriptKernelID * kid,Allocation *)41 void rsovScriptGroupSetInput(const Context *rsc, const ScriptGroup *sg,
42 const ScriptKernelID *kid, Allocation *) {}
43
rsovScriptGroupSetOutput(const Context * rsc,const ScriptGroup * sg,const ScriptKernelID * kid,Allocation *)44 void rsovScriptGroupSetOutput(const Context *rsc, const ScriptGroup *sg,
45 const ScriptKernelID *kid, Allocation *) {}
46
rsovScriptGroupExecute(const Context * rsc,const ScriptGroupBase * sg)47 void rsovScriptGroupExecute(const Context *rsc, const ScriptGroupBase *sg) {
48 RsdCpuReference::CpuScriptGroupBase *sgi =
49 (RsdCpuReference::CpuScriptGroupBase *)sg->mHal.drv;
50 sgi->execute();
51 }
52
rsovScriptGroupDestroy(const Context * rsc,const ScriptGroupBase * sg)53 void rsovScriptGroupDestroy(const Context *rsc, const ScriptGroupBase *sg) {
54 RsdCpuReference::CpuScriptGroupBase *sgi =
55 (RsdCpuReference::CpuScriptGroupBase *)sg->mHal.drv;
56 delete sgi;
57 }
58