rsDispatch.h revision eb9aa675754c49f613c6ad71d41472b30f38b007
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 RsScriptInvokeID (*ScriptInvokeIDCreateFnPtr) (RsContext, RsScript, int); 86typedef RsScriptFieldID (*ScriptFieldIDCreateFnPtr) (RsContext, RsScript, int); 87typedef RsScriptGroup (*ScriptGroupCreateFnPtr) (RsContext, RsScriptKernelID*, size_t, RsScriptKernelID*, size_t, RsScriptKernelID*, size_t, RsScriptFieldID*, size_t, const RsType*, size_t); 88typedef RsScriptGroup2 (*ScriptGroup2CreateFnPtr)(RsContext, RsClosure*, size_t); 89typedef void (*ScriptGroupSetOutputFnPtr) (RsContext, RsScriptGroup, RsScriptKernelID, RsAllocation); 90typedef void (*ScriptGroupSetInputFnPtr) (RsContext, RsScriptGroup, RsScriptKernelID, RsAllocation); 91typedef void (*ScriptGroupExecuteFnPtr) (RsContext, RsScriptGroup); 92typedef void (*AllocationIoSendFnPtr) (RsContext, RsAllocation); 93typedef void (*AllocationIoReceiveFnPtr) (RsContext, RsAllocation); 94typedef void * (*AllocationGetPointerFnPtr) (RsContext, RsAllocation, uint32_t lod, RsAllocationCubemapFace face, uint32_t z, uint32_t array, size_t *stride, size_t stride_len); 95 96struct dispatchTable { 97 SetNativeLibDirFnPtr SetNativeLibDir; 98 99 // inserted by hand from rs.h 100 AllocationGetTypeFnPtr AllocationGetType; 101 TypeGetNativeDataFnPtr TypeGetNativeData; 102 ElementGetNativeDataFnPtr ElementGetNativeData; 103 ElementGetSubElementsFnPtr ElementGetSubElements; 104 105 DeviceCreateFnPtr DeviceCreate; 106 DeviceDestroyFnPtr DeviceDestroy; 107 DeviceSetConfigFnPtr DeviceSetConfig; 108 ContextCreateFnPtr ContextCreate; 109 GetNameFnPtr GetName; 110 111 // generated from rs.spec 112 ContextDestroyFnPtr ContextDestroy; 113 ContextGetMessageFnPtr ContextGetMessage; 114 ContextPeekMessageFnPtr ContextPeekMessage; 115 ContextSendMessageFnPtr ContextSendMessage; 116 ContextInitToClientFnPtr ContextInitToClient; 117 ContextDeinitToClientFnPtr ContextDeinitToClient; 118 TypeCreateFnPtr TypeCreate; 119 AllocationCreateTypedFnPtr AllocationCreateTyped; 120 AllocationCreateFromBitmapFnPtr AllocationCreateFromBitmap; 121 AllocationCubeCreateFromBitmapFnPtr AllocationCubeCreateFromBitmap; 122 AllocationGetSurfaceFnPtr AllocationGetSurface; 123 AllocationSetSurfaceFnPtr AllocationSetSurface; 124 ClosureCreateFnPtr ClosureCreate; 125 ClosureSetArgFnPtr ClosureSetArg; 126 ClosureSetGlobalFnPtr ClosureSetGlobal; 127 ContextFinishFnPtr ContextFinish; 128 ContextDumpFnPtr ContextDump; 129 ContextSetPriorityFnPtr ContextSetPriority; 130 AssignNameFnPtr AssignName; 131 ObjDestroyFnPtr ObjDestroy; 132 ElementCreateFnPtr ElementCreate; 133 ElementCreate2FnPtr ElementCreate2; 134 AllocationCopyToBitmapFnPtr AllocationCopyToBitmap; 135 Allocation1DDataFnPtr Allocation1DData; 136 Allocation1DElementDataFnPtr Allocation1DElementData; 137 Allocation2DDataFnPtr Allocation2DData; 138 Allocation3DDataFnPtr Allocation3DData; 139 AllocationGenerateMipmapsFnPtr AllocationGenerateMipmaps; 140 AllocationReadFnPtr AllocationRead; 141 Allocation1DReadFnPtr Allocation1DRead; 142 Allocation2DReadFnPtr Allocation2DRead; 143 AllocationSyncAllFnPtr AllocationSyncAll; 144 AllocationResize1DFnPtr AllocationResize1D; 145 AllocationCopy2DRangeFnPtr AllocationCopy2DRange; 146 AllocationCopy3DRangeFnPtr AllocationCopy3DRange; 147 SamplerCreateFnPtr SamplerCreate; 148 ScriptBindAllocationFnPtr ScriptBindAllocation; 149 ScriptSetTimeZoneFnPtr ScriptSetTimeZone; 150 ScriptInvokeFnPtr ScriptInvoke; 151 ScriptInvokeVFnPtr ScriptInvokeV; 152 ScriptForEachFnPtr ScriptForEach; 153 ScriptSetVarIFnPtr ScriptSetVarI; 154 ScriptSetVarObjFnPtr ScriptSetVarObj; 155 ScriptSetVarJFnPtr ScriptSetVarJ; 156 ScriptSetVarFFnPtr ScriptSetVarF; 157 ScriptSetVarDFnPtr ScriptSetVarD; 158 ScriptSetVarVFnPtr ScriptSetVarV; 159 ScriptGetVarVFnPtr ScriptGetVarV; 160 ScriptSetVarVEFnPtr ScriptSetVarVE; 161 ScriptCCreateFnPtr ScriptCCreate; 162 ScriptIntrinsicCreateFnPtr ScriptIntrinsicCreate; 163 ScriptKernelIDCreateFnPtr ScriptKernelIDCreate; 164 ScriptInvokeIDCreateFnPtr ScriptInvokeIDCreate; 165 ScriptFieldIDCreateFnPtr ScriptFieldIDCreate; 166 ScriptGroupCreateFnPtr ScriptGroupCreate; 167 ScriptGroup2CreateFnPtr ScriptGroup2Create; 168 ScriptGroupSetOutputFnPtr ScriptGroupSetOutput; 169 ScriptGroupSetInputFnPtr ScriptGroupSetInput; 170 ScriptGroupExecuteFnPtr ScriptGroupExecute; 171 AllocationIoSendFnPtr AllocationIoSend; 172 AllocationIoReceiveFnPtr AllocationIoReceive; 173 AllocationGetPointerFnPtr AllocationGetPointer; 174}; 175 176bool loadSymbols(void* handle, dispatchTable& dispatchTab); 177 178//USAGE_IO for RS Support lib 179typedef void (*sAllocationSetSurfaceFnPtr) (JNIEnv *, jobject, RsContext, RsAllocation, RsNativeWindow, dispatchTable); 180struct ioSuppDT { 181 //USAGE_IO_OUTPUT 182 sAllocationSetSurfaceFnPtr sAllocationSetSurface; 183}; 184 185bool loadIOSuppSyms(void* handleIO, ioSuppDT& ioDispatch); 186#endif 187