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 | |
Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 24 | struct BCCscript; |
Jack Palevich | ec5a20b | 2009-05-28 15:53:04 -0700 | [diff] [blame] | 25 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 26 | // --------------------------------------------------------------------------- |
| 27 | namespace android { |
| 28 | namespace renderscript { |
| 29 | |
Jack Palevich | ec5a20b | 2009-05-28 15:53:04 -0700 | [diff] [blame] | 30 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 31 | |
| 32 | class ScriptC : public Script |
| 33 | { |
| 34 | public: |
Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 35 | typedef int (*RunScript_t)(); |
Jason Sams | 2525a81 | 2009-09-03 15:43:13 -0700 | [diff] [blame] | 36 | typedef void (*VoidFunc_t)(); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 37 | |
Jason Sams | a9e7a05 | 2009-09-25 14:51:22 -0700 | [diff] [blame] | 38 | ScriptC(Context *); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 39 | virtual ~ScriptC(); |
| 40 | |
Jason Sams | 3a833d8 | 2009-06-08 15:20:31 -0700 | [diff] [blame] | 41 | struct Program_t { |
Jason Sams | 928f5cf | 2009-06-08 18:50:13 -0700 | [diff] [blame] | 42 | int mVersionMajor; |
| 43 | int mVersionMinor; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 44 | |
Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 45 | RunScript_t mRoot; |
Jason Sams | 2525a81 | 2009-09-03 15:43:13 -0700 | [diff] [blame] | 46 | VoidFunc_t mInit; |
Jason Sams | 3a833d8 | 2009-06-08 15:20:31 -0700 | [diff] [blame] | 47 | }; |
| 48 | |
Jason Sams | 3a833d8 | 2009-06-08 15:20:31 -0700 | [diff] [blame] | 49 | Program_t mProgram; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 50 | |
Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 51 | BCCscript* mBccScript; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 52 | |
Jason Sams | 1de0b87 | 2010-05-17 14:55:34 -0700 | [diff] [blame] | 53 | const Allocation *ptrToAllocation(const void *) const; |
| 54 | |
Jason Sams | d79b2e9 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 55 | |
| 56 | virtual void Invoke(Context *rsc, uint32_t slot, const void *data, uint32_t len); |
| 57 | |
Jason Sams | f17bccc | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 58 | virtual uint32_t run(Context *); |
| 59 | |
Jason Sams | 8f8a572 | 2010-07-15 17:11:13 -0700 | [diff] [blame^] | 60 | virtual void runForEach(Context *rsc, |
| 61 | const Allocation * ain, |
| 62 | Allocation * aout, |
| 63 | const void * usr, |
| 64 | const RsScriptCall *sc = NULL); |
Jason Sams | f17bccc | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 65 | |
Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 66 | virtual void serialize(OStream *stream) const { } |
Alex Sakhartchouk | aae74ad | 2010-06-04 10:06:50 -0700 | [diff] [blame] | 67 | virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_SCRIPT_C; } |
Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 68 | static Type *createFromStream(Context *rsc, IStream *stream) { return NULL; } |
Jason Sams | f17bccc | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 69 | |
| 70 | protected: |
| 71 | void setupScript(Context *); |
| 72 | void setupGLState(Context *); |
| 73 | Script * setTLS(Script *); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 74 | }; |
| 75 | |
Jack Palevich | ec5a20b | 2009-05-28 15:53:04 -0700 | [diff] [blame] | 76 | class ScriptCState |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 77 | { |
| 78 | public: |
| 79 | ScriptCState(); |
| 80 | ~ScriptCState(); |
| 81 | |
Jason Sams | be2e841 | 2009-09-16 15:04:38 -0700 | [diff] [blame] | 82 | ScriptC *mScript; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 83 | |
Jason Sams | 43ee0685 | 2009-08-12 17:54:11 -0700 | [diff] [blame] | 84 | ObjectBaseRef<const Type> mConstantBufferTypes[MAX_SCRIPT_BANKS]; |
Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 85 | //String8 mSlotNames[MAX_SCRIPT_BANKS]; |
Jason Sams | 334ea0c | 2009-08-17 13:56:09 -0700 | [diff] [blame] | 86 | bool mSlotWritable[MAX_SCRIPT_BANKS]; |
Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 87 | //String8 mInvokableNames[MAX_SCRIPT_BANKS]; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 88 | |
| 89 | void clear(); |
Jason Sams | be2e841 | 2009-09-16 15:04:38 -0700 | [diff] [blame] | 90 | void runCompiler(Context *rsc, ScriptC *s); |
Jason Sams | 54440a0 | 2009-07-16 15:08:06 -0700 | [diff] [blame] | 91 | |
| 92 | struct SymbolTable_t { |
| 93 | const char * mName; |
| 94 | void * mPtr; |
Jason Sams | 54440a0 | 2009-07-16 15:08:06 -0700 | [diff] [blame] | 95 | }; |
Jason Sams | 536923d | 2010-05-18 13:35:45 -0700 | [diff] [blame] | 96 | //static SymbolTable_t gSyms[]; |
Jason Sams | 54440a0 | 2009-07-16 15:08:06 -0700 | [diff] [blame] | 97 | static const SymbolTable_t * lookupSymbol(const char *); |
Jason Sams | 536923d | 2010-05-18 13:35:45 -0700 | [diff] [blame] | 98 | static const SymbolTable_t * lookupSymbolCL(const char *); |
| 99 | static const SymbolTable_t * lookupSymbolGL(const char *); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 100 | }; |
| 101 | |
| 102 | |
| 103 | } |
| 104 | } |
| 105 | #endif |
| 106 | |
| 107 | |
| 108 | |