Jason Sams | dbe66d6 | 2012-09-17 13:54:41 -0700 | [diff] [blame] | 1 | /* |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 2 | * Copyright (C) 2011-2012 The Android Open Source Project |
Jason Sams | dbe66d6 | 2012-09-17 13:54:41 -0700 | [diff] [blame] | 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" |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 18 | #include "../cpu_ref/rsd_cpu.h" |
Jason Sams | dbe66d6 | 2012-09-17 13:54:41 -0700 | [diff] [blame] | 19 | |
Jason Sams | dbe66d6 | 2012-09-17 13:54:41 -0700 | [diff] [blame] | 20 | |
| 21 | #include "rsScript.h" |
| 22 | #include "rsScriptGroup.h" |
| 23 | #include "rsdScriptGroup.h" |
| 24 | #include "rsdBcc.h" |
Jason Sams | bee28c6 | 2012-10-25 18:15:54 -0700 | [diff] [blame] | 25 | #include "rsdAllocation.h" |
Jason Sams | dbe66d6 | 2012-09-17 13:54:41 -0700 | [diff] [blame] | 26 | |
| 27 | using namespace android; |
| 28 | using namespace android::renderscript; |
| 29 | |
| 30 | |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 31 | bool rsdScriptGroupInit(const Context *rsc, ScriptGroup *sg) { |
| 32 | RsdHal *dc = (RsdHal *)rsc->mHal.drv; |
| 33 | |
| 34 | sg->mHal.drv = dc->mCpuRef->createScriptGroup(sg); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame] | 35 | return sg->mHal.drv != nullptr; |
Jason Sams | dbe66d6 | 2012-09-17 13:54:41 -0700 | [diff] [blame] | 36 | } |
| 37 | |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 38 | void rsdScriptGroupSetInput(const Context *rsc, const ScriptGroup *sg, |
| 39 | const ScriptKernelID *kid, Allocation *) { |
Jason Sams | dbe66d6 | 2012-09-17 13:54:41 -0700 | [diff] [blame] | 40 | } |
| 41 | |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 42 | void rsdScriptGroupSetOutput(const Context *rsc, const ScriptGroup *sg, |
| 43 | const ScriptKernelID *kid, Allocation *) { |
Jason Sams | dbe66d6 | 2012-09-17 13:54:41 -0700 | [diff] [blame] | 44 | } |
| 45 | |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 46 | void rsdScriptGroupExecute(const Context *rsc, const ScriptGroup *sg) { |
| 47 | RsdCpuReference::CpuScriptGroup *sgi = (RsdCpuReference::CpuScriptGroup *)sg->mHal.drv; |
| 48 | sgi->execute(); |
Jason Sams | bee28c6 | 2012-10-25 18:15:54 -0700 | [diff] [blame] | 49 | } |
| 50 | |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 51 | void rsdScriptGroupDestroy(const Context *rsc, const ScriptGroup *sg) { |
| 52 | RsdCpuReference::CpuScriptGroup *sgi = (RsdCpuReference::CpuScriptGroup *)sg->mHal.drv; |
| 53 | delete sgi; |
Jason Sams | dbe66d6 | 2012-09-17 13:54:41 -0700 | [diff] [blame] | 54 | } |
| 55 | |
Jason Sams | a36c50a | 2014-06-17 12:06:06 -0700 | [diff] [blame] | 56 | void rsdScriptGroupUpdateCachedObject(const Context *rsc, |
| 57 | const ScriptGroup *sg, |
| 58 | rs_script_group *obj) |
| 59 | { |
| 60 | obj->p = sg; |
| 61 | #ifdef __LP64__ |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame] | 62 | obj->r = nullptr; |
| 63 | if (sg != nullptr) { |
Jason Sams | a36c50a | 2014-06-17 12:06:06 -0700 | [diff] [blame] | 64 | obj->v1 = sg->mHal.drv; |
| 65 | } else { |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame] | 66 | obj->v1 = nullptr; |
Jason Sams | a36c50a | 2014-06-17 12:06:06 -0700 | [diff] [blame] | 67 | } |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame] | 68 | obj->v2 = nullptr; |
Jason Sams | a36c50a | 2014-06-17 12:06:06 -0700 | [diff] [blame] | 69 | #endif |
| 70 | } |
| 71 | |
Jason Sams | dbe66d6 | 2012-09-17 13:54:41 -0700 | [diff] [blame] | 72 | |