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