Cleanup logging and fix a startup race condition that manifested on Firestone.
This commit is contained in:
@@ -40,7 +40,7 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback
|
||||
public RSSurfaceView(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
Log.v("***", "RSSurfaceView");
|
||||
Log.v(RenderScript.LOG_TAG, "RSSurfaceView");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,7 +50,7 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback
|
||||
public RSSurfaceView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
Log.v("***", "RSSurfaceView");
|
||||
Log.v(RenderScript.LOG_TAG, "RSSurfaceView");
|
||||
}
|
||||
|
||||
private void init() {
|
||||
@@ -66,7 +66,7 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback
|
||||
* not normally called or subclassed by clients of RSSurfaceView.
|
||||
*/
|
||||
public void surfaceCreated(SurfaceHolder holder) {
|
||||
Log.v("***", "surfaceCreated");
|
||||
Log.v(RenderScript.LOG_TAG, "surfaceCreated");
|
||||
mSurfaceHolder = holder;
|
||||
//mGLThread.surfaceCreated();
|
||||
}
|
||||
@@ -77,7 +77,7 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback
|
||||
*/
|
||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||
// Surface will be destroyed when we return
|
||||
Log.v("***", "surfaceDestroyed");
|
||||
Log.v(RenderScript.LOG_TAG, "surfaceDestroyed");
|
||||
//mGLThread.surfaceDestroyed();
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback
|
||||
* not normally called or subclassed by clients of RSSurfaceView.
|
||||
*/
|
||||
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
|
||||
Log.v("***", "surfaceChanged");
|
||||
Log.v(RenderScript.LOG_TAG, "surfaceChanged");
|
||||
|
||||
//mGLThread.onWindowResize(w, h);
|
||||
}
|
||||
@@ -98,7 +98,7 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback
|
||||
* Must not be called before a renderer has been set.
|
||||
*/
|
||||
public void onPause() {
|
||||
Log.v("***", "onPause");
|
||||
Log.v(RenderScript.LOG_TAG, "onPause");
|
||||
//mGLThread.onPause();
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback
|
||||
* Must not be called before a renderer has been set.
|
||||
*/
|
||||
public void onResume() {
|
||||
Log.v("***", "onResume");
|
||||
Log.v(RenderScript.LOG_TAG, "onResume");
|
||||
//mGLThread.onResume();
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback
|
||||
* @param r the runnable to be run on the GL rendering thread.
|
||||
*/
|
||||
public void queueEvent(Runnable r) {
|
||||
Log.v("***", "queueEvent");
|
||||
Log.v(RenderScript.LOG_TAG, "queueEvent");
|
||||
//mGLThread.queueEvent(r);
|
||||
}
|
||||
|
||||
@@ -139,14 +139,14 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
public RenderScript createRenderScript() {
|
||||
Log.v("***", "createRenderScript 1");
|
||||
Log.v(RenderScript.LOG_TAG, "createRenderScript 1");
|
||||
Surface sur = null;
|
||||
while ((sur == null) || (mSurfaceHolder == null)) {
|
||||
sur = getHolder().getSurface();
|
||||
}
|
||||
Log.v("***", "createRenderScript 2");
|
||||
Log.v(RenderScript.LOG_TAG, "createRenderScript 2");
|
||||
RenderScript rs = new RenderScript(sur);
|
||||
Log.v("***", "createRenderScript 3 rs");
|
||||
Log.v(RenderScript.LOG_TAG, "createRenderScript 3 rs");
|
||||
return rs;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
|
||||
public class RenderScript {
|
||||
private static final String LOG_TAG = "libRS_jni";
|
||||
static final String LOG_TAG = "libRS_jni";
|
||||
private static final boolean DEBUG = false;
|
||||
private static final boolean LOG_ENABLED = DEBUG ? Config.LOGD : Config.LOGV;
|
||||
|
||||
|
||||
@@ -14,12 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "libRS_jni"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <utils/misc.h>
|
||||
|
||||
#include <ui/EGLNativeWindowSurface.h>
|
||||
@@ -27,6 +28,7 @@
|
||||
|
||||
#include <core/SkBitmap.h>
|
||||
|
||||
|
||||
#include "jni.h"
|
||||
#include "JNIHelp.h"
|
||||
#include "android_runtime/AndroidRuntime.h"
|
||||
@@ -107,7 +109,6 @@ nContextCreate(JNIEnv *_env, jobject _this, jint dev, jobject wnd, jint ver)
|
||||
if (window == NULL)
|
||||
goto not_valid_surface;
|
||||
|
||||
LOGE("nContextCreate 5");
|
||||
return (jint)rsContextCreate((RsDevice)dev, window, ver);
|
||||
}
|
||||
|
||||
@@ -1068,8 +1069,6 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved)
|
||||
JNIEnv* env = NULL;
|
||||
jint result = -1;
|
||||
|
||||
LOGE("****************************************************\n");
|
||||
|
||||
if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) {
|
||||
LOGE("ERROR: GetEnv failed\n");
|
||||
goto bail;
|
||||
|
||||
@@ -50,7 +50,6 @@ Allocation::Allocation(const Type *type)
|
||||
|
||||
Allocation::~Allocation()
|
||||
{
|
||||
LOGE("Allocation %p destryed", this);
|
||||
}
|
||||
|
||||
void Allocation::setCpuWritable(bool)
|
||||
@@ -79,8 +78,6 @@ void Allocation::uploadToTexture(uint32_t lodOffset)
|
||||
//rsAssert(!mTextureId);
|
||||
rsAssert(lodOffset < mType->getLODCount());
|
||||
|
||||
//LOGE("uploadToTexture %i, lod %i", mTextureID, lodOffset);
|
||||
|
||||
GLenum type = mType->getElement()->getGLType();
|
||||
GLenum format = mType->getElement()->getGLFormat();
|
||||
|
||||
@@ -109,8 +106,6 @@ void Allocation::uploadToBufferObject()
|
||||
rsAssert(!mType->getDimY());
|
||||
rsAssert(!mType->getDimZ());
|
||||
|
||||
//LOGE("uploadToTexture %i, lod %i", mTextureID, lodOffset);
|
||||
|
||||
if (!mBufferID) {
|
||||
glGenBuffers(1, &mBufferID);
|
||||
}
|
||||
|
||||
@@ -119,9 +119,6 @@ void * Context::threadProc(void *vrsc)
|
||||
Context *rsc = static_cast<Context *>(vrsc);
|
||||
|
||||
gIO = new ThreadIO();
|
||||
rsc->mServerCommands.init(128);
|
||||
rsc->mServerReturns.init(128);
|
||||
|
||||
rsc->initEGL();
|
||||
|
||||
ScriptTLSStruct *tlsStruct = new ScriptTLSStruct;
|
||||
@@ -169,9 +166,6 @@ Context::Context(Device *dev, Surface *sur)
|
||||
mRunning = false;
|
||||
mExit = false;
|
||||
|
||||
mServerCommands.init(256);
|
||||
mServerReturns.init(256);
|
||||
|
||||
// see comment in header
|
||||
gCon = this;
|
||||
|
||||
@@ -194,13 +188,14 @@ Context::Context(Device *dev, Surface *sur)
|
||||
sparam.sched_priority = ANDROID_PRIORITY_DISPLAY;
|
||||
pthread_attr_setschedparam(&threadAttr, &sparam);
|
||||
|
||||
LOGE("RS Launching thread");
|
||||
mWndSurface = sur;
|
||||
|
||||
LOGV("RS Launching thread");
|
||||
status = pthread_create(&mThreadId, &threadAttr, threadProc, this);
|
||||
if (status) {
|
||||
LOGE("Failed to start rs context thread.");
|
||||
}
|
||||
|
||||
mWndSurface = sur;
|
||||
while(!mRunning) {
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
@@ -116,9 +116,6 @@ protected:
|
||||
bool mRunning;
|
||||
bool mExit;
|
||||
|
||||
LocklessCommandFifo mServerCommands;
|
||||
LocklessCommandFifo mServerReturns;
|
||||
|
||||
pthread_t mThreadId;
|
||||
|
||||
ObjectBaseRef<Script> mRootScript;
|
||||
|
||||
@@ -410,8 +410,6 @@ RsElement rsi_ElementCreate(Context *rsc)
|
||||
|
||||
rsc->mStateElement.mComponentBuildList.clear();
|
||||
se->incRef();
|
||||
|
||||
LOGE("Create %p", se);
|
||||
return se;
|
||||
}
|
||||
|
||||
|
||||
@@ -64,8 +64,6 @@ uint32_t LocklessCommandFifo::getFreeSpace() const
|
||||
if (freeSpace < 0) {
|
||||
freeSpace = 0;
|
||||
}
|
||||
|
||||
//LOGE("free %i", freeSpace);
|
||||
return freeSpace;
|
||||
}
|
||||
|
||||
@@ -90,13 +88,11 @@ void * LocklessCommandFifo::reserve(uint32_t sizeInBytes)
|
||||
|
||||
void LocklessCommandFifo::commit(uint32_t command, uint32_t sizeInBytes)
|
||||
{
|
||||
//LOGE("commit cmd %i size %i", command, sizeInBytes);
|
||||
//dumpState("commit 1");
|
||||
reinterpret_cast<uint16_t *>(mPut)[0] = command;
|
||||
reinterpret_cast<uint16_t *>(mPut)[1] = sizeInBytes;
|
||||
mPut += ((sizeInBytes + 3) & ~3) + 4;
|
||||
//dumpState("commit 2");
|
||||
|
||||
mSignalToWorker.set();
|
||||
}
|
||||
|
||||
@@ -123,12 +119,9 @@ const void * LocklessCommandFifo::get(uint32_t *command, uint32_t *bytesData)
|
||||
mSignalToControl.set();
|
||||
mSignalToWorker.wait();
|
||||
}
|
||||
//dumpState("get 3");
|
||||
|
||||
*command = reinterpret_cast<const uint16_t *>(mGet)[0];
|
||||
*bytesData = reinterpret_cast<const uint16_t *>(mGet)[1];
|
||||
//LOGE("Got %i, %i", *command, *bytesData);
|
||||
|
||||
if (*command) {
|
||||
// non-zero command is valid
|
||||
return mGet+4;
|
||||
@@ -173,7 +166,7 @@ void LocklessCommandFifo::makeSpace(uint32_t bytes)
|
||||
|
||||
void LocklessCommandFifo::dumpState(const char *s) const
|
||||
{
|
||||
LOGE("%s put %p, get %p, buf %p, end %p", s, mPut, mGet, mBuffer, mEnd);
|
||||
LOGV("%s put %p, get %p, buf %p, end %p", s, mPut, mGet, mBuffer, mEnd);
|
||||
}
|
||||
|
||||
LocklessCommandFifo::Signal::Signal()
|
||||
|
||||
@@ -33,14 +33,14 @@ ObjectBase::~ObjectBase()
|
||||
void ObjectBase::incRef() const
|
||||
{
|
||||
mRefCount ++;
|
||||
//LOGE("ObjectBase %p inc ref %i", this, mRefCount);
|
||||
//LOGV("ObjectBase %p inc ref %i", this, mRefCount);
|
||||
}
|
||||
|
||||
void ObjectBase::decRef() const
|
||||
{
|
||||
rsAssert(mRefCount > 0);
|
||||
mRefCount --;
|
||||
//LOGE("ObjectBase %p dec ref %i", this, mRefCount);
|
||||
//LOGV("ObjectBase %p dec ref %i", this, mRefCount);
|
||||
if (!mRefCount) {
|
||||
delete this;
|
||||
}
|
||||
|
||||
@@ -171,8 +171,6 @@ void rsi_ProgramFragmentBindTexture(Context *rsc, RsProgramFragment vpf, uint32_
|
||||
{
|
||||
ProgramFragment *pf = static_cast<ProgramFragment *>(vpf);
|
||||
pf->bindTexture(slot, static_cast<Allocation *>(a));
|
||||
|
||||
//LOGE("%p %p", pf, rsc->getFragment());
|
||||
if (pf == rsc->getFragment()) {
|
||||
pf->setupGL();
|
||||
}
|
||||
|
||||
@@ -36,11 +36,11 @@ ProgramVertex::~ProgramVertex()
|
||||
|
||||
static void logMatrix(const char *txt, const float *f)
|
||||
{
|
||||
LOGE("Matrix %s, %p", txt, f);
|
||||
LOGE("%6.2f, %6.2f, %6.2f, %6.2f", f[0], f[4], f[8], f[12]);
|
||||
LOGE("%6.2f, %6.2f, %6.2f, %6.2f", f[1], f[5], f[9], f[13]);
|
||||
LOGE("%6.2f, %6.2f, %6.2f, %6.2f", f[2], f[6], f[10], f[14]);
|
||||
LOGE("%6.2f, %6.2f, %6.2f, %6.2f", f[3], f[7], f[11], f[15]);
|
||||
LOGV("Matrix %s, %p", txt, f);
|
||||
LOGV("%6.2f, %6.2f, %6.2f, %6.2f", f[0], f[4], f[8], f[12]);
|
||||
LOGV("%6.2f, %6.2f, %6.2f, %6.2f", f[1], f[5], f[9], f[13]);
|
||||
LOGV("%6.2f, %6.2f, %6.2f, %6.2f", f[2], f[6], f[10], f[14]);
|
||||
LOGV("%6.2f, %6.2f, %6.2f, %6.2f", f[3], f[7], f[11], f[15]);
|
||||
}
|
||||
|
||||
void ProgramVertex::setupGL()
|
||||
|
||||
@@ -472,14 +472,10 @@ void ScriptCState::runCompiler(Context *rsc)
|
||||
accGetPragmas(mAccScript, &pragmaCount, pragmaMax, &str[0]);
|
||||
|
||||
for (int ct=0; ct < pragmaCount; ct+=2) {
|
||||
LOGE("pragma %i %s %s", ct, str[ct], str[ct+1]);
|
||||
|
||||
if (!strcmp(str[ct], "version")) {
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (!strcmp(str[ct], "stateVertex")) {
|
||||
if (!strcmp(str[ct+1], "default")) {
|
||||
continue;
|
||||
|
||||
@@ -34,22 +34,17 @@ ThreadIO::~ThreadIO()
|
||||
|
||||
bool ThreadIO::playCoreCommands(Context *con, bool waitForCommand)
|
||||
{
|
||||
//LOGE("playCoreCommands 1");
|
||||
uint32_t cmdID = 0;
|
||||
uint32_t cmdSize = 0;
|
||||
bool ret = false;
|
||||
while(!mToCore.isEmpty() || waitForCommand) {
|
||||
ret = true;
|
||||
//LOGE("playCoreCommands 2");
|
||||
const void * data = mToCore.get(&cmdID, &cmdSize);
|
||||
waitForCommand = false;
|
||||
//LOGE("playCoreCommands 3 %i %i", cmdID, cmdSize);
|
||||
//LOGV("playCoreCommands 3 %i %i", cmdID, cmdSize);
|
||||
|
||||
gPlaybackFuncs[cmdID](con, data);
|
||||
//LOGE("playCoreCommands 4");
|
||||
|
||||
mToCore.next();
|
||||
//LOGE("playCoreCommands 5");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ void TriangleMesh::analyzeElement()
|
||||
mSizeTex = 2;
|
||||
}
|
||||
}
|
||||
LOGE("TriangleMesh %i,%i %i,%i %i,%i", mSizeCoord, mOffsetCoord, mSizeNorm, mOffsetNorm, mSizeTex, mOffsetTex);
|
||||
LOGV("TriangleMesh %i,%i %i,%i %i,%i", mSizeCoord, mOffsetCoord, mSizeNorm, mOffsetNorm, mSizeTex, mOffsetTex);
|
||||
|
||||
}
|
||||
|
||||
@@ -130,7 +130,6 @@ namespace renderscript {
|
||||
|
||||
void rsi_TriangleMeshBegin(Context *rsc, RsElement vertex, RsElement index)
|
||||
{
|
||||
//LOGE("tmb %p %p", vertex, index);
|
||||
TriangleMeshContext *tmc = &rsc->mStateTriangleMesh;
|
||||
|
||||
tmc->clear();
|
||||
@@ -139,8 +138,6 @@ void rsi_TriangleMeshBegin(Context *rsc, RsElement vertex, RsElement index)
|
||||
tmc->mIndexElement = static_cast<Element *>(index);
|
||||
tmc->mIndexSizeBits = tmc->mIndexElement->getSizeBits();
|
||||
|
||||
//LOGE("Element sizes %i %i", tmc->mVertexSizeBits, tmc->mIndexSizeBits);
|
||||
|
||||
assert(!(tmc->mVertexSizeBits & 0x7));
|
||||
assert(!(tmc->mIndexSizeBits & 0x7));
|
||||
}
|
||||
@@ -198,8 +195,6 @@ RsTriangleMesh rsi_TriangleMeshCreate(Context *rsc)
|
||||
return 0;
|
||||
}
|
||||
|
||||
LOGE("Create mesh, triangleCount %i", tm->mTriangleCount);
|
||||
|
||||
memcpy(tm->mVertexData, tmc->mVertexData.array(), tm->mVertexDataSize);
|
||||
memcpy(tm->mIndexData, tmc->mIndexData.array(), tm->mIndexDataSize);
|
||||
tm->analyzeElement();
|
||||
@@ -225,8 +220,6 @@ void rsi_TriangleMeshRenderRange(Context *rsc, RsTriangleMesh vtm, uint32_t firs
|
||||
|
||||
rsc->setupCheck();
|
||||
|
||||
//LOGE("1 %p ", vtm);
|
||||
//LOGE("1.1 %p %p", tm->mVertexData, tm->mIndexData);
|
||||
if (!tm->mBufferObjects[0]) {
|
||||
glGenBuffers(2, &tm->mBufferObjects[0]);
|
||||
|
||||
@@ -239,7 +232,6 @@ void rsi_TriangleMeshRenderRange(Context *rsc, RsTriangleMesh vtm, uint32_t firs
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
//LOGE("1.2");
|
||||
if (first >= tm->mTriangleCount) {
|
||||
return;
|
||||
}
|
||||
@@ -252,7 +244,6 @@ void rsi_TriangleMeshRenderRange(Context *rsc, RsTriangleMesh vtm, uint32_t firs
|
||||
|
||||
const float *f = (const float *)tm->mVertexData;
|
||||
|
||||
//LOGE("2");
|
||||
glBindBuffer(GL_ARRAY_BUFFER, tm->mBufferObjects[0]);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, tm->mBufferObjects[1]);
|
||||
|
||||
@@ -283,8 +274,6 @@ void rsi_TriangleMeshRenderRange(Context *rsc, RsTriangleMesh vtm, uint32_t firs
|
||||
|
||||
glDrawElements(GL_TRIANGLES, count * 3, GL_UNSIGNED_SHORT, (GLvoid *)(first * 3 * 2));
|
||||
|
||||
//LOGE("4");
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
@@ -63,7 +63,6 @@ size_t Type::getOffsetForFace(uint32_t face) const
|
||||
|
||||
void Type::compute()
|
||||
{
|
||||
//LOGE("compute");
|
||||
uint32_t oldLODCount = mLODCount;
|
||||
if (mDimLOD) {
|
||||
uint32_t l2x = rsFindHighBit(mDimX) + 1;
|
||||
@@ -80,9 +79,6 @@ void Type::compute()
|
||||
mLODs = new LOD[mLODCount];
|
||||
}
|
||||
|
||||
//LOGE("xyz %i %i %i", mDimX, mDimY, mDimZ);
|
||||
//LOGE("mips %i", mLODCount);
|
||||
//LOGE("e size %i", mElement->getSizeBytes());
|
||||
uint32_t tx = mDimX;
|
||||
uint32_t ty = mDimY;
|
||||
uint32_t tz = mDimZ;
|
||||
@@ -92,15 +88,12 @@ void Type::compute()
|
||||
mLODs[lod].mY = ty;
|
||||
mLODs[lod].mZ = tz;
|
||||
mLODs[lod].mOffset = offset;
|
||||
//LOGE("txyz %i %i %i", tx, ty, tz);
|
||||
offset += tx * rsMax(ty, 1u) * rsMax(tz, 1u) * mElement->getSizeBytes();
|
||||
tx = (tx + 1) >> 1;
|
||||
ty = (ty + 1) >> 1;
|
||||
tz = (tz + 1) >> 1;
|
||||
}
|
||||
|
||||
//LOGE("size %i", offset);
|
||||
|
||||
// At this point the offset is the size of a mipmap chain;
|
||||
mMipChainSizeBytes = offset;
|
||||
|
||||
|
||||
@@ -17,14 +17,15 @@
|
||||
#ifndef ANDROID_RS_UTILS_H
|
||||
#define ANDROID_RS_UTILS_H
|
||||
|
||||
#include "RenderScript.h"
|
||||
|
||||
#define LOG_NDEBUG 0
|
||||
#define LOG_TAG "rs"
|
||||
#include <utils/Log.h>
|
||||
#include <utils/Vector.h>
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "RenderScript.h"
|
||||
|
||||
namespace android {
|
||||
namespace renderscript {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user