blob: 928dca5376ed3cf7d70379773060c8e4c4856c3d [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;
Alex Sakhartchouk43850542011-05-05 16:56:27 -070032class Program;
Jason Sams48f50562011-03-18 15:03:25 -070033class ProgramStore;
Jason Sams331bf9b2011-04-06 11:23:54 -070034class ProgramRaster;
Alex Sakhartchouk4a36b452011-04-29 16:49:08 -070035class ProgramVertex;
36class ProgramFragment;
37class Mesh;
Alex Sakhartchouk43850542011-05-05 16:56:27 -070038class Sampler;
Alex Sakhartchouk2f6964f2011-05-13 14:53:34 -070039class FBOCache;
Jason Samse4a06c52011-03-16 16:29:28 -070040
Jason Samse4a06c52011-03-16 16:29:28 -070041typedef void *(*RsHalSymbolLookupFunc)(void *usrptr, char const *symbolName);
42
Jason Samse4a06c52011-03-16 16:29:28 -070043/**
44 * Script management functions
45 */
46typedef struct {
Jason Sams803626f2011-04-06 17:52:23 -070047 bool (*initGraphics)(const Context *);
48 void (*shutdownGraphics)(const Context *);
Alex Sakhartchouk6c72eec2011-05-17 12:32:47 -070049 bool (*setSurface)(const Context *, uint32_t w, uint32_t h, RsNativeWindow);
Jason Sams803626f2011-04-06 17:52:23 -070050 void (*swap)(const Context *);
51
Jason Sams55d2a252011-03-17 16:12:47 -070052 void (*shutdownDriver)(Context *);
Jason Samse4a06c52011-03-16 16:29:28 -070053 void (*getVersion)(unsigned int *major, unsigned int *minor);
Jason Sams55d2a252011-03-17 16:12:47 -070054 void (*setPriority)(const Context *, int32_t priority);
Jason Samse4a06c52011-03-16 16:29:28 -070055
56
57
58 struct {
Jason Sams48f50562011-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 Samsfcf72312011-04-20 15:09:01 -070064 uint32_t flags);
Jason Samse4a06c52011-03-16 16:29:28 -070065
Jason Sams55d2a252011-03-17 16:12:47 -070066 void (*invokeFunction)(const Context *rsc, Script *s,
Jason Samse4a06c52011-03-16 16:29:28 -070067 uint32_t slot,
68 const void *params,
69 size_t paramLength);
Jason Sams55d2a252011-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 Samse4a06c52011-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 Sams48f50562011-03-18 15:03:25 -070094 struct {
Jason Sams7e8aae72011-05-26 16:33:01 -070095 bool (*init)(const Context *rsc, Allocation *alloc, bool forceZero);
96 void (*destroy)(const Context *rsc, Allocation *alloc);
97
98 void (*resize)(const Context *rsc, const Allocation *alloc, const Type *newType,
99 bool zeroNew);
100 void (*syncAll)(const Context *rsc, const Allocation *alloc, RsAllocationUsageType src);
101 void (*markDirty)(const Context *rsc, const Allocation *alloc);
102
103 void (*data1D)(const Context *rsc, const Allocation *alloc,
104 uint32_t xoff, uint32_t lod, uint32_t count,
105 const void *data, uint32_t sizeBytes);
106 void (*data2D)(const Context *rsc, const Allocation *alloc,
107 uint32_t xoff, uint32_t yoff, uint32_t lod,
108 RsAllocationCubemapFace face, uint32_t w, uint32_t h,
109 const void *data, uint32_t sizeBytes);
110 void (*data3D)(const Context *rsc, const Allocation *alloc,
111 uint32_t xoff, uint32_t yoff, uint32_t zoff,
112 uint32_t lod, RsAllocationCubemapFace face,
113 uint32_t w, uint32_t h, uint32_t d, const void *data, uint32_t sizeBytes);
114
Alex Sakhartchouk304b1f52011-06-14 11:13:19 -0700115 // Allocation to allocation copies
116 void (*allocData1D)(const Context *rsc,
117 const Allocation *dstAlloc,
118 uint32_t dstXoff, uint32_t dstLod, uint32_t count,
119 const Allocation *srcAlloc, uint32_t srcXoff, uint32_t srcLod);
120 void (*allocData2D)(const Context *rsc,
121 const Allocation *dstAlloc,
122 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod,
123 RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h,
124 const Allocation *srcAlloc,
125 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod,
126 RsAllocationCubemapFace srcFace);
127 void (*allocData3D)(const Context *rsc,
128 const Allocation *dstAlloc,
129 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstZoff,
130 uint32_t dstLod, RsAllocationCubemapFace dstFace,
131 uint32_t w, uint32_t h, uint32_t d,
132 const Allocation *srcAlloc,
133 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff,
134 uint32_t srcLod, RsAllocationCubemapFace srcFace);
135
Jason Sams7e8aae72011-05-26 16:33:01 -0700136 void (*elementData1D)(const Context *rsc, const Allocation *alloc, uint32_t x,
137 const void *data, uint32_t elementOff, uint32_t sizeBytes);
138 void (*elementData2D)(const Context *rsc, const Allocation *alloc, uint32_t x, uint32_t y,
139 const void *data, uint32_t elementOff, uint32_t sizeBytes);
140
141
142 } allocation;
143
144 struct {
Jason Sams48f50562011-03-18 15:03:25 -0700145 bool (*init)(const Context *rsc, const ProgramStore *ps);
146 void (*setActive)(const Context *rsc, const ProgramStore *ps);
147 void (*destroy)(const Context *rsc, const ProgramStore *ps);
148 } store;
149
Jason Sams331bf9b2011-04-06 11:23:54 -0700150 struct {
151 bool (*init)(const Context *rsc, const ProgramRaster *ps);
152 void (*setActive)(const Context *rsc, const ProgramRaster *ps);
153 void (*destroy)(const Context *rsc, const ProgramRaster *ps);
154 } raster;
Jason Sams48f50562011-03-18 15:03:25 -0700155
Alex Sakhartchouk4a36b452011-04-29 16:49:08 -0700156 struct {
157 bool (*init)(const Context *rsc, const ProgramVertex *pv,
158 const char* shader, uint32_t shaderLen);
159 void (*setActive)(const Context *rsc, const ProgramVertex *pv);
160 void (*destroy)(const Context *rsc, const ProgramVertex *pv);
161 } vertex;
162
163 struct {
164 bool (*init)(const Context *rsc, const ProgramFragment *pf,
165 const char* shader, uint32_t shaderLen);
166 void (*setActive)(const Context *rsc, const ProgramFragment *pf);
167 void (*destroy)(const Context *rsc, const ProgramFragment *pf);
168 } fragment;
169
170 struct {
171 bool (*init)(const Context *rsc, const Mesh *m);
172 void (*draw)(const Context *rsc, const Mesh *m, uint32_t primIndex, uint32_t start, uint32_t len);
173 void (*destroy)(const Context *rsc, const Mesh *m);
174 } mesh;
Jason Samse4a06c52011-03-16 16:29:28 -0700175
Alex Sakhartchouk43850542011-05-05 16:56:27 -0700176 struct {
177 bool (*init)(const Context *rsc, const Sampler *m);
178 void (*destroy)(const Context *rsc, const Sampler *m);
179 } sampler;
180
Alex Sakhartchouk2f6964f2011-05-13 14:53:34 -0700181 struct {
182 bool (*init)(const Context *rsc, const FBOCache *fb);
183 void (*setActive)(const Context *rsc, const FBOCache *fb);
184 void (*destroy)(const Context *rsc, const FBOCache *fb);
185 } framebuffer;
186
Jason Samse4a06c52011-03-16 16:29:28 -0700187} RsdHalFunctions;
188
Jason Samse4a06c52011-03-16 16:29:28 -0700189
190}
191}
192
193
194bool rsdHalInit(android::renderscript::Context *, uint32_t version_major, uint32_t version_minor);
195
196#endif
197