Remove InvokeData and add ContextFinish to generate a sync point.
Change-Id: I27da8bf5fba2c8a428964cb6a5e66dd7a94958d8
This commit is contained in:
@@ -68,6 +68,7 @@ public class RenderScript {
|
||||
native void nContextSetSurface(int w, int h, Surface sur);
|
||||
native void nContextSetPriority(int p);
|
||||
native void nContextDump(int bits);
|
||||
native void nContextFinish();
|
||||
|
||||
native void nContextBindRootScript(int script);
|
||||
native void nContextBindSampler(int sampler, int slot);
|
||||
@@ -141,7 +142,6 @@ public class RenderScript {
|
||||
native void nScriptBindAllocation(int script, int alloc, int slot);
|
||||
native void nScriptSetTimeZone(int script, byte[] timeZone);
|
||||
native void nScriptInvoke(int id, int slot);
|
||||
native void nScriptInvokeData(int id, int slot);
|
||||
native void nScriptInvokeV(int id, int slot, byte[] params);
|
||||
native void nScriptSetVarI(int id, int slot, int val);
|
||||
native void nScriptSetVarF(int id, int slot, float val);
|
||||
@@ -323,6 +323,10 @@ public class RenderScript {
|
||||
nContextDump(bits);
|
||||
}
|
||||
|
||||
public void finish() {
|
||||
nContextFinish();
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
validate();
|
||||
nContextDeinitToClient();
|
||||
|
||||
@@ -46,12 +46,12 @@ public class Script extends BaseObj {
|
||||
mRS.nScriptInvoke(mID, slot);
|
||||
}
|
||||
|
||||
protected void invokeData(int slot) {
|
||||
mRS.nScriptInvokeData(mID, slot);
|
||||
}
|
||||
|
||||
protected void invokeV(int slot, FieldPacker v) {
|
||||
mRS.nScriptInvokeV(mID, slot, v.getData());
|
||||
protected void invoke(int slot, FieldPacker v) {
|
||||
if (v != null) {
|
||||
mRS.nScriptInvokeV(mID, slot, v.getData());
|
||||
} else {
|
||||
mRS.nScriptInvoke(mID, slot);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -84,6 +84,14 @@ static void nInitElements(JNIEnv *_env, jobject _this, jint a8, jint rgba4444, j
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
static void
|
||||
nContextFinish(JNIEnv *_env, jobject _this)
|
||||
{
|
||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||
LOG_API("nContextFinish, con(%p)", con);
|
||||
rsContextFinish(con);
|
||||
}
|
||||
|
||||
static void
|
||||
nAssignName(JNIEnv *_env, jobject _this, jint obj, jbyteArray str)
|
||||
{
|
||||
@@ -959,15 +967,6 @@ nScriptInvoke(JNIEnv *_env, jobject _this, jint obj, jint slot)
|
||||
rsScriptInvoke(con, (RsScript)obj, slot);
|
||||
}
|
||||
|
||||
static void
|
||||
nScriptInvokeData(JNIEnv *_env, jobject _this, jint obj, jint slot)
|
||||
{
|
||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||
LOG_API("nScriptInvokeData, con(%p), script(%p)", con, (void *)obj);
|
||||
rsScriptInvokeData(con, (RsScript)obj, slot, 0);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
nScriptInvokeV(JNIEnv *_env, jobject _this, jint script, jint slot, jbyteArray data)
|
||||
{
|
||||
@@ -1381,6 +1380,7 @@ static JNINativeMethod methods[] = {
|
||||
{"nDeviceSetConfig", "(III)V", (void*)nDeviceSetConfig },
|
||||
{"nContextCreate", "(II)I", (void*)nContextCreate },
|
||||
{"nContextCreateGL", "(IIZ)I", (void*)nContextCreateGL },
|
||||
{"nContextFinish", "()V", (void*)nContextFinish },
|
||||
{"nContextSetPriority", "(I)V", (void*)nContextSetPriority },
|
||||
{"nContextSetSurface", "(IILandroid/view/Surface;)V", (void*)nContextSetSurface },
|
||||
{"nContextDestroy", "(I)V", (void*)nContextDestroy },
|
||||
@@ -1442,7 +1442,6 @@ static JNINativeMethod methods[] = {
|
||||
{"nScriptBindAllocation", "(III)V", (void*)nScriptBindAllocation },
|
||||
{"nScriptSetTimeZone", "(I[B)V", (void*)nScriptSetTimeZone },
|
||||
{"nScriptInvoke", "(II)V", (void*)nScriptInvoke },
|
||||
{"nScriptInvokeData", "(II)V", (void*)nScriptInvokeData },
|
||||
{"nScriptInvokeV", "(II[B)V", (void*)nScriptInvokeV },
|
||||
{"nScriptSetVarI", "(III)V", (void*)nScriptSetVarI },
|
||||
{"nScriptSetVarF", "(IIF)V", (void*)nScriptSetVarF },
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Fountain test script
|
||||
#pragma version(1)
|
||||
|
||||
#pragma rs java_package_name(com.android.fountain)
|
||||
|
||||
#include "../../../../scriptc/rs_types.rsh"
|
||||
#include "../../../../scriptc/rs_math.rsh"
|
||||
#include "../../../../scriptc/rs_graphics.rsh"
|
||||
@@ -10,7 +12,7 @@ static int newPart = 0;
|
||||
float4 partColor;
|
||||
rs_mesh partMesh;
|
||||
|
||||
typedef struct __attribute__((packed, aligned(4))) Point_s {
|
||||
typedef struct __attribute__((packed, aligned(4))) Point {
|
||||
float2 delta;
|
||||
float2 position;
|
||||
uchar4 color;
|
||||
|
||||
Binary file not shown.
@@ -34,7 +34,7 @@ public class FountainRS {
|
||||
mRS = rs;
|
||||
mRes = res;
|
||||
|
||||
ScriptField_Point_s points = new ScriptField_Point_s(mRS, PART_COUNT);
|
||||
ScriptField_Point points = new ScriptField_Point(mRS, PART_COUNT);
|
||||
|
||||
SimpleMesh.Builder smb = new SimpleMesh.Builder(mRS);
|
||||
int vtxSlot = smb.addVertexType(points.getType());
|
||||
@@ -42,7 +42,7 @@ public class FountainRS {
|
||||
SimpleMesh sm = smb.create();
|
||||
sm.bindVertexAllocation(points.getAllocation(), vtxSlot);
|
||||
|
||||
mScript = new ScriptC_Fountain(mRS, mRes, true);
|
||||
mScript = new ScriptC_Fountain(mRS, mRes, R.raw.fountain_bc, true);
|
||||
mScript.set_partMesh(sm);
|
||||
mScript.bind_point(points);
|
||||
mRS.contextBindRootScript(mScript);
|
||||
|
||||
@@ -22,8 +22,8 @@ import android.util.Log;
|
||||
|
||||
public class ScriptC_Fountain extends ScriptC {
|
||||
// Constructor
|
||||
public ScriptC_Fountain(RenderScript rs, Resources resources, boolean isRoot) {
|
||||
super(rs, resources, R.raw.fountain_bc, isRoot);
|
||||
public ScriptC_Fountain(RenderScript rs, Resources resources, int id, boolean isRoot) {
|
||||
super(rs, resources, id, isRoot);
|
||||
}
|
||||
|
||||
private final static int mExportVarIdx_partColor = 0;
|
||||
@@ -43,9 +43,7 @@ public class ScriptC_Fountain extends ScriptC {
|
||||
private SimpleMesh mExportVar_partMesh;
|
||||
public void set_partMesh(SimpleMesh v) {
|
||||
mExportVar_partMesh = v;
|
||||
int id = 0;
|
||||
if (v != null) id = v.getID();
|
||||
setVar(mExportVarIdx_partMesh, id);
|
||||
setVar(mExportVarIdx_partMesh, (v == null) ? 0 : v.getID());
|
||||
}
|
||||
|
||||
public SimpleMesh get_partMesh() {
|
||||
@@ -53,14 +51,14 @@ public class ScriptC_Fountain extends ScriptC {
|
||||
}
|
||||
|
||||
private final static int mExportVarIdx_point = 2;
|
||||
private ScriptField_Point_s mExportVar_point;
|
||||
public void bind_point(ScriptField_Point_s v) {
|
||||
private ScriptField_Point mExportVar_point;
|
||||
public void bind_point(ScriptField_Point v) {
|
||||
mExportVar_point = v;
|
||||
if(v == null) bindAllocation(null, mExportVarIdx_point);
|
||||
else bindAllocation(v.getAllocation(), mExportVarIdx_point);
|
||||
}
|
||||
|
||||
public ScriptField_Point_s get_point() {
|
||||
public ScriptField_Point get_point() {
|
||||
return mExportVar_point;
|
||||
}
|
||||
|
||||
@@ -70,7 +68,7 @@ public class ScriptC_Fountain extends ScriptC {
|
||||
addParticles_fp.addI32(rate);
|
||||
addParticles_fp.addI32(x);
|
||||
addParticles_fp.addI32(y);
|
||||
invokeV(mExportFuncIdx_addParticles, addParticles_fp);
|
||||
invoke(mExportFuncIdx_addParticles, addParticles_fp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import android.renderscript.*;
|
||||
import android.content.res.Resources;
|
||||
import android.util.Log;
|
||||
|
||||
public class ScriptField_Point_s extends android.renderscript.Script.FieldBase {
|
||||
public class ScriptField_Point extends android.renderscript.Script.FieldBase {
|
||||
static public class Item {
|
||||
public static final int sizeof = 20;
|
||||
|
||||
@@ -38,7 +38,7 @@ public class ScriptField_Point_s extends android.renderscript.Script.FieldBase {
|
||||
|
||||
private Item mItemArray[];
|
||||
private FieldPacker mIOBuffer;
|
||||
public ScriptField_Point_s(RenderScript rs, int count) {
|
||||
public ScriptField_Point(RenderScript rs, int count) {
|
||||
mItemArray = null;
|
||||
mIOBuffer = null;
|
||||
{
|
||||
@@ -286,6 +286,7 @@ public class ImageProcessingActivity extends Activity
|
||||
long t = java.lang.System.currentTimeMillis();
|
||||
if (true) {
|
||||
mScript.invokable_Filter();
|
||||
mRS.finish();
|
||||
} else {
|
||||
javaFilter();
|
||||
}
|
||||
@@ -355,6 +356,7 @@ public class ImageProcessingActivity extends Activity
|
||||
public void surfaceCreated(SurfaceHolder holder) {
|
||||
createScript();
|
||||
mScript.invokable_Filter();
|
||||
mRS.finish();
|
||||
}
|
||||
|
||||
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
|
||||
@@ -412,6 +414,7 @@ public class ImageProcessingActivity extends Activity
|
||||
long t = java.lang.System.currentTimeMillis();
|
||||
|
||||
mScript.invokable_FilterBenchmark();
|
||||
mRS.finish();
|
||||
|
||||
t = java.lang.System.currentTimeMillis() - t;
|
||||
android.util.Log.v("Img", "Renderscript frame time core ms " + t);
|
||||
@@ -424,5 +427,6 @@ public class ImageProcessingActivity extends Activity
|
||||
mScript.set_radius(mRadius);
|
||||
|
||||
mScript.invokable_Filter();
|
||||
mRS.finish();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,12 +104,12 @@ public class ScriptC_Threshold
|
||||
|
||||
private final static int mInvokableIndex_Filter = 4;
|
||||
public void invokable_Filter() {
|
||||
invokeData(mInvokableIndex_Filter);
|
||||
invoke(mInvokableIndex_Filter);
|
||||
}
|
||||
|
||||
private final static int mInvokableIndex_FilterBenchmark = 5;
|
||||
public void invokable_FilterBenchmark() {
|
||||
invokeData(mInvokableIndex_FilterBenchmark);
|
||||
invoke(mInvokableIndex_FilterBenchmark);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
|
||||
ContextFinish {
|
||||
handcodeApi
|
||||
}
|
||||
|
||||
ContextBindRootScript {
|
||||
param RsScript sampler
|
||||
@@ -261,12 +264,6 @@ ScriptInvoke {
|
||||
param uint32_t slot
|
||||
}
|
||||
|
||||
ScriptInvokeData {
|
||||
param RsScript s
|
||||
param uint32_t slot
|
||||
param void * data
|
||||
}
|
||||
|
||||
ScriptInvokeV {
|
||||
param RsScript s
|
||||
param uint32_t slot
|
||||
|
||||
@@ -761,6 +761,9 @@ void Context::dumpDebug() const
|
||||
namespace android {
|
||||
namespace renderscript {
|
||||
|
||||
void rsi_ContextFinish(Context *rsc)
|
||||
{
|
||||
}
|
||||
|
||||
void rsi_ContextBindRootScript(Context *rsc, RsScript vs)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
|
||||
#define DATA_SYNC_SIZE 1024
|
||||
|
||||
static inline void rsHCAPI_ContextFinish (RsContext rsc)
|
||||
{
|
||||
ThreadIO *io = &((Context *)rsc)->mIO;
|
||||
uint32_t size = sizeof(RS_CMD_ContextFinish);
|
||||
RS_CMD_ContextFinish *cmd = static_cast<RS_CMD_ContextFinish *>(io->mToCore.reserve(size));
|
||||
io->mToCore.commitSync(RS_CMD_ID_ContextFinish, size);
|
||||
}
|
||||
|
||||
static inline void rsHCAPI_ScriptInvokeV (RsContext rsc, RsScript va, uint32_t slot, const void * data, uint32_t sizeBytes)
|
||||
{
|
||||
ThreadIO *io = &((Context *)rsc)->mIO;
|
||||
|
||||
@@ -260,17 +260,25 @@ void ScriptCState::runCompiler(Context *rsc, ScriptC *s)
|
||||
s->mProgram.mInit();
|
||||
}
|
||||
|
||||
s->mEnviroment.mInvokeFunctions = (Script::InvokeFunc_t *)calloc(100, sizeof(void *));
|
||||
BCCchar **labels = new char*[100];
|
||||
bccGetFunctions(s->mBccScript, (BCCsizei *)&s->mEnviroment.mInvokeFunctionCount,
|
||||
100, (BCCchar **)labels);
|
||||
//LOGE("func count %i", s->mEnviroment.mInvokeFunctionCount);
|
||||
for (uint32_t i=0; i < s->mEnviroment.mInvokeFunctionCount; i++) {
|
||||
BCCsizei length;
|
||||
bccGetFunctionBinary(s->mBccScript, labels[i], (BCCvoid **)&(s->mEnviroment.mInvokeFunctions[i]), &length);
|
||||
//LOGE("func %i %p", i, s->mEnviroment.mInvokeFunctions[i]);
|
||||
bccGetExportFuncs(s->mBccScript, (BCCsizei*) &s->mEnviroment.mInvokeFunctionCount, 0, NULL);
|
||||
if(s->mEnviroment.mInvokeFunctionCount <= 0)
|
||||
s->mEnviroment.mInvokeFunctions = NULL;
|
||||
else {
|
||||
s->mEnviroment.mInvokeFunctions = (Script::InvokeFunc_t*) calloc(s->mEnviroment.mInvokeFunctionCount, sizeof(Script::InvokeFunc_t));
|
||||
bccGetExportFuncs(s->mBccScript, NULL, s->mEnviroment.mInvokeFunctionCount, (BCCvoid **) s->mEnviroment.mInvokeFunctions);
|
||||
}
|
||||
|
||||
// s->mEnviroment.mInvokeFunctions = (Script::InvokeFunc_t *)calloc(100, sizeof(void *));
|
||||
// BCCchar **labels = new char*[100];
|
||||
// bccGetFunctions(s->mBccScript, (BCCsizei *)&s->mEnviroment.mInvokeFunctionCount,
|
||||
// 100, (BCCchar **)labels);
|
||||
//LOGE("func count %i", s->mEnviroment.mInvokeFunctionCount);
|
||||
// for (uint32_t i=0; i < s->mEnviroment.mInvokeFunctionCount; i++) {
|
||||
// BCCsizei length;
|
||||
// bccGetFunctionBinary(s->mBccScript, labels[i], (BCCvoid **)&(s->mEnviroment.mInvokeFunctions[i]), &length);
|
||||
//LOGE("func %i %p", i, s->mEnviroment.mInvokeFunctions[i]);
|
||||
// }
|
||||
|
||||
s->mEnviroment.mFieldAddress = (void **)calloc(100, sizeof(void *));
|
||||
bccGetExportVars(s->mBccScript, (BCCsizei *)&s->mEnviroment.mFieldCount,
|
||||
100, s->mEnviroment.mFieldAddress);
|
||||
|
||||
@@ -477,6 +477,8 @@ static ScriptCState::SymbolTable_t gSyms[] = {
|
||||
|
||||
{ "_Z18rsgUploadToTextureii", (void *)&SC_uploadToTexture2 },
|
||||
{ "_Z18rsgUploadToTexturei", (void *)&SC_uploadToTexture },
|
||||
{ "_Z18rsgUploadToTexture13rs_allocationi", (void *)&SC_uploadToTexture2 },
|
||||
{ "_Z18rsgUploadToTexture13rs_allocation", (void *)&SC_uploadToTexture },
|
||||
{ "rsgUploadToBufferObject", (void *)&SC_uploadToBufferObject },
|
||||
|
||||
{ "rsgDrawRect", (void *)&SC_drawRect },
|
||||
@@ -487,6 +489,8 @@ static ScriptCState::SymbolTable_t gSyms[] = {
|
||||
{ "rsgDrawSpriteScreenspaceCropped", (void *)&SC_drawSpriteScreenspaceCropped },
|
||||
{ "rsgDrawLine", (void *)&SC_drawLine },
|
||||
{ "rsgDrawPoint", (void *)&SC_drawPoint },
|
||||
{ "_Z17rsgDrawSimpleMesh7rs_mesh", (void *)&SC_drawSimpleMesh },
|
||||
{ "_Z17rsgDrawSimpleMesh7rs_meshii", (void *)&SC_drawSimpleMeshRange },
|
||||
{ "_Z17rsgDrawSimpleMeshi", (void *)&SC_drawSimpleMesh },
|
||||
{ "_Z17rsgDrawSimpleMeshiii", (void *)&SC_drawSimpleMeshRange },
|
||||
|
||||
|
||||
Reference in New Issue
Block a user