diff options
Diffstat (limited to 'libs/rs')
-rw-r--r-- | libs/rs/rs.spec | 29 | ||||
-rw-r--r-- | libs/rs/rsProgram.cpp | 6 | ||||
-rw-r--r-- | libs/rs/rsProgram.h | 2 | ||||
-rw-r--r-- | libs/rs/rsProgramFragment.cpp | 1 | ||||
-rw-r--r-- | libs/rs/rsProgramVertex.cpp | 4 | ||||
-rw-r--r-- | libs/rs/rsSampler.cpp | 106 | ||||
-rw-r--r-- | libs/rs/rsSampler.h | 29 |
7 files changed, 51 insertions, 126 deletions
diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec index 0c4e1ed..5370e25 100644 --- a/libs/rs/rs.spec +++ b/libs/rs/rs.spec @@ -250,24 +250,15 @@ AllocationResize2D { param uint32_t dimY } -SamplerBegin { - } - -SamplerSet { - param RsSamplerParam p - param RsSamplerValue value - } - -SamplerSet2 { - param RsSamplerParam p - param float value - } - SamplerCreate { - ret RsSampler - } - - + param RsSamplerValue magFilter + param RsSamplerValue minFilter + param RsSamplerValue wrapS + param RsSamplerValue wrapT + param RsSamplerValue wrapR + param float mAniso + ret RsSampler +} ScriptBindAllocation { param RsScript vtm @@ -275,13 +266,11 @@ ScriptBindAllocation { param uint32_t slot } - ScriptSetTimeZone { param RsScript s param const char * timeZone } - ScriptInvoke { param RsScript s param uint32_t slot @@ -293,7 +282,7 @@ ScriptInvokeV { param const void * data } -ScriptForEach { +ScriptForEach { param RsScript s param uint32_t slot param RsAllocation ain diff --git a/libs/rs/rsProgram.cpp b/libs/rs/rsProgram.cpp index 28fa061..c0fa95b 100644 --- a/libs/rs/rsProgram.cpp +++ b/libs/rs/rsProgram.cpp @@ -49,7 +49,6 @@ Program::Program(Context *rsc, const char * shaderText, uint32_t shaderLength, mHal.state.constants = new ObjectBaseRef<Allocation>[mHal.state.constantsCount]; uint32_t input = 0; - uint32_t output = 0; uint32_t constant = 0; uint32_t texture = 0; for (uint32_t ct=0; ct < paramLength; ct+=2) { @@ -154,7 +153,6 @@ void Program::bindTexture(Context *rsc, uint32_t slot, Allocation *a) { return; } - //LOGE("bindtex %i %p", slot, a); mHal.state.textures[slot].set(a); mDirty = true; } @@ -170,10 +168,6 @@ void Program::bindSampler(Context *rsc, uint32_t slot, Sampler *s) { mDirty = true; } -void Program::setShader(const char *txt, uint32_t len) { - mUserShader.setTo(txt, len); -} - namespace android { namespace renderscript { diff --git a/libs/rs/rsProgram.h b/libs/rs/rsProgram.h index bcf5519..2922270 100644 --- a/libs/rs/rsProgram.h +++ b/libs/rs/rsProgram.h @@ -43,8 +43,6 @@ public: void bindTexture(Context *, uint32_t slot, Allocation *); void bindSampler(Context *, uint32_t slot, Sampler *); - void setShader(const char *, uint32_t len); - void forceDirty() const {mDirty = true;} struct Hal { diff --git a/libs/rs/rsProgramFragment.cpp b/libs/rs/rsProgramFragment.cpp index 39887ca..fcbfbc8 100644 --- a/libs/rs/rsProgramFragment.cpp +++ b/libs/rs/rsProgramFragment.cpp @@ -56,7 +56,6 @@ void ProgramFragment::setConstantColor(Context *rsc, float r, float g, float b, } void ProgramFragment::setupGL2(Context *rsc, ProgramFragmentState *state) { - //LOGE("sgl2 frag1 %x", glGetError()); if ((state->mLast.get() == this) && !mDirty) { return; } diff --git a/libs/rs/rsProgramVertex.cpp b/libs/rs/rsProgramVertex.cpp index dfd732f..b8b3c0b 100644 --- a/libs/rs/rsProgramVertex.cpp +++ b/libs/rs/rsProgramVertex.cpp @@ -37,8 +37,6 @@ void ProgramVertex::setupGL2(Context *rsc, ProgramVertexState *state) { return; } - rsc->checkError("ProgramVertex::setupGL2 start"); - if (!isUserProgram()) { if (mHal.state.constants[0].get() == NULL) { rsc->setError(RS_ERROR_FATAL_UNKNOWN, @@ -59,8 +57,6 @@ void ProgramVertex::setupGL2(Context *rsc, ProgramVertexState *state) { state->mLast.set(this); rsc->mHal.funcs.vertex.setActive(rsc, this); - - rsc->checkError("ProgramVertex::setupGL2"); } void ProgramVertex::setProjectionMatrix(Context *rsc, const rsc_Matrix *m) const { diff --git a/libs/rs/rsSampler.cpp b/libs/rs/rsSampler.cpp index db2383a..670d07e 100644 --- a/libs/rs/rsSampler.cpp +++ b/libs/rs/rsSampler.cpp @@ -39,12 +39,12 @@ Sampler::Sampler(Context *rsc, RsSamplerValue wrapT, RsSamplerValue wrapR, float aniso) : ObjectBase(rsc) { - mMagFilter = magFilter; - mMinFilter = minFilter; - mWrapS = wrapS; - mWrapT = wrapT; - mWrapR = wrapR; - mAniso = aniso; + mHal.state.magFilter = magFilter; + mHal.state.minFilter = minFilter; + mHal.state.wrapS = wrapS; + mHal.state.wrapT = wrapT; + mHal.state.wrapR = wrapR; + mHal.state.aniso = aniso; } Sampler::~Sampler() { @@ -76,35 +76,35 @@ void Sampler::setupGL(const Context *rsc, const Allocation *tex) { if (tex->getHasGraphicsMipmaps() && (rsc->ext_GL_NV_texture_npot_2D_mipmap() || rsc->ext_GL_IMG_texture_npot())) { if (rsc->ext_GL_NV_texture_npot_2D_mipmap()) { - glTexParameteri(target, GL_TEXTURE_MIN_FILTER, trans[mMinFilter]); + glTexParameteri(target, GL_TEXTURE_MIN_FILTER, trans[mHal.state.minFilter]); } else { - switch (trans[mMinFilter]) { + switch (trans[mHal.state.minFilter]) { case GL_LINEAR_MIPMAP_LINEAR: glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); break; default: - glTexParameteri(target, GL_TEXTURE_MIN_FILTER, trans[mMinFilter]); + glTexParameteri(target, GL_TEXTURE_MIN_FILTER, trans[mHal.state.minFilter]); break; } } } else { - glTexParameteri(target, GL_TEXTURE_MIN_FILTER, transNP[mMinFilter]); + glTexParameteri(target, GL_TEXTURE_MIN_FILTER, transNP[mHal.state.minFilter]); } - glTexParameteri(target, GL_TEXTURE_MAG_FILTER, transNP[mMagFilter]); - glTexParameteri(target, GL_TEXTURE_WRAP_S, transNP[mWrapS]); - glTexParameteri(target, GL_TEXTURE_WRAP_T, transNP[mWrapT]); + glTexParameteri(target, GL_TEXTURE_MAG_FILTER, transNP[mHal.state.magFilter]); + glTexParameteri(target, GL_TEXTURE_WRAP_S, transNP[mHal.state.wrapS]); + glTexParameteri(target, GL_TEXTURE_WRAP_T, transNP[mHal.state.wrapT]); } else { if (tex->getHasGraphicsMipmaps()) { - glTexParameteri(target, GL_TEXTURE_MIN_FILTER, trans[mMinFilter]); + glTexParameteri(target, GL_TEXTURE_MIN_FILTER, trans[mHal.state.minFilter]); } else { - glTexParameteri(target, GL_TEXTURE_MIN_FILTER, transNP[mMinFilter]); + glTexParameteri(target, GL_TEXTURE_MIN_FILTER, transNP[mHal.state.minFilter]); } - glTexParameteri(target, GL_TEXTURE_MAG_FILTER, trans[mMagFilter]); - glTexParameteri(target, GL_TEXTURE_WRAP_S, trans[mWrapS]); - glTexParameteri(target, GL_TEXTURE_WRAP_T, trans[mWrapT]); + glTexParameteri(target, GL_TEXTURE_MAG_FILTER, trans[mHal.state.magFilter]); + glTexParameteri(target, GL_TEXTURE_WRAP_S, trans[mHal.state.wrapS]); + glTexParameteri(target, GL_TEXTURE_WRAP_T, trans[mHal.state.wrapT]); } - float anisoValue = rsMin(rsc->ext_texture_max_aniso(), mAniso); + float anisoValue = rsMin(rsc->ext_texture_max_aniso(), mHal.state.aniso); if (rsc->ext_texture_max_aniso() > 1.0f) { glTexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, anisoValue); } @@ -135,66 +135,14 @@ Sampler *Sampler::createFromStream(Context *rsc, IStream *stream) { namespace android { namespace renderscript { - -void rsi_SamplerBegin(Context *rsc) { - SamplerState * ss = &rsc->mStateSampler; - - ss->mMagFilter = RS_SAMPLER_LINEAR; - ss->mMinFilter = RS_SAMPLER_LINEAR; - ss->mWrapS = RS_SAMPLER_WRAP; - ss->mWrapT = RS_SAMPLER_WRAP; - ss->mWrapR = RS_SAMPLER_WRAP; - ss->mAniso = 1.0f; -} - -void rsi_SamplerSet(Context *rsc, RsSamplerParam param, RsSamplerValue value) { - SamplerState * ss = &rsc->mStateSampler; - - switch (param) { - case RS_SAMPLER_MAG_FILTER: - ss->mMagFilter = value; - break; - case RS_SAMPLER_MIN_FILTER: - ss->mMinFilter = value; - break; - case RS_SAMPLER_WRAP_S: - ss->mWrapS = value; - break; - case RS_SAMPLER_WRAP_T: - ss->mWrapT = value; - break; - case RS_SAMPLER_WRAP_R: - ss->mWrapR = value; - break; - default: - LOGE("Attempting to set invalid value on sampler"); - break; - } -} - -void rsi_SamplerSet2(Context *rsc, RsSamplerParam param, float value) { - SamplerState * ss = &rsc->mStateSampler; - - switch (param) { - case RS_SAMPLER_ANISO: - ss->mAniso = value; - break; - default: - LOGE("Attempting to set invalid value on sampler"); - break; - } -} - -RsSampler rsi_SamplerCreate(Context *rsc) { - SamplerState * ss = &rsc->mStateSampler; - - Sampler * s = new Sampler(rsc, - ss->mMagFilter, - ss->mMinFilter, - ss->mWrapS, - ss->mWrapT, - ss->mWrapR, - ss->mAniso); +RsSampler rsi_SamplerCreate(Context * rsc, + RsSamplerValue magFilter, + RsSamplerValue minFilter, + RsSamplerValue wrapS, + RsSamplerValue wrapT, + RsSamplerValue wrapR, + float aniso) { + Sampler * s = new Sampler(rsc, magFilter, minFilter, wrapS, wrapT, wrapR, aniso); s->incUserRef(); return s; } diff --git a/libs/rs/rsSampler.h b/libs/rs/rsSampler.h index 737bb8b..192ee07 100644 --- a/libs/rs/rsSampler.h +++ b/libs/rs/rsSampler.h @@ -50,14 +50,22 @@ public: virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_SAMPLER; } static Sampler *createFromStream(Context *rsc, IStream *stream); -protected: - RsSamplerValue mMagFilter; - RsSamplerValue mMinFilter; - RsSamplerValue mWrapS; - RsSamplerValue mWrapT; - RsSamplerValue mWrapR; - float mAniso; + struct Hal { + mutable void *drv; + + struct State { + RsSamplerValue magFilter; + RsSamplerValue minFilter; + RsSamplerValue wrapS; + RsSamplerValue wrapT; + RsSamplerValue wrapR; + float aniso; + }; + State state; + }; + Hal mHal; +protected: int32_t mBoundSlot; private: @@ -67,13 +75,6 @@ private: class SamplerState { public: - RsSamplerValue mMagFilter; - RsSamplerValue mMinFilter; - RsSamplerValue mWrapS; - RsSamplerValue mWrapT; - RsSamplerValue mWrapR; - float mAniso; - ObjectBaseRef<Sampler> mSamplers[RS_MAX_SAMPLER_SLOT]; }; |