summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorXia Wang <xiaw@google.com>2011-06-14 19:08:22 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-06-14 19:08:22 -0700
commit4a49b95d4b9801c83a12b87e7e3d20501b3a185c (patch)
treeb94d3e4375e5f9f8a1be8872629131c5288c1eba /tests
parent05be9531b6faf9313e7577284a547b89950d0d55 (diff)
parentcb040a063fd527afc37f6f703fab882ac3ab63cd (diff)
downloadframeworks_base-4a49b95d4b9801c83a12b87e7e3d20501b3a185c.zip
frameworks_base-4a49b95d4b9801c83a12b87e7e3d20501b3a185c.tar.gz
frameworks_base-4a49b95d4b9801c83a12b87e7e3d20501b3a185c.tar.bz2
Merge "Add more opengl benchmark test: - all apps in launcher - shortcuts of apps in home page"
Diffstat (limited to 'tests')
-rw-r--r--tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBenchRS.java21
-rw-r--r--tests/RenderScriptTests/PerfTest/src/com/android/perftest/rsbench.rs113
2 files changed, 113 insertions, 21 deletions
diff --git a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBenchRS.java b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBenchRS.java
index 3ba6ba4..b568781 100644
--- a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBenchRS.java
+++ b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBenchRS.java
@@ -44,6 +44,7 @@ import android.util.Log;
public class RsBenchRS {
private static final String TAG = "RsBenchRS";
+ private static final String SAMPLE_TEXT = "Bench Test";
int mWidth;
int mHeight;
@@ -125,7 +126,8 @@ public class RsBenchRS {
Font mFontSerif;
private Allocation mTextAlloc;
- private ScriptField_TexAllocs_s mTextureAllocs;
+ private ScriptField_ListAllocs_s mTextureAllocs;
+ private ScriptField_ListAllocs_s mSampleTextAllocs;
private ScriptC_rsbench mScript;
@@ -445,7 +447,7 @@ public class RsBenchRS {
mScript.set_g100by100Mesh(m100by100Mesh);
mWbyHMesh= getMbyNMesh(mBenchmarkDimX, mBenchmarkDimY, mBenchmarkDimX/4, mBenchmarkDimY/4);
mScript.set_gWbyHMesh(mWbyHMesh);
- mSingleMesh = getSingleMesh(50, 50);
+ mSingleMesh = getSingleMesh(1, 1); // a unit size mesh
mScript.set_gSingleMesh(mSingleMesh);
FileA3D model = FileA3D.createFromResource(mRS, mRes, R.raw.torus);
@@ -547,15 +549,24 @@ public class RsBenchRS {
mScript.set_gRenderBufferDepth(offscreen);
- mTextureAllocs = new ScriptField_TexAllocs_s(mRS, 100);
+ mTextureAllocs = new ScriptField_ListAllocs_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);
+ ScriptField_ListAllocs_s.Item texElem = new ScriptField_ListAllocs_s.Item();
+ texElem.item = loadTextureRGB(R.drawable.globe);
mTextureAllocs.set(texElem, i, false);
}
mTextureAllocs.copyAll();
mScript.bind_gTexList100(mTextureAllocs);
+ mSampleTextAllocs = new ScriptField_ListAllocs_s(mRS, 100);
+ for (int i = 0; i < 100; i++) {
+ ScriptField_ListAllocs_s.Item textElem = new ScriptField_ListAllocs_s.Item();
+ textElem.item = Allocation.createFromString(mRS, SAMPLE_TEXT, Allocation.USAGE_SCRIPT);
+ mSampleTextAllocs.set(textElem, i, false);
+ }
+ mSampleTextAllocs.copyAll();
+ mScript.bind_gSampleTextList100(mSampleTextAllocs);
+
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 b6572fb..0294b31 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 = 27;
+const int gMaxModes = 29;
int gMaxLoops;
// Allocation to send test names back to java
@@ -46,11 +46,12 @@ rs_allocation gTexTransparent;
rs_allocation gTexChecker;
rs_allocation gTexGlobe;
-typedef struct TexAllocs_s {
- rs_allocation texture;
-} TexAllocs;
+typedef struct ListAllocs_s {
+ rs_allocation item;
+} ListAllocs;
-TexAllocs *gTexList100;
+ListAllocs *gTexList100;
+ListAllocs *gSampleTextList100;
rs_mesh g10by10Mesh;
rs_mesh g100by100Mesh;
@@ -195,6 +196,7 @@ static void displayMeshSamples(int meshNum) {
rsgBindProgramStore(gProgStoreBlendNone);
rsgBindProgramFragment(gProgFragmentTexture);
rsgBindSampler(gProgFragmentTexture, 0, gLinearClamp);
+
rsgBindTexture(gProgFragmentTexture, 0, gTexOpaque);
if (meshNum == 0) {
@@ -207,7 +209,7 @@ static void displayMeshSamples(int meshNum) {
}
// Display sample images in a mesh with different texture
-static void displayMeshWithMultiTexture(int meshMode) {
+static void displayIcons(int meshMode) {
bindProgramVertexOrtho();
// Fragment shader with texture
@@ -217,22 +219,90 @@ static void displayMeshWithMultiTexture(int meshMode) {
int meshCount = (int)pow(10.0f, (float)(meshMode + 1));
+ float size = 50.0;
+ rs_matrix4x4 matrix;
+ rsMatrixLoadScale(&matrix, size, size, 1.0);
+
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);
+ rs_matrix4x4 transMatrix;
+ rsMatrixLoadTranslate(&transMatrix, xPos, yPos, 0);
+ rsMatrixMultiply(&transMatrix, &matrix);
+ rsgProgramVertexLoadModelMatrix(&transMatrix);
int i = (x + y * meshCount) % 100;
- rsgBindTexture(gProgFragmentTexture, 0, gTexList100[i].texture);
+ rsgBindTexture(gProgFragmentTexture, 0, gTexList100[i].item);
+ rsgDrawMesh(gSingleMesh);
+ }
+ }
+}
+
+// Draw meshes in a single page with top left corner coordinates (xStart, yStart)
+static void drawMeshInPage(float xStart, float yStart, int wResolution, int hResolution) {
+ // Draw wResolution * hResolution meshes in one page
+ float wMargin = 100.0f;
+ float hMargin = 100.0f;
+ float xPad = 50.0f;
+ float yPad = 20.0f;
+ float size = 100.0f; // size of images
+
+ // font info
+ rs_font font = gFontSans;
+ rsgBindFont(font);
+ rsgFontColor(1.0f, 1.0f, 1.0f, 1.0f);
+
+ // Measure text size
+ int left = 0, right = 0, top = 0, bottom = 0;
+ rsgMeasureText(gSampleTextList100[0].item, &left, &right, &top, &bottom);
+ float textHeight = (float)(top - bottom);
+ float textWidth = (float)(right - left);
+
+ rs_matrix4x4 matrix;
+ rsMatrixLoadScale(&matrix, size, size, 1.0);
+
+ for (int y = 0; y < hResolution; y++) {
+ float yPos = yStart + hMargin + y * size + y * yPad;
+ for (int x = 0; x < wResolution; x++) {
+ float xPos = xStart + wMargin + x * size + x * xPad;
+
+ rs_matrix4x4 transMatrix;
+ rsMatrixLoadTranslate(&transMatrix, xPos + size/2, yPos + size/2, 0);
+ rsMatrixMultiply(&transMatrix, &matrix); // scale the mesh
+ rsgProgramVertexLoadModelMatrix(&transMatrix);
+
+ int i = (y * wResolution + x) % 100;
+ rsgBindTexture(gProgFragmentTexture, 0, gTexList100[i].item);
rsgDrawMesh(gSingleMesh);
+ rsgDrawText(gSampleTextList100[i].item, xPos, yPos + size + yPad/2 + textHeight);
}
}
}
+// Display both images and text as shown in launcher and homepage
+// meshMode will decide how many pages we draw
+// meshMode = 0: draw 3 pages of meshes
+// meshMode = 1: draw 5 pages of meshes
+static void displayImageWithText(int wResolution, int hResolution, int meshMode) {
+ bindProgramVertexOrtho();
+
+ // Fragment shader with texture
+ rsgBindProgramStore(gProgStoreBlendAlpha);
+ rsgBindProgramFragment(gProgFragmentTexture);
+ rsgBindSampler(gProgFragmentTexture, 0, gLinearClamp);
+
+ drawMeshInPage(0, 0, wResolution, hResolution);
+ drawMeshInPage(-1.0f*gRenderSurfaceW, 0, wResolution, hResolution);
+ drawMeshInPage(1.0f*gRenderSurfaceW, 0, wResolution, hResolution);
+ if (meshMode == 1) {
+ // draw another two pages of meshes
+ drawMeshInPage(-2.0f*gRenderSurfaceW, 0, wResolution, hResolution);
+ drawMeshInPage(2.0f*gRenderSurfaceW, 0, wResolution, hResolution);
+ }
+}
+
static float gTorusRotation = 0;
static void updateModelMatrix(rs_matrix4x4 *matrix, void *buffer) {
if (buffer == 0) {
@@ -532,8 +602,14 @@ 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",
+ "UI test with icon display 10 by 10", // 25
+ "UI test with icon display 100 by 100", // 26
+ "UI test with image and text display 3 pages", // 27
+ "UI test with image and text display 5 pages", // 28
+ "UI test with list view", // 29
+// "UI test with live wallpaper", // 30
+// "Mesh with 10 by 10 texture",
+// "Mesh with 100 by 100 texture",
};
void getTestName(int testIndex) {
@@ -627,10 +703,16 @@ static void runTest(int index) {
displayPixelLightSamples(8, true);
break;
case 25:
- displayMeshWithMultiTexture(0);
+ displayIcons(0);
break;
case 26:
- displayMeshWithMultiTexture(1);
+ displayIcons(1);
+ break;
+ case 27:
+ displayImageWithText(7, 5, 0);
+ break;
+ case 28:
+ displayImageWithText(7, 5, 1);
break;
}
}
@@ -683,6 +765,7 @@ int root(void) {
gRenderSurfaceW = rsgGetWidth();
gRenderSurfaceH = rsgGetHeight();
int size = 8;
+ // draw each frame at (8, 3/4 gRenderSurfaceH) with size
drawOffscreenResult((drawPos+=size)%gRenderSurfaceW, (gRenderSurfaceH * 3) / 4, size, size);
}
@@ -692,11 +775,9 @@ int root(void) {
float fps = (float)(frameCount) / ((float)(end - start)*0.001f);
rsDebug(testNames[benchMode], fps);
gResultBuffer[benchMode] = fps;
-
drawOffscreenResult(0, 0,
gRenderSurfaceW / 2,
gRenderSurfaceH / 2);
-
const char* text = testNames[benchMode];
int left = 0, right = 0, top = 0, bottom = 0;
uint width = rsgGetWidth();