Jason Sams | e4a06c5 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef RS_HAL_H |
| 18 | #define RS_HAL_H |
| 19 | |
| 20 | #include <RenderScriptDefines.h> |
Jason Sams | 803626f | 2011-04-06 17:52:23 -0700 | [diff] [blame] | 21 | #include <ui/egl/android_natives.h> |
Jason Sams | e4a06c5 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 22 | |
| 23 | namespace android { |
| 24 | namespace renderscript { |
| 25 | |
| 26 | class Context; |
| 27 | class ObjectBase; |
| 28 | class Element; |
| 29 | class Type; |
| 30 | class Allocation; |
| 31 | class Script; |
| 32 | class ScriptC; |
Alex Sakhartchouk | 4385054 | 2011-05-05 16:56:27 -0700 | [diff] [blame] | 33 | class Program; |
Jason Sams | 48f5056 | 2011-03-18 15:03:25 -0700 | [diff] [blame] | 34 | class ProgramStore; |
Jason Sams | 331bf9b | 2011-04-06 11:23:54 -0700 | [diff] [blame] | 35 | class ProgramRaster; |
Alex Sakhartchouk | 4a36b45 | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 36 | class ProgramVertex; |
| 37 | class ProgramFragment; |
| 38 | class Mesh; |
Alex Sakhartchouk | 4385054 | 2011-05-05 16:56:27 -0700 | [diff] [blame] | 39 | class Sampler; |
Alex Sakhartchouk | 2f6964f | 2011-05-13 14:53:34 -0700 | [diff] [blame] | 40 | class FBOCache; |
Jason Sams | e4a06c5 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 41 | |
Jason Sams | e4a06c5 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 42 | typedef void *(*RsHalSymbolLookupFunc)(void *usrptr, char const *symbolName); |
| 43 | |
Jason Sams | e4a06c5 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 44 | /** |
| 45 | * Script management functions |
| 46 | */ |
| 47 | typedef struct { |
Jason Sams | 803626f | 2011-04-06 17:52:23 -0700 | [diff] [blame] | 48 | bool (*initGraphics)(const Context *); |
| 49 | void (*shutdownGraphics)(const Context *); |
Alex Sakhartchouk | 6c72eec | 2011-05-17 12:32:47 -0700 | [diff] [blame] | 50 | bool (*setSurface)(const Context *, uint32_t w, uint32_t h, RsNativeWindow); |
Jason Sams | 803626f | 2011-04-06 17:52:23 -0700 | [diff] [blame] | 51 | void (*swap)(const Context *); |
| 52 | |
Jason Sams | 55d2a25 | 2011-03-17 16:12:47 -0700 | [diff] [blame] | 53 | void (*shutdownDriver)(Context *); |
Jason Sams | e4a06c5 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 54 | void (*getVersion)(unsigned int *major, unsigned int *minor); |
Jason Sams | 55d2a25 | 2011-03-17 16:12:47 -0700 | [diff] [blame] | 55 | void (*setPriority)(const Context *, int32_t priority); |
Jason Sams | e4a06c5 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 56 | |
| 57 | |
| 58 | |
| 59 | struct { |
Jason Sams | 48f5056 | 2011-03-18 15:03:25 -0700 | [diff] [blame] | 60 | bool (*init)(const Context *rsc, ScriptC *s, |
| 61 | char const *resName, |
| 62 | char const *cacheDir, |
| 63 | uint8_t const *bitcode, |
| 64 | size_t bitcodeSize, |
Jason Sams | fcf7231 | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 65 | uint32_t flags); |
Jason Sams | e4a06c5 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 66 | |
Jason Sams | 55d2a25 | 2011-03-17 16:12:47 -0700 | [diff] [blame] | 67 | void (*invokeFunction)(const Context *rsc, Script *s, |
Jason Sams | e4a06c5 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 68 | uint32_t slot, |
| 69 | const void *params, |
| 70 | size_t paramLength); |
Jason Sams | 55d2a25 | 2011-03-17 16:12:47 -0700 | [diff] [blame] | 71 | int (*invokeRoot)(const Context *rsc, Script *s); |
| 72 | void (*invokeForEach)(const Context *rsc, |
| 73 | Script *s, |
| 74 | const Allocation * ain, |
| 75 | Allocation * aout, |
| 76 | const void * usr, |
| 77 | uint32_t usrLen, |
| 78 | const RsScriptCall *sc); |
| 79 | void (*invokeInit)(const Context *rsc, Script *s); |
Jason Sams | e4a06c5 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 80 | |
| 81 | void (*setGlobalVar)(const Context *rsc, const Script *s, |
| 82 | uint32_t slot, |
| 83 | void *data, |
| 84 | size_t dataLength); |
| 85 | void (*setGlobalBind)(const Context *rsc, const Script *s, |
| 86 | uint32_t slot, |
| 87 | void *data); |
| 88 | void (*setGlobalObj)(const Context *rsc, const Script *s, |
| 89 | uint32_t slot, |
| 90 | ObjectBase *data); |
| 91 | |
| 92 | void (*destroy)(const Context *rsc, Script *s); |
| 93 | } script; |
| 94 | |
Jason Sams | 48f5056 | 2011-03-18 15:03:25 -0700 | [diff] [blame] | 95 | struct { |
Jason Sams | 7e8aae7 | 2011-05-26 16:33:01 -0700 | [diff] [blame^] | 96 | bool (*init)(const Context *rsc, Allocation *alloc, bool forceZero); |
| 97 | void (*destroy)(const Context *rsc, Allocation *alloc); |
| 98 | |
| 99 | void (*resize)(const Context *rsc, const Allocation *alloc, const Type *newType, |
| 100 | bool zeroNew); |
| 101 | void (*syncAll)(const Context *rsc, const Allocation *alloc, RsAllocationUsageType src); |
| 102 | void (*markDirty)(const Context *rsc, const Allocation *alloc); |
| 103 | |
| 104 | void (*data1D)(const Context *rsc, const Allocation *alloc, |
| 105 | uint32_t xoff, uint32_t lod, uint32_t count, |
| 106 | const void *data, uint32_t sizeBytes); |
| 107 | void (*data2D)(const Context *rsc, const Allocation *alloc, |
| 108 | uint32_t xoff, uint32_t yoff, uint32_t lod, |
| 109 | RsAllocationCubemapFace face, uint32_t w, uint32_t h, |
| 110 | const void *data, uint32_t sizeBytes); |
| 111 | void (*data3D)(const Context *rsc, const Allocation *alloc, |
| 112 | uint32_t xoff, uint32_t yoff, uint32_t zoff, |
| 113 | uint32_t lod, RsAllocationCubemapFace face, |
| 114 | uint32_t w, uint32_t h, uint32_t d, const void *data, uint32_t sizeBytes); |
| 115 | |
| 116 | void (*elementData1D)(const Context *rsc, const Allocation *alloc, uint32_t x, |
| 117 | const void *data, uint32_t elementOff, uint32_t sizeBytes); |
| 118 | void (*elementData2D)(const Context *rsc, const Allocation *alloc, uint32_t x, uint32_t y, |
| 119 | const void *data, uint32_t elementOff, uint32_t sizeBytes); |
| 120 | |
| 121 | |
| 122 | } allocation; |
| 123 | |
| 124 | struct { |
Jason Sams | 48f5056 | 2011-03-18 15:03:25 -0700 | [diff] [blame] | 125 | bool (*init)(const Context *rsc, const ProgramStore *ps); |
| 126 | void (*setActive)(const Context *rsc, const ProgramStore *ps); |
| 127 | void (*destroy)(const Context *rsc, const ProgramStore *ps); |
| 128 | } store; |
| 129 | |
Jason Sams | 331bf9b | 2011-04-06 11:23:54 -0700 | [diff] [blame] | 130 | struct { |
| 131 | bool (*init)(const Context *rsc, const ProgramRaster *ps); |
| 132 | void (*setActive)(const Context *rsc, const ProgramRaster *ps); |
| 133 | void (*destroy)(const Context *rsc, const ProgramRaster *ps); |
| 134 | } raster; |
Jason Sams | 48f5056 | 2011-03-18 15:03:25 -0700 | [diff] [blame] | 135 | |
Alex Sakhartchouk | 4a36b45 | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 136 | struct { |
| 137 | bool (*init)(const Context *rsc, const ProgramVertex *pv, |
| 138 | const char* shader, uint32_t shaderLen); |
| 139 | void (*setActive)(const Context *rsc, const ProgramVertex *pv); |
| 140 | void (*destroy)(const Context *rsc, const ProgramVertex *pv); |
| 141 | } vertex; |
| 142 | |
| 143 | struct { |
| 144 | bool (*init)(const Context *rsc, const ProgramFragment *pf, |
| 145 | const char* shader, uint32_t shaderLen); |
| 146 | void (*setActive)(const Context *rsc, const ProgramFragment *pf); |
| 147 | void (*destroy)(const Context *rsc, const ProgramFragment *pf); |
| 148 | } fragment; |
| 149 | |
| 150 | struct { |
| 151 | bool (*init)(const Context *rsc, const Mesh *m); |
| 152 | void (*draw)(const Context *rsc, const Mesh *m, uint32_t primIndex, uint32_t start, uint32_t len); |
| 153 | void (*destroy)(const Context *rsc, const Mesh *m); |
| 154 | } mesh; |
Jason Sams | e4a06c5 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 155 | |
Alex Sakhartchouk | 4385054 | 2011-05-05 16:56:27 -0700 | [diff] [blame] | 156 | struct { |
| 157 | bool (*init)(const Context *rsc, const Sampler *m); |
| 158 | void (*destroy)(const Context *rsc, const Sampler *m); |
| 159 | } sampler; |
| 160 | |
Alex Sakhartchouk | 2f6964f | 2011-05-13 14:53:34 -0700 | [diff] [blame] | 161 | struct { |
| 162 | bool (*init)(const Context *rsc, const FBOCache *fb); |
| 163 | void (*setActive)(const Context *rsc, const FBOCache *fb); |
| 164 | void (*destroy)(const Context *rsc, const FBOCache *fb); |
| 165 | } framebuffer; |
| 166 | |
Jason Sams | e4a06c5 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 167 | } RsdHalFunctions; |
| 168 | |
Jason Sams | e4a06c5 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 169 | |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | |
| 174 | bool rsdHalInit(android::renderscript::Context *, uint32_t version_major, uint32_t version_minor); |
| 175 | |
| 176 | #endif |
| 177 | |