summaryrefslogtreecommitdiffstats
path: root/libs/rs/java
diff options
context:
space:
mode:
authorAlex Sakhartchouk <alexst@google.com>2010-12-21 14:42:26 -0800
committerAlex Sakhartchouk <alexst@google.com>2010-12-21 14:57:04 -0800
commitb4d7bb6872f523b4318144202e119766ed9054ed (patch)
tree2e7e18e9864c7c9398bbce8f0bc227f147b648f4 /libs/rs/java
parent1528d8f47cc6f0e0d5c9f905f82d15a35ce1bafb (diff)
downloadframeworks_base-b4d7bb6872f523b4318144202e119766ed9054ed.zip
frameworks_base-b4d7bb6872f523b4318144202e119766ed9054ed.tar.gz
frameworks_base-b4d7bb6872f523b4318144202e119766ed9054ed.tar.bz2
API cleanup for renderscript. This will be a multiproject commit.
Change-Id: Ida62d3a155285a20725be9daa62217faef1c3734
Diffstat (limited to 'libs/rs/java')
-rw-r--r--libs/rs/java/Balls/src/com/android/balls/BallsRS.java23
-rw-r--r--libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java4
-rw-r--r--libs/rs/java/ModelViewer/src/com/android/modelviewer/SceneGraphRS.java22
-rw-r--r--libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModelRS.java22
-rw-r--r--libs/rs/java/Samples/src/com/android/samples/RsBenchRS.java67
-rw-r--r--libs/rs/java/Samples/src/com/android/samples/RsRenderStatesRS.java69
6 files changed, 123 insertions, 84 deletions
diff --git a/libs/rs/java/Balls/src/com/android/balls/BallsRS.java b/libs/rs/java/Balls/src/com/android/balls/BallsRS.java
index 0a06394..50ee921 100644
--- a/libs/rs/java/Balls/src/com/android/balls/BallsRS.java
+++ b/libs/rs/java/Balls/src/com/android/balls/BallsRS.java
@@ -50,7 +50,7 @@ public class BallsRS {
private void createProgramVertex() {
updateProjectionMatrices();
- ProgramVertex.ShaderBuilder sb = new ProgramVertex.ShaderBuilder(mRS);
+ ProgramVertex.Builder sb = new ProgramVertex.Builder(mRS);
String t = "varying vec4 varColor;\n" +
"void main() {\n" +
" vec4 pos = vec4(0.0, 0.0, 0.0, 1.0);\n" +
@@ -75,18 +75,27 @@ public class BallsRS {
return allocation;
}
+ ProgramStore BLEND_ADD_DEPTH_NONE(RenderScript rs) {
+ ProgramStore.Builder builder = new ProgramStore.Builder(rs);
+ builder.setDepthFunc(ProgramStore.DepthFunc.ALWAYS);
+ builder.setBlendFunc(ProgramStore.BlendSrcFunc.ONE, ProgramStore.BlendDstFunc.ONE);
+ builder.setDitherEnabled(false);
+ builder.setDepthMaskEnabled(false);
+ return builder.create();
+ }
+
public void init(RenderScriptGL rs, Resources res, int width, int height) {
mRS = rs;
mRes = res;
- ProgramFragment.Builder pfb = new ProgramFragment.Builder(rs);
+ ProgramFragmentFixedFunction.Builder pfb = new ProgramFragmentFixedFunction.Builder(rs);
pfb.setPointSpriteTexCoordinateReplacement(true);
- pfb.setTexture(ProgramFragment.Builder.EnvMode.MODULATE,
- ProgramFragment.Builder.Format.RGBA, 0);
+ pfb.setTexture(ProgramFragmentFixedFunction.Builder.EnvMode.MODULATE,
+ ProgramFragmentFixedFunction.Builder.Format.RGBA, 0);
pfb.setVaryingColor(true);
mPFPoints = pfb.create();
- pfb = new ProgramFragment.Builder(rs);
+ pfb = new ProgramFragmentFixedFunction.Builder(rs);
pfb.setVaryingColor(true);
mPFLines = pfb.create();
@@ -97,7 +106,7 @@ public class BallsRS {
Mesh.AllocationBuilder smb = new Mesh.AllocationBuilder(mRS);
smb.addVertexAllocation(mPoints.getAllocation());
- smb.addIndexType(Primitive.POINT);
+ smb.addIndexSetType(Mesh.Primitive.POINT);
Mesh smP = smb.create();
mPhysicsScript = new ScriptC_ball_physics(mRS, mRes, R.raw.ball_physics);
@@ -113,7 +122,7 @@ public class BallsRS {
mScript.set_gPFPoints(mPFPoints);
createProgramVertex();
- mRS.bindProgramStore(ProgramStore.BLEND_ADD_DEPTH_NO_DEPTH(mRS));
+ mRS.bindProgramStore(BLEND_ADD_DEPTH_NONE(mRS));
mPhysicsScript.set_gMinPos(new Float2(5, 5));
mPhysicsScript.set_gMaxPos(new Float2(width - 5, height - 5));
diff --git a/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java b/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java
index a5d06e9..be2f9ca 100644
--- a/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java
+++ b/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java
@@ -34,7 +34,7 @@ public class FountainRS {
mRS = rs;
mRes = res;
- ProgramFragment.Builder pfb = new ProgramFragment.Builder(rs);
+ ProgramFragmentFixedFunction.Builder pfb = new ProgramFragmentFixedFunction.Builder(rs);
pfb.setVaryingColor(true);
rs.bindProgramFragment(pfb.create());
@@ -43,7 +43,7 @@ public class FountainRS {
Mesh.AllocationBuilder smb = new Mesh.AllocationBuilder(mRS);
smb.addVertexAllocation(points.getAllocation());
- smb.addIndexType(Primitive.POINT);
+ smb.addIndexSetType(Mesh.Primitive.POINT);
Mesh sm = smb.create();
mScript = new ScriptC_fountain(mRS, mRes, R.raw.fountain);
diff --git a/libs/rs/java/ModelViewer/src/com/android/modelviewer/SceneGraphRS.java b/libs/rs/java/ModelViewer/src/com/android/modelviewer/SceneGraphRS.java
index 7d99686..f91f31e 100644
--- a/libs/rs/java/ModelViewer/src/com/android/modelviewer/SceneGraphRS.java
+++ b/libs/rs/java/ModelViewer/src/com/android/modelviewer/SceneGraphRS.java
@@ -54,7 +54,7 @@ public class SceneGraphRS {
private ProgramStore mPSBackground;
private ProgramFragment mPFBackground;
private ProgramVertex mPVBackground;
- private ProgramVertex.MatrixAllocation mPVA;
+ private ProgramVertexFixedFunction.Constants mPVA;
private Allocation mGridImage;
private Allocation mAllocPV;
@@ -94,8 +94,8 @@ public class SceneGraphRS {
ProgramStore.Builder b = new ProgramStore.Builder(mRS);
b.setDepthFunc(ProgramStore.DepthFunc.LESS);
- b.setDitherEnable(false);
- b.setDepthMask(true);
+ b.setDitherEnabled(false);
+ b.setDepthMaskEnabled(true);
mPSBackground = b.create();
mScript.set_gPFSBackground(mPSBackground);
@@ -103,15 +103,15 @@ public class SceneGraphRS {
private void initPF() {
Sampler.Builder bs = new Sampler.Builder(mRS);
- bs.setMin(Sampler.Value.LINEAR);
- bs.setMag(Sampler.Value.LINEAR);
+ bs.setMinification(Sampler.Value.LINEAR);
+ bs.setMagnification(Sampler.Value.LINEAR);
bs.setWrapS(Sampler.Value.CLAMP);
bs.setWrapT(Sampler.Value.CLAMP);
mSampler = bs.create();
- ProgramFragment.Builder b = new ProgramFragment.Builder(mRS);
- b.setTexture(ProgramFragment.Builder.EnvMode.REPLACE,
- ProgramFragment.Builder.Format.RGBA, 0);
+ ProgramFragmentFixedFunction.Builder b = new ProgramFragmentFixedFunction.Builder(mRS);
+ b.setTexture(ProgramFragmentFixedFunction.Builder.EnvMode.REPLACE,
+ ProgramFragmentFixedFunction.Builder.Format.RGBA, 0);
mPFBackground = b.create();
mPFBackground.bindSampler(mSampler, 0);
@@ -119,11 +119,11 @@ public class SceneGraphRS {
}
private void initPV() {
- ProgramVertex.Builder pvb = new ProgramVertex.Builder(mRS);
+ ProgramVertexFixedFunction.Builder pvb = new ProgramVertexFixedFunction.Builder(mRS);
mPVBackground = pvb.create();
- mPVA = new ProgramVertex.MatrixAllocation(mRS);
- mPVBackground.bindAllocation(mPVA);
+ mPVA = new ProgramVertexFixedFunction.Constants(mRS);
+ ((ProgramVertexFixedFunction)mPVBackground).bindConstants(mPVA);
mScript.set_gPVBackground(mPVBackground);
}
diff --git a/libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModelRS.java b/libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModelRS.java
index 5451ca1..b18a327 100644
--- a/libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModelRS.java
+++ b/libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModelRS.java
@@ -50,7 +50,7 @@ public class SimpleModelRS {
private ProgramStore mPSBackground;
private ProgramFragment mPFBackground;
private ProgramVertex mPVBackground;
- private ProgramVertex.MatrixAllocation mPVA;
+ private ProgramVertexFixedFunction.Constants mPVA;
private Allocation mGridImage;
private Allocation mAllocPV;
@@ -89,8 +89,8 @@ public class SimpleModelRS {
ProgramStore.Builder b = new ProgramStore.Builder(mRS);
b.setDepthFunc(ProgramStore.DepthFunc.LESS);
- b.setDitherEnable(false);
- b.setDepthMask(true);
+ b.setDitherEnabled(false);
+ b.setDepthMaskEnabled(true);
mPSBackground = b.create();
mScript.set_gPFSBackground(mPSBackground);
@@ -98,15 +98,15 @@ public class SimpleModelRS {
private void initPF() {
Sampler.Builder bs = new Sampler.Builder(mRS);
- bs.setMin(Sampler.Value.LINEAR);
- bs.setMag(Sampler.Value.LINEAR);
+ bs.setMinification(Sampler.Value.LINEAR);
+ bs.setMagnification(Sampler.Value.LINEAR);
bs.setWrapS(Sampler.Value.CLAMP);
bs.setWrapT(Sampler.Value.CLAMP);
mSampler = bs.create();
- ProgramFragment.Builder b = new ProgramFragment.Builder(mRS);
- b.setTexture(ProgramFragment.Builder.EnvMode.REPLACE,
- ProgramFragment.Builder.Format.RGBA, 0);
+ ProgramFragmentFixedFunction.Builder b = new ProgramFragmentFixedFunction.Builder(mRS);
+ b.setTexture(ProgramFragmentFixedFunction.Builder.EnvMode.REPLACE,
+ ProgramFragmentFixedFunction.Builder.Format.RGBA, 0);
mPFBackground = b.create();
mPFBackground.bindSampler(mSampler, 0);
@@ -114,11 +114,11 @@ public class SimpleModelRS {
}
private void initPV() {
- ProgramVertex.Builder pvb = new ProgramVertex.Builder(mRS);
+ ProgramVertexFixedFunction.Builder pvb = new ProgramVertexFixedFunction.Builder(mRS);
mPVBackground = pvb.create();
- mPVA = new ProgramVertex.MatrixAllocation(mRS);
- mPVBackground.bindAllocation(mPVA);
+ mPVA = new ProgramVertexFixedFunction.Constants(mRS);
+ ((ProgramVertexFixedFunction)mPVBackground).bindConstants(mPVA);
mScript.set_gPVBackground(mPVBackground);
}
diff --git a/libs/rs/java/Samples/src/com/android/samples/RsBenchRS.java b/libs/rs/java/Samples/src/com/android/samples/RsBenchRS.java
index b3e8026..5430a13 100644
--- a/libs/rs/java/Samples/src/com/android/samples/RsBenchRS.java
+++ b/libs/rs/java/Samples/src/com/android/samples/RsBenchRS.java
@@ -26,6 +26,8 @@ import android.renderscript.Allocation.CubemapLayout;
import android.renderscript.Allocation.MipmapControl;
import android.renderscript.Program.TextureType;
import android.renderscript.ProgramStore.DepthFunc;
+import android.renderscript.ProgramStore.BlendSrcFunc;
+import android.renderscript.ProgramStore.BlendDstFunc;
import android.renderscript.Sampler.Value;
import android.util.Log;
@@ -69,7 +71,7 @@ public class RsBenchRS {
private ProgramFragment mProgFragmentColor;
private ProgramVertex mProgVertex;
- private ProgramVertex.MatrixAllocation mPVA;
+ private ProgramVertexFixedFunction.Constants mPVA;
// Custom shaders
private ProgramVertex mProgVertexCustom;
@@ -122,6 +124,15 @@ public class RsBenchRS {
mScript.set_gDisplayMode(mMode);
}
+ ProgramStore BLEND_ADD_DEPTH_NONE(RenderScript rs) {
+ ProgramStore.Builder builder = new ProgramStore.Builder(rs);
+ builder.setDepthFunc(ProgramStore.DepthFunc.ALWAYS);
+ builder.setBlendFunc(BlendSrcFunc.ONE, BlendDstFunc.ONE);
+ builder.setDitherEnabled(false);
+ builder.setDepthMaskEnabled(false);
+ return builder.create();
+ }
+
private Mesh getMbyNMesh(float width, float height, int wResolution, int hResolution) {
Mesh.TriangleMeshBuilder tmb = new Mesh.TriangleMeshBuilder(mRS,
@@ -155,18 +166,18 @@ public class RsBenchRS {
private void initProgramStore() {
// Use stock the stock program store object
mProgStoreBlendNoneDepth = ProgramStore.BLEND_NONE_DEPTH_TEST(mRS);
- mProgStoreBlendNone = ProgramStore.BLEND_NONE_DEPTH_NO_DEPTH(mRS);
+ mProgStoreBlendNone = ProgramStore.BLEND_NONE_DEPTH_NONE(mRS);
// Create a custom program store
ProgramStore.Builder builder = new ProgramStore.Builder(mRS);
builder.setDepthFunc(ProgramStore.DepthFunc.ALWAYS);
builder.setBlendFunc(ProgramStore.BlendSrcFunc.SRC_ALPHA,
ProgramStore.BlendDstFunc.ONE_MINUS_SRC_ALPHA);
- builder.setDitherEnable(false);
- builder.setDepthMask(false);
+ builder.setDitherEnabled(false);
+ builder.setDepthMaskEnabled(false);
mProgStoreBlendAlpha = builder.create();
- mProgStoreBlendAdd = ProgramStore.BLEND_ADD_DEPTH_NO_DEPTH(mRS);
+ mProgStoreBlendAdd = BLEND_ADD_DEPTH_NONE(mRS);
mScript.set_gProgStoreBlendNoneDepth(mProgStoreBlendNoneDepth);
mScript.set_gProgStoreBlendNone(mProgStoreBlendNone);
@@ -176,13 +187,13 @@ public class RsBenchRS {
private void initProgramFragment() {
- ProgramFragment.Builder texBuilder = new ProgramFragment.Builder(mRS);
- texBuilder.setTexture(ProgramFragment.Builder.EnvMode.REPLACE,
- ProgramFragment.Builder.Format.RGBA, 0);
+ ProgramFragmentFixedFunction.Builder texBuilder = new ProgramFragmentFixedFunction.Builder(mRS);
+ texBuilder.setTexture(ProgramFragmentFixedFunction.Builder.EnvMode.REPLACE,
+ ProgramFragmentFixedFunction.Builder.Format.RGBA, 0);
mProgFragmentTexture = texBuilder.create();
mProgFragmentTexture.bindSampler(mLinearClamp, 0);
- ProgramFragment.Builder colBuilder = new ProgramFragment.Builder(mRS);
+ ProgramFragmentFixedFunction.Builder colBuilder = new ProgramFragmentFixedFunction.Builder(mRS);
colBuilder.setVaryingColor(false);
mProgFragmentColor = colBuilder.create();
@@ -191,12 +202,14 @@ public class RsBenchRS {
}
private void initProgramVertex() {
- ProgramVertex.Builder pvb = new ProgramVertex.Builder(mRS);
+ ProgramVertexFixedFunction.Builder pvb = new ProgramVertexFixedFunction.Builder(mRS);
mProgVertex = pvb.create();
- mPVA = new ProgramVertex.MatrixAllocation(mRS);
- mProgVertex.bindAllocation(mPVA);
- mPVA.setupOrthoWindow(mWidth, mHeight);
+ mPVA = new ProgramVertexFixedFunction.Constants(mRS);
+ ((ProgramVertexFixedFunction)mProgVertex).bindConstants(mPVA);
+ Matrix4f proj = new Matrix4f();
+ proj.loadOrthoWindow(mWidth, mHeight);
+ mPVA.setProjection(proj);
mScript.set_gProgVertex(mProgVertex);
}
@@ -213,7 +226,7 @@ public class RsBenchRS {
mScript.bind_gFSConstPixel(mFSConstPixel);
// Initialize the shader builder
- ProgramVertex.ShaderBuilder pvbCustom = new ProgramVertex.ShaderBuilder(mRS);
+ ProgramVertex.Builder pvbCustom = new ProgramVertex.Builder(mRS);
// Specify the resource that contains the shader string
pvbCustom.setShader(mRes, R.raw.shaderv);
// Use a script field to specify the input layout
@@ -224,7 +237,7 @@ public class RsBenchRS {
// Bind the source of constant data
mProgVertexCustom.bindConstants(mVSConst.getAllocation(), 0);
- ProgramFragment.ShaderBuilder pfbCustom = new ProgramFragment.ShaderBuilder(mRS);
+ ProgramFragment.Builder pfbCustom = new ProgramFragment.Builder(mRS);
// Specify the resource that contains the shader string
pfbCustom.setShader(mRes, R.raw.shaderf);
// Tell the builder how many textures we have
@@ -236,42 +249,44 @@ public class RsBenchRS {
mProgFragmentCustom.bindConstants(mFSConst.getAllocation(), 0);
// Cubemap test shaders
- pvbCustom = new ProgramVertex.ShaderBuilder(mRS);
+ pvbCustom = new ProgramVertex.Builder(mRS);
pvbCustom.setShader(mRes, R.raw.shadercubev);
pvbCustom.addInput(ScriptField_VertexShaderInputs_s.createElement(mRS));
pvbCustom.addConstant(mVSConst.getAllocation().getType());
mProgVertexCube = pvbCustom.create();
mProgVertexCube.bindConstants(mVSConst.getAllocation(), 0);
- pfbCustom = new ProgramFragment.ShaderBuilder(mRS);
+ pfbCustom = new ProgramFragment.Builder(mRS);
pfbCustom.setShader(mRes, R.raw.shadercubef);
pfbCustom.addTexture(Program.TextureType.TEXTURE_CUBE);
mProgFragmentCube = pfbCustom.create();
- pvbCustom = new ProgramVertex.ShaderBuilder(mRS);
+ pvbCustom = new ProgramVertex.Builder(mRS);
pvbCustom.setShader(mRes, R.raw.shader2v);
pvbCustom.addInput(ScriptField_VertexShaderInputs_s.createElement(mRS));
pvbCustom.addConstant(mVSConstPixel.getAllocation().getType());
mProgVertexPixelLight = pvbCustom.create();
mProgVertexPixelLight.bindConstants(mVSConstPixel.getAllocation(), 0);
- pvbCustom = new ProgramVertex.ShaderBuilder(mRS);
+ pvbCustom = new ProgramVertex.Builder(mRS);
pvbCustom.setShader(mRes, R.raw.shader2movev);
pvbCustom.addInput(ScriptField_VertexShaderInputs_s.createElement(mRS));
pvbCustom.addConstant(mVSConstPixel.getAllocation().getType());
mProgVertexPixelLightMove = pvbCustom.create();
mProgVertexPixelLightMove.bindConstants(mVSConstPixel.getAllocation(), 0);
- pfbCustom = new ProgramFragment.ShaderBuilder(mRS);
+ pfbCustom = new ProgramFragment.Builder(mRS);
pfbCustom.setShader(mRes, R.raw.shader2f);
pfbCustom.addTexture(Program.TextureType.TEXTURE_2D);
pfbCustom.addConstant(mFSConstPixel.getAllocation().getType());
mProgFragmentPixelLight = pfbCustom.create();
mProgFragmentPixelLight.bindConstants(mFSConstPixel.getAllocation(), 0);
- pfbCustom = new ProgramFragment.ShaderBuilder(mRS);
+ pfbCustom = new ProgramFragment.Builder(mRS);
pfbCustom.setShader(mRes, R.raw.multitexf);
- pfbCustom.setTextureCount(3);
+ for (int texCount = 0; texCount < 3; texCount ++) {
+ pfbCustom.addTexture(Program.TextureType.TEXTURE_2D);
+ }
mProgFragmentMultitex = pfbCustom.create();
mScript.set_gProgVertexCustom(mProgVertexCustom);
@@ -354,8 +369,8 @@ public class RsBenchRS {
private void initSamplers() {
Sampler.Builder bs = new Sampler.Builder(mRS);
- bs.setMin(Sampler.Value.LINEAR);
- bs.setMag(Sampler.Value.LINEAR);
+ bs.setMinification(Sampler.Value.LINEAR);
+ bs.setMagnification(Sampler.Value.LINEAR);
bs.setWrapS(Sampler.Value.WRAP);
bs.setWrapT(Sampler.Value.WRAP);
mLinearWrap = bs.create();
@@ -365,8 +380,8 @@ public class RsBenchRS {
mMipLinearWrap = Sampler.WRAP_LINEAR_MIP_LINEAR(mRS);
bs = new Sampler.Builder(mRS);
- bs.setMin(Sampler.Value.LINEAR_MIP_LINEAR);
- bs.setMag(Sampler.Value.LINEAR);
+ bs.setMinification(Sampler.Value.LINEAR_MIP_LINEAR);
+ bs.setMagnification(Sampler.Value.LINEAR);
bs.setWrapS(Sampler.Value.WRAP);
bs.setWrapT(Sampler.Value.WRAP);
bs.setAnisotropy(8.0f);
diff --git a/libs/rs/java/Samples/src/com/android/samples/RsRenderStatesRS.java b/libs/rs/java/Samples/src/com/android/samples/RsRenderStatesRS.java
index 636a486..cac105a 100644
--- a/libs/rs/java/Samples/src/com/android/samples/RsRenderStatesRS.java
+++ b/libs/rs/java/Samples/src/com/android/samples/RsRenderStatesRS.java
@@ -26,6 +26,8 @@ import android.renderscript.Allocation.CubemapLayout;
import android.renderscript.Font.Style;
import android.renderscript.Program.TextureType;
import android.renderscript.ProgramStore.DepthFunc;
+import android.renderscript.ProgramStore.BlendSrcFunc;
+import android.renderscript.ProgramStore.BlendDstFunc;
import android.renderscript.Sampler.Value;
import android.util.Log;
@@ -69,7 +71,7 @@ public class RsRenderStatesRS {
private ProgramFragment mProgFragmentColor;
private ProgramVertex mProgVertex;
- private ProgramVertex.MatrixAllocation mPVA;
+ private ProgramVertexFixedFunction.Constants mPVA;
// Custom shaders
private ProgramVertex mProgVertexCustom;
@@ -120,6 +122,15 @@ public class RsRenderStatesRS {
mScript.set_gDisplayMode(mMode);
}
+ ProgramStore BLEND_ADD_DEPTH_NONE(RenderScript rs) {
+ ProgramStore.Builder builder = new ProgramStore.Builder(rs);
+ builder.setDepthFunc(ProgramStore.DepthFunc.ALWAYS);
+ builder.setBlendFunc(BlendSrcFunc.ONE, BlendDstFunc.ONE);
+ builder.setDitherEnabled(false);
+ builder.setDepthMaskEnabled(false);
+ return builder.create();
+ }
+
private Mesh getMbyNMesh(float width, float height, int wResolution, int hResolution) {
Mesh.TriangleMeshBuilder tmb = new Mesh.TriangleMeshBuilder(mRS,
@@ -153,18 +164,18 @@ public class RsRenderStatesRS {
private void initProgramStore() {
// Use stock the stock program store object
mProgStoreBlendNoneDepth = ProgramStore.BLEND_NONE_DEPTH_TEST(mRS);
- mProgStoreBlendNone = ProgramStore.BLEND_NONE_DEPTH_NO_DEPTH(mRS);
+ mProgStoreBlendNone = ProgramStore.BLEND_NONE_DEPTH_NONE(mRS);
// Create a custom program store
ProgramStore.Builder builder = new ProgramStore.Builder(mRS);
builder.setDepthFunc(ProgramStore.DepthFunc.ALWAYS);
builder.setBlendFunc(ProgramStore.BlendSrcFunc.SRC_ALPHA,
ProgramStore.BlendDstFunc.ONE_MINUS_SRC_ALPHA);
- builder.setDitherEnable(false);
- builder.setDepthMask(false);
+ builder.setDitherEnabled(false);
+ builder.setDepthMaskEnabled(false);
mProgStoreBlendAlpha = builder.create();
- mProgStoreBlendAdd = ProgramStore.BLEND_ADD_DEPTH_NO_DEPTH(mRS);
+ mProgStoreBlendAdd = BLEND_ADD_DEPTH_NONE(mRS);
mScript.set_gProgStoreBlendNoneDepth(mProgStoreBlendNoneDepth);
mScript.set_gProgStoreBlendNone(mProgStoreBlendNone);
@@ -174,13 +185,13 @@ public class RsRenderStatesRS {
private void initProgramFragment() {
- ProgramFragment.Builder texBuilder = new ProgramFragment.Builder(mRS);
- texBuilder.setTexture(ProgramFragment.Builder.EnvMode.REPLACE,
- ProgramFragment.Builder.Format.RGBA, 0);
+ ProgramFragmentFixedFunction.Builder texBuilder = new ProgramFragmentFixedFunction.Builder(mRS);
+ texBuilder.setTexture(ProgramFragmentFixedFunction.Builder.EnvMode.REPLACE,
+ ProgramFragmentFixedFunction.Builder.Format.RGBA, 0);
mProgFragmentTexture = texBuilder.create();
mProgFragmentTexture.bindSampler(mLinearClamp, 0);
- ProgramFragment.Builder colBuilder = new ProgramFragment.Builder(mRS);
+ ProgramFragmentFixedFunction.Builder colBuilder = new ProgramFragmentFixedFunction.Builder(mRS);
colBuilder.setVaryingColor(false);
mProgFragmentColor = colBuilder.create();
@@ -189,12 +200,14 @@ public class RsRenderStatesRS {
}
private void initProgramVertex() {
- ProgramVertex.Builder pvb = new ProgramVertex.Builder(mRS);
+ ProgramVertexFixedFunction.Builder pvb = new ProgramVertexFixedFunction.Builder(mRS);
mProgVertex = pvb.create();
- mPVA = new ProgramVertex.MatrixAllocation(mRS);
- mProgVertex.bindAllocation(mPVA);
- mPVA.setupOrthoWindow(mWidth, mHeight);
+ mPVA = new ProgramVertexFixedFunction.Constants(mRS);
+ ((ProgramVertexFixedFunction)mProgVertex).bindConstants(mPVA);
+ Matrix4f proj = new Matrix4f();
+ proj.loadOrthoWindow(mWidth, mHeight);
+ mPVA.setProjection(proj);
mScript.set_gProgVertex(mProgVertex);
}
@@ -211,7 +224,7 @@ public class RsRenderStatesRS {
mScript.bind_gFSConstants2(mFSConst2);
// Initialize the shader builder
- ProgramVertex.ShaderBuilder pvbCustom = new ProgramVertex.ShaderBuilder(mRS);
+ ProgramVertex.Builder pvbCustom = new ProgramVertex.Builder(mRS);
// Specify the resource that contains the shader string
pvbCustom.setShader(mRes, R.raw.shaderv);
// Use a script field to spcify the input layout
@@ -222,47 +235,49 @@ public class RsRenderStatesRS {
// Bind the source of constant data
mProgVertexCustom.bindConstants(mVSConst.getAllocation(), 0);
- ProgramFragment.ShaderBuilder pfbCustom = new ProgramFragment.ShaderBuilder(mRS);
+ ProgramFragment.Builder pfbCustom = new ProgramFragment.Builder(mRS);
// Specify the resource that contains the shader string
pfbCustom.setShader(mRes, R.raw.shaderf);
//Tell the builder how many textures we have
- pfbCustom.setTextureCount(1);
+ pfbCustom.addTexture(Program.TextureType.TEXTURE_2D);
// Define the constant input layout
pfbCustom.addConstant(mFSConst.getAllocation().getType());
mProgFragmentCustom = pfbCustom.create();
// Bind the source of constant data
mProgFragmentCustom.bindConstants(mFSConst.getAllocation(), 0);
- pvbCustom = new ProgramVertex.ShaderBuilder(mRS);
+ pvbCustom = new ProgramVertex.Builder(mRS);
pvbCustom.setShader(mRes, R.raw.shaderarrayv);
pvbCustom.addInput(ScriptField_VertexShaderInputs_s.createElement(mRS));
pvbCustom.addConstant(mVSConst2.getAllocation().getType());
mProgVertexCustom2 = pvbCustom.create();
mProgVertexCustom2.bindConstants(mVSConst2.getAllocation(), 0);
- pfbCustom = new ProgramFragment.ShaderBuilder(mRS);
+ pfbCustom = new ProgramFragment.Builder(mRS);
pfbCustom.setShader(mRes, R.raw.shaderarrayf);
- pfbCustom.setTextureCount(1);
+ pfbCustom.addTexture(Program.TextureType.TEXTURE_2D);
pfbCustom.addConstant(mFSConst2.getAllocation().getType());
mProgFragmentCustom2 = pfbCustom.create();
mProgFragmentCustom2.bindConstants(mFSConst2.getAllocation(), 0);
// Cubemap test shaders
- pvbCustom = new ProgramVertex.ShaderBuilder(mRS);
+ pvbCustom = new ProgramVertex.Builder(mRS);
pvbCustom.setShader(mRes, R.raw.shadercubev);
pvbCustom.addInput(ScriptField_VertexShaderInputs_s.createElement(mRS));
pvbCustom.addConstant(mVSConst.getAllocation().getType());
mProgVertexCube = pvbCustom.create();
mProgVertexCube.bindConstants(mVSConst.getAllocation(), 0);
- pfbCustom = new ProgramFragment.ShaderBuilder(mRS);
+ pfbCustom = new ProgramFragment.Builder(mRS);
pfbCustom.setShader(mRes, R.raw.shadercubef);
pfbCustom.addTexture(Program.TextureType.TEXTURE_CUBE);
mProgFragmentCube = pfbCustom.create();
- pfbCustom = new ProgramFragment.ShaderBuilder(mRS);
+ pfbCustom = new ProgramFragment.Builder(mRS);
pfbCustom.setShader(mRes, R.raw.multitexf);
- pfbCustom.setTextureCount(3);
+ for (int texCount = 0; texCount < 3; texCount ++) {
+ pfbCustom.addTexture(Program.TextureType.TEXTURE_2D);
+ }
mProgFragmentMultitex = pfbCustom.create();
mScript.set_gProgVertexCustom(mProgVertexCustom);
@@ -340,8 +355,8 @@ public class RsRenderStatesRS {
private void initSamplers() {
Sampler.Builder bs = new Sampler.Builder(mRS);
- bs.setMin(Sampler.Value.LINEAR);
- bs.setMag(Sampler.Value.LINEAR);
+ bs.setMinification(Sampler.Value.LINEAR);
+ bs.setMagnification(Sampler.Value.LINEAR);
bs.setWrapS(Sampler.Value.WRAP);
bs.setWrapT(Sampler.Value.WRAP);
mLinearWrap = bs.create();
@@ -351,8 +366,8 @@ public class RsRenderStatesRS {
mMipLinearWrap = Sampler.WRAP_LINEAR_MIP_LINEAR(mRS);
bs = new Sampler.Builder(mRS);
- bs.setMin(Sampler.Value.LINEAR_MIP_LINEAR);
- bs.setMag(Sampler.Value.LINEAR);
+ bs.setMinification(Sampler.Value.LINEAR_MIP_LINEAR);
+ bs.setMagnification(Sampler.Value.LINEAR);
bs.setWrapS(Sampler.Value.WRAP);
bs.setWrapT(Sampler.Value.WRAP);
bs.setAnisotropy(8.0f);