Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 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 | |
| 18 | #include "rsCpuIntrinsic.h" |
| 19 | |
Chih-Hung Hsieh | 462de21 | 2016-11-16 11:33:57 -0800 | [diff] [blame] | 20 | namespace android { |
| 21 | namespace renderscript { |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 22 | |
| 23 | RsdCpuScriptIntrinsic::RsdCpuScriptIntrinsic(RsdCpuReferenceImpl *ctx, const Script *s, |
Jason Sams | c905efd | 2012-11-26 15:20:18 -0800 | [diff] [blame] | 24 | const Element *e, RsScriptIntrinsicID iid) |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 25 | : RsdCpuScriptImpl(ctx, s) { |
| 26 | |
| 27 | mID = iid; |
Jason Sams | c905efd | 2012-11-26 15:20:18 -0800 | [diff] [blame] | 28 | mElement.set(e); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | RsdCpuScriptIntrinsic::~RsdCpuScriptIntrinsic() { |
| 32 | } |
| 33 | |
| 34 | void RsdCpuScriptIntrinsic::invokeFunction(uint32_t slot, const void *params, size_t paramLength) { |
| 35 | mCtx->getContext()->setError(RS_ERROR_FATAL_DRIVER, |
| 36 | "Unexpected RsdCpuScriptIntrinsic::invokeFunction"); |
| 37 | } |
| 38 | |
| 39 | int RsdCpuScriptIntrinsic::invokeRoot() { |
| 40 | mCtx->getContext()->setError(RS_ERROR_FATAL_DRIVER, |
| 41 | "Unexpected RsdCpuScriptIntrinsic::invokeRoot"); |
| 42 | return 0; |
| 43 | } |
| 44 | |
| 45 | void RsdCpuScriptIntrinsic::invokeInit() { |
| 46 | mCtx->getContext()->setError(RS_ERROR_FATAL_DRIVER, |
| 47 | "Unexpected RsdCpuScriptIntrinsic::invokeInit"); |
| 48 | } |
| 49 | |
| 50 | void RsdCpuScriptIntrinsic::setGlobalVar(uint32_t slot, const void *data, size_t dataLength) { |
| 51 | mCtx->getContext()->setError(RS_ERROR_FATAL_DRIVER, |
| 52 | "Unexpected RsdCpuScriptIntrinsic::setGlobalVar"); |
| 53 | } |
| 54 | |
| 55 | void RsdCpuScriptIntrinsic::setGlobalVarWithElemDims(uint32_t slot, const void *data, |
| 56 | size_t dataLength, const Element *e, |
Stephen Hines | ac8d146 | 2014-06-25 00:01:23 -0700 | [diff] [blame] | 57 | const uint32_t *dims, size_t dimLength) { |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 58 | mCtx->getContext()->setError(RS_ERROR_FATAL_DRIVER, |
| 59 | "Unexpected RsdCpuScriptIntrinsic::setGlobalVarWithElemDims"); |
| 60 | } |
| 61 | |
| 62 | void RsdCpuScriptIntrinsic::setGlobalBind(uint32_t slot, Allocation *data) { |
| 63 | mCtx->getContext()->setError(RS_ERROR_FATAL_DRIVER, |
| 64 | "Unexpected RsdCpuScriptIntrinsic::setGlobalBind"); |
| 65 | } |
| 66 | |
| 67 | void RsdCpuScriptIntrinsic::setGlobalObj(uint32_t slot, ObjectBase *data) { |
| 68 | mCtx->getContext()->setError(RS_ERROR_FATAL_DRIVER, |
| 69 | "Unexpected RsdCpuScriptIntrinsic::setGlobalObj"); |
| 70 | } |
| 71 | |
| 72 | void RsdCpuScriptIntrinsic::invokeFreeChildren() { |
| 73 | } |
| 74 | |
| 75 | |
Chris Wailes | f371213 | 2014-07-16 15:18:30 -0700 | [diff] [blame] | 76 | void RsdCpuScriptIntrinsic::preLaunch(uint32_t slot, const Allocation ** ains, |
| 77 | uint32_t inLen, Allocation * aout, |
| 78 | const void * usr, uint32_t usrLen, |
| 79 | const RsScriptCall *sc) { |
Jason Sams | 2282e28 | 2013-06-17 16:52:01 -0700 | [diff] [blame] | 80 | } |
| 81 | |
Chris Wailes | f371213 | 2014-07-16 15:18:30 -0700 | [diff] [blame] | 82 | void RsdCpuScriptIntrinsic::postLaunch(uint32_t slot, const Allocation ** ains, |
| 83 | uint32_t inLen, Allocation * aout, |
| 84 | const void * usr, uint32_t usrLen, |
| 85 | const RsScriptCall *sc) { |
Jason Sams | 2282e28 | 2013-06-17 16:52:01 -0700 | [diff] [blame] | 86 | } |
| 87 | |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 88 | void RsdCpuScriptIntrinsic::invokeForEach(uint32_t slot, |
Chris Wailes | f371213 | 2014-07-16 15:18:30 -0700 | [diff] [blame] | 89 | const Allocation ** ains, |
| 90 | uint32_t inLen, |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 91 | Allocation * aout, |
| 92 | const void * usr, |
| 93 | uint32_t usrLen, |
| 94 | const RsScriptCall *sc) { |
| 95 | |
Matt Wala | 14ce007 | 2015-07-30 17:30:25 -0700 | [diff] [blame] | 96 | MTLaunchStructForEach mtls; |
Jason Sams | 2282e28 | 2013-06-17 16:52:01 -0700 | [diff] [blame] | 97 | |
Chris Wailes | f371213 | 2014-07-16 15:18:30 -0700 | [diff] [blame] | 98 | preLaunch(slot, ains, inLen, aout, usr, usrLen, sc); |
Chris Wailes | 4b3c34e | 2014-06-11 12:00:29 -0700 | [diff] [blame] | 99 | |
Jason Sams | bf2111d | 2015-01-26 18:13:41 -0800 | [diff] [blame] | 100 | if (forEachMtlsSetup(ains, inLen, aout, usr, usrLen, sc, &mtls)) { |
| 101 | mtls.script = this; |
| 102 | mtls.fep.slot = slot; |
Chris Wailes | 4b3c34e | 2014-06-11 12:00:29 -0700 | [diff] [blame] | 103 | |
Matt Wala | 14ce007 | 2015-07-30 17:30:25 -0700 | [diff] [blame] | 104 | mtls.kernel = mRootPtr; |
Jason Sams | bf2111d | 2015-01-26 18:13:41 -0800 | [diff] [blame] | 105 | mtls.fep.usr = this; |
Chris Wailes | 4b3c34e | 2014-06-11 12:00:29 -0700 | [diff] [blame] | 106 | |
Jason Sams | bf2111d | 2015-01-26 18:13:41 -0800 | [diff] [blame] | 107 | RsdCpuScriptImpl * oldTLS = mCtx->setTLS(this); |
Matt Wala | 14ce007 | 2015-07-30 17:30:25 -0700 | [diff] [blame] | 108 | mCtx->launchForEach(ains, inLen, aout, sc, &mtls); |
Jason Sams | bf2111d | 2015-01-26 18:13:41 -0800 | [diff] [blame] | 109 | mCtx->setTLS(oldTLS); |
| 110 | } |
Chris Wailes | 4b3c34e | 2014-06-11 12:00:29 -0700 | [diff] [blame] | 111 | |
Chris Wailes | f371213 | 2014-07-16 15:18:30 -0700 | [diff] [blame] | 112 | postLaunch(slot, ains, inLen, aout, usr, usrLen, sc); |
Chris Wailes | 4b3c34e | 2014-06-11 12:00:29 -0700 | [diff] [blame] | 113 | } |
| 114 | |
Matt Wala | 14ce007 | 2015-07-30 17:30:25 -0700 | [diff] [blame] | 115 | void RsdCpuScriptIntrinsic::forEachKernelSetup(uint32_t slot, MTLaunchStructForEach *mtls) { |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 116 | |
| 117 | mtls->script = this; |
| 118 | mtls->fep.slot = slot; |
Matt Wala | 14ce007 | 2015-07-30 17:30:25 -0700 | [diff] [blame] | 119 | mtls->kernel = mRootPtr; |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 120 | mtls->fep.usr = this; |
| 121 | } |
Chih-Hung Hsieh | 462de21 | 2016-11-16 11:33:57 -0800 | [diff] [blame] | 122 | |
| 123 | } // namespace renderscript |
| 124 | } // namespace android |