Remove All Ads from XDA

Compiling renderscript code at runtime

1 posts
Thanks Meter: 0
By degoossez, Junior Member on 25th March 2014, 04:04 PM
Post Reply Email Thread
I was wondering if it's possible to write/modify renderscript code when the android application is running.
My main goal is to make an app where users can learn to work with renderscript without any java knowledge. The basic layout of the app would consist of an input and output image, with the possibility for code input. The basic functionality of this app is already working and this is an image of the interface.
Click image for larger version

Name:	resized.png
Views:	45
Size:	34.3 KB
ID:	2649322

It would be useful to test renderscript code with direct feedback from the app.

I've already done research about the build process and came up with the following idea:

A basic "template" renderscript file, with the necessary global variables like in and out allocations.

My java code would create a script object of the generated java class and do the basic initialization of these global script variables.
The root function of this template .rs file would be empty, and it should be possible to be implemented by the user at runtime.

When the user types in his code in the main view of the app, the code is written to my own .rs file which then is compiled by the llvm-rs-cc compiler, invoked by the application. The generated .bc would then be copied to the location of the original .bc file of
the template. Because the only change of code happens inside the root function, it would not be necessary to make changes to the surrounding
java code.

The problem I'm having at the moment is the fact that the .bc files are bundled within the final apk inside the res/raw folder,
which is not accessible by the app. Overwriting old .bc files with the newly generated files is therefore not possible.

Is there a(nother) way to compile renderscript code at runtime?
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes