Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1 | /* |
| 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 Onorato | d7b3774 | 2009-08-09 22:57:44 -0700 | [diff] [blame] | 24 | #include <utils/KeyedVector.h> |
| 25 | |
Jack Palevich | ec5a20b | 2009-05-28 15:53:04 -0700 | [diff] [blame] | 26 | struct ACCscript; |
| 27 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 28 | // --------------------------------------------------------------------------- |
| 29 | namespace android { |
| 30 | namespace renderscript { |
| 31 | |
Jack Palevich | ec5a20b | 2009-05-28 15:53:04 -0700 | [diff] [blame] | 32 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 33 | |
| 34 | class ScriptC : public Script |
| 35 | { |
| 36 | public: |
Jason Sams | c97bb88 | 2009-07-20 14:31:06 -0700 | [diff] [blame] | 37 | typedef int (*RunScript_t)(uint32_t launchIndex); |
Jason Sams | 2525a81 | 2009-09-03 15:43:13 -0700 | [diff] [blame] | 38 | typedef void (*VoidFunc_t)(); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 39 | |
Jason Sams | a9e7a05 | 2009-09-25 14:51:22 -0700 | [diff] [blame] | 40 | ScriptC(Context *); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 41 | virtual ~ScriptC(); |
| 42 | |
Jason Sams | 3a833d8 | 2009-06-08 15:20:31 -0700 | [diff] [blame] | 43 | struct Program_t { |
| 44 | const char * mScriptText; |
| 45 | uint32_t mScriptTextLength; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 46 | |
Jason Sams | 928f5cf | 2009-06-08 18:50:13 -0700 | [diff] [blame] | 47 | |
| 48 | int mVersionMajor; |
| 49 | int mVersionMinor; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 50 | |
Jason Sams | c97bb88 | 2009-07-20 14:31:06 -0700 | [diff] [blame] | 51 | RunScript_t mScript; |
Jason Sams | 2525a81 | 2009-09-03 15:43:13 -0700 | [diff] [blame] | 52 | VoidFunc_t mInit; |
| 53 | |
| 54 | void ** mSlotPointers[MAX_SCRIPT_BANKS]; |
Jason Sams | 3a833d8 | 2009-06-08 15:20:31 -0700 | [diff] [blame] | 55 | }; |
| 56 | |
Jason Sams | 3a833d8 | 2009-06-08 15:20:31 -0700 | [diff] [blame] | 57 | Program_t mProgram; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 58 | |
Jack Palevich | ec5a20b | 2009-05-28 15:53:04 -0700 | [diff] [blame] | 59 | ACCscript* mAccScript; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 60 | |
Jason Sams | e60446b | 2009-09-24 14:55:38 -0700 | [diff] [blame] | 61 | virtual void setupScript(); |
Jason Sams | 3a833d8 | 2009-06-08 15:20:31 -0700 | [diff] [blame] | 62 | virtual bool run(Context *, uint32_t launchID); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 63 | }; |
| 64 | |
Jack Palevich | ec5a20b | 2009-05-28 15:53:04 -0700 | [diff] [blame] | 65 | class ScriptCState |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 66 | { |
| 67 | public: |
| 68 | ScriptCState(); |
| 69 | ~ScriptCState(); |
| 70 | |
Jason Sams | be2e841 | 2009-09-16 15:04:38 -0700 | [diff] [blame] | 71 | ScriptC *mScript; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 72 | |
Jason Sams | 43ee0685 | 2009-08-12 17:54:11 -0700 | [diff] [blame] | 73 | ObjectBaseRef<const Type> mConstantBufferTypes[MAX_SCRIPT_BANKS]; |
Jason Sams | fbf0b9e | 2009-08-13 12:59:04 -0700 | [diff] [blame] | 74 | String8 mSlotNames[MAX_SCRIPT_BANKS]; |
Jason Sams | 334ea0c | 2009-08-17 13:56:09 -0700 | [diff] [blame] | 75 | bool mSlotWritable[MAX_SCRIPT_BANKS]; |
Jason Sams | be2e841 | 2009-09-16 15:04:38 -0700 | [diff] [blame] | 76 | String8 mInvokableNames[MAX_SCRIPT_BANKS]; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 77 | |
| 78 | void clear(); |
Jason Sams | be2e841 | 2009-09-16 15:04:38 -0700 | [diff] [blame] | 79 | void runCompiler(Context *rsc, ScriptC *s); |
Jason Sams | 66b2771 | 2009-09-25 15:25:00 -0700 | [diff] [blame] | 80 | void appendVarDefines(const Context *rsc, String8 *str); |
| 81 | void appendTypes(const Context *rsc, String8 *str); |
Jason Sams | 54440a0 | 2009-07-16 15:08:06 -0700 | [diff] [blame] | 82 | |
| 83 | struct SymbolTable_t { |
| 84 | const char * mName; |
| 85 | void * mPtr; |
Jason Sams | c97bb88 | 2009-07-20 14:31:06 -0700 | [diff] [blame] | 86 | const char * mRet; |
| 87 | const char * mParam; |
Jason Sams | 54440a0 | 2009-07-16 15:08:06 -0700 | [diff] [blame] | 88 | }; |
| 89 | static SymbolTable_t gSyms[]; |
| 90 | static const SymbolTable_t * lookupSymbol(const char *); |
Jason Sams | 764205c | 2009-07-16 17:47:40 -0700 | [diff] [blame] | 91 | static void appendDecls(String8 *str); |
Joe Onorato | d7b3774 | 2009-08-09 22:57:44 -0700 | [diff] [blame] | 92 | |
| 93 | KeyedVector<String8,int> mInt32Defines; |
| 94 | KeyedVector<String8,float> mFloatDefines; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 95 | }; |
| 96 | |
| 97 | |
| 98 | } |
| 99 | } |
| 100 | #endif |
| 101 | |
| 102 | |
| 103 | |