blob: e4bf17f3be2a8358f9f1817d58914aaab3d99ea2 [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
Jason Sams1d6983a2012-02-16 16:07:49 -080020#include <rsDefines.h>
Jason Samse4a06c52011-03-16 16:29:28 -070021
Jason Sams163766c2012-02-15 12:04:24 -080022struct ANativeWindow;
23
Jason Samse4a06c52011-03-16 16:29:28 -070024namespace android {
25namespace renderscript {
26
27class Context;
28class ObjectBase;
29class Element;
30class Type;
31class Allocation;
32class Script;
33class ScriptC;
Jason Samsf15ed012011-10-31 13:23:43 -070034class Path;
Alex Sakhartchouk43850542011-05-05 16:56:27 -070035class Program;
Jason Sams48f50562011-03-18 15:03:25 -070036class ProgramStore;
Jason Sams331bf9b2011-04-06 11:23:54 -070037class ProgramRaster;
Alex Sakhartchouk4a36b452011-04-29 16:49:08 -070038class ProgramVertex;
39class ProgramFragment;
40class Mesh;
Alex Sakhartchouk43850542011-05-05 16:56:27 -070041class Sampler;
Alex Sakhartchouk2f6964f2011-05-13 14:53:34 -070042class FBOCache;
Jason Samse4a06c52011-03-16 16:29:28 -070043
Jason Samse4a06c52011-03-16 16:29:28 -070044typedef void *(*RsHalSymbolLookupFunc)(void *usrptr, char const *symbolName);
45
Jason Samsc1b4c1f2011-08-17 13:46:46 -070046typedef struct {
47 const void *in;
48 void *out;
49 const void *usr;
50 size_t usr_len;
51 uint32_t x;
52 uint32_t y;
53 uint32_t z;
54 uint32_t lod;
55 RsAllocationCubemapFace face;
56 uint32_t ar[16];
57} RsForEachStubParamStruct;
58
Jason Samse4a06c52011-03-16 16:29:28 -070059/**
60 * Script management functions
61 */
62typedef struct {
Jason Sams803626f2011-04-06 17:52:23 -070063 bool (*initGraphics)(const Context *);
64 void (*shutdownGraphics)(const Context *);
Alex Sakhartchouk6c72eec2011-05-17 12:32:47 -070065 bool (*setSurface)(const Context *, uint32_t w, uint32_t h, RsNativeWindow);
Jason Sams803626f2011-04-06 17:52:23 -070066 void (*swap)(const Context *);
67
Jason Sams55d2a252011-03-17 16:12:47 -070068 void (*shutdownDriver)(Context *);
Jason Samse4a06c52011-03-16 16:29:28 -070069 void (*getVersion)(unsigned int *major, unsigned int *minor);
Jason Sams55d2a252011-03-17 16:12:47 -070070 void (*setPriority)(const Context *, int32_t priority);
Jason Samse4a06c52011-03-16 16:29:28 -070071
72
73
74 struct {
Jason Sams48f50562011-03-18 15:03:25 -070075 bool (*init)(const Context *rsc, ScriptC *s,
76 char const *resName,
77 char const *cacheDir,
78 uint8_t const *bitcode,
79 size_t bitcodeSize,
Jason Samsfcf72312011-04-20 15:09:01 -070080 uint32_t flags);
Jason Samse4a06c52011-03-16 16:29:28 -070081
Jason Sams55d2a252011-03-17 16:12:47 -070082 void (*invokeFunction)(const Context *rsc, Script *s,
Jason Samse4a06c52011-03-16 16:29:28 -070083 uint32_t slot,
84 const void *params,
85 size_t paramLength);
Jason Sams55d2a252011-03-17 16:12:47 -070086 int (*invokeRoot)(const Context *rsc, Script *s);
87 void (*invokeForEach)(const Context *rsc,
88 Script *s,
Jason Sams92b0eab2011-07-13 11:26:26 -070089 uint32_t slot,
Jason Sams55d2a252011-03-17 16:12:47 -070090 const Allocation * ain,
91 Allocation * aout,
92 const void * usr,
93 uint32_t usrLen,
94 const RsScriptCall *sc);
95 void (*invokeInit)(const Context *rsc, Script *s);
Stephen Hines514f9792011-08-31 17:41:39 -070096 void (*invokeFreeChildren)(const Context *rsc, Script *s);
Jason Samse4a06c52011-03-16 16:29:28 -070097
98 void (*setGlobalVar)(const Context *rsc, const Script *s,
99 uint32_t slot,
100 void *data,
101 size_t dataLength);
102 void (*setGlobalBind)(const Context *rsc, const Script *s,
103 uint32_t slot,
104 void *data);
105 void (*setGlobalObj)(const Context *rsc, const Script *s,
106 uint32_t slot,
107 ObjectBase *data);
108
109 void (*destroy)(const Context *rsc, Script *s);
110 } script;
111
Jason Sams48f50562011-03-18 15:03:25 -0700112 struct {
Jason Sams7e8aae72011-05-26 16:33:01 -0700113 bool (*init)(const Context *rsc, Allocation *alloc, bool forceZero);
114 void (*destroy)(const Context *rsc, Allocation *alloc);
115
116 void (*resize)(const Context *rsc, const Allocation *alloc, const Type *newType,
117 bool zeroNew);
118 void (*syncAll)(const Context *rsc, const Allocation *alloc, RsAllocationUsageType src);
119 void (*markDirty)(const Context *rsc, const Allocation *alloc);
Jason Sams163766c2012-02-15 12:04:24 -0800120
Jason Sams615e7ce2012-01-13 14:01:20 -0800121 int32_t (*initSurfaceTexture)(const Context *rsc, const Allocation *alloc);
Jason Sams163766c2012-02-15 12:04:24 -0800122 void (*setSurfaceTexture)(const Context *rsc, Allocation *alloc, ANativeWindow *sur);
123 void (*ioSend)(const Context *rsc, Allocation *alloc);
124 void (*ioReceive)(const Context *rsc, Allocation *alloc);
Jason Sams7e8aae72011-05-26 16:33:01 -0700125
126 void (*data1D)(const Context *rsc, const Allocation *alloc,
127 uint32_t xoff, uint32_t lod, uint32_t count,
Alex Sakhartchouka3f15432012-02-13 11:57:32 -0800128 const void *data, size_t sizeBytes);
Jason Sams7e8aae72011-05-26 16:33:01 -0700129 void (*data2D)(const Context *rsc, const Allocation *alloc,
130 uint32_t xoff, uint32_t yoff, uint32_t lod,
131 RsAllocationCubemapFace face, uint32_t w, uint32_t h,
Alex Sakhartchouka3f15432012-02-13 11:57:32 -0800132 const void *data, size_t sizeBytes);
Jason Sams7e8aae72011-05-26 16:33:01 -0700133 void (*data3D)(const Context *rsc, const Allocation *alloc,
134 uint32_t xoff, uint32_t yoff, uint32_t zoff,
135 uint32_t lod, RsAllocationCubemapFace face,
Alex Sakhartchouka3f15432012-02-13 11:57:32 -0800136 uint32_t w, uint32_t h, uint32_t d, const void *data, size_t sizeBytes);
Jason Sams7e8aae72011-05-26 16:33:01 -0700137
Alex Sakhartchouk304b1f52011-06-14 11:13:19 -0700138 // Allocation to allocation copies
139 void (*allocData1D)(const Context *rsc,
140 const Allocation *dstAlloc,
141 uint32_t dstXoff, uint32_t dstLod, uint32_t count,
142 const Allocation *srcAlloc, uint32_t srcXoff, uint32_t srcLod);
143 void (*allocData2D)(const Context *rsc,
144 const Allocation *dstAlloc,
145 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod,
146 RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h,
147 const Allocation *srcAlloc,
148 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod,
149 RsAllocationCubemapFace srcFace);
150 void (*allocData3D)(const Context *rsc,
151 const Allocation *dstAlloc,
152 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstZoff,
153 uint32_t dstLod, RsAllocationCubemapFace dstFace,
154 uint32_t w, uint32_t h, uint32_t d,
155 const Allocation *srcAlloc,
156 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff,
157 uint32_t srcLod, RsAllocationCubemapFace srcFace);
158
Jason Sams7e8aae72011-05-26 16:33:01 -0700159 void (*elementData1D)(const Context *rsc, const Allocation *alloc, uint32_t x,
Alex Sakhartchouka3f15432012-02-13 11:57:32 -0800160 const void *data, uint32_t elementOff, size_t sizeBytes);
Jason Sams7e8aae72011-05-26 16:33:01 -0700161 void (*elementData2D)(const Context *rsc, const Allocation *alloc, uint32_t x, uint32_t y,
Alex Sakhartchouka3f15432012-02-13 11:57:32 -0800162 const void *data, uint32_t elementOff, size_t sizeBytes);
Jason Sams7e8aae72011-05-26 16:33:01 -0700163
164
165 } allocation;
166
167 struct {
Jason Sams48f50562011-03-18 15:03:25 -0700168 bool (*init)(const Context *rsc, const ProgramStore *ps);
169 void (*setActive)(const Context *rsc, const ProgramStore *ps);
170 void (*destroy)(const Context *rsc, const ProgramStore *ps);
171 } store;
172
Jason Sams331bf9b2011-04-06 11:23:54 -0700173 struct {
174 bool (*init)(const Context *rsc, const ProgramRaster *ps);
175 void (*setActive)(const Context *rsc, const ProgramRaster *ps);
176 void (*destroy)(const Context *rsc, const ProgramRaster *ps);
177 } raster;
Jason Sams48f50562011-03-18 15:03:25 -0700178
Alex Sakhartchouk4a36b452011-04-29 16:49:08 -0700179 struct {
180 bool (*init)(const Context *rsc, const ProgramVertex *pv,
Alex Sakhartchouk2123b462012-02-15 16:21:46 -0800181 const char* shader, size_t shaderLen,
182 const char** textureNames, size_t textureNamesCount,
183 const size_t *textureNamesLength);
Alex Sakhartchouk4a36b452011-04-29 16:49:08 -0700184 void (*setActive)(const Context *rsc, const ProgramVertex *pv);
185 void (*destroy)(const Context *rsc, const ProgramVertex *pv);
186 } vertex;
187
188 struct {
189 bool (*init)(const Context *rsc, const ProgramFragment *pf,
Alex Sakhartchouk2123b462012-02-15 16:21:46 -0800190 const char* shader, size_t shaderLen,
191 const char** textureNames, size_t textureNamesCount,
192 const size_t *textureNamesLength);
Alex Sakhartchouk4a36b452011-04-29 16:49:08 -0700193 void (*setActive)(const Context *rsc, const ProgramFragment *pf);
194 void (*destroy)(const Context *rsc, const ProgramFragment *pf);
195 } fragment;
196
197 struct {
198 bool (*init)(const Context *rsc, const Mesh *m);
199 void (*draw)(const Context *rsc, const Mesh *m, uint32_t primIndex, uint32_t start, uint32_t len);
200 void (*destroy)(const Context *rsc, const Mesh *m);
201 } mesh;
Jason Samse4a06c52011-03-16 16:29:28 -0700202
Alex Sakhartchouk43850542011-05-05 16:56:27 -0700203 struct {
Jason Samsf15ed012011-10-31 13:23:43 -0700204 bool (*initStatic)(const Context *rsc, const Path *m, const Allocation *vtx, const Allocation *loops);
205 bool (*initDynamic)(const Context *rsc, const Path *m);
206 void (*draw)(const Context *rsc, const Path *m);
207 void (*destroy)(const Context *rsc, const Path *m);
208 } path;
209
210 struct {
Alex Sakhartchouk43850542011-05-05 16:56:27 -0700211 bool (*init)(const Context *rsc, const Sampler *m);
212 void (*destroy)(const Context *rsc, const Sampler *m);
213 } sampler;
214
Alex Sakhartchouk2f6964f2011-05-13 14:53:34 -0700215 struct {
216 bool (*init)(const Context *rsc, const FBOCache *fb);
217 void (*setActive)(const Context *rsc, const FBOCache *fb);
218 void (*destroy)(const Context *rsc, const FBOCache *fb);
219 } framebuffer;
220
Jason Samse4a06c52011-03-16 16:29:28 -0700221} RsdHalFunctions;
222
Jason Samse4a06c52011-03-16 16:29:28 -0700223
224}
225}
226
227
228bool rsdHalInit(android::renderscript::Context *, uint32_t version_major, uint32_t version_minor);
229
230#endif
231