blob: 4cc2abf016236b5021cd9cb579cfa6da8be4c6e3 [file] [log] [blame]
Jason Samsbad80742011-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 Sams4b3de472011-04-06 17:52:23 -070021#include <ui/egl/android_natives.h>
Jason Samsbad80742011-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;
Alex Sakhartchouk7f126c72011-05-05 16:56:27 -070033class Program;
Jason Sams8feea4e2011-03-18 15:03:25 -070034class ProgramStore;
Jason Sams721acc42011-04-06 11:23:54 -070035class ProgramRaster;
Alex Sakhartchouka04e30d2011-04-29 16:49:08 -070036class ProgramVertex;
37class ProgramFragment;
38class Mesh;
Alex Sakhartchouk7f126c72011-05-05 16:56:27 -070039class Sampler;
Jason Samsbad80742011-03-16 16:29:28 -070040
Jason Samsbad80742011-03-16 16:29:28 -070041typedef void *(*RsHalSymbolLookupFunc)(void *usrptr, char const *symbolName);
42
Jason Samsbad80742011-03-16 16:29:28 -070043/**
44 * Script management functions
45 */
46typedef struct {
Jason Sams4b3de472011-04-06 17:52:23 -070047 bool (*initGraphics)(const Context *);
48 void (*shutdownGraphics)(const Context *);
49 bool (*setSurface)(const Context *, uint32_t w, uint32_t h, ANativeWindow *);
50 void (*swap)(const Context *);
51
Jason Samscdfdb8f2011-03-17 16:12:47 -070052 void (*shutdownDriver)(Context *);
Jason Samsbad80742011-03-16 16:29:28 -070053 void (*getVersion)(unsigned int *major, unsigned int *minor);
Jason Samscdfdb8f2011-03-17 16:12:47 -070054 void (*setPriority)(const Context *, int32_t priority);
Jason Samsbad80742011-03-16 16:29:28 -070055
56
57
58 struct {
Jason Sams8feea4e2011-03-18 15:03:25 -070059 bool (*init)(const Context *rsc, ScriptC *s,
60 char const *resName,
61 char const *cacheDir,
62 uint8_t const *bitcode,
63 size_t bitcodeSize,
Jason Sams87fe59a2011-04-20 15:09:01 -070064 uint32_t flags);
Jason Samsbad80742011-03-16 16:29:28 -070065
Jason Samscdfdb8f2011-03-17 16:12:47 -070066 void (*invokeFunction)(const Context *rsc, Script *s,
Jason Samsbad80742011-03-16 16:29:28 -070067 uint32_t slot,
68 const void *params,
69 size_t paramLength);
Jason Samscdfdb8f2011-03-17 16:12:47 -070070 int (*invokeRoot)(const Context *rsc, Script *s);
71 void (*invokeForEach)(const Context *rsc,
72 Script *s,
73 const Allocation * ain,
74 Allocation * aout,
75 const void * usr,
76 uint32_t usrLen,
77 const RsScriptCall *sc);
78 void (*invokeInit)(const Context *rsc, Script *s);
Jason Samsbad80742011-03-16 16:29:28 -070079
80 void (*setGlobalVar)(const Context *rsc, const Script *s,
81 uint32_t slot,
82 void *data,
83 size_t dataLength);
84 void (*setGlobalBind)(const Context *rsc, const Script *s,
85 uint32_t slot,
86 void *data);
87 void (*setGlobalObj)(const Context *rsc, const Script *s,
88 uint32_t slot,
89 ObjectBase *data);
90
91 void (*destroy)(const Context *rsc, Script *s);
92 } script;
93
Jason Sams8feea4e2011-03-18 15:03:25 -070094 struct {
95 bool (*init)(const Context *rsc, const ProgramStore *ps);
96 void (*setActive)(const Context *rsc, const ProgramStore *ps);
97 void (*destroy)(const Context *rsc, const ProgramStore *ps);
98 } store;
99
Jason Sams721acc42011-04-06 11:23:54 -0700100 struct {
101 bool (*init)(const Context *rsc, const ProgramRaster *ps);
102 void (*setActive)(const Context *rsc, const ProgramRaster *ps);
103 void (*destroy)(const Context *rsc, const ProgramRaster *ps);
104 } raster;
Jason Sams8feea4e2011-03-18 15:03:25 -0700105
Alex Sakhartchouka04e30d2011-04-29 16:49:08 -0700106 struct {
107 bool (*init)(const Context *rsc, const ProgramVertex *pv,
108 const char* shader, uint32_t shaderLen);
109 void (*setActive)(const Context *rsc, const ProgramVertex *pv);
110 void (*destroy)(const Context *rsc, const ProgramVertex *pv);
111 } vertex;
112
113 struct {
114 bool (*init)(const Context *rsc, const ProgramFragment *pf,
115 const char* shader, uint32_t shaderLen);
116 void (*setActive)(const Context *rsc, const ProgramFragment *pf);
117 void (*destroy)(const Context *rsc, const ProgramFragment *pf);
118 } fragment;
119
120 struct {
121 bool (*init)(const Context *rsc, const Mesh *m);
122 void (*draw)(const Context *rsc, const Mesh *m, uint32_t primIndex, uint32_t start, uint32_t len);
123 void (*destroy)(const Context *rsc, const Mesh *m);
124 } mesh;
Jason Samsbad80742011-03-16 16:29:28 -0700125
Alex Sakhartchouk7f126c72011-05-05 16:56:27 -0700126 struct {
127 bool (*init)(const Context *rsc, const Sampler *m);
128 void (*destroy)(const Context *rsc, const Sampler *m);
129 } sampler;
130
Jason Samsbad80742011-03-16 16:29:28 -0700131} RsdHalFunctions;
132
Jason Samsbad80742011-03-16 16:29:28 -0700133
134}
135}
136
137
138bool rsdHalInit(android::renderscript::Context *, uint32_t version_major, uint32_t version_minor);
139
140#endif
141