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 | |
Jason Sams | 0ca7cba | 2015-03-11 15:22:38 -0700 | [diff] [blame] | 22 | /** |
| 23 | * The interface for loading RenderScript drivers |
| 24 | * |
| 25 | * The startup sequence is |
| 26 | * |
| 27 | * 1: dlopen driver |
| 28 | * 2: Query driver version with rsdHalQueryVersion() |
| 29 | * 3: Fill in HAL pointer table with calls to rsdHalQueryHAL() |
| 30 | * 4: Initialize the context with rsdHalInit() |
| 31 | * |
| 32 | * If any of these functions return false, the loading of the |
| 33 | * driver will abort and the reference driver will be used. |
| 34 | * rsdHalAbort() will be called to clean up any partially |
| 35 | * allocated state. |
| 36 | * |
Jason Sams | b9276ce | 2015-03-17 13:42:47 -0700 | [diff] [blame] | 37 | * A driver should return FALSE for any conditions that will |
| 38 | * prevent the driver from working normally. |
| 39 | * |
| 40 | * |
Jason Sams | 0ca7cba | 2015-03-11 15:22:38 -0700 | [diff] [blame] | 41 | * If these are successful, the driver will be loaded and used |
| 42 | * normally. Teardown will use the normal |
| 43 | * context->mHal.funcs.shutdown() path. There will be no call |
| 44 | * to rsdHalAbort(). |
| 45 | * |
| 46 | * |
| 47 | */ |
| 48 | |
| 49 | |
Jason Sams | 7ac2a4d | 2012-02-15 12:04:24 -0800 | [diff] [blame] | 50 | struct ANativeWindow; |
| 51 | |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 52 | namespace android { |
| 53 | namespace renderscript { |
| 54 | |
| 55 | class Context; |
| 56 | class ObjectBase; |
| 57 | class Element; |
| 58 | class Type; |
| 59 | class Allocation; |
| 60 | class Script; |
Jason Sams | dbe66d6 | 2012-09-17 13:54:41 -0700 | [diff] [blame] | 61 | class ScriptKernelID; |
| 62 | class ScriptFieldID; |
| 63 | class ScriptMethodID; |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 64 | class ScriptC; |
Jason Sams | dbe66d6 | 2012-09-17 13:54:41 -0700 | [diff] [blame] | 65 | class ScriptGroup; |
Yang Ni | 1ffd86b | 2015-01-07 09:16:40 -0800 | [diff] [blame] | 66 | class ScriptGroupBase; |
Jason Sams | 9e0afb5 | 2011-10-31 13:23:43 -0700 | [diff] [blame] | 67 | class Path; |
Alex Sakhartchouk | 7f126c7 | 2011-05-05 16:56:27 -0700 | [diff] [blame] | 68 | class Program; |
Jason Sams | 8feea4e | 2011-03-18 15:03:25 -0700 | [diff] [blame] | 69 | class ProgramStore; |
Jason Sams | 721acc4 | 2011-04-06 11:23:54 -0700 | [diff] [blame] | 70 | class ProgramRaster; |
Alex Sakhartchouk | a04e30d | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 71 | class ProgramVertex; |
| 72 | class ProgramFragment; |
| 73 | class Mesh; |
Alex Sakhartchouk | 7f126c7 | 2011-05-05 16:56:27 -0700 | [diff] [blame] | 74 | class Sampler; |
Alex Sakhartchouk | da6d34a | 2011-05-13 14:53:34 -0700 | [diff] [blame] | 75 | class FBOCache; |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 76 | |
Jason Sams | a36c50a | 2014-06-17 12:06:06 -0700 | [diff] [blame] | 77 | /** |
| 78 | * Define the internal object types. This ia a mirror of the |
| 79 | * definition in rs_types.rsh except with the p value typed |
| 80 | * correctly. |
| 81 | * |
| 82 | * p = pointer to internal object implementation |
| 83 | * r = reserved by libRS runtime |
| 84 | * v1 = Mirror of p->mHal.drv |
| 85 | * v2 = reserved for use by vendor drivers |
| 86 | */ |
| 87 | |
| 88 | #ifndef __LP64__ |
| 89 | #define RS_BASE_OBJ(_t_) typedef struct { const _t_* p; } __attribute__((packed, aligned(4))) |
| 90 | #else |
| 91 | #define RS_BASE_OBJ(_t_) typedef struct { const _t_* p; const void* r; const void* v1; const void* v2; } |
| 92 | #endif |
| 93 | |
Jason Sams | 05ef73f | 2014-08-05 14:59:22 -0700 | [diff] [blame] | 94 | RS_BASE_OBJ(ObjectBase) rs_object_base; |
Jason Sams | a36c50a | 2014-06-17 12:06:06 -0700 | [diff] [blame] | 95 | RS_BASE_OBJ(Element) rs_element; |
| 96 | RS_BASE_OBJ(Type) rs_type; |
| 97 | RS_BASE_OBJ(Allocation) rs_allocation; |
| 98 | RS_BASE_OBJ(Sampler) rs_sampler; |
| 99 | RS_BASE_OBJ(Script) rs_script; |
| 100 | RS_BASE_OBJ(ScriptGroup) rs_script_group; |
| 101 | |
| 102 | #ifndef __LP64__ |
| 103 | typedef struct { const int* p; } __attribute__((packed, aligned(4))) rs_mesh; |
Jason Sams | a36c50a | 2014-06-17 12:06:06 -0700 | [diff] [blame] | 104 | typedef struct { const int* p; } __attribute__((packed, aligned(4))) rs_program_fragment; |
| 105 | typedef struct { const int* p; } __attribute__((packed, aligned(4))) rs_program_vertex; |
| 106 | typedef struct { const int* p; } __attribute__((packed, aligned(4))) rs_program_raster; |
| 107 | typedef struct { const int* p; } __attribute__((packed, aligned(4))) rs_program_store; |
| 108 | typedef struct { const int* p; } __attribute__((packed, aligned(4))) rs_font; |
| 109 | #endif // __LP64__ |
| 110 | |
| 111 | |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 112 | typedef void *(*RsHalSymbolLookupFunc)(void *usrptr, char const *symbolName); |
| 113 | |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 114 | /** |
| 115 | * Script management functions |
| 116 | */ |
| 117 | typedef struct { |
Jason Sams | 4b3de47 | 2011-04-06 17:52:23 -0700 | [diff] [blame] | 118 | bool (*initGraphics)(const Context *); |
| 119 | void (*shutdownGraphics)(const Context *); |
Alex Sakhartchouk | 7257c7e | 2011-05-17 12:32:47 -0700 | [diff] [blame] | 120 | bool (*setSurface)(const Context *, uint32_t w, uint32_t h, RsNativeWindow); |
Jason Sams | 4b3de47 | 2011-04-06 17:52:23 -0700 | [diff] [blame] | 121 | void (*swap)(const Context *); |
| 122 | |
Jason Sams | cdfdb8f | 2011-03-17 16:12:47 -0700 | [diff] [blame] | 123 | void (*shutdownDriver)(Context *); |
Jason Sams | cdfdb8f | 2011-03-17 16:12:47 -0700 | [diff] [blame] | 124 | void (*setPriority)(const Context *, int32_t priority); |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 125 | |
Tim Murray | 3468938 | 2013-03-11 12:12:03 -0700 | [diff] [blame] | 126 | void* (*allocRuntimeMem)(size_t size, uint32_t flags); |
| 127 | void (*freeRuntimeMem)(void* ptr); |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 128 | |
| 129 | struct { |
Jason Sams | 8feea4e | 2011-03-18 15:03:25 -0700 | [diff] [blame] | 130 | bool (*init)(const Context *rsc, ScriptC *s, |
| 131 | char const *resName, |
| 132 | char const *cacheDir, |
| 133 | uint8_t const *bitcode, |
| 134 | size_t bitcodeSize, |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 135 | uint32_t flags); |
Jason Sams | 8eaba4f | 2012-08-14 14:38:05 -0700 | [diff] [blame] | 136 | bool (*initIntrinsic)(const Context *rsc, Script *s, |
Stephen Hines | 41d6c76 | 2012-08-21 17:07:38 -0700 | [diff] [blame] | 137 | RsScriptIntrinsicID iid, |
Jason Sams | 8eaba4f | 2012-08-14 14:38:05 -0700 | [diff] [blame] | 138 | Element *e); |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 139 | |
Jason Sams | cdfdb8f | 2011-03-17 16:12:47 -0700 | [diff] [blame] | 140 | void (*invokeFunction)(const Context *rsc, Script *s, |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 141 | uint32_t slot, |
| 142 | const void *params, |
| 143 | size_t paramLength); |
Jason Sams | cdfdb8f | 2011-03-17 16:12:47 -0700 | [diff] [blame] | 144 | int (*invokeRoot)(const Context *rsc, Script *s); |
| 145 | void (*invokeForEach)(const Context *rsc, |
| 146 | Script *s, |
Jason Sams | 35e429e | 2011-07-13 11:26:26 -0700 | [diff] [blame] | 147 | uint32_t slot, |
Jason Sams | cdfdb8f | 2011-03-17 16:12:47 -0700 | [diff] [blame] | 148 | const Allocation * ain, |
| 149 | Allocation * aout, |
| 150 | const void * usr, |
Tim Murray | 099bc26 | 2013-03-20 16:54:03 -0700 | [diff] [blame] | 151 | size_t usrLen, |
Jason Sams | cdfdb8f | 2011-03-17 16:12:47 -0700 | [diff] [blame] | 152 | const RsScriptCall *sc); |
| 153 | void (*invokeInit)(const Context *rsc, Script *s); |
Stephen Hines | 4ee16ff | 2011-08-31 17:41:39 -0700 | [diff] [blame] | 154 | void (*invokeFreeChildren)(const Context *rsc, Script *s); |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 155 | |
| 156 | void (*setGlobalVar)(const Context *rsc, const Script *s, |
| 157 | uint32_t slot, |
| 158 | void *data, |
| 159 | size_t dataLength); |
Tim Murray | 9c64239 | 2013-04-11 13:29:59 -0700 | [diff] [blame] | 160 | void (*getGlobalVar)(const Context *rsc, const Script *s, |
| 161 | uint32_t slot, |
| 162 | void *data, |
| 163 | size_t dataLength); |
Stephen Hines | 2980f07 | 2012-04-09 18:26:29 -0700 | [diff] [blame] | 164 | void (*setGlobalVarWithElemDims)(const Context *rsc, const Script *s, |
| 165 | uint32_t slot, |
| 166 | void *data, |
| 167 | size_t dataLength, |
| 168 | const Element *e, |
Stephen Hines | ac8d146 | 2014-06-25 00:01:23 -0700 | [diff] [blame] | 169 | const uint32_t *dims, |
Stephen Hines | 2980f07 | 2012-04-09 18:26:29 -0700 | [diff] [blame] | 170 | size_t dimLength); |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 171 | void (*setGlobalBind)(const Context *rsc, const Script *s, |
| 172 | uint32_t slot, |
Jason Sams | 807fdc4 | 2012-07-25 17:55:39 -0700 | [diff] [blame] | 173 | Allocation *data); |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 174 | void (*setGlobalObj)(const Context *rsc, const Script *s, |
| 175 | uint32_t slot, |
| 176 | ObjectBase *data); |
| 177 | |
| 178 | void (*destroy)(const Context *rsc, Script *s); |
Chris Wailes | 4b3c34e | 2014-06-11 12:00:29 -0700 | [diff] [blame] | 179 | void (*invokeForEachMulti)(const Context *rsc, |
| 180 | Script *s, |
| 181 | uint32_t slot, |
| 182 | const Allocation ** ains, |
| 183 | size_t inLen, |
| 184 | Allocation * aout, |
| 185 | const void * usr, |
| 186 | size_t usrLen, |
| 187 | const RsScriptCall *sc); |
Jason Sams | a36c50a | 2014-06-17 12:06:06 -0700 | [diff] [blame] | 188 | void (*updateCachedObject)(const Context *rsc, const Script *, rs_script *obj); |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 189 | } script; |
| 190 | |
Jason Sams | 8feea4e | 2011-03-18 15:03:25 -0700 | [diff] [blame] | 191 | struct { |
Jason Sams | eb4fe18 | 2011-05-26 16:33:01 -0700 | [diff] [blame] | 192 | bool (*init)(const Context *rsc, Allocation *alloc, bool forceZero); |
Jason Sams | bc9dc27 | 2015-02-09 12:50:22 -0800 | [diff] [blame] | 193 | bool (*initAdapter)(const Context *rsc, Allocation *alloc); |
Jason Sams | eb4fe18 | 2011-05-26 16:33:01 -0700 | [diff] [blame] | 194 | void (*destroy)(const Context *rsc, Allocation *alloc); |
Jason Sams | ddceab9 | 2013-08-07 13:02:32 -0700 | [diff] [blame] | 195 | uint32_t (*grallocBits)(const Context *rsc, Allocation *alloc); |
Jason Sams | eb4fe18 | 2011-05-26 16:33:01 -0700 | [diff] [blame] | 196 | |
| 197 | void (*resize)(const Context *rsc, const Allocation *alloc, const Type *newType, |
| 198 | bool zeroNew); |
| 199 | void (*syncAll)(const Context *rsc, const Allocation *alloc, RsAllocationUsageType src); |
| 200 | void (*markDirty)(const Context *rsc, const Allocation *alloc); |
Jason Sams | 7ac2a4d | 2012-02-15 12:04:24 -0800 | [diff] [blame] | 201 | |
Jason Sams | 733396b | 2013-02-22 12:46:18 -0800 | [diff] [blame] | 202 | void (*setSurface)(const Context *rsc, Allocation *alloc, ANativeWindow *sur); |
Jason Sams | 7ac2a4d | 2012-02-15 12:04:24 -0800 | [diff] [blame] | 203 | void (*ioSend)(const Context *rsc, Allocation *alloc); |
Jason Sams | ddceab9 | 2013-08-07 13:02:32 -0700 | [diff] [blame] | 204 | |
| 205 | /** |
| 206 | * A new gralloc buffer is in use. The pointers and strides in |
| 207 | * mHal.drvState.lod[0-2] will be updated with the new values. |
| 208 | * |
| 209 | * The new gralloc handle is provided in mHal.state.nativeBuffer |
| 210 | * |
| 211 | */ |
Jason Sams | 7ac2a4d | 2012-02-15 12:04:24 -0800 | [diff] [blame] | 212 | void (*ioReceive)(const Context *rsc, Allocation *alloc); |
Jason Sams | eb4fe18 | 2011-05-26 16:33:01 -0700 | [diff] [blame] | 213 | |
| 214 | void (*data1D)(const Context *rsc, const Allocation *alloc, |
Tim Murray | 099bc26 | 2013-03-20 16:54:03 -0700 | [diff] [blame] | 215 | uint32_t xoff, uint32_t lod, size_t count, |
Alex Sakhartchouk | c794cd5 | 2012-02-13 11:57:32 -0800 | [diff] [blame] | 216 | const void *data, size_t sizeBytes); |
Jason Sams | eb4fe18 | 2011-05-26 16:33:01 -0700 | [diff] [blame] | 217 | void (*data2D)(const Context *rsc, const Allocation *alloc, |
| 218 | uint32_t xoff, uint32_t yoff, uint32_t lod, |
| 219 | RsAllocationCubemapFace face, uint32_t w, uint32_t h, |
Tim Murray | 358747a | 2012-11-26 13:52:04 -0800 | [diff] [blame] | 220 | const void *data, size_t sizeBytes, size_t stride); |
Jason Sams | eb4fe18 | 2011-05-26 16:33:01 -0700 | [diff] [blame] | 221 | void (*data3D)(const Context *rsc, const Allocation *alloc, |
Jason Sams | 3bbc0fd | 2013-04-09 14:16:13 -0700 | [diff] [blame] | 222 | uint32_t xoff, uint32_t yoff, uint32_t zoff, uint32_t lod, |
| 223 | uint32_t w, uint32_t h, uint32_t d, const void *data, size_t sizeBytes, |
| 224 | size_t stride); |
Jason Sams | eb4fe18 | 2011-05-26 16:33:01 -0700 | [diff] [blame] | 225 | |
Jason Sams | 807fdc4 | 2012-07-25 17:55:39 -0700 | [diff] [blame] | 226 | void (*read1D)(const Context *rsc, const Allocation *alloc, |
Tim Murray | 099bc26 | 2013-03-20 16:54:03 -0700 | [diff] [blame] | 227 | uint32_t xoff, uint32_t lod, size_t count, |
Jason Sams | 807fdc4 | 2012-07-25 17:55:39 -0700 | [diff] [blame] | 228 | void *data, size_t sizeBytes); |
| 229 | void (*read2D)(const Context *rsc, const Allocation *alloc, |
| 230 | uint32_t xoff, uint32_t yoff, uint32_t lod, |
| 231 | RsAllocationCubemapFace face, uint32_t w, uint32_t h, |
Tim Murray | 358747a | 2012-11-26 13:52:04 -0800 | [diff] [blame] | 232 | void *data, size_t sizeBytes, size_t stride); |
Jason Sams | 807fdc4 | 2012-07-25 17:55:39 -0700 | [diff] [blame] | 233 | void (*read3D)(const Context *rsc, const Allocation *alloc, |
Jason Sams | 3bbc0fd | 2013-04-09 14:16:13 -0700 | [diff] [blame] | 234 | uint32_t xoff, uint32_t yoff, uint32_t zoff, uint32_t lod, |
| 235 | uint32_t w, uint32_t h, uint32_t d, void *data, size_t sizeBytes, |
| 236 | size_t stride); |
Jason Sams | 807fdc4 | 2012-07-25 17:55:39 -0700 | [diff] [blame] | 237 | |
| 238 | // Lock and unlock make a 1D region of memory available to the CPU |
| 239 | // for direct access by pointer. Once unlock is called control is |
| 240 | // returned to the SOC driver. |
| 241 | void * (*lock1D)(const Context *rsc, const Allocation *alloc); |
| 242 | void (*unlock1D)(const Context *rsc, const Allocation *alloc); |
| 243 | |
Alex Sakhartchouk | 74a8279 | 2011-06-14 11:13:19 -0700 | [diff] [blame] | 244 | // Allocation to allocation copies |
| 245 | void (*allocData1D)(const Context *rsc, |
| 246 | const Allocation *dstAlloc, |
Tim Murray | 099bc26 | 2013-03-20 16:54:03 -0700 | [diff] [blame] | 247 | uint32_t dstXoff, uint32_t dstLod, size_t count, |
Alex Sakhartchouk | 74a8279 | 2011-06-14 11:13:19 -0700 | [diff] [blame] | 248 | const Allocation *srcAlloc, uint32_t srcXoff, uint32_t srcLod); |
| 249 | void (*allocData2D)(const Context *rsc, |
| 250 | const Allocation *dstAlloc, |
| 251 | uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod, |
| 252 | RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h, |
| 253 | const Allocation *srcAlloc, |
| 254 | uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod, |
| 255 | RsAllocationCubemapFace srcFace); |
| 256 | void (*allocData3D)(const Context *rsc, |
| 257 | const Allocation *dstAlloc, |
| 258 | uint32_t dstXoff, uint32_t dstYoff, uint32_t dstZoff, |
Jason Sams | 3bbc0fd | 2013-04-09 14:16:13 -0700 | [diff] [blame] | 259 | uint32_t dstLod, |
Alex Sakhartchouk | 74a8279 | 2011-06-14 11:13:19 -0700 | [diff] [blame] | 260 | uint32_t w, uint32_t h, uint32_t d, |
| 261 | const Allocation *srcAlloc, |
| 262 | uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff, |
Jason Sams | 3bbc0fd | 2013-04-09 14:16:13 -0700 | [diff] [blame] | 263 | uint32_t srcLod); |
Alex Sakhartchouk | 74a8279 | 2011-06-14 11:13:19 -0700 | [diff] [blame] | 264 | |
Miao Wang | cc8cea7 | 2015-02-19 18:14:46 -0800 | [diff] [blame] | 265 | void (*elementData)(const Context *rsc, const Allocation *alloc, |
| 266 | uint32_t x, uint32_t y, uint32_t z, |
| 267 | const void *data, uint32_t elementOff, size_t sizeBytes); |
| 268 | void (*elementRead)(const Context *rsc, const Allocation *alloc, |
| 269 | uint32_t x, uint32_t y, uint32_t z, |
| 270 | void *data, uint32_t elementOff, size_t sizeBytes); |
Jason Sams | eb4fe18 | 2011-05-26 16:33:01 -0700 | [diff] [blame] | 271 | |
Jason Sams | 61a4bb7 | 2012-07-25 19:33:43 -0700 | [diff] [blame] | 272 | void (*generateMipmaps)(const Context *rsc, const Allocation *alloc); |
Jason Sams | a36c50a | 2014-06-17 12:06:06 -0700 | [diff] [blame] | 273 | |
| 274 | void (*updateCachedObject)(const Context *rsc, const Allocation *alloc, rs_allocation *obj); |
Jason Sams | bc9dc27 | 2015-02-09 12:50:22 -0800 | [diff] [blame] | 275 | |
| 276 | void (*adapterOffset)(const Context *rsc, const Allocation *alloc); |
Jason Sams | eb4fe18 | 2011-05-26 16:33:01 -0700 | [diff] [blame] | 277 | } allocation; |
| 278 | |
| 279 | struct { |
Jason Sams | 8feea4e | 2011-03-18 15:03:25 -0700 | [diff] [blame] | 280 | bool (*init)(const Context *rsc, const ProgramStore *ps); |
| 281 | void (*setActive)(const Context *rsc, const ProgramStore *ps); |
| 282 | void (*destroy)(const Context *rsc, const ProgramStore *ps); |
| 283 | } store; |
| 284 | |
Jason Sams | 721acc4 | 2011-04-06 11:23:54 -0700 | [diff] [blame] | 285 | struct { |
| 286 | bool (*init)(const Context *rsc, const ProgramRaster *ps); |
| 287 | void (*setActive)(const Context *rsc, const ProgramRaster *ps); |
| 288 | void (*destroy)(const Context *rsc, const ProgramRaster *ps); |
| 289 | } raster; |
Jason Sams | 8feea4e | 2011-03-18 15:03:25 -0700 | [diff] [blame] | 290 | |
Alex Sakhartchouk | a04e30d | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 291 | struct { |
| 292 | bool (*init)(const Context *rsc, const ProgramVertex *pv, |
Alex Sakhartchouk | 748eb07 | 2012-02-15 16:21:46 -0800 | [diff] [blame] | 293 | const char* shader, size_t shaderLen, |
| 294 | const char** textureNames, size_t textureNamesCount, |
| 295 | const size_t *textureNamesLength); |
Alex Sakhartchouk | a04e30d | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 296 | void (*setActive)(const Context *rsc, const ProgramVertex *pv); |
| 297 | void (*destroy)(const Context *rsc, const ProgramVertex *pv); |
| 298 | } vertex; |
| 299 | |
| 300 | struct { |
| 301 | bool (*init)(const Context *rsc, const ProgramFragment *pf, |
Alex Sakhartchouk | 748eb07 | 2012-02-15 16:21:46 -0800 | [diff] [blame] | 302 | const char* shader, size_t shaderLen, |
| 303 | const char** textureNames, size_t textureNamesCount, |
| 304 | const size_t *textureNamesLength); |
Alex Sakhartchouk | a04e30d | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 305 | void (*setActive)(const Context *rsc, const ProgramFragment *pf); |
| 306 | void (*destroy)(const Context *rsc, const ProgramFragment *pf); |
| 307 | } fragment; |
| 308 | |
| 309 | struct { |
| 310 | bool (*init)(const Context *rsc, const Mesh *m); |
| 311 | void (*draw)(const Context *rsc, const Mesh *m, uint32_t primIndex, uint32_t start, uint32_t len); |
| 312 | void (*destroy)(const Context *rsc, const Mesh *m); |
| 313 | } mesh; |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 314 | |
Alex Sakhartchouk | 7f126c7 | 2011-05-05 16:56:27 -0700 | [diff] [blame] | 315 | struct { |
| 316 | bool (*init)(const Context *rsc, const Sampler *m); |
| 317 | void (*destroy)(const Context *rsc, const Sampler *m); |
Jason Sams | a36c50a | 2014-06-17 12:06:06 -0700 | [diff] [blame] | 318 | void (*updateCachedObject)(const Context *rsc, const Sampler *s, rs_sampler *obj); |
Alex Sakhartchouk | 7f126c7 | 2011-05-05 16:56:27 -0700 | [diff] [blame] | 319 | } sampler; |
| 320 | |
Alex Sakhartchouk | da6d34a | 2011-05-13 14:53:34 -0700 | [diff] [blame] | 321 | struct { |
| 322 | bool (*init)(const Context *rsc, const FBOCache *fb); |
| 323 | void (*setActive)(const Context *rsc, const FBOCache *fb); |
| 324 | void (*destroy)(const Context *rsc, const FBOCache *fb); |
| 325 | } framebuffer; |
| 326 | |
Jason Sams | dbe66d6 | 2012-09-17 13:54:41 -0700 | [diff] [blame] | 327 | struct { |
Yang Ni | 1ffd86b | 2015-01-07 09:16:40 -0800 | [diff] [blame] | 328 | bool (*init)(const Context *rsc, ScriptGroupBase *sg); |
Jason Sams | dbe66d6 | 2012-09-17 13:54:41 -0700 | [diff] [blame] | 329 | void (*setInput)(const Context *rsc, const ScriptGroup *sg, |
| 330 | const ScriptKernelID *kid, Allocation *); |
| 331 | void (*setOutput)(const Context *rsc, const ScriptGroup *sg, |
| 332 | const ScriptKernelID *kid, Allocation *); |
Yang Ni | 1ffd86b | 2015-01-07 09:16:40 -0800 | [diff] [blame] | 333 | void (*execute)(const Context *rsc, const ScriptGroupBase *sg); |
| 334 | void (*destroy)(const Context *rsc, const ScriptGroupBase *sg); |
Jason Sams | a36c50a | 2014-06-17 12:06:06 -0700 | [diff] [blame] | 335 | void (*updateCachedObject)(const Context *rsc, const ScriptGroup *sg, rs_script_group *obj); |
Jason Sams | dbe66d6 | 2012-09-17 13:54:41 -0700 | [diff] [blame] | 336 | } scriptgroup; |
| 337 | |
Jason Sams | a36c50a | 2014-06-17 12:06:06 -0700 | [diff] [blame] | 338 | struct { |
| 339 | bool (*init)(const Context *rsc, const Type *m); |
| 340 | void (*destroy)(const Context *rsc, const Type *m); |
| 341 | void (*updateCachedObject)(const Context *rsc, const Type *s, rs_type *obj); |
| 342 | } type; |
| 343 | |
| 344 | struct { |
| 345 | bool (*init)(const Context *rsc, const Element *m); |
| 346 | void (*destroy)(const Context *rsc, const Element *m); |
| 347 | void (*updateCachedObject)(const Context *rsc, const Element *s, rs_element *obj); |
| 348 | } element; |
| 349 | |
Jason Sams | 9761c3f | 2013-11-26 18:10:59 -0800 | [diff] [blame] | 350 | void (*finish)(const Context *rsc); |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 351 | } RsdHalFunctions; |
| 352 | |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 353 | |
Jason Sams | 0ca7cba | 2015-03-11 15:22:38 -0700 | [diff] [blame] | 354 | enum RsHalInitEnums { |
| 355 | RS_HAL_CORE_SHUTDOWN = 1, |
| 356 | RS_HAL_CORE_SET_PRIORITY = 2, |
| 357 | RS_HAL_CORE_ALLOC_RUNTIME_MEM = 3, |
| 358 | RS_HAL_CORE_FREE_RUNTIME_MEM = 4, |
| 359 | RS_HAL_CORE_FINISH = 5, |
| 360 | |
| 361 | RS_HAL_SCRIPT_INIT = 1000, |
| 362 | RS_HAL_SCRIPT_INIT_INTRINSIC = 1001, |
| 363 | RS_HAL_SCRIPT_INVOKE_FUNCTION = 1002, |
| 364 | RS_HAL_SCRIPT_INVOKE_ROOT = 1003, |
| 365 | RS_HAL_SCRIPT_INVOKE_FOR_EACH = 1004, |
| 366 | RS_HAL_SCRIPT_INVOKE_INIT = 1005, |
| 367 | RS_HAL_SCRIPT_INVOKE_FREE_CHILDREN = 1006, |
| 368 | RS_HAL_SCRIPT_SET_GLOBAL_VAR = 1007, |
| 369 | RS_HAL_SCRIPT_GET_GLOBAL_VAR = 1008, |
| 370 | RS_HAL_SCRIPT_SET_GLOBAL_VAR_WITH_ELEMENT_DIM = 1009, |
| 371 | RS_HAL_SCRIPT_SET_GLOBAL_BIND = 1010, |
| 372 | RS_HAL_SCRIPT_SET_GLOBAL_OBJECT = 1011, |
| 373 | RS_HAL_SCRIPT_DESTROY = 1012, |
| 374 | RS_HAL_SCRIPT_INVOKE_FOR_EACH_MULTI = 1013, |
| 375 | RS_HAL_SCRIPT_UPDATE_CACHED_OBJECT = 1014, |
| 376 | |
| 377 | RS_HAL_ALLOCATION_INIT = 2000, |
| 378 | RS_HAL_ALLOCATION_INIT_ADAPTER = 2001, |
| 379 | RS_HAL_ALLOCATION_DESTROY = 2002, |
| 380 | RS_HAL_ALLOCATION_GET_GRALLOC_BITS = 2003, |
| 381 | RS_HAL_ALLOCATION_RESIZE = 2004, |
| 382 | RS_HAL_ALLOCATION_SYNC_ALL = 2005, |
| 383 | RS_HAL_ALLOCATION_MARK_DIRTY = 2006, |
| 384 | RS_HAL_ALLOCATION_SET_SURFACE = 2007, |
| 385 | RS_HAL_ALLOCATION_IO_SEND = 2008, |
| 386 | RS_HAL_ALLOCATION_IO_RECEIVE = 2009, |
| 387 | RS_HAL_ALLOCATION_DATA_1D = 2010, |
| 388 | RS_HAL_ALLOCATION_DATA_2D = 2011, |
| 389 | RS_HAL_ALLOCATION_DATA_3D = 2012, |
| 390 | RS_HAL_ALLOCATION_READ_1D = 2013, |
| 391 | RS_HAL_ALLOCATION_READ_2D = 2014, |
| 392 | RS_HAL_ALLOCATION_READ_3D = 2015, |
| 393 | RS_HAL_ALLOCATION_LOCK_1D = 2016, |
| 394 | RS_HAL_ALLOCATION_UNLOCK_1D = 2017, |
| 395 | RS_HAL_ALLOCATION_COPY_1D = 2018, |
| 396 | RS_HAL_ALLOCATION_COPY_2D = 2019, |
| 397 | RS_HAL_ALLOCATION_COPY_3D = 2020, |
| 398 | RS_HAL_ALLOCATION_ELEMENT_DATA = 2021, |
| 399 | RS_HAL_ALLOCATION_ELEMENT_READ = 2022, |
| 400 | RS_HAL_ALLOCATION_GENERATE_MIPMAPS = 2023, |
| 401 | RS_HAL_ALLOCATION_UPDATE_CACHED_OBJECT = 2024, |
| 402 | RS_HAL_ALLOCATION_ADAPTER_OFFSET = 2025, |
| 403 | |
| 404 | RS_HAL_SAMPLER_INIT = 3000, |
| 405 | RS_HAL_SAMPLER_DESTROY = 3001, |
| 406 | RS_HAL_SAMPLER_UPDATE_CACHED_OBJECT = 3002, |
| 407 | |
| 408 | RS_HAL_TYPE_INIT = 4000, |
| 409 | RS_HAL_TYPE_DESTROY = 4001, |
| 410 | RS_HAL_TYPE_UPDATE_CACHED_OBJECT = 4002, |
| 411 | |
| 412 | RS_HAL_ELEMENT_INIT = 5000, |
| 413 | RS_HAL_ELEMENT_DESTROY = 5001, |
| 414 | RS_HAL_ELEMENT_UPDATE_CACHED_OBJECT = 5002, |
| 415 | |
| 416 | RS_HAL_SCRIPT_GROUP_INIT = 6000, |
| 417 | RS_HAL_SCRIPT_GROUP_DESTROY = 6001, |
| 418 | RS_HAL_SCRIPT_GROUP_UPDATE_CACHED_OBJECT = 6002, |
| 419 | RS_HAL_SCRIPT_GROUP_SET_INPUT = 6003, |
| 420 | RS_HAL_SCRIPT_GROUP_SET_OUTPUT = 6004, |
| 421 | RS_HAL_SCRIPT_GROUP_EXECUTE = 6005, |
| 422 | |
| 423 | |
| 424 | |
| 425 | RS_HAL_GRAPHICS_INIT = 100001, |
| 426 | RS_HAL_GRAPHICS_SHUTDOWN = 100002, |
| 427 | RS_HAL_GRAPHICS_SWAP = 100003, |
| 428 | RS_HAL_GRAPHICS_SET_SURFACE = 100004, |
| 429 | RS_HAL_GRAPHICS_RASTER_INIT = 101000, |
| 430 | RS_HAL_GRAPHICS_RASTER_SET_ACTIVE = 101001, |
| 431 | RS_HAL_GRAPHICS_RASTER_DESTROY = 101002, |
| 432 | RS_HAL_GRAPHICS_VERTEX_INIT = 102000, |
| 433 | RS_HAL_GRAPHICS_VERTEX_SET_ACTIVE = 102001, |
| 434 | RS_HAL_GRAPHICS_VERTEX_DESTROY = 102002, |
| 435 | RS_HAL_GRAPHICS_FRAGMENT_INIT = 103000, |
| 436 | RS_HAL_GRAPHICS_FRAGMENT_SET_ACTIVE = 103001, |
| 437 | RS_HAL_GRAPHICS_FRAGMENT_DESTROY = 103002, |
| 438 | RS_HAL_GRAPHICS_MESH_INIT = 104000, |
| 439 | RS_HAL_GRAPHICS_MESH_DRAW = 104001, |
| 440 | RS_HAL_GRAPHICS_MESH_DESTROY = 104002, |
| 441 | RS_HAL_GRAPHICS_FB_INIT = 105000, |
| 442 | RS_HAL_GRAPHICS_FB_SET_ACTIVE = 105001, |
| 443 | RS_HAL_GRAPHICS_FB_DESTROY = 105002, |
| 444 | RS_HAL_GRAPHICS_STORE_INIT = 106000, |
| 445 | RS_HAL_GRAPHICS_STORE_SET_ACTIVE = 106001, |
| 446 | RS_HAL_GRAPHICS_STORE_DESTROY = 106002, |
| 447 | }; |
| 448 | |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 449 | } |
| 450 | } |
| 451 | |
Stephen Hines | 414a461 | 2012-09-05 18:05:08 -0700 | [diff] [blame] | 452 | #ifdef __cplusplus |
| 453 | extern "C" { |
| 454 | #endif |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 455 | |
Jason Sams | 0ca7cba | 2015-03-11 15:22:38 -0700 | [diff] [blame] | 456 | /** |
| 457 | * Get the major version number of the driver. The major |
| 458 | * version should be the API version number |
| 459 | * |
| 460 | * The Minor version number is vendor specific |
| 461 | * |
| 462 | * return: False will abort loading the driver, true indicates |
| 463 | * success |
| 464 | */ |
| 465 | bool rsdHalQueryVersion(uint32_t *version_major, uint32_t *version_minor); |
| 466 | |
| 467 | |
| 468 | /** |
| 469 | * Get an entry point in the driver HAL |
| 470 | * |
| 471 | * The driver should set the function pointer to its |
| 472 | * implementation of the function. If it does not have an entry |
| 473 | * for an enum, its should set the function pointer to NULL |
| 474 | * |
Jason Sams | b9276ce | 2015-03-17 13:42:47 -0700 | [diff] [blame] | 475 | * Returning NULL is expected in cases during development as new |
| 476 | * entry points are added that a driver may not understand. If |
| 477 | * the runtime receives a NULL it will decide if the function is |
| 478 | * required and will either continue loading or abort as needed. |
| 479 | * |
| 480 | * |
Jason Sams | 0ca7cba | 2015-03-11 15:22:38 -0700 | [diff] [blame] | 481 | * return: False will abort loading the driver, true indicates |
| 482 | * success |
Jason Sams | b9276ce | 2015-03-17 13:42:47 -0700 | [diff] [blame] | 483 | * |
Jason Sams | 0ca7cba | 2015-03-11 15:22:38 -0700 | [diff] [blame] | 484 | */ |
| 485 | bool rsdHalQueryHal(android::renderscript::RsHalInitEnums entry, void **fnPtr); |
| 486 | |
| 487 | |
| 488 | /** |
| 489 | * Called to initialize the context for use with a driver. |
| 490 | * |
| 491 | * return: False will abort loading the driver, true indicates |
| 492 | * success |
| 493 | */ |
Stephen Hines | 414a461 | 2012-09-05 18:05:08 -0700 | [diff] [blame] | 494 | bool rsdHalInit(RsContext, uint32_t version_major, uint32_t version_minor); |
| 495 | |
Jason Sams | 0ca7cba | 2015-03-11 15:22:38 -0700 | [diff] [blame] | 496 | /** |
| 497 | * Called if one of the loading functions above returns false. |
| 498 | * This is to clean up any resources allocated during an error |
| 499 | * condition. If this path is called it means the normal |
| 500 | * context->mHal.funcs.shutdown() will not be called. |
| 501 | */ |
| 502 | void rsdHalAbort(RsContext); |
| 503 | |
Stephen Hines | 414a461 | 2012-09-05 18:05:08 -0700 | [diff] [blame] | 504 | #ifdef __cplusplus |
| 505 | } |
| 506 | #endif |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 507 | |
| 508 | #endif |