1 /*
2  * Copyright (C) 2011-2012 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 #define LOG_TAG "libDispatch"
17 #include <android/log.h>
18 
19 #include "rsDispatch.h"
20 #include <dlfcn.h>
21 #include <limits.h>
22 
23 #define LOG_ERR(...) __android_log_print(ANDROID_LOG_ERROR, "RS Dispatch", __VA_ARGS__);
24 #define REDUCE_API_LEVEL 24
25 
loadSymbols(void * handle,dispatchTable & dispatchTab,int targetApiLevel)26 bool loadSymbols(void* handle, dispatchTable& dispatchTab, int targetApiLevel) {
27 #ifdef __LP64__
28     // Function to set the native lib path for 64bit compat lib.
29     dispatchTab.SetNativeLibDir = (SetNativeLibDirFnPtr)dlsym(handle, "rsaContextSetNativeLibDir");
30     if (dispatchTab.SetNativeLibDir == nullptr) {
31         LOG_ERR("Couldn't initialize dispatchTab.SetNativeLibDir");
32         return false;
33     }
34 #endif
35 
36     dispatchTab.Allocation1DData = (Allocation1DDataFnPtr)dlsym(handle, "rsAllocation1DData");
37     dispatchTab.Allocation1DElementData = (Allocation1DElementDataFnPtr)dlsym(handle, "rsAllocation1DElementData");
38     dispatchTab.Allocation1DRead = (Allocation1DReadFnPtr)dlsym(handle, "rsAllocation1DRead");
39     dispatchTab.Allocation2DData = (Allocation2DDataFnPtr)dlsym(handle, "rsAllocation2DData");
40     dispatchTab.Allocation2DRead = (Allocation2DReadFnPtr)dlsym(handle, "rsAllocation2DRead");
41     dispatchTab.Allocation3DData = (Allocation3DDataFnPtr)dlsym(handle, "rsAllocation3DData");
42     dispatchTab.Allocation3DRead = (Allocation3DReadFnPtr)dlsym(handle, "rsAllocation3DRead");
43     dispatchTab.AllocationCopy2DRange = (AllocationCopy2DRangeFnPtr)dlsym(handle, "rsAllocationCopy2DRange");
44     dispatchTab.AllocationCopy3DRange = (AllocationCopy3DRangeFnPtr)dlsym(handle, "rsAllocationCopy3DRange");
45     dispatchTab.AllocationCopyToBitmap = (AllocationCopyToBitmapFnPtr)dlsym(handle, "rsAllocationCopyToBitmap");
46     dispatchTab.AllocationCreateFromBitmap = (AllocationCreateFromBitmapFnPtr)dlsym(handle, "rsAllocationCreateFromBitmap");
47     dispatchTab.AllocationCreateTyped = (AllocationCreateTypedFnPtr)dlsym(handle, "rsAllocationCreateTyped");
48     dispatchTab.AllocationCubeCreateFromBitmap = (AllocationCubeCreateFromBitmapFnPtr)dlsym(handle, "rsAllocationCubeCreateFromBitmap");
49     dispatchTab.AllocationElementData = (AllocationElementDataFnPtr)dlsym(handle, "rsAllocationElementData");
50     dispatchTab.AllocationElementRead = (AllocationElementReadFnPtr)dlsym(handle, "rsAllocationElementRead");
51     dispatchTab.AllocationGenerateMipmaps = (AllocationGenerateMipmapsFnPtr)dlsym(handle, "rsAllocationGenerateMipmaps");
52     dispatchTab.AllocationGetPointer = (AllocationGetPointerFnPtr)dlsym(handle, "rsAllocationGetPointer");
53     dispatchTab.AllocationGetSurface = (AllocationGetSurfaceFnPtr)dlsym(handle, "rsAllocationGetSurface");
54     dispatchTab.AllocationGetType = (AllocationGetTypeFnPtr)dlsym(handle, "rsaAllocationGetType");
55     dispatchTab.AllocationIoReceive = (AllocationIoReceiveFnPtr)dlsym(handle, "rsAllocationIoReceive");
56     dispatchTab.AllocationIoSend = (AllocationIoSendFnPtr)dlsym(handle, "rsAllocationIoSend");
57     dispatchTab.AllocationRead = (AllocationReadFnPtr)dlsym(handle, "rsAllocationRead");
58     dispatchTab.AllocationResize1D = (AllocationResize1DFnPtr)dlsym(handle, "rsAllocationResize1D");
59     dispatchTab.AllocationSetSurface = (AllocationSetSurfaceFnPtr)dlsym(handle, "rsAllocationSetSurface");
60     dispatchTab.AllocationSyncAll = (AllocationSyncAllFnPtr)dlsym(handle, "rsAllocationSyncAll");
61     dispatchTab.AssignName = (AssignNameFnPtr)dlsym(handle, "rsAssignName");
62     dispatchTab.ClosureCreate = (ClosureCreateFnPtr)dlsym(handle, "rsClosureCreate");
63     dispatchTab.ClosureSetArg = (ClosureSetArgFnPtr)dlsym(handle, "rsClosureSetArg");
64     dispatchTab.ClosureSetGlobal = (ClosureSetGlobalFnPtr)dlsym(handle, "rsClosureSetGlobal");
65     dispatchTab.ContextCreate = (ContextCreateFnPtr)dlsym(handle, "rsContextCreate");;
66     dispatchTab.ContextDeinitToClient = (ContextDeinitToClientFnPtr)dlsym(handle, "rsContextDeinitToClient");
67     dispatchTab.ContextDestroy = (ContextDestroyFnPtr)dlsym(handle, "rsContextDestroy");
68     dispatchTab.ContextDump = (ContextDumpFnPtr)dlsym(handle, "rsContextDump");
69     dispatchTab.ContextFinish = (ContextFinishFnPtr)dlsym(handle, "rsContextFinish");
70     dispatchTab.ContextGetMessage = (ContextGetMessageFnPtr)dlsym(handle, "rsContextGetMessage");
71     dispatchTab.ContextInitToClient = (ContextInitToClientFnPtr)dlsym(handle, "rsContextInitToClient");
72     dispatchTab.ContextPeekMessage = (ContextPeekMessageFnPtr)dlsym(handle, "rsContextPeekMessage");
73     dispatchTab.ContextSendMessage = (ContextSendMessageFnPtr)dlsym(handle, "rsContextSendMessage");
74     dispatchTab.ContextSetPriority = (ContextSetPriorityFnPtr)dlsym(handle, "rsContextSetPriority");
75     dispatchTab.DeviceCreate = (DeviceCreateFnPtr)dlsym(handle, "rsDeviceCreate");
76     dispatchTab.DeviceDestroy = (DeviceDestroyFnPtr)dlsym(handle, "rsDeviceDestroy");
77     dispatchTab.DeviceSetConfig = (DeviceSetConfigFnPtr)dlsym(handle, "rsDeviceSetConfig");
78     dispatchTab.ElementCreate = (ElementCreateFnPtr)dlsym(handle, "rsElementCreate");
79     dispatchTab.ElementCreate2 = (ElementCreate2FnPtr)dlsym(handle, "rsElementCreate2");
80     dispatchTab.ElementGetNativeData = (ElementGetNativeDataFnPtr)dlsym(handle, "rsaElementGetNativeData");
81     dispatchTab.ElementGetSubElements = (ElementGetSubElementsFnPtr)dlsym(handle, "rsaElementGetSubElements");
82     dispatchTab.GetName = (GetNameFnPtr)dlsym(handle, "rsaGetName");;
83     dispatchTab.InvokeClosureCreate = (InvokeClosureCreateFnPtr)dlsym(handle, "rsInvokeClosureCreate");
84     dispatchTab.ObjDestroy = (ObjDestroyFnPtr)dlsym(handle, "rsObjDestroy");
85     dispatchTab.SamplerCreate = (SamplerCreateFnPtr)dlsym(handle, "rsSamplerCreate");
86     dispatchTab.ScriptBindAllocation = (ScriptBindAllocationFnPtr)dlsym(handle, "rsScriptBindAllocation");
87     dispatchTab.ScriptCCreate = (ScriptCCreateFnPtr)dlsym(handle, "rsScriptCCreate");
88     dispatchTab.ScriptFieldIDCreate = (ScriptFieldIDCreateFnPtr)dlsym(handle, "rsScriptFieldIDCreate");
89     dispatchTab.ScriptForEach = (ScriptForEachFnPtr)dlsym(handle, "rsScriptForEach");
90     dispatchTab.ScriptForEachMulti = (ScriptForEachMultiFnPtr)dlsym(handle, "rsScriptForEachMulti");
91     dispatchTab.ScriptGetVarV = (ScriptGetVarVFnPtr)dlsym(handle, "rsScriptGetVarV");
92     dispatchTab.ScriptGroup2Create = (ScriptGroup2CreateFnPtr)dlsym(handle, "rsScriptGroup2Create");
93     dispatchTab.ScriptGroupCreate = (ScriptGroupCreateFnPtr)dlsym(handle, "rsScriptGroupCreate");
94     dispatchTab.ScriptGroupExecute = (ScriptGroupExecuteFnPtr)dlsym(handle, "rsScriptGroupExecute");
95     dispatchTab.ScriptGroupSetInput = (ScriptGroupSetInputFnPtr)dlsym(handle, "rsScriptGroupSetInput");
96     dispatchTab.ScriptGroupSetOutput = (ScriptGroupSetOutputFnPtr)dlsym(handle, "rsScriptGroupSetOutput");
97     dispatchTab.ScriptIntrinsicCreate = (ScriptIntrinsicCreateFnPtr)dlsym(handle, "rsScriptIntrinsicCreate");
98     dispatchTab.ScriptInvoke = (ScriptInvokeFnPtr)dlsym(handle, "rsScriptInvoke");
99     dispatchTab.ScriptInvokeIDCreate = (ScriptInvokeIDCreateFnPtr)dlsym(handle, "rsScriptInvokeIDCreate");
100     dispatchTab.ScriptInvokeV = (ScriptInvokeVFnPtr)dlsym(handle, "rsScriptInvokeV");
101     dispatchTab.ScriptKernelIDCreate = (ScriptKernelIDCreateFnPtr)dlsym(handle, "rsScriptKernelIDCreate");
102     dispatchTab.ScriptReduce = (ScriptReduceFnPtr)dlsym(handle, "rsScriptReduce");
103     dispatchTab.ScriptSetTimeZone = (ScriptSetTimeZoneFnPtr)dlsym(handle, "rsScriptSetTimeZone");
104     dispatchTab.ScriptSetVarD = (ScriptSetVarDFnPtr)dlsym(handle, "rsScriptSetVarD");
105     dispatchTab.ScriptSetVarF = (ScriptSetVarFFnPtr)dlsym(handle, "rsScriptSetVarF");
106     dispatchTab.ScriptSetVarI = (ScriptSetVarIFnPtr)dlsym(handle, "rsScriptSetVarI");
107     dispatchTab.ScriptSetVarJ = (ScriptSetVarJFnPtr)dlsym(handle, "rsScriptSetVarJ");
108     dispatchTab.ScriptSetVarObj = (ScriptSetVarObjFnPtr)dlsym(handle, "rsScriptSetVarObj");
109     dispatchTab.ScriptSetVarV = (ScriptSetVarVFnPtr)dlsym(handle, "rsScriptSetVarV");
110     dispatchTab.ScriptSetVarVE = (ScriptSetVarVEFnPtr)dlsym(handle, "rsScriptSetVarVE");
111     dispatchTab.TypeCreate = (TypeCreateFnPtr)dlsym(handle, "rsTypeCreate");
112     dispatchTab.TypeGetNativeData = (TypeGetNativeDataFnPtr)dlsym(handle, "rsaTypeGetNativeData");
113 
114     // Clear error buffer for later operations.
115     dlerror();
116 
117     if (dispatchTab.AllocationGetType == nullptr) {
118         LOG_ERR("Couldn't initialize dispatchTab.AllocationGetType");
119         return false;
120     }
121     if (dispatchTab.TypeGetNativeData == nullptr) {
122         LOG_ERR("Couldn't initialize dispatchTab.TypeGetNativeData");
123         return false;
124     }
125     if (dispatchTab.ElementGetNativeData == nullptr) {
126         LOG_ERR("Couldn't initialize dispatchTab.ElementGetNativeData");
127         return false;
128     }
129     if (dispatchTab.ElementGetSubElements == nullptr) {
130         LOG_ERR("Couldn't initialize dispatchTab.ElementGetSubElements");
131         return false;
132     }
133     if (dispatchTab.DeviceCreate == nullptr) {
134         LOG_ERR("Couldn't initialize dispatchTab.DeviceCreate");
135         return false;
136     }
137     if (dispatchTab.DeviceDestroy == nullptr) {
138         LOG_ERR("Couldn't initialize dispatchTab.DeviceDestroy");
139         return false;
140     }
141     if (dispatchTab.DeviceSetConfig == nullptr) {
142         LOG_ERR("Couldn't initialize dispatchTab.DeviceSetConfig");
143         return false;
144     }
145     if (dispatchTab.ContextCreate == nullptr) {
146         LOG_ERR("Couldn't initialize dispatchTab.ContextCreate");
147         return false;
148     }
149     if (dispatchTab.GetName == nullptr) {
150         LOG_ERR("Couldn't initialize dispatchTab.GetName");
151         return false;
152     }
153     if (dispatchTab.ContextDestroy == nullptr) {
154         LOG_ERR("Couldn't initialize dispatchTab.ContextDestroy");
155         return false;
156     }
157     if (dispatchTab.ContextGetMessage == nullptr) {
158         LOG_ERR("Couldn't initialize dispatchTab.ContextGetMessage");
159         return false;
160     }
161     if (dispatchTab.ContextPeekMessage == nullptr) {
162         LOG_ERR("Couldn't initialize dispatchTab.ContextPeekMessage");
163         return false;
164     }
165     if (dispatchTab.ContextSendMessage == nullptr) {
166         LOG_ERR("Couldn't initialize dispatchTab.ContextSendMessage");
167         return false;
168     }
169     if (dispatchTab.ContextInitToClient == nullptr) {
170         LOG_ERR("Couldn't initialize dispatchTab.ContextInitToClient");
171         return false;
172     }
173     if (dispatchTab.ContextDeinitToClient == nullptr) {
174         LOG_ERR("Couldn't initialize dispatchTab.ContextDeinitToClient");
175         return false;
176     }
177     if (dispatchTab.TypeCreate == nullptr) {
178         LOG_ERR("Couldn't initialize dispatchTab.TypeCreate");
179         return false;
180     }
181     if (dispatchTab.AllocationCreateTyped == nullptr) {
182         LOG_ERR("Couldn't initialize dispatchTab.AllocationCreateTyped");
183         return false;
184     }
185     if (dispatchTab.AllocationCreateFromBitmap == nullptr) {
186         LOG_ERR("Couldn't initialize dispatchTab.AllocationCreateFromBitmap");
187         return false;
188     }
189     if (dispatchTab.AllocationCubeCreateFromBitmap == nullptr) {
190         LOG_ERR("Couldn't initialize dispatchTab.AllocationCubeCreateFromBitmap");
191         return false;
192     }
193     if (dispatchTab.AllocationGetSurface == nullptr) {
194         LOG_ERR("Couldn't initialize dispatchTab.AllocationGetSurface");
195         return false;
196     }
197     if (dispatchTab.AllocationSetSurface == nullptr) {
198         LOG_ERR("Couldn't initialize dispatchTab.AllocationSetSurface");
199         return false;
200     }
201     if (dispatchTab.ContextFinish == nullptr) {
202         LOG_ERR("Couldn't initialize dispatchTab.ContextFinish");
203         return false;
204     }
205     if (dispatchTab.ContextDump == nullptr) {
206         LOG_ERR("Couldn't initialize dispatchTab.ContextDump");
207         return false;
208     }
209     if (dispatchTab.ContextSetPriority == nullptr) {
210         LOG_ERR("Couldn't initialize dispatchTab.ContextSetPriority");
211         return false;
212     }
213     if (dispatchTab.AssignName == nullptr) {
214         LOG_ERR("Couldn't initialize dispatchTab.AssignName");
215         return false;
216     }
217     if (dispatchTab.ObjDestroy == nullptr) {
218         LOG_ERR("Couldn't initialize dispatchTab.ObjDestroy");
219         return false;
220     }
221     if (dispatchTab.ElementCreate == nullptr) {
222         LOG_ERR("Couldn't initialize dispatchTab.ElementCreate");
223         return false;
224     }
225     if (dispatchTab.ElementCreate2 == nullptr) {
226         LOG_ERR("Couldn't initialize dispatchTab.ElementCreate2");
227         return false;
228     }
229     if (dispatchTab.AllocationCopyToBitmap == nullptr) {
230         LOG_ERR("Couldn't initialize dispatchTab.AllocationCopyToBitmap");
231         return false;
232     }
233     if (dispatchTab.Allocation1DData == nullptr) {
234         LOG_ERR("Couldn't initialize dispatchTab.Allocation1DData");
235         return false;
236     }
237     if (dispatchTab.Allocation1DElementData == nullptr) {
238         LOG_ERR("Couldn't initialize dispatchTab.Allocation1DElementData");
239         return false;
240     }
241     if (dispatchTab.Allocation2DData == nullptr) {
242         LOG_ERR("Couldn't initialize dispatchTab.Allocation2DData");
243         return false;
244     }
245     if (dispatchTab.Allocation3DData == nullptr) {
246         LOG_ERR("Couldn't initialize dispatchTab.Allocation3DData");
247         return false;
248     }
249     if (dispatchTab.AllocationGenerateMipmaps == nullptr) {
250         LOG_ERR("Couldn't initialize dispatchTab.AllocationGenerateMipmaps");
251         return false;
252     }
253     if (dispatchTab.AllocationRead == nullptr) {
254         LOG_ERR("Couldn't initialize dispatchTab.AllocationRead");
255         return false;
256     }
257     if (dispatchTab.Allocation1DRead == nullptr) {
258         LOG_ERR("Couldn't initialize dispatchTab.Allocation1DRead");
259         return false;
260     }
261     if (dispatchTab.Allocation2DRead == nullptr) {
262         LOG_ERR("Couldn't initialize dispatchTab.Allocation2DRead");
263         return false;
264     }
265     if (dispatchTab.AllocationSyncAll == nullptr) {
266         LOG_ERR("Couldn't initialize dispatchTab.AllocationSyncAll");
267         return false;
268     }
269     if (dispatchTab.AllocationResize1D == nullptr) {
270         LOG_ERR("Couldn't initialize dispatchTab.AllocationResize1D");
271         return false;
272     }
273     if (dispatchTab.AllocationCopy2DRange == nullptr) {
274         LOG_ERR("Couldn't initialize dispatchTab.AllocationCopy2DRange");
275         return false;
276     }
277     if (dispatchTab.AllocationCopy3DRange == nullptr) {
278         LOG_ERR("Couldn't initialize dispatchTab.AllocationCopy3DRange");
279         return false;
280     }
281     if (dispatchTab.SamplerCreate == nullptr) {
282         LOG_ERR("Couldn't initialize dispatchTab.SamplerCreate");
283         return false;
284     }
285     if (dispatchTab.ScriptBindAllocation == nullptr) {
286         LOG_ERR("Couldn't initialize dispatchTab.ScriptBindAllocation");
287         return false;
288     }
289     if (dispatchTab.ScriptSetTimeZone == nullptr) {
290         LOG_ERR("Couldn't initialize dispatchTab.ScriptSetTimeZone");
291         return false;
292     }
293     if (dispatchTab.ScriptInvoke == nullptr) {
294         LOG_ERR("Couldn't initialize dispatchTab.ScriptInvoke");
295         return false;
296     }
297     if (dispatchTab.ScriptInvokeV == nullptr) {
298         LOG_ERR("Couldn't initialize dispatchTab.ScriptInvokeV");
299         return false;
300     }
301     if (dispatchTab.ScriptForEach == nullptr) {
302         LOG_ERR("Couldn't initialize dispatchTab.ScriptForEach");
303         return false;
304     }
305     if (dispatchTab.ScriptSetVarI == nullptr) {
306         LOG_ERR("Couldn't initialize dispatchTab.ScriptSetVarI");
307         return false;
308     }
309     if (dispatchTab.ScriptSetVarObj == nullptr) {
310         LOG_ERR("Couldn't initialize dispatchTab.ScriptSetVarObj");
311         return false;
312     }
313     if (dispatchTab.ScriptSetVarJ == nullptr) {
314         LOG_ERR("Couldn't initialize dispatchTab.ScriptSetVarJ");
315         return false;
316     }
317     if (dispatchTab.ScriptSetVarF == nullptr) {
318         LOG_ERR("Couldn't initialize dispatchTab.ScriptSetVarF");
319         return false;
320     }
321     if (dispatchTab.ScriptSetVarD == nullptr) {
322         LOG_ERR("Couldn't initialize dispatchTab.ScriptSetVarD");
323         return false;
324     }
325     if (dispatchTab.ScriptSetVarV == nullptr) {
326         LOG_ERR("Couldn't initialize dispatchTab.ScriptSetVarV");
327         return false;
328     }
329     if (dispatchTab.ScriptGetVarV == nullptr) {
330         LOG_ERR("Couldn't initialize dispatchTab.ScriptGetVarV");
331         return false;
332     }
333     if (dispatchTab.ScriptSetVarVE == nullptr) {
334         LOG_ERR("Couldn't initialize dispatchTab.ScriptSetVarVE");
335         return false;
336     }
337     if (dispatchTab.ScriptCCreate == nullptr) {
338         LOG_ERR("Couldn't initialize dispatchTab.ScriptCCreate");
339         return false;
340     }
341     if (dispatchTab.ScriptIntrinsicCreate == nullptr) {
342         LOG_ERR("Couldn't initialize dispatchTab.ScriptIntrinsicCreate");
343         return false;
344     }
345     if (dispatchTab.ScriptKernelIDCreate == nullptr) {
346         LOG_ERR("Couldn't initialize dispatchTab.ScriptKernelIDCreate");
347         return false;
348     }
349     if (dispatchTab.ScriptFieldIDCreate == nullptr) {
350         LOG_ERR("Couldn't initialize dispatchTab.ScriptFieldIDCreate");
351         return false;
352     }
353     if (dispatchTab.ScriptGroupCreate == nullptr) {
354         LOG_ERR("Couldn't initialize dispatchTab.ScriptGroupCreate");
355         return false;
356     }
357     if (dispatchTab.ScriptGroupSetOutput == nullptr) {
358         LOG_ERR("Couldn't initialize dispatchTab.ScriptGroupSetOutput");
359         return false;
360     }
361     if (dispatchTab.ScriptGroupSetInput == nullptr) {
362         LOG_ERR("Couldn't initialize dispatchTab.ScriptGroupSetInput");
363         return false;
364     }
365     if (dispatchTab.ScriptGroupExecute == nullptr) {
366         LOG_ERR("Couldn't initialize dispatchTab.ScriptGroupExecute");
367         return false;
368     }
369     if (dispatchTab.AllocationIoSend == nullptr) {
370         LOG_ERR("Couldn't initialize dispatchTab.AllocationIoSend");
371         return false;
372     }
373     if (dispatchTab.AllocationIoReceive == nullptr) {
374         LOG_ERR("Couldn't initialize dispatchTab.AllocationIoReceive");
375         return false;
376     }
377     // API_21 functions
378     if (targetApiLevel >= 21) {
379         if (dispatchTab.AllocationGetPointer == nullptr) {
380             LOG_ERR("Couldn't initialize dispatchTab.AllocationGetPointer");
381             return false;
382         }
383     }
384     // API_23 functions
385     if (targetApiLevel >= 23) {
386         // ScriptGroup V2 functions
387         if (dispatchTab.ScriptInvokeIDCreate == nullptr) {
388             LOG_ERR("Couldn't initialize dispatchTab.ScriptInvokeIDCreate");
389             return false;
390         }
391         if (dispatchTab.ClosureCreate == nullptr) {
392             LOG_ERR("Couldn't initialize dispatchTab.ClosureCreate");
393             return false;
394         }
395         if (dispatchTab.InvokeClosureCreate == nullptr) {
396             LOG_ERR("Couldn't initialize dispatchTab.InvokeClosureCreate");
397             return false;
398         }
399         if (dispatchTab.ClosureSetArg == nullptr) {
400             LOG_ERR("Couldn't initialize dispatchTab.ClosureSetArg");
401             return false;
402         }
403         if (dispatchTab.ClosureSetGlobal == nullptr) {
404             LOG_ERR("Couldn't initialize dispatchTab.ClosureSetGlobal");
405             return false;
406         }
407         if (dispatchTab.ScriptGroup2Create == nullptr) {
408             LOG_ERR("Couldn't initialize dispatchTab.ScriptGroup2Create");
409             return false;
410         }
411         if (dispatchTab.AllocationElementData == nullptr) {
412             LOG_ERR("Couldn't initialize dispatchTab.AllocationElementData");
413             return false;
414         }
415         if (dispatchTab.AllocationElementRead == nullptr) {
416             LOG_ERR("Couldn't initialize dispatchTab.AllocationElementRead");
417             return false;
418         }
419         if (dispatchTab.Allocation3DRead == nullptr) {
420             LOG_ERR("Couldn't initialize dispatchTab.Allocation3DRead");
421             return false;
422         }
423         if (dispatchTab.ScriptForEachMulti == nullptr) {
424             LOG_ERR("Couldn't initialize dispatchTab.ScriptForEachMulti");
425             return false;
426         }
427     }
428 
429     if (targetApiLevel >= REDUCE_API_LEVEL) {
430         if (dispatchTab.ScriptReduce == nullptr) {
431             LOG_ERR("Couldn't initialize dispatchTab.ScriptReduce");
432             return false;
433         }
434     }
435 
436     return true;
437 
438 }
439 
440 
loadIOSuppSyms(void * handleIO,ioSuppDT & ioDispatch)441 bool loadIOSuppSyms(void* handleIO, ioSuppDT& ioDispatch){
442     ioDispatch.sAllocationSetSurface = (sAllocationSetSurfaceFnPtr)dlsym(handleIO, "AllocationSetSurface");
443     if (ioDispatch.sAllocationSetSurface == nullptr) {
444         LOG_ERR("Couldn't initialize ioDispatch.sAllocationSetSurface");
445         return false;
446     }
447     return true;
448 }
449