2009-05-22 14:03:28 -07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2009 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ANDROID_RS_SCRIPT_C_H
|
|
|
|
#define ANDROID_RS_SCRIPT_C_H
|
|
|
|
|
|
|
|
#include "rsScript.h"
|
|
|
|
|
|
|
|
#include "RenderScriptEnv.h"
|
|
|
|
|
2011-08-01 15:02:34 -07:00
|
|
|
#ifndef ANDROID_RS_SERIALIZE
|
|
|
|
#include "bcinfo/BitcodeTranslator.h"
|
|
|
|
#endif
|
2009-05-28 15:53:04 -07:00
|
|
|
|
2009-05-22 14:03:28 -07:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
namespace android {
|
|
|
|
namespace renderscript {
|
|
|
|
|
2009-05-28 15:53:04 -07:00
|
|
|
|
2010-11-09 17:00:54 -08:00
|
|
|
class ScriptC : public Script {
|
2009-05-22 14:03:28 -07:00
|
|
|
public:
|
2010-05-11 14:03:58 -07:00
|
|
|
typedef int (*RunScript_t)();
|
2009-09-03 15:43:13 -07:00
|
|
|
typedef void (*VoidFunc_t)();
|
2009-05-22 14:03:28 -07:00
|
|
|
|
2009-09-25 14:51:22 -07:00
|
|
|
ScriptC(Context *);
|
2009-05-22 14:03:28 -07:00
|
|
|
virtual ~ScriptC();
|
|
|
|
|
|
|
|
|
2010-05-17 14:55:34 -07:00
|
|
|
const Allocation *ptrToAllocation(const void *) const;
|
|
|
|
|
2010-05-19 17:22:57 -07:00
|
|
|
|
2011-06-03 10:18:01 -07:00
|
|
|
virtual void Invoke(Context *rsc, uint32_t slot, const void *data, size_t len);
|
2010-05-19 17:22:57 -07:00
|
|
|
|
2010-05-28 18:23:22 -07:00
|
|
|
virtual uint32_t run(Context *);
|
|
|
|
|
2010-07-15 17:11:13 -07:00
|
|
|
virtual void runForEach(Context *rsc,
|
|
|
|
const Allocation * ain,
|
|
|
|
Allocation * aout,
|
|
|
|
const void * usr,
|
2011-04-20 15:09:01 -07:00
|
|
|
size_t usrBytes,
|
2010-07-15 17:11:13 -07:00
|
|
|
const RsScriptCall *sc = NULL);
|
2010-05-28 18:23:22 -07:00
|
|
|
|
2010-05-21 12:53:13 -07:00
|
|
|
virtual void serialize(OStream *stream) const { }
|
2010-06-04 10:06:50 -07:00
|
|
|
virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_SCRIPT_C; }
|
2010-05-21 12:53:13 -07:00
|
|
|
static Type *createFromStream(Context *rsc, IStream *stream) { return NULL; }
|
2010-05-28 18:23:22 -07:00
|
|
|
|
2011-03-16 16:29:28 -07:00
|
|
|
bool runCompiler(Context *rsc, const char *resName, const char *cacheDir,
|
|
|
|
const uint8_t *bitcode, size_t bitcodeLen);
|
|
|
|
|
2011-03-17 16:12:47 -07:00
|
|
|
//protected:
|
2010-05-28 18:23:22 -07:00
|
|
|
void setupScript(Context *);
|
|
|
|
void setupGLState(Context *);
|
|
|
|
Script * setTLS(Script *);
|
2011-08-01 15:02:34 -07:00
|
|
|
private:
|
|
|
|
#ifndef ANDROID_RS_SERIALIZE
|
|
|
|
bcinfo::BitcodeTranslator *BT;
|
|
|
|
#endif
|
2009-05-22 14:03:28 -07:00
|
|
|
};
|
|
|
|
|
2010-11-09 17:00:54 -08:00
|
|
|
class ScriptCState {
|
2009-05-22 14:03:28 -07:00
|
|
|
public:
|
|
|
|
ScriptCState();
|
|
|
|
~ScriptCState();
|
|
|
|
|
2011-01-23 17:48:45 -08:00
|
|
|
char * mScriptText;
|
|
|
|
size_t mScriptLen;
|
2009-05-22 14:03:28 -07:00
|
|
|
|
2009-07-16 15:08:06 -07:00
|
|
|
struct SymbolTable_t {
|
|
|
|
const char * mName;
|
|
|
|
void * mPtr;
|
2010-11-01 14:26:30 -07:00
|
|
|
bool threadable;
|
2009-07-16 15:08:06 -07:00
|
|
|
};
|
|
|
|
static const SymbolTable_t * lookupSymbol(const char *);
|
2010-05-18 13:35:45 -07:00
|
|
|
static const SymbolTable_t * lookupSymbolCL(const char *);
|
|
|
|
static const SymbolTable_t * lookupSymbolGL(const char *);
|
2009-05-22 14:03:28 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|