blob: 6a4537b392a26c0e16433180a81dd2f37e09bbbc [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>
21
22namespace android {
23namespace renderscript {
24
25class Context;
26class ObjectBase;
27class Element;
28class Type;
29class Allocation;
30class Script;
31class ScriptC;
Alex Sakhartchouk7f126c72011-05-05 16:56:27 -070032class Program;
Jason Sams8feea4e2011-03-18 15:03:25 -070033class ProgramStore;
Jason Sams721acc42011-04-06 11:23:54 -070034class ProgramRaster;
Alex Sakhartchouka04e30d2011-04-29 16:49:08 -070035class ProgramVertex;
36class ProgramFragment;
37class Mesh;
Alex Sakhartchouk7f126c72011-05-05 16:56:27 -070038class Sampler;
Alex Sakhartchoukda6d34a2011-05-13 14:53:34 -070039class FBOCache;
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 *);
Alex Sakhartchouk7257c7e2011-05-17 12:32:47 -070049 bool (*setSurface)(const Context *, uint32_t w, uint32_t h, RsNativeWindow);
Jason Sams4b3de472011-04-06 17:52:23 -070050 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,
Jason Sams35e429e2011-07-13 11:26:26 -070073 uint32_t slot,
Jason Samscdfdb8f2011-03-17 16:12:47 -070074 const Allocation * ain,
75 Allocation * aout,
76 const void * usr,
77 uint32_t usrLen,
78 const RsScriptCall *sc);
79 void (*invokeInit)(const Context *rsc, Script *s);
Jason Samsbad80742011-03-16 16:29:28 -070080
81 void (*setGlobalVar)(const Context *rsc, const Script *s,
82 uint32_t slot,
83 void *data,
84 size_t dataLength);
85 void (*setGlobalBind)(const Context *rsc, const Script *s,
86 uint32_t slot,
87 void *data);
88 void (*setGlobalObj)(const Context *rsc, const Script *s,
89 uint32_t slot,
90 ObjectBase *data);
91
92 void (*destroy)(const Context *rsc, Script *s);
93 } script;
94
Jason Sams8feea4e2011-03-18 15:03:25 -070095 struct {
Jason Samseb4fe182011-05-26 16:33:01 -070096 bool (*init)(const Context *rsc, Allocation *alloc, bool forceZero);
97 void (*destroy)(const Context *rsc, Allocation *alloc);
98
99 void (*resize)(const Context *rsc, const Allocation *alloc, const Type *newType,
100 bool zeroNew);
101 void (*syncAll)(const Context *rsc, const Allocation *alloc, RsAllocationUsageType src);
102 void (*markDirty)(const Context *rsc, const Allocation *alloc);
103
104 void (*data1D)(const Context *rsc, const Allocation *alloc,
105 uint32_t xoff, uint32_t lod, uint32_t count,
106 const void *data, uint32_t sizeBytes);
107 void (*data2D)(const Context *rsc, const Allocation *alloc,
108 uint32_t xoff, uint32_t yoff, uint32_t lod,
109 RsAllocationCubemapFace face, uint32_t w, uint32_t h,
110 const void *data, uint32_t sizeBytes);
111 void (*data3D)(const Context *rsc, const Allocation *alloc,
112 uint32_t xoff, uint32_t yoff, uint32_t zoff,
113 uint32_t lod, RsAllocationCubemapFace face,
114 uint32_t w, uint32_t h, uint32_t d, const void *data, uint32_t sizeBytes);
115
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700116 // Allocation to allocation copies
117 void (*allocData1D)(const Context *rsc,
118 const Allocation *dstAlloc,
119 uint32_t dstXoff, uint32_t dstLod, uint32_t count,
120 const Allocation *srcAlloc, uint32_t srcXoff, uint32_t srcLod);
121 void (*allocData2D)(const Context *rsc,
122 const Allocation *dstAlloc,
123 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod,
124 RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h,
125 const Allocation *srcAlloc,
126 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod,
127 RsAllocationCubemapFace srcFace);
128 void (*allocData3D)(const Context *rsc,
129 const Allocation *dstAlloc,
130 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstZoff,
131 uint32_t dstLod, RsAllocationCubemapFace dstFace,
132 uint32_t w, uint32_t h, uint32_t d,
133 const Allocation *srcAlloc,
134 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff,
135 uint32_t srcLod, RsAllocationCubemapFace srcFace);
136
Jason Samseb4fe182011-05-26 16:33:01 -0700137 void (*elementData1D)(const Context *rsc, const Allocation *alloc, uint32_t x,
138 const void *data, uint32_t elementOff, uint32_t sizeBytes);
139 void (*elementData2D)(const Context *rsc, const Allocation *alloc, uint32_t x, uint32_t y,
140 const void *data, uint32_t elementOff, uint32_t sizeBytes);
141
142
143 } allocation;
144
145 struct {
Jason Sams8feea4e2011-03-18 15:03:25 -0700146 bool (*init)(const Context *rsc, const ProgramStore *ps);
147 void (*setActive)(const Context *rsc, const ProgramStore *ps);
148 void (*destroy)(const Context *rsc, const ProgramStore *ps);
149 } store;
150
Jason Sams721acc42011-04-06 11:23:54 -0700151 struct {
152 bool (*init)(const Context *rsc, const ProgramRaster *ps);
153 void (*setActive)(const Context *rsc, const ProgramRaster *ps);
154 void (*destroy)(const Context *rsc, const ProgramRaster *ps);
155 } raster;
Jason Sams8feea4e2011-03-18 15:03:25 -0700156
Alex Sakhartchouka04e30d2011-04-29 16:49:08 -0700157 struct {
158 bool (*init)(const Context *rsc, const ProgramVertex *pv,
159 const char* shader, uint32_t shaderLen);
160 void (*setActive)(const Context *rsc, const ProgramVertex *pv);
161 void (*destroy)(const Context *rsc, const ProgramVertex *pv);
162 } vertex;
163
164 struct {
165 bool (*init)(const Context *rsc, const ProgramFragment *pf,
166 const char* shader, uint32_t shaderLen);
167 void (*setActive)(const Context *rsc, const ProgramFragment *pf);
168 void (*destroy)(const Context *rsc, const ProgramFragment *pf);
169 } fragment;
170
171 struct {
172 bool (*init)(const Context *rsc, const Mesh *m);
173 void (*draw)(const Context *rsc, const Mesh *m, uint32_t primIndex, uint32_t start, uint32_t len);
174 void (*destroy)(const Context *rsc, const Mesh *m);
175 } mesh;
Jason Samsbad80742011-03-16 16:29:28 -0700176
Alex Sakhartchouk7f126c72011-05-05 16:56:27 -0700177 struct {
178 bool (*init)(const Context *rsc, const Sampler *m);
179 void (*destroy)(const Context *rsc, const Sampler *m);
180 } sampler;
181
Alex Sakhartchoukda6d34a2011-05-13 14:53:34 -0700182 struct {
183 bool (*init)(const Context *rsc, const FBOCache *fb);
184 void (*setActive)(const Context *rsc, const FBOCache *fb);
185 void (*destroy)(const Context *rsc, const FBOCache *fb);
186 } framebuffer;
187
Jason Samsbad80742011-03-16 16:29:28 -0700188} RsdHalFunctions;
189
Jason Samsbad80742011-03-16 16:29:28 -0700190
191}
192}
193
194
195bool rsdHalInit(android::renderscript::Context *, uint32_t version_major, uint32_t version_minor);
196
197#endif
198