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> |
| 21 | |
| 22 | namespace android { |
| 23 | namespace renderscript { |
| 24 | |
| 25 | class Context; |
| 26 | class ObjectBase; |
| 27 | class Element; |
| 28 | class Type; |
| 29 | class Allocation; |
| 30 | class Script; |
| 31 | class ScriptC; |
Jason Sams | 48f5056 | 2011-03-18 15:03:25 -0700 | [diff] [blame] | 32 | class ProgramStore; |
Jason Sams | 331bf9b | 2011-04-06 11:23:54 -0700 | [diff] [blame^] | 33 | class ProgramRaster; |
Jason Sams | e4a06c5 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 34 | |
Jason Sams | e4a06c5 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 35 | typedef void *(*RsHalSymbolLookupFunc)(void *usrptr, char const *symbolName); |
| 36 | |
Jason Sams | 55d2a25 | 2011-03-17 16:12:47 -0700 | [diff] [blame] | 37 | typedef struct ScriptTLSStructRec { |
| 38 | Context * mContext; |
| 39 | Script * mScript; |
| 40 | } ScriptTLSStruct; |
Jason Sams | e4a06c5 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 41 | |
| 42 | |
| 43 | /** |
| 44 | * Script management functions |
| 45 | */ |
| 46 | typedef struct { |
Jason Sams | 55d2a25 | 2011-03-17 16:12:47 -0700 | [diff] [blame] | 47 | void (*shutdownDriver)(Context *); |
Jason Sams | e4a06c5 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 48 | void (*getVersion)(unsigned int *major, unsigned int *minor); |
Jason Sams | 55d2a25 | 2011-03-17 16:12:47 -0700 | [diff] [blame] | 49 | void (*setPriority)(const Context *, int32_t priority); |
Jason Sams | e4a06c5 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 50 | |
| 51 | |
| 52 | |
| 53 | struct { |
Jason Sams | 48f5056 | 2011-03-18 15:03:25 -0700 | [diff] [blame] | 54 | bool (*init)(const Context *rsc, ScriptC *s, |
| 55 | char const *resName, |
| 56 | char const *cacheDir, |
| 57 | uint8_t const *bitcode, |
| 58 | size_t bitcodeSize, |
| 59 | uint32_t flags, |
| 60 | RsHalSymbolLookupFunc lookupFunc); |
Jason Sams | e4a06c5 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 61 | |
Jason Sams | 55d2a25 | 2011-03-17 16:12:47 -0700 | [diff] [blame] | 62 | void (*invokeFunction)(const Context *rsc, Script *s, |
Jason Sams | e4a06c5 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 63 | uint32_t slot, |
| 64 | const void *params, |
| 65 | size_t paramLength); |
Jason Sams | 55d2a25 | 2011-03-17 16:12:47 -0700 | [diff] [blame] | 66 | int (*invokeRoot)(const Context *rsc, Script *s); |
| 67 | void (*invokeForEach)(const Context *rsc, |
| 68 | Script *s, |
| 69 | const Allocation * ain, |
| 70 | Allocation * aout, |
| 71 | const void * usr, |
| 72 | uint32_t usrLen, |
| 73 | const RsScriptCall *sc); |
| 74 | void (*invokeInit)(const Context *rsc, Script *s); |
Jason Sams | e4a06c5 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 75 | |
| 76 | void (*setGlobalVar)(const Context *rsc, const Script *s, |
| 77 | uint32_t slot, |
| 78 | void *data, |
| 79 | size_t dataLength); |
| 80 | void (*setGlobalBind)(const Context *rsc, const Script *s, |
| 81 | uint32_t slot, |
| 82 | void *data); |
| 83 | void (*setGlobalObj)(const Context *rsc, const Script *s, |
| 84 | uint32_t slot, |
| 85 | ObjectBase *data); |
| 86 | |
| 87 | void (*destroy)(const Context *rsc, Script *s); |
| 88 | } script; |
| 89 | |
| 90 | |
Jason Sams | 48f5056 | 2011-03-18 15:03:25 -0700 | [diff] [blame] | 91 | struct { |
| 92 | bool (*init)(const Context *rsc, const ProgramStore *ps); |
| 93 | void (*setActive)(const Context *rsc, const ProgramStore *ps); |
| 94 | void (*destroy)(const Context *rsc, const ProgramStore *ps); |
| 95 | } store; |
| 96 | |
Jason Sams | 331bf9b | 2011-04-06 11:23:54 -0700 | [diff] [blame^] | 97 | struct { |
| 98 | bool (*init)(const Context *rsc, const ProgramRaster *ps); |
| 99 | void (*setActive)(const Context *rsc, const ProgramRaster *ps); |
| 100 | void (*destroy)(const Context *rsc, const ProgramRaster *ps); |
| 101 | } raster; |
Jason Sams | 48f5056 | 2011-03-18 15:03:25 -0700 | [diff] [blame] | 102 | |
Jason Sams | e4a06c5 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 103 | |
| 104 | } RsdHalFunctions; |
| 105 | |
| 106 | void rsiSetObject(ObjectBase **vdst, ObjectBase * vsrc); |
| 107 | void rsiClearObject(ObjectBase **vdst); |
| 108 | bool rsiIsObject(const ObjectBase *vdst); |
| 109 | |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | |
| 114 | bool rsdHalInit(android::renderscript::Context *, uint32_t version_major, uint32_t version_minor); |
| 115 | |
| 116 | #endif |
| 117 | |