blob: 216c6f2bef19c39e68e3f29aad5ad4620da99576 [file] [log] [blame]
Jason Sams326e0dd2009-05-22 14:03:28 -07001/*
2 * Copyright (C) 2009 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 ANDROID_RS_SCRIPT_C_H
18#define ANDROID_RS_SCRIPT_C_H
19
20#include "rsScript.h"
21
22#include "RenderScriptEnv.h"
23
Jason Samsbe36bf32010-05-11 14:03:58 -070024struct BCCscript;
Jack Palevich1ef8b802009-05-28 15:53:04 -070025
Jason Sams326e0dd2009-05-22 14:03:28 -070026// ---------------------------------------------------------------------------
27namespace android {
28namespace renderscript {
29
Jack Palevich1ef8b802009-05-28 15:53:04 -070030
Jason Sams326e0dd2009-05-22 14:03:28 -070031
32class ScriptC : public Script
33{
34public:
Jason Samsbe36bf32010-05-11 14:03:58 -070035 typedef int (*RunScript_t)();
Jason Sams1d54f102009-09-03 15:43:13 -070036 typedef void (*VoidFunc_t)();
Jason Sams326e0dd2009-05-22 14:03:28 -070037
Jason Samse514b452009-09-25 14:51:22 -070038 ScriptC(Context *);
Jason Sams326e0dd2009-05-22 14:03:28 -070039 virtual ~ScriptC();
40
Jason Samsefb8de12009-06-08 15:20:31 -070041 struct Program_t {
Jason Sams928b7342009-06-08 18:50:13 -070042 int mVersionMajor;
43 int mVersionMinor;
Jason Sams326e0dd2009-05-22 14:03:28 -070044
Jason Samsbe36bf32010-05-11 14:03:58 -070045 RunScript_t mRoot;
Jason Sams1d54f102009-09-03 15:43:13 -070046 VoidFunc_t mInit;
Jason Samsefb8de12009-06-08 15:20:31 -070047 };
48
Jason Samsefb8de12009-06-08 15:20:31 -070049 Program_t mProgram;
Jason Sams326e0dd2009-05-22 14:03:28 -070050
Jason Samsbe36bf32010-05-11 14:03:58 -070051 BCCscript* mBccScript;
Jason Sams326e0dd2009-05-22 14:03:28 -070052
Jason Samsce92d4b2010-05-17 14:55:34 -070053 const Allocation *ptrToAllocation(const void *) const;
54
Jason Sams22fa3712010-05-19 17:22:57 -070055 void setTLS();
56 void clearTLS();
57
58 virtual void Invoke(Context *rsc, uint32_t slot, const void *data, uint32_t len);
59
Jason Samsada7f272009-09-24 14:55:38 -070060 virtual void setupScript();
Jason Sams2dca84d2009-12-09 11:05:45 -080061 virtual uint32_t run(Context *, uint32_t launchID);
Alex Sakhartchoukfb6b6142010-05-21 12:53:13 -070062
63 virtual void serialize(OStream *stream) const { }
64 virtual A3DClassID getClassId() const { return A3D_CLASS_ID_SCRIPT_C; }
65 static Type *createFromStream(Context *rsc, IStream *stream) { return NULL; }
Jason Sams326e0dd2009-05-22 14:03:28 -070066};
67
Jack Palevich1ef8b802009-05-28 15:53:04 -070068class ScriptCState
Jason Sams326e0dd2009-05-22 14:03:28 -070069{
70public:
71 ScriptCState();
72 ~ScriptCState();
73
Jason Sams8c6bc692009-09-16 15:04:38 -070074 ScriptC *mScript;
Jason Sams326e0dd2009-05-22 14:03:28 -070075
Jason Sams8b2c0652009-08-12 17:54:11 -070076 ObjectBaseRef<const Type> mConstantBufferTypes[MAX_SCRIPT_BANKS];
Jason Samsbe36bf32010-05-11 14:03:58 -070077 //String8 mSlotNames[MAX_SCRIPT_BANKS];
Jason Sams90b36a82009-08-17 13:56:09 -070078 bool mSlotWritable[MAX_SCRIPT_BANKS];
Jason Samsbe36bf32010-05-11 14:03:58 -070079 //String8 mInvokableNames[MAX_SCRIPT_BANKS];
Jason Sams326e0dd2009-05-22 14:03:28 -070080
81 void clear();
Jason Sams8c6bc692009-09-16 15:04:38 -070082 void runCompiler(Context *rsc, ScriptC *s);
Jason Sams29df66f2009-07-16 15:08:06 -070083
84 struct SymbolTable_t {
85 const char * mName;
86 void * mPtr;
Jason Sams29df66f2009-07-16 15:08:06 -070087 };
Jason Samsaeb094b2010-05-18 13:35:45 -070088 //static SymbolTable_t gSyms[];
Jason Sams29df66f2009-07-16 15:08:06 -070089 static const SymbolTable_t * lookupSymbol(const char *);
Jason Samsaeb094b2010-05-18 13:35:45 -070090 static const SymbolTable_t * lookupSymbolCL(const char *);
91 static const SymbolTable_t * lookupSymbolGL(const char *);
Jason Sams326e0dd2009-05-22 14:03:28 -070092};
93
94
95}
96}
97#endif
98
99
100