| Jason Sams | 326e0dd | 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 | 57b79ce | 2009-08-09 22:57:44 -0700 | [diff] [blame] | 24 | #include <utils/KeyedVector.h> | 
|  | 25 |  | 
| Jason Sams | be36bf3 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 26 | struct BCCscript; | 
| Jack Palevich | 1ef8b80 | 2009-05-28 15:53:04 -0700 | [diff] [blame] | 27 |  | 
| Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 28 | // --------------------------------------------------------------------------- | 
|  | 29 | namespace android { | 
|  | 30 | namespace renderscript { | 
|  | 31 |  | 
| Jack Palevich | 1ef8b80 | 2009-05-28 15:53:04 -0700 | [diff] [blame] | 32 |  | 
| Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 33 |  | 
|  | 34 | class ScriptC : public Script | 
|  | 35 | { | 
|  | 36 | public: | 
| Jason Sams | be36bf3 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 37 | typedef int (*RunScript_t)(); | 
| Jason Sams | 1d54f10 | 2009-09-03 15:43:13 -0700 | [diff] [blame] | 38 | typedef void (*VoidFunc_t)(); | 
| Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 39 |  | 
| Jason Sams | e514b45 | 2009-09-25 14:51:22 -0700 | [diff] [blame] | 40 | ScriptC(Context *); | 
| Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 41 | virtual ~ScriptC(); | 
|  | 42 |  | 
| Jason Sams | efb8de1 | 2009-06-08 15:20:31 -0700 | [diff] [blame] | 43 | struct Program_t { | 
| Jason Sams | 928b734 | 2009-06-08 18:50:13 -0700 | [diff] [blame] | 44 | int mVersionMajor; | 
|  | 45 | int mVersionMinor; | 
| Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 46 |  | 
| Jason Sams | be36bf3 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 47 | RunScript_t mRoot; | 
| Jason Sams | 1d54f10 | 2009-09-03 15:43:13 -0700 | [diff] [blame] | 48 | VoidFunc_t mInit; | 
| Jason Sams | efb8de1 | 2009-06-08 15:20:31 -0700 | [diff] [blame] | 49 | }; | 
|  | 50 |  | 
| Jason Sams | efb8de1 | 2009-06-08 15:20:31 -0700 | [diff] [blame] | 51 | Program_t mProgram; | 
| Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 52 |  | 
| Jason Sams | be36bf3 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 53 | BCCscript*    mBccScript; | 
| Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 54 |  | 
| Jason Sams | ce92d4b | 2010-05-17 14:55:34 -0700 | [diff] [blame] | 55 | const Allocation *ptrToAllocation(const void *) const; | 
|  | 56 |  | 
| Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame^] | 57 | void setTLS(); | 
|  | 58 | void clearTLS(); | 
|  | 59 |  | 
|  | 60 | virtual void Invoke(Context *rsc, uint32_t slot, const void *data, uint32_t len); | 
|  | 61 |  | 
| Jason Sams | ada7f27 | 2009-09-24 14:55:38 -0700 | [diff] [blame] | 62 | virtual void setupScript(); | 
| Jason Sams | 2dca84d | 2009-12-09 11:05:45 -0800 | [diff] [blame] | 63 | virtual uint32_t run(Context *, uint32_t launchID); | 
| Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 64 | }; | 
|  | 65 |  | 
| Jack Palevich | 1ef8b80 | 2009-05-28 15:53:04 -0700 | [diff] [blame] | 66 | class ScriptCState | 
| Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 67 | { | 
|  | 68 | public: | 
|  | 69 | ScriptCState(); | 
|  | 70 | ~ScriptCState(); | 
|  | 71 |  | 
| Jason Sams | 8c6bc69 | 2009-09-16 15:04:38 -0700 | [diff] [blame] | 72 | ScriptC *mScript; | 
| Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 73 |  | 
| Jason Sams | 8b2c065 | 2009-08-12 17:54:11 -0700 | [diff] [blame] | 74 | ObjectBaseRef<const Type> mConstantBufferTypes[MAX_SCRIPT_BANKS]; | 
| Jason Sams | be36bf3 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 75 | //String8 mSlotNames[MAX_SCRIPT_BANKS]; | 
| Jason Sams | 90b36a8 | 2009-08-17 13:56:09 -0700 | [diff] [blame] | 76 | bool mSlotWritable[MAX_SCRIPT_BANKS]; | 
| Jason Sams | be36bf3 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 77 | //String8 mInvokableNames[MAX_SCRIPT_BANKS]; | 
| Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 78 |  | 
|  | 79 | void clear(); | 
| Jason Sams | 8c6bc69 | 2009-09-16 15:04:38 -0700 | [diff] [blame] | 80 | void runCompiler(Context *rsc, ScriptC *s); | 
| Jason Sams | 29df66f | 2009-07-16 15:08:06 -0700 | [diff] [blame] | 81 |  | 
|  | 82 | struct SymbolTable_t { | 
|  | 83 | const char * mName; | 
|  | 84 | void * mPtr; | 
| Jason Sams | 29df66f | 2009-07-16 15:08:06 -0700 | [diff] [blame] | 85 | }; | 
| Jason Sams | aeb094b | 2010-05-18 13:35:45 -0700 | [diff] [blame] | 86 | //static SymbolTable_t gSyms[]; | 
| Jason Sams | 29df66f | 2009-07-16 15:08:06 -0700 | [diff] [blame] | 87 | static const SymbolTable_t * lookupSymbol(const char *); | 
| Jason Sams | aeb094b | 2010-05-18 13:35:45 -0700 | [diff] [blame] | 88 | static const SymbolTable_t * lookupSymbolCL(const char *); | 
|  | 89 | static const SymbolTable_t * lookupSymbolGL(const char *); | 
| Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 90 | }; | 
|  | 91 |  | 
|  | 92 |  | 
|  | 93 | } | 
|  | 94 | } | 
|  | 95 | #endif | 
|  | 96 |  | 
|  | 97 |  | 
|  | 98 |  |