summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--graphics/java/android/renderscript/RenderScript.java23
-rw-r--r--graphics/java/android/renderscript/Sampler.java15
-rw-r--r--graphics/jni/android_renderscript_RenderScript.cpp37
-rw-r--r--libs/rs/rs.spec29
-rw-r--r--libs/rs/rsProgram.cpp6
-rw-r--r--libs/rs/rsProgram.h2
-rw-r--r--libs/rs/rsProgramFragment.cpp1
-rw-r--r--libs/rs/rsProgramVertex.cpp4
-rw-r--r--libs/rs/rsSampler.cpp106
-rw-r--r--libs/rs/rsSampler.h29
10 files changed, 68 insertions, 184 deletions
diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java
index eea0986..feb74b8 100644
--- a/graphics/java/android/renderscript/RenderScript.java
+++ b/graphics/java/android/renderscript/RenderScript.java
@@ -473,25 +473,12 @@ public class RenderScript {
return rsnScriptCCreate(mContext, resName, cacheDir, script, length);
}
- native void rsnSamplerBegin(int con);
- synchronized void nSamplerBegin() {
+ native int rsnSamplerCreate(int con, int magFilter, int minFilter,
+ int wrapS, int wrapT, int wrapR, float aniso);
+ synchronized int nSamplerCreate(int magFilter, int minFilter,
+ int wrapS, int wrapT, int wrapR, float aniso) {
validate();
- rsnSamplerBegin(mContext);
- }
- native void rsnSamplerSet(int con, int param, int value);
- synchronized void nSamplerSet(int param, int value) {
- validate();
- rsnSamplerSet(mContext, param, value);
- }
- native void rsnSamplerSet2(int con, int param, float value);
- synchronized void nSamplerSet2(int param, float value) {
- validate();
- rsnSamplerSet2(mContext, param, value);
- }
- native int rsnSamplerCreate(int con);
- synchronized int nSamplerCreate() {
- validate();
- return rsnSamplerCreate(mContext);
+ return rsnSamplerCreate(mContext, magFilter, minFilter, wrapS, wrapT, wrapR, aniso);
}
native int rsnProgramStoreCreate(int con, boolean r, boolean g, boolean b, boolean a,
diff --git a/graphics/java/android/renderscript/Sampler.java b/graphics/java/android/renderscript/Sampler.java
index 8e1cac5..98943a1 100644
--- a/graphics/java/android/renderscript/Sampler.java
+++ b/graphics/java/android/renderscript/Sampler.java
@@ -239,21 +239,10 @@ public class Sampler extends BaseObj {
}
}
- static synchronized Sampler internalCreate(RenderScript rs, Builder b) {
- rs.nSamplerBegin();
- rs.nSamplerSet(0, b.mMin.mID);
- rs.nSamplerSet(1, b.mMag.mID);
- rs.nSamplerSet(2, b.mWrapS.mID);
- rs.nSamplerSet(3, b.mWrapT.mID);
- rs.nSamplerSet(4, b.mWrapR.mID);
- rs.nSamplerSet2(5, b.mAniso);
- int id = rs.nSamplerCreate();
- return new Sampler(id, rs);
- }
-
public Sampler create() {
mRS.validate();
- return internalCreate(mRS, this);
+ int id = mRS.nSamplerCreate(mMag.mID, mMin.mID, mWrapS.mID, mWrapT.mID, mWrapR.mID, mAniso);
+ return new Sampler(id, mRS);
}
}
diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp
index 256435f..445f4b5 100644
--- a/graphics/jni/android_renderscript_RenderScript.cpp
+++ b/graphics/jni/android_renderscript_RenderScript.cpp
@@ -1059,32 +1059,18 @@ nContextBindProgramRaster(JNIEnv *_env, jobject _this, RsContext con, jint pf)
// ---------------------------------------------------------------------------
-static void
-nSamplerBegin(JNIEnv *_env, jobject _this, RsContext con)
-{
- LOG_API("nSamplerBegin, con(%p)", con);
- rsSamplerBegin(con);
-}
-
-static void
-nSamplerSet(JNIEnv *_env, jobject _this, RsContext con, jint p, jint v)
-{
- LOG_API("nSamplerSet, con(%p), param(%i), value(%i)", con, p, v);
- rsSamplerSet(con, (RsSamplerParam)p, (RsSamplerValue)v);
-}
-
-static void
-nSamplerSet2(JNIEnv *_env, jobject _this, RsContext con, jint p, jfloat v)
-{
- LOG_API("nSamplerSet2, con(%p), param(%i), value(%f)", con, p, v);
- rsSamplerSet2(con, (RsSamplerParam)p, v);
-}
-
static jint
-nSamplerCreate(JNIEnv *_env, jobject _this, RsContext con)
+nSamplerCreate(JNIEnv *_env, jobject _this, RsContext con, jint magFilter, jint minFilter,
+ jint wrapS, jint wrapT, jint wrapR, jfloat aniso)
{
LOG_API("nSamplerCreate, con(%p)", con);
- return (jint)rsSamplerCreate(con);
+ return (jint)rsSamplerCreate(con,
+ (RsSamplerValue)magFilter,
+ (RsSamplerValue)minFilter,
+ (RsSamplerValue)wrapS,
+ (RsSamplerValue)wrapT,
+ (RsSamplerValue)wrapR,
+ aniso);
}
// ---------------------------------------------------------------------------
@@ -1280,10 +1266,7 @@ static JNINativeMethod methods[] = {
{"rsnContextBindProgramVertex", "(II)V", (void*)nContextBindProgramVertex },
{"rsnContextBindProgramRaster", "(II)V", (void*)nContextBindProgramRaster },
-{"rsnSamplerBegin", "(I)V", (void*)nSamplerBegin },
-{"rsnSamplerSet", "(III)V", (void*)nSamplerSet },
-{"rsnSamplerSet2", "(IIF)V", (void*)nSamplerSet2 },
-{"rsnSamplerCreate", "(I)I", (void*)nSamplerCreate },
+{"rsnSamplerCreate", "(IIIIIIF)I", (void*)nSamplerCreate },
{"rsnMeshCreate", "(III)I", (void*)nMeshCreate },
{"rsnMeshBindVertex", "(IIII)V", (void*)nMeshBindVertex },
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];
};