blob: 4283d4a6ae00b0fda24105a804d0aa83e891b17a [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 Samse4a06c52011-03-16 16:29:28 -070038/**
39 * Script management functions
40 */
41typedef struct {
Jason Sams803626f2011-04-06 17:52:23 -070042 bool (*initGraphics)(const Context *);
43 void (*shutdownGraphics)(const Context *);
44 bool (*setSurface)(const Context *, uint32_t w, uint32_t h, ANativeWindow *);
45 void (*swap)(const Context *);
46
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,
Jason Samsfcf72312011-04-20 15:09:01 -070059 uint32_t flags);
Jason Samse4a06c52011-03-16 16:29:28 -070060
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
Jason Sams48f50562011-03-18 15:03:25 -070089 struct {
90 bool (*init)(const Context *rsc, const ProgramStore *ps);
91 void (*setActive)(const Context *rsc, const ProgramStore *ps);
92 void (*destroy)(const Context *rsc, const ProgramStore *ps);
93 } store;
94
Jason Sams331bf9b2011-04-06 11:23:54 -070095 struct {
96 bool (*init)(const Context *rsc, const ProgramRaster *ps);
97 void (*setActive)(const Context *rsc, const ProgramRaster *ps);
98 void (*destroy)(const Context *rsc, const ProgramRaster *ps);
99 } raster;
Jason Sams48f50562011-03-18 15:03:25 -0700100
Jason Samse4a06c52011-03-16 16:29:28 -0700101
102} RsdHalFunctions;
103
Jason Samse4a06c52011-03-16 16:29:28 -0700104
105}
106}
107
108
109bool rsdHalInit(android::renderscript::Context *, uint32_t version_major, uint32_t version_minor);
110
111#endif
112