Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1 | /* |
Stephen Hines | 4419977 | 2012-02-21 20:13:12 -0800 | [diff] [blame] | 2 | * Copyright (C) 2009-2012 The Android Open Source Project |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 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_RS_SCRIPT_C_H |
| 18 | #define ANDROID_RS_SCRIPT_C_H |
| 19 | |
Jean-Luc Brouillet | 2303748 | 2014-03-25 16:27:34 -0700 | [diff] [blame] | 20 | #include "rsEnv.h" |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 21 | #include "rsScript.h" |
| 22 | |
Jean-Luc Brouillet | f4d216e | 2014-06-09 18:04:16 -0700 | [diff] [blame] | 23 | #if !defined(RS_COMPATIBILITY_LIB) && !defined(ANDROID_RS_SERIALIZE) |
Stephen Hines | cbb0b8a | 2011-08-01 15:02:34 -0700 | [diff] [blame] | 24 | #include "bcinfo/BitcodeTranslator.h" |
| 25 | #endif |
Jack Palevich | 1ef8b80 | 2009-05-28 15:53:04 -0700 | [diff] [blame] | 26 | |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 27 | // --------------------------------------------------------------------------- |
| 28 | namespace android { |
| 29 | namespace renderscript { |
| 30 | |
Jack Palevich | 1ef8b80 | 2009-05-28 15:53:04 -0700 | [diff] [blame] | 31 | |
Jean-Luc Brouillet | 2303748 | 2014-03-25 16:27:34 -0700 | [diff] [blame] | 32 | /** This class represents a script compiled from an .rs file. */ |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 33 | class ScriptC : public Script { |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 34 | public: |
Jason Sams | be36bf3 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 35 | typedef int (*RunScript_t)(); |
Jason Sams | 1d54f10 | 2009-09-03 15:43:13 -0700 | [diff] [blame] | 36 | typedef void (*VoidFunc_t)(); |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 37 | |
Jason Sams | e514b45 | 2009-09-25 14:51:22 -0700 | [diff] [blame] | 38 | ScriptC(Context *); |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 39 | virtual ~ScriptC(); |
| 40 | |
Alex Sakhartchouk | b81a0eb | 2011-06-03 10:18:01 -0700 | [diff] [blame] | 41 | virtual void Invoke(Context *rsc, uint32_t slot, const void *data, size_t len); |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 42 | |
Jason Sams | c61346b | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 43 | virtual uint32_t run(Context *); |
| 44 | |
Jason Sams | ace3e01 | 2010-07-15 17:11:13 -0700 | [diff] [blame] | 45 | virtual void runForEach(Context *rsc, |
Stephen Hines | 4419977 | 2012-02-21 20:13:12 -0800 | [diff] [blame] | 46 | uint32_t slot, |
Chris Wailes | 4b3c34e | 2014-06-11 12:00:29 -0700 | [diff] [blame] | 47 | const Allocation ** ains, |
| 48 | size_t inLen, |
| 49 | Allocation * aout, |
| 50 | const void * usr, |
| 51 | size_t usrBytes, |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame] | 52 | const RsScriptCall *sc = nullptr); |
Chris Wailes | 4b3c34e | 2014-06-11 12:00:29 -0700 | [diff] [blame] | 53 | |
Jason Sams | e3150cf | 2012-07-24 18:10:20 -0700 | [diff] [blame] | 54 | virtual void serialize(Context *rsc, OStream *stream) const { } |
Alex Sakhartchouk | b825f67 | 2010-06-04 10:06:50 -0700 | [diff] [blame] | 55 | virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_SCRIPT_C; } |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame] | 56 | static Type *createFromStream(Context *rsc, IStream *stream) { return nullptr; } |
Jason Sams | c61346b | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 57 | |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 58 | bool runCompiler(Context *rsc, const char *resName, const char *cacheDir, |
| 59 | const uint8_t *bitcode, size_t bitcodeLen); |
| 60 | |
Jason Sams | cdfdb8f | 2011-03-17 16:12:47 -0700 | [diff] [blame] | 61 | //protected: |
Jason Sams | c61346b | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 62 | void setupScript(Context *); |
| 63 | void setupGLState(Context *); |
Stephen Hines | f6af3bd | 2014-12-23 17:47:43 -0800 | [diff] [blame] | 64 | |
| 65 | #if !defined(RS_COMPATIBILITY_LIB) |
| 66 | static bool createCacheDir(const char *cacheDir); |
| 67 | #endif |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 68 | private: |
Jean-Luc Brouillet | f4d216e | 2014-06-09 18:04:16 -0700 | [diff] [blame] | 69 | #if !defined(RS_COMPATIBILITY_LIB) && !defined(ANDROID_RS_SERIALIZE) |
Stephen Hines | cbb0b8a | 2011-08-01 15:02:34 -0700 | [diff] [blame] | 70 | bcinfo::BitcodeTranslator *BT; |
| 71 | #endif |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 72 | }; |
| 73 | |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 74 | } |
| 75 | } |
| 76 | #endif |