rsScriptC.h revision c61346b91434307c5003029017b54ce9c49112be
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
24struct BCCscript;
25
26// ---------------------------------------------------------------------------
27namespace android {
28namespace renderscript {
29
30
31
32class ScriptC : public Script
33{
34public:
35    typedef int (*RunScript_t)();
36    typedef void (*VoidFunc_t)();
37
38    ScriptC(Context *);
39    virtual ~ScriptC();
40
41    struct Program_t {
42        int mVersionMajor;
43        int mVersionMinor;
44
45        RunScript_t mRoot;
46        VoidFunc_t mInit;
47    };
48
49    Program_t mProgram;
50
51    BCCscript*    mBccScript;
52
53    const Allocation *ptrToAllocation(const void *) const;
54
55
56    virtual void Invoke(Context *rsc, uint32_t slot, const void *data, uint32_t len);
57
58    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
64
65    virtual void serialize(OStream *stream) const {    }
66    virtual A3DClassID getClassId() const { return A3D_CLASS_ID_SCRIPT_C; }
67    static Type *createFromStream(Context *rsc, IStream *stream) { return NULL; }
68
69protected:
70    void setupScript(Context *);
71    void setupGLState(Context *);
72    Script * setTLS(Script *);
73};
74
75class ScriptCState
76{
77public:
78    ScriptCState();
79    ~ScriptCState();
80
81    ScriptC *mScript;
82
83    ObjectBaseRef<const Type> mConstantBufferTypes[MAX_SCRIPT_BANKS];
84    //String8 mSlotNames[MAX_SCRIPT_BANKS];
85    bool mSlotWritable[MAX_SCRIPT_BANKS];
86    //String8 mInvokableNames[MAX_SCRIPT_BANKS];
87
88    void clear();
89    void runCompiler(Context *rsc, ScriptC *s);
90
91    struct SymbolTable_t {
92        const char * mName;
93        void * mPtr;
94    };
95    //static SymbolTable_t gSyms[];
96    static const SymbolTable_t * lookupSymbol(const char *);
97    static const SymbolTable_t * lookupSymbolCL(const char *);
98    static const SymbolTable_t * lookupSymbolGL(const char *);
99};
100
101
102}
103}
104#endif
105
106
107
108