| Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 1 | /* |
| Stephen Hines | 2980f07 | 2012-04-09 18:26:29 -0700 | [diff] [blame] | 2 | * Copyright (C) 2011-2012 The Android Open Source Project |
| Jason Sams | bad8074 | 2011-03-16 16:29:28 -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 | #ifndef RSD_BCC_H |
| 18 | #define RSD_BCC_H |
| 19 | |
| 20 | #include <rs_hal.h> |
| Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 21 | #include <rsRuntime.h> |
| Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 22 | |
| Jason Sams | dbe66d6 | 2012-09-17 13:54:41 -0700 | [diff] [blame^] | 23 | namespace bcc { |
| 24 | class BCCContext; |
| 25 | class RSCompilerDriver; |
| 26 | class RSExecutable; |
| 27 | } |
| Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 28 | |
| 29 | bool rsdScriptInit(const android::renderscript::Context *, android::renderscript::ScriptC *, |
| 30 | char const *resName, char const *cacheDir, |
| Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 31 | uint8_t const *bitcode, size_t bitcodeSize, uint32_t flags); |
| Jason Sams | 8eaba4f | 2012-08-14 14:38:05 -0700 | [diff] [blame] | 32 | bool rsdInitIntrinsic(const android::renderscript::Context *rsc, |
| 33 | android::renderscript::Script *s, |
| Stephen Hines | 41d6c76 | 2012-08-21 17:07:38 -0700 | [diff] [blame] | 34 | RsScriptIntrinsicID iid, |
| Jason Sams | 8eaba4f | 2012-08-14 14:38:05 -0700 | [diff] [blame] | 35 | android::renderscript::Element *e); |
| 36 | |
| Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 37 | void rsdScriptInvokeFunction(const android::renderscript::Context *dc, |
| Jason Sams | cdfdb8f | 2011-03-17 16:12:47 -0700 | [diff] [blame] | 38 | android::renderscript::Script *script, |
| Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 39 | uint32_t slot, |
| 40 | const void *params, |
| 41 | size_t paramLength); |
| Jason Sams | cdfdb8f | 2011-03-17 16:12:47 -0700 | [diff] [blame] | 42 | |
| 43 | void rsdScriptInvokeForEach(const android::renderscript::Context *rsc, |
| 44 | android::renderscript::Script *s, |
| Jason Sams | 35e429e | 2011-07-13 11:26:26 -0700 | [diff] [blame] | 45 | uint32_t slot, |
| Jason Sams | cdfdb8f | 2011-03-17 16:12:47 -0700 | [diff] [blame] | 46 | const android::renderscript::Allocation * ain, |
| 47 | android::renderscript::Allocation * aout, |
| 48 | const void * usr, |
| 49 | uint32_t usrLen, |
| 50 | const RsScriptCall *sc); |
| 51 | |
| Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 52 | int rsdScriptInvokeRoot(const android::renderscript::Context *dc, |
| Jason Sams | cdfdb8f | 2011-03-17 16:12:47 -0700 | [diff] [blame] | 53 | android::renderscript::Script *script); |
| Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 54 | void rsdScriptInvokeInit(const android::renderscript::Context *dc, |
| Jason Sams | cdfdb8f | 2011-03-17 16:12:47 -0700 | [diff] [blame] | 55 | android::renderscript::Script *script); |
| Stephen Hines | 4ee16ff | 2011-08-31 17:41:39 -0700 | [diff] [blame] | 56 | void rsdScriptInvokeFreeChildren(const android::renderscript::Context *dc, |
| 57 | android::renderscript::Script *script); |
| Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 58 | |
| 59 | void rsdScriptSetGlobalVar(const android::renderscript::Context *, |
| 60 | const android::renderscript::Script *, |
| 61 | uint32_t slot, void *data, size_t dataLen); |
| Stephen Hines | 2980f07 | 2012-04-09 18:26:29 -0700 | [diff] [blame] | 62 | void rsdScriptSetGlobalVarWithElemDims(const android::renderscript::Context *, |
| 63 | const android::renderscript::Script *, |
| 64 | uint32_t slot, void *data, |
| 65 | size_t dataLength, |
| 66 | const android::renderscript::Element *, |
| 67 | const size_t *dims, |
| 68 | size_t dimLength); |
| Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 69 | void rsdScriptSetGlobalBind(const android::renderscript::Context *, |
| 70 | const android::renderscript::Script *, |
| Jason Sams | 807fdc4 | 2012-07-25 17:55:39 -0700 | [diff] [blame] | 71 | uint32_t slot, android::renderscript::Allocation *data); |
| Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 72 | void rsdScriptSetGlobalObj(const android::renderscript::Context *, |
| 73 | const android::renderscript::Script *, |
| 74 | uint32_t slot, android::renderscript::ObjectBase *data); |
| 75 | |
| 76 | void rsdScriptSetGlobal(const android::renderscript::Context *dc, |
| 77 | const android::renderscript::Script *script, |
| 78 | uint32_t slot, |
| 79 | void *data, |
| 80 | size_t dataLength); |
| 81 | void rsdScriptGetGlobal(const android::renderscript::Context *dc, |
| 82 | const android::renderscript::Script *script, |
| 83 | uint32_t slot, |
| 84 | void *data, |
| 85 | size_t dataLength); |
| 86 | void rsdScriptDestroy(const android::renderscript::Context *dc, |
| 87 | android::renderscript::Script *script); |
| 88 | |
| Jason Sams | 807fdc4 | 2012-07-25 17:55:39 -0700 | [diff] [blame] | 89 | android::renderscript::Allocation * rsdScriptGetAllocationForPointer( |
| 90 | const android::renderscript::Context *dc, |
| 91 | const android::renderscript::Script *script, |
| 92 | const void *); |
| Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 93 | |
| Jason Sams | dbe66d6 | 2012-09-17 13:54:41 -0700 | [diff] [blame^] | 94 | |
| 95 | typedef void (*outer_foreach_t)( |
| 96 | const android::renderscript::RsForEachStubParamStruct *, |
| 97 | uint32_t x1, uint32_t x2, |
| 98 | uint32_t instep, uint32_t outstep); |
| 99 | |
| 100 | typedef struct RsdIntriniscFuncs_rec { |
| 101 | |
| 102 | void (*bind)(const android::renderscript::Context *dc, |
| 103 | const android::renderscript::Script *script, |
| 104 | void * intrinsicData, |
| 105 | uint32_t slot, android::renderscript::Allocation *data); |
| 106 | void (*setVar)(const android::renderscript::Context *dc, |
| 107 | const android::renderscript::Script *script, |
| 108 | void * intrinsicData, |
| 109 | uint32_t slot, void *data, size_t dataLength); |
| 110 | void (*root)(const android::renderscript::RsForEachStubParamStruct *, |
| 111 | uint32_t x1, uint32_t x2, uint32_t instep, uint32_t outstep); |
| 112 | |
| 113 | void (*destroy)(const android::renderscript::Context *dc, |
| 114 | const android::renderscript::Script *script, |
| 115 | void * intrinsicData); |
| 116 | } RsdIntriniscFuncs_t; |
| 117 | |
| 118 | struct DrvScript { |
| 119 | RsScriptIntrinsicID mIntrinsicID; |
| 120 | int (*mRoot)(); |
| 121 | int (*mRootExpand)(); |
| 122 | void (*mInit)(); |
| 123 | void (*mFreeChildren)(); |
| 124 | |
| 125 | bcc::BCCContext *mCompilerContext; |
| 126 | bcc::RSCompilerDriver *mCompilerDriver; |
| 127 | bcc::RSExecutable *mExecutable; |
| 128 | |
| 129 | android::renderscript::Allocation **mBoundAllocs; |
| 130 | RsdIntriniscFuncs_t mIntrinsicFuncs; |
| 131 | void * mIntrinsicData; |
| 132 | }; |
| 133 | |
| 134 | typedef struct { |
| 135 | android::renderscript::RsForEachStubParamStruct fep; |
| 136 | uint32_t cpuIdx; |
| 137 | |
| 138 | } MTThreadStuct; |
| 139 | |
| 140 | typedef struct { |
| 141 | android::renderscript::RsForEachStubParamStruct fep; |
| 142 | |
| 143 | android::renderscript::Context *rsc; |
| 144 | android::renderscript::Script *script; |
| 145 | ForEachFunc_t kernel; |
| 146 | uint32_t sig; |
| 147 | const android::renderscript::Allocation * ain; |
| 148 | android::renderscript::Allocation * aout; |
| 149 | |
| 150 | uint32_t mSliceSize; |
| 151 | volatile int mSliceNum; |
| 152 | |
| 153 | uint32_t xStart; |
| 154 | uint32_t xEnd; |
| 155 | uint32_t yStart; |
| 156 | uint32_t yEnd; |
| 157 | uint32_t zStart; |
| 158 | uint32_t zEnd; |
| 159 | uint32_t arrayStart; |
| 160 | uint32_t arrayEnd; |
| 161 | } MTLaunchStruct; |
| 162 | |
| 163 | void rsdScriptLaunchThreads(const android::renderscript::Context *rsc, |
| 164 | android::renderscript::Script *s, |
| 165 | uint32_t slot, |
| 166 | const android::renderscript::Allocation * ain, |
| 167 | android::renderscript::Allocation * aout, |
| 168 | const void * usr, |
| 169 | uint32_t usrLen, |
| 170 | const RsScriptCall *sc, |
| 171 | MTLaunchStruct *mtls); |
| 172 | |
| 173 | void rsdScriptInvokeForEachMtlsSetup(const android::renderscript::Context *rsc, |
| 174 | const android::renderscript::Allocation * ain, |
| 175 | android::renderscript::Allocation * aout, |
| 176 | const void * usr, |
| 177 | uint32_t usrLen, |
| 178 | const RsScriptCall *sc, |
| 179 | MTLaunchStruct *mtls); |
| 180 | |
| 181 | |
| 182 | |
| 183 | |
| Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 184 | #endif |