From d79b2e9f8b0fa43f6734aaa5e9d0d389d5da5109 Mon Sep 17 00:00:00 2001 From: Jason Sams Date: Wed, 19 May 2010 17:22:57 -0700 Subject: [PATCH] Begin naming cleanup for renderscript runtime. Prefix functions with "rs" or "rsg". Change-Id: I4435b486831bfab1ea473ccfad435b404e68f1c9 --- .../android/renderscript/RenderScript.java | 3 - .../java/android/renderscript/Script.java | 15 - .../jni/android_renderscript_RenderScript.cpp | 26 - .../Film/src/com/android/film/FilmRS.java | 4 - libs/rs/java/Fountain/res/raw/fountain.rs | 36 +- libs/rs/java/Fountain/res/raw/fountain_bc.bc | Bin 2048 -> 2532 bytes .../src/com/android/fountain/FountainRS.java | 2 - .../android/fountain/ScriptC_Fountain.java | 7 +- libs/rs/rs.spec | 17 - libs/rs/rsContext.cpp | 26 +- libs/rs/rsContext.h | 2 - libs/rs/rsScript.cpp | 88 +-- libs/rs/rsScript.h | 5 +- libs/rs/rsScriptC.cpp | 63 +- libs/rs/rsScriptC.h | 5 + libs/rs/rsScriptC_Lib.cpp | 228 +++--- libs/rs/rsScriptC_LibGL.cpp | 104 +-- libs/rs/scriptc/rs_cl.rsh | 620 +++++++++++++++ libs/rs/scriptc/rs_graphics.rsh | 91 +-- libs/rs/scriptc/rs_math.rsh | 738 +++--------------- libs/rs/scriptc/rs_types.rsh | 10 +- 21 files changed, 1002 insertions(+), 1088 deletions(-) create mode 100644 libs/rs/scriptc/rs_cl.rsh diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java index 92ac5737ce125..acc58bc832d44 100644 --- a/graphics/java/android/renderscript/RenderScript.java +++ b/graphics/java/android/renderscript/RenderScript.java @@ -134,9 +134,6 @@ public class RenderScript { native int nAdapter2DCreate(); native void nScriptBindAllocation(int script, int alloc, int slot); - native void nScriptSetClearColor(int script, float r, float g, float b, float a); - native void nScriptSetClearDepth(int script, float depth); - native void nScriptSetClearStencil(int script, int stencil); native void nScriptSetTimeZone(int script, byte[] timeZone); native void nScriptInvoke(int id, int slot); native void nScriptInvokeData(int id, int slot); diff --git a/graphics/java/android/renderscript/Script.java b/graphics/java/android/renderscript/Script.java index 632a459069a56..4c4071a25f3bd 100644 --- a/graphics/java/android/renderscript/Script.java +++ b/graphics/java/android/renderscript/Script.java @@ -81,21 +81,6 @@ public class Script extends BaseObj { mRS.nScriptSetVarV(mID, index, v.getData()); } - public void setClearColor(float r, float g, float b, float a) { - mRS.validate(); - mRS.nScriptSetClearColor(mID, r, g, b, a); - } - - public void setClearDepth(float d) { - mRS.validate(); - mRS.nScriptSetClearDepth(mID, d); - } - - public void setClearStencil(int stencil) { - mRS.validate(); - mRS.nScriptSetClearStencil(mID, stencil); - } - public void setTimeZone(String timeZone) { mRS.validate(); try { diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp index 7170e5aeb1718..223ef4bd7e5e0 100644 --- a/graphics/jni/android_renderscript_RenderScript.cpp +++ b/graphics/jni/android_renderscript_RenderScript.cpp @@ -880,29 +880,6 @@ nScriptSetVarV(JNIEnv *_env, jobject _this, jint script, jint slot, jbyteArray d _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); } -static void -nScriptSetClearColor(JNIEnv *_env, jobject _this, jint script, jfloat r, jfloat g, jfloat b, jfloat a) -{ - RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nScriptSetClearColor, con(%p), s(%p), r(%f), g(%f), b(%f), a(%f)", con, (void *)script, r, g, b, a); - rsScriptSetClearColor(con, (RsScript)script, r, g, b, a); -} - -static void -nScriptSetClearDepth(JNIEnv *_env, jobject _this, jint script, jfloat d) -{ - RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nScriptCSetClearDepth, con(%p), s(%p), depth(%f)", con, (void *)script, d); - rsScriptSetClearDepth(con, (RsScript)script, d); -} - -static void -nScriptSetClearStencil(JNIEnv *_env, jobject _this, jint script, jint stencil) -{ - RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nScriptCSetClearStencil, con(%p), s(%p), stencil(%i)", con, (void *)script, stencil); - rsScriptSetClearStencil(con, (RsScript)script, stencil); -} static void nScriptSetTimeZone(JNIEnv *_env, jobject _this, jint script, jbyteArray timeZone) @@ -1410,9 +1387,6 @@ static JNINativeMethod methods[] = { {"nAdapter2DCreate", "()I", (void*)nAdapter2DCreate }, {"nScriptBindAllocation", "(III)V", (void*)nScriptBindAllocation }, -{"nScriptSetClearColor", "(IFFFF)V", (void*)nScriptSetClearColor }, -{"nScriptSetClearDepth", "(IF)V", (void*)nScriptSetClearDepth }, -{"nScriptSetClearStencil", "(II)V", (void*)nScriptSetClearStencil }, {"nScriptSetTimeZone", "(I[B)V", (void*)nScriptSetTimeZone }, {"nScriptInvoke", "(II)V", (void*)nScriptInvoke }, {"nScriptInvokeData", "(II)V", (void*)nScriptInvokeData }, diff --git a/libs/rs/java/Film/src/com/android/film/FilmRS.java b/libs/rs/java/Film/src/com/android/film/FilmRS.java index e26b051c9a538..93438a0b2c2ec 100644 --- a/libs/rs/java/Film/src/com/android/film/FilmRS.java +++ b/libs/rs/java/Film/src/com/android/film/FilmRS.java @@ -213,13 +213,9 @@ public class FilmRS { Log.e("rs", "Done loading named"); - //mStripPositionType = Type.createFromClass(mRS, StripPosition.class, 1); - ScriptC.Builder sb = new ScriptC.Builder(mRS); sb.setScript(mRes, R.raw.filmstrip); - //sb.setType(mStripPositionType, "Pos", 1); mScriptStrip = sb.create(); - mScriptStrip.setClearColor(0.0f, 0.0f, 0.0f, 1.0f); mAllocPos = Allocation.createTyped(mRS, mStripPositionType); diff --git a/libs/rs/java/Fountain/res/raw/fountain.rs b/libs/rs/java/Fountain/res/raw/fountain.rs index 5562a7767b99b..8b6994178e939 100644 --- a/libs/rs/java/Fountain/res/raw/fountain.rs +++ b/libs/rs/java/Fountain/res/raw/fountain.rs @@ -9,7 +9,6 @@ static int newPart = 0; float4 partColor; rs_mesh partMesh; -rs_allocation partBuffer; typedef struct __attribute__((packed, aligned(4))) Point_s { float2 delta; @@ -18,17 +17,13 @@ typedef struct __attribute__((packed, aligned(4))) Point_s { } Point_t; Point_t *point; -#pragma rs export_var(point, partColor, partMesh, partBuffer) -//#pragma rs export_type(Point_s) -//#pragma rs export_element(point) +#pragma rs export_var(point, partColor, partMesh) int root() { - debugPf(1, partColor.x); - debugPi(4, partMesh); - debugPi(5, partBuffer); - - float height = getHeight(); - int size = allocGetDimX(partBuffer); + rsgClearColor(0.f, 0.f, 0.f, 1.f); + float height = rsgGetHeight(); + rs_allocation alloc = rsGetAllocation(point); + int size = rsAllocationGetDimX(alloc); Point_t * p = point; for (int ct=0; ct < size; ct++) { @@ -40,22 +35,31 @@ int root() { p++; } - uploadToBufferObject(partBuffer); - drawSimpleMesh(partMesh); + rsgUploadToBufferObject(alloc); + rsgDrawSimpleMesh(partMesh); return 1; } void addParticles(int rate, int x, int y) { - float rMax = ((float)rate) * 0.005f; - int size = allocGetDimX(partBuffer); + rsDebug("partColor", partColor); + rsDebug("partColor x", partColor.x); + rsDebug("partColor y", partColor.y); + rsDebug("partColor z", partColor.z); + rsDebug("partColor w", partColor.w); - rs_color4u c = convertColorTo8888(partColor.x, partColor.y, partColor.z); + float rMax = ((float)rate) * 0.005f; + int size = rsAllocationGetDimX(rsGetAllocation(point)); + + rs_color4u c = rsPackColorTo8888(partColor.x, partColor.y, partColor.z); Point_t * np = &point[newPart]; float2 p = {x, y}; while (rate--) { - np->delta = vec2Rand(rMax); + float angle = rsRand(3.14f * 2.f); + float len = rsRand(rMax); + np->delta.x = len * sin(angle); + np->delta.y = len * cos(angle); np->pos = p; np->color = c; newPart++; diff --git a/libs/rs/java/Fountain/res/raw/fountain_bc.bc b/libs/rs/java/Fountain/res/raw/fountain_bc.bc index f14706877eaf45b3fc878aac069918924dd217d2..45475faf662e4158c74e04beaf7376a8c20735d5 100644 GIT binary patch delta 2179 zcmYjS4^R_V8h=SP$p$wun4lXZumMC`qb4MjpuuiJ2tgwR5ye8!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trm|;zNgmqdAUGImpE?>NP+tZ&+5B4_A*VZQjHfY{hBT?mg|qW7I>7+ zlpjl!5=HHpz@Bwb%G^x*7GvO$Qn8d8ibL&7olFXwQ&WN-X;Y$0^MfN4HKgGz#%;li zWm@priKFFu{g#pKf_^va0jR&)KF%9QMJh|GWYVKfB+NsP(u$?o4=m2{rlW*j|6GF> zI{%bt9CKTUsfXj0rf%5vEoF?I{ph5oVm_n7P(x@K1rC@Hxxm=uOTDpuF59?QBEOlWkIo`As(mTh!cf!b$dQA}M4t~lc+MWIx_}GQd!vOFk zT>pboU^|3T?t%b*bNj6p+c*HLMb#JY$miehNagn&0&M8~Mz4>2WL@Zdtydi{H(nvc zC8G6b_yh5#Dt8m*<-}h!25#{XNO>FnhLAj!rX?J|?0t zP55W3d#ZxG@od$v1rhVMpmCHV$Lh$~iP;a{RVA;^wALE}G4l~WsKni88~boMqVTN5 ztat4iV0=jz()~64Wit>>Ipw%e>KyGcGCWts@2gN;spJ4is~JL zB%2*Rpn}e!hWt><_@E(qbQ7#KvOPIvzV}BWI07Rs4+_k@JhT~qp%U-iOQZd|OyO@n z9~4M>`H#q(-YTlhVNUjmjR$a7*Hc+EE`CKgs|A diff --git a/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java b/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java index d193134c1c05a..ba09a161217a6 100644 --- a/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java +++ b/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java @@ -77,9 +77,7 @@ public class FountainRS { mSM.bindVertexAllocation(mPoints.getAllocation(), vtxSlot); mScript = new ScriptC_Fountain(mRS, mRes, true); - mScript.setClearColor(0.0f, 0.0f, 0.0f, 1.0f); mScript.set_partMesh(mSM); - mScript.set_partBuffer(mPoints.getAllocation()); mScript.bind_point(mPoints); mRS.contextBindRootScript(mScript); } diff --git a/libs/rs/java/Fountain/src/com/android/fountain/ScriptC_Fountain.java b/libs/rs/java/Fountain/src/com/android/fountain/ScriptC_Fountain.java index 7cff390c9a793..cace1ecbb4562 100644 --- a/libs/rs/java/Fountain/src/com/android/fountain/ScriptC_Fountain.java +++ b/libs/rs/java/Fountain/src/com/android/fountain/ScriptC_Fountain.java @@ -20,17 +20,14 @@ public class ScriptC_Fountain public void set_partMesh(SimpleMesh v) { setVar(1, v.getID()); } - public void set_partBuffer(Allocation v) { - setVar(2, v.getID()); - } private ScriptField_Point mField_point; public void bind_point(ScriptField_Point f) { mField_point = f; if (f == null) { - bindAllocation(null, 3); + bindAllocation(null, 2); } else { - bindAllocation(f.getAllocation(), 3); + bindAllocation(f.getAllocation(), 2); } } public ScriptField_Point get_point() { diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec index 4ad25aebaf29e..2a872cd21241a 100644 --- a/libs/rs/rs.spec +++ b/libs/rs/rs.spec @@ -248,13 +248,6 @@ ScriptBindAllocation { ScriptCBegin { } -ScriptSetClearColor { - param RsScript s - param float r - param float g - param float b - param float a - } ScriptSetTimeZone { param RsScript s @@ -262,16 +255,6 @@ ScriptSetTimeZone { param uint32_t length } -ScriptSetClearDepth { - param RsScript s - param float depth - } - -ScriptSetClearStencil { - param RsScript s - param uint32_t stencil - } - ScriptInvoke { param RsScript s diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp index da85f83ac60ec..f99e5f217bbe7 100644 --- a/libs/rs/rsContext.cpp +++ b/libs/rs/rsContext.cpp @@ -111,9 +111,6 @@ void Context::initEGL(bool useGL2) LOGE("eglCreateContext returned EGL_NO_CONTEXT"); } gGLContextCount++; - - eglQuerySurface(mEGL.mDisplay, mEGL.mSurface, EGL_WIDTH, &mEGL.mWidth); - eglQuerySurface(mEGL.mDisplay, mEGL.mSurface, EGL_HEIGHT, &mEGL.mHeight); } void Context::deinitEGL() @@ -156,21 +153,7 @@ void Context::checkError(const char *msg) const uint32_t Context::runRootScript() { - timerSet(RS_TIMER_CLEAR_SWAP); - glViewport(0, 0, mWidth, mHeight); - glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - glClearColor(mRootScript->mEnviroment.mClearColor[0], - mRootScript->mEnviroment.mClearColor[1], - mRootScript->mEnviroment.mClearColor[2], - mRootScript->mEnviroment.mClearColor[3]); - if (mUseDepth) { - glDepthMask(GL_TRUE); - glClearDepthf(mRootScript->mEnviroment.mClearDepth); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - } else { - glClear(GL_COLOR_BUFFER_BIT); - } timerSet(RS_TIMER_SCRIPT); mStateFragmentStore.mLast.clear(); @@ -485,8 +468,6 @@ void Context::setSurface(uint32_t w, uint32_t h, android_native_window_t *sur) checkEglError("eglDestroySurface", ret); mEGL.mSurface = NULL; - mEGL.mWidth = 0; - mEGL.mHeight = 0; mWidth = 0; mHeight = 0; } @@ -514,10 +495,6 @@ void Context::setSurface(uint32_t w, uint32_t h, android_native_window_t *sur) mStateVertex.updateSize(this); - if ((int)mWidth != mEGL.mWidth || (int)mHeight != mEGL.mHeight) { - LOGE("EGL/Surface mismatch EGL (%i x %i) SF (%i x %i)", mEGL.mWidth, mEGL.mHeight, mWidth, mHeight); - } - if (first) { mGL.mVersion = glGetString(GL_VERSION); mGL.mVendor = glGetString(GL_VENDOR); @@ -762,8 +739,7 @@ void Context::dumpDebug() const LOGE("RS Context debug"); LOGE(" EGL ver %i %i", mEGL.mMajorVersion, mEGL.mMinorVersion); - LOGE(" EGL context %p surface %p, w=%i h=%i Display=%p", mEGL.mContext, - mEGL.mSurface, mEGL.mWidth, mEGL.mHeight, mEGL.mDisplay); + LOGE(" EGL context %p surface %p, Display=%p", mEGL.mContext, mEGL.mSurface, mEGL.mDisplay); LOGE(" GL vendor: %s", mGL.mVendor); LOGE(" GL renderer: %s", mGL.mRenderer); LOGE(" GL Version: %s", mGL.mVersion); diff --git a/libs/rs/rsContext.h b/libs/rs/rsContext.h index 4a6072d6093af..9df07dc69abd3 100644 --- a/libs/rs/rsContext.h +++ b/libs/rs/rsContext.h @@ -176,8 +176,6 @@ protected: EGLConfig mConfig; EGLContext mContext; EGLSurface mSurface; - EGLint mWidth; - EGLint mHeight; EGLDisplay mDisplay; } mEGL; diff --git a/libs/rs/rsScript.cpp b/libs/rs/rsScript.cpp index b0bbb22a95a78..fc22fc3f39f71 100644 --- a/libs/rs/rsScript.cpp +++ b/libs/rs/rsScript.cpp @@ -24,12 +24,6 @@ Script::Script(Context *rsc) : ObjectBase(rsc) mAllocFile = __FILE__; mAllocLine = __LINE__; memset(&mEnviroment, 0, sizeof(mEnviroment)); - mEnviroment.mClearColor[0] = 0; - mEnviroment.mClearColor[1] = 0; - mEnviroment.mClearColor[2] = 0; - mEnviroment.mClearColor[3] = 1; - mEnviroment.mClearDepth = 1; - mEnviroment.mClearStencil = 0; } Script::~Script() @@ -61,33 +55,12 @@ void rsi_ScriptBindAllocation(Context * rsc, RsScript vs, RsAllocation va, uint3 //LOGE("rsi_ScriptBindAllocation %i %p %p", slot, a, a->getPtr()); } -void rsi_ScriptSetClearColor(Context * rsc, RsScript vs, float r, float g, float b, float a) -{ - Script *s = static_cast