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