DO NOT MERGE. Merge Froyo renderscript to Eclair to support live wallpapers on droid. This gives the necessary CPU reduction to allow the wallpapers to work on the slower CPU.

Committer: Jason Sams <rjsams@android.com>

 On branch droid
 Changes to be committed:
   (use "git reset HEAD <file>..." to unstage)

	modified:   libs/rs/rsAllocation.cpp
	modified:   libs/rs/rsAllocation.h
	modified:   libs/rs/rsContext.cpp
	modified:   libs/rs/rsContext.h
	modified:   libs/rs/rsProgram.cpp
	modified:   libs/rs/rsProgram.h

Delete the old rollo sample which is obsolete.

Fix film init

Begin gl2 support.  Renderscript still uses GL1.1 by default.  However, 2.0 can be enabled and will render most tests correctly.

Fix film

Beging GL2 user shaders.  Switch master to using GL2 by default.

Implement RS tracked defered texture and buffer object uploads.

 Committer: Jason Sams <rjsams@android.com>

 On branch droid
 Changes to be committed:
   (use "git reset HEAD <file>..." to unstage)

	modified:   libs/rs/rsAllocation.cpp
	modified:   libs/rs/rsAllocation.h
	modified:   libs/rs/rsContext.h
	modified:   libs/rs/rsProgramFragment.cpp
	modified:   libs/rs/rsSimpleMesh.cpp

Remove check for surface valid that is no longer valid.

Continue development of es2.0 user shader support for renderscript.  This change cleans up ProgramVertex creation and adds support for passing input, output, and constant type info.

Continue es2 shader dev

Conflicts:

	graphics/java/android/renderscript/Program.java
	graphics/java/android/renderscript/ProgramVertex.java

Place shader logging behind prop to declutter logs.

Fix emulated glColor in es2 mode.

Fix live wallpaper many.  Z coordinate was being ignored for draw quad call.

Add argument checking to sampler builder to disallow illegal modes.

Move texture bindings to base program object.  Change ProgramFragment creation to require a texture format in 1.0 mode.

Element restructuring.  Add support for new basic Element types including the RS objects and vectors(2-4).  In theory this paves the way for maintaining type info for RS objects, passing elements for GLSL uiforms/attribs/varyings, and supporting nested structures.

This will break some apps, checkings for other projects will follow to unbreak them.

Disable excessive RS logging.

Add RS support for generic attribs as input to vertex programs.

More complete support for named attribs.  Adds user typed attribs as available to programVertex.  Non user attribs are not treated like user for GL2 for simplicity.

Support npot on es 2.0 HW.

Change user attribs to look for empty slot rather than using them in order.  Prevents conflict with numbered legacy slots.

Fix npot but where mipmap level sizes were rounding in the wrong direction.  Should always be floor.

Implement type generation for user uniforms in vertex shader.

Remove excessive logging, fix error in GLSL uniform generation.

Fix RS mipmap generation for 8 bit alpha textures.

Cleanup seperation of Legacy and user attribs.  All user programs now use the new names.  Legacy vertex attribs are given default names.

Fix some minor bugs with GL state setup that were exposed by Droids driver.

Implement drawSpriteCropped on es2.0
This commit is contained in:
Jason Sams
2010-02-11 18:16:21 -08:00
parent c1eba82ba4
commit 0b9bbb6dc5
79 changed files with 3245 additions and 2725 deletions

View File

@@ -25,72 +25,67 @@ import android.util.Log;
* @hide
*
**/
public class ProgramVertex extends BaseObj {
public class ProgramVertex extends Program {
public static final int MAX_LIGHT = 8;
ProgramVertex(int id, RenderScript rs) {
super(rs);
mID = id;
super(id, rs);
}
public void bindAllocation(MatrixAllocation va) {
mRS.validate();
mRS.nProgramVertexBindAllocation(mID, va.mAlloc.mID);
bindConstants(va.mAlloc, 0);
}
public static class Builder {
RenderScript mRS;
Element mIn;
Element mOut;
Light[] mLights;
int mLightCount;
boolean mTextureMatrixEnable;
public Builder(RenderScript rs, Element in, Element out) {
mRS = rs;
mIn = in;
mOut = out;
mLights = new Light[MAX_LIGHT];
mLightCount = 0;
}
public void setTextureMatrixEnable(boolean enable) {
mTextureMatrixEnable = enable;
}
public void addLight(Light l) throws IllegalStateException {
if(mLightCount >= MAX_LIGHT) {
throw new IllegalArgumentException("Max light count exceeded.");
}
mLights[mLightCount] = l;
mLightCount++;
public ProgramVertex create() {
int id = mRS.nProgramVertexCreate(mTextureMatrixEnable);
return new ProgramVertex(id, mRS);
}
}
static synchronized ProgramVertex internalCreate(RenderScript rs, Builder b) {
int inID = 0;
int outID = 0;
if (b.mIn != null) {
inID = b.mIn.mID;
}
if (b.mOut != null) {
outID = b.mOut.mID;
}
rs.nProgramVertexBegin(inID, outID);
for(int ct=0; ct < b.mLightCount; ct++) {
rs.nProgramVertexAddLight(b.mLights[ct].mID);
}
rs.nProgramVertexSetTextureMatrixEnable(b.mTextureMatrixEnable);
int id = rs.nProgramVertexCreate();
return new ProgramVertex(id, rs);
public static class ShaderBuilder extends BaseProgramBuilder {
public ShaderBuilder(RenderScript rs) {
super(rs);
}
public ProgramVertex create() {
mRS.validate();
return internalCreate(mRS, this);
int[] tmp = new int[(mInputCount + mOutputCount + mConstantCount +1) * 2];
int idx = 0;
for (int i=0; i < mInputCount; i++) {
tmp[idx++] = 0;
tmp[idx++] = mInputs[i].mID;
}
for (int i=0; i < mOutputCount; i++) {
tmp[idx++] = 1;
tmp[idx++] = mOutputs[i].mID;
}
for (int i=0; i < mConstantCount; i++) {
tmp[idx++] = 2;
tmp[idx++] = mConstants[i].mID;
}
tmp[idx++] = 3;
tmp[idx++] = mTextureCount;
int id = mRS.nProgramVertexCreate2(mShader, tmp);
ProgramVertex pv = new ProgramVertex(id, mRS);
initProgram(pv);
return pv;
}
}
@@ -112,7 +107,7 @@ public class ProgramVertex extends BaseObj {
mProjection = new Matrix();
mTexture = new Matrix();
mAlloc = Allocation.createSized(rs, Element.USER_F32(rs), 48);
mAlloc = Allocation.createSized(rs, Element.createUser(rs, Element.DataType.FLOAT_32), 48);
mAlloc.subData1D(MODELVIEW_OFFSET, 16, mModel.mMat);
mAlloc.subData1D(PROJECTION_OFFSET, 16, mProjection.mMat);
mAlloc.subData1D(TEXTURE_OFFSET, 16, mTexture.mMat);