Home | History | Annotate | Download | only in cpp
      1 /*
      2  * Copyright (C) 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 
     17 #ifndef ANDROID_RSDISPATCH_H
     18 #define ANDROID_RSDISPATCH_H
     19 
     20 #include "rsInternalDefines.h"
     21 #include "jni.h"
     22 
     23 typedef void (*SetNativeLibDirFnPtr)(RsContext con, const char *nativeLibDir, size_t length);
     24 typedef const void* (*AllocationGetTypeFnPtr)(RsContext con, RsAllocation va);
     25 typedef void (*TypeGetNativeDataFnPtr)(RsContext, RsType, uintptr_t *typeData, uint32_t typeDataSize);
     26 typedef void (*ElementGetNativeDataFnPtr)(RsContext, RsElement, uintptr_t *elemData, uint32_t elemDataSize);
     27 typedef void (*ElementGetSubElementsFnPtr)(RsContext, RsElement, uintptr_t *ids, const char **names, uint32_t *arraySizes, uint32_t dataSize);
     28 typedef RsDevice (*DeviceCreateFnPtr) ();
     29 typedef void (*DeviceDestroyFnPtr) (RsDevice dev);
     30 typedef void (*DeviceSetConfigFnPtr) (RsDevice dev, RsDeviceParam p, int32_t value);
     31 typedef RsContext (*ContextCreateFnPtr)(RsDevice vdev, uint32_t version, uint32_t sdkVersion, RsContextType ct, uint32_t flags);
     32 typedef void (*GetNameFnPtr)(RsContext, void * obj, const char **name);
     33 typedef RsClosure (*ClosureCreateFnPtr)(RsContext, RsScriptKernelID, RsAllocation, RsScriptFieldID*, size_t, uintptr_t*, size_t, int*, size_t, RsClosure*, size_t, RsScriptFieldID*, size_t);
     34 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);
     35 typedef void (*ClosureSetArgFnPtr)(RsContext, RsClosure, uint32_t, uintptr_t, size_t);
     36 typedef void (*ClosureSetGlobalFnPtr)(RsContext, RsClosure, RsScriptFieldID, uintptr_t, size_t);
     37 typedef void (*ContextDestroyFnPtr) (RsContext);
     38 typedef RsMessageToClientType (*ContextGetMessageFnPtr) (RsContext, void*, size_t, size_t*, size_t, uint32_t*, size_t);
     39 typedef RsMessageToClientType (*ContextPeekMessageFnPtr) (RsContext, size_t*, size_t, uint32_t*, size_t);
     40 typedef void (*ContextSendMessageFnPtr) (RsContext, uint32_t, const uint8_t*, size_t);
     41 typedef void (*ContextInitToClientFnPtr) (RsContext);
     42 typedef void (*ContextDeinitToClientFnPtr) (RsContext);
     43 typedef RsType (*TypeCreateFnPtr) (RsContext, RsElement, uint32_t, uint32_t, uint32_t, bool, bool, uint32_t);
     44 typedef RsAllocation (*AllocationCreateTypedFnPtr) (RsContext, RsType, RsAllocationMipmapControl, uint32_t, uintptr_t);
     45 typedef RsAllocation (*AllocationCreateFromBitmapFnPtr) (RsContext, RsType, RsAllocationMipmapControl, const void*, size_t, uint32_t);
     46 typedef RsAllocation (*AllocationCubeCreateFromBitmapFnPtr) (RsContext, RsType, RsAllocationMipmapControl, const void*, size_t, uint32_t);
     47 typedef RsNativeWindow (*AllocationGetSurfaceFnPtr) (RsContext, RsAllocation);
     48 typedef void (*AllocationSetSurfaceFnPtr) (RsContext, RsAllocation, RsNativeWindow);
     49 typedef void (*ContextFinishFnPtr) (RsContext);
     50 typedef void (*ContextDumpFnPtr) (RsContext, int32_t);
     51 typedef void (*ContextSetPriorityFnPtr) (RsContext, int32_t);
     52 typedef void (*AssignNameFnPtr) (RsContext, RsObjectBase, const char*, size_t);
     53 typedef void (*ObjDestroyFnPtr) (RsContext, RsAsyncVoidPtr);
     54 typedef RsElement (*ElementCreateFnPtr) (RsContext, RsDataType, RsDataKind, bool, uint32_t);
     55 typedef RsElement (*ElementCreate2FnPtr) (RsContext, const RsElement*, size_t, const char**, size_t, const size_t*, const uint32_t*, size_t);
     56 typedef void (*AllocationCopyToBitmapFnPtr) (RsContext, RsAllocation, void*, size_t);
     57 typedef void (*Allocation1DDataFnPtr) (RsContext, RsAllocation, uint32_t, uint32_t, uint32_t, const void*, size_t);
     58 typedef void (*Allocation1DElementDataFnPtr) (RsContext, RsAllocation, uint32_t, uint32_t, const void*, size_t, size_t);
     59 typedef void (*AllocationElementDataFnPtr) (RsContext, RsAllocation, uint32_t, uint32_t, uint32_t, uint32_t, const void*, size_t, size_t);
     60 typedef void (*Allocation2DDataFnPtr) (RsContext, RsAllocation, uint32_t, uint32_t, uint32_t, RsAllocationCubemapFace, uint32_t, uint32_t, const void*, size_t, size_t);
     61 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);
     62 typedef void (*AllocationGenerateMipmapsFnPtr) (RsContext, RsAllocation);
     63 typedef void (*AllocationReadFnPtr) (RsContext, RsAllocation, void*, size_t);
     64 typedef void (*Allocation1DReadFnPtr) (RsContext, RsAllocation, uint32_t, uint32_t, uint32_t, void*, size_t);
     65 typedef void (*AllocationElementReadFnPtr) (RsContext, RsAllocation, uint32_t, uint32_t, uint32_t, uint32_t, void*, size_t, size_t);
     66 typedef void (*Allocation2DReadFnPtr) (RsContext, RsAllocation, uint32_t, uint32_t, uint32_t, RsAllocationCubemapFace, uint32_t, uint32_t, void*, size_t, size_t);
     67 typedef void (*Allocation3DReadFnPtr) (RsContext, RsAllocation, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, void*, size_t, size_t);
     68 typedef void (*AllocationSyncAllFnPtr) (RsContext, RsAllocation, RsAllocationUsageType);
     69 typedef void (*AllocationResize1DFnPtr) (RsContext, RsAllocation, uint32_t);
     70 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);
     71 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);
     72 typedef RsSampler (*SamplerCreateFnPtr) (RsContext, RsSamplerValue, RsSamplerValue, RsSamplerValue, RsSamplerValue, RsSamplerValue, float);
     73 typedef void (*ScriptBindAllocationFnPtr) (RsContext, RsScript, RsAllocation, uint32_t);
     74 typedef void (*ScriptSetTimeZoneFnPtr) (RsContext, RsScript, const char*, size_t);
     75 typedef void (*ScriptInvokeFnPtr) (RsContext, RsScript, uint32_t);
     76 typedef void (*ScriptInvokeVFnPtr) (RsContext, RsScript, uint32_t, const void*, size_t);
     77 typedef void (*ScriptForEachFnPtr) (RsContext, RsScript, uint32_t, RsAllocation, RsAllocation, const void*, size_t, const RsScriptCall*, size_t);
     78 typedef void (*ScriptSetVarIFnPtr) (RsContext, RsScript, uint32_t, int);
     79 typedef void (*ScriptSetVarObjFnPtr) (RsContext, RsScript, uint32_t, RsObjectBase);
     80 typedef void (*ScriptSetVarJFnPtr) (RsContext, RsScript, uint32_t, int64_t);
     81 typedef void (*ScriptSetVarFFnPtr) (RsContext, RsScript, uint32_t, float);
     82 typedef void (*ScriptSetVarDFnPtr) (RsContext, RsScript, uint32_t, double);
     83 typedef void (*ScriptSetVarVFnPtr) (RsContext, RsScript, uint32_t, const void*, size_t);
     84 typedef void (*ScriptGetVarVFnPtr) (RsContext, RsScript, uint32_t, void*, size_t);
     85 typedef void (*ScriptSetVarVEFnPtr) (RsContext, RsScript, uint32_t, const void*, size_t, RsElement, const uint32_t*, size_t);
     86 typedef RsScript (*ScriptCCreateFnPtr) (RsContext, const char*, size_t, const char*, size_t, const char*, size_t);
     87 typedef RsScript (*ScriptIntrinsicCreateFnPtr) (RsContext, uint32_t id, RsElement);
     88 typedef RsScriptKernelID (*ScriptKernelIDCreateFnPtr) (RsContext, RsScript, int, int);
     89 typedef RsScriptInvokeID (*ScriptInvokeIDCreateFnPtr) (RsContext, RsScript, int);
     90 typedef RsScriptFieldID (*ScriptFieldIDCreateFnPtr) (RsContext, RsScript, int);
     91 typedef RsScriptGroup (*ScriptGroupCreateFnPtr) (RsContext, RsScriptKernelID*, size_t, RsScriptKernelID*, size_t, RsScriptKernelID*, size_t, RsScriptFieldID*, size_t, const RsType*, size_t);
     92 typedef RsScriptGroup2 (*ScriptGroup2CreateFnPtr)(RsContext, const char*, size_t, const char*, size_t, RsClosure*, size_t);
     93 typedef void (*ScriptGroupSetOutputFnPtr) (RsContext, RsScriptGroup, RsScriptKernelID, RsAllocation);
     94 typedef void (*ScriptGroupSetInputFnPtr) (RsContext, RsScriptGroup, RsScriptKernelID, RsAllocation);
     95 typedef void (*ScriptGroupExecuteFnPtr) (RsContext, RsScriptGroup);
     96 typedef void (*ScriptForEachMultiFnPtr) (RsContext, RsScript, uint32_t, RsAllocation *, size_t, RsAllocation, const void *, size_t, const RsScriptCall *, size_t);
     97 typedef void (*AllocationIoSendFnPtr) (RsContext, RsAllocation);
     98 typedef void (*AllocationIoReceiveFnPtr) (RsContext, RsAllocation);
     99 typedef void * (*AllocationGetPointerFnPtr) (RsContext, RsAllocation, uint32_t lod, RsAllocationCubemapFace face, uint32_t z, uint32_t array, size_t *stride, size_t stride_len);
    100 
    101 struct dispatchTable {
    102     SetNativeLibDirFnPtr SetNativeLibDir;
    103 
    104     // inserted by hand from rs.h
    105     AllocationGetTypeFnPtr AllocationGetType;
    106     TypeGetNativeDataFnPtr TypeGetNativeData;
    107     ElementGetNativeDataFnPtr ElementGetNativeData;
    108     ElementGetSubElementsFnPtr ElementGetSubElements;
    109 
    110     DeviceCreateFnPtr DeviceCreate;
    111     DeviceDestroyFnPtr DeviceDestroy;
    112     DeviceSetConfigFnPtr DeviceSetConfig;
    113     ContextCreateFnPtr ContextCreate;
    114     GetNameFnPtr GetName;
    115 
    116     // generated from rs.spec
    117     ContextDestroyFnPtr ContextDestroy;
    118     ContextGetMessageFnPtr ContextGetMessage;
    119     ContextPeekMessageFnPtr ContextPeekMessage;
    120     ContextSendMessageFnPtr ContextSendMessage;
    121     ContextInitToClientFnPtr ContextInitToClient;
    122     ContextDeinitToClientFnPtr ContextDeinitToClient;
    123     TypeCreateFnPtr TypeCreate;
    124     AllocationCreateTypedFnPtr AllocationCreateTyped;
    125     AllocationCreateFromBitmapFnPtr AllocationCreateFromBitmap;
    126     AllocationCubeCreateFromBitmapFnPtr AllocationCubeCreateFromBitmap;
    127     AllocationGetSurfaceFnPtr AllocationGetSurface;
    128     AllocationSetSurfaceFnPtr AllocationSetSurface;
    129     ClosureCreateFnPtr ClosureCreate;
    130     InvokeClosureCreateFnPtr InvokeClosureCreate;
    131     ClosureSetArgFnPtr ClosureSetArg;
    132     ClosureSetGlobalFnPtr ClosureSetGlobal;
    133     ContextFinishFnPtr ContextFinish;
    134     ContextDumpFnPtr ContextDump;
    135     ContextSetPriorityFnPtr ContextSetPriority;
    136     AssignNameFnPtr AssignName;
    137     ObjDestroyFnPtr ObjDestroy;
    138     ElementCreateFnPtr ElementCreate;
    139     ElementCreate2FnPtr ElementCreate2;
    140     AllocationCopyToBitmapFnPtr AllocationCopyToBitmap;
    141     Allocation1DDataFnPtr Allocation1DData;
    142     Allocation1DElementDataFnPtr Allocation1DElementData;
    143     AllocationElementDataFnPtr AllocationElementData;
    144     Allocation2DDataFnPtr Allocation2DData;
    145     Allocation3DDataFnPtr Allocation3DData;
    146     AllocationGenerateMipmapsFnPtr AllocationGenerateMipmaps;
    147     AllocationReadFnPtr AllocationRead;
    148     Allocation1DReadFnPtr Allocation1DRead;
    149     AllocationElementReadFnPtr AllocationElementRead;
    150     Allocation2DReadFnPtr Allocation2DRead;
    151     Allocation3DReadFnPtr Allocation3DRead;
    152     AllocationSyncAllFnPtr AllocationSyncAll;
    153     AllocationResize1DFnPtr AllocationResize1D;
    154     AllocationCopy2DRangeFnPtr AllocationCopy2DRange;
    155     AllocationCopy3DRangeFnPtr AllocationCopy3DRange;
    156     SamplerCreateFnPtr SamplerCreate;
    157     ScriptBindAllocationFnPtr ScriptBindAllocation;
    158     ScriptSetTimeZoneFnPtr ScriptSetTimeZone;
    159     ScriptInvokeFnPtr ScriptInvoke;
    160     ScriptInvokeVFnPtr ScriptInvokeV;
    161     ScriptForEachFnPtr ScriptForEach;
    162     ScriptSetVarIFnPtr ScriptSetVarI;
    163     ScriptSetVarObjFnPtr ScriptSetVarObj;
    164     ScriptSetVarJFnPtr ScriptSetVarJ;
    165     ScriptSetVarFFnPtr ScriptSetVarF;
    166     ScriptSetVarDFnPtr ScriptSetVarD;
    167     ScriptSetVarVFnPtr ScriptSetVarV;
    168     ScriptGetVarVFnPtr ScriptGetVarV;
    169     ScriptSetVarVEFnPtr ScriptSetVarVE;
    170     ScriptCCreateFnPtr ScriptCCreate;
    171     ScriptIntrinsicCreateFnPtr ScriptIntrinsicCreate;
    172     ScriptKernelIDCreateFnPtr ScriptKernelIDCreate;
    173     ScriptInvokeIDCreateFnPtr ScriptInvokeIDCreate;
    174     ScriptFieldIDCreateFnPtr ScriptFieldIDCreate;
    175     ScriptGroupCreateFnPtr ScriptGroupCreate;
    176     ScriptGroup2CreateFnPtr ScriptGroup2Create;
    177     ScriptGroupSetOutputFnPtr ScriptGroupSetOutput;
    178     ScriptGroupSetInputFnPtr ScriptGroupSetInput;
    179     ScriptGroupExecuteFnPtr ScriptGroupExecute;
    180     ScriptForEachMultiFnPtr ScriptForEachMulti;
    181     AllocationIoSendFnPtr AllocationIoSend;
    182     AllocationIoReceiveFnPtr AllocationIoReceive;
    183     AllocationGetPointerFnPtr AllocationGetPointer;
    184 };
    185 
    186 bool loadSymbols(void* handle, dispatchTable& dispatchTab, int device_api = 0);
    187 
    188 //USAGE_IO for RS Support lib
    189 typedef void (*sAllocationSetSurfaceFnPtr) (JNIEnv *, jobject, RsContext, RsAllocation, RsNativeWindow, dispatchTable);
    190 struct ioSuppDT {
    191     //USAGE_IO_OUTPUT
    192     sAllocationSetSurfaceFnPtr sAllocationSetSurface;
    193 };
    194 
    195 bool loadIOSuppSyms(void* handleIO, ioSuppDT& ioDispatch);
    196 #endif
    197