blob: 01fbcafd809880a8702928166077058006c1d980 [file] [log] [blame]
Jason Sams709a0972012-11-15 18:18:04 -08001/*
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
Jean-Luc Brouillet9ab50942014-06-18 18:10:32 -07007 *
Jason Sams709a0972012-11-15 18:18:04 -08008 * 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
Jason Sams709a0972012-11-15 18:18:04 -080017#include "rsCpuCore.h"
Jason Sams709a0972012-11-15 18:18:04 -080018#include "rsCpuScript.h"
Jason Sams709a0972012-11-15 18:18:04 -080019
Jason Sams110f1812013-03-14 16:02:18 -070020#ifdef RS_COMPATIBILITY_LIB
Jason Sams110f1812013-03-14 16:02:18 -070021 #include <stdio.h>
Stephen Hinesee48c0b2013-10-30 17:48:30 -070022 #include <sys/stat.h>
Stephen Hinesc2c11cc2013-07-19 01:07:42 -070023 #include <unistd.h>
Jason Sams110f1812013-03-14 16:02:18 -070024#else
25 #include <bcc/BCCContext.h>
Stephen Hines82e0a672014-05-05 15:40:56 -070026 #include <bcc/Config/Config.h>
Jason Sams110f1812013-03-14 16:02:18 -070027 #include <bcc/Renderscript/RSCompilerDriver.h>
Jason Sams110f1812013-03-14 16:02:18 -070028 #include <bcc/Renderscript/RSInfo.h>
Stephen Hinesb58d9ad2013-06-19 19:26:19 -070029 #include <bcinfo/MetadataExtractor.h>
Stephen Hinesba17ae42013-06-05 17:18:04 -070030 #include <cutils/properties.h>
Stephen Hinesb58d9ad2013-06-19 19:26:19 -070031
32 #include <sys/types.h>
33 #include <sys/wait.h>
34 #include <unistd.h>
Stephen Hines00511322014-01-31 11:20:23 -080035
36 #include <string>
37 #include <vector>
Jason Sams110f1812013-03-14 16:02:18 -070038#endif
Jason Sams709a0972012-11-15 18:18:04 -080039
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -080040#include <set>
41#include <string>
42#include <dlfcn.h>
43#include <stdlib.h>
44#include <string.h>
45#include <fstream>
46#include <iostream>
47
48#ifdef __LP64__
49#define SYSLIBPATH "/system/lib64"
50#else
51#define SYSLIBPATH "/system/lib"
52#endif
53
Stephen Hinesba17ae42013-06-05 17:18:04 -070054namespace {
Stephen Hinesc2c11cc2013-07-19 01:07:42 -070055
56// Create a len length string containing random characters from [A-Za-z0-9].
57static std::string getRandomString(size_t len) {
58 char buf[len + 1];
59 for (size_t i = 0; i < len; i++) {
60 uint32_t r = arc4random() & 0xffff;
61 r %= 62;
62 if (r < 26) {
63 // lowercase
64 buf[i] = 'a' + r;
65 } else if (r < 52) {
66 // uppercase
67 buf[i] = 'A' + (r - 26);
68 } else {
69 // Use a number
70 buf[i] = '0' + (r - 52);
71 }
72 }
73 buf[len] = '\0';
74 return std::string(buf);
75}
76
Stephen Hinesee48c0b2013-10-30 17:48:30 -070077// Check if a path exists and attempt to create it if it doesn't.
78static bool ensureCacheDirExists(const char *path) {
79 if (access(path, R_OK | W_OK | X_OK) == 0) {
80 // Done if we can rwx the directory
81 return true;
82 }
83 if (mkdir(path, 0700) == 0) {
84 return true;
85 }
86 return false;
87}
88
Stephen Hines7d774852014-10-01 12:57:57 -070089// Copy the file named \p srcFile to \p dstFile.
90// Return 0 on success and -1 if anything wasn't copied.
91static int copyFile(const char *dstFile, const char *srcFile) {
92 std::ifstream srcStream(srcFile);
93 if (!srcStream) {
94 ALOGE("Could not verify or read source file: %s", srcFile);
95 return -1;
96 }
97 std::ofstream dstStream(dstFile);
98 if (!dstStream) {
99 ALOGE("Could not verify or write destination file: %s", dstFile);
100 return -1;
101 }
102 dstStream << srcStream.rdbuf();
103 if (!dstStream) {
104 ALOGE("Could not write destination file: %s", dstFile);
105 return -1;
106 }
107
108 srcStream.close();
109 dstStream.close();
110
111 return 0;
112}
113
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800114static std::string findSharedObjectName(const char *cacheDir,
115 const char *resName) {
116
Stephen Hinesc2c11cc2013-07-19 01:07:42 -0700117#ifndef RS_SERVER
118 std::string scriptSOName(cacheDir);
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800119#ifdef RS_COMPATIBILITY_LIB
Stephen Hinesc2c11cc2013-07-19 01:07:42 -0700120 size_t cutPos = scriptSOName.rfind("cache");
121 if (cutPos != std::string::npos) {
122 scriptSOName.erase(cutPos);
123 } else {
124 ALOGE("Found peculiar cacheDir (missing \"cache\"): %s", cacheDir);
125 }
126 scriptSOName.append("/lib/librs.");
127#else
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800128 scriptSOName.append("/librs.");
129#endif
130
131#else
Stephen Hinesc2c11cc2013-07-19 01:07:42 -0700132 std::string scriptSOName("lib");
133#endif
134 scriptSOName.append(resName);
135 scriptSOName.append(".so");
136
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800137 return scriptSOName;
138}
139
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800140#ifndef RS_COMPATIBILITY_LIB
141
Stephen Hinesba17ae42013-06-05 17:18:04 -0700142static bool is_force_recompile() {
143#ifdef RS_SERVER
144 return false;
145#else
146 char buf[PROPERTY_VALUE_MAX];
147
148 // Re-compile if floating point precision has been overridden.
149 property_get("debug.rs.precision", buf, "");
150 if (buf[0] != '\0') {
151 return true;
152 }
153
154 // Re-compile if debug.rs.forcerecompile is set.
155 property_get("debug.rs.forcerecompile", buf, "0");
156 if ((::strcmp(buf, "1") == 0) || (::strcmp(buf, "true") == 0)) {
157 return true;
158 } else {
159 return false;
160 }
161#endif // RS_SERVER
162}
Stephen Hinesb58d9ad2013-06-19 19:26:19 -0700163
Chris Wailes6847e732014-08-11 17:30:51 -0700164static void setCompileArguments(std::vector<const char*>* args,
165 const std::string& bcFileName,
166 const char* cacheDir, const char* resName,
167 const char* core_lib, bool useRSDebugContext,
168 const char* bccPluginName) {
Jean-Luc Brouillet40e35cd2014-06-25 18:21:45 -0700169 rsAssert(cacheDir && resName && core_lib);
Yang Nida0f0692015-01-12 13:03:40 -0800170 args->push_back(android::renderscript::RsdCpuScriptImpl::BCC_EXE_PATH);
Tim Murray687cfe82015-01-08 14:59:38 -0800171 args->push_back("-unroll-runtime");
172 args->push_back("-scalarize-load-store");
Jean-Luc Brouillet40e35cd2014-06-25 18:21:45 -0700173 args->push_back("-o");
174 args->push_back(resName);
175 args->push_back("-output_path");
176 args->push_back(cacheDir);
177 args->push_back("-bclib");
178 args->push_back(core_lib);
179 args->push_back("-mtriple");
180 args->push_back(DEFAULT_TARGET_TRIPLE_STRING);
181
Tim Murray358ffb82014-12-09 11:53:06 -0800182 // Enable workaround for A53 codegen by default.
183#if defined(__aarch64__) && !defined(DISABLE_A53_WORKAROUND)
184 args->push_back("-aarch64-fix-cortex-a53-835769");
185#endif
186
Jean-Luc Brouillet40e35cd2014-06-25 18:21:45 -0700187 // Execute the bcc compiler.
188 if (useRSDebugContext) {
189 args->push_back("-rs-debug-ctx");
190 } else {
191 // Only load additional libraries for compiles that don't use
192 // the debug context.
193 if (bccPluginName && strlen(bccPluginName) > 0) {
194 args->push_back("-load");
195 args->push_back(bccPluginName);
196 }
197 }
198
Stephen Hines45e753a2015-01-19 20:58:44 -0800199 args->push_back("-fPIC");
200 args->push_back("-embedRSInfo");
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800201
Chris Wailes6847e732014-08-11 17:30:51 -0700202 args->push_back(bcFileName.c_str());
Chris Wailes44bef6f2014-08-12 13:51:10 -0700203 args->push_back(nullptr);
Jean-Luc Brouillet40e35cd2014-06-25 18:21:45 -0700204}
205
Chris Wailes6847e732014-08-11 17:30:51 -0700206static bool compileBitcode(const std::string &bcFileName,
Stephen Hinesb58d9ad2013-06-19 19:26:19 -0700207 const char *bitcode,
208 size_t bitcodeSize,
Chris Wailes6847e732014-08-11 17:30:51 -0700209 const char **compileArguments,
210 const std::string &compileCommandLine) {
Jean-Luc Brouillet40e35cd2014-06-25 18:21:45 -0700211 rsAssert(bitcode && bitcodeSize);
Stephen Hinesb58d9ad2013-06-19 19:26:19 -0700212
Chris Wailes6847e732014-08-11 17:30:51 -0700213 FILE *bcfile = fopen(bcFileName.c_str(), "w");
Stephen Hinesb58d9ad2013-06-19 19:26:19 -0700214 if (!bcfile) {
Chris Wailes6847e732014-08-11 17:30:51 -0700215 ALOGE("Could not write to %s", bcFileName.c_str());
Stephen Hinesb58d9ad2013-06-19 19:26:19 -0700216 return false;
217 }
218 size_t nwritten = fwrite(bitcode, 1, bitcodeSize, bcfile);
219 fclose(bcfile);
220 if (nwritten != bitcodeSize) {
221 ALOGE("Could not write %zu bytes to %s", bitcodeSize,
Chris Wailes6847e732014-08-11 17:30:51 -0700222 bcFileName.c_str());
Stephen Hinesb58d9ad2013-06-19 19:26:19 -0700223 return false;
224 }
225
226 pid_t pid = fork();
Stephen Hines00511322014-01-31 11:20:23 -0800227
Stephen Hinesb58d9ad2013-06-19 19:26:19 -0700228 switch (pid) {
229 case -1: { // Error occurred (we attempt no recovery)
230 ALOGE("Couldn't fork for bcc compiler execution");
231 return false;
232 }
233 case 0: { // Child process
Jean-Luc Brouillet40e35cd2014-06-25 18:21:45 -0700234 ALOGV("Invoking BCC with: %s", compileCommandLine.c_str());
Yang Nida0f0692015-01-12 13:03:40 -0800235 execv(android::renderscript::RsdCpuScriptImpl::BCC_EXE_PATH,
236 (char* const*)compileArguments);
Stephen Hines00511322014-01-31 11:20:23 -0800237
Stephen Hines00511322014-01-31 11:20:23 -0800238 ALOGE("execv() failed: %s", strerror(errno));
Stephen Hinesb58d9ad2013-06-19 19:26:19 -0700239 abort();
240 return false;
241 }
242 default: { // Parent process (actual driver)
243 // Wait on child process to finish compiling the source.
244 int status = 0;
245 pid_t w = waitpid(pid, &status, 0);
246 if (w == -1) {
247 ALOGE("Could not wait for bcc compiler");
248 return false;
249 }
250
251 if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {
252 return true;
253 }
254
255 ALOGE("bcc compiler terminated unexpectedly");
256 return false;
257 }
258 }
259}
Stephen Hinesb58d9ad2013-06-19 19:26:19 -0700260
Yang Ni1c44cb62015-01-22 12:02:27 -0800261#endif // !defined(RS_COMPATIBILITY_LIB)
262} // namespace
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800263
Yang Ni1c44cb62015-01-22 12:02:27 -0800264namespace android {
265namespace renderscript {
266
267const char* SharedLibraryUtils::LD_EXE_PATH = "/system/bin/ld.mc";
268const char* SharedLibraryUtils::RS_CACHE_DIR = "com.android.renderscript.cache";
269
270#ifndef RS_COMPATIBILITY_LIB
271
272bool SharedLibraryUtils::createSharedLibrary(const char *cacheDir, const char *resName) {
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800273 std::string sharedLibName = findSharedObjectName(cacheDir, resName);
274 std::string objFileName = cacheDir;
275 objFileName.append("/");
276 objFileName.append(resName);
277 objFileName.append(".o");
278
279 const char *compiler_rt = SYSLIBPATH"/libcompiler_rt.so";
280 std::vector<const char *> args = {
281 LD_EXE_PATH,
282 "-shared",
283 "-nostdlib",
284 compiler_rt,
285 "-mtriple", DEFAULT_TARGET_TRIPLE_STRING,
286 "-L", SYSLIBPATH,
287 "-lRSDriver", "-lm", "-lc",
288 objFileName.c_str(),
289 "-o", sharedLibName.c_str(),
290 nullptr
291 };
292
293 std::string cmdLineStr = bcc::getCommandLine(args.size()-1, args.data());
294
295 pid_t pid = fork();
296
297 switch (pid) {
298 case -1: { // Error occurred (we attempt no recovery)
299 ALOGE("Couldn't fork for linker (%s) execution", LD_EXE_PATH);
300 return false;
301 }
302 case 0: { // Child process
303 ALOGV("Invoking ld.mc with args '%s'", cmdLineStr.c_str());
304 execv(LD_EXE_PATH, (char* const*) args.data());
305
306 ALOGE("execv() failed: %s", strerror(errno));
307 abort();
308 return false;
309 }
310 default: { // Parent process (actual driver)
311 // Wait on child process to finish compiling the source.
312 int status = 0;
313 pid_t w = waitpid(pid, &status, 0);
314 if (w == -1) {
315 ALOGE("Could not wait for linker (%s)", LD_EXE_PATH);
316 return false;
317 }
318
319 if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {
320 return true;
321 }
322
323 ALOGE("Linker (%s) terminated unexpectedly", LD_EXE_PATH);
324 return false;
325 }
326 }
327}
Stephen Hinesba17ae42013-06-05 17:18:04 -0700328
Yang Ni1c44cb62015-01-22 12:02:27 -0800329#endif // RS_COMPATIBILITY_LIB
330
331void* SharedLibraryUtils::loadSharedLibrary(const char *cacheDir, const char *resName) {
332 void *loaded = nullptr;
333
334 std::string scriptSOName = findSharedObjectName(cacheDir, resName);
335
336 // We should check if we can load the library from the standard app
337 // location for shared libraries first.
338 loaded = loadSOHelper(scriptSOName.c_str(), cacheDir, resName);
339
340 if (loaded == nullptr) {
341 ALOGE("Unable to open shared library (%s): %s",
342 scriptSOName.c_str(), dlerror());
343
344#ifdef RS_COMPATIBILITY_LIB
345 // One final attempt to find the library in "/system/lib".
346 // We do this to allow bundled applications to use the compatibility
347 // library fallback path. Those applications don't have a private
348 // library path, so they need to install to the system directly.
349 // Note that this is really just a testing path.
350 std::string scriptSONameSystem("/system/lib/librs.");
351 scriptSONameSystem.append(resName);
352 scriptSONameSystem.append(".so");
353 loaded = loadSOHelper(scriptSONameSystem.c_str(), cacheDir,
354 resName);
355 if (loaded == nullptr) {
356 ALOGE("Unable to open system shared library (%s): %s",
357 scriptSONameSystem.c_str(), dlerror());
358 }
359#endif
360 }
361
362 return loaded;
363}
364
365void* SharedLibraryUtils::loadSOHelper(const char *origName, const char *cacheDir,
366 const char *resName) {
367 // Keep track of which .so libraries have been loaded. Once a library is
368 // in the set (per-process granularity), we must instead make a copy of
369 // the original shared object (randomly named .so file) and load that one
370 // instead. If we don't do this, we end up aliasing global data between
371 // the various Script instances (which are supposed to be completely
372 // independent).
373 static std::set<std::string> LoadedLibraries;
374
375 void *loaded = nullptr;
376
377 // Skip everything if we don't even have the original library available.
378 if (access(origName, F_OK) != 0) {
379 return nullptr;
380 }
381
382 // Common path is that we have not loaded this Script/library before.
383 if (LoadedLibraries.find(origName) == LoadedLibraries.end()) {
384 loaded = dlopen(origName, RTLD_NOW | RTLD_LOCAL);
385 if (loaded) {
386 LoadedLibraries.insert(origName);
387 }
388 return loaded;
389 }
390
391 std::string newName(cacheDir);
392
393 // Append RS_CACHE_DIR only if it is not found in cacheDir
394 // In driver mode, RS_CACHE_DIR is already appended to cacheDir.
395 if (newName.find(RS_CACHE_DIR) == std::string::npos) {
396 newName.append("/");
397 newName.append(RS_CACHE_DIR);
398 newName.append("/");
399 }
400
401 if (!ensureCacheDirExists(newName.c_str())) {
402 ALOGE("Could not verify or create cache dir: %s", cacheDir);
403 return nullptr;
404 }
405
406 // Construct an appropriately randomized filename for the copy.
407 newName.append("librs.");
408 newName.append(resName);
409 newName.append("#");
410 newName.append(getRandomString(6)); // 62^6 potential filename variants.
411 newName.append(".so");
412
413 int r = copyFile(newName.c_str(), origName);
414 if (r != 0) {
415 ALOGE("Could not create copy %s -> %s", origName, newName.c_str());
416 return nullptr;
417 }
418 loaded = dlopen(newName.c_str(), RTLD_NOW | RTLD_LOCAL);
419 r = unlink(newName.c_str());
420 if (r != 0) {
421 ALOGE("Could not unlink copy %s", newName.c_str());
422 }
423 if (loaded) {
424 LoadedLibraries.insert(newName.c_str());
425 }
426
427 return loaded;
428}
Jason Sams709a0972012-11-15 18:18:04 -0800429
Yang Nida0f0692015-01-12 13:03:40 -0800430const char* RsdCpuScriptImpl::BCC_EXE_PATH = "/system/bin/bcc";
431
Jason Sams110f1812013-03-14 16:02:18 -0700432#define MAXLINE 500
433#define MAKE_STR_HELPER(S) #S
434#define MAKE_STR(S) MAKE_STR_HELPER(S)
435#define EXPORT_VAR_STR "exportVarCount: "
Jason Sams110f1812013-03-14 16:02:18 -0700436#define EXPORT_FUNC_STR "exportFuncCount: "
Jason Sams110f1812013-03-14 16:02:18 -0700437#define EXPORT_FOREACH_STR "exportForEachCount: "
Jason Sams110f1812013-03-14 16:02:18 -0700438#define OBJECT_SLOT_STR "objectSlotCount: "
Pirama Arumuga Nainar577194a2015-01-23 14:27:33 -0800439#define PRAGMA_STR "pragmaCount: "
Pirama Arumuga Nainar68173de2015-01-28 12:12:36 -0800440#define THREADABLE_STR "isThreadable: "
Jason Sams110f1812013-03-14 16:02:18 -0700441
442// Copy up to a newline or size chars from str -> s, updating str
Chris Wailes44bef6f2014-08-12 13:51:10 -0700443// Returns s when successful and nullptr when '\0' is finally reached.
Jason Sams110f1812013-03-14 16:02:18 -0700444static char* strgets(char *s, int size, const char **ppstr) {
445 if (!ppstr || !*ppstr || **ppstr == '\0' || size < 1) {
Chris Wailes44bef6f2014-08-12 13:51:10 -0700446 return nullptr;
Jason Sams110f1812013-03-14 16:02:18 -0700447 }
448
449 int i;
450 for (i = 0; i < (size - 1); i++) {
451 s[i] = **ppstr;
452 (*ppstr)++;
453 if (s[i] == '\0') {
454 return s;
455 } else if (s[i] == '\n') {
456 s[i+1] = '\0';
457 return s;
458 }
459 }
460
461 // size has been exceeded.
462 s[i] = '\0';
463
464 return s;
465}
Jason Sams709a0972012-11-15 18:18:04 -0800466
467RsdCpuScriptImpl::RsdCpuScriptImpl(RsdCpuReferenceImpl *ctx, const Script *s) {
468 mCtx = ctx;
469 mScript = s;
470
Chris Wailes44bef6f2014-08-12 13:51:10 -0700471 mScriptSO = nullptr;
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800472
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800473#ifndef RS_COMPATIBILITY_LIB
Chris Wailes44bef6f2014-08-12 13:51:10 -0700474 mCompilerDriver = nullptr;
Jason Sams110f1812013-03-14 16:02:18 -0700475#endif
476
Tim Murraye195a3f2014-03-13 15:04:58 -0700477
Chris Wailes44bef6f2014-08-12 13:51:10 -0700478 mRoot = nullptr;
479 mRootExpand = nullptr;
480 mInit = nullptr;
481 mFreeChildren = nullptr;
Yang Nid9bae682015-01-20 15:31:15 -0800482 mScriptExec = nullptr;
Jason Sams709a0972012-11-15 18:18:04 -0800483
Chris Wailes44bef6f2014-08-12 13:51:10 -0700484 mBoundAllocs = nullptr;
485 mIntrinsicData = nullptr;
Jason Sams709a0972012-11-15 18:18:04 -0800486 mIsThreadable = true;
487}
488
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800489bool RsdCpuScriptImpl::storeRSInfoFromSO() {
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800490 mRoot = (RootFunc_t) dlsym(mScriptSO, "root");
491 if (mRoot) {
492 //ALOGE("Found root(): %p", mRoot);
493 }
494 mRootExpand = (RootFunc_t) dlsym(mScriptSO, "root.expand");
495 if (mRootExpand) {
496 //ALOGE("Found root.expand(): %p", mRootExpand);
497 }
498 mInit = (InvokeFunc_t) dlsym(mScriptSO, "init");
499 if (mInit) {
500 //ALOGE("Found init(): %p", mInit);
501 }
502 mFreeChildren = (InvokeFunc_t) dlsym(mScriptSO, ".rs.dtor");
503 if (mFreeChildren) {
504 //ALOGE("Found .rs.dtor(): %p", mFreeChildren);
505 }
506
Yang Nid9bae682015-01-20 15:31:15 -0800507 mScriptExec = ScriptExecutable::createFromSharedObject(
508 mCtx->getContext(), mScriptSO);
509
510 if (mScriptExec == nullptr) {
511 return false;
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800512 }
513
Yang Nid9bae682015-01-20 15:31:15 -0800514 size_t varCount = mScriptExec->getExportedVariableCount();
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800515 if (varCount > 0) {
516 mBoundAllocs = new Allocation *[varCount];
517 memset(mBoundAllocs, 0, varCount * sizeof(*mBoundAllocs));
518 }
519
Pirama Arumuga Nainar68173de2015-01-28 12:12:36 -0800520 mIsThreadable = mScriptExec->getThreadable();
521 //ALOGE("Script isThreadable? %d", mIsThreadable);
522
Yang Nid9bae682015-01-20 15:31:15 -0800523 return true;
524}
525
526ScriptExecutable* ScriptExecutable::createFromSharedObject(
527 Context* RSContext, void* sharedObj) {
528 char line[MAXLINE];
529
530 size_t varCount = 0;
531 size_t funcCount = 0;
532 size_t forEachCount = 0;
533 size_t objectSlotCount = 0;
Pirama Arumuga Nainar577194a2015-01-23 14:27:33 -0800534 size_t pragmaCount = 0;
Pirama Arumuga Nainar68173de2015-01-28 12:12:36 -0800535 bool isThreadable = true;
Yang Nid9bae682015-01-20 15:31:15 -0800536
Yang Nie8f9fba2015-01-30 08:55:10 -0800537 void** fieldAddress = nullptr;
538 bool* fieldIsObject = nullptr;
539 InvokeFunc_t* invokeFunctions = nullptr;
540 ForEachFunc_t* forEachFunctions = nullptr;
541 uint32_t* forEachSignatures = nullptr;
542 const char ** pragmaKeys = nullptr;
543 const char ** pragmaValues = nullptr;
544
Yang Nid9bae682015-01-20 15:31:15 -0800545 const char *rsInfo = (const char *) dlsym(sharedObj, ".rs.info");
546
547 if (strgets(line, MAXLINE, &rsInfo) == nullptr) {
548 return nullptr;
549 }
550 if (sscanf(line, EXPORT_VAR_STR "%zu", &varCount) != 1) {
551 ALOGE("Invalid export var count!: %s", line);
552 return nullptr;
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800553 }
554
Yang Nie8f9fba2015-01-30 08:55:10 -0800555 fieldAddress = new void*[varCount];
556 if (fieldAddress == nullptr) {
557 return nullptr;
558 }
559
560 fieldIsObject = new bool[varCount];
561 if (fieldIsObject == nullptr) {
562 goto error;
563 }
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800564
Yang Nid9bae682015-01-20 15:31:15 -0800565 for (size_t i = 0; i < varCount; ++i) {
566 if (strgets(line, MAXLINE, &rsInfo) == nullptr) {
Yang Nie8f9fba2015-01-30 08:55:10 -0800567 goto error;
Yang Nid9bae682015-01-20 15:31:15 -0800568 }
569 char *c = strrchr(line, '\n');
570 if (c) {
571 *c = '\0';
572 }
573 void* addr = dlsym(sharedObj, line);
574 if (addr == nullptr) {
575 ALOGE("Failed to find variable address for %s: %s",
576 line, dlerror());
577 // Not a critical error if we don't find a global variable.
578 }
Yang Nie8f9fba2015-01-30 08:55:10 -0800579 fieldAddress[i] = addr;
580 fieldIsObject[i] = false;
Yang Nid9bae682015-01-20 15:31:15 -0800581 }
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800582
Yang Nid9bae682015-01-20 15:31:15 -0800583 if (strgets(line, MAXLINE, &rsInfo) == nullptr) {
Yang Nie8f9fba2015-01-30 08:55:10 -0800584 goto error;
Yang Nid9bae682015-01-20 15:31:15 -0800585 }
586 if (sscanf(line, EXPORT_FUNC_STR "%zu", &funcCount) != 1) {
587 ALOGE("Invalid export func count!: %s", line);
Yang Nie8f9fba2015-01-30 08:55:10 -0800588 goto error;
Yang Nid9bae682015-01-20 15:31:15 -0800589 }
590
Yang Nie8f9fba2015-01-30 08:55:10 -0800591 invokeFunctions = new InvokeFunc_t[funcCount];
592 if (invokeFunctions == nullptr) {
593 goto error;
594 }
Yang Nid9bae682015-01-20 15:31:15 -0800595
596 for (size_t i = 0; i < funcCount; ++i) {
597 if (strgets(line, MAXLINE, &rsInfo) == nullptr) {
Yang Nie8f9fba2015-01-30 08:55:10 -0800598 goto error;
Yang Nid9bae682015-01-20 15:31:15 -0800599 }
600 char *c = strrchr(line, '\n');
601 if (c) {
602 *c = '\0';
603 }
604
605 invokeFunctions[i] = (InvokeFunc_t) dlsym(sharedObj, line);
606 if (invokeFunctions[i] == nullptr) {
607 ALOGE("Failed to get function address for %s(): %s",
608 line, dlerror());
Yang Nie8f9fba2015-01-30 08:55:10 -0800609 goto error;
Yang Nid9bae682015-01-20 15:31:15 -0800610 }
611 }
612
613 if (strgets(line, MAXLINE, &rsInfo) == nullptr) {
Yang Nie8f9fba2015-01-30 08:55:10 -0800614 goto error;
Yang Nid9bae682015-01-20 15:31:15 -0800615 }
616 if (sscanf(line, EXPORT_FOREACH_STR "%zu", &forEachCount) != 1) {
617 ALOGE("Invalid export forEach count!: %s", line);
Yang Nie8f9fba2015-01-30 08:55:10 -0800618 goto error;
Yang Nid9bae682015-01-20 15:31:15 -0800619 }
620
Yang Nie8f9fba2015-01-30 08:55:10 -0800621 forEachFunctions = new ForEachFunc_t[forEachCount];
622 if (forEachFunctions == nullptr) {
623 goto error;
624 }
625
626 forEachSignatures = new uint32_t[forEachCount];
627 if (forEachSignatures == nullptr) {
628 goto error;
629 }
Yang Nid9bae682015-01-20 15:31:15 -0800630
631 for (size_t i = 0; i < forEachCount; ++i) {
632 unsigned int tmpSig = 0;
633 char tmpName[MAXLINE];
634
635 if (strgets(line, MAXLINE, &rsInfo) == nullptr) {
Yang Nie8f9fba2015-01-30 08:55:10 -0800636 goto error;
Yang Nid9bae682015-01-20 15:31:15 -0800637 }
638 if (sscanf(line, "%u - %" MAKE_STR(MAXLINE) "s",
639 &tmpSig, tmpName) != 2) {
640 ALOGE("Invalid export forEach!: %s", line);
Yang Nie8f9fba2015-01-30 08:55:10 -0800641 goto error;
Yang Nid9bae682015-01-20 15:31:15 -0800642 }
643
644 // Lookup the expanded ForEach kernel.
645 strncat(tmpName, ".expand", MAXLINE-1-strlen(tmpName));
646 forEachSignatures[i] = tmpSig;
647 forEachFunctions[i] =
648 (ForEachFunc_t) dlsym(sharedObj, tmpName);
649 if (i != 0 && forEachFunctions[i] == nullptr) {
650 // Ignore missing root.expand functions.
651 // root() is always specified at location 0.
652 ALOGE("Failed to find forEach function address for %s: %s",
653 tmpName, dlerror());
Yang Nie8f9fba2015-01-30 08:55:10 -0800654 goto error;
Yang Nid9bae682015-01-20 15:31:15 -0800655 }
656 }
657
658 if (strgets(line, MAXLINE, &rsInfo) == nullptr) {
Yang Nie8f9fba2015-01-30 08:55:10 -0800659 goto error;
Yang Nid9bae682015-01-20 15:31:15 -0800660 }
661 if (sscanf(line, OBJECT_SLOT_STR "%zu", &objectSlotCount) != 1) {
662 ALOGE("Invalid object slot count!: %s", line);
Yang Nie8f9fba2015-01-30 08:55:10 -0800663 goto error;
Yang Nid9bae682015-01-20 15:31:15 -0800664 }
665
Yang Nid9bae682015-01-20 15:31:15 -0800666 for (size_t i = 0; i < objectSlotCount; ++i) {
667 uint32_t varNum = 0;
668 if (strgets(line, MAXLINE, &rsInfo) == nullptr) {
Yang Nie8f9fba2015-01-30 08:55:10 -0800669 goto error;
Yang Nid9bae682015-01-20 15:31:15 -0800670 }
671 if (sscanf(line, "%u", &varNum) != 1) {
672 ALOGE("Invalid object slot!: %s", line);
Yang Nie8f9fba2015-01-30 08:55:10 -0800673 goto error;
Yang Nid9bae682015-01-20 15:31:15 -0800674 }
675
676 if (varNum < varCount) {
677 fieldIsObject[varNum] = true;
678 }
679 }
680
Yang Nie8f9fba2015-01-30 08:55:10 -0800681#ifndef RS_COMPATIBILITY_LIB
Pirama Arumuga Nainar68173de2015-01-28 12:12:36 -0800682 // Do not attempt to read pragmas or isThreadable flag in compat lib path.
683 // Neither is applicable for compat lib
Pirama Arumuga Nainar577194a2015-01-23 14:27:33 -0800684
Pirama Arumuga Nainar577194a2015-01-23 14:27:33 -0800685 if (strgets(line, MAXLINE, &rsInfo) == nullptr) {
Yang Nie8f9fba2015-01-30 08:55:10 -0800686 goto error;
Pirama Arumuga Nainar577194a2015-01-23 14:27:33 -0800687 }
688
689 if (sscanf(line, PRAGMA_STR "%zu", &pragmaCount) != 1) {
690 ALOGE("Invalid pragma count!: %s", line);
Yang Nie8f9fba2015-01-30 08:55:10 -0800691 goto error;
Pirama Arumuga Nainar577194a2015-01-23 14:27:33 -0800692 }
693
Yang Nie8f9fba2015-01-30 08:55:10 -0800694 pragmaKeys = new const char*[pragmaCount];
695 if (pragmaKeys == nullptr) {
696 goto error;
697 }
698
699 pragmaValues = new const char*[pragmaCount];
700 if (pragmaValues == nullptr) {
701 goto error;
702 }
703
704 bzero(pragmaKeys, sizeof(char*) * pragmaCount);
705 bzero(pragmaValues, sizeof(char*) * pragmaCount);
Pirama Arumuga Nainar577194a2015-01-23 14:27:33 -0800706
707 for (size_t i = 0; i < pragmaCount; ++i) {
708 if (strgets(line, MAXLINE, &rsInfo) == nullptr) {
709 ALOGE("Unable to read pragma at index %zu!", i);
Yang Nie8f9fba2015-01-30 08:55:10 -0800710 goto error;
Pirama Arumuga Nainar577194a2015-01-23 14:27:33 -0800711 }
712
713 char key[MAXLINE];
714 char value[MAXLINE] = ""; // initialize in case value is empty
715
716 // pragmas can just have a key and no value. Only check to make sure
717 // that the key is not empty
718 if (sscanf(line, "%" MAKE_STR(MAXLINE) "s - %" MAKE_STR(MAXLINE) "s",
719 key, value) == 0 ||
720 strlen(key) == 0)
721 {
722 ALOGE("Invalid pragma value!: %s", line);
723
Yang Nie8f9fba2015-01-30 08:55:10 -0800724 goto error;
Pirama Arumuga Nainar577194a2015-01-23 14:27:33 -0800725 }
726
727 char *pKey = new char[strlen(key)+1];
728 strcpy(pKey, key);
729 pragmaKeys[i] = pKey;
730
731 char *pValue = new char[strlen(value)+1];
732 strcpy(pValue, value);
733 pragmaValues[i] = pValue;
734 //ALOGE("Pragma %zu: Key: '%s' Value: '%s'", i, pKey, pValue);
735 }
Pirama Arumuga Nainar68173de2015-01-28 12:12:36 -0800736
737 if (strgets(line, MAXLINE, &rsInfo) == nullptr) {
Yang Nie8f9fba2015-01-30 08:55:10 -0800738 goto error;
Pirama Arumuga Nainar68173de2015-01-28 12:12:36 -0800739 }
740
741 char tmpFlag[4];
742 if (sscanf(line, THREADABLE_STR "%4s", tmpFlag) != 1) {
743 ALOGE("Invalid threadable flag!: %s", line);
Yang Nie8f9fba2015-01-30 08:55:10 -0800744 goto error;
Pirama Arumuga Nainar68173de2015-01-28 12:12:36 -0800745 }
Yang Nie8f9fba2015-01-30 08:55:10 -0800746 if (strcmp(tmpFlag, "yes") == 0) {
Pirama Arumuga Nainar68173de2015-01-28 12:12:36 -0800747 isThreadable = true;
Yang Nie8f9fba2015-01-30 08:55:10 -0800748 } else if (strcmp(tmpFlag, "no") == 0) {
Pirama Arumuga Nainar68173de2015-01-28 12:12:36 -0800749 isThreadable = false;
Yang Nie8f9fba2015-01-30 08:55:10 -0800750 } else {
Pirama Arumuga Nainar68173de2015-01-28 12:12:36 -0800751 ALOGE("Invalid threadable flag!: %s", tmpFlag);
Yang Nie8f9fba2015-01-30 08:55:10 -0800752 goto error;
Pirama Arumuga Nainar68173de2015-01-28 12:12:36 -0800753 }
754
Yang Nie8f9fba2015-01-30 08:55:10 -0800755#endif // RS_COMPATIBILITY_LIB
Pirama Arumuga Nainar577194a2015-01-23 14:27:33 -0800756
Yang Nid9bae682015-01-20 15:31:15 -0800757 return new ScriptExecutable(
Yang Nie8f9fba2015-01-30 08:55:10 -0800758 RSContext, fieldAddress, fieldIsObject, varCount,
759 invokeFunctions, funcCount,
760 forEachFunctions, forEachSignatures, forEachCount,
761 pragmaKeys, pragmaValues, pragmaCount,
Pirama Arumuga Nainar68173de2015-01-28 12:12:36 -0800762 isThreadable);
Yang Nie8f9fba2015-01-30 08:55:10 -0800763
764error:
765
766#ifndef RS_COMPATIBILITY_LIB
767 for (size_t idx = 0; idx < pragmaCount; ++idx) {
Yang Nida0f0692015-01-12 13:03:40 -0800768 delete [] pragmaKeys[idx];
769 delete [] pragmaValues[idx];
Yang Nie8f9fba2015-01-30 08:55:10 -0800770 }
771
772 delete[] pragmaValues;
773 delete[] pragmaKeys;
774#endif // RS_COMPATIBILITY_LIB
775
776 delete[] forEachSignatures;
777 delete[] forEachFunctions;
778 delete[] invokeFunctions;
779 delete[] fieldIsObject;
780 delete[] fieldAddress;
781
782 return nullptr;
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800783}
784
Jason Sams709a0972012-11-15 18:18:04 -0800785bool RsdCpuScriptImpl::init(char const *resName, char const *cacheDir,
786 uint8_t const *bitcode, size_t bitcodeSize,
Stephen Hines00511322014-01-31 11:20:23 -0800787 uint32_t flags, char const *bccPluginName) {
Yang Nie8f9fba2015-01-30 08:55:10 -0800788 //ALOGE("rsdScriptCreate %p %p %p %p %i %i %p", rsc, resName, cacheDir,
789 // bitcode, bitcodeSize, flags, lookupFunc);
Jason Sams709a0972012-11-15 18:18:04 -0800790 //ALOGE("rsdScriptInit %p %p", rsc, script);
791
792 mCtx->lockMutex();
Jason Sams110f1812013-03-14 16:02:18 -0700793#ifndef RS_COMPATIBILITY_LIB
Stephen Hines00511322014-01-31 11:20:23 -0800794 bool useRSDebugContext = false;
Jason Sams709a0972012-11-15 18:18:04 -0800795
Chris Wailes44bef6f2014-08-12 13:51:10 -0700796 mCompilerDriver = nullptr;
Jason Sams709a0972012-11-15 18:18:04 -0800797
Jason Sams709a0972012-11-15 18:18:04 -0800798 mCompilerDriver = new bcc::RSCompilerDriver();
Chris Wailes44bef6f2014-08-12 13:51:10 -0700799 if (mCompilerDriver == nullptr) {
Jason Sams709a0972012-11-15 18:18:04 -0800800 ALOGE("bcc: FAILS to create compiler driver (out of memory)");
801 mCtx->unlockMutex();
802 return false;
803 }
804
Stephen Hinesb7d9c802013-04-29 19:13:09 -0700805 // Run any compiler setup functions we have been provided with.
806 RSSetupCompilerCallback setupCompilerCallback =
807 mCtx->getSetupCompilerCallback();
Chris Wailes44bef6f2014-08-12 13:51:10 -0700808 if (setupCompilerCallback != nullptr) {
Stephen Hinesb7d9c802013-04-29 19:13:09 -0700809 setupCompilerCallback(mCompilerDriver);
810 }
811
Jean-Luc Brouillet40e35cd2014-06-25 18:21:45 -0700812 bcinfo::MetadataExtractor bitcodeMetadata((const char *) bitcode, bitcodeSize);
813 if (!bitcodeMetadata.extract()) {
Stephen Hinesb58d9ad2013-06-19 19:26:19 -0700814 ALOGE("Could not extract metadata from bitcode");
Stephen Hinesf94e8db2014-06-26 11:55:29 -0700815 mCtx->unlockMutex();
Stephen Hinesb58d9ad2013-06-19 19:26:19 -0700816 return false;
817 }
818
Jean-Luc Brouillet40e35cd2014-06-25 18:21:45 -0700819 const char* core_lib = findCoreLib(bitcodeMetadata, (const char*)bitcode, bitcodeSize);
Stephen Hinescca3d6c2013-04-15 01:06:39 -0700820
821 if (mCtx->getContext()->getContextType() == RS_CONTEXT_TYPE_DEBUG) {
Stephen Hinesf47e8b42013-04-18 01:06:29 -0700822 mCompilerDriver->setDebugContext(true);
Stephen Hines00511322014-01-31 11:20:23 -0800823 useRSDebugContext = true;
Stephen Hinescca3d6c2013-04-15 01:06:39 -0700824 }
Stephen Hinesba17ae42013-06-05 17:18:04 -0700825
Chris Wailes6847e732014-08-11 17:30:51 -0700826 std::string bcFileName(cacheDir);
Jean-Luc Brouillet40e35cd2014-06-25 18:21:45 -0700827 bcFileName.append("/");
828 bcFileName.append(resName);
829 bcFileName.append(".bc");
830
831 std::vector<const char*> compileArguments;
832 setCompileArguments(&compileArguments, bcFileName, cacheDir, resName, core_lib,
833 useRSDebugContext, bccPluginName);
Chris Wailes44bef6f2014-08-12 13:51:10 -0700834 // The last argument of compileArguments ia a nullptr, so remove 1 from the size.
Jean-Luc Brouillet40e35cd2014-06-25 18:21:45 -0700835 std::string compileCommandLine =
836 bcc::getCommandLine(compileArguments.size() - 1, compileArguments.data());
837
Tim Murraybf96a522015-01-23 15:37:03 -0800838 if (!is_force_recompile() && !useRSDebugContext) {
Yang Ni1c44cb62015-01-22 12:02:27 -0800839 mScriptSO = SharedLibraryUtils::loadSharedLibrary(cacheDir, resName);
Jean-Luc Brouillet40e35cd2014-06-25 18:21:45 -0700840 }
841
842 // If we can't, it's either not there or out of date. We compile the bit code and try loading
843 // again.
Stephen Hines45e753a2015-01-19 20:58:44 -0800844 if (mScriptSO == nullptr) {
845 if (!compileBitcode(bcFileName, (const char*)bitcode, bitcodeSize,
846 compileArguments.data(), compileCommandLine))
847 {
Jean-Luc Brouillet40e35cd2014-06-25 18:21:45 -0700848 ALOGE("bcc: FAILS to compile '%s'", resName);
849 mCtx->unlockMutex();
850 return false;
851 }
Stephen Hines45e753a2015-01-19 20:58:44 -0800852
Yang Ni1c44cb62015-01-22 12:02:27 -0800853 if (!SharedLibraryUtils::createSharedLibrary(cacheDir, resName)) {
Stephen Hines45e753a2015-01-19 20:58:44 -0800854 ALOGE("Linker: Failed to link object file '%s'", resName);
855 mCtx->unlockMutex();
856 return false;
857 }
858
Yang Ni1c44cb62015-01-22 12:02:27 -0800859 mScriptSO = SharedLibraryUtils::loadSharedLibrary(cacheDir, resName);
Stephen Hines45e753a2015-01-19 20:58:44 -0800860 if (mScriptSO == nullptr) {
861 ALOGE("Unable to load '%s'", resName);
Jean-Luc Brouillet40e35cd2014-06-25 18:21:45 -0700862 mCtx->unlockMutex();
863 return false;
Stephen Hinesba17ae42013-06-05 17:18:04 -0700864 }
865 }
Jason Sams709a0972012-11-15 18:18:04 -0800866
Yang Nida0f0692015-01-12 13:03:40 -0800867 mBitcodeFilePath = bcFileName;
868
Stephen Hines45e753a2015-01-19 20:58:44 -0800869 // Read RS symbol information from the .so.
870 if ( !mScriptSO) {
871 goto error;
Jason Sams709a0972012-11-15 18:18:04 -0800872 }
873
Stephen Hines45e753a2015-01-19 20:58:44 -0800874 if ( !storeRSInfoFromSO()) {
875 goto error;
Tim Murray29809d12014-05-28 12:04:19 -0700876 }
Jean-Luc Brouilletf4d216e2014-06-09 18:04:16 -0700877#else // RS_COMPATIBILITY_LIB is defined
Jason Sams110f1812013-03-14 16:02:18 -0700878
Yang Ni1c44cb62015-01-22 12:02:27 -0800879 mScriptSO = SharedLibraryUtils::loadSharedLibrary(cacheDir, resName);
Jason Sams110f1812013-03-14 16:02:18 -0700880
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800881 if (!mScriptSO) {
882 goto error;
883 }
Jason Sams110f1812013-03-14 16:02:18 -0700884
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800885 if (!storeRSInfoFromSO()) {
Stephen Hinesc2c11cc2013-07-19 01:07:42 -0700886 goto error;
Jason Sams110f1812013-03-14 16:02:18 -0700887 }
888#endif
Jason Sams709a0972012-11-15 18:18:04 -0800889 mCtx->unlockMutex();
890 return true;
Jason Sams110f1812013-03-14 16:02:18 -0700891
Jason Sams110f1812013-03-14 16:02:18 -0700892error:
893
894 mCtx->unlockMutex();
Jason Sams110f1812013-03-14 16:02:18 -0700895 if (mScriptSO) {
896 dlclose(mScriptSO);
897 }
898 return false;
Jason Sams709a0972012-11-15 18:18:04 -0800899}
900
Jean-Luc Brouillet9ab50942014-06-18 18:10:32 -0700901#ifndef RS_COMPATIBILITY_LIB
902
Jean-Luc Brouillet9ab50942014-06-18 18:10:32 -0700903const char* RsdCpuScriptImpl::findCoreLib(const bcinfo::MetadataExtractor& ME, const char* bitcode,
904 size_t bitcodeSize) {
905 const char* defaultLib = SYSLIBPATH"/libclcore.bc";
906
907 // If we're debugging, use the debug library.
908 if (mCtx->getContext()->getContextType() == RS_CONTEXT_TYPE_DEBUG) {
909 return SYSLIBPATH"/libclcore_debug.bc";
910 }
911
912 // If a callback has been registered to specify a library, use that.
913 RSSelectRTCallback selectRTCallback = mCtx->getSelectRTCallback();
Chris Wailes44bef6f2014-08-12 13:51:10 -0700914 if (selectRTCallback != nullptr) {
Jean-Luc Brouillet9ab50942014-06-18 18:10:32 -0700915 return selectRTCallback((const char*)bitcode, bitcodeSize);
916 }
917
918 // Check for a platform specific library
919#if defined(ARCH_ARM_HAVE_NEON) && !defined(DISABLE_CLCORE_NEON)
920 enum bcinfo::RSFloatPrecision prec = ME.getRSFloatPrecision();
Jean-Luc Brouilletf4d38362014-07-09 17:46:03 -0700921 if (prec == bcinfo::RS_FP_Relaxed) {
Jean-Luc Brouillet9ab50942014-06-18 18:10:32 -0700922 // NEON-capable ARMv7a devices can use an accelerated math library
923 // for all reduced precision scripts.
924 // ARMv8 does not use NEON, as ASIMD can be used with all precision
925 // levels.
926 return SYSLIBPATH"/libclcore_neon.bc";
927 } else {
928 return defaultLib;
929 }
930#elif defined(__i386__) || defined(__x86_64__)
931 // x86 devices will use an optimized library.
932 return SYSLIBPATH"/libclcore_x86.bc";
933#else
934 return defaultLib;
935#endif
936}
937
938#endif
939
Jason Sams709a0972012-11-15 18:18:04 -0800940void RsdCpuScriptImpl::populateScript(Script *script) {
Jason Sams110f1812013-03-14 16:02:18 -0700941 // Copy info over to runtime
Yang Nid9bae682015-01-20 15:31:15 -0800942 script->mHal.info.exportedFunctionCount = mScriptExec->getExportedFunctionCount();
943 script->mHal.info.exportedVariableCount = mScriptExec->getExportedVariableCount();
Pirama Arumuga Nainar577194a2015-01-23 14:27:33 -0800944 script->mHal.info.exportedPragmaCount = mScriptExec->getPragmaCount();;
Yang Nie8f9fba2015-01-30 08:55:10 -0800945 script->mHal.info.exportedPragmaKeyList = mScriptExec->getPragmaKeys();
946 script->mHal.info.exportedPragmaValueList = mScriptExec->getPragmaValues();
Jason Sams110f1812013-03-14 16:02:18 -0700947
948 // Bug, need to stash in metadata
949 if (mRootExpand) {
950 script->mHal.info.root = mRootExpand;
951 } else {
952 script->mHal.info.root = mRoot;
953 }
Jason Sams709a0972012-11-15 18:18:04 -0800954}
955
Jason Sams709a0972012-11-15 18:18:04 -0800956
957typedef void (*rs_t)(const void *, void *, const void *, uint32_t, uint32_t, uint32_t, uint32_t);
958
Jason Samsbf2111d2015-01-26 18:13:41 -0800959bool RsdCpuScriptImpl::forEachMtlsSetup(const Allocation ** ains,
Chris Wailesf3712132014-07-16 15:18:30 -0700960 uint32_t inLen,
Chris Wailes4b3c34e2014-06-11 12:00:29 -0700961 Allocation * aout,
962 const void * usr, uint32_t usrLen,
963 const RsScriptCall *sc,
964 MTLaunchStruct *mtls) {
965
966 memset(mtls, 0, sizeof(MTLaunchStruct));
967
Chris Wailesf3712132014-07-16 15:18:30 -0700968 for (int index = inLen; --index >= 0;) {
969 const Allocation* ain = ains[index];
Chris Wailes4b3c34e2014-06-11 12:00:29 -0700970
Chris Wailesf3712132014-07-16 15:18:30 -0700971 // possible for this to occur if IO_OUTPUT/IO_INPUT with no bound surface
Chris Wailes44bef6f2014-08-12 13:51:10 -0700972 if (ain != nullptr &&
973 (const uint8_t *)ain->mHal.drvState.lod[0].mallocPtr == nullptr) {
974
Chris Wailesf3712132014-07-16 15:18:30 -0700975 mCtx->getContext()->setError(RS_ERROR_BAD_SCRIPT,
976 "rsForEach called with null in allocations");
Jason Samsbf2111d2015-01-26 18:13:41 -0800977 return false;
Chris Wailes4b3c34e2014-06-11 12:00:29 -0700978 }
979 }
980
Chris Wailes44bef6f2014-08-12 13:51:10 -0700981 if (aout &&
982 (const uint8_t *)aout->mHal.drvState.lod[0].mallocPtr == nullptr) {
983
Chris Wailesf3712132014-07-16 15:18:30 -0700984 mCtx->getContext()->setError(RS_ERROR_BAD_SCRIPT,
985 "rsForEach called with null out allocations");
Jason Samsbf2111d2015-01-26 18:13:41 -0800986 return false;
Chris Wailes4b3c34e2014-06-11 12:00:29 -0700987 }
988
Chris Wailesf3712132014-07-16 15:18:30 -0700989 if (inLen > 0) {
Chris Wailes4b3c34e2014-06-11 12:00:29 -0700990 const Allocation *ain0 = ains[0];
991 const Type *inType = ain0->getType();
992
Jason Samsc0d68472015-01-20 14:29:52 -0800993 mtls->fep.dim.x = inType->getDimX();
994 mtls->fep.dim.y = inType->getDimY();
995 mtls->fep.dim.z = inType->getDimZ();
Chris Wailes4b3c34e2014-06-11 12:00:29 -0700996
997 for (int Index = inLen; --Index >= 1;) {
998 if (!ain0->hasSameDims(ains[Index])) {
999 mCtx->getContext()->setError(RS_ERROR_BAD_SCRIPT,
Yang Nie8f9fba2015-01-30 08:55:10 -08001000 "Failed to launch kernel; dimensions of input and output"
1001 "allocations do not match.");
Chris Wailes4b3c34e2014-06-11 12:00:29 -07001002
Jason Samsbf2111d2015-01-26 18:13:41 -08001003 return false;
Chris Wailes4b3c34e2014-06-11 12:00:29 -07001004 }
1005 }
1006
Chris Wailes44bef6f2014-08-12 13:51:10 -07001007 } else if (aout != nullptr) {
Chris Wailes4b3c34e2014-06-11 12:00:29 -07001008 const Type *outType = aout->getType();
1009
Jason Samsc0d68472015-01-20 14:29:52 -08001010 mtls->fep.dim.x = outType->getDimX();
1011 mtls->fep.dim.y = outType->getDimY();
1012 mtls->fep.dim.z = outType->getDimZ();
Chris Wailes4b3c34e2014-06-11 12:00:29 -07001013
1014 } else {
Chris Wailesf3712132014-07-16 15:18:30 -07001015 mCtx->getContext()->setError(RS_ERROR_BAD_SCRIPT,
1016 "rsForEach called with null allocations");
Jason Samsbf2111d2015-01-26 18:13:41 -08001017 return false;
Chris Wailes4b3c34e2014-06-11 12:00:29 -07001018 }
1019
Chris Wailes44bef6f2014-08-12 13:51:10 -07001020 if (inLen > 0 && aout != nullptr) {
Chris Wailes4b3c34e2014-06-11 12:00:29 -07001021 if (!ains[0]->hasSameDims(aout)) {
1022 mCtx->getContext()->setError(RS_ERROR_BAD_SCRIPT,
1023 "Failed to launch kernel; dimensions of input and output allocations do not match.");
1024
Jason Samsbf2111d2015-01-26 18:13:41 -08001025 return false;
Chris Wailes4b3c34e2014-06-11 12:00:29 -07001026 }
1027 }
1028
1029 if (!sc || (sc->xEnd == 0)) {
Jason Samsbf2111d2015-01-26 18:13:41 -08001030 mtls->end.x = mtls->fep.dim.x;
Chris Wailes4b3c34e2014-06-11 12:00:29 -07001031 } else {
Jason Samsbf2111d2015-01-26 18:13:41 -08001032 mtls->start.x = rsMin(mtls->fep.dim.x, sc->xStart);
1033 mtls->end.x = rsMin(mtls->fep.dim.x, sc->xEnd);
1034 if (mtls->start.x >= mtls->end.x) return false;
Chris Wailes4b3c34e2014-06-11 12:00:29 -07001035 }
1036
1037 if (!sc || (sc->yEnd == 0)) {
Jason Samsbf2111d2015-01-26 18:13:41 -08001038 mtls->end.y = mtls->fep.dim.y;
Chris Wailes4b3c34e2014-06-11 12:00:29 -07001039 } else {
Jason Samsbf2111d2015-01-26 18:13:41 -08001040 mtls->start.y = rsMin(mtls->fep.dim.y, sc->yStart);
1041 mtls->end.y = rsMin(mtls->fep.dim.y, sc->yEnd);
1042 if (mtls->start.y >= mtls->end.y) return false;
Chris Wailes4b3c34e2014-06-11 12:00:29 -07001043 }
1044
1045 if (!sc || (sc->zEnd == 0)) {
Jason Samsbf2111d2015-01-26 18:13:41 -08001046 mtls->end.z = mtls->fep.dim.z;
Chris Wailes4b3c34e2014-06-11 12:00:29 -07001047 } else {
Jason Samsbf2111d2015-01-26 18:13:41 -08001048 mtls->start.z = rsMin(mtls->fep.dim.z, sc->zStart);
1049 mtls->end.z = rsMin(mtls->fep.dim.z, sc->zEnd);
1050 if (mtls->start.z >= mtls->end.z) return false;
Chris Wailes4b3c34e2014-06-11 12:00:29 -07001051 }
1052
Jason Samsbf2111d2015-01-26 18:13:41 -08001053 if (!sc || (sc->arrayEnd == 0)) {
1054 mtls->end.array[0] = mtls->fep.dim.array[0];
1055 } else {
1056 mtls->start.array[0] = rsMin(mtls->fep.dim.array[0], sc->arrayStart);
1057 mtls->end.array[0] = rsMin(mtls->fep.dim.array[0], sc->arrayEnd);
1058 if (mtls->start.array[0] >= mtls->end.array[0]) return false;
1059 }
Chris Wailes4b3c34e2014-06-11 12:00:29 -07001060
Jason Samsbf2111d2015-01-26 18:13:41 -08001061 if (!sc || (sc->array2End == 0)) {
1062 mtls->end.array[1] = mtls->fep.dim.array[1];
1063 } else {
1064 mtls->start.array[1] = rsMin(mtls->fep.dim.array[1], sc->array2Start);
1065 mtls->end.array[1] = rsMin(mtls->fep.dim.array[1], sc->array2End);
1066 if (mtls->start.array[1] >= mtls->end.array[1]) return false;
1067 }
1068
1069 if (!sc || (sc->array3End == 0)) {
1070 mtls->end.array[2] = mtls->fep.dim.array[2];
1071 } else {
1072 mtls->start.array[2] = rsMin(mtls->fep.dim.array[2], sc->array3Start);
1073 mtls->end.array[2] = rsMin(mtls->fep.dim.array[2], sc->array3End);
1074 if (mtls->start.array[2] >= mtls->end.array[2]) return false;
1075 }
1076
1077 if (!sc || (sc->array4End == 0)) {
1078 mtls->end.array[3] = mtls->fep.dim.array[3];
1079 } else {
1080 mtls->start.array[3] = rsMin(mtls->fep.dim.array[3], sc->array4Start);
1081 mtls->end.array[3] = rsMin(mtls->fep.dim.array[3], sc->array4End);
1082 if (mtls->start.array[3] >= mtls->end.array[3]) return false;
1083 }
1084
1085
1086 // The X & Y walkers always want 0-1 min even if dim is not present
1087 mtls->end.x = rsMax((uint32_t)1, mtls->end.x);
1088 mtls->end.y = rsMax((uint32_t)1, mtls->end.y);
Chris Wailes4b3c34e2014-06-11 12:00:29 -07001089
1090 mtls->rsc = mCtx;
Jason Samsc0d68472015-01-20 14:29:52 -08001091 if (ains) {
1092 memcpy(mtls->ains, ains, inLen * sizeof(ains[0]));
1093 }
1094 mtls->aout[0] = aout;
Chris Wailes4b3c34e2014-06-11 12:00:29 -07001095 mtls->fep.usr = usr;
1096 mtls->fep.usrLen = usrLen;
1097 mtls->mSliceSize = 1;
1098 mtls->mSliceNum = 0;
1099
Chris Wailes4b3c34e2014-06-11 12:00:29 -07001100 mtls->isThreadable = mIsThreadable;
1101
Chris Wailesf3712132014-07-16 15:18:30 -07001102 if (inLen > 0) {
Chris Wailesf3712132014-07-16 15:18:30 -07001103 mtls->fep.inLen = inLen;
Chris Wailes4b3c34e2014-06-11 12:00:29 -07001104 for (int index = inLen; --index >= 0;) {
Jason Samsc0d68472015-01-20 14:29:52 -08001105 mtls->fep.inPtr[index] = (const uint8_t*)ains[index]->mHal.drvState.lod[0].mallocPtr;
1106 mtls->fep.inStride[index] = ains[index]->getType()->getElementSizeBytes();
Chris Wailes4b3c34e2014-06-11 12:00:29 -07001107 }
1108 }
1109
Chris Wailes44bef6f2014-08-12 13:51:10 -07001110 if (aout != nullptr) {
Jason Samsc0d68472015-01-20 14:29:52 -08001111 mtls->fep.outPtr[0] = (uint8_t *)aout->mHal.drvState.lod[0].mallocPtr;
1112 mtls->fep.outStride[0] = aout->getType()->getElementSizeBytes();
Chris Wailes4b3c34e2014-06-11 12:00:29 -07001113 }
Jason Samsbf2111d2015-01-26 18:13:41 -08001114
1115 // All validation passed, ok to launch threads
1116 return true;
Chris Wailes4b3c34e2014-06-11 12:00:29 -07001117}
1118
Jason Sams709a0972012-11-15 18:18:04 -08001119
1120void RsdCpuScriptImpl::invokeForEach(uint32_t slot,
Chris Wailesf3712132014-07-16 15:18:30 -07001121 const Allocation ** ains,
1122 uint32_t inLen,
Jason Sams709a0972012-11-15 18:18:04 -08001123 Allocation * aout,
1124 const void * usr,
1125 uint32_t usrLen,
1126 const RsScriptCall *sc) {
1127
1128 MTLaunchStruct mtls;
Chris Wailes4b3c34e2014-06-11 12:00:29 -07001129
Jason Samsbf2111d2015-01-26 18:13:41 -08001130 if (forEachMtlsSetup(ains, inLen, aout, usr, usrLen, sc, &mtls)) {
1131 forEachKernelSetup(slot, &mtls);
Chris Wailes4b3c34e2014-06-11 12:00:29 -07001132
Jason Samsbf2111d2015-01-26 18:13:41 -08001133 RsdCpuScriptImpl * oldTLS = mCtx->setTLS(this);
1134 mCtx->launchThreads(ains, inLen, aout, sc, &mtls);
1135 mCtx->setTLS(oldTLS);
1136 }
Chris Wailes4b3c34e2014-06-11 12:00:29 -07001137}
1138
Jason Sams709a0972012-11-15 18:18:04 -08001139void RsdCpuScriptImpl::forEachKernelSetup(uint32_t slot, MTLaunchStruct *mtls) {
Jason Sams709a0972012-11-15 18:18:04 -08001140 mtls->script = this;
1141 mtls->fep.slot = slot;
Yang Nid9bae682015-01-20 15:31:15 -08001142 mtls->kernel = mScriptExec->getForEachFunction(slot);
Chris Wailes44bef6f2014-08-12 13:51:10 -07001143 rsAssert(mtls->kernel != nullptr);
Yang Nid9bae682015-01-20 15:31:15 -08001144 mtls->sig = mScriptExec->getForEachSignature(slot);
Jason Sams709a0972012-11-15 18:18:04 -08001145}
1146
1147int RsdCpuScriptImpl::invokeRoot() {
1148 RsdCpuScriptImpl * oldTLS = mCtx->setTLS(this);
1149 int ret = mRoot();
1150 mCtx->setTLS(oldTLS);
1151 return ret;
1152}
1153
1154void RsdCpuScriptImpl::invokeInit() {
1155 if (mInit) {
1156 mInit();
1157 }
1158}
1159
1160void RsdCpuScriptImpl::invokeFreeChildren() {
1161 if (mFreeChildren) {
1162 mFreeChildren();
1163 }
1164}
1165
1166void RsdCpuScriptImpl::invokeFunction(uint32_t slot, const void *params,
1167 size_t paramLength) {
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -08001168 //ALOGE("invoke %i %p %zu", slot, params, paramLength);
Yong Cheneaba5a32014-12-12 13:25:18 +08001169 void * ap = nullptr;
1170
1171#if defined(__x86_64__)
1172 // The invoked function could have input parameter of vector type for example float4 which
1173 // requires void* params to be 16 bytes aligned when using SSE instructions for x86_64 platform.
1174 // So try to align void* params before passing them into RS exported function.
1175
1176 if ((uint8_t)(uint64_t)params & 0x0F) {
1177 if ((ap = (void*)memalign(16, paramLength)) != nullptr) {
1178 memcpy(ap, params, paramLength);
1179 } else {
Yang Nie8f9fba2015-01-30 08:55:10 -08001180 ALOGE("x86_64: invokeFunction memalign error, still use params which"
1181 " is not 16 bytes aligned.");
Yong Cheneaba5a32014-12-12 13:25:18 +08001182 }
1183 }
1184#endif
Jason Sams709a0972012-11-15 18:18:04 -08001185
1186 RsdCpuScriptImpl * oldTLS = mCtx->setTLS(this);
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -08001187 reinterpret_cast<void (*)(const void *, uint32_t)>(
Yang Nid9bae682015-01-20 15:31:15 -08001188 mScriptExec->getInvokeFunction(slot))(ap? (const void *) ap: params, paramLength);
Yong Cheneaba5a32014-12-12 13:25:18 +08001189
Jason Sams709a0972012-11-15 18:18:04 -08001190 mCtx->setTLS(oldTLS);
1191}
1192
1193void RsdCpuScriptImpl::setGlobalVar(uint32_t slot, const void *data, size_t dataLength) {
1194 //rsAssert(!script->mFieldIsObject[slot]);
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -08001195 //ALOGE("setGlobalVar %i %p %zu", slot, data, dataLength);
Jason Sams709a0972012-11-15 18:18:04 -08001196
1197 //if (mIntrinsicID) {
1198 //mIntrinsicFuncs.setVar(dc, script, drv->mIntrinsicData, slot, data, dataLength);
1199 //return;
1200 //}
1201
Yang Nid9bae682015-01-20 15:31:15 -08001202 int32_t *destPtr = reinterpret_cast<int32_t *>(mScriptExec->getFieldAddress(slot));
Jason Sams709a0972012-11-15 18:18:04 -08001203 if (!destPtr) {
1204 //ALOGV("Calling setVar on slot = %i which is null", slot);
1205 return;
1206 }
1207
1208 memcpy(destPtr, data, dataLength);
1209}
1210
Tim Murray9c642392013-04-11 13:29:59 -07001211void RsdCpuScriptImpl::getGlobalVar(uint32_t slot, void *data, size_t dataLength) {
1212 //rsAssert(!script->mFieldIsObject[slot]);
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -08001213 //ALOGE("getGlobalVar %i %p %zu", slot, data, dataLength);
Tim Murray9c642392013-04-11 13:29:59 -07001214
Yang Nid9bae682015-01-20 15:31:15 -08001215 int32_t *srcPtr = reinterpret_cast<int32_t *>(mScriptExec->getFieldAddress(slot));
Tim Murray9c642392013-04-11 13:29:59 -07001216 if (!srcPtr) {
1217 //ALOGV("Calling setVar on slot = %i which is null", slot);
1218 return;
1219 }
1220 memcpy(data, srcPtr, dataLength);
1221}
1222
1223
Jason Sams709a0972012-11-15 18:18:04 -08001224void RsdCpuScriptImpl::setGlobalVarWithElemDims(uint32_t slot, const void *data, size_t dataLength,
1225 const Element *elem,
Stephen Hinesac8d1462014-06-25 00:01:23 -07001226 const uint32_t *dims, size_t dimLength) {
Yang Nid9bae682015-01-20 15:31:15 -08001227 int32_t *destPtr = reinterpret_cast<int32_t *>(mScriptExec->getFieldAddress(slot));
Jason Sams709a0972012-11-15 18:18:04 -08001228 if (!destPtr) {
1229 //ALOGV("Calling setVar on slot = %i which is null", slot);
1230 return;
1231 }
1232
1233 // We want to look at dimension in terms of integer components,
1234 // but dimLength is given in terms of bytes.
1235 dimLength /= sizeof(int);
1236
1237 // Only a single dimension is currently supported.
1238 rsAssert(dimLength == 1);
1239 if (dimLength == 1) {
1240 // First do the increment loop.
1241 size_t stride = elem->getSizeBytes();
1242 const char *cVal = reinterpret_cast<const char *>(data);
Stephen Hinesac8d1462014-06-25 00:01:23 -07001243 for (uint32_t i = 0; i < dims[0]; i++) {
Jason Sams709a0972012-11-15 18:18:04 -08001244 elem->incRefs(cVal);
1245 cVal += stride;
1246 }
1247
1248 // Decrement loop comes after (to prevent race conditions).
1249 char *oldVal = reinterpret_cast<char *>(destPtr);
Stephen Hinesac8d1462014-06-25 00:01:23 -07001250 for (uint32_t i = 0; i < dims[0]; i++) {
Jason Sams709a0972012-11-15 18:18:04 -08001251 elem->decRefs(oldVal);
1252 oldVal += stride;
1253 }
1254 }
1255
1256 memcpy(destPtr, data, dataLength);
1257}
1258
1259void RsdCpuScriptImpl::setGlobalBind(uint32_t slot, Allocation *data) {
1260
1261 //rsAssert(!script->mFieldIsObject[slot]);
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -08001262 //ALOGE("setGlobalBind %i %p", slot, data);
Jason Sams709a0972012-11-15 18:18:04 -08001263
Yang Nid9bae682015-01-20 15:31:15 -08001264 int32_t *destPtr = reinterpret_cast<int32_t *>(mScriptExec->getFieldAddress(slot));
Jason Sams709a0972012-11-15 18:18:04 -08001265 if (!destPtr) {
1266 //ALOGV("Calling setVar on slot = %i which is null", slot);
1267 return;
1268 }
1269
Chris Wailes44bef6f2014-08-12 13:51:10 -07001270 void *ptr = nullptr;
Jason Sams709a0972012-11-15 18:18:04 -08001271 mBoundAllocs[slot] = data;
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -08001272 if (data) {
Jason Sams709a0972012-11-15 18:18:04 -08001273 ptr = data->mHal.drvState.lod[0].mallocPtr;
1274 }
1275 memcpy(destPtr, &ptr, sizeof(void *));
1276}
1277
1278void RsdCpuScriptImpl::setGlobalObj(uint32_t slot, ObjectBase *data) {
1279
1280 //rsAssert(script->mFieldIsObject[slot]);
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -08001281 //ALOGE("setGlobalObj %i %p", slot, data);
Jason Sams709a0972012-11-15 18:18:04 -08001282
Yang Nid9bae682015-01-20 15:31:15 -08001283 int32_t *destPtr = reinterpret_cast<int32_t *>(mScriptExec->getFieldAddress(slot));
Jason Sams709a0972012-11-15 18:18:04 -08001284 if (!destPtr) {
1285 //ALOGV("Calling setVar on slot = %i which is null", slot);
1286 return;
1287 }
1288
Jason Sams05ef73f2014-08-05 14:59:22 -07001289 rsrSetObject(mCtx->getContext(), (rs_object_base *)destPtr, data);
Jason Sams709a0972012-11-15 18:18:04 -08001290}
1291
1292RsdCpuScriptImpl::~RsdCpuScriptImpl() {
Jason Sams110f1812013-03-14 16:02:18 -07001293#ifndef RS_COMPATIBILITY_LIB
Jason Sams709a0972012-11-15 18:18:04 -08001294 if (mCompilerDriver) {
1295 delete mCompilerDriver;
1296 }
Stephen Hines45e753a2015-01-19 20:58:44 -08001297#endif
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -08001298
Yang Nid9bae682015-01-20 15:31:15 -08001299 if (mScriptExec != nullptr) {
1300 delete mScriptExec;
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -08001301 }
Jason Sams110f1812013-03-14 16:02:18 -07001302 if (mBoundAllocs) delete[] mBoundAllocs;
1303 if (mScriptSO) {
1304 dlclose(mScriptSO);
1305 }
Jason Sams709a0972012-11-15 18:18:04 -08001306}
1307
1308Allocation * RsdCpuScriptImpl::getAllocationForPointer(const void *ptr) const {
1309 if (!ptr) {
Chris Wailes44bef6f2014-08-12 13:51:10 -07001310 return nullptr;
Jason Sams709a0972012-11-15 18:18:04 -08001311 }
1312
1313 for (uint32_t ct=0; ct < mScript->mHal.info.exportedVariableCount; ct++) {
1314 Allocation *a = mBoundAllocs[ct];
1315 if (!a) continue;
1316 if (a->mHal.drvState.lod[0].mallocPtr == ptr) {
1317 return a;
1318 }
1319 }
1320 ALOGE("rsGetAllocation, failed to find %p", ptr);
Chris Wailes44bef6f2014-08-12 13:51:10 -07001321 return nullptr;
Jason Sams709a0972012-11-15 18:18:04 -08001322}
1323
Chris Wailesf3712132014-07-16 15:18:30 -07001324void RsdCpuScriptImpl::preLaunch(uint32_t slot, const Allocation ** ains,
1325 uint32_t inLen, Allocation * aout,
1326 const void * usr, uint32_t usrLen,
1327 const RsScriptCall *sc) {}
Jason Sams17e3cdc2013-09-09 17:32:16 -07001328
Chris Wailesf3712132014-07-16 15:18:30 -07001329void RsdCpuScriptImpl::postLaunch(uint32_t slot, const Allocation ** ains,
1330 uint32_t inLen, Allocation * aout,
1331 const void * usr, uint32_t usrLen,
1332 const RsScriptCall *sc) {}
Jason Sams17e3cdc2013-09-09 17:32:16 -07001333
Jason Sams709a0972012-11-15 18:18:04 -08001334
1335}
1336}