blob: 7d52507aea34f8d75627bb2c1ed6a46a228e1365 [file] [log] [blame]
Jason Sams709a0972012-11-15 18:18:04 -08001/*
2 * Copyright (C) 2011-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#ifndef RSD_BCC_H
18#define RSD_BCC_H
19
20#include <rs_hal.h>
21#include <rsRuntime.h>
22
23#include "rsCpuCore.h"
24
25namespace bcc {
26 class BCCContext;
27 class RSCompilerDriver;
28 class RSExecutable;
29}
30
31namespace android {
32namespace renderscript {
33
34
35
36class RsdCpuScriptImpl : public RsdCpuReferenceImpl::CpuScript {
37public:
38 typedef void (*outer_foreach_t)(
39 const RsForEachStubParamStruct *,
40 uint32_t x1, uint32_t x2,
41 uint32_t instep, uint32_t outstep);
Jason Sams110f1812013-03-14 16:02:18 -070042#ifdef RS_COMPATIBILITY_LIB
43 typedef void (* InvokeFunc_t)(void);
44 typedef void (* ForEachFunc_t)(void);
45 typedef int (* RootFunc_t)(void);
46 typedef void (*WorkerCallback_t)(void *usr, uint32_t idx);
47#endif
Jason Sams709a0972012-11-15 18:18:04 -080048
49 bool init(char const *resName, char const *cacheDir,
50 uint8_t const *bitcode, size_t bitcodeSize, uint32_t flags);
51 virtual void populateScript(Script *);
52
53 virtual void invokeFunction(uint32_t slot, const void *params, size_t paramLength);
54 virtual int invokeRoot();
55 virtual void invokeForEach(uint32_t slot,
56 const Allocation * ain,
57 Allocation * aout,
58 const void * usr,
59 uint32_t usrLen,
60 const RsScriptCall *sc);
61 virtual void invokeInit();
62 virtual void invokeFreeChildren();
63
64 virtual void setGlobalVar(uint32_t slot, const void *data, size_t dataLength);
Tim Murray9c642392013-04-11 13:29:59 -070065 virtual void getGlobalVar(uint32_t slot, void *data, size_t dataLength);
Jason Sams709a0972012-11-15 18:18:04 -080066 virtual void setGlobalVarWithElemDims(uint32_t slot, const void *data, size_t dataLength,
67 const Element *e, const size_t *dims, size_t dimLength);
68 virtual void setGlobalBind(uint32_t slot, Allocation *data);
69 virtual void setGlobalObj(uint32_t slot, ObjectBase *data);
70
71
72 virtual ~RsdCpuScriptImpl();
73 RsdCpuScriptImpl(RsdCpuReferenceImpl *ctx, const Script *s);
74
75 const Script * getScript() {return mScript;}
76
77 void forEachMtlsSetup(const Allocation * ain, Allocation * aout,
78 const void * usr, uint32_t usrLen,
79 const RsScriptCall *sc, MTLaunchStruct *mtls);
80 virtual void forEachKernelSetup(uint32_t slot, MTLaunchStruct *mtls);
81
82
83 const RsdCpuReference::CpuSymbol * lookupSymbolMath(const char *sym);
84 static void * lookupRuntimeStub(void* pContext, char const* name);
85
86 virtual Allocation * getAllocationForPointer(const void *ptr) const;
87
Jason Samscadfac42013-03-06 18:09:08 -080088#ifndef RS_COMPATIBILITY_LIB
Stephen Hinesf218bf12013-02-12 19:32:38 -080089 virtual void * getRSExecutable() { return mExecutable; }
Jason Samscadfac42013-03-06 18:09:08 -080090#endif
Jason Sams709a0972012-11-15 18:18:04 -080091
92protected:
93 RsdCpuReferenceImpl *mCtx;
94 const Script *mScript;
95
Jason Sams110f1812013-03-14 16:02:18 -070096#ifndef RS_COMPATIBILITY_LIB
Jason Sams709a0972012-11-15 18:18:04 -080097 int (*mRoot)();
98 int (*mRootExpand)();
99 void (*mInit)();
100 void (*mFreeChildren)();
101
102 bcc::BCCContext *mCompilerContext;
103 bcc::RSCompilerDriver *mCompilerDriver;
104 bcc::RSExecutable *mExecutable;
Jason Sams110f1812013-03-14 16:02:18 -0700105#else
106 void *mScriptSO;
107 RootFunc_t mRoot;
108 RootFunc_t mRootExpand;
109 InvokeFunc_t mInit;
110 InvokeFunc_t mFreeChildren;
111 InvokeFunc_t *mInvokeFunctions;
112 ForEachFunc_t *mForEachFunctions;
113
114 void **mFieldAddress;
115 bool *mFieldIsObject;
116 uint32_t *mForEachSignatures;
117
118 // for populate script
119 //int mVersionMajor;
120 //int mVersionMinor;
121 size_t mExportedVariableCount;
122 size_t mExportedFunctionCount;
123#endif
Jason Sams709a0972012-11-15 18:18:04 -0800124
125 Allocation **mBoundAllocs;
126 void * mIntrinsicData;
127 bool mIsThreadable;
128
129};
130
131
132Allocation * rsdScriptGetAllocationForPointer(
133 const Context *dc,
134 const Script *script,
135 const void *);
136
137
138
139}
140}
141
142#endif