blob: 17983ce76484dcbd196f8b6b01a0a675c6d8f709 [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;
32
33
Jason Samse4a06c52011-03-16 16:29:28 -070034typedef void *(*RsHalSymbolLookupFunc)(void *usrptr, char const *symbolName);
35
Jason Sams55d2a252011-03-17 16:12:47 -070036typedef struct ScriptTLSStructRec {
37 Context * mContext;
38 Script * mScript;
39} ScriptTLSStruct;
Jason Samse4a06c52011-03-16 16:29:28 -070040
41
42/**
43 * Script management functions
44 */
45typedef struct {
Jason Sams55d2a252011-03-17 16:12:47 -070046 void (*shutdownDriver)(Context *);
Jason Samse4a06c52011-03-16 16:29:28 -070047 void (*getVersion)(unsigned int *major, unsigned int *minor);
Jason Sams55d2a252011-03-17 16:12:47 -070048 void (*setPriority)(const Context *, int32_t priority);
Jason Samse4a06c52011-03-16 16:29:28 -070049
50
51
52 struct {
53 bool (*scriptInit)(const Context *rsc, ScriptC *s,
54 char const *resName,
55 char const *cacheDir,
56 uint8_t const *bitcode,
57 size_t bitcodeSize,
58 uint32_t flags,
59 RsHalSymbolLookupFunc lookupFunc);
60
Jason Sams55d2a252011-03-17 16:12:47 -070061 void (*invokeFunction)(const Context *rsc, Script *s,
Jason Samse4a06c52011-03-16 16:29:28 -070062 uint32_t slot,
63 const void *params,
64 size_t paramLength);
Jason Sams55d2a252011-03-17 16:12:47 -070065 int (*invokeRoot)(const Context *rsc, Script *s);
66 void (*invokeForEach)(const Context *rsc,
67 Script *s,
68 const Allocation * ain,
69 Allocation * aout,
70 const void * usr,
71 uint32_t usrLen,
72 const RsScriptCall *sc);
73 void (*invokeInit)(const Context *rsc, Script *s);
Jason Samse4a06c52011-03-16 16:29:28 -070074
75 void (*setGlobalVar)(const Context *rsc, const Script *s,
76 uint32_t slot,
77 void *data,
78 size_t dataLength);
79 void (*setGlobalBind)(const Context *rsc, const Script *s,
80 uint32_t slot,
81 void *data);
82 void (*setGlobalObj)(const Context *rsc, const Script *s,
83 uint32_t slot,
84 ObjectBase *data);
85
86 void (*destroy)(const Context *rsc, Script *s);
87 } script;
88
89
90
91} RsdHalFunctions;
92
93void rsiSetObject(ObjectBase **vdst, ObjectBase * vsrc);
94void rsiClearObject(ObjectBase **vdst);
95bool rsiIsObject(const ObjectBase *vdst);
96
97}
98}
99
100
101bool rsdHalInit(android::renderscript::Context *, uint32_t version_major, uint32_t version_minor);
102
103#endif
104