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