blob: a4ca9367d8c9f5104d925024ecef5e07582dfb5a [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>
Jason Sams803626f2011-04-06 17:52:23 -070021#include <ui/egl/android_natives.h>
Jason Samse4a06c52011-03-16 16:29:28 -070022
23namespace android {
24namespace renderscript {
25
26class Context;
27class ObjectBase;
28class Element;
29class Type;
30class Allocation;
31class Script;
32class ScriptC;
Jason Sams48f50562011-03-18 15:03:25 -070033class ProgramStore;
Jason Sams331bf9b2011-04-06 11:23:54 -070034class ProgramRaster;
Jason Samse4a06c52011-03-16 16:29:28 -070035
Jason Samse4a06c52011-03-16 16:29:28 -070036typedef void *(*RsHalSymbolLookupFunc)(void *usrptr, char const *symbolName);
37
Jason Sams55d2a252011-03-17 16:12:47 -070038typedef struct ScriptTLSStructRec {
39 Context * mContext;
40 Script * mScript;
41} ScriptTLSStruct;
Jason Samse4a06c52011-03-16 16:29:28 -070042
43
44/**
45 * Script management functions
46 */
47typedef struct {
Jason Sams803626f2011-04-06 17:52:23 -070048 bool (*initGraphics)(const Context *);
49 void (*shutdownGraphics)(const Context *);
50 bool (*setSurface)(const Context *, uint32_t w, uint32_t h, ANativeWindow *);
51 void (*swap)(const Context *);
52
Jason Sams55d2a252011-03-17 16:12:47 -070053 void (*shutdownDriver)(Context *);
Jason Samse4a06c52011-03-16 16:29:28 -070054 void (*getVersion)(unsigned int *major, unsigned int *minor);
Jason Sams55d2a252011-03-17 16:12:47 -070055 void (*setPriority)(const Context *, int32_t priority);
Jason Samse4a06c52011-03-16 16:29:28 -070056
57
58
59 struct {
Jason Sams48f50562011-03-18 15:03:25 -070060 bool (*init)(const Context *rsc, ScriptC *s,
61 char const *resName,
62 char const *cacheDir,
63 uint8_t const *bitcode,
64 size_t bitcodeSize,
65 uint32_t flags,
66 RsHalSymbolLookupFunc lookupFunc);
Jason Samse4a06c52011-03-16 16:29:28 -070067
Jason Sams55d2a252011-03-17 16:12:47 -070068 void (*invokeFunction)(const Context *rsc, Script *s,
Jason Samse4a06c52011-03-16 16:29:28 -070069 uint32_t slot,
70 const void *params,
71 size_t paramLength);
Jason Sams55d2a252011-03-17 16:12:47 -070072 int (*invokeRoot)(const Context *rsc, Script *s);
73 void (*invokeForEach)(const Context *rsc,
74 Script *s,
75 const Allocation * ain,
76 Allocation * aout,
77 const void * usr,
78 uint32_t usrLen,
79 const RsScriptCall *sc);
80 void (*invokeInit)(const Context *rsc, Script *s);
Jason Samse4a06c52011-03-16 16:29:28 -070081
82 void (*setGlobalVar)(const Context *rsc, const Script *s,
83 uint32_t slot,
84 void *data,
85 size_t dataLength);
86 void (*setGlobalBind)(const Context *rsc, const Script *s,
87 uint32_t slot,
88 void *data);
89 void (*setGlobalObj)(const Context *rsc, const Script *s,
90 uint32_t slot,
91 ObjectBase *data);
92
93 void (*destroy)(const Context *rsc, Script *s);
94 } script;
95
Jason Sams48f50562011-03-18 15:03:25 -070096 struct {
97 bool (*init)(const Context *rsc, const ProgramStore *ps);
98 void (*setActive)(const Context *rsc, const ProgramStore *ps);
99 void (*destroy)(const Context *rsc, const ProgramStore *ps);
100 } store;
101
Jason Sams331bf9b2011-04-06 11:23:54 -0700102 struct {
103 bool (*init)(const Context *rsc, const ProgramRaster *ps);
104 void (*setActive)(const Context *rsc, const ProgramRaster *ps);
105 void (*destroy)(const Context *rsc, const ProgramRaster *ps);
106 } raster;
Jason Sams48f50562011-03-18 15:03:25 -0700107
Jason Samse4a06c52011-03-16 16:29:28 -0700108
109} RsdHalFunctions;
110
111void rsiSetObject(ObjectBase **vdst, ObjectBase * vsrc);
112void rsiClearObject(ObjectBase **vdst);
113bool rsiIsObject(const ObjectBase *vdst);
114
115}
116}
117
118
119bool rsdHalInit(android::renderscript::Context *, uint32_t version_major, uint32_t version_minor);
120
121#endif
122