blob: a99a0628f19771f2f6cf9cd5dff7ea6f67423854 [file] [log] [blame]
Jason Samsbad80742011-03-16 16:29:28 -07001/*
Stephen Hines2980f072012-04-09 18:26:29 -07002 * Copyright (C) 2011-2012 The Android Open Source Project
Jason Samsbad80742011-03-16 16:29:28 -07003 *
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 Sams87fe59a2011-04-20 15:09:01 -070021#include <rsRuntime.h>
Jason Samsbad80742011-03-16 16:29:28 -070022
Jason Samsdbe66d62012-09-17 13:54:41 -070023namespace bcc {
24 class BCCContext;
25 class RSCompilerDriver;
26 class RSExecutable;
27}
Jason Samsbad80742011-03-16 16:29:28 -070028
29bool rsdScriptInit(const android::renderscript::Context *, android::renderscript::ScriptC *,
30 char const *resName, char const *cacheDir,
Jason Sams87fe59a2011-04-20 15:09:01 -070031 uint8_t const *bitcode, size_t bitcodeSize, uint32_t flags);
Jason Sams8eaba4f2012-08-14 14:38:05 -070032bool rsdInitIntrinsic(const android::renderscript::Context *rsc,
33 android::renderscript::Script *s,
Stephen Hines41d6c762012-08-21 17:07:38 -070034 RsScriptIntrinsicID iid,
Jason Sams8eaba4f2012-08-14 14:38:05 -070035 android::renderscript::Element *e);
36
Jason Samsbad80742011-03-16 16:29:28 -070037void rsdScriptInvokeFunction(const android::renderscript::Context *dc,
Jason Samscdfdb8f2011-03-17 16:12:47 -070038 android::renderscript::Script *script,
Jason Samsbad80742011-03-16 16:29:28 -070039 uint32_t slot,
40 const void *params,
41 size_t paramLength);
Jason Samscdfdb8f2011-03-17 16:12:47 -070042
43void rsdScriptInvokeForEach(const android::renderscript::Context *rsc,
44 android::renderscript::Script *s,
Jason Sams35e429e2011-07-13 11:26:26 -070045 uint32_t slot,
Jason Samscdfdb8f2011-03-17 16:12:47 -070046 const android::renderscript::Allocation * ain,
47 android::renderscript::Allocation * aout,
48 const void * usr,
49 uint32_t usrLen,
50 const RsScriptCall *sc);
51
Jason Samsbad80742011-03-16 16:29:28 -070052int rsdScriptInvokeRoot(const android::renderscript::Context *dc,
Jason Samscdfdb8f2011-03-17 16:12:47 -070053 android::renderscript::Script *script);
Jason Samsbad80742011-03-16 16:29:28 -070054void rsdScriptInvokeInit(const android::renderscript::Context *dc,
Jason Samscdfdb8f2011-03-17 16:12:47 -070055 android::renderscript::Script *script);
Stephen Hines4ee16ff2011-08-31 17:41:39 -070056void rsdScriptInvokeFreeChildren(const android::renderscript::Context *dc,
57 android::renderscript::Script *script);
Jason Samsbad80742011-03-16 16:29:28 -070058
59void rsdScriptSetGlobalVar(const android::renderscript::Context *,
60 const android::renderscript::Script *,
61 uint32_t slot, void *data, size_t dataLen);
Stephen Hines2980f072012-04-09 18:26:29 -070062void 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 Samsbad80742011-03-16 16:29:28 -070069void rsdScriptSetGlobalBind(const android::renderscript::Context *,
70 const android::renderscript::Script *,
Jason Sams807fdc42012-07-25 17:55:39 -070071 uint32_t slot, android::renderscript::Allocation *data);
Jason Samsbad80742011-03-16 16:29:28 -070072void rsdScriptSetGlobalObj(const android::renderscript::Context *,
73 const android::renderscript::Script *,
74 uint32_t slot, android::renderscript::ObjectBase *data);
75
76void rsdScriptSetGlobal(const android::renderscript::Context *dc,
77 const android::renderscript::Script *script,
78 uint32_t slot,
79 void *data,
80 size_t dataLength);
81void rsdScriptGetGlobal(const android::renderscript::Context *dc,
82 const android::renderscript::Script *script,
83 uint32_t slot,
84 void *data,
85 size_t dataLength);
86void rsdScriptDestroy(const android::renderscript::Context *dc,
87 android::renderscript::Script *script);
88
Jason Sams807fdc42012-07-25 17:55:39 -070089android::renderscript::Allocation * rsdScriptGetAllocationForPointer(
90 const android::renderscript::Context *dc,
91 const android::renderscript::Script *script,
92 const void *);
Jason Samsbad80742011-03-16 16:29:28 -070093
Jason Samsdbe66d62012-09-17 13:54:41 -070094
95typedef void (*outer_foreach_t)(
96 const android::renderscript::RsForEachStubParamStruct *,
97 uint32_t x1, uint32_t x2,
98 uint32_t instep, uint32_t outstep);
99
100typedef 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
118struct 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
134typedef struct {
135 android::renderscript::RsForEachStubParamStruct fep;
136 uint32_t cpuIdx;
137
138} MTThreadStuct;
139
140typedef 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
163void 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
173void 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 Samsbad80742011-03-16 16:29:28 -0700184#endif