rsCpuScript.h revision f218bf115af4ae4fd79adbb8842608b308a4cf07
1/* 2 * Copyright (C) 2011-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 RSD_BCC_H 18#define RSD_BCC_H 19 20#include <rs_hal.h> 21#include <rsRuntime.h> 22 23#include "rsCpuCore.h" 24 25namespace bcc { 26 class BCCContext; 27 class RSCompilerDriver; 28 class RSExecutable; 29} 30 31namespace android { 32namespace renderscript { 33 34 35 36class RsdCpuScriptImpl : public RsdCpuReferenceImpl::CpuScript { 37public: 38 typedef void (*outer_foreach_t)( 39 const RsForEachStubParamStruct *, 40 uint32_t x1, uint32_t x2, 41 uint32_t instep, uint32_t outstep); 42 43 bool init(char const *resName, char const *cacheDir, 44 uint8_t const *bitcode, size_t bitcodeSize, uint32_t flags); 45 virtual void populateScript(Script *); 46 47 virtual void invokeFunction(uint32_t slot, const void *params, size_t paramLength); 48 virtual int invokeRoot(); 49 virtual void invokeForEach(uint32_t slot, 50 const Allocation * ain, 51 Allocation * aout, 52 const void * usr, 53 uint32_t usrLen, 54 const RsScriptCall *sc); 55 virtual void invokeInit(); 56 virtual void invokeFreeChildren(); 57 58 virtual void setGlobalVar(uint32_t slot, const void *data, size_t dataLength); 59 virtual void setGlobalVarWithElemDims(uint32_t slot, const void *data, size_t dataLength, 60 const Element *e, const size_t *dims, size_t dimLength); 61 virtual void setGlobalBind(uint32_t slot, Allocation *data); 62 virtual void setGlobalObj(uint32_t slot, ObjectBase *data); 63 64 65 virtual ~RsdCpuScriptImpl(); 66 RsdCpuScriptImpl(RsdCpuReferenceImpl *ctx, const Script *s); 67 68 const Script * getScript() {return mScript;} 69 70 void forEachMtlsSetup(const Allocation * ain, Allocation * aout, 71 const void * usr, uint32_t usrLen, 72 const RsScriptCall *sc, MTLaunchStruct *mtls); 73 virtual void forEachKernelSetup(uint32_t slot, MTLaunchStruct *mtls); 74 75 76 const RsdCpuReference::CpuSymbol * lookupSymbolMath(const char *sym); 77 static void * lookupRuntimeStub(void* pContext, char const* name); 78 79 virtual Allocation * getAllocationForPointer(const void *ptr) const; 80 81 virtual void * getRSExecutable() { return mExecutable; } 82 83protected: 84 RsdCpuReferenceImpl *mCtx; 85 const Script *mScript; 86 87 int (*mRoot)(); 88 int (*mRootExpand)(); 89 void (*mInit)(); 90 void (*mFreeChildren)(); 91 92 bcc::BCCContext *mCompilerContext; 93 bcc::RSCompilerDriver *mCompilerDriver; 94 bcc::RSExecutable *mExecutable; 95 96 Allocation **mBoundAllocs; 97 void * mIntrinsicData; 98 bool mIsThreadable; 99 100}; 101 102 103Allocation * rsdScriptGetAllocationForPointer( 104 const Context *dc, 105 const Script *script, 106 const void *); 107 108 109 110} 111} 112 113#endif 114