• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
20 namespace android {
21 namespace renderscript {
22 
RsdCpuScriptIntrinsic(RsdCpuReferenceImpl * ctx,const Script * s,const Element * e,RsScriptIntrinsicID iid)23 RsdCpuScriptIntrinsic::RsdCpuScriptIntrinsic(RsdCpuReferenceImpl *ctx, const Script *s,
24                                              const Element *e, RsScriptIntrinsicID iid)
25         : RsdCpuScriptImpl(ctx, s) {
26 
27     mID = iid;
28     mElement.set(e);
29 }
30 
~RsdCpuScriptIntrinsic()31 RsdCpuScriptIntrinsic::~RsdCpuScriptIntrinsic() {
32 }
33 
invokeFunction(uint32_t slot,const void * params,size_t paramLength)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 
invokeRoot()39 int RsdCpuScriptIntrinsic::invokeRoot() {
40     mCtx->getContext()->setError(RS_ERROR_FATAL_DRIVER,
41                                  "Unexpected RsdCpuScriptIntrinsic::invokeRoot");
42     return 0;
43 }
44 
invokeInit()45 void RsdCpuScriptIntrinsic::invokeInit() {
46     mCtx->getContext()->setError(RS_ERROR_FATAL_DRIVER,
47                                  "Unexpected RsdCpuScriptIntrinsic::invokeInit");
48 }
49 
setGlobalVar(uint32_t slot,const void * data,size_t dataLength)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 
setGlobalVarWithElemDims(uint32_t slot,const void * data,size_t dataLength,const Element * e,const uint32_t * dims,size_t dimLength)55 void RsdCpuScriptIntrinsic::setGlobalVarWithElemDims(uint32_t slot, const void *data,
56                                                      size_t dataLength, const Element *e,
57                                                      const uint32_t *dims, size_t dimLength) {
58     mCtx->getContext()->setError(RS_ERROR_FATAL_DRIVER,
59                                  "Unexpected RsdCpuScriptIntrinsic::setGlobalVarWithElemDims");
60 }
61 
setGlobalBind(uint32_t slot,Allocation * data)62 void RsdCpuScriptIntrinsic::setGlobalBind(uint32_t slot, Allocation *data) {
63     mCtx->getContext()->setError(RS_ERROR_FATAL_DRIVER,
64                                  "Unexpected RsdCpuScriptIntrinsic::setGlobalBind");
65 }
66 
setGlobalObj(uint32_t slot,ObjectBase * data)67 void RsdCpuScriptIntrinsic::setGlobalObj(uint32_t slot, ObjectBase *data) {
68     mCtx->getContext()->setError(RS_ERROR_FATAL_DRIVER,
69                                  "Unexpected RsdCpuScriptIntrinsic::setGlobalObj");
70 }
71 
invokeFreeChildren()72 void RsdCpuScriptIntrinsic::invokeFreeChildren() {
73 }
74 
75 
preLaunch(uint32_t slot,const Allocation ** ains,uint32_t inLen,Allocation * aout,const void * usr,uint32_t usrLen,const RsScriptCall * sc)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) {
80 }
81 
postLaunch(uint32_t slot,const Allocation ** ains,uint32_t inLen,Allocation * aout,const void * usr,uint32_t usrLen,const RsScriptCall * sc)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) {
86 }
87 
invokeForEach(uint32_t slot,const Allocation ** ains,uint32_t inLen,Allocation * aout,const void * usr,uint32_t usrLen,const RsScriptCall * sc)88 void RsdCpuScriptIntrinsic::invokeForEach(uint32_t slot,
89                                           const Allocation ** ains,
90                                           uint32_t inLen,
91                                           Allocation * aout,
92                                           const void * usr,
93                                           uint32_t usrLen,
94                                           const RsScriptCall *sc) {
95 
96     MTLaunchStructForEach mtls;
97 
98     preLaunch(slot, ains, inLen, aout, usr, usrLen, sc);
99 
100     if (forEachMtlsSetup(ains, inLen, aout, usr, usrLen, sc, &mtls)) {
101         mtls.script = this;
102         mtls.fep.slot = slot;
103 
104         mtls.kernel = mRootPtr;
105         mtls.fep.usr = this;
106 
107         RsdCpuScriptImpl * oldTLS = mCtx->setTLS(this);
108         mCtx->launchForEach(ains, inLen, aout, sc, &mtls);
109         mCtx->setTLS(oldTLS);
110     }
111 
112     postLaunch(slot, ains, inLen, aout, usr, usrLen, sc);
113 }
114 
forEachKernelSetup(uint32_t slot,MTLaunchStructForEach * mtls)115 void RsdCpuScriptIntrinsic::forEachKernelSetup(uint32_t slot, MTLaunchStructForEach *mtls) {
116 
117     mtls->script = this;
118     mtls->fep.slot = slot;
119     mtls->kernel = mRootPtr;
120     mtls->fep.usr = this;
121 }
122 
123 } // namespace renderscript
124 } // namespace android
125