summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorXia Wang <xiaw@google.com>2011-05-27 16:55:30 -0700
committerXia Wang <xiaw@google.com>2011-06-06 15:12:29 -0700
commit62e8f2228f81c3ae6a55c665b6ec0fe8c09b271e (patch)
treedee2394978e14945b8bae5ff129802de66239bd7 /tests
parentc321c19fc91bfec9a74039ed4d37b815dd4ef379 (diff)
downloadframeworks_base-62e8f2228f81c3ae6a55c665b6ec0fe8c09b271e.zip
frameworks_base-62e8f2228f81c3ae6a55c665b6ec0fe8c09b271e.tar.gz
frameworks_base-62e8f2228f81c3ae6a55c665b6ec0fe8c09b271e.tar.bz2
Add OpenGl benchmark tests:
display images with different texture in each mesh. Change-Id: I051be3cf8be117e62fc635dfaf75b5c0e4cdd644
Diffstat (limited to 'tests')
-rwxr-xr-xtests/RenderScriptTests/PerfTest/res/drawable/globe.pngbin0 -> 4142 bytes
-rw-r--r--tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBenchRS.java39
-rw-r--r--tests/RenderScriptTests/PerfTest/src/com/android/perftest/rsbench.rs47
3 files changed, 84 insertions, 2 deletions
diff --git a/tests/RenderScriptTests/PerfTest/res/drawable/globe.png b/tests/RenderScriptTests/PerfTest/res/drawable/globe.png
new file mode 100755
index 0000000..f9d6172
--- /dev/null
+++ b/tests/RenderScriptTests/PerfTest/res/drawable/globe.png
Binary files differ
diff --git a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBenchRS.java b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBenchRS.java
index 5377f12..3ba6ba4 100644
--- a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBenchRS.java
+++ b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBenchRS.java
@@ -113,16 +113,20 @@ public class RsBenchRS {
private Allocation mTexOpaque;
private Allocation mTexTransparent;
private Allocation mTexChecker;
+ private Allocation mTexGlobe;
private Mesh m10by10Mesh;
private Mesh m100by100Mesh;
private Mesh mWbyHMesh;
private Mesh mTorus;
+ private Mesh mSingleMesh;
Font mFontSans;
Font mFontSerif;
private Allocation mTextAlloc;
+ private ScriptField_TexAllocs_s mTextureAllocs;
+
private ScriptC_rsbench mScript;
private final BitmapFactory.Options mOptionsARGB = new BitmapFactory.Options();
@@ -253,6 +257,27 @@ public class RsBenchRS {
return tmb.create(true);
}
+ /**
+ * Create a mesh with a single quad for the given width and height.
+ */
+ private Mesh getSingleMesh(float width, float height) {
+ Mesh.TriangleMeshBuilder tmb = new Mesh.TriangleMeshBuilder(mRS,
+ 2, Mesh.TriangleMeshBuilder.TEXTURE_0);
+ float xOffset = width/2;
+ float yOffset = height/2;
+ tmb.setTexture(0, 0);
+ tmb.addVertex(-1.0f * xOffset, -1.0f * yOffset);
+ tmb.setTexture(1, 0);
+ tmb.addVertex(xOffset, -1.0f * yOffset);
+ tmb.setTexture(1, 1);
+ tmb.addVertex(xOffset, yOffset);
+ tmb.setTexture(0, 1);
+ tmb.addVertex(-1.0f * xOffset, yOffset);
+ tmb.addTriangle(0, 3, 1);
+ tmb.addTriangle(1, 3, 2);
+ return tmb.create(true);
+ }
+
private void initProgramStore() {
// Use stock the stock program store object
mProgStoreBlendNoneDepth = ProgramStore.BLEND_NONE_DEPTH_TEST(mRS);
@@ -392,11 +417,13 @@ public class RsBenchRS {
mTexOpaque = loadTextureRGB(R.drawable.data);
mTexTransparent = loadTextureARGB(R.drawable.leaf);
mTexChecker = loadTextureRGB(R.drawable.checker);
+ mTexGlobe = loadTextureRGB(R.drawable.globe);
mScript.set_gTexTorus(mTexTorus);
mScript.set_gTexOpaque(mTexOpaque);
mScript.set_gTexTransparent(mTexTransparent);
mScript.set_gTexChecker(mTexChecker);
+ mScript.set_gTexGlobe(mTexGlobe);
}
private void initFonts() {
@@ -418,6 +445,8 @@ public class RsBenchRS {
mScript.set_g100by100Mesh(m100by100Mesh);
mWbyHMesh= getMbyNMesh(mBenchmarkDimX, mBenchmarkDimY, mBenchmarkDimX/4, mBenchmarkDimY/4);
mScript.set_gWbyHMesh(mWbyHMesh);
+ mSingleMesh = getSingleMesh(50, 50);
+ mScript.set_gSingleMesh(mSingleMesh);
FileA3D model = FileA3D.createFromResource(mRS, mRes, R.raw.torus);
FileA3D.IndexEntry entry = model.getIndexEntry(0);
@@ -517,6 +546,16 @@ public class RsBenchRS {
Allocation.USAGE_GRAPHICS_RENDER_TARGET);
mScript.set_gRenderBufferDepth(offscreen);
+
+ mTextureAllocs = new ScriptField_TexAllocs_s(mRS, 100);
+ for (int i = 0; i < 100; i++) {
+ ScriptField_TexAllocs_s.Item texElem = new ScriptField_TexAllocs_s.Item();
+ texElem.texture = loadTextureRGB(R.drawable.globe);
+ mTextureAllocs.set(texElem, i, false);
+ }
+ mTextureAllocs.copyAll();
+ mScript.bind_gTexList100(mTextureAllocs);
+
mRS.bindRootScript(mScript);
}
}
diff --git a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/rsbench.rs b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/rsbench.rs
index e7f5cd4..b6572fb 100644
--- a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/rsbench.rs
+++ b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/rsbench.rs
@@ -23,7 +23,7 @@
const int RS_MSG_TEST_DONE = 100;
const int RS_MSG_RESULTS_READY = 101;
-const int gMaxModes = 25;
+const int gMaxModes = 27;
int gMaxLoops;
// Allocation to send test names back to java
@@ -44,11 +44,19 @@ rs_allocation gTexOpaque;
rs_allocation gTexTorus;
rs_allocation gTexTransparent;
rs_allocation gTexChecker;
+rs_allocation gTexGlobe;
+
+typedef struct TexAllocs_s {
+ rs_allocation texture;
+} TexAllocs;
+
+TexAllocs *gTexList100;
rs_mesh g10by10Mesh;
rs_mesh g100by100Mesh;
rs_mesh gWbyHMesh;
rs_mesh gTorusMesh;
+rs_mesh gSingleMesh;
rs_font gFontSans;
rs_font gFontSerif;
@@ -142,7 +150,7 @@ static void displayFontSamples(int fillNum) {
}
static void bindProgramVertexOrtho() {
- // Default vertex sahder
+ // Default vertex shader
rsgBindProgramVertex(gProgVertex);
// Setup the projection matrix
rs_matrix4x4 proj;
@@ -198,6 +206,33 @@ static void displayMeshSamples(int meshNum) {
}
}
+// Display sample images in a mesh with different texture
+static void displayMeshWithMultiTexture(int meshMode) {
+ bindProgramVertexOrtho();
+
+ // Fragment shader with texture
+ rsgBindProgramStore(gProgStoreBlendAlpha);
+ rsgBindProgramFragment(gProgFragmentTexture);
+ rsgBindSampler(gProgFragmentTexture, 0, gLinearClamp);
+
+ int meshCount = (int)pow(10.0f, (float)(meshMode + 1));
+
+ float yPos = 0;
+ for (int y = 0; y < meshCount; y++) {
+ yPos = (y + 1) * 50;
+ float xPos = 0;
+ for (int x = 0; x < meshCount; x++) {
+ xPos = (x + 1) * 50;
+ rs_matrix4x4 matrix;
+ rsMatrixLoadTranslate(&matrix, xPos, yPos, 0);
+ rsgProgramVertexLoadModelMatrix(&matrix);
+ int i = (x + y * meshCount) % 100;
+ rsgBindTexture(gProgFragmentTexture, 0, gTexList100[i].texture);
+ rsgDrawMesh(gSingleMesh);
+ }
+ }
+}
+
static float gTorusRotation = 0;
static void updateModelMatrix(rs_matrix4x4 *matrix, void *buffer) {
if (buffer == 0) {
@@ -497,6 +532,8 @@ static const char *testNames[] = {
"Geo test 25.6k heavy fragment heavy vertex",
"Geo test 51.2k heavy fragment heavy vertex",
"Geo test 204.8k small tries heavy fragment heavy vertex",
+ "Mesh with 10 by 10 texture",
+ "Mesh with 100 by 100 texture",
};
void getTestName(int testIndex) {
@@ -589,6 +626,12 @@ static void runTest(int index) {
case 24:
displayPixelLightSamples(8, true);
break;
+ case 25:
+ displayMeshWithMultiTexture(0);
+ break;
+ case 26:
+ displayMeshWithMultiTexture(1);
+ break;
}
}