blob: 50e8a4ce1e549f89803b1f3b3c06d230e5afbcb9 [file] [log] [blame]
Jason Samsd19f10d2009-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 Sams4d339932010-05-11 14:03:58 -070024struct BCCscript;
Jack Palevichec5a20b2009-05-28 15:53:04 -070025
Jason Samsd19f10d2009-05-22 14:03:28 -070026// ---------------------------------------------------------------------------
27namespace android {
28namespace renderscript {
29
Jack Palevichec5a20b2009-05-28 15:53:04 -070030
Jason Samsd19f10d2009-05-22 14:03:28 -070031
32class ScriptC : public Script
33{
34public:
Jason Sams4d339932010-05-11 14:03:58 -070035 typedef int (*RunScript_t)();
Jason Sams2525a812009-09-03 15:43:13 -070036 typedef void (*VoidFunc_t)();
Jason Samsd19f10d2009-05-22 14:03:28 -070037
Jason Samsa9e7a052009-09-25 14:51:22 -070038 ScriptC(Context *);
Jason Samsd19f10d2009-05-22 14:03:28 -070039 virtual ~ScriptC();
40
Jason Sams3a833d82009-06-08 15:20:31 -070041 struct Program_t {
Jason Sams928f5cf2009-06-08 18:50:13 -070042 int mVersionMajor;
43 int mVersionMinor;
Jason Samsd19f10d2009-05-22 14:03:28 -070044
Jason Sams4d339932010-05-11 14:03:58 -070045 RunScript_t mRoot;
Jason Sams2525a812009-09-03 15:43:13 -070046 VoidFunc_t mInit;
Jason Sams3a833d82009-06-08 15:20:31 -070047 };
48
Jason Sams3a833d82009-06-08 15:20:31 -070049 Program_t mProgram;
Jason Samsd19f10d2009-05-22 14:03:28 -070050
Jason Sams4d339932010-05-11 14:03:58 -070051 BCCscript* mBccScript;
Jason Samsd19f10d2009-05-22 14:03:28 -070052
Jason Sams1de0b872010-05-17 14:55:34 -070053 const Allocation *ptrToAllocation(const void *) const;
54
Jason Samsd79b2e92010-05-19 17:22:57 -070055
56 virtual void Invoke(Context *rsc, uint32_t slot, const void *data, uint32_t len);
57
Jason Samsf17bccc2010-05-28 18:23:22 -070058 virtual uint32_t run(Context *);
59
60 virtual void runForEach(Context *rsc, const Allocation *ain, Allocation *aout);
61 virtual void runForEach(Context *rsc, const Allocation *ain, Allocation *aout, uint32_t xStart, uint32_t xEnd);
62 virtual void runForEach(Context *rsc, const Allocation *ain, Allocation *aout, uint32_t xStart, uint32_t yStart, uint32_t xEnd, uint32_t yEnd);
63
Alex Sakhartchoukaa7d2882010-05-21 12:53:13 -070064 virtual void serialize(OStream *stream) const { }
Alex Sakhartchoukaae74ad2010-06-04 10:06:50 -070065 virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_SCRIPT_C; }
Alex Sakhartchoukaa7d2882010-05-21 12:53:13 -070066 static Type *createFromStream(Context *rsc, IStream *stream) { return NULL; }
Jason Samsf17bccc2010-05-28 18:23:22 -070067
68protected:
69 void setupScript(Context *);
70 void setupGLState(Context *);
71 Script * setTLS(Script *);
Jason Samsd19f10d2009-05-22 14:03:28 -070072};
73
Jack Palevichec5a20b2009-05-28 15:53:04 -070074class ScriptCState
Jason Samsd19f10d2009-05-22 14:03:28 -070075{
76public:
77 ScriptCState();
78 ~ScriptCState();
79
Jason Samsbe2e8412009-09-16 15:04:38 -070080 ScriptC *mScript;
Jason Samsd19f10d2009-05-22 14:03:28 -070081
Jason Sams43ee06852009-08-12 17:54:11 -070082 ObjectBaseRef<const Type> mConstantBufferTypes[MAX_SCRIPT_BANKS];
Jason Sams4d339932010-05-11 14:03:58 -070083 //String8 mSlotNames[MAX_SCRIPT_BANKS];
Jason Sams334ea0c2009-08-17 13:56:09 -070084 bool mSlotWritable[MAX_SCRIPT_BANKS];
Jason Sams4d339932010-05-11 14:03:58 -070085 //String8 mInvokableNames[MAX_SCRIPT_BANKS];
Jason Samsd19f10d2009-05-22 14:03:28 -070086
87 void clear();
Jason Samsbe2e8412009-09-16 15:04:38 -070088 void runCompiler(Context *rsc, ScriptC *s);
Jason Sams54440a02009-07-16 15:08:06 -070089
90 struct SymbolTable_t {
91 const char * mName;
92 void * mPtr;
Jason Sams54440a02009-07-16 15:08:06 -070093 };
Jason Sams536923d2010-05-18 13:35:45 -070094 //static SymbolTable_t gSyms[];
Jason Sams54440a02009-07-16 15:08:06 -070095 static const SymbolTable_t * lookupSymbol(const char *);
Jason Sams536923d2010-05-18 13:35:45 -070096 static const SymbolTable_t * lookupSymbolCL(const char *);
97 static const SymbolTable_t * lookupSymbolGL(const char *);
Jason Samsd19f10d2009-05-22 14:03:28 -070098};
99
100
101}
102}
103#endif
104
105
106