| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 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 "rsCpuCore.h" |
| 18 | #include "rsCpuScript.h" |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 19 | #include "rsScriptGroup.h" |
| 20 | #include "rsCpuScriptGroup.h" |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 21 | |
| Miao Wang | 82e135c | 2017-02-27 23:35:35 -0800 | [diff] [blame] | 22 | #include <vector> |
| 23 | |
| Chih-Hung Hsieh | 462de21 | 2016-11-16 11:33:57 -0800 | [diff] [blame] | 24 | namespace android { |
| 25 | namespace renderscript { |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 26 | |
| Yang Ni | 1ffd86b | 2015-01-07 09:16:40 -0800 | [diff] [blame] | 27 | CpuScriptGroupImpl::CpuScriptGroupImpl(RsdCpuReferenceImpl *ctx, const ScriptGroupBase *sg) { |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 28 | mCtx = ctx; |
| Yang Ni | 1ffd86b | 2015-01-07 09:16:40 -0800 | [diff] [blame] | 29 | mSG = (ScriptGroup*)sg; |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | CpuScriptGroupImpl::~CpuScriptGroupImpl() { |
| 33 | |
| 34 | } |
| 35 | |
| 36 | bool CpuScriptGroupImpl::init() { |
| 37 | return true; |
| 38 | } |
| 39 | |
| 40 | void CpuScriptGroupImpl::setInput(const ScriptKernelID *kid, Allocation *a) { |
| 41 | } |
| 42 | |
| 43 | void CpuScriptGroupImpl::setOutput(const ScriptKernelID *kid, Allocation *a) { |
| 44 | } |
| 45 | |
| 46 | |
| David Gross | b0abb14 | 2015-03-12 15:23:03 -0700 | [diff] [blame] | 47 | typedef void (*ScriptGroupRootFunc_t)(const RsExpandKernelDriverInfo *kinfo, |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 48 | uint32_t xstart, uint32_t xend, |
| Chris Wailes | 9ed7910 | 2014-07-25 15:53:28 -0700 | [diff] [blame] | 49 | uint32_t outstep); |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 50 | |
| David Gross | b0abb14 | 2015-03-12 15:23:03 -0700 | [diff] [blame] | 51 | void CpuScriptGroupImpl::scriptGroupRoot(const RsExpandKernelDriverInfo *kinfo, |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 52 | uint32_t xstart, uint32_t xend, |
| Chris Wailes | 9ed7910 | 2014-07-25 15:53:28 -0700 | [diff] [blame] | 53 | uint32_t outstep) { |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 54 | |
| 55 | |
| David Gross | b0abb14 | 2015-03-12 15:23:03 -0700 | [diff] [blame] | 56 | const ScriptList *sl = (const ScriptList *)kinfo->usr; |
| 57 | RsExpandKernelDriverInfo *mkinfo = const_cast<RsExpandKernelDriverInfo *>(kinfo); |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 58 | |
| David Gross | b0abb14 | 2015-03-12 15:23:03 -0700 | [diff] [blame] | 59 | const uint32_t oldInStride = mkinfo->inStride[0]; |
| Chris Wailes | f371213 | 2014-07-16 15:18:30 -0700 | [diff] [blame] | 60 | |
| Chris Wailes | 80ef693 | 2014-07-08 11:22:18 -0700 | [diff] [blame] | 61 | for (size_t ct = 0; ct < sl->count; ct++) { |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 62 | ScriptGroupRootFunc_t func; |
| Chris Wailes | 80ef693 | 2014-07-08 11:22:18 -0700 | [diff] [blame] | 63 | func = (ScriptGroupRootFunc_t)sl->fnPtrs[ct]; |
| David Gross | b0abb14 | 2015-03-12 15:23:03 -0700 | [diff] [blame] | 64 | mkinfo->usr = sl->usrPtrs[ct]; |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 65 | |
| Stephen Hines | 4b2bea3 | 2014-08-13 17:32:10 +0000 | [diff] [blame] | 66 | if (sl->ins[ct]) { |
| David Gross | b0abb14 | 2015-03-12 15:23:03 -0700 | [diff] [blame] | 67 | rsAssert(kinfo->inLen == 1); |
| Stephen Hines | 4b2bea3 | 2014-08-13 17:32:10 +0000 | [diff] [blame] | 68 | |
| David Gross | b0abb14 | 2015-03-12 15:23:03 -0700 | [diff] [blame] | 69 | mkinfo->inPtr[0] = (const uint8_t *)sl->ins[ct]->mHal.drvState.lod[0].mallocPtr; |
| 70 | |
| 71 | mkinfo->inStride[0] = sl->ins[ct]->mHal.state.elementSizeBytes; |
| Chris Wailes | 80ef693 | 2014-07-08 11:22:18 -0700 | [diff] [blame] | 72 | |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 73 | if (sl->inExts[ct]) { |
| David Gross | b0abb14 | 2015-03-12 15:23:03 -0700 | [diff] [blame] | 74 | mkinfo->inPtr[0] = |
| 75 | (mkinfo->inPtr[0] + |
| 76 | sl->ins[ct]->mHal.drvState.lod[0].stride * kinfo->current.y); |
| Chris Wailes | 80ef693 | 2014-07-08 11:22:18 -0700 | [diff] [blame] | 77 | |
| David Gross | b0abb14 | 2015-03-12 15:23:03 -0700 | [diff] [blame] | 78 | } else if (sl->ins[ct]->mHal.drvState.lod[0].dimY > kinfo->lid) { |
| 79 | mkinfo->inPtr[0] = |
| 80 | (mkinfo->inPtr[0] + |
| 81 | sl->ins[ct]->mHal.drvState.lod[0].stride * kinfo->lid); |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 82 | } |
| Chris Wailes | f371213 | 2014-07-16 15:18:30 -0700 | [diff] [blame] | 83 | |
| 84 | } else { |
| David Gross | b0abb14 | 2015-03-12 15:23:03 -0700 | [diff] [blame] | 85 | rsAssert(kinfo->inLen == 0); |
| 86 | |
| 87 | mkinfo->inPtr[0] = nullptr; |
| 88 | mkinfo->inStride[0] = 0; |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 89 | } |
| 90 | |
| Chris Wailes | f371213 | 2014-07-16 15:18:30 -0700 | [diff] [blame] | 91 | uint32_t ostep; |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 92 | if (sl->outs[ct]) { |
| David Gross | b0abb14 | 2015-03-12 15:23:03 -0700 | [diff] [blame] | 93 | mkinfo->outPtr[0] = |
| Chris Wailes | 80ef693 | 2014-07-08 11:22:18 -0700 | [diff] [blame] | 94 | (uint8_t *)sl->outs[ct]->mHal.drvState.lod[0].mallocPtr; |
| 95 | |
| Jason Sams | 17e3cdc | 2013-09-09 17:32:16 -0700 | [diff] [blame] | 96 | ostep = sl->outs[ct]->mHal.state.elementSizeBytes; |
| Chris Wailes | 80ef693 | 2014-07-08 11:22:18 -0700 | [diff] [blame] | 97 | |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 98 | if (sl->outExts[ct]) { |
| David Gross | b0abb14 | 2015-03-12 15:23:03 -0700 | [diff] [blame] | 99 | mkinfo->outPtr[0] = |
| 100 | mkinfo->outPtr[0] + |
| 101 | sl->outs[ct]->mHal.drvState.lod[0].stride * kinfo->current.y; |
| Chris Wailes | 80ef693 | 2014-07-08 11:22:18 -0700 | [diff] [blame] | 102 | |
| David Gross | b0abb14 | 2015-03-12 15:23:03 -0700 | [diff] [blame] | 103 | } else if (sl->outs[ct]->mHal.drvState.lod[0].dimY > kinfo->lid) { |
| 104 | mkinfo->outPtr[0] = |
| 105 | mkinfo->outPtr[0] + |
| 106 | sl->outs[ct]->mHal.drvState.lod[0].stride * kinfo->lid; |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 107 | } |
| Chris Wailes | f371213 | 2014-07-16 15:18:30 -0700 | [diff] [blame] | 108 | } else { |
| David Gross | b0abb14 | 2015-03-12 15:23:03 -0700 | [diff] [blame] | 109 | mkinfo->outPtr[0] = nullptr; |
| 110 | ostep = 0; |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | //ALOGE("kernel %i %p,%p %p,%p", ct, mp->ptrIn, mp->in, mp->ptrOut, mp->out); |
| David Gross | b0abb14 | 2015-03-12 15:23:03 -0700 | [diff] [blame] | 114 | func(kinfo, xstart, xend, ostep); |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 115 | } |
| 116 | //ALOGE("script group root"); |
| 117 | |
| David Gross | b0abb14 | 2015-03-12 15:23:03 -0700 | [diff] [blame] | 118 | mkinfo->inStride[0] = oldInStride; |
| 119 | mkinfo->usr = sl; |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | |
| 123 | |
| 124 | void CpuScriptGroupImpl::execute() { |
| Miao Wang | 82e135c | 2017-02-27 23:35:35 -0800 | [diff] [blame] | 125 | std::vector<Allocation *> ins; |
| 126 | std::vector<uint8_t> inExts; |
| 127 | std::vector<Allocation *> outs; |
| 128 | std::vector<uint8_t> outExts; |
| 129 | std::vector<const ScriptKernelID *> kernels; |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 130 | bool fieldDep = false; |
| 131 | |
| 132 | for (size_t ct=0; ct < mSG->mNodes.size(); ct++) { |
| 133 | ScriptGroup::Node *n = mSG->mNodes[ct]; |
| 134 | Script *s = n->mKernels[0]->mScript; |
| Stephen Hines | c78839b | 2013-09-10 17:40:41 -0700 | [diff] [blame] | 135 | if (s->hasObjectSlots()) { |
| 136 | // Disable the ScriptGroup optimization if we have global RS |
| 137 | // objects that might interfere between kernels. |
| 138 | fieldDep = true; |
| 139 | } |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 140 | |
| 141 | //ALOGE("node %i, order %i, in %i out %i", (int)ct, n->mOrder, (int)n->mInputs.size(), (int)n->mOutputs.size()); |
| 142 | |
| 143 | for (size_t ct2=0; ct2 < n->mInputs.size(); ct2++) { |
| 144 | if (n->mInputs[ct2]->mDstField.get() && n->mInputs[ct2]->mDstField->mScript) { |
| 145 | //ALOGE("field %p %zu", n->mInputs[ct2]->mDstField->mScript, n->mInputs[ct2]->mDstField->mSlot); |
| 146 | s->setVarObj(n->mInputs[ct2]->mDstField->mSlot, n->mInputs[ct2]->mAlloc.get()); |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | for (size_t ct2=0; ct2 < n->mKernels.size(); ct2++) { |
| 151 | const ScriptKernelID *k = n->mKernels[ct2]; |
| Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame] | 152 | Allocation *ain = nullptr; |
| 153 | Allocation *aout = nullptr; |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 154 | bool inExt = false; |
| 155 | bool outExt = false; |
| 156 | |
| 157 | for (size_t ct3=0; ct3 < n->mInputs.size(); ct3++) { |
| 158 | if (n->mInputs[ct3]->mDstKernel.get() == k) { |
| 159 | ain = n->mInputs[ct3]->mAlloc.get(); |
| Yang Ni | 5f6f16f | 2014-07-25 13:51:09 -0700 | [diff] [blame] | 160 | break; |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 161 | } |
| 162 | } |
| Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame] | 163 | if (ain == nullptr) { |
| Yang Ni | 5f6f16f | 2014-07-25 13:51:09 -0700 | [diff] [blame] | 164 | for (size_t ct3=0; ct3 < mSG->mInputs.size(); ct3++) { |
| 165 | if (mSG->mInputs[ct3]->mKernel == k) { |
| 166 | ain = mSG->mInputs[ct3]->mAlloc.get(); |
| 167 | inExt = true; |
| 168 | break; |
| 169 | } |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 170 | } |
| 171 | } |
| 172 | |
| 173 | for (size_t ct3=0; ct3 < n->mOutputs.size(); ct3++) { |
| 174 | if (n->mOutputs[ct3]->mSource.get() == k) { |
| 175 | aout = n->mOutputs[ct3]->mAlloc.get(); |
| Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame] | 176 | if(n->mOutputs[ct3]->mDstField.get() != nullptr) { |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 177 | fieldDep = true; |
| 178 | } |
| Yang Ni | 5f6f16f | 2014-07-25 13:51:09 -0700 | [diff] [blame] | 179 | break; |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 180 | } |
| 181 | } |
| Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame] | 182 | if (aout == nullptr) { |
| Yang Ni | 5f6f16f | 2014-07-25 13:51:09 -0700 | [diff] [blame] | 183 | for (size_t ct3=0; ct3 < mSG->mOutputs.size(); ct3++) { |
| 184 | if (mSG->mOutputs[ct3]->mKernel == k) { |
| 185 | aout = mSG->mOutputs[ct3]->mAlloc.get(); |
| 186 | outExt = true; |
| 187 | break; |
| 188 | } |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 189 | } |
| 190 | } |
| 191 | |
| Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame] | 192 | rsAssert((k->mHasKernelOutput == (aout != nullptr)) && |
| 193 | (k->mHasKernelInput == (ain != nullptr))); |
| Yang Ni | 5f6f16f | 2014-07-25 13:51:09 -0700 | [diff] [blame] | 194 | |
| Miao Wang | 82e135c | 2017-02-27 23:35:35 -0800 | [diff] [blame] | 195 | ins.push_back(ain); |
| 196 | inExts.push_back(inExt); |
| 197 | outs.push_back(aout); |
| 198 | outExts.push_back(outExt); |
| 199 | kernels.push_back(k); |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 200 | } |
| 201 | |
| 202 | } |
| 203 | |
| Matt Wala | 14ce007 | 2015-07-30 17:30:25 -0700 | [diff] [blame] | 204 | MTLaunchStructForEach mtls; |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 205 | |
| Chris Wailes | f371213 | 2014-07-16 15:18:30 -0700 | [diff] [blame] | 206 | if (fieldDep) { |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 207 | for (size_t ct=0; ct < ins.size(); ct++) { |
| 208 | Script *s = kernels[ct]->mScript; |
| 209 | RsdCpuScriptImpl *si = (RsdCpuScriptImpl *)mCtx->lookupScript(s); |
| 210 | uint32_t slot = kernels[ct]->mSlot; |
| 211 | |
| Chris Wailes | f371213 | 2014-07-16 15:18:30 -0700 | [diff] [blame] | 212 | uint32_t inLen; |
| 213 | const Allocation **ains; |
| 214 | |
| Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame] | 215 | if (ins[ct] == nullptr) { |
| Chris Wailes | f371213 | 2014-07-16 15:18:30 -0700 | [diff] [blame] | 216 | inLen = 0; |
| Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame] | 217 | ains = nullptr; |
| Chris Wailes | f371213 | 2014-07-16 15:18:30 -0700 | [diff] [blame] | 218 | |
| 219 | } else { |
| 220 | inLen = 1; |
| 221 | ains = const_cast<const Allocation**>(&ins[ct]); |
| 222 | } |
| 223 | |
| Jason Sams | bf2111d | 2015-01-26 18:13:41 -0800 | [diff] [blame] | 224 | bool launchOK = si->forEachMtlsSetup(ains, inLen, outs[ct], nullptr, 0, nullptr, &mtls); |
| Chris Wailes | f371213 | 2014-07-16 15:18:30 -0700 | [diff] [blame] | 225 | |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 226 | si->forEachKernelSetup(slot, &mtls); |
| Chris Wailes | f371213 | 2014-07-16 15:18:30 -0700 | [diff] [blame] | 227 | si->preLaunch(slot, ains, inLen, outs[ct], mtls.fep.usr, |
| Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame] | 228 | mtls.fep.usrLen, nullptr); |
| Chris Wailes | f371213 | 2014-07-16 15:18:30 -0700 | [diff] [blame] | 229 | |
| Jason Sams | bf2111d | 2015-01-26 18:13:41 -0800 | [diff] [blame] | 230 | if (launchOK) { |
| Matt Wala | 14ce007 | 2015-07-30 17:30:25 -0700 | [diff] [blame] | 231 | mCtx->launchForEach(ains, inLen, outs[ct], nullptr, &mtls); |
| Jason Sams | bf2111d | 2015-01-26 18:13:41 -0800 | [diff] [blame] | 232 | } |
| Chris Wailes | f371213 | 2014-07-16 15:18:30 -0700 | [diff] [blame] | 233 | |
| Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame] | 234 | si->postLaunch(slot, ains, inLen, outs[ct], nullptr, 0, nullptr); |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 235 | } |
| 236 | } else { |
| 237 | ScriptList sl; |
| Miao Wang | 82e135c | 2017-02-27 23:35:35 -0800 | [diff] [blame] | 238 | sl.ins = ins.data(); |
| 239 | sl.outs = outs.data(); |
| 240 | sl.kernels = kernels.data(); |
| Yang Ni | b8353c5 | 2015-02-14 18:00:59 -0800 | [diff] [blame] | 241 | sl.count = kernels.size(); |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 242 | |
| Chris Wailes | f371213 | 2014-07-16 15:18:30 -0700 | [diff] [blame] | 243 | uint32_t inLen; |
| 244 | const Allocation **ains; |
| 245 | |
| Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame] | 246 | if (ins[0] == nullptr) { |
| Chris Wailes | f371213 | 2014-07-16 15:18:30 -0700 | [diff] [blame] | 247 | inLen = 0; |
| Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame] | 248 | ains = nullptr; |
| Chris Wailes | f371213 | 2014-07-16 15:18:30 -0700 | [diff] [blame] | 249 | |
| 250 | } else { |
| 251 | inLen = 1; |
| 252 | ains = const_cast<const Allocation**>(&ins[0]); |
| 253 | } |
| 254 | |
| Miao Wang | 82e135c | 2017-02-27 23:35:35 -0800 | [diff] [blame] | 255 | std::vector<const void *> usrPtrs; |
| 256 | std::vector<const void *> fnPtrs; |
| 257 | std::vector<uint32_t> sigs; |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 258 | for (size_t ct=0; ct < kernels.size(); ct++) { |
| 259 | Script *s = kernels[ct]->mScript; |
| 260 | RsdCpuScriptImpl *si = (RsdCpuScriptImpl *)mCtx->lookupScript(s); |
| 261 | |
| 262 | si->forEachKernelSetup(kernels[ct]->mSlot, &mtls); |
| Miao Wang | 82e135c | 2017-02-27 23:35:35 -0800 | [diff] [blame] | 263 | fnPtrs.push_back((void *)mtls.kernel); |
| 264 | usrPtrs.push_back(mtls.fep.usr); |
| 265 | sigs.push_back(mtls.fep.usrLen); |
| Chris Wailes | f371213 | 2014-07-16 15:18:30 -0700 | [diff] [blame] | 266 | si->preLaunch(kernels[ct]->mSlot, ains, inLen, outs[ct], |
| Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame] | 267 | mtls.fep.usr, mtls.fep.usrLen, nullptr); |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 268 | } |
| Miao Wang | 82e135c | 2017-02-27 23:35:35 -0800 | [diff] [blame] | 269 | sl.sigs = sigs.data(); |
| 270 | sl.usrPtrs = usrPtrs.data(); |
| 271 | sl.fnPtrs = fnPtrs.data(); |
| 272 | sl.inExts = inExts.data(); |
| 273 | sl.outExts = outExts.data(); |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 274 | |
| 275 | Script *s = kernels[0]->mScript; |
| 276 | RsdCpuScriptImpl *si = (RsdCpuScriptImpl *)mCtx->lookupScript(s); |
| Chris Wailes | f371213 | 2014-07-16 15:18:30 -0700 | [diff] [blame] | 277 | |
| Jason Sams | bf2111d | 2015-01-26 18:13:41 -0800 | [diff] [blame] | 278 | if (si->forEachMtlsSetup(ains, inLen, outs[0], nullptr, 0, nullptr, &mtls)) { |
| Chris Wailes | f371213 | 2014-07-16 15:18:30 -0700 | [diff] [blame] | 279 | |
| Jason Sams | bf2111d | 2015-01-26 18:13:41 -0800 | [diff] [blame] | 280 | mtls.script = nullptr; |
| Matt Wala | 14ce007 | 2015-07-30 17:30:25 -0700 | [diff] [blame] | 281 | mtls.kernel = &scriptGroupRoot; |
| Jason Sams | bf2111d | 2015-01-26 18:13:41 -0800 | [diff] [blame] | 282 | mtls.fep.usr = &sl; |
| Chris Wailes | f371213 | 2014-07-16 15:18:30 -0700 | [diff] [blame] | 283 | |
| Matt Wala | 14ce007 | 2015-07-30 17:30:25 -0700 | [diff] [blame] | 284 | mCtx->launchForEach(ains, inLen, outs[0], nullptr, &mtls); |
| Jason Sams | bf2111d | 2015-01-26 18:13:41 -0800 | [diff] [blame] | 285 | } |
| Jason Sams | 17e3cdc | 2013-09-09 17:32:16 -0700 | [diff] [blame] | 286 | |
| 287 | for (size_t ct=0; ct < kernels.size(); ct++) { |
| 288 | Script *s = kernels[ct]->mScript; |
| 289 | RsdCpuScriptImpl *si = (RsdCpuScriptImpl *)mCtx->lookupScript(s); |
| Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame] | 290 | si->postLaunch(kernels[ct]->mSlot, ains, inLen, outs[ct], nullptr, 0, |
| 291 | nullptr); |
| Jason Sams | 17e3cdc | 2013-09-09 17:32:16 -0700 | [diff] [blame] | 292 | } |
| Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 293 | } |
| 294 | } |
| Chih-Hung Hsieh | 462de21 | 2016-11-16 11:33:57 -0800 | [diff] [blame] | 295 | |
| 296 | } // namespace renderscript |
| 297 | } // namespace android |