Merge change 22231 into eclair
* changes: Add support for selecting the color bit depth and if the application used a depth buffer.
This commit is contained in:
@@ -141,15 +141,12 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
public RenderScript createRenderScript() {
|
public RenderScript createRenderScript(boolean useDepth) {
|
||||||
Log.v(RenderScript.LOG_TAG, "createRenderScript 1");
|
|
||||||
Surface sur = null;
|
Surface sur = null;
|
||||||
while ((sur == null) || (mSurfaceHolder == null)) {
|
while ((sur == null) || (mSurfaceHolder == null)) {
|
||||||
sur = getHolder().getSurface();
|
sur = getHolder().getSurface();
|
||||||
}
|
}
|
||||||
Log.v(RenderScript.LOG_TAG, "createRenderScript 2");
|
RenderScript rs = new RenderScript(sur, useDepth);
|
||||||
RenderScript rs = new RenderScript(sur);
|
|
||||||
Log.v(RenderScript.LOG_TAG, "createRenderScript 3 rs");
|
|
||||||
return rs;
|
return rs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public class RenderScript {
|
|||||||
|
|
||||||
native int nDeviceCreate();
|
native int nDeviceCreate();
|
||||||
native void nDeviceDestroy(int dev);
|
native void nDeviceDestroy(int dev);
|
||||||
native int nContextCreate(int dev, Surface sur, int ver);
|
native int nContextCreate(int dev, Surface sur, int ver, boolean useDepth);
|
||||||
native void nContextDestroy(int con);
|
native void nContextDestroy(int con);
|
||||||
|
|
||||||
//void rsContextBindSampler (uint32_t slot, RsSampler sampler);
|
//void rsContextBindSampler (uint32_t slot, RsSampler sampler);
|
||||||
@@ -194,10 +194,10 @@ public class RenderScript {
|
|||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
|
||||||
public RenderScript(Surface sur) {
|
public RenderScript(Surface sur, boolean useDepth) {
|
||||||
mSurface = sur;
|
mSurface = sur;
|
||||||
mDev = nDeviceCreate();
|
mDev = nDeviceCreate();
|
||||||
mContext = nContextCreate(mDev, mSurface, 0);
|
mContext = nContextCreate(mDev, mSurface, 0, useDepth);
|
||||||
|
|
||||||
// TODO: This should be protected by a lock
|
// TODO: This should be protected by a lock
|
||||||
if(!mElementsInitialized) {
|
if(!mElementsInitialized) {
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ nDeviceDestroy(JNIEnv *_env, jobject _this, jint dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static jint
|
static jint
|
||||||
nContextCreate(JNIEnv *_env, jobject _this, jint dev, jobject wnd, jint ver)
|
nContextCreate(JNIEnv *_env, jobject _this, jint dev, jobject wnd, jint ver, jboolean useDepth)
|
||||||
{
|
{
|
||||||
LOG_API("nContextCreate");
|
LOG_API("nContextCreate");
|
||||||
|
|
||||||
@@ -142,7 +142,7 @@ nContextCreate(JNIEnv *_env, jobject _this, jint dev, jobject wnd, jint ver)
|
|||||||
if (window == NULL)
|
if (window == NULL)
|
||||||
goto not_valid_surface;
|
goto not_valid_surface;
|
||||||
|
|
||||||
return (jint)rsContextCreate((RsDevice)dev, window, ver);
|
return (jint)rsContextCreate((RsDevice)dev, window, ver, useDepth);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -1206,7 +1206,7 @@ static JNINativeMethod methods[] = {
|
|||||||
{"_nInit", "()V", (void*)_nInit },
|
{"_nInit", "()V", (void*)_nInit },
|
||||||
{"nDeviceCreate", "()I", (void*)nDeviceCreate },
|
{"nDeviceCreate", "()I", (void*)nDeviceCreate },
|
||||||
{"nDeviceDestroy", "(I)V", (void*)nDeviceDestroy },
|
{"nDeviceDestroy", "(I)V", (void*)nDeviceDestroy },
|
||||||
{"nContextCreate", "(ILandroid/view/Surface;I)I", (void*)nContextCreate },
|
{"nContextCreate", "(ILandroid/view/Surface;IZ)I", (void*)nContextCreate },
|
||||||
{"nContextDestroy", "(I)V", (void*)nContextDestroy },
|
{"nContextDestroy", "(I)V", (void*)nContextDestroy },
|
||||||
{"nAssignName", "(I[B)V", (void*)nAssignName },
|
{"nAssignName", "(I[B)V", (void*)nAssignName },
|
||||||
{"nObjDestroy", "(I)V", (void*)nObjDestroy },
|
{"nObjDestroy", "(I)V", (void*)nObjDestroy },
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ typedef void * RsProgramFragmentStore;
|
|||||||
RsDevice rsDeviceCreate();
|
RsDevice rsDeviceCreate();
|
||||||
void rsDeviceDestroy(RsDevice);
|
void rsDeviceDestroy(RsDevice);
|
||||||
|
|
||||||
RsContext rsContextCreate(RsDevice, void *, uint32_t version);
|
RsContext rsContextCreate(RsDevice, void *, uint32_t version, bool useDepth);
|
||||||
void rsContextDestroy(RsContext);
|
void rsContextDestroy(RsContext);
|
||||||
void rsObjDestroyOOB(RsContext, void *);
|
void rsObjDestroyOOB(RsContext, void *);
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class FallView extends RSSurfaceView {
|
|||||||
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
|
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
|
||||||
super.surfaceChanged(holder, format, w, h);
|
super.surfaceChanged(holder, format, w, h);
|
||||||
|
|
||||||
RenderScript RS = createRenderScript();
|
RenderScript RS = createRenderScript(false);
|
||||||
mRender = new FallRS(w, h);
|
mRender = new FallRS(w, h);
|
||||||
mRender.init(RS, getResources());
|
mRender.init(RS, getResources());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class FilmView extends RSSurfaceView {
|
|||||||
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
|
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
|
||||||
super.surfaceChanged(holder, format, w, h);
|
super.surfaceChanged(holder, format, w, h);
|
||||||
|
|
||||||
mRS = createRenderScript();
|
mRS = createRenderScript(true);
|
||||||
mRender = new FilmRS();
|
mRender = new FilmRS();
|
||||||
mRender.init(mRS, getResources(), w, h);
|
mRender.init(mRS, getResources(), w, h);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class FountainView extends RSSurfaceView {
|
|||||||
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
|
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
|
||||||
super.surfaceChanged(holder, format, w, h);
|
super.surfaceChanged(holder, format, w, h);
|
||||||
|
|
||||||
mRS = createRenderScript();
|
mRS = createRenderScript(false);
|
||||||
mRender = new FountainRS();
|
mRender = new FountainRS();
|
||||||
mRender.init(mRS, getResources(), w, h);
|
mRender.init(mRS, getResources(), w, h);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public class RolloView extends RSSurfaceView {
|
|||||||
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
|
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
|
||||||
super.surfaceChanged(holder, format, w, h);
|
super.surfaceChanged(holder, format, w, h);
|
||||||
|
|
||||||
mRS = createRenderScript();
|
mRS = createRenderScript(false);
|
||||||
mRender = new RolloRS();
|
mRender = new RolloRS();
|
||||||
mRender.init(mRS, getResources(), w, h);
|
mRender.init(mRS, getResources(), w, h);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include "rsContext.h"
|
#include "rsContext.h"
|
||||||
#include "rsThreadIO.h"
|
#include "rsThreadIO.h"
|
||||||
#include <ui/FramebufferNativeWindow.h>
|
#include <ui/FramebufferNativeWindow.h>
|
||||||
|
#include <ui/EGLUtils.h>
|
||||||
|
|
||||||
#include <GLES/gl.h>
|
#include <GLES/gl.h>
|
||||||
#include <GLES/glext.h>
|
#include <GLES/glext.h>
|
||||||
@@ -29,41 +30,64 @@ pthread_key_t Context::gThreadTLSKey = 0;
|
|||||||
|
|
||||||
void Context::initEGL()
|
void Context::initEGL()
|
||||||
{
|
{
|
||||||
mNumConfigs = -1;
|
mEGL.mNumConfigs = -1;
|
||||||
|
EGLint configAttribs[128];
|
||||||
|
EGLint *configAttribsPtr = configAttribs;
|
||||||
|
|
||||||
EGLint s_configAttribs[] = {
|
memset(configAttribs, 0, sizeof(configAttribs));
|
||||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
|
||||||
#if 1
|
|
||||||
EGL_RED_SIZE, 8,
|
|
||||||
EGL_GREEN_SIZE, 8,
|
|
||||||
EGL_BLUE_SIZE, 8,
|
|
||||||
EGL_ALPHA_SIZE, 8,
|
|
||||||
#else
|
|
||||||
EGL_RED_SIZE, 5,
|
|
||||||
EGL_GREEN_SIZE, 6,
|
|
||||||
EGL_BLUE_SIZE, 5,
|
|
||||||
#endif
|
|
||||||
EGL_DEPTH_SIZE, 16,
|
|
||||||
EGL_NONE
|
|
||||||
};
|
|
||||||
|
|
||||||
mDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
configAttribsPtr[0] = EGL_SURFACE_TYPE;
|
||||||
eglInitialize(mDisplay, &mMajorVersion, &mMinorVersion);
|
configAttribsPtr[1] = EGL_WINDOW_BIT;
|
||||||
eglChooseConfig(mDisplay, s_configAttribs, &mConfig, 1, &mNumConfigs);
|
configAttribsPtr += 2;
|
||||||
|
|
||||||
|
if (mUseDepth) {
|
||||||
|
configAttribsPtr[0] = EGL_DEPTH_SIZE;
|
||||||
|
configAttribsPtr[1] = 16;
|
||||||
|
configAttribsPtr += 2;
|
||||||
|
}
|
||||||
|
configAttribsPtr[0] = EGL_NONE;
|
||||||
|
rsAssert(configAttribsPtr < (configAttribs + (sizeof(configAttribs) / sizeof(EGLint))));
|
||||||
|
|
||||||
|
mEGL.mDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||||
|
eglInitialize(mEGL.mDisplay, &mEGL.mMajorVersion, &mEGL.mMinorVersion);
|
||||||
|
|
||||||
|
status_t err = EGLUtils::selectConfigForNativeWindow(mEGL.mDisplay, configAttribs, mWndSurface, &mEGL.mConfig);
|
||||||
|
if (err) {
|
||||||
|
LOGE("couldn't find an EGLConfig matching the screen format\n");
|
||||||
|
}
|
||||||
|
//eglChooseConfig(mEGL.mDisplay, configAttribs, &mEGL.mConfig, 1, &mEGL.mNumConfigs);
|
||||||
|
|
||||||
|
if (mWndSurface) {
|
||||||
|
mEGL.mSurface = eglCreateWindowSurface(mEGL.mDisplay, mEGL.mConfig, mWndSurface, NULL);
|
||||||
|
} else {
|
||||||
|
mEGL.mSurface = eglCreateWindowSurface(mEGL.mDisplay, mEGL.mConfig,
|
||||||
|
android_createDisplaySurface(),
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
mEGL.mContext = eglCreateContext(mEGL.mDisplay, mEGL.mConfig, NULL, NULL);
|
||||||
|
eglMakeCurrent(mEGL.mDisplay, mEGL.mSurface, mEGL.mSurface, mEGL.mContext);
|
||||||
|
eglQuerySurface(mEGL.mDisplay, mEGL.mSurface, EGL_WIDTH, &mEGL.mWidth);
|
||||||
|
eglQuerySurface(mEGL.mDisplay, mEGL.mSurface, EGL_HEIGHT, &mEGL.mHeight);
|
||||||
|
|
||||||
|
|
||||||
|
mGL.mVersion = glGetString(GL_VERSION);
|
||||||
|
mGL.mVendor = glGetString(GL_VENDOR);
|
||||||
|
mGL.mRenderer = glGetString(GL_RENDERER);
|
||||||
|
mGL.mExtensions = glGetString(GL_EXTENSIONS);
|
||||||
|
|
||||||
|
LOGV("EGL Version %i %i", mEGL.mMajorVersion, mEGL.mMinorVersion);
|
||||||
|
LOGV("GL Version %s", mGL.mVersion);
|
||||||
|
LOGV("GL Vendor %s", mGL.mVendor);
|
||||||
|
LOGV("GL Renderer %s", mGL.mRenderer);
|
||||||
|
LOGV("GL Extensions %s", mGL.mExtensions);
|
||||||
|
|
||||||
|
if (memcmp(mGL.mVersion, "OpenGL ES-CM", 12)) {
|
||||||
|
LOGE("Error, OpenGL ES Lite not supported");
|
||||||
|
}
|
||||||
|
sscanf((const char *)mGL.mVersion + 13, "%i.%i", &mGL.mMajorVersion, &mGL.mMinorVersion);
|
||||||
|
|
||||||
if (mWndSurface) {
|
|
||||||
mSurface = eglCreateWindowSurface(mDisplay, mConfig, mWndSurface,
|
|
||||||
NULL);
|
|
||||||
} else {
|
|
||||||
mSurface = eglCreateWindowSurface(mDisplay, mConfig,
|
|
||||||
android_createDisplaySurface(),
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
mContext = eglCreateContext(mDisplay, mConfig, NULL, NULL);
|
|
||||||
eglMakeCurrent(mDisplay, mSurface, mSurface, mContext);
|
|
||||||
eglQuerySurface(mDisplay, mSurface, EGL_WIDTH, &mWidth);
|
|
||||||
eglQuerySurface(mDisplay, mSurface, EGL_HEIGHT, &mHeight);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Context::runScript(Script *s, uint32_t launchID)
|
bool Context::runScript(Script *s, uint32_t launchID)
|
||||||
@@ -90,19 +114,22 @@ bool Context::runRootScript()
|
|||||||
|
|
||||||
//glColor4f(1,1,1,1);
|
//glColor4f(1,1,1,1);
|
||||||
//glEnable(GL_LIGHT0);
|
//glEnable(GL_LIGHT0);
|
||||||
glViewport(0, 0, mWidth, mHeight);
|
glViewport(0, 0, mEGL.mWidth, mEGL.mHeight);
|
||||||
|
#if 1
|
||||||
glDepthMask(GL_TRUE);
|
|
||||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||||
|
|
||||||
glClearColor(mRootScript->mEnviroment.mClearColor[0],
|
glClearColor(mRootScript->mEnviroment.mClearColor[0],
|
||||||
mRootScript->mEnviroment.mClearColor[1],
|
mRootScript->mEnviroment.mClearColor[1],
|
||||||
mRootScript->mEnviroment.mClearColor[2],
|
mRootScript->mEnviroment.mClearColor[2],
|
||||||
mRootScript->mEnviroment.mClearColor[3]);
|
mRootScript->mEnviroment.mClearColor[3]);
|
||||||
glClearDepthf(mRootScript->mEnviroment.mClearDepth);
|
if (mUseDepth) {
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glDepthMask(GL_TRUE);
|
||||||
glClear(GL_DEPTH_BUFFER_BIT);
|
glClearDepthf(mRootScript->mEnviroment.mClearDepth);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
} else {
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#if RS_LOG_TIMES
|
#if RS_LOG_TIMES
|
||||||
timerSet(RS_TIMER_SCRIPT);
|
timerSet(RS_TIMER_SCRIPT);
|
||||||
#endif
|
#endif
|
||||||
@@ -156,13 +183,13 @@ void Context::timerPrint()
|
|||||||
void Context::setupCheck()
|
void Context::setupCheck()
|
||||||
{
|
{
|
||||||
if (mFragmentStore.get()) {
|
if (mFragmentStore.get()) {
|
||||||
mFragmentStore->setupGL(&mStateFragmentStore);
|
mFragmentStore->setupGL(this, &mStateFragmentStore);
|
||||||
}
|
}
|
||||||
if (mFragment.get()) {
|
if (mFragment.get()) {
|
||||||
mFragment->setupGL(&mStateFragment);
|
mFragment->setupGL(this, &mStateFragment);
|
||||||
}
|
}
|
||||||
if (mVertex.get()) {
|
if (mVertex.get()) {
|
||||||
mVertex->setupGL(&mStateVertex);
|
mVertex->setupGL(this, &mStateVertex);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -186,11 +213,11 @@ void * Context::threadProc(void *vrsc)
|
|||||||
LOGE("pthread_setspecific %i", status);
|
LOGE("pthread_setspecific %i", status);
|
||||||
}
|
}
|
||||||
|
|
||||||
rsc->mStateVertex.init(rsc, rsc->mWidth, rsc->mHeight);
|
rsc->mStateVertex.init(rsc, rsc->mEGL.mWidth, rsc->mEGL.mHeight);
|
||||||
rsc->setVertex(NULL);
|
rsc->setVertex(NULL);
|
||||||
rsc->mStateFragment.init(rsc, rsc->mWidth, rsc->mHeight);
|
rsc->mStateFragment.init(rsc, rsc->mEGL.mWidth, rsc->mEGL.mHeight);
|
||||||
rsc->setFragment(NULL);
|
rsc->setFragment(NULL);
|
||||||
rsc->mStateFragmentStore.init(rsc, rsc->mWidth, rsc->mHeight);
|
rsc->mStateFragmentStore.init(rsc, rsc->mEGL.mWidth, rsc->mEGL.mHeight);
|
||||||
rsc->setFragmentStore(NULL);
|
rsc->setFragmentStore(NULL);
|
||||||
|
|
||||||
rsc->mRunning = true;
|
rsc->mRunning = true;
|
||||||
@@ -204,7 +231,7 @@ void * Context::threadProc(void *vrsc)
|
|||||||
#if RS_LOG_TIMES
|
#if RS_LOG_TIMES
|
||||||
rsc->timerSet(RS_TIMER_CLEAR_SWAP);
|
rsc->timerSet(RS_TIMER_CLEAR_SWAP);
|
||||||
#endif
|
#endif
|
||||||
eglSwapBuffers(rsc->mDisplay, rsc->mSurface);
|
eglSwapBuffers(rsc->mEGL.mDisplay, rsc->mEGL.mSurface);
|
||||||
#if RS_LOG_TIMES
|
#if RS_LOG_TIMES
|
||||||
rsc->timerSet(RS_TIMER_INTERNAL);
|
rsc->timerSet(RS_TIMER_INTERNAL);
|
||||||
rsc->timerPrint();
|
rsc->timerPrint();
|
||||||
@@ -218,18 +245,19 @@ void * Context::threadProc(void *vrsc)
|
|||||||
|
|
||||||
glClearColor(0,0,0,0);
|
glClearColor(0,0,0,0);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
eglSwapBuffers(rsc->mDisplay, rsc->mSurface);
|
eglSwapBuffers(rsc->mEGL.mDisplay, rsc->mEGL.mSurface);
|
||||||
eglTerminate(rsc->mDisplay);
|
eglTerminate(rsc->mEGL.mDisplay);
|
||||||
rsc->objDestroyOOBRun();
|
rsc->objDestroyOOBRun();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Context::Context(Device *dev, Surface *sur)
|
Context::Context(Device *dev, Surface *sur, bool useDepth)
|
||||||
{
|
{
|
||||||
dev->addContext(this);
|
dev->addContext(this);
|
||||||
mDev = dev;
|
mDev = dev;
|
||||||
mRunning = false;
|
mRunning = false;
|
||||||
mExit = false;
|
mExit = false;
|
||||||
|
mUseDepth = useDepth;
|
||||||
|
|
||||||
int status;
|
int status;
|
||||||
pthread_attr_t threadAttr;
|
pthread_attr_t threadAttr;
|
||||||
@@ -284,17 +312,6 @@ Context::~Context()
|
|||||||
objDestroyOOBDestroy();
|
objDestroyOOBDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Context::swapBuffers()
|
|
||||||
{
|
|
||||||
eglSwapBuffers(mDisplay, mSurface);
|
|
||||||
}
|
|
||||||
|
|
||||||
void rsContextSwap(RsContext vrsc)
|
|
||||||
{
|
|
||||||
Context *rsc = static_cast<Context *>(vrsc);
|
|
||||||
rsc->swapBuffers();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Context::setRootScript(Script *s)
|
void Context::setRootScript(Script *s)
|
||||||
{
|
{
|
||||||
mRootScript.set(s);
|
mRootScript.set(s);
|
||||||
@@ -520,10 +537,10 @@ void rsi_ContextSetDefineI32(Context *rsc, const char* name, int32_t value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RsContext rsContextCreate(RsDevice vdev, void *sur, uint32_t version)
|
RsContext rsContextCreate(RsDevice vdev, void *sur, uint32_t version, bool useDepth)
|
||||||
{
|
{
|
||||||
Device * dev = static_cast<Device *>(vdev);
|
Device * dev = static_cast<Device *>(vdev);
|
||||||
Context *rsc = new Context(dev, (Surface *)sur);
|
Context *rsc = new Context(dev, (Surface *)sur, useDepth);
|
||||||
return rsc;
|
return rsc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace renderscript {
|
|||||||
class Context
|
class Context
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Context(Device *, Surface *);
|
Context(Device *, Surface *, bool useDepth);
|
||||||
~Context();
|
~Context();
|
||||||
|
|
||||||
static pthread_key_t gThreadTLSKey;
|
static pthread_key_t gThreadTLSKey;
|
||||||
@@ -111,8 +111,8 @@ public:
|
|||||||
mFloatDefines.add(String8(name), value);
|
mFloatDefines.add(String8(name), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t getWidth() const {return mWidth;}
|
uint32_t getWidth() const {return mEGL.mWidth;}
|
||||||
uint32_t getHeight() const {return mHeight;}
|
uint32_t getHeight() const {return mEGL.mHeight;}
|
||||||
|
|
||||||
|
|
||||||
ThreadIO mIO;
|
ThreadIO mIO;
|
||||||
@@ -132,21 +132,38 @@ public:
|
|||||||
void timerSet(Timers);
|
void timerSet(Timers);
|
||||||
void timerPrint();
|
void timerPrint();
|
||||||
|
|
||||||
|
bool checkVersion1_1() const {return (mGL.mMajorVersion > 1) || (mGL.mMinorVersion >= 1); }
|
||||||
|
bool checkVersion2_0() const {return mGL.mMajorVersion >= 2; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Device *mDev;
|
Device *mDev;
|
||||||
|
|
||||||
EGLint mNumConfigs;
|
struct {
|
||||||
EGLint mMajorVersion;
|
EGLint mNumConfigs;
|
||||||
EGLint mMinorVersion;
|
EGLint mMajorVersion;
|
||||||
EGLConfig mConfig;
|
EGLint mMinorVersion;
|
||||||
EGLContext mContext;
|
EGLConfig mConfig;
|
||||||
EGLSurface mSurface;
|
EGLContext mContext;
|
||||||
EGLint mWidth;
|
EGLSurface mSurface;
|
||||||
EGLint mHeight;
|
EGLint mWidth;
|
||||||
EGLDisplay mDisplay;
|
EGLint mHeight;
|
||||||
|
EGLDisplay mDisplay;
|
||||||
|
} mEGL;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
const uint8_t * mVendor;
|
||||||
|
const uint8_t * mRenderer;
|
||||||
|
const uint8_t * mVersion;
|
||||||
|
const uint8_t * mExtensions;
|
||||||
|
|
||||||
|
uint32_t mMajorVersion;
|
||||||
|
uint32_t mMinorVersion;
|
||||||
|
|
||||||
|
} mGL;
|
||||||
|
|
||||||
bool mRunning;
|
bool mRunning;
|
||||||
bool mExit;
|
bool mExit;
|
||||||
|
bool mUseDepth;
|
||||||
|
|
||||||
pthread_t mThreadId;
|
pthread_t mThreadId;
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,11 @@ void ObjectBase::decRef() const
|
|||||||
mRefCount --;
|
mRefCount --;
|
||||||
//LOGV("ObjectBase %p dec ref %i", this, mRefCount);
|
//LOGV("ObjectBase %p dec ref %i", this, mRefCount);
|
||||||
if (!mRefCount) {
|
if (!mRefCount) {
|
||||||
|
if (mName) {
|
||||||
|
LOGV("Deleting RS object %p, name %s", this, mName);
|
||||||
|
} else {
|
||||||
|
LOGV("Deleting RS object %p, no name", this);
|
||||||
|
}
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,9 +47,3 @@ void Program::checkUpdatedAllocation(const Allocation *alloc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Program::setupGL()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -32,11 +32,7 @@ public:
|
|||||||
Program(Element *in, Element *out);
|
Program(Element *in, Element *out);
|
||||||
virtual ~Program();
|
virtual ~Program();
|
||||||
|
|
||||||
|
|
||||||
void bindAllocation(Allocation *);
|
void bindAllocation(Allocation *);
|
||||||
|
|
||||||
virtual void setupGL();
|
|
||||||
|
|
||||||
void checkUpdatedAllocation(const Allocation *);
|
void checkUpdatedAllocation(const Allocation *);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ ProgramFragment::~ProgramFragment()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProgramFragment::setupGL(ProgramFragmentState *state)
|
void ProgramFragment::setupGL(const Context *rsc, ProgramFragmentState *state)
|
||||||
{
|
{
|
||||||
if ((state->mLast.get() == this) && !mDirty) {
|
if ((state->mLast.get() == this) && !mDirty) {
|
||||||
return;
|
return;
|
||||||
@@ -55,7 +55,9 @@ void ProgramFragment::setupGL(ProgramFragmentState *state)
|
|||||||
}
|
}
|
||||||
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
//glTexEnvi(GL_POINT_SPRITE_OES, GL_COORD_REPLACE_OES, mPointSpriteEnable);
|
if (rsc->checkVersion1_1()) {
|
||||||
|
glTexEnvi(GL_POINT_SPRITE_OES, GL_COORD_REPLACE_OES, mPointSpriteEnable);
|
||||||
|
}
|
||||||
glBindTexture(GL_TEXTURE_2D, mTextures[ct]->getTextureID());
|
glBindTexture(GL_TEXTURE_2D, mTextures[ct]->getTextureID());
|
||||||
|
|
||||||
switch(mEnvModes[ct]) {
|
switch(mEnvModes[ct]) {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public:
|
|||||||
ProgramFragment(Element *in, Element *out, bool pointSpriteEnable);
|
ProgramFragment(Element *in, Element *out, bool pointSpriteEnable);
|
||||||
virtual ~ProgramFragment();
|
virtual ~ProgramFragment();
|
||||||
|
|
||||||
virtual void setupGL(ProgramFragmentState *);
|
virtual void setupGL(const Context *, ProgramFragmentState *);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ ProgramFragmentStore::~ProgramFragmentStore()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProgramFragmentStore::setupGL(ProgramFragmentStoreState *state)
|
void ProgramFragmentStore::setupGL(const Context *rsc, ProgramFragmentStoreState *state)
|
||||||
{
|
{
|
||||||
if (state->mLast.get() == this) {
|
if (state->mLast.get() == this) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public:
|
|||||||
ProgramFragmentStore(Element *in, Element *out);
|
ProgramFragmentStore(Element *in, Element *out);
|
||||||
virtual ~ProgramFragmentStore();
|
virtual ~ProgramFragmentStore();
|
||||||
|
|
||||||
virtual void setupGL(ProgramFragmentStoreState *);
|
virtual void setupGL(const Context *, ProgramFragmentStoreState *);
|
||||||
|
|
||||||
void setDepthFunc(RsDepthFunc);
|
void setDepthFunc(RsDepthFunc);
|
||||||
void setDepthMask(bool);
|
void setDepthMask(bool);
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ static void logMatrix(const char *txt, const float *f)
|
|||||||
LOGV("%6.2f, %6.2f, %6.2f, %6.2f", f[3], f[7], f[11], f[15]);
|
LOGV("%6.2f, %6.2f, %6.2f, %6.2f", f[3], f[7], f[11], f[15]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProgramVertex::setupGL(ProgramVertexState *state)
|
void ProgramVertex::setupGL(const Context *rsc, ProgramVertexState *state)
|
||||||
{
|
{
|
||||||
if ((state->mLast.get() == this) && !mDirty) {
|
if ((state->mLast.get() == this) && !mDirty) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public:
|
|||||||
ProgramVertex(Element *in, Element *out);
|
ProgramVertex(Element *in, Element *out);
|
||||||
virtual ~ProgramVertex();
|
virtual ~ProgramVertex();
|
||||||
|
|
||||||
virtual void setupGL(ProgramVertexState *state);
|
virtual void setupGL(const Context *rsc, ProgramVertexState *state);
|
||||||
|
|
||||||
|
|
||||||
void setTextureMatrixEnable(bool e) {mTextureMatrixEnable = e;}
|
void setTextureMatrixEnable(bool e) {mTextureMatrixEnable = e;}
|
||||||
|
|||||||
Reference in New Issue
Block a user