summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rsAllocation.cpp5
-rw-r--r--rsAllocation.h1
-rw-r--r--rsContext.cpp25
-rw-r--r--rsContext.h3
-rw-r--r--rsProgramFragment.cpp11
-rw-r--r--rsProgramFragment.h1
-rw-r--r--rsProgramRaster.cpp46
-rw-r--r--rsProgramRaster.h1
-rw-r--r--rsProgramStore.cpp35
-rw-r--r--rsProgramStore.h1
-rw-r--r--rsProgramVertex.cpp5
-rw-r--r--rsProgramVertex.h1
-rw-r--r--rsSampler.cpp10
-rw-r--r--rsSampler.h2
-rw-r--r--rsScriptC.cpp11
-rw-r--r--rsVertexArray.h1
16 files changed, 31 insertions, 128 deletions
diff --git a/rsAllocation.cpp b/rsAllocation.cpp
index 60998c31..87c4f2be 100644
--- a/rsAllocation.cpp
+++ b/rsAllocation.cpp
@@ -724,10 +724,7 @@ RsAllocation rsi_AllocationCreateFromBitmap(Context *rsc, uint32_t w, uint32_t h
const Element *src = static_cast<const Element *>(_src);
const Element *dst = static_cast<const Element *>(_dst);
- // Check for pow2 on pre es 2.0 versions.
- rsAssert(rsc->checkVersion2_0() || (!(w & (w-1)) && !(h & (h-1))));
-
- //LOGE("rsi_AllocationCreateFromBitmap %i %i %i %i %i", w, h, dstFmt, srcFmt, genMips);
+ //LOGE("%p rsi_AllocationCreateFromBitmap %i %i %i", rsc, w, h, genMips);
rsi_TypeBegin(rsc, _dst);
rsi_TypeAdd(rsc, RS_DIMENSION_X, w);
rsi_TypeAdd(rsc, RS_DIMENSION_Y, h);
diff --git a/rsAllocation.h b/rsAllocation.h
index b6b5d2f8..ce5372fe 100644
--- a/rsAllocation.h
+++ b/rsAllocation.h
@@ -90,6 +90,7 @@ public:
void decRefs(const void *ptr, size_t ct) const;
void sendDirty() const;
+ bool getHasGraphicsMipmaps() const {return mTextureGenMipmap;}
protected:
ObjectBaseRef<const Type> mType;
diff --git a/rsContext.cpp b/rsContext.cpp
index 5327aacb..3dbdbfb5 100644
--- a/rsContext.cpp
+++ b/rsContext.cpp
@@ -232,23 +232,15 @@ void Context::timerPrint()
bool Context::setupCheck()
{
- if (checkVersion2_0()) {
- if (!mShaderCache.lookup(this, mVertex.get(), mFragment.get())) {
- LOGE("Context::setupCheck() 1 fail");
- return false;
- }
-
- mFragmentStore->setupGL2(this, &mStateFragmentStore);
- mFragment->setupGL2(this, &mStateFragment, &mShaderCache);
- mRaster->setupGL2(this, &mStateRaster);
- mVertex->setupGL2(this, &mStateVertex, &mShaderCache);
-
- } else {
- mFragmentStore->setupGL(this, &mStateFragmentStore);
- mFragment->setupGL(this, &mStateFragment);
- mRaster->setupGL(this, &mStateRaster);
- mVertex->setupGL(this, &mStateVertex);
+ if (!mShaderCache.lookup(this, mVertex.get(), mFragment.get())) {
+ LOGE("Context::setupCheck() 1 fail");
+ return false;
}
+
+ mFragmentStore->setupGL2(this, &mStateFragmentStore);
+ mFragment->setupGL2(this, &mStateFragment, &mShaderCache);
+ mRaster->setupGL2(this, &mStateRaster);
+ mVertex->setupGL2(this, &mStateVertex, &mShaderCache);
return true;
}
@@ -940,6 +932,7 @@ RsContext rsContextCreateGL(RsDevice vdev, uint32_t version, bool useDepth)
LOGV("rsContextCreateGL %p, %i", vdev, useDepth);
Device * dev = static_cast<Device *>(vdev);
Context *rsc = new Context(dev, true, useDepth);
+ LOGV("rsContextCreateGL ret %p ", rsc);
return rsc;
}
diff --git a/rsContext.h b/rsContext.h
index 6d1a41d3..e38ba551 100644
--- a/rsContext.h
+++ b/rsContext.h
@@ -153,9 +153,6 @@ public:
void timerPrint();
void timerFrame();
- bool checkVersion1_1() const {return (mGL.mMajorVersion > 1) || (mGL.mMinorVersion >= 1); }
- bool checkVersion2_0() const {return mGL.mMajorVersion >= 2; }
-
struct {
bool mLogTimes;
bool mLogScripts;
diff --git a/rsProgramFragment.cpp b/rsProgramFragment.cpp
index 3174e82d..9817fcab 100644
--- a/rsProgramFragment.cpp
+++ b/rsProgramFragment.cpp
@@ -103,13 +103,8 @@ void ProgramFragment::setConstantColor(float r, float g, float b, float a)
mDirty = true;
}
-void ProgramFragment::setupGL(const Context *rsc, ProgramFragmentState *state)
-{
-}
-
void ProgramFragment::setupGL2(const Context *rsc, ProgramFragmentState *state, ShaderCache *sc)
{
-
//LOGE("sgl2 frag1 %x", glGetError());
if ((state->mLast.get() == this) && !mDirty) {
return;
@@ -131,12 +126,12 @@ void ProgramFragment::setupGL2(const Context *rsc, ProgramFragmentState *state,
glBindTexture(GL_TEXTURE_2D, mTextures[ct]->getTextureID());
rsc->checkError("ProgramFragment::setupGL2 tex bind");
if (mSamplers[ct].get()) {
- mSamplers[ct]->setupGL(rsc, mTextures[ct]->getType()->getIsNp2());
+ mSamplers[ct]->setupGL(rsc, mTextures[ct].get());
} else {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
rsc->checkError("ProgramFragment::setupGL2 tex env");
}
diff --git a/rsProgramFragment.h b/rsProgramFragment.h
index f08bb254..fb78b3f4 100644
--- a/rsProgramFragment.h
+++ b/rsProgramFragment.h
@@ -34,7 +34,6 @@ public:
uint32_t paramLength);
virtual ~ProgramFragment();
- virtual void setupGL(const Context *, ProgramFragmentState *);
virtual void setupGL2(const Context *, ProgramFragmentState *, ShaderCache *sc);
virtual void createShader();
diff --git a/rsProgramRaster.cpp b/rsProgramRaster.cpp
index 5b693701..62d060d3 100644
--- a/rsProgramRaster.cpp
+++ b/rsProgramRaster.cpp
@@ -61,52 +61,6 @@ void ProgramRaster::setCullMode(RsCullMode mode)
mDirty = true;
}
-void ProgramRaster::setupGL(const Context *rsc, ProgramRasterState *state)
-{
- if (state->mLast.get() == this && !mDirty) {
- return;
- }
- state->mLast.set(this);
- mDirty = false;
-
- if (mPointSmooth) {
- glEnable(GL_POINT_SMOOTH);
- } else {
- glDisable(GL_POINT_SMOOTH);
- }
-
- glLineWidth(mLineWidth);
- if (mLineSmooth) {
- glEnable(GL_LINE_SMOOTH);
- } else {
- glDisable(GL_LINE_SMOOTH);
- }
-
- if (rsc->checkVersion1_1()) {
-#ifndef ANDROID_RS_BUILD_FOR_HOST
- if (mPointSprite) {
- glEnable(GL_POINT_SPRITE_OES);
- } else {
- glDisable(GL_POINT_SPRITE_OES);
- }
-#endif //ANDROID_RS_BUILD_FOR_HOST
- }
-
- switch(mCull) {
- case RS_CULL_BACK:
- glEnable(GL_CULL_FACE);
- glCullFace(GL_BACK);
- break;
- case RS_CULL_FRONT:
- glEnable(GL_CULL_FACE);
- glCullFace(GL_FRONT);
- break;
- case RS_CULL_NONE:
- glDisable(GL_CULL_FACE);
- break;
- }
-}
-
void ProgramRaster::setupGL2(const Context *rsc, ProgramRasterState *state)
{
if (state->mLast.get() == this && !mDirty) {
diff --git a/rsProgramRaster.h b/rsProgramRaster.h
index 801ab2a9..d5ed6860 100644
--- a/rsProgramRaster.h
+++ b/rsProgramRaster.h
@@ -34,7 +34,6 @@ public:
bool pointSprite);
virtual ~ProgramRaster();
- virtual void setupGL(const Context *, ProgramRasterState *);
virtual void setupGL2(const Context *, ProgramRasterState *);
virtual void serialize(OStream *stream) const;
virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_RASTER; }
diff --git a/rsProgramStore.cpp b/rsProgramStore.cpp
index e741c0a5..3f90d7ac 100644
--- a/rsProgramStore.cpp
+++ b/rsProgramStore.cpp
@@ -56,41 +56,6 @@ ProgramStore::~ProgramStore()
{
}
-void ProgramStore::setupGL(const Context *rsc, ProgramStoreState *state)
-{
- if (state->mLast.get() == this) {
- return;
- }
- state->mLast.set(this);
-
- glColorMask(mColorRWriteEnable,
- mColorGWriteEnable,
- mColorBWriteEnable,
- mColorAWriteEnable);
- if (mBlendEnable) {
- glEnable(GL_BLEND);
- glBlendFunc(mBlendSrc, mBlendDst);
- } else {
- glDisable(GL_BLEND);
- }
-
- //LOGE("pfs %i, %i, %x", mDepthWriteEnable, mDepthTestEnable, mDepthFunc);
-
- glDepthMask(mDepthWriteEnable);
- if(mDepthTestEnable || mDepthWriteEnable) {
- glEnable(GL_DEPTH_TEST);
- glDepthFunc(mDepthFunc);
- } else {
- glDisable(GL_DEPTH_TEST);
- }
-
- if (mDitherEnable) {
- glEnable(GL_DITHER);
- } else {
- glDisable(GL_DITHER);
- }
-}
-
void ProgramStore::setupGL2(const Context *rsc, ProgramStoreState *state)
{
if (state->mLast.get() == this) {
diff --git a/rsProgramStore.h b/rsProgramStore.h
index fe8d78ec..95bcf3c0 100644
--- a/rsProgramStore.h
+++ b/rsProgramStore.h
@@ -32,7 +32,6 @@ public:
ProgramStore(Context *);
virtual ~ProgramStore();
- virtual void setupGL(const Context *, ProgramStoreState *);
virtual void setupGL2(const Context *, ProgramStoreState *);
void setDepthFunc(RsDepthFunc);
diff --git a/rsProgramVertex.cpp b/rsProgramVertex.cpp
index 28084d7f..6446b55d 100644
--- a/rsProgramVertex.cpp
+++ b/rsProgramVertex.cpp
@@ -68,11 +68,6 @@ static void logMatrix(const char *txt, const float *f)
LOGV("%6.4f, %6.4f, %6.4f, %6.4f", f[3], f[7], f[11], f[15]);
}
-void ProgramVertex::setupGL(const Context *rsc, ProgramVertexState *state)
-{
- assert(0);
-}
-
void ProgramVertex::loadShader(Context *rsc) {
Program::loadShader(rsc, GL_VERTEX_SHADER);
}
diff --git a/rsProgramVertex.h b/rsProgramVertex.h
index d6b3f5af..65ce541c 100644
--- a/rsProgramVertex.h
+++ b/rsProgramVertex.h
@@ -35,7 +35,6 @@ public:
ProgramVertex(Context *, bool texMat);
virtual ~ProgramVertex();
- virtual void setupGL(const Context *rsc, ProgramVertexState *state);
virtual void setupGL2(const Context *rsc, ProgramVertexState *state, ShaderCache *sc);
diff --git a/rsSampler.cpp b/rsSampler.cpp
index 47b8a613..c6a848c6 100644
--- a/rsSampler.cpp
+++ b/rsSampler.cpp
@@ -59,7 +59,7 @@ Sampler::~Sampler()
{
}
-void Sampler::setupGL(const Context *rsc, bool npot)
+void Sampler::setupGL(const Context *rsc, const Allocation *tex)
{
GLenum trans[] = {
GL_NEAREST, //RS_SAMPLER_NEAREST,
@@ -77,13 +77,17 @@ void Sampler::setupGL(const Context *rsc, bool npot)
GL_CLAMP_TO_EDGE, //RS_SAMPLER_CLAMP
};
- if (!rsc->ext_OES_texture_npot() && npot) {
+ if (!rsc->ext_OES_texture_npot() && tex->getType()->getIsNp2()) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, transNP[mMinFilter]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, transNP[mMagFilter]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, transNP[mWrapS]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, transNP[mWrapT]);
} else {
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, trans[mMinFilter]);
+ if (tex->getHasGraphicsMipmaps()) {
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, trans[mMinFilter]);
+ } else {
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, transNP[mMinFilter]);
+ }
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, trans[mMagFilter]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, trans[mWrapS]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, trans[mWrapT]);
diff --git a/rsSampler.h b/rsSampler.h
index 3786439c..32a8efd6 100644
--- a/rsSampler.h
+++ b/rsSampler.h
@@ -41,7 +41,7 @@ public:
virtual ~Sampler();
void bind(Allocation *);
- void setupGL(const Context *, bool npot);
+ void setupGL(const Context *, const Allocation *);
void bindToContext(SamplerState *, uint32_t slot);
void unbindFromContext(SamplerState *);
diff --git a/rsScriptC.cpp b/rsScriptC.cpp
index 662791db..cbc5df95 100644
--- a/rsScriptC.cpp
+++ b/rsScriptC.cpp
@@ -56,9 +56,16 @@ void ScriptC::setupScript(Context *rsc)
= nanoseconds_to_milliseconds(systemTime(SYSTEM_TIME_MONOTONIC));
for (uint32_t ct=0; ct < mEnviroment.mFieldCount; ct++) {
- if (!mSlots[ct].get())
+ if (mSlots[ct].get() && !mTypes[ct].get()) {
+ mTypes[ct].set(mSlots[ct]->getType());
+ }
+
+ if (!mTypes[ct].get())
continue;
- void *ptr = mSlots[ct]->getPtr();
+ void *ptr = NULL;
+ if (mSlots[ct].get()) {
+ ptr = mSlots[ct]->getPtr();
+ }
void **dest = ((void ***)mEnviroment.mFieldAddress)[ct];
//LOGE("setupScript %i %p = %p %p %i", ct, dest, ptr, mSlots[ct]->getType(), mSlots[ct]->getType()->getDimX());
diff --git a/rsVertexArray.h b/rsVertexArray.h
index 7c609b26..bd76d871 100644
--- a/rsVertexArray.h
+++ b/rsVertexArray.h
@@ -65,7 +65,6 @@ public:
//void addLegacy(uint32_t type, uint32_t size, uint32_t stride, bool normalized, uint32_t offset);
void add(uint32_t type, uint32_t size, uint32_t stride, bool normalized, uint32_t offset, const char *name);
- void setupGL(const Context *rsc, class VertexArrayState *) const;
void setupGL2(const Context *rsc, class VertexArrayState *, ShaderCache *) const;
void logAttrib(uint32_t idx, uint32_t slot) const;