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