Yang Ni | 1ffd86b | 2015-01-07 09:16:40 -0800 | [diff] [blame] | 1 | #ifndef ANDROID_RENDERSCRIPT_CLOSURE_H_ |
| 2 | #define ANDROID_RENDERSCRIPT_CLOSURE_H_ |
| 3 | |
Yang Ni | 1ffd86b | 2015-01-07 09:16:40 -0800 | [diff] [blame] | 4 | #include "rsDefines.h" |
Yang Ni | ff2bb54 | 2015-02-02 14:33:47 -0800 | [diff] [blame] | 5 | #include "rsMap.h" |
Yang Ni | 1ffd86b | 2015-01-07 09:16:40 -0800 | [diff] [blame] | 6 | #include "rsObjectBase.h" |
| 7 | |
| 8 | namespace android { |
| 9 | namespace renderscript { |
| 10 | |
Yang Ni | 1ffd86b | 2015-01-07 09:16:40 -0800 | [diff] [blame] | 11 | class Allocation; |
| 12 | class Context; |
Yang Ni | 062c287 | 2015-02-20 15:20:00 -0800 | [diff] [blame] | 13 | class IDBase; |
Yang Ni | eb9aa67 | 2015-01-27 14:32:25 -0800 | [diff] [blame] | 14 | class ObjectBase; |
Yang Ni | 1ffd86b | 2015-01-07 09:16:40 -0800 | [diff] [blame] | 15 | class ScriptFieldID; |
Yang Ni | eb9aa67 | 2015-01-27 14:32:25 -0800 | [diff] [blame] | 16 | class ScriptInvokeID; |
Yang Ni | 1ffd86b | 2015-01-07 09:16:40 -0800 | [diff] [blame] | 17 | class ScriptKernelID; |
| 18 | class Type; |
| 19 | |
| 20 | class Closure : public ObjectBase { |
| 21 | public: |
Yang Ni | eb9aa67 | 2015-01-27 14:32:25 -0800 | [diff] [blame] | 22 | Closure(Context* context, |
| 23 | const ScriptKernelID* kernelID, |
| 24 | Allocation* returnValue, |
| 25 | const int numValues, |
| 26 | const ScriptFieldID** fieldIDs, |
Yang Ni | fef0cd4 | 2015-11-11 15:08:16 -0800 | [diff] [blame] | 27 | const int64_t* values, // Allocations or primitive (numeric) types |
Yang Ni | bd0af2d | 2015-03-23 17:14:58 -0700 | [diff] [blame] | 28 | const int* sizes, // size for data type. -1 indicates an allocation. |
Yang Ni | eb9aa67 | 2015-01-27 14:32:25 -0800 | [diff] [blame] | 29 | const Closure** depClosures, |
| 30 | const ScriptFieldID** depFieldIDs); |
| 31 | Closure(Context* context, |
| 32 | const ScriptInvokeID* invokeID, |
| 33 | const void* params, |
| 34 | const size_t paramLength, |
| 35 | const size_t numValues, |
| 36 | const ScriptFieldID** fieldIDs, |
Yang Ni | fef0cd4 | 2015-11-11 15:08:16 -0800 | [diff] [blame] | 37 | const int64_t* values, // Allocations or primitive (numeric) types |
Yang Ni | bd0af2d | 2015-03-23 17:14:58 -0700 | [diff] [blame] | 38 | const int* sizes); // size for data type. -1 indicates an allocation. |
Yang Ni | 1ffd86b | 2015-01-07 09:16:40 -0800 | [diff] [blame] | 39 | |
Yang Ni | eb9aa67 | 2015-01-27 14:32:25 -0800 | [diff] [blame] | 40 | virtual ~Closure(); |
Yang Ni | 1ffd86b | 2015-01-07 09:16:40 -0800 | [diff] [blame] | 41 | |
Yang Ni | eb9aa67 | 2015-01-27 14:32:25 -0800 | [diff] [blame] | 42 | virtual void serialize(Context *rsc, OStream *stream) const {} |
Yang Ni | 1ffd86b | 2015-01-07 09:16:40 -0800 | [diff] [blame] | 43 | |
Yang Ni | eb9aa67 | 2015-01-27 14:32:25 -0800 | [diff] [blame] | 44 | virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_CLOSURE; } |
Yang Ni | 1ffd86b | 2015-01-07 09:16:40 -0800 | [diff] [blame] | 45 | |
Yang Ni | fef0cd4 | 2015-11-11 15:08:16 -0800 | [diff] [blame] | 46 | // Set the value of an argument or a global. |
| 47 | // The special value -1 for the size indicates the value is an Allocation. |
| 48 | void setArg(const uint32_t index, const void* value, const int size); |
| 49 | void setGlobal(const ScriptFieldID* fieldID, const int64_t value, |
Yang Ni | bd0af2d | 2015-03-23 17:14:58 -0700 | [diff] [blame] | 50 | const int size); |
Yang Ni | 1ffd86b | 2015-01-07 09:16:40 -0800 | [diff] [blame] | 51 | |
Yang Ni | eb9aa67 | 2015-01-27 14:32:25 -0800 | [diff] [blame] | 52 | Context* mContext; |
Yang Ni | 1ffd86b | 2015-01-07 09:16:40 -0800 | [diff] [blame] | 53 | |
Yang Ni | 062c287 | 2015-02-20 15:20:00 -0800 | [diff] [blame] | 54 | // KernelId or InvokeID |
| 55 | const ObjectBaseRef<IDBase> mFunctionID; |
| 56 | // Flag indicating if this closure is for a kernel (true) or invocable |
| 57 | // function (false) |
| 58 | const bool mIsKernel; |
Yang Ni | 1ffd86b | 2015-01-07 09:16:40 -0800 | [diff] [blame] | 59 | |
Yang Ni | eb9aa67 | 2015-01-27 14:32:25 -0800 | [diff] [blame] | 60 | // Values referrenced in arguments and globals cannot be futures. They must be |
| 61 | // either a known value or unbound value. |
| 62 | // For now, all arguments should be Allocations. |
Yang Ni | ff2bb54 | 2015-02-02 14:33:47 -0800 | [diff] [blame] | 63 | const void** mArgs; |
| 64 | size_t mNumArg; |
Yang Ni | 1ffd86b | 2015-01-07 09:16:40 -0800 | [diff] [blame] | 65 | |
Yang Ni | ff2bb54 | 2015-02-02 14:33:47 -0800 | [diff] [blame] | 66 | // A global could be allocation or any primitive data type. |
Yang Ni | fef0cd4 | 2015-11-11 15:08:16 -0800 | [diff] [blame] | 67 | Map<const ScriptFieldID*, Pair<int64_t, int>> mGlobals; |
Yang Ni | 1ffd86b | 2015-01-07 09:16:40 -0800 | [diff] [blame] | 68 | |
Yang Ni | eb9aa67 | 2015-01-27 14:32:25 -0800 | [diff] [blame] | 69 | Allocation* mReturnValue; |
Yang Ni | 1ffd86b | 2015-01-07 09:16:40 -0800 | [diff] [blame] | 70 | |
Yang Ni | eb9aa67 | 2015-01-27 14:32:25 -0800 | [diff] [blame] | 71 | // All the other closures which this closure depends on for one of its |
| 72 | // arguments, and the fields which it depends on. |
Yang Ni | bd0af2d | 2015-03-23 17:14:58 -0700 | [diff] [blame] | 73 | Map<const Closure*, Map<int, ObjectBaseRef<ScriptFieldID>>*> mArgDeps; |
Yang Ni | eb9aa67 | 2015-01-27 14:32:25 -0800 | [diff] [blame] | 74 | |
| 75 | // All the other closures that this closure depends on for one of its fields, |
| 76 | // and the fields that it depends on. |
Yang Ni | bd0af2d | 2015-03-23 17:14:58 -0700 | [diff] [blame] | 77 | Map<const Closure*, Map<const ScriptFieldID*, |
| 78 | ObjectBaseRef<ScriptFieldID>>*> mGlobalDeps; |
Yang Ni | eb9aa67 | 2015-01-27 14:32:25 -0800 | [diff] [blame] | 79 | |
Yang Ni | 99bd4a4 | 2015-05-11 19:40:38 -0700 | [diff] [blame] | 80 | uint8_t* mParams; |
Yang Ni | eb9aa67 | 2015-01-27 14:32:25 -0800 | [diff] [blame] | 81 | const size_t mParamLength; |
Yang Ni | 1ffd86b | 2015-01-07 09:16:40 -0800 | [diff] [blame] | 82 | }; |
| 83 | |
| 84 | } // namespace renderscript |
| 85 | } // namespace android |
| 86 | |
| 87 | #endif // ANDROID_RENDERSCRIPT_CLOSURE_H_ |