summaryrefslogtreecommitdiff
path: root/cpp/rsDispatch.h
blob: d77a4d97fb66ca0bdd03762790363278ef24df6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/*
 * Copyright (C) 2012 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef ANDROID_RSDISPATCH_H
#define ANDROID_RSDISPATCH_H

#include "rsInternalDefines.h"
#include "jni.h"

typedef void (*SetNativeLibDirFnPtr)(RsContext con, const char *nativeLibDir, size_t length);
typedef const void* (*AllocationGetTypeFnPtr)(RsContext con, RsAllocation va);
typedef void (*TypeGetNativeDataFnPtr)(RsContext, RsType, uintptr_t *typeData, uint32_t typeDataSize);
typedef void (*ElementGetNativeDataFnPtr)(RsContext, RsElement, uintptr_t *elemData, uint32_t elemDataSize);
typedef void (*ElementGetSubElementsFnPtr)(RsContext, RsElement, uintptr_t *ids, const char **names, uint32_t *arraySizes, uint32_t dataSize);
typedef RsDevice (*DeviceCreateFnPtr) ();
typedef void (*DeviceDestroyFnPtr) (RsDevice dev);
typedef void (*DeviceSetConfigFnPtr) (RsDevice dev, RsDeviceParam p, int32_t value);
typedef RsContext (*ContextCreateFnPtr)(RsDevice vdev, uint32_t version, uint32_t sdkVersion, RsContextType ct, uint32_t flags);
typedef void (*GetNameFnPtr)(RsContext, void * obj, const char **name);
typedef RsClosure (*ClosureCreateFnPtr)(RsContext, RsScriptKernelID, RsAllocation, RsScriptFieldID*, size_t, uintptr_t*, size_t, int*, size_t, RsClosure*, size_t, RsScriptFieldID*, size_t);
typedef RsClosure (*InvokeClosureCreateFnPtr)(RsContext, RsScriptInvokeID, const void*, const size_t, const RsScriptFieldID*, const size_t, const uintptr_t*, const size_t, const int*, const size_t);
typedef void (*ClosureSetArgFnPtr)(RsContext, RsClosure, uint32_t, uintptr_t, size_t);
typedef void (*ClosureSetGlobalFnPtr)(RsContext, RsClosure, RsScriptFieldID, uintptr_t, size_t);
typedef void (*ContextDestroyFnPtr) (RsContext);
typedef RsMessageToClientType (*ContextGetMessageFnPtr) (RsContext, void*, size_t, size_t*, size_t, uint32_t*, size_t);
typedef RsMessageToClientType (*ContextPeekMessageFnPtr) (RsContext, size_t*, size_t, uint32_t*, size_t);
typedef void (*ContextSendMessageFnPtr) (RsContext, uint32_t, const uint8_t*, size_t);
typedef void (*ContextInitToClientFnPtr) (RsContext);
typedef void (*ContextDeinitToClientFnPtr) (RsContext);
typedef RsType (*TypeCreateFnPtr) (RsContext, RsElement, uint32_t, uint32_t, uint32_t, bool, bool, uint32_t);
typedef RsAllocation (*AllocationCreateTypedFnPtr) (RsContext, RsType, RsAllocationMipmapControl, uint32_t, uintptr_t);
typedef RsAllocation (*AllocationCreateFromBitmapFnPtr) (RsContext, RsType, RsAllocationMipmapControl, const void*, size_t, uint32_t);
typedef RsAllocation (*AllocationCubeCreateFromBitmapFnPtr) (RsContext, RsType, RsAllocationMipmapControl, const void*, size_t, uint32_t);
typedef RsNativeWindow (*AllocationGetSurfaceFnPtr) (RsContext, RsAllocation);
typedef void (*AllocationSetSurfaceFnPtr) (RsContext, RsAllocation, RsNativeWindow);
typedef void (*ContextFinishFnPtr) (RsContext);
typedef void (*ContextDumpFnPtr) (RsContext, int32_t);
typedef void (*ContextSetPriorityFnPtr) (RsContext, int32_t);
typedef void (*AssignNameFnPtr) (RsContext, RsObjectBase, const char*, size_t);
typedef void (*ObjDestroyFnPtr) (RsContext, RsAsyncVoidPtr);
typedef RsElement (*ElementCreateFnPtr) (RsContext, RsDataType, RsDataKind, bool, uint32_t);
typedef RsElement (*ElementCreate2FnPtr) (RsContext, const RsElement*, size_t, const char**, size_t, const size_t*, const uint32_t*, size_t);
typedef void (*AllocationCopyToBitmapFnPtr) (RsContext, RsAllocation, void*, size_t);
typedef void (*Allocation1DDataFnPtr) (RsContext, RsAllocation, uint32_t, uint32_t, uint32_t, const void*, size_t);
typedef void (*Allocation1DElementDataFnPtr) (RsContext, RsAllocation, uint32_t, uint32_t, const void*, size_t, size_t);
typedef void (*AllocationElementDataFnPtr) (RsContext, RsAllocation, uint32_t, uint32_t, uint32_t, uint32_t, const void*, size_t, size_t);
typedef void (*Allocation2DDataFnPtr) (RsContext, RsAllocation, uint32_t, uint32_t, uint32_t, RsAllocationCubemapFace, uint32_t, uint32_t, const void*, size_t, size_t);
typedef void (*Allocation3DDataFnPtr) (RsContext, RsAllocation, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, const void*, size_t, size_t);
typedef void (*AllocationGenerateMipmapsFnPtr) (RsContext, RsAllocation);
typedef void (*AllocationReadFnPtr) (RsContext, RsAllocation, void*, size_t);
typedef void (*Allocation1DReadFnPtr) (RsContext, RsAllocation, uint32_t, uint32_t, uint32_t, void*, size_t);
typedef void (*AllocationElementReadFnPtr) (RsContext, RsAllocation, uint32_t, uint32_t, uint32_t, uint32_t, void*, size_t, size_t);
typedef void (*Allocation2DReadFnPtr) (RsContext, RsAllocation, uint32_t, uint32_t, uint32_t, RsAllocationCubemapFace, uint32_t, uint32_t, void*, size_t, size_t);
typedef void (*Allocation3DReadFnPtr) (RsContext, RsAllocation, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, void*, size_t, size_t);
typedef void (*AllocationSyncAllFnPtr) (RsContext, RsAllocation, RsAllocationUsageType);
typedef void (*AllocationResize1DFnPtr) (RsContext, RsAllocation, uint32_t);
typedef void (*AllocationCopy2DRangeFnPtr) (RsContext, RsAllocation, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, RsAllocation, uint32_t, uint32_t, uint32_t, uint32_t);
typedef void (*AllocationCopy3DRangeFnPtr) (RsContext, RsAllocation, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, RsAllocation, uint32_t, uint32_t, uint32_t, uint32_t);
typedef RsSampler (*SamplerCreateFnPtr) (RsContext, RsSamplerValue, RsSamplerValue, RsSamplerValue, RsSamplerValue, RsSamplerValue, float);
typedef void (*ScriptBindAllocationFnPtr) (RsContext, RsScript, RsAllocation, uint32_t);
typedef void (*ScriptSetTimeZoneFnPtr) (RsContext, RsScript, const char*, size_t);
typedef void (*ScriptInvokeFnPtr) (RsContext, RsScript, uint32_t);
typedef void (*ScriptInvokeVFnPtr) (RsContext, RsScript, uint32_t, const void*, size_t);
typedef void (*ScriptForEachFnPtr) (RsContext, RsScript, uint32_t, RsAllocation, RsAllocation, const void*, size_t, const RsScriptCall*, size_t);
typedef void (*ScriptSetVarIFnPtr) (RsContext, RsScript, uint32_t, int);
typedef void (*ScriptSetVarObjFnPtr) (RsContext, RsScript, uint32_t, RsObjectBase);
typedef void (*ScriptSetVarJFnPtr) (RsContext, RsScript, uint32_t, int64_t);
typedef void (*ScriptSetVarFFnPtr) (RsContext, RsScript, uint32_t, float);
typedef void (*ScriptSetVarDFnPtr) (RsContext, RsScript, uint32_t, double);
typedef void (*ScriptSetVarVFnPtr) (RsContext, RsScript, uint32_t, const void*, size_t);
typedef void (*ScriptGetVarVFnPtr) (RsContext, RsScript, uint32_t, void*, size_t);
typedef void (*ScriptSetVarVEFnPtr) (RsContext, RsScript, uint32_t, const void*, size_t, RsElement, const uint32_t*, size_t);
typedef RsScript (*ScriptCCreateFnPtr) (RsContext, const char*, size_t, const char*, size_t, const char*, size_t);
typedef RsScript (*ScriptIntrinsicCreateFnPtr) (RsContext, uint32_t id, RsElement);
typedef RsScriptKernelID (*ScriptKernelIDCreateFnPtr) (RsContext, RsScript, int, int);
typedef RsScriptInvokeID (*ScriptInvokeIDCreateFnPtr) (RsContext, RsScript, int);
typedef RsScriptFieldID (*ScriptFieldIDCreateFnPtr) (RsContext, RsScript, int);
typedef RsScriptGroup (*ScriptGroupCreateFnPtr) (RsContext, RsScriptKernelID*, size_t, RsScriptKernelID*, size_t, RsScriptKernelID*, size_t, RsScriptFieldID*, size_t, const RsType*, size_t);
typedef RsScriptGroup2 (*ScriptGroup2CreateFnPtr)(RsContext, const char*, size_t, const char*, size_t, RsClosure*, size_t);
typedef void (*ScriptGroupSetOutputFnPtr) (RsContext, RsScriptGroup, RsScriptKernelID, RsAllocation);
typedef void (*ScriptGroupSetInputFnPtr) (RsContext, RsScriptGroup, RsScriptKernelID, RsAllocation);
typedef void (*ScriptGroupExecuteFnPtr) (RsContext, RsScriptGroup);
typedef void (*AllocationIoSendFnPtr) (RsContext, RsAllocation);
typedef void (*AllocationIoReceiveFnPtr) (RsContext, RsAllocation);
typedef void * (*AllocationGetPointerFnPtr) (RsContext, RsAllocation, uint32_t lod, RsAllocationCubemapFace face, uint32_t z, uint32_t array, size_t *stride, size_t stride_len);

struct dispatchTable {
    SetNativeLibDirFnPtr SetNativeLibDir;

    // inserted by hand from rs.h
    AllocationGetTypeFnPtr AllocationGetType;
    TypeGetNativeDataFnPtr TypeGetNativeData;
    ElementGetNativeDataFnPtr ElementGetNativeData;
    ElementGetSubElementsFnPtr ElementGetSubElements;

    DeviceCreateFnPtr DeviceCreate;
    DeviceDestroyFnPtr DeviceDestroy;
    DeviceSetConfigFnPtr DeviceSetConfig;
    ContextCreateFnPtr ContextCreate;
    GetNameFnPtr GetName;

    // generated from rs.spec
    ContextDestroyFnPtr ContextDestroy;
    ContextGetMessageFnPtr ContextGetMessage;
    ContextPeekMessageFnPtr ContextPeekMessage;
    ContextSendMessageFnPtr ContextSendMessage;
    ContextInitToClientFnPtr ContextInitToClient;
    ContextDeinitToClientFnPtr ContextDeinitToClient;
    TypeCreateFnPtr TypeCreate;
    AllocationCreateTypedFnPtr AllocationCreateTyped;
    AllocationCreateFromBitmapFnPtr AllocationCreateFromBitmap;
    AllocationCubeCreateFromBitmapFnPtr AllocationCubeCreateFromBitmap;
    AllocationGetSurfaceFnPtr AllocationGetSurface;
    AllocationSetSurfaceFnPtr AllocationSetSurface;
    ClosureCreateFnPtr ClosureCreate;
    InvokeClosureCreateFnPtr InvokeClosureCreate;
    ClosureSetArgFnPtr ClosureSetArg;
    ClosureSetGlobalFnPtr ClosureSetGlobal;
    ContextFinishFnPtr ContextFinish;
    ContextDumpFnPtr ContextDump;
    ContextSetPriorityFnPtr ContextSetPriority;
    AssignNameFnPtr AssignName;
    ObjDestroyFnPtr ObjDestroy;
    ElementCreateFnPtr ElementCreate;
    ElementCreate2FnPtr ElementCreate2;
    AllocationCopyToBitmapFnPtr AllocationCopyToBitmap;
    Allocation1DDataFnPtr Allocation1DData;
    Allocation1DElementDataFnPtr Allocation1DElementData;
    AllocationElementDataFnPtr AllocationElementData;
    Allocation2DDataFnPtr Allocation2DData;
    Allocation3DDataFnPtr Allocation3DData;
    AllocationGenerateMipmapsFnPtr AllocationGenerateMipmaps;
    AllocationReadFnPtr AllocationRead;
    Allocation1DReadFnPtr Allocation1DRead;
    AllocationElementReadFnPtr AllocationElementRead;
    Allocation2DReadFnPtr Allocation2DRead;
    Allocation3DReadFnPtr Allocation3DRead;
    AllocationSyncAllFnPtr AllocationSyncAll;
    AllocationResize1DFnPtr AllocationResize1D;
    AllocationCopy2DRangeFnPtr AllocationCopy2DRange;
    AllocationCopy3DRangeFnPtr AllocationCopy3DRange;
    SamplerCreateFnPtr SamplerCreate;
    ScriptBindAllocationFnPtr ScriptBindAllocation;
    ScriptSetTimeZoneFnPtr ScriptSetTimeZone;
    ScriptInvokeFnPtr ScriptInvoke;
    ScriptInvokeVFnPtr ScriptInvokeV;
    ScriptForEachFnPtr ScriptForEach;
    ScriptSetVarIFnPtr ScriptSetVarI;
    ScriptSetVarObjFnPtr ScriptSetVarObj;
    ScriptSetVarJFnPtr ScriptSetVarJ;
    ScriptSetVarFFnPtr ScriptSetVarF;
    ScriptSetVarDFnPtr ScriptSetVarD;
    ScriptSetVarVFnPtr ScriptSetVarV;
    ScriptGetVarVFnPtr ScriptGetVarV;
    ScriptSetVarVEFnPtr ScriptSetVarVE;
    ScriptCCreateFnPtr ScriptCCreate;
    ScriptIntrinsicCreateFnPtr ScriptIntrinsicCreate;
    ScriptKernelIDCreateFnPtr ScriptKernelIDCreate;
    ScriptInvokeIDCreateFnPtr ScriptInvokeIDCreate;
    ScriptFieldIDCreateFnPtr ScriptFieldIDCreate;
    ScriptGroupCreateFnPtr ScriptGroupCreate;
    ScriptGroup2CreateFnPtr ScriptGroup2Create;
    ScriptGroupSetOutputFnPtr ScriptGroupSetOutput;
    ScriptGroupSetInputFnPtr ScriptGroupSetInput;
    ScriptGroupExecuteFnPtr ScriptGroupExecute;
    AllocationIoSendFnPtr AllocationIoSend;
    AllocationIoReceiveFnPtr AllocationIoReceive;
    AllocationGetPointerFnPtr AllocationGetPointer;
};

bool loadSymbols(void* handle, dispatchTable& dispatchTab, int device_api = 0);

//USAGE_IO for RS Support lib
typedef void (*sAllocationSetSurfaceFnPtr) (JNIEnv *, jobject, RsContext, RsAllocation, RsNativeWindow, dispatchTable);
struct ioSuppDT {
    //USAGE_IO_OUTPUT
    sAllocationSetSurfaceFnPtr sAllocationSetSurface;
};

bool loadIOSuppSyms(void* handleIO, ioSuppDT& ioDispatch);
#endif