blob: 06a9b57fd2fe6667a81b368fe5016f16aff38e08 [file] [log] [blame]
Jason Samsbad80742011-03-16 16:29:28 -07001/*
Stephen Hines2980f072012-04-09 18:26:29 -07002 * Copyright (C) 2011-2012 The Android Open Source Project
Jason Samsbad80742011-03-16 16:29:28 -07003 *
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 Sams66f0a162014-11-11 13:46:38 -080020#include <rsInternalDefines.h>
Jason Samsbad80742011-03-16 16:29:28 -070021
David Gross8e707912016-06-06 16:15:00 -070022/*
23 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
24 * !! Major version number of the driver. This is used to ensure that
25 * !! the driver (e.g., libRSDriver) is compatible with the shell
26 * !! (i.e., libRS_internal) responsible for loading the driver.
27 * !! There is no notion of backwards compatibility -- the driver and
28 * !! the shell must agree on the major version number.
29 * !!
30 * !! The version number must change whenever there is a semantic change
31 * !! to the HAL such as adding or removing an entry point or changing
32 * !! the meaning of an entry point. By convention it is monotonically
33 * !! increasing across all branches (e.g., aosp/master and all internal
34 * !! branches).
35 * !!
36 * !! Be very careful when merging or cherry picking between branches!
37 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
38 */
Miao Wangf750c532017-03-03 16:03:44 -080039#define RS_HAL_VERSION 200
David Gross8e707912016-06-06 16:15:00 -070040
Jason Sams0ca7cba2015-03-11 15:22:38 -070041/**
42 * The interface for loading RenderScript drivers
43 *
44 * The startup sequence is
45 *
46 * 1: dlopen driver
David Gross8e707912016-06-06 16:15:00 -070047 * 2: Query driver version with rsdHalQueryVersion() and verify
48 * that the driver (e.g., libRSDriver) is compatible with the shell
49 * (i.e., libRS_internal) responsible for loading the driver
Jason Sams0ca7cba2015-03-11 15:22:38 -070050 * 3: Fill in HAL pointer table with calls to rsdHalQueryHAL()
51 * 4: Initialize the context with rsdHalInit()
52 *
53 * If any of these functions return false, the loading of the
54 * driver will abort and the reference driver will be used.
55 * rsdHalAbort() will be called to clean up any partially
56 * allocated state.
57 *
Jason Samsb9276ce2015-03-17 13:42:47 -070058 * A driver should return FALSE for any conditions that will
59 * prevent the driver from working normally.
60 *
61 *
Jason Sams0ca7cba2015-03-11 15:22:38 -070062 * If these are successful, the driver will be loaded and used
63 * normally. Teardown will use the normal
64 * context->mHal.funcs.shutdown() path. There will be no call
65 * to rsdHalAbort().
66 *
67 *
68 */
69
70
Jason Sams7ac2a4d2012-02-15 12:04:24 -080071struct ANativeWindow;
72
Jason Samsbad80742011-03-16 16:29:28 -070073namespace android {
74namespace renderscript {
75
76class Context;
77class ObjectBase;
78class Element;
79class Type;
80class Allocation;
81class Script;
Jason Samsdbe66d62012-09-17 13:54:41 -070082class ScriptKernelID;
83class ScriptFieldID;
84class ScriptMethodID;
Jason Samsbad80742011-03-16 16:29:28 -070085class ScriptC;
Jason Samsdbe66d62012-09-17 13:54:41 -070086class ScriptGroup;
Yang Ni1ffd86b2015-01-07 09:16:40 -080087class ScriptGroupBase;
Jason Sams9e0afb52011-10-31 13:23:43 -070088class Path;
Alex Sakhartchouk7f126c72011-05-05 16:56:27 -070089class Program;
Jason Sams8feea4e2011-03-18 15:03:25 -070090class ProgramStore;
Jason Sams721acc42011-04-06 11:23:54 -070091class ProgramRaster;
Alex Sakhartchouka04e30d2011-04-29 16:49:08 -070092class ProgramVertex;
93class ProgramFragment;
94class Mesh;
Alex Sakhartchouk7f126c72011-05-05 16:56:27 -070095class Sampler;
Alex Sakhartchoukda6d34a2011-05-13 14:53:34 -070096class FBOCache;
Jason Samsbad80742011-03-16 16:29:28 -070097
Jason Samsa36c50a2014-06-17 12:06:06 -070098/**
99 * Define the internal object types. This ia a mirror of the
100 * definition in rs_types.rsh except with the p value typed
101 * correctly.
102 *
103 * p = pointer to internal object implementation
I-Jui (Ray) Sung700e6882017-03-06 14:42:53 -0800104 * unused1, unused2, unused3 = reserved for ABI compatibility
Jason Samsa36c50a2014-06-17 12:06:06 -0700105 */
106
Jean-Luc Brouillet86323722017-01-19 22:11:40 -0800107// RS_BASE_OBJ must have the same layout as _RS_OBJECT_DECL defined in
108// script_api/rs_object_types.spec.
109// TODO(jeanluc) Look at unifying.
Jason Samsa36c50a2014-06-17 12:06:06 -0700110#ifndef __LP64__
111#define RS_BASE_OBJ(_t_) typedef struct { const _t_* p; } __attribute__((packed, aligned(4)))
Jean-Luc Brouillet86323722017-01-19 22:11:40 -0800112#define RS_BASE_NULL_OBJ {0}
Jason Samsa36c50a2014-06-17 12:06:06 -0700113#else
I-Jui (Ray) Sung700e6882017-03-06 14:42:53 -0800114#define RS_BASE_OBJ(_t_) typedef struct { const _t_* p; const void* unused1; const void* unused2; const void* unused3; }
Jean-Luc Brouillet86323722017-01-19 22:11:40 -0800115#define RS_BASE_NULL_OBJ {0, 0, 0, 0}
Jason Samsa36c50a2014-06-17 12:06:06 -0700116#endif
117
Jason Sams05ef73f2014-08-05 14:59:22 -0700118RS_BASE_OBJ(ObjectBase) rs_object_base;
Jason Samsa36c50a2014-06-17 12:06:06 -0700119RS_BASE_OBJ(Element) rs_element;
120RS_BASE_OBJ(Type) rs_type;
121RS_BASE_OBJ(Allocation) rs_allocation;
122RS_BASE_OBJ(Sampler) rs_sampler;
123RS_BASE_OBJ(Script) rs_script;
124RS_BASE_OBJ(ScriptGroup) rs_script_group;
125
126#ifndef __LP64__
127typedef struct { const int* p; } __attribute__((packed, aligned(4))) rs_mesh;
Jason Samsa36c50a2014-06-17 12:06:06 -0700128typedef struct { const int* p; } __attribute__((packed, aligned(4))) rs_program_fragment;
129typedef struct { const int* p; } __attribute__((packed, aligned(4))) rs_program_vertex;
130typedef struct { const int* p; } __attribute__((packed, aligned(4))) rs_program_raster;
131typedef struct { const int* p; } __attribute__((packed, aligned(4))) rs_program_store;
132typedef struct { const int* p; } __attribute__((packed, aligned(4))) rs_font;
133#endif // __LP64__
134
135
Jason Samsbad80742011-03-16 16:29:28 -0700136typedef void *(*RsHalSymbolLookupFunc)(void *usrptr, char const *symbolName);
137
Jason Samsbad80742011-03-16 16:29:28 -0700138/**
139 * Script management functions
140 */
141typedef struct {
Miao Wang025a1f42017-04-06 19:24:44 -0700142 int (*initGraphics)(const Context *);
Jason Sams4b3de472011-04-06 17:52:23 -0700143 void (*shutdownGraphics)(const Context *);
Alex Sakhartchouk7257c7e2011-05-17 12:32:47 -0700144 bool (*setSurface)(const Context *, uint32_t w, uint32_t h, RsNativeWindow);
Jason Sams4b3de472011-04-06 17:52:23 -0700145 void (*swap)(const Context *);
146
Jason Samscdfdb8f2011-03-17 16:12:47 -0700147 void (*shutdownDriver)(Context *);
Jason Samscdfdb8f2011-03-17 16:12:47 -0700148 void (*setPriority)(const Context *, int32_t priority);
Jason Samsbad80742011-03-16 16:29:28 -0700149
Tim Murray34689382013-03-11 12:12:03 -0700150 void* (*allocRuntimeMem)(size_t size, uint32_t flags);
151 void (*freeRuntimeMem)(void* ptr);
Jason Samsbad80742011-03-16 16:29:28 -0700152
153 struct {
Jason Sams8feea4e2011-03-18 15:03:25 -0700154 bool (*init)(const Context *rsc, ScriptC *s,
155 char const *resName,
156 char const *cacheDir,
157 uint8_t const *bitcode,
158 size_t bitcodeSize,
Jason Sams87fe59a2011-04-20 15:09:01 -0700159 uint32_t flags);
Jason Sams8eaba4f2012-08-14 14:38:05 -0700160 bool (*initIntrinsic)(const Context *rsc, Script *s,
Stephen Hines41d6c762012-08-21 17:07:38 -0700161 RsScriptIntrinsicID iid,
Jason Sams8eaba4f2012-08-14 14:38:05 -0700162 Element *e);
Jason Samsbad80742011-03-16 16:29:28 -0700163
Jason Samscdfdb8f2011-03-17 16:12:47 -0700164 void (*invokeFunction)(const Context *rsc, Script *s,
Jason Samsbad80742011-03-16 16:29:28 -0700165 uint32_t slot,
166 const void *params,
167 size_t paramLength);
Jason Samscdfdb8f2011-03-17 16:12:47 -0700168 int (*invokeRoot)(const Context *rsc, Script *s);
169 void (*invokeForEach)(const Context *rsc,
170 Script *s,
Jason Sams35e429e2011-07-13 11:26:26 -0700171 uint32_t slot,
Jason Samscdfdb8f2011-03-17 16:12:47 -0700172 const Allocation * ain,
173 Allocation * aout,
174 const void * usr,
Tim Murray099bc262013-03-20 16:54:03 -0700175 size_t usrLen,
Jason Samscdfdb8f2011-03-17 16:12:47 -0700176 const RsScriptCall *sc);
Matt Wala14ce0072015-07-30 17:30:25 -0700177 void (*invokeReduce)(const Context *rsc, Script *s,
David Grossae2ec3f2016-06-01 14:45:47 -0700178 uint32_t slot,
179 const Allocation ** ains, size_t inLen,
Matt Wala14ce0072015-07-30 17:30:25 -0700180 Allocation *aout,
181 const RsScriptCall *sc);
Jason Samscdfdb8f2011-03-17 16:12:47 -0700182 void (*invokeInit)(const Context *rsc, Script *s);
Stephen Hines4ee16ff2011-08-31 17:41:39 -0700183 void (*invokeFreeChildren)(const Context *rsc, Script *s);
Jason Samsbad80742011-03-16 16:29:28 -0700184
185 void (*setGlobalVar)(const Context *rsc, const Script *s,
186 uint32_t slot,
187 void *data,
188 size_t dataLength);
Tim Murray9c642392013-04-11 13:29:59 -0700189 void (*getGlobalVar)(const Context *rsc, const Script *s,
190 uint32_t slot,
191 void *data,
192 size_t dataLength);
Stephen Hines2980f072012-04-09 18:26:29 -0700193 void (*setGlobalVarWithElemDims)(const Context *rsc, const Script *s,
194 uint32_t slot,
195 void *data,
196 size_t dataLength,
197 const Element *e,
Stephen Hinesac8d1462014-06-25 00:01:23 -0700198 const uint32_t *dims,
Stephen Hines2980f072012-04-09 18:26:29 -0700199 size_t dimLength);
Jason Samsbad80742011-03-16 16:29:28 -0700200 void (*setGlobalBind)(const Context *rsc, const Script *s,
201 uint32_t slot,
Jason Sams807fdc42012-07-25 17:55:39 -0700202 Allocation *data);
Jason Samsbad80742011-03-16 16:29:28 -0700203 void (*setGlobalObj)(const Context *rsc, const Script *s,
204 uint32_t slot,
205 ObjectBase *data);
206
207 void (*destroy)(const Context *rsc, Script *s);
Chris Wailes4b3c34e2014-06-11 12:00:29 -0700208 void (*invokeForEachMulti)(const Context *rsc,
209 Script *s,
210 uint32_t slot,
211 const Allocation ** ains,
212 size_t inLen,
213 Allocation * aout,
214 const void * usr,
215 size_t usrLen,
216 const RsScriptCall *sc);
Jason Samsa36c50a2014-06-17 12:06:06 -0700217 void (*updateCachedObject)(const Context *rsc, const Script *, rs_script *obj);
Jason Samsbad80742011-03-16 16:29:28 -0700218 } script;
219
Jason Sams8feea4e2011-03-18 15:03:25 -0700220 struct {
Jason Samseb4fe182011-05-26 16:33:01 -0700221 bool (*init)(const Context *rsc, Allocation *alloc, bool forceZero);
Jason Samsf82b6262015-05-11 15:02:50 -0700222 bool (*initOem)(const Context *rsc, Allocation *alloc, bool forceZero, void *usrPtr);
Jason Samsbc9dc272015-02-09 12:50:22 -0800223 bool (*initAdapter)(const Context *rsc, Allocation *alloc);
Jason Samseb4fe182011-05-26 16:33:01 -0700224 void (*destroy)(const Context *rsc, Allocation *alloc);
Jason Samsddceab92013-08-07 13:02:32 -0700225 uint32_t (*grallocBits)(const Context *rsc, Allocation *alloc);
Jason Samseb4fe182011-05-26 16:33:01 -0700226
227 void (*resize)(const Context *rsc, const Allocation *alloc, const Type *newType,
228 bool zeroNew);
229 void (*syncAll)(const Context *rsc, const Allocation *alloc, RsAllocationUsageType src);
230 void (*markDirty)(const Context *rsc, const Allocation *alloc);
Jason Sams7ac2a4d2012-02-15 12:04:24 -0800231
Jason Sams733396b2013-02-22 12:46:18 -0800232 void (*setSurface)(const Context *rsc, Allocation *alloc, ANativeWindow *sur);
Jason Sams7ac2a4d2012-02-15 12:04:24 -0800233 void (*ioSend)(const Context *rsc, Allocation *alloc);
Jason Samsddceab92013-08-07 13:02:32 -0700234
235 /**
236 * A new gralloc buffer is in use. The pointers and strides in
237 * mHal.drvState.lod[0-2] will be updated with the new values.
238 *
239 * The new gralloc handle is provided in mHal.state.nativeBuffer
240 *
241 */
Jason Sams7ac2a4d2012-02-15 12:04:24 -0800242 void (*ioReceive)(const Context *rsc, Allocation *alloc);
Jason Samseb4fe182011-05-26 16:33:01 -0700243
244 void (*data1D)(const Context *rsc, const Allocation *alloc,
Tim Murray099bc262013-03-20 16:54:03 -0700245 uint32_t xoff, uint32_t lod, size_t count,
Alex Sakhartchoukc794cd52012-02-13 11:57:32 -0800246 const void *data, size_t sizeBytes);
Jason Samseb4fe182011-05-26 16:33:01 -0700247 void (*data2D)(const Context *rsc, const Allocation *alloc,
248 uint32_t xoff, uint32_t yoff, uint32_t lod,
249 RsAllocationCubemapFace face, uint32_t w, uint32_t h,
Tim Murray358747a2012-11-26 13:52:04 -0800250 const void *data, size_t sizeBytes, size_t stride);
Jason Samseb4fe182011-05-26 16:33:01 -0700251 void (*data3D)(const Context *rsc, const Allocation *alloc,
Jason Sams3bbc0fd2013-04-09 14:16:13 -0700252 uint32_t xoff, uint32_t yoff, uint32_t zoff, uint32_t lod,
253 uint32_t w, uint32_t h, uint32_t d, const void *data, size_t sizeBytes,
254 size_t stride);
Jason Samseb4fe182011-05-26 16:33:01 -0700255
Jason Sams807fdc42012-07-25 17:55:39 -0700256 void (*read1D)(const Context *rsc, const Allocation *alloc,
Tim Murray099bc262013-03-20 16:54:03 -0700257 uint32_t xoff, uint32_t lod, size_t count,
Jason Sams807fdc42012-07-25 17:55:39 -0700258 void *data, size_t sizeBytes);
259 void (*read2D)(const Context *rsc, const Allocation *alloc,
260 uint32_t xoff, uint32_t yoff, uint32_t lod,
261 RsAllocationCubemapFace face, uint32_t w, uint32_t h,
Tim Murray358747a2012-11-26 13:52:04 -0800262 void *data, size_t sizeBytes, size_t stride);
Jason Sams807fdc42012-07-25 17:55:39 -0700263 void (*read3D)(const Context *rsc, const Allocation *alloc,
Jason Sams3bbc0fd2013-04-09 14:16:13 -0700264 uint32_t xoff, uint32_t yoff, uint32_t zoff, uint32_t lod,
265 uint32_t w, uint32_t h, uint32_t d, void *data, size_t sizeBytes,
266 size_t stride);
Jason Sams807fdc42012-07-25 17:55:39 -0700267
268 // Lock and unlock make a 1D region of memory available to the CPU
269 // for direct access by pointer. Once unlock is called control is
270 // returned to the SOC driver.
271 void * (*lock1D)(const Context *rsc, const Allocation *alloc);
272 void (*unlock1D)(const Context *rsc, const Allocation *alloc);
273
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700274 // Allocation to allocation copies
275 void (*allocData1D)(const Context *rsc,
276 const Allocation *dstAlloc,
Tim Murray099bc262013-03-20 16:54:03 -0700277 uint32_t dstXoff, uint32_t dstLod, size_t count,
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700278 const Allocation *srcAlloc, uint32_t srcXoff, uint32_t srcLod);
279 void (*allocData2D)(const Context *rsc,
280 const Allocation *dstAlloc,
281 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod,
282 RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h,
283 const Allocation *srcAlloc,
284 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod,
285 RsAllocationCubemapFace srcFace);
286 void (*allocData3D)(const Context *rsc,
287 const Allocation *dstAlloc,
288 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstZoff,
Jason Sams3bbc0fd2013-04-09 14:16:13 -0700289 uint32_t dstLod,
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700290 uint32_t w, uint32_t h, uint32_t d,
291 const Allocation *srcAlloc,
292 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff,
Jason Sams3bbc0fd2013-04-09 14:16:13 -0700293 uint32_t srcLod);
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700294
Miao Wangcc8cea72015-02-19 18:14:46 -0800295 void (*elementData)(const Context *rsc, const Allocation *alloc,
296 uint32_t x, uint32_t y, uint32_t z,
297 const void *data, uint32_t elementOff, size_t sizeBytes);
298 void (*elementRead)(const Context *rsc, const Allocation *alloc,
299 uint32_t x, uint32_t y, uint32_t z,
300 void *data, uint32_t elementOff, size_t sizeBytes);
Jason Samseb4fe182011-05-26 16:33:01 -0700301
Jason Sams61a4bb72012-07-25 19:33:43 -0700302 void (*generateMipmaps)(const Context *rsc, const Allocation *alloc);
Jason Samsa36c50a2014-06-17 12:06:06 -0700303
304 void (*updateCachedObject)(const Context *rsc, const Allocation *alloc, rs_allocation *obj);
Jason Samsbc9dc272015-02-09 12:50:22 -0800305
306 void (*adapterOffset)(const Context *rsc, const Allocation *alloc);
Jason Sams8ce12812015-05-18 17:28:59 -0700307
308 void (*getPointer)(const Context *rsc, const Allocation *alloc,
309 uint32_t lod, RsAllocationCubemapFace face,
310 uint32_t z, uint32_t array);
Miao Wang47a58812015-07-23 21:59:16 -0700311#ifdef RS_COMPATIBILITY_LIB
312 bool (*initStrided)(const Context *rsc, Allocation *alloc, bool forceZero, size_t requiredAlignment);
313#endif
Jason Samseb4fe182011-05-26 16:33:01 -0700314 } allocation;
315
316 struct {
Jason Sams8feea4e2011-03-18 15:03:25 -0700317 bool (*init)(const Context *rsc, const ProgramStore *ps);
318 void (*setActive)(const Context *rsc, const ProgramStore *ps);
319 void (*destroy)(const Context *rsc, const ProgramStore *ps);
320 } store;
321
Jason Sams721acc42011-04-06 11:23:54 -0700322 struct {
323 bool (*init)(const Context *rsc, const ProgramRaster *ps);
324 void (*setActive)(const Context *rsc, const ProgramRaster *ps);
325 void (*destroy)(const Context *rsc, const ProgramRaster *ps);
326 } raster;
Jason Sams8feea4e2011-03-18 15:03:25 -0700327
Alex Sakhartchouka04e30d2011-04-29 16:49:08 -0700328 struct {
329 bool (*init)(const Context *rsc, const ProgramVertex *pv,
Alex Sakhartchouk748eb072012-02-15 16:21:46 -0800330 const char* shader, size_t shaderLen,
331 const char** textureNames, size_t textureNamesCount,
332 const size_t *textureNamesLength);
Alex Sakhartchouka04e30d2011-04-29 16:49:08 -0700333 void (*setActive)(const Context *rsc, const ProgramVertex *pv);
334 void (*destroy)(const Context *rsc, const ProgramVertex *pv);
335 } vertex;
336
337 struct {
338 bool (*init)(const Context *rsc, const ProgramFragment *pf,
Alex Sakhartchouk748eb072012-02-15 16:21:46 -0800339 const char* shader, size_t shaderLen,
340 const char** textureNames, size_t textureNamesCount,
341 const size_t *textureNamesLength);
Alex Sakhartchouka04e30d2011-04-29 16:49:08 -0700342 void (*setActive)(const Context *rsc, const ProgramFragment *pf);
343 void (*destroy)(const Context *rsc, const ProgramFragment *pf);
344 } fragment;
345
346 struct {
347 bool (*init)(const Context *rsc, const Mesh *m);
348 void (*draw)(const Context *rsc, const Mesh *m, uint32_t primIndex, uint32_t start, uint32_t len);
349 void (*destroy)(const Context *rsc, const Mesh *m);
350 } mesh;
Jason Samsbad80742011-03-16 16:29:28 -0700351
Alex Sakhartchouk7f126c72011-05-05 16:56:27 -0700352 struct {
353 bool (*init)(const Context *rsc, const Sampler *m);
354 void (*destroy)(const Context *rsc, const Sampler *m);
Jason Samsa36c50a2014-06-17 12:06:06 -0700355 void (*updateCachedObject)(const Context *rsc, const Sampler *s, rs_sampler *obj);
Alex Sakhartchouk7f126c72011-05-05 16:56:27 -0700356 } sampler;
357
Alex Sakhartchoukda6d34a2011-05-13 14:53:34 -0700358 struct {
359 bool (*init)(const Context *rsc, const FBOCache *fb);
360 void (*setActive)(const Context *rsc, const FBOCache *fb);
361 void (*destroy)(const Context *rsc, const FBOCache *fb);
362 } framebuffer;
363
Jason Samsdbe66d62012-09-17 13:54:41 -0700364 struct {
Yang Ni1ffd86b2015-01-07 09:16:40 -0800365 bool (*init)(const Context *rsc, ScriptGroupBase *sg);
Jason Samsdbe66d62012-09-17 13:54:41 -0700366 void (*setInput)(const Context *rsc, const ScriptGroup *sg,
367 const ScriptKernelID *kid, Allocation *);
368 void (*setOutput)(const Context *rsc, const ScriptGroup *sg,
369 const ScriptKernelID *kid, Allocation *);
Yang Ni1ffd86b2015-01-07 09:16:40 -0800370 void (*execute)(const Context *rsc, const ScriptGroupBase *sg);
371 void (*destroy)(const Context *rsc, const ScriptGroupBase *sg);
Jason Samsa36c50a2014-06-17 12:06:06 -0700372 void (*updateCachedObject)(const Context *rsc, const ScriptGroup *sg, rs_script_group *obj);
Jason Samsdbe66d62012-09-17 13:54:41 -0700373 } scriptgroup;
374
Jason Samsa36c50a2014-06-17 12:06:06 -0700375 struct {
376 bool (*init)(const Context *rsc, const Type *m);
377 void (*destroy)(const Context *rsc, const Type *m);
378 void (*updateCachedObject)(const Context *rsc, const Type *s, rs_type *obj);
379 } type;
380
381 struct {
382 bool (*init)(const Context *rsc, const Element *m);
383 void (*destroy)(const Context *rsc, const Element *m);
384 void (*updateCachedObject)(const Context *rsc, const Element *s, rs_element *obj);
385 } element;
386
Jason Sams9761c3f2013-11-26 18:10:59 -0800387 void (*finish)(const Context *rsc);
Jason Samsbad80742011-03-16 16:29:28 -0700388} RsdHalFunctions;
389
Jason Samsbad80742011-03-16 16:29:28 -0700390
Jason Sams0ca7cba2015-03-11 15:22:38 -0700391enum RsHalInitEnums {
392 RS_HAL_CORE_SHUTDOWN = 1,
393 RS_HAL_CORE_SET_PRIORITY = 2,
394 RS_HAL_CORE_ALLOC_RUNTIME_MEM = 3,
395 RS_HAL_CORE_FREE_RUNTIME_MEM = 4,
396 RS_HAL_CORE_FINISH = 5,
397
398 RS_HAL_SCRIPT_INIT = 1000,
399 RS_HAL_SCRIPT_INIT_INTRINSIC = 1001,
400 RS_HAL_SCRIPT_INVOKE_FUNCTION = 1002,
401 RS_HAL_SCRIPT_INVOKE_ROOT = 1003,
402 RS_HAL_SCRIPT_INVOKE_FOR_EACH = 1004,
403 RS_HAL_SCRIPT_INVOKE_INIT = 1005,
404 RS_HAL_SCRIPT_INVOKE_FREE_CHILDREN = 1006,
405 RS_HAL_SCRIPT_SET_GLOBAL_VAR = 1007,
406 RS_HAL_SCRIPT_GET_GLOBAL_VAR = 1008,
407 RS_HAL_SCRIPT_SET_GLOBAL_VAR_WITH_ELEMENT_DIM = 1009,
408 RS_HAL_SCRIPT_SET_GLOBAL_BIND = 1010,
409 RS_HAL_SCRIPT_SET_GLOBAL_OBJECT = 1011,
410 RS_HAL_SCRIPT_DESTROY = 1012,
411 RS_HAL_SCRIPT_INVOKE_FOR_EACH_MULTI = 1013,
412 RS_HAL_SCRIPT_UPDATE_CACHED_OBJECT = 1014,
Matt Wala14ce0072015-07-30 17:30:25 -0700413 RS_HAL_SCRIPT_INVOKE_REDUCE = 1015,
Jason Sams0ca7cba2015-03-11 15:22:38 -0700414
415 RS_HAL_ALLOCATION_INIT = 2000,
416 RS_HAL_ALLOCATION_INIT_ADAPTER = 2001,
417 RS_HAL_ALLOCATION_DESTROY = 2002,
418 RS_HAL_ALLOCATION_GET_GRALLOC_BITS = 2003,
419 RS_HAL_ALLOCATION_RESIZE = 2004,
420 RS_HAL_ALLOCATION_SYNC_ALL = 2005,
421 RS_HAL_ALLOCATION_MARK_DIRTY = 2006,
422 RS_HAL_ALLOCATION_SET_SURFACE = 2007,
423 RS_HAL_ALLOCATION_IO_SEND = 2008,
424 RS_HAL_ALLOCATION_IO_RECEIVE = 2009,
425 RS_HAL_ALLOCATION_DATA_1D = 2010,
426 RS_HAL_ALLOCATION_DATA_2D = 2011,
427 RS_HAL_ALLOCATION_DATA_3D = 2012,
428 RS_HAL_ALLOCATION_READ_1D = 2013,
429 RS_HAL_ALLOCATION_READ_2D = 2014,
430 RS_HAL_ALLOCATION_READ_3D = 2015,
431 RS_HAL_ALLOCATION_LOCK_1D = 2016,
432 RS_HAL_ALLOCATION_UNLOCK_1D = 2017,
433 RS_HAL_ALLOCATION_COPY_1D = 2018,
434 RS_HAL_ALLOCATION_COPY_2D = 2019,
435 RS_HAL_ALLOCATION_COPY_3D = 2020,
436 RS_HAL_ALLOCATION_ELEMENT_DATA = 2021,
437 RS_HAL_ALLOCATION_ELEMENT_READ = 2022,
438 RS_HAL_ALLOCATION_GENERATE_MIPMAPS = 2023,
439 RS_HAL_ALLOCATION_UPDATE_CACHED_OBJECT = 2024,
440 RS_HAL_ALLOCATION_ADAPTER_OFFSET = 2025,
Jason Samsf82b6262015-05-11 15:02:50 -0700441 RS_HAL_ALLOCATION_INIT_OEM = 2026,
Jason Sams8ce12812015-05-18 17:28:59 -0700442 RS_HAL_ALLOCATION_GET_POINTER = 2027,
Miao Wang47a58812015-07-23 21:59:16 -0700443#ifdef RS_COMPATIBILITY_LIB
444 RS_HAL_ALLOCATION_INIT_STRIDED = 2999,
445#endif
Jason Sams0ca7cba2015-03-11 15:22:38 -0700446
447 RS_HAL_SAMPLER_INIT = 3000,
448 RS_HAL_SAMPLER_DESTROY = 3001,
449 RS_HAL_SAMPLER_UPDATE_CACHED_OBJECT = 3002,
450
451 RS_HAL_TYPE_INIT = 4000,
452 RS_HAL_TYPE_DESTROY = 4001,
453 RS_HAL_TYPE_UPDATE_CACHED_OBJECT = 4002,
454
455 RS_HAL_ELEMENT_INIT = 5000,
456 RS_HAL_ELEMENT_DESTROY = 5001,
457 RS_HAL_ELEMENT_UPDATE_CACHED_OBJECT = 5002,
458
459 RS_HAL_SCRIPT_GROUP_INIT = 6000,
460 RS_HAL_SCRIPT_GROUP_DESTROY = 6001,
461 RS_HAL_SCRIPT_GROUP_UPDATE_CACHED_OBJECT = 6002,
462 RS_HAL_SCRIPT_GROUP_SET_INPUT = 6003,
463 RS_HAL_SCRIPT_GROUP_SET_OUTPUT = 6004,
464 RS_HAL_SCRIPT_GROUP_EXECUTE = 6005,
465
466
467
468 RS_HAL_GRAPHICS_INIT = 100001,
469 RS_HAL_GRAPHICS_SHUTDOWN = 100002,
470 RS_HAL_GRAPHICS_SWAP = 100003,
471 RS_HAL_GRAPHICS_SET_SURFACE = 100004,
472 RS_HAL_GRAPHICS_RASTER_INIT = 101000,
473 RS_HAL_GRAPHICS_RASTER_SET_ACTIVE = 101001,
474 RS_HAL_GRAPHICS_RASTER_DESTROY = 101002,
475 RS_HAL_GRAPHICS_VERTEX_INIT = 102000,
476 RS_HAL_GRAPHICS_VERTEX_SET_ACTIVE = 102001,
477 RS_HAL_GRAPHICS_VERTEX_DESTROY = 102002,
478 RS_HAL_GRAPHICS_FRAGMENT_INIT = 103000,
479 RS_HAL_GRAPHICS_FRAGMENT_SET_ACTIVE = 103001,
480 RS_HAL_GRAPHICS_FRAGMENT_DESTROY = 103002,
481 RS_HAL_GRAPHICS_MESH_INIT = 104000,
482 RS_HAL_GRAPHICS_MESH_DRAW = 104001,
483 RS_HAL_GRAPHICS_MESH_DESTROY = 104002,
484 RS_HAL_GRAPHICS_FB_INIT = 105000,
485 RS_HAL_GRAPHICS_FB_SET_ACTIVE = 105001,
486 RS_HAL_GRAPHICS_FB_DESTROY = 105002,
487 RS_HAL_GRAPHICS_STORE_INIT = 106000,
488 RS_HAL_GRAPHICS_STORE_SET_ACTIVE = 106001,
489 RS_HAL_GRAPHICS_STORE_DESTROY = 106002,
490};
491
Rahul Chaudhry7974fc02017-02-09 12:33:28 -0800492} // namespace renderscript
493} // namespace android
Jason Samsbad80742011-03-16 16:29:28 -0700494
Stephen Hines414a4612012-09-05 18:05:08 -0700495#ifdef __cplusplus
496extern "C" {
497#endif
Jason Samsbad80742011-03-16 16:29:28 -0700498
Jason Sams0ca7cba2015-03-11 15:22:38 -0700499/**
500 * Get the major version number of the driver. The major
David Gross8e707912016-06-06 16:15:00 -0700501 * version should be the RS_HAL_VERSION against which the
502 * driver was built
Jason Sams0ca7cba2015-03-11 15:22:38 -0700503 *
504 * The Minor version number is vendor specific
505 *
David Gross8e707912016-06-06 16:15:00 -0700506 * The caller should ensure that *version_major is the same as
507 * RS_HAL_VERSION -- i.e., that the driver (e.g., libRSDriver)
508 * is compatible with the shell (i.e., libRS_internal) responsible
509 * for loading the driver
510 *
Jason Sams0ca7cba2015-03-11 15:22:38 -0700511 * return: False will abort loading the driver, true indicates
512 * success
513 */
514bool rsdHalQueryVersion(uint32_t *version_major, uint32_t *version_minor);
515
516
517/**
518 * Get an entry point in the driver HAL
519 *
520 * The driver should set the function pointer to its
521 * implementation of the function. If it does not have an entry
522 * for an enum, its should set the function pointer to NULL
523 *
Jason Samsb9276ce2015-03-17 13:42:47 -0700524 * Returning NULL is expected in cases during development as new
525 * entry points are added that a driver may not understand. If
526 * the runtime receives a NULL it will decide if the function is
527 * required and will either continue loading or abort as needed.
528 *
529 *
Jason Sams0ca7cba2015-03-11 15:22:38 -0700530 * return: False will abort loading the driver, true indicates
531 * success
Jason Samsb9276ce2015-03-17 13:42:47 -0700532 *
Jason Sams0ca7cba2015-03-11 15:22:38 -0700533 */
534bool rsdHalQueryHal(android::renderscript::RsHalInitEnums entry, void **fnPtr);
535
536
537/**
538 * Called to initialize the context for use with a driver.
539 *
540 * return: False will abort loading the driver, true indicates
541 * success
542 */
Stephen Hines414a4612012-09-05 18:05:08 -0700543bool rsdHalInit(RsContext, uint32_t version_major, uint32_t version_minor);
544
Jason Sams0ca7cba2015-03-11 15:22:38 -0700545/**
546 * Called if one of the loading functions above returns false.
547 * This is to clean up any resources allocated during an error
548 * condition. If this path is called it means the normal
549 * context->mHal.funcs.shutdown() will not be called.
550 */
551void rsdHalAbort(RsContext);
552
Stephen Hines414a4612012-09-05 18:05:08 -0700553#ifdef __cplusplus
554}
555#endif
Jason Samsbad80742011-03-16 16:29:28 -0700556
557#endif