blob: 0afc94b99e9be19b525e5a74c5693ff9f6ebcf4b [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 Samsc1b4c1f2011-08-17 13:46:46 -070043typedef struct {
44 const void *in;
45 void *out;
46 const void *usr;
47 size_t usr_len;
48 uint32_t x;
49 uint32_t y;
50 uint32_t z;
51 uint32_t lod;
52 RsAllocationCubemapFace face;
53 uint32_t ar[16];
54} RsForEachStubParamStruct;
55
Jason Samse4a06c52011-03-16 16:29:28 -070056/**
57 * Script management functions
58 */
59typedef struct {
Jason Sams803626f2011-04-06 17:52:23 -070060 bool (*initGraphics)(const Context *);
61 void (*shutdownGraphics)(const Context *);
Alex Sakhartchouk6c72eec2011-05-17 12:32:47 -070062 bool (*setSurface)(const Context *, uint32_t w, uint32_t h, RsNativeWindow);
Jason Sams803626f2011-04-06 17:52:23 -070063 void (*swap)(const Context *);
64
Jason Sams55d2a252011-03-17 16:12:47 -070065 void (*shutdownDriver)(Context *);
Jason Samse4a06c52011-03-16 16:29:28 -070066 void (*getVersion)(unsigned int *major, unsigned int *minor);
Jason Sams55d2a252011-03-17 16:12:47 -070067 void (*setPriority)(const Context *, int32_t priority);
Jason Samse4a06c52011-03-16 16:29:28 -070068
69
70
71 struct {
Jason Sams48f50562011-03-18 15:03:25 -070072 bool (*init)(const Context *rsc, ScriptC *s,
73 char const *resName,
74 char const *cacheDir,
75 uint8_t const *bitcode,
76 size_t bitcodeSize,
Jason Samsfcf72312011-04-20 15:09:01 -070077 uint32_t flags);
Jason Samse4a06c52011-03-16 16:29:28 -070078
Jason Sams55d2a252011-03-17 16:12:47 -070079 void (*invokeFunction)(const Context *rsc, Script *s,
Jason Samse4a06c52011-03-16 16:29:28 -070080 uint32_t slot,
81 const void *params,
82 size_t paramLength);
Jason Sams55d2a252011-03-17 16:12:47 -070083 int (*invokeRoot)(const Context *rsc, Script *s);
84 void (*invokeForEach)(const Context *rsc,
85 Script *s,
Jason Sams92b0eab2011-07-13 11:26:26 -070086 uint32_t slot,
Jason Sams55d2a252011-03-17 16:12:47 -070087 const Allocation * ain,
88 Allocation * aout,
89 const void * usr,
90 uint32_t usrLen,
91 const RsScriptCall *sc);
92 void (*invokeInit)(const Context *rsc, Script *s);
Stephen Hines514f9792011-08-31 17:41:39 -070093 void (*invokeFreeChildren)(const Context *rsc, Script *s);
Jason Samse4a06c52011-03-16 16:29:28 -070094
95 void (*setGlobalVar)(const Context *rsc, const Script *s,
96 uint32_t slot,
97 void *data,
98 size_t dataLength);
99 void (*setGlobalBind)(const Context *rsc, const Script *s,
100 uint32_t slot,
101 void *data);
102 void (*setGlobalObj)(const Context *rsc, const Script *s,
103 uint32_t slot,
104 ObjectBase *data);
105
106 void (*destroy)(const Context *rsc, Script *s);
107 } script;
108
Jason Sams48f50562011-03-18 15:03:25 -0700109 struct {
Jason Sams7e8aae72011-05-26 16:33:01 -0700110 bool (*init)(const Context *rsc, Allocation *alloc, bool forceZero);
111 void (*destroy)(const Context *rsc, Allocation *alloc);
112
113 void (*resize)(const Context *rsc, const Allocation *alloc, const Type *newType,
114 bool zeroNew);
115 void (*syncAll)(const Context *rsc, const Allocation *alloc, RsAllocationUsageType src);
116 void (*markDirty)(const Context *rsc, const Allocation *alloc);
Jason Sams532efd32012-02-10 13:24:18 -0800117 int32_t (*initSurfaceTexture)(const Context *rsc, const Allocation *alloc);
Jason Sams7e8aae72011-05-26 16:33:01 -0700118
119 void (*data1D)(const Context *rsc, const Allocation *alloc,
120 uint32_t xoff, uint32_t lod, uint32_t count,
121 const void *data, uint32_t sizeBytes);
122 void (*data2D)(const Context *rsc, const Allocation *alloc,
123 uint32_t xoff, uint32_t yoff, uint32_t lod,
124 RsAllocationCubemapFace face, uint32_t w, uint32_t h,
125 const void *data, uint32_t sizeBytes);
126 void (*data3D)(const Context *rsc, const Allocation *alloc,
127 uint32_t xoff, uint32_t yoff, uint32_t zoff,
128 uint32_t lod, RsAllocationCubemapFace face,
129 uint32_t w, uint32_t h, uint32_t d, const void *data, uint32_t sizeBytes);
130
Alex Sakhartchouk304b1f52011-06-14 11:13:19 -0700131 // Allocation to allocation copies
132 void (*allocData1D)(const Context *rsc,
133 const Allocation *dstAlloc,
134 uint32_t dstXoff, uint32_t dstLod, uint32_t count,
135 const Allocation *srcAlloc, uint32_t srcXoff, uint32_t srcLod);
136 void (*allocData2D)(const Context *rsc,
137 const Allocation *dstAlloc,
138 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod,
139 RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h,
140 const Allocation *srcAlloc,
141 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod,
142 RsAllocationCubemapFace srcFace);
143 void (*allocData3D)(const Context *rsc,
144 const Allocation *dstAlloc,
145 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstZoff,
146 uint32_t dstLod, RsAllocationCubemapFace dstFace,
147 uint32_t w, uint32_t h, uint32_t d,
148 const Allocation *srcAlloc,
149 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff,
150 uint32_t srcLod, RsAllocationCubemapFace srcFace);
151
Jason Sams7e8aae72011-05-26 16:33:01 -0700152 void (*elementData1D)(const Context *rsc, const Allocation *alloc, uint32_t x,
153 const void *data, uint32_t elementOff, uint32_t sizeBytes);
154 void (*elementData2D)(const Context *rsc, const Allocation *alloc, uint32_t x, uint32_t y,
155 const void *data, uint32_t elementOff, uint32_t sizeBytes);
156
157
158 } allocation;
159
160 struct {
Jason Sams48f50562011-03-18 15:03:25 -0700161 bool (*init)(const Context *rsc, const ProgramStore *ps);
162 void (*setActive)(const Context *rsc, const ProgramStore *ps);
163 void (*destroy)(const Context *rsc, const ProgramStore *ps);
164 } store;
165
Jason Sams331bf9b2011-04-06 11:23:54 -0700166 struct {
167 bool (*init)(const Context *rsc, const ProgramRaster *ps);
168 void (*setActive)(const Context *rsc, const ProgramRaster *ps);
169 void (*destroy)(const Context *rsc, const ProgramRaster *ps);
170 } raster;
Jason Sams48f50562011-03-18 15:03:25 -0700171
Alex Sakhartchouk4a36b452011-04-29 16:49:08 -0700172 struct {
173 bool (*init)(const Context *rsc, const ProgramVertex *pv,
174 const char* shader, uint32_t shaderLen);
175 void (*setActive)(const Context *rsc, const ProgramVertex *pv);
176 void (*destroy)(const Context *rsc, const ProgramVertex *pv);
177 } vertex;
178
179 struct {
180 bool (*init)(const Context *rsc, const ProgramFragment *pf,
181 const char* shader, uint32_t shaderLen);
182 void (*setActive)(const Context *rsc, const ProgramFragment *pf);
183 void (*destroy)(const Context *rsc, const ProgramFragment *pf);
184 } fragment;
185
186 struct {
187 bool (*init)(const Context *rsc, const Mesh *m);
188 void (*draw)(const Context *rsc, const Mesh *m, uint32_t primIndex, uint32_t start, uint32_t len);
189 void (*destroy)(const Context *rsc, const Mesh *m);
190 } mesh;
Jason Samse4a06c52011-03-16 16:29:28 -0700191
Alex Sakhartchouk43850542011-05-05 16:56:27 -0700192 struct {
193 bool (*init)(const Context *rsc, const Sampler *m);
194 void (*destroy)(const Context *rsc, const Sampler *m);
195 } sampler;
196
Alex Sakhartchouk2f6964f2011-05-13 14:53:34 -0700197 struct {
198 bool (*init)(const Context *rsc, const FBOCache *fb);
199 void (*setActive)(const Context *rsc, const FBOCache *fb);
200 void (*destroy)(const Context *rsc, const FBOCache *fb);
201 } framebuffer;
202
Jason Samse4a06c52011-03-16 16:29:28 -0700203} RsdHalFunctions;
204
Jason Samse4a06c52011-03-16 16:29:28 -0700205
206}
207}
208
209
210bool rsdHalInit(android::renderscript::Context *, uint32_t version_major, uint32_t version_minor);
211
212#endif
213