blob: 1aab08c0a86415c9441b1fd4d824aced7bdaebd9 [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
Joe Onorato57b79ce2009-08-09 22:57:44 -070024#include <utils/KeyedVector.h>
25
Jason Samsbe36bf32010-05-11 14:03:58 -070026struct BCCscript;
Jack Palevich1ef8b802009-05-28 15:53:04 -070027
Jason Sams326e0dd2009-05-22 14:03:28 -070028// ---------------------------------------------------------------------------
29namespace android {
30namespace renderscript {
31
Jack Palevich1ef8b802009-05-28 15:53:04 -070032
Jason Sams326e0dd2009-05-22 14:03:28 -070033
34class ScriptC : public Script
35{
36public:
Jason Samsbe36bf32010-05-11 14:03:58 -070037 typedef int (*RunScript_t)();
Jason Sams1d54f102009-09-03 15:43:13 -070038 typedef void (*VoidFunc_t)();
Jason Sams326e0dd2009-05-22 14:03:28 -070039
Jason Samse514b452009-09-25 14:51:22 -070040 ScriptC(Context *);
Jason Sams326e0dd2009-05-22 14:03:28 -070041 virtual ~ScriptC();
42
Jason Samsefb8de12009-06-08 15:20:31 -070043 struct Program_t {
Jason Sams928b7342009-06-08 18:50:13 -070044 int mVersionMajor;
45 int mVersionMinor;
Jason Sams326e0dd2009-05-22 14:03:28 -070046
Jason Samsbe36bf32010-05-11 14:03:58 -070047 RunScript_t mRoot;
Jason Sams1d54f102009-09-03 15:43:13 -070048 VoidFunc_t mInit;
Jason Samsefb8de12009-06-08 15:20:31 -070049 };
50
Jason Samsefb8de12009-06-08 15:20:31 -070051 Program_t mProgram;
Jason Sams326e0dd2009-05-22 14:03:28 -070052
Jason Samsbe36bf32010-05-11 14:03:58 -070053 BCCscript* mBccScript;
Jason Sams326e0dd2009-05-22 14:03:28 -070054
Jason Samsce92d4b2010-05-17 14:55:34 -070055 const Allocation *ptrToAllocation(const void *) const;
56
Jason Samsada7f272009-09-24 14:55:38 -070057 virtual void setupScript();
Jason Sams2dca84d2009-12-09 11:05:45 -080058 virtual uint32_t run(Context *, uint32_t launchID);
Jason Sams326e0dd2009-05-22 14:03:28 -070059};
60
Jack Palevich1ef8b802009-05-28 15:53:04 -070061class ScriptCState
Jason Sams326e0dd2009-05-22 14:03:28 -070062{
63public:
64 ScriptCState();
65 ~ScriptCState();
66
Jason Sams8c6bc692009-09-16 15:04:38 -070067 ScriptC *mScript;
Jason Sams326e0dd2009-05-22 14:03:28 -070068
Jason Sams8b2c0652009-08-12 17:54:11 -070069 ObjectBaseRef<const Type> mConstantBufferTypes[MAX_SCRIPT_BANKS];
Jason Samsbe36bf32010-05-11 14:03:58 -070070 //String8 mSlotNames[MAX_SCRIPT_BANKS];
Jason Sams90b36a82009-08-17 13:56:09 -070071 bool mSlotWritable[MAX_SCRIPT_BANKS];
Jason Samsbe36bf32010-05-11 14:03:58 -070072 //String8 mInvokableNames[MAX_SCRIPT_BANKS];
Jason Sams326e0dd2009-05-22 14:03:28 -070073
74 void clear();
Jason Sams8c6bc692009-09-16 15:04:38 -070075 void runCompiler(Context *rsc, ScriptC *s);
Jason Sams29df66f2009-07-16 15:08:06 -070076
77 struct SymbolTable_t {
78 const char * mName;
79 void * mPtr;
Jason Sams29df66f2009-07-16 15:08:06 -070080 };
Jason Samsaeb094b2010-05-18 13:35:45 -070081 //static SymbolTable_t gSyms[];
Jason Sams29df66f2009-07-16 15:08:06 -070082 static const SymbolTable_t * lookupSymbol(const char *);
Jason Samsaeb094b2010-05-18 13:35:45 -070083 static const SymbolTable_t * lookupSymbolCL(const char *);
84 static const SymbolTable_t * lookupSymbolGL(const char *);
Jason Sams326e0dd2009-05-22 14:03:28 -070085};
86
87
88}
89}
90#endif
91
92
93