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