summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--opengl/tests/angeles/app-linux.c39
-rw-r--r--opengl/tests/fillrate/Android.mk17
-rw-r--r--opengl/tests/fillrate/fillrate.cpp149
-rw-r--r--opengl/tests/textures/textures.c33
4 files changed, 231 insertions, 7 deletions
diff --git a/opengl/tests/angeles/app-linux.c b/opengl/tests/angeles/app-linux.c
index 7d0d320..6be4876 100644
--- a/opengl/tests/angeles/app-linux.c
+++ b/opengl/tests/angeles/app-linux.c
@@ -132,6 +132,7 @@ static int initGraphics()
};
EGLint numConfigs = -1;
+ EGLint n = 0;
EGLint majorVersion;
EGLint minorVersion;
EGLConfig config;
@@ -148,15 +149,43 @@ static int initGraphics()
egl_error("eglInitialize");
eglGetConfigs(dpy, NULL, 0, &numConfigs);
- egl_error("eglGetConfigs");
- fprintf(stderr,"num configs %d\n", numConfigs);
+
+ // Get all the "potential match" configs...
+ EGLConfig* const configs = malloc(sizeof(EGLConfig)*numConfigs);
+ eglChooseConfig(dpy, s_configAttribs, configs, numConfigs, &n);
+ config = configs[0];
+ if (n > 1) {
+ // if there is more than one candidate, go through the list
+ // and pick one that matches our framebuffer format
+ int fbSzA = 0; // should not hardcode
+ int fbSzR = 5; // should not hardcode
+ int fbSzG = 6; // should not hardcode
+ int fbSzB = 5; // should not hardcode
+ int i;
+ for (i=0 ; i<n ; i++) {
+ EGLint r,g,b,a;
+ eglGetConfigAttrib(dpy, configs[i], EGL_RED_SIZE, &r);
+ eglGetConfigAttrib(dpy, configs[i], EGL_GREEN_SIZE, &g);
+ eglGetConfigAttrib(dpy, configs[i], EGL_BLUE_SIZE, &b);
+ eglGetConfigAttrib(dpy, configs[i], EGL_ALPHA_SIZE, &a);
+ if (fbSzA == a && fbSzR == r && fbSzG == g && fbSzB == b) {
+ config = configs[i];
+ break;
+ }
+ }
+ }
+ free(configs);
+
- eglChooseConfig(dpy, s_configAttribs, &config, 1, &numConfigs);
- egl_error("eglChooseConfig");
+ //eglGetConfigs(dpy, NULL, 0, &numConfigs);
+ //egl_error("eglGetConfigs");
+ //fprintf(stderr,"num configs %d\n", numConfigs);
+ //eglChooseConfig(dpy, s_configAttribs, &config, 1, &numConfigs);
+ //egl_error("eglChooseConfig");
surface = eglCreateWindowSurface(dpy, config,
android_createDisplaySurface(), NULL);
- egl_error("eglMapWindowSurface");
+ egl_error("eglCreateWindowSurface");
fprintf(stderr,"surface = %p\n", surface);
diff --git a/opengl/tests/fillrate/Android.mk b/opengl/tests/fillrate/Android.mk
new file mode 100644
index 0000000..a7d30c2
--- /dev/null
+++ b/opengl/tests/fillrate/Android.mk
@@ -0,0 +1,17 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ fillrate.cpp
+
+LOCAL_SHARED_LIBRARIES := \
+ libcutils \
+ libEGL \
+ libGLESv1_CM \
+ libui
+
+LOCAL_MODULE:= test-opengl-fillrate
+
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_EXECUTABLE)
diff --git a/opengl/tests/fillrate/fillrate.cpp b/opengl/tests/fillrate/fillrate.cpp
new file mode 100644
index 0000000..c814e8d
--- /dev/null
+++ b/opengl/tests/fillrate/fillrate.cpp
@@ -0,0 +1,149 @@
+/*
+**
+** Copyright 2006, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+#define LOG_TAG "fillrate"
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <EGL/egl.h>
+#include <GLES/gl.h>
+#include <GLES/glext.h>
+
+#include <utils/StopWatch.h>
+#include <ui/FramebufferNativeWindow.h>
+
+using namespace android;
+
+int main(int argc, char** argv)
+{
+ EGLint configAttribs[] = {
+ EGL_DEPTH_SIZE, 0,
+ EGL_NONE
+ };
+
+ EGLint numConfigs = -1, n=0;
+ EGLint majorVersion;
+ EGLint minorVersion;
+ EGLConfig config;
+ EGLContext context;
+ EGLSurface surface;
+ EGLint w, h;
+
+ EGLDisplay dpy;
+
+ dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+ eglInitialize(dpy, &majorVersion, &minorVersion);
+
+ // Get all the "potential match" configs...
+ eglGetConfigs(dpy, NULL, 0, &numConfigs);
+ EGLConfig* const configs = (EGLConfig*)malloc(sizeof(EGLConfig)*numConfigs);
+ eglChooseConfig(dpy, configAttribs, configs, numConfigs, &n);
+ config = configs[0];
+ if (n > 1) {
+ // if there is more than one candidate, go through the list
+ // and pick one that matches our framebuffer format
+ int fbSzA = 0; // should not hardcode
+ int fbSzR = 5; // should not hardcode
+ int fbSzG = 6; // should not hardcode
+ int fbSzB = 5; // should not hardcode
+ int i;
+ for (i=0 ; i<n ; i++) {
+ EGLint r,g,b,a;
+ eglGetConfigAttrib(dpy, configs[i], EGL_RED_SIZE, &r);
+ eglGetConfigAttrib(dpy, configs[i], EGL_GREEN_SIZE, &g);
+ eglGetConfigAttrib(dpy, configs[i], EGL_BLUE_SIZE, &b);
+ eglGetConfigAttrib(dpy, configs[i], EGL_ALPHA_SIZE, &a);
+ if (fbSzA == a && fbSzR == r && fbSzG == g && fbSzB == b) {
+ config = configs[i];
+ break;
+ }
+ }
+ }
+ free(configs);
+
+ surface = eglCreateWindowSurface(dpy, config,
+ android_createDisplaySurface(), NULL);
+ context = eglCreateContext(dpy, config, NULL, NULL);
+ eglMakeCurrent(dpy, surface, surface, context);
+ eglQuerySurface(dpy, surface, EGL_WIDTH, &w);
+ eglQuerySurface(dpy, surface, EGL_HEIGHT, &h);
+
+ printf("w=%d, h=%d\n", w, h);
+
+ glBindTexture(GL_TEXTURE_2D, 0);
+ glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glDisable(GL_DITHER);
+ glDisable(GL_BLEND);
+ glEnable(GL_TEXTURE_2D);
+ glColor4f(1,1,1,1);
+
+ uint32_t* t32 = (uint32_t*)malloc(512*512*4);
+ for (int y=0 ; y<512 ; y++) {
+ for (int x=0 ; x<512 ; x++) {
+ t32[x+y*512] = 0x10FFFFFF;
+ }
+ }
+
+ const GLfloat vertices[4][2] = {
+ { 0, 0 },
+ { 0, h },
+ { w, h },
+ { w, 0 }
+ };
+
+ const GLfloat texCoords[4][2] = {
+ { 0, 0 },
+ { 0, 1 },
+ { 1, 1 },
+ { 1, 0 }
+ };
+
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 512, 512, 0, GL_RGBA, GL_UNSIGNED_BYTE, t32);
+
+ glViewport(0, 0, w, h);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrthof(0, w, 0, h, 0, 1);
+
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glVertexPointer(2, GL_FIXED, 0, vertices);
+ glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
+
+ glClearColor(1,0,0,0);
+ glClear(GL_COLOR_BUFFER_BIT);
+ glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+ eglSwapBuffers(dpy, surface);
+
+ for (int c=1 ; c<32 ; c++) {
+ glClear(GL_COLOR_BUFFER_BIT);
+ nsecs_t now = systemTime();
+ for (int i=0 ; i<c ; i++) {
+ glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+ }
+ eglSwapBuffers(dpy, surface);
+ nsecs_t t = systemTime() - now;
+ printf("%lld\t%d\t%f\n", t, c, (double(t)/c)/1000000.0);
+ }
+ return 0;
+}
diff --git a/opengl/tests/textures/textures.c b/opengl/tests/textures/textures.c
index 214291b..d877e74 100644
--- a/opengl/tests/textures/textures.c
+++ b/opengl/tests/textures/textures.c
@@ -31,7 +31,7 @@ int main(int argc, char** argv)
EGL_NONE
};
- EGLint numConfigs = -1;
+ EGLint numConfigs = -1, n=0;
EGLint majorVersion;
EGLint minorVersion;
EGLConfig config;
@@ -43,7 +43,36 @@ int main(int argc, char** argv)
dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
eglInitialize(dpy, &majorVersion, &minorVersion);
- eglChooseConfig(dpy, s_configAttribs, &config, 1, &numConfigs);
+
+ // Get all the "potential match" configs...
+ eglGetConfigs(dpy, NULL, 0, &numConfigs);
+ EGLConfig* const configs = malloc(sizeof(EGLConfig)*numConfigs);
+ eglChooseConfig(dpy, s_configAttribs, configs, numConfigs, &n);
+ config = configs[0];
+ if (n > 1) {
+ // if there is more than one candidate, go through the list
+ // and pick one that matches our framebuffer format
+ int fbSzA = 0; // should not hardcode
+ int fbSzR = 5; // should not hardcode
+ int fbSzG = 6; // should not hardcode
+ int fbSzB = 5; // should not hardcode
+ int i;
+ for (i=0 ; i<n ; i++) {
+ EGLint r,g,b,a;
+ eglGetConfigAttrib(dpy, configs[i], EGL_RED_SIZE, &r);
+ eglGetConfigAttrib(dpy, configs[i], EGL_GREEN_SIZE, &g);
+ eglGetConfigAttrib(dpy, configs[i], EGL_BLUE_SIZE, &b);
+ eglGetConfigAttrib(dpy, configs[i], EGL_ALPHA_SIZE, &a);
+ if (fbSzA == a && fbSzR == r && fbSzG == g && fbSzB == b) {
+ config = configs[i];
+ break;
+ }
+ }
+ }
+ free(configs);
+
+
+
surface = eglCreateWindowSurface(dpy, config,
android_createDisplaySurface(), NULL);
context = eglCreateContext(dpy, config, NULL, NULL);