blob: 93d7476818a7fa6e72965ab7ffad880b0d054908 [file] [log] [blame]
Jason Samse4a06c52011-03-16 16:29:28 -07001/*
2 * Copyright (C) 2011 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 RS_HAL_H
18#define RS_HAL_H
19
20#include <RenderScriptDefines.h>
21
22namespace android {
23namespace renderscript {
24
25class Context;
26class ObjectBase;
27class Element;
28class Type;
29class Allocation;
30class Script;
31class ScriptC;
Jason Sams48f50562011-03-18 15:03:25 -070032class ProgramStore;
Jason Sams331bf9b2011-04-06 11:23:54 -070033class ProgramRaster;
Jason Samse4a06c52011-03-16 16:29:28 -070034
Jason Samse4a06c52011-03-16 16:29:28 -070035typedef void *(*RsHalSymbolLookupFunc)(void *usrptr, char const *symbolName);
36
Jason Sams55d2a252011-03-17 16:12:47 -070037typedef struct ScriptTLSStructRec {
38 Context * mContext;
39 Script * mScript;
40} ScriptTLSStruct;
Jason Samse4a06c52011-03-16 16:29:28 -070041
42
43/**
44 * Script management functions
45 */
46typedef struct {
Jason Sams55d2a252011-03-17 16:12:47 -070047 void (*shutdownDriver)(Context *);
Jason Samse4a06c52011-03-16 16:29:28 -070048 void (*getVersion)(unsigned int *major, unsigned int *minor);
Jason Sams55d2a252011-03-17 16:12:47 -070049 void (*setPriority)(const Context *, int32_t priority);
Jason Samse4a06c52011-03-16 16:29:28 -070050
51
52
53 struct {
Jason Sams48f50562011-03-18 15:03:25 -070054 bool (*init)(const Context *rsc, ScriptC *s,
55 char const *resName,
56 char const *cacheDir,
57 uint8_t const *bitcode,
58 size_t bitcodeSize,
59 uint32_t flags,
60 RsHalSymbolLookupFunc lookupFunc);
Jason Samse4a06c52011-03-16 16:29:28 -070061
Jason Sams55d2a252011-03-17 16:12:47 -070062 void (*invokeFunction)(const Context *rsc, Script *s,
Jason Samse4a06c52011-03-16 16:29:28 -070063 uint32_t slot,
64 const void *params,
65 size_t paramLength);
Jason Sams55d2a252011-03-17 16:12:47 -070066 int (*invokeRoot)(const Context *rsc, Script *s);
67 void (*invokeForEach)(const Context *rsc,
68 Script *s,
69 const Allocation * ain,
70 Allocation * aout,
71 const void * usr,
72 uint32_t usrLen,
73 const RsScriptCall *sc);
74 void (*invokeInit)(const Context *rsc, Script *s);
Jason Samse4a06c52011-03-16 16:29:28 -070075
76 void (*setGlobalVar)(const Context *rsc, const Script *s,
77 uint32_t slot,
78 void *data,
79 size_t dataLength);
80 void (*setGlobalBind)(const Context *rsc, const Script *s,
81 uint32_t slot,
82 void *data);
83 void (*setGlobalObj)(const Context *rsc, const Script *s,
84 uint32_t slot,
85 ObjectBase *data);
86
87 void (*destroy)(const Context *rsc, Script *s);
88 } script;
89
90
Jason Sams48f50562011-03-18 15:03:25 -070091 struct {
92 bool (*init)(const Context *rsc, const ProgramStore *ps);
93 void (*setActive)(const Context *rsc, const ProgramStore *ps);
94 void (*destroy)(const Context *rsc, const ProgramStore *ps);
95 } store;
96
Jason Sams331bf9b2011-04-06 11:23:54 -070097 struct {
98 bool (*init)(const Context *rsc, const ProgramRaster *ps);
99 void (*setActive)(const Context *rsc, const ProgramRaster *ps);
100 void (*destroy)(const Context *rsc, const ProgramRaster *ps);
101 } raster;
Jason Sams48f50562011-03-18 15:03:25 -0700102
Jason Samse4a06c52011-03-16 16:29:28 -0700103
104} RsdHalFunctions;
105
106void rsiSetObject(ObjectBase **vdst, ObjectBase * vsrc);
107void rsiClearObject(ObjectBase **vdst);
108bool rsiIsObject(const ObjectBase *vdst);
109
110}
111}
112
113
114bool rsdHalInit(android::renderscript::Context *, uint32_t version_major, uint32_t version_minor);
115
116#endif
117