blob: 800053a7cf116fef2c2f64bdceb21971d4fcac40 [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;
Jason Samsf15ed012011-10-31 13:23:43 -070032class Path;
Alex Sakhartchouk43850542011-05-05 16:56:27 -070033class Program;
Jason Sams48f50562011-03-18 15:03:25 -070034class ProgramStore;
Jason Sams331bf9b2011-04-06 11:23:54 -070035class ProgramRaster;
Alex Sakhartchouk4a36b452011-04-29 16:49:08 -070036class ProgramVertex;
37class ProgramFragment;
38class Mesh;
Alex Sakhartchouk43850542011-05-05 16:56:27 -070039class Sampler;
Alex Sakhartchouk2f6964f2011-05-13 14:53:34 -070040class FBOCache;
Jason Samse4a06c52011-03-16 16:29:28 -070041
Jason Samse4a06c52011-03-16 16:29:28 -070042typedef void *(*RsHalSymbolLookupFunc)(void *usrptr, char const *symbolName);
43
Jason Samsc1b4c1f2011-08-17 13:46:46 -070044typedef struct {
45 const void *in;
46 void *out;
47 const void *usr;
48 size_t usr_len;
49 uint32_t x;
50 uint32_t y;
51 uint32_t z;
52 uint32_t lod;
53 RsAllocationCubemapFace face;
54 uint32_t ar[16];
55} RsForEachStubParamStruct;
56
Jason Samse4a06c52011-03-16 16:29:28 -070057/**
58 * Script management functions
59 */
60typedef struct {
Jason Sams803626f2011-04-06 17:52:23 -070061 bool (*initGraphics)(const Context *);
62 void (*shutdownGraphics)(const Context *);
Alex Sakhartchouk6c72eec2011-05-17 12:32:47 -070063 bool (*setSurface)(const Context *, uint32_t w, uint32_t h, RsNativeWindow);
Jason Sams803626f2011-04-06 17:52:23 -070064 void (*swap)(const Context *);
65
Jason Sams55d2a252011-03-17 16:12:47 -070066 void (*shutdownDriver)(Context *);
Jason Samse4a06c52011-03-16 16:29:28 -070067 void (*getVersion)(unsigned int *major, unsigned int *minor);
Jason Sams55d2a252011-03-17 16:12:47 -070068 void (*setPriority)(const Context *, int32_t priority);
Jason Samse4a06c52011-03-16 16:29:28 -070069
70
71
72 struct {
Jason Sams48f50562011-03-18 15:03:25 -070073 bool (*init)(const Context *rsc, ScriptC *s,
74 char const *resName,
75 char const *cacheDir,
76 uint8_t const *bitcode,
77 size_t bitcodeSize,
Jason Samsfcf72312011-04-20 15:09:01 -070078 uint32_t flags);
Jason Samse4a06c52011-03-16 16:29:28 -070079
Jason Sams55d2a252011-03-17 16:12:47 -070080 void (*invokeFunction)(const Context *rsc, Script *s,
Jason Samse4a06c52011-03-16 16:29:28 -070081 uint32_t slot,
82 const void *params,
83 size_t paramLength);
Jason Sams55d2a252011-03-17 16:12:47 -070084 int (*invokeRoot)(const Context *rsc, Script *s);
85 void (*invokeForEach)(const Context *rsc,
86 Script *s,
Jason Sams92b0eab2011-07-13 11:26:26 -070087 uint32_t slot,
Jason Sams55d2a252011-03-17 16:12:47 -070088 const Allocation * ain,
89 Allocation * aout,
90 const void * usr,
91 uint32_t usrLen,
92 const RsScriptCall *sc);
93 void (*invokeInit)(const Context *rsc, Script *s);
Stephen Hines514f9792011-08-31 17:41:39 -070094 void (*invokeFreeChildren)(const Context *rsc, Script *s);
Jason Samse4a06c52011-03-16 16:29:28 -070095
96 void (*setGlobalVar)(const Context *rsc, const Script *s,
97 uint32_t slot,
98 void *data,
99 size_t dataLength);
100 void (*setGlobalBind)(const Context *rsc, const Script *s,
101 uint32_t slot,
102 void *data);
103 void (*setGlobalObj)(const Context *rsc, const Script *s,
104 uint32_t slot,
105 ObjectBase *data);
106
107 void (*destroy)(const Context *rsc, Script *s);
108 } script;
109
Jason Sams48f50562011-03-18 15:03:25 -0700110 struct {
Jason Sams7e8aae72011-05-26 16:33:01 -0700111 bool (*init)(const Context *rsc, Allocation *alloc, bool forceZero);
112 void (*destroy)(const Context *rsc, Allocation *alloc);
113
114 void (*resize)(const Context *rsc, const Allocation *alloc, const Type *newType,
115 bool zeroNew);
116 void (*syncAll)(const Context *rsc, const Allocation *alloc, RsAllocationUsageType src);
117 void (*markDirty)(const Context *rsc, const Allocation *alloc);
Jason Sams615e7ce2012-01-13 14:01:20 -0800118 int32_t (*initSurfaceTexture)(const Context *rsc, const Allocation *alloc);
Jason Sams7e8aae72011-05-26 16:33:01 -0700119
120 void (*data1D)(const Context *rsc, const Allocation *alloc,
121 uint32_t xoff, uint32_t lod, uint32_t count,
Alex Sakhartchouka3f15432012-02-13 11:57:32 -0800122 const void *data, size_t sizeBytes);
Jason Sams7e8aae72011-05-26 16:33:01 -0700123 void (*data2D)(const Context *rsc, const Allocation *alloc,
124 uint32_t xoff, uint32_t yoff, uint32_t lod,
125 RsAllocationCubemapFace face, uint32_t w, uint32_t h,
Alex Sakhartchouka3f15432012-02-13 11:57:32 -0800126 const void *data, size_t sizeBytes);
Jason Sams7e8aae72011-05-26 16:33:01 -0700127 void (*data3D)(const Context *rsc, const Allocation *alloc,
128 uint32_t xoff, uint32_t yoff, uint32_t zoff,
129 uint32_t lod, RsAllocationCubemapFace face,
Alex Sakhartchouka3f15432012-02-13 11:57:32 -0800130 uint32_t w, uint32_t h, uint32_t d, const void *data, size_t sizeBytes);
Jason Sams7e8aae72011-05-26 16:33:01 -0700131
Alex Sakhartchouk304b1f52011-06-14 11:13:19 -0700132 // Allocation to allocation copies
133 void (*allocData1D)(const Context *rsc,
134 const Allocation *dstAlloc,
135 uint32_t dstXoff, uint32_t dstLod, uint32_t count,
136 const Allocation *srcAlloc, uint32_t srcXoff, uint32_t srcLod);
137 void (*allocData2D)(const Context *rsc,
138 const Allocation *dstAlloc,
139 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod,
140 RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h,
141 const Allocation *srcAlloc,
142 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod,
143 RsAllocationCubemapFace srcFace);
144 void (*allocData3D)(const Context *rsc,
145 const Allocation *dstAlloc,
146 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstZoff,
147 uint32_t dstLod, RsAllocationCubemapFace dstFace,
148 uint32_t w, uint32_t h, uint32_t d,
149 const Allocation *srcAlloc,
150 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff,
151 uint32_t srcLod, RsAllocationCubemapFace srcFace);
152
Jason Sams7e8aae72011-05-26 16:33:01 -0700153 void (*elementData1D)(const Context *rsc, const Allocation *alloc, uint32_t x,
Alex Sakhartchouka3f15432012-02-13 11:57:32 -0800154 const void *data, uint32_t elementOff, size_t sizeBytes);
Jason Sams7e8aae72011-05-26 16:33:01 -0700155 void (*elementData2D)(const Context *rsc, const Allocation *alloc, uint32_t x, uint32_t y,
Alex Sakhartchouka3f15432012-02-13 11:57:32 -0800156 const void *data, uint32_t elementOff, size_t sizeBytes);
Jason Sams7e8aae72011-05-26 16:33:01 -0700157
158
159 } allocation;
160
161 struct {
Jason Sams48f50562011-03-18 15:03:25 -0700162 bool (*init)(const Context *rsc, const ProgramStore *ps);
163 void (*setActive)(const Context *rsc, const ProgramStore *ps);
164 void (*destroy)(const Context *rsc, const ProgramStore *ps);
165 } store;
166
Jason Sams331bf9b2011-04-06 11:23:54 -0700167 struct {
168 bool (*init)(const Context *rsc, const ProgramRaster *ps);
169 void (*setActive)(const Context *rsc, const ProgramRaster *ps);
170 void (*destroy)(const Context *rsc, const ProgramRaster *ps);
171 } raster;
Jason Sams48f50562011-03-18 15:03:25 -0700172
Alex Sakhartchouk4a36b452011-04-29 16:49:08 -0700173 struct {
174 bool (*init)(const Context *rsc, const ProgramVertex *pv,
Alex Sakhartchouk2123b462012-02-15 16:21:46 -0800175 const char* shader, size_t shaderLen,
176 const char** textureNames, size_t textureNamesCount,
177 const size_t *textureNamesLength);
Alex Sakhartchouk4a36b452011-04-29 16:49:08 -0700178 void (*setActive)(const Context *rsc, const ProgramVertex *pv);
179 void (*destroy)(const Context *rsc, const ProgramVertex *pv);
180 } vertex;
181
182 struct {
183 bool (*init)(const Context *rsc, const ProgramFragment *pf,
Alex Sakhartchouk2123b462012-02-15 16:21:46 -0800184 const char* shader, size_t shaderLen,
185 const char** textureNames, size_t textureNamesCount,
186 const size_t *textureNamesLength);
Alex Sakhartchouk4a36b452011-04-29 16:49:08 -0700187 void (*setActive)(const Context *rsc, const ProgramFragment *pf);
188 void (*destroy)(const Context *rsc, const ProgramFragment *pf);
189 } fragment;
190
191 struct {
192 bool (*init)(const Context *rsc, const Mesh *m);
193 void (*draw)(const Context *rsc, const Mesh *m, uint32_t primIndex, uint32_t start, uint32_t len);
194 void (*destroy)(const Context *rsc, const Mesh *m);
195 } mesh;
Jason Samse4a06c52011-03-16 16:29:28 -0700196
Alex Sakhartchouk43850542011-05-05 16:56:27 -0700197 struct {
Jason Samsf15ed012011-10-31 13:23:43 -0700198 bool (*initStatic)(const Context *rsc, const Path *m, const Allocation *vtx, const Allocation *loops);
199 bool (*initDynamic)(const Context *rsc, const Path *m);
200 void (*draw)(const Context *rsc, const Path *m);
201 void (*destroy)(const Context *rsc, const Path *m);
202 } path;
203
204 struct {
Alex Sakhartchouk43850542011-05-05 16:56:27 -0700205 bool (*init)(const Context *rsc, const Sampler *m);
206 void (*destroy)(const Context *rsc, const Sampler *m);
207 } sampler;
208
Alex Sakhartchouk2f6964f2011-05-13 14:53:34 -0700209 struct {
210 bool (*init)(const Context *rsc, const FBOCache *fb);
211 void (*setActive)(const Context *rsc, const FBOCache *fb);
212 void (*destroy)(const Context *rsc, const FBOCache *fb);
213 } framebuffer;
214
Jason Samse4a06c52011-03-16 16:29:28 -0700215} RsdHalFunctions;
216
Jason Samse4a06c52011-03-16 16:29:28 -0700217
218}
219}
220
221
222bool rsdHalInit(android::renderscript::Context *, uint32_t version_major, uint32_t version_minor);
223
224#endif
225