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