Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 1 | /* |
Stephen Hines | 2980f07 | 2012-04-09 18:26:29 -0700 | [diff] [blame] | 2 | * Copyright (C) 2011-2012 The Android Open Source Project |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 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 Sams | 66f0a16 | 2014-11-11 13:46:38 -0800 | [diff] [blame] | 20 | #include <rsInternalDefines.h> |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 21 | |
David Gross | 8e70791 | 2016-06-06 16:15:00 -0700 | [diff] [blame] | 22 | /* |
| 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 Wang | f750c53 | 2017-03-03 16:03:44 -0800 | [diff] [blame] | 39 | #define RS_HAL_VERSION 200 |
David Gross | 8e70791 | 2016-06-06 16:15:00 -0700 | [diff] [blame] | 40 | |
Jason Sams | 0ca7cba | 2015-03-11 15:22:38 -0700 | [diff] [blame] | 41 | /** |
| 42 | * The interface for loading RenderScript drivers |
| 43 | * |
| 44 | * The startup sequence is |
| 45 | * |
| 46 | * 1: dlopen driver |
David Gross | 8e70791 | 2016-06-06 16:15:00 -0700 | [diff] [blame] | 47 | * 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 Sams | 0ca7cba | 2015-03-11 15:22:38 -0700 | [diff] [blame] | 50 | * 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 Sams | b9276ce | 2015-03-17 13:42:47 -0700 | [diff] [blame] | 58 | * A driver should return FALSE for any conditions that will |
| 59 | * prevent the driver from working normally. |
| 60 | * |
| 61 | * |
Jason Sams | 0ca7cba | 2015-03-11 15:22:38 -0700 | [diff] [blame] | 62 | * 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 Sams | 7ac2a4d | 2012-02-15 12:04:24 -0800 | [diff] [blame] | 71 | struct ANativeWindow; |
| 72 | |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 73 | namespace android { |
| 74 | namespace renderscript { |
| 75 | |
| 76 | class Context; |
| 77 | class ObjectBase; |
| 78 | class Element; |
| 79 | class Type; |
| 80 | class Allocation; |
| 81 | class Script; |
Jason Sams | dbe66d6 | 2012-09-17 13:54:41 -0700 | [diff] [blame] | 82 | class ScriptKernelID; |
| 83 | class ScriptFieldID; |
| 84 | class ScriptMethodID; |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 85 | class ScriptC; |
Jason Sams | dbe66d6 | 2012-09-17 13:54:41 -0700 | [diff] [blame] | 86 | class ScriptGroup; |
Yang Ni | 1ffd86b | 2015-01-07 09:16:40 -0800 | [diff] [blame] | 87 | class ScriptGroupBase; |
Jason Sams | 9e0afb5 | 2011-10-31 13:23:43 -0700 | [diff] [blame] | 88 | class Path; |
Alex Sakhartchouk | 7f126c7 | 2011-05-05 16:56:27 -0700 | [diff] [blame] | 89 | class Program; |
Jason Sams | 8feea4e | 2011-03-18 15:03:25 -0700 | [diff] [blame] | 90 | class ProgramStore; |
Jason Sams | 721acc4 | 2011-04-06 11:23:54 -0700 | [diff] [blame] | 91 | class ProgramRaster; |
Alex Sakhartchouk | a04e30d | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 92 | class ProgramVertex; |
| 93 | class ProgramFragment; |
| 94 | class Mesh; |
Alex Sakhartchouk | 7f126c7 | 2011-05-05 16:56:27 -0700 | [diff] [blame] | 95 | class Sampler; |
Alex Sakhartchouk | da6d34a | 2011-05-13 14:53:34 -0700 | [diff] [blame] | 96 | class FBOCache; |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 97 | |
Jason Sams | a36c50a | 2014-06-17 12:06:06 -0700 | [diff] [blame] | 98 | /** |
| 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) Sung | 700e688 | 2017-03-06 14:42:53 -0800 | [diff] [blame] | 104 | * unused1, unused2, unused3 = reserved for ABI compatibility |
Jason Sams | a36c50a | 2014-06-17 12:06:06 -0700 | [diff] [blame] | 105 | */ |
| 106 | |
Jean-Luc Brouillet | 8632372 | 2017-01-19 22:11:40 -0800 | [diff] [blame] | 107 | // 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 Sams | a36c50a | 2014-06-17 12:06:06 -0700 | [diff] [blame] | 110 | #ifndef __LP64__ |
| 111 | #define RS_BASE_OBJ(_t_) typedef struct { const _t_* p; } __attribute__((packed, aligned(4))) |
Jean-Luc Brouillet | 8632372 | 2017-01-19 22:11:40 -0800 | [diff] [blame] | 112 | #define RS_BASE_NULL_OBJ {0} |
Jason Sams | a36c50a | 2014-06-17 12:06:06 -0700 | [diff] [blame] | 113 | #else |
I-Jui (Ray) Sung | 700e688 | 2017-03-06 14:42:53 -0800 | [diff] [blame] | 114 | #define RS_BASE_OBJ(_t_) typedef struct { const _t_* p; const void* unused1; const void* unused2; const void* unused3; } |
Jean-Luc Brouillet | 8632372 | 2017-01-19 22:11:40 -0800 | [diff] [blame] | 115 | #define RS_BASE_NULL_OBJ {0, 0, 0, 0} |
Jason Sams | a36c50a | 2014-06-17 12:06:06 -0700 | [diff] [blame] | 116 | #endif |
| 117 | |
Jason Sams | 05ef73f | 2014-08-05 14:59:22 -0700 | [diff] [blame] | 118 | RS_BASE_OBJ(ObjectBase) rs_object_base; |
Jason Sams | a36c50a | 2014-06-17 12:06:06 -0700 | [diff] [blame] | 119 | RS_BASE_OBJ(Element) rs_element; |
| 120 | RS_BASE_OBJ(Type) rs_type; |
| 121 | RS_BASE_OBJ(Allocation) rs_allocation; |
| 122 | RS_BASE_OBJ(Sampler) rs_sampler; |
| 123 | RS_BASE_OBJ(Script) rs_script; |
| 124 | RS_BASE_OBJ(ScriptGroup) rs_script_group; |
| 125 | |
| 126 | #ifndef __LP64__ |
| 127 | typedef struct { const int* p; } __attribute__((packed, aligned(4))) rs_mesh; |
Jason Sams | a36c50a | 2014-06-17 12:06:06 -0700 | [diff] [blame] | 128 | typedef struct { const int* p; } __attribute__((packed, aligned(4))) rs_program_fragment; |
| 129 | typedef struct { const int* p; } __attribute__((packed, aligned(4))) rs_program_vertex; |
| 130 | typedef struct { const int* p; } __attribute__((packed, aligned(4))) rs_program_raster; |
| 131 | typedef struct { const int* p; } __attribute__((packed, aligned(4))) rs_program_store; |
| 132 | typedef struct { const int* p; } __attribute__((packed, aligned(4))) rs_font; |
| 133 | #endif // __LP64__ |
| 134 | |
| 135 | |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 136 | typedef void *(*RsHalSymbolLookupFunc)(void *usrptr, char const *symbolName); |
| 137 | |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 138 | /** |
| 139 | * Script management functions |
| 140 | */ |
| 141 | typedef struct { |
Miao Wang | 025a1f4 | 2017-04-06 19:24:44 -0700 | [diff] [blame] | 142 | int (*initGraphics)(const Context *); |
Jason Sams | 4b3de47 | 2011-04-06 17:52:23 -0700 | [diff] [blame] | 143 | void (*shutdownGraphics)(const Context *); |
Alex Sakhartchouk | 7257c7e | 2011-05-17 12:32:47 -0700 | [diff] [blame] | 144 | bool (*setSurface)(const Context *, uint32_t w, uint32_t h, RsNativeWindow); |
Jason Sams | 4b3de47 | 2011-04-06 17:52:23 -0700 | [diff] [blame] | 145 | void (*swap)(const Context *); |
| 146 | |
Jason Sams | cdfdb8f | 2011-03-17 16:12:47 -0700 | [diff] [blame] | 147 | void (*shutdownDriver)(Context *); |
Jason Sams | cdfdb8f | 2011-03-17 16:12:47 -0700 | [diff] [blame] | 148 | void (*setPriority)(const Context *, int32_t priority); |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 149 | |
Tim Murray | 3468938 | 2013-03-11 12:12:03 -0700 | [diff] [blame] | 150 | void* (*allocRuntimeMem)(size_t size, uint32_t flags); |
| 151 | void (*freeRuntimeMem)(void* ptr); |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 152 | |
| 153 | struct { |
Jason Sams | 8feea4e | 2011-03-18 15:03:25 -0700 | [diff] [blame] | 154 | 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 Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 159 | uint32_t flags); |
Jason Sams | 8eaba4f | 2012-08-14 14:38:05 -0700 | [diff] [blame] | 160 | bool (*initIntrinsic)(const Context *rsc, Script *s, |
Stephen Hines | 41d6c76 | 2012-08-21 17:07:38 -0700 | [diff] [blame] | 161 | RsScriptIntrinsicID iid, |
Jason Sams | 8eaba4f | 2012-08-14 14:38:05 -0700 | [diff] [blame] | 162 | Element *e); |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 163 | |
Jason Sams | cdfdb8f | 2011-03-17 16:12:47 -0700 | [diff] [blame] | 164 | void (*invokeFunction)(const Context *rsc, Script *s, |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 165 | uint32_t slot, |
| 166 | const void *params, |
| 167 | size_t paramLength); |
Jason Sams | cdfdb8f | 2011-03-17 16:12:47 -0700 | [diff] [blame] | 168 | int (*invokeRoot)(const Context *rsc, Script *s); |
| 169 | void (*invokeForEach)(const Context *rsc, |
| 170 | Script *s, |
Jason Sams | 35e429e | 2011-07-13 11:26:26 -0700 | [diff] [blame] | 171 | uint32_t slot, |
Jason Sams | cdfdb8f | 2011-03-17 16:12:47 -0700 | [diff] [blame] | 172 | const Allocation * ain, |
| 173 | Allocation * aout, |
| 174 | const void * usr, |
Tim Murray | 099bc26 | 2013-03-20 16:54:03 -0700 | [diff] [blame] | 175 | size_t usrLen, |
Jason Sams | cdfdb8f | 2011-03-17 16:12:47 -0700 | [diff] [blame] | 176 | const RsScriptCall *sc); |
Matt Wala | 14ce007 | 2015-07-30 17:30:25 -0700 | [diff] [blame] | 177 | void (*invokeReduce)(const Context *rsc, Script *s, |
David Gross | ae2ec3f | 2016-06-01 14:45:47 -0700 | [diff] [blame] | 178 | uint32_t slot, |
| 179 | const Allocation ** ains, size_t inLen, |
Matt Wala | 14ce007 | 2015-07-30 17:30:25 -0700 | [diff] [blame] | 180 | Allocation *aout, |
| 181 | const RsScriptCall *sc); |
Jason Sams | cdfdb8f | 2011-03-17 16:12:47 -0700 | [diff] [blame] | 182 | void (*invokeInit)(const Context *rsc, Script *s); |
Stephen Hines | 4ee16ff | 2011-08-31 17:41:39 -0700 | [diff] [blame] | 183 | void (*invokeFreeChildren)(const Context *rsc, Script *s); |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 184 | |
| 185 | void (*setGlobalVar)(const Context *rsc, const Script *s, |
| 186 | uint32_t slot, |
| 187 | void *data, |
| 188 | size_t dataLength); |
Tim Murray | 9c64239 | 2013-04-11 13:29:59 -0700 | [diff] [blame] | 189 | void (*getGlobalVar)(const Context *rsc, const Script *s, |
| 190 | uint32_t slot, |
| 191 | void *data, |
| 192 | size_t dataLength); |
Stephen Hines | 2980f07 | 2012-04-09 18:26:29 -0700 | [diff] [blame] | 193 | void (*setGlobalVarWithElemDims)(const Context *rsc, const Script *s, |
| 194 | uint32_t slot, |
| 195 | void *data, |
| 196 | size_t dataLength, |
| 197 | const Element *e, |
Stephen Hines | ac8d146 | 2014-06-25 00:01:23 -0700 | [diff] [blame] | 198 | const uint32_t *dims, |
Stephen Hines | 2980f07 | 2012-04-09 18:26:29 -0700 | [diff] [blame] | 199 | size_t dimLength); |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 200 | void (*setGlobalBind)(const Context *rsc, const Script *s, |
| 201 | uint32_t slot, |
Jason Sams | 807fdc4 | 2012-07-25 17:55:39 -0700 | [diff] [blame] | 202 | Allocation *data); |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 203 | 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 Wailes | 4b3c34e | 2014-06-11 12:00:29 -0700 | [diff] [blame] | 208 | 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 Sams | a36c50a | 2014-06-17 12:06:06 -0700 | [diff] [blame] | 217 | void (*updateCachedObject)(const Context *rsc, const Script *, rs_script *obj); |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 218 | } script; |
| 219 | |
Jason Sams | 8feea4e | 2011-03-18 15:03:25 -0700 | [diff] [blame] | 220 | struct { |
Jason Sams | eb4fe18 | 2011-05-26 16:33:01 -0700 | [diff] [blame] | 221 | bool (*init)(const Context *rsc, Allocation *alloc, bool forceZero); |
Jason Sams | f82b626 | 2015-05-11 15:02:50 -0700 | [diff] [blame] | 222 | bool (*initOem)(const Context *rsc, Allocation *alloc, bool forceZero, void *usrPtr); |
Jason Sams | bc9dc27 | 2015-02-09 12:50:22 -0800 | [diff] [blame] | 223 | bool (*initAdapter)(const Context *rsc, Allocation *alloc); |
Jason Sams | eb4fe18 | 2011-05-26 16:33:01 -0700 | [diff] [blame] | 224 | void (*destroy)(const Context *rsc, Allocation *alloc); |
Jason Sams | ddceab9 | 2013-08-07 13:02:32 -0700 | [diff] [blame] | 225 | uint32_t (*grallocBits)(const Context *rsc, Allocation *alloc); |
Jason Sams | eb4fe18 | 2011-05-26 16:33:01 -0700 | [diff] [blame] | 226 | |
| 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 Sams | 7ac2a4d | 2012-02-15 12:04:24 -0800 | [diff] [blame] | 231 | |
Jason Sams | 733396b | 2013-02-22 12:46:18 -0800 | [diff] [blame] | 232 | void (*setSurface)(const Context *rsc, Allocation *alloc, ANativeWindow *sur); |
Jason Sams | 7ac2a4d | 2012-02-15 12:04:24 -0800 | [diff] [blame] | 233 | void (*ioSend)(const Context *rsc, Allocation *alloc); |
Jason Sams | ddceab9 | 2013-08-07 13:02:32 -0700 | [diff] [blame] | 234 | |
| 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 Sams | 7ac2a4d | 2012-02-15 12:04:24 -0800 | [diff] [blame] | 242 | void (*ioReceive)(const Context *rsc, Allocation *alloc); |
Jason Sams | eb4fe18 | 2011-05-26 16:33:01 -0700 | [diff] [blame] | 243 | |
| 244 | void (*data1D)(const Context *rsc, const Allocation *alloc, |
Tim Murray | 099bc26 | 2013-03-20 16:54:03 -0700 | [diff] [blame] | 245 | uint32_t xoff, uint32_t lod, size_t count, |
Alex Sakhartchouk | c794cd5 | 2012-02-13 11:57:32 -0800 | [diff] [blame] | 246 | const void *data, size_t sizeBytes); |
Jason Sams | eb4fe18 | 2011-05-26 16:33:01 -0700 | [diff] [blame] | 247 | 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 Murray | 358747a | 2012-11-26 13:52:04 -0800 | [diff] [blame] | 250 | const void *data, size_t sizeBytes, size_t stride); |
Jason Sams | eb4fe18 | 2011-05-26 16:33:01 -0700 | [diff] [blame] | 251 | void (*data3D)(const Context *rsc, const Allocation *alloc, |
Jason Sams | 3bbc0fd | 2013-04-09 14:16:13 -0700 | [diff] [blame] | 252 | 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 Sams | eb4fe18 | 2011-05-26 16:33:01 -0700 | [diff] [blame] | 255 | |
Jason Sams | 807fdc4 | 2012-07-25 17:55:39 -0700 | [diff] [blame] | 256 | void (*read1D)(const Context *rsc, const Allocation *alloc, |
Tim Murray | 099bc26 | 2013-03-20 16:54:03 -0700 | [diff] [blame] | 257 | uint32_t xoff, uint32_t lod, size_t count, |
Jason Sams | 807fdc4 | 2012-07-25 17:55:39 -0700 | [diff] [blame] | 258 | 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 Murray | 358747a | 2012-11-26 13:52:04 -0800 | [diff] [blame] | 262 | void *data, size_t sizeBytes, size_t stride); |
Jason Sams | 807fdc4 | 2012-07-25 17:55:39 -0700 | [diff] [blame] | 263 | void (*read3D)(const Context *rsc, const Allocation *alloc, |
Jason Sams | 3bbc0fd | 2013-04-09 14:16:13 -0700 | [diff] [blame] | 264 | 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 Sams | 807fdc4 | 2012-07-25 17:55:39 -0700 | [diff] [blame] | 267 | |
| 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 Sakhartchouk | 74a8279 | 2011-06-14 11:13:19 -0700 | [diff] [blame] | 274 | // Allocation to allocation copies |
| 275 | void (*allocData1D)(const Context *rsc, |
| 276 | const Allocation *dstAlloc, |
Tim Murray | 099bc26 | 2013-03-20 16:54:03 -0700 | [diff] [blame] | 277 | uint32_t dstXoff, uint32_t dstLod, size_t count, |
Alex Sakhartchouk | 74a8279 | 2011-06-14 11:13:19 -0700 | [diff] [blame] | 278 | 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 Sams | 3bbc0fd | 2013-04-09 14:16:13 -0700 | [diff] [blame] | 289 | uint32_t dstLod, |
Alex Sakhartchouk | 74a8279 | 2011-06-14 11:13:19 -0700 | [diff] [blame] | 290 | uint32_t w, uint32_t h, uint32_t d, |
| 291 | const Allocation *srcAlloc, |
| 292 | uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff, |
Jason Sams | 3bbc0fd | 2013-04-09 14:16:13 -0700 | [diff] [blame] | 293 | uint32_t srcLod); |
Alex Sakhartchouk | 74a8279 | 2011-06-14 11:13:19 -0700 | [diff] [blame] | 294 | |
Miao Wang | cc8cea7 | 2015-02-19 18:14:46 -0800 | [diff] [blame] | 295 | 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 Sams | eb4fe18 | 2011-05-26 16:33:01 -0700 | [diff] [blame] | 301 | |
Jason Sams | 61a4bb7 | 2012-07-25 19:33:43 -0700 | [diff] [blame] | 302 | void (*generateMipmaps)(const Context *rsc, const Allocation *alloc); |
Jason Sams | a36c50a | 2014-06-17 12:06:06 -0700 | [diff] [blame] | 303 | |
| 304 | void (*updateCachedObject)(const Context *rsc, const Allocation *alloc, rs_allocation *obj); |
Jason Sams | bc9dc27 | 2015-02-09 12:50:22 -0800 | [diff] [blame] | 305 | |
| 306 | void (*adapterOffset)(const Context *rsc, const Allocation *alloc); |
Jason Sams | 8ce1281 | 2015-05-18 17:28:59 -0700 | [diff] [blame] | 307 | |
| 308 | void (*getPointer)(const Context *rsc, const Allocation *alloc, |
| 309 | uint32_t lod, RsAllocationCubemapFace face, |
| 310 | uint32_t z, uint32_t array); |
Miao Wang | 47a5881 | 2015-07-23 21:59:16 -0700 | [diff] [blame] | 311 | #ifdef RS_COMPATIBILITY_LIB |
| 312 | bool (*initStrided)(const Context *rsc, Allocation *alloc, bool forceZero, size_t requiredAlignment); |
| 313 | #endif |
Jason Sams | eb4fe18 | 2011-05-26 16:33:01 -0700 | [diff] [blame] | 314 | } allocation; |
| 315 | |
| 316 | struct { |
Jason Sams | 8feea4e | 2011-03-18 15:03:25 -0700 | [diff] [blame] | 317 | 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 Sams | 721acc4 | 2011-04-06 11:23:54 -0700 | [diff] [blame] | 322 | 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 Sams | 8feea4e | 2011-03-18 15:03:25 -0700 | [diff] [blame] | 327 | |
Alex Sakhartchouk | a04e30d | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 328 | struct { |
| 329 | bool (*init)(const Context *rsc, const ProgramVertex *pv, |
Alex Sakhartchouk | 748eb07 | 2012-02-15 16:21:46 -0800 | [diff] [blame] | 330 | const char* shader, size_t shaderLen, |
| 331 | const char** textureNames, size_t textureNamesCount, |
| 332 | const size_t *textureNamesLength); |
Alex Sakhartchouk | a04e30d | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 333 | 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 Sakhartchouk | 748eb07 | 2012-02-15 16:21:46 -0800 | [diff] [blame] | 339 | const char* shader, size_t shaderLen, |
| 340 | const char** textureNames, size_t textureNamesCount, |
| 341 | const size_t *textureNamesLength); |
Alex Sakhartchouk | a04e30d | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 342 | 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 Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 351 | |
Alex Sakhartchouk | 7f126c7 | 2011-05-05 16:56:27 -0700 | [diff] [blame] | 352 | struct { |
| 353 | bool (*init)(const Context *rsc, const Sampler *m); |
| 354 | void (*destroy)(const Context *rsc, const Sampler *m); |
Jason Sams | a36c50a | 2014-06-17 12:06:06 -0700 | [diff] [blame] | 355 | void (*updateCachedObject)(const Context *rsc, const Sampler *s, rs_sampler *obj); |
Alex Sakhartchouk | 7f126c7 | 2011-05-05 16:56:27 -0700 | [diff] [blame] | 356 | } sampler; |
| 357 | |
Alex Sakhartchouk | da6d34a | 2011-05-13 14:53:34 -0700 | [diff] [blame] | 358 | 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 Sams | dbe66d6 | 2012-09-17 13:54:41 -0700 | [diff] [blame] | 364 | struct { |
Yang Ni | 1ffd86b | 2015-01-07 09:16:40 -0800 | [diff] [blame] | 365 | bool (*init)(const Context *rsc, ScriptGroupBase *sg); |
Jason Sams | dbe66d6 | 2012-09-17 13:54:41 -0700 | [diff] [blame] | 366 | 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 Ni | 1ffd86b | 2015-01-07 09:16:40 -0800 | [diff] [blame] | 370 | void (*execute)(const Context *rsc, const ScriptGroupBase *sg); |
| 371 | void (*destroy)(const Context *rsc, const ScriptGroupBase *sg); |
Jason Sams | a36c50a | 2014-06-17 12:06:06 -0700 | [diff] [blame] | 372 | void (*updateCachedObject)(const Context *rsc, const ScriptGroup *sg, rs_script_group *obj); |
Jason Sams | dbe66d6 | 2012-09-17 13:54:41 -0700 | [diff] [blame] | 373 | } scriptgroup; |
| 374 | |
Jason Sams | a36c50a | 2014-06-17 12:06:06 -0700 | [diff] [blame] | 375 | 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 Sams | 9761c3f | 2013-11-26 18:10:59 -0800 | [diff] [blame] | 387 | void (*finish)(const Context *rsc); |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 388 | } RsdHalFunctions; |
| 389 | |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 390 | |
Jason Sams | 0ca7cba | 2015-03-11 15:22:38 -0700 | [diff] [blame] | 391 | enum 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 Wala | 14ce007 | 2015-07-30 17:30:25 -0700 | [diff] [blame] | 413 | RS_HAL_SCRIPT_INVOKE_REDUCE = 1015, |
Jason Sams | 0ca7cba | 2015-03-11 15:22:38 -0700 | [diff] [blame] | 414 | |
| 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 Sams | f82b626 | 2015-05-11 15:02:50 -0700 | [diff] [blame] | 441 | RS_HAL_ALLOCATION_INIT_OEM = 2026, |
Jason Sams | 8ce1281 | 2015-05-18 17:28:59 -0700 | [diff] [blame] | 442 | RS_HAL_ALLOCATION_GET_POINTER = 2027, |
Miao Wang | 47a5881 | 2015-07-23 21:59:16 -0700 | [diff] [blame] | 443 | #ifdef RS_COMPATIBILITY_LIB |
| 444 | RS_HAL_ALLOCATION_INIT_STRIDED = 2999, |
| 445 | #endif |
Jason Sams | 0ca7cba | 2015-03-11 15:22:38 -0700 | [diff] [blame] | 446 | |
| 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 Chaudhry | 7974fc0 | 2017-02-09 12:33:28 -0800 | [diff] [blame] | 492 | } // namespace renderscript |
| 493 | } // namespace android |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 494 | |
Stephen Hines | 414a461 | 2012-09-05 18:05:08 -0700 | [diff] [blame] | 495 | #ifdef __cplusplus |
| 496 | extern "C" { |
| 497 | #endif |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 498 | |
Jason Sams | 0ca7cba | 2015-03-11 15:22:38 -0700 | [diff] [blame] | 499 | /** |
| 500 | * Get the major version number of the driver. The major |
David Gross | 8e70791 | 2016-06-06 16:15:00 -0700 | [diff] [blame] | 501 | * version should be the RS_HAL_VERSION against which the |
| 502 | * driver was built |
Jason Sams | 0ca7cba | 2015-03-11 15:22:38 -0700 | [diff] [blame] | 503 | * |
| 504 | * The Minor version number is vendor specific |
| 505 | * |
David Gross | 8e70791 | 2016-06-06 16:15:00 -0700 | [diff] [blame] | 506 | * 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 Sams | 0ca7cba | 2015-03-11 15:22:38 -0700 | [diff] [blame] | 511 | * return: False will abort loading the driver, true indicates |
| 512 | * success |
| 513 | */ |
| 514 | bool 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 Sams | b9276ce | 2015-03-17 13:42:47 -0700 | [diff] [blame] | 524 | * 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 Sams | 0ca7cba | 2015-03-11 15:22:38 -0700 | [diff] [blame] | 530 | * return: False will abort loading the driver, true indicates |
| 531 | * success |
Jason Sams | b9276ce | 2015-03-17 13:42:47 -0700 | [diff] [blame] | 532 | * |
Jason Sams | 0ca7cba | 2015-03-11 15:22:38 -0700 | [diff] [blame] | 533 | */ |
| 534 | bool 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 Hines | 414a461 | 2012-09-05 18:05:08 -0700 | [diff] [blame] | 543 | bool rsdHalInit(RsContext, uint32_t version_major, uint32_t version_minor); |
| 544 | |
Jason Sams | 0ca7cba | 2015-03-11 15:22:38 -0700 | [diff] [blame] | 545 | /** |
| 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 | */ |
| 551 | void rsdHalAbort(RsContext); |
| 552 | |
Stephen Hines | 414a461 | 2012-09-05 18:05:08 -0700 | [diff] [blame] | 553 | #ifdef __cplusplus |
| 554 | } |
| 555 | #endif |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 556 | |
| 557 | #endif |