]> git.cworth.org Git - apitrace-tests/commitdiff
Make tri_glsl test robust against attribute location changes.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Mon, 14 May 2012 19:22:28 +0000 (20:22 +0100)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Mon, 14 May 2012 19:22:28 +0000 (20:22 +0100)
apps/egl/gl/tri_glsl.c
apps/egl/gl/tri_glsl.ref.txt
apps/egl/gles2/tri_glsl.c
apps/egl/gles2/tri_glsl.ref.txt

index ab7e23603bc81c3c8a9cf058906de72e426ada72..df7b704cf3ef2a2aece208c8da1ed9104eee94a3 100644 (file)
@@ -161,7 +161,7 @@ create_shaders(void)
    glCompileShader(fragShader);
    glGetShaderiv(fragShader, GL_COMPILE_STATUS, &stat);
    if (!stat) {
    glCompileShader(fragShader);
    glGetShaderiv(fragShader, GL_COMPILE_STATUS, &stat);
    if (!stat) {
-      printf("Error: fragment shader did not compile!\n");
+      fprintf(stderr, "error: fragment shader did not compile!\n");
       exit(1);
    }
 
       exit(1);
    }
 
@@ -170,13 +170,15 @@ create_shaders(void)
    glCompileShader(vertShader);
    glGetShaderiv(vertShader, GL_COMPILE_STATUS, &stat);
    if (!stat) {
    glCompileShader(vertShader);
    glGetShaderiv(vertShader, GL_COMPILE_STATUS, &stat);
    if (!stat) {
-      printf("Error: vertex shader did not compile!\n");
+      fprintf(stderr, "error: vertex shader did not compile!\n");
       exit(1);
    }
 
    program = glCreateProgram();
    glAttachShader(program, fragShader);
    glAttachShader(program, vertShader);
       exit(1);
    }
 
    program = glCreateProgram();
    glAttachShader(program, fragShader);
    glAttachShader(program, vertShader);
+   glBindAttribLocation(program, attr_pos, "pos");
+   glBindAttribLocation(program, attr_color, "color");
    glLinkProgram(program);
 
    glGetProgramiv(program, GL_LINK_STATUS, &stat);
    glLinkProgram(program);
 
    glGetProgramiv(program, GL_LINK_STATUS, &stat);
@@ -184,28 +186,16 @@ create_shaders(void)
       char log[1000];
       GLsizei len;
       glGetProgramInfoLog(program, 1000, &len, log);
       char log[1000];
       GLsizei len;
       glGetProgramInfoLog(program, 1000, &len, log);
-      printf("Error: linking:\n%s\n", log);
+      fprintf(stderr, "error: linking:\n%s\n", log);
       exit(1);
    }
 
    glUseProgram(program);
 
       exit(1);
    }
 
    glUseProgram(program);
 
-   if (1) {
-      /* test setting attrib locations */
-      glBindAttribLocation(program, attr_pos, "pos");
-      glBindAttribLocation(program, attr_color, "color");
-      glLinkProgram(program);  /* needed to put attribs into effect */
-   }
-   else {
-      /* test automatic attrib locations */
-      attr_pos = glGetAttribLocation(program, "pos");
-      attr_color = glGetAttribLocation(program, "color");
-   }
+   attr_pos = glGetAttribLocation(program, "pos");
+   attr_color = glGetAttribLocation(program, "color");
 
    u_matrix = glGetUniformLocation(program, "modelviewProjection");
 
    u_matrix = glGetUniformLocation(program, "modelviewProjection");
-   printf("Uniform modelviewProjection at %d\n", u_matrix);
-   printf("Attrib pos at %d\n", attr_pos);
-   printf("Attrib color at %d\n", attr_color);
 }
 
 
 }
 
 
@@ -272,7 +262,7 @@ make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
    root = RootWindow( x_dpy, scrnum );
 
    if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) {
    root = RootWindow( x_dpy, scrnum );
 
    if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) {
-      printf("Error: couldn't get an EGL visual config\n");
+      fprintf(stderr, "error: couldn't get an EGL visual config\n");
       exit(1);
    }
 
       exit(1);
    }
 
@@ -280,7 +270,7 @@ make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
    assert(num_configs > 0);
 
    if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
    assert(num_configs > 0);
 
    if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
-      printf("Error: eglGetConfigAttrib() failed\n");
+      fprintf(stderr, "error: eglGetConfigAttrib() failed\n");
       exit(1);
    }
 
       exit(1);
    }
 
@@ -288,7 +278,7 @@ make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
    visTemplate.visualid = vid;
    visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals);
    if (!visInfo) {
    visTemplate.visualid = vid;
    visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals);
    if (!visInfo) {
-      printf("Error: couldn't get X visual\n");
+      fprintf(stderr, "error: couldn't get X visual\n");
       exit(1);
    }
 
       exit(1);
    }
 
@@ -324,7 +314,7 @@ make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
 
    ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, ctx_attribs );
    if (!ctx) {
 
    ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, ctx_attribs );
    if (!ctx) {
-      printf("Error: eglCreateContext failed\n");
+      fprintf(stderr, "error: eglCreateContext failed\n");
       exit(1);
    }
 
       exit(1);
    }
 
@@ -339,7 +329,7 @@ make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
 
    *surfRet = eglCreateWindowSurface(egl_dpy, config, win, NULL);
    if (!*surfRet) {
 
    *surfRet = eglCreateWindowSurface(egl_dpy, config, win, NULL);
    if (!*surfRet) {
-      printf("Error: eglCreateWindowSurface failed\n");
+      fprintf(stderr, "error: eglCreateWindowSurface failed\n");
       exit(1);
    }
 
       exit(1);
    }
 
@@ -459,19 +449,19 @@ main(int argc, char *argv[])
 
    x_dpy = XOpenDisplay(dpyName);
    if (!x_dpy) {
 
    x_dpy = XOpenDisplay(dpyName);
    if (!x_dpy) {
-      printf("Error: couldn't open display %s\n",
+      fprintf(stderr, "error: couldn't open display %s\n",
             dpyName ? dpyName : getenv("DISPLAY"));
       return -1;
    }
 
    egl_dpy = eglGetDisplay(x_dpy);
    if (!egl_dpy) {
             dpyName ? dpyName : getenv("DISPLAY"));
       return -1;
    }
 
    egl_dpy = eglGetDisplay(x_dpy);
    if (!egl_dpy) {
-      printf("Error: eglGetDisplay() failed\n");
+      fprintf(stderr, "error: eglGetDisplay() failed\n");
       return -1;
    }
 
    if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) {
       return -1;
    }
 
    if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) {
-      printf("Error: eglInitialize() failed\n");
+      fprintf(stderr, "error: eglInitialize() failed\n");
       return -1;
    }
 
       return -1;
    }
 
@@ -493,7 +483,7 @@ main(int argc, char *argv[])
 
    XMapWindow(x_dpy, win);
    if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) {
 
    XMapWindow(x_dpy, win);
    if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) {
-      printf("Error: eglMakeCurrent() failed\n");
+      fprintf(stderr, "error: eglMakeCurrent() failed\n");
       return -1;
    }
 
       return -1;
    }
 
index cdd77fced3419c5cc66ed996e4d02194fd782823..4af5cbe32e23acdfe34638273b05eb5779c722ac 100644 (file)
@@ -23,16 +23,13 @@ glGetShaderiv(shader = 2, pname = GL_COMPILE_STATUS, params = &1)
 glCreateProgram() = 3
 glAttachShader(program = 3, shader = 1)
 glAttachShader(program = 3, shader = 2)
 glCreateProgram() = 3
 glAttachShader(program = 3, shader = 1)
 glAttachShader(program = 3, shader = 2)
-glBindAttribLocation(program = 3, index = 1, name = "pos")
-glBindAttribLocation(program = 3, index = 0, name = "color")
-glLinkProgram(program = 3)
-glGetProgramiv(program = 3, pname = GL_LINK_STATUS, params = &1)
-glUseProgram(program = 3)
-glBindAttribLocation(program = 3, index = 0, name = "pos")
-glBindAttribLocation(program = 3, index = 1, name = "color")
 glBindAttribLocation(program = 3, index = 0, name = "pos")
 glBindAttribLocation(program = 3, index = 1, name = "color")
 glLinkProgram(program = 3)
 glBindAttribLocation(program = 3, index = 0, name = "pos")
 glBindAttribLocation(program = 3, index = 1, name = "color")
 glLinkProgram(program = 3)
+glGetProgramiv(program = 3, pname = GL_LINK_STATUS, params = &1)
+glUseProgram(program = 3)
+glGetAttribLocation(program = 3, name = "pos") = 0
+glGetAttribLocation(program = 3, name = "color") = 1
 glGetUniformLocation(program = 3, name = "modelviewProjection") = 0
 glViewport(x = 0, y = 0, width = 300, height = 300)
 glViewport(x = 0, y = 0, width = 300, height = 300)
 glGetUniformLocation(program = 3, name = "modelviewProjection") = 0
 glViewport(x = 0, y = 0, width = 300, height = 300)
 glViewport(x = 0, y = 0, width = 300, height = 300)
index d09824ba0515ba4340ddcd25cecdde63b0775891..e02d717adb26eca494f7e347036fb63be116c156 100644 (file)
@@ -161,7 +161,7 @@ create_shaders(void)
    glCompileShader(fragShader);
    glGetShaderiv(fragShader, GL_COMPILE_STATUS, &stat);
    if (!stat) {
    glCompileShader(fragShader);
    glGetShaderiv(fragShader, GL_COMPILE_STATUS, &stat);
    if (!stat) {
-      printf("Error: fragment shader did not compile!\n");
+      fprintf(stderr, "error: fragment shader did not compile!\n");
       exit(1);
    }
 
       exit(1);
    }
 
@@ -170,13 +170,15 @@ create_shaders(void)
    glCompileShader(vertShader);
    glGetShaderiv(vertShader, GL_COMPILE_STATUS, &stat);
    if (!stat) {
    glCompileShader(vertShader);
    glGetShaderiv(vertShader, GL_COMPILE_STATUS, &stat);
    if (!stat) {
-      printf("Error: vertex shader did not compile!\n");
+      fprintf(stderr, "error: vertex shader did not compile!\n");
       exit(1);
    }
 
    program = glCreateProgram();
    glAttachShader(program, fragShader);
    glAttachShader(program, vertShader);
       exit(1);
    }
 
    program = glCreateProgram();
    glAttachShader(program, fragShader);
    glAttachShader(program, vertShader);
+   glBindAttribLocation(program, attr_pos, "pos");
+   glBindAttribLocation(program, attr_color, "color");
    glLinkProgram(program);
 
    glGetProgramiv(program, GL_LINK_STATUS, &stat);
    glLinkProgram(program);
 
    glGetProgramiv(program, GL_LINK_STATUS, &stat);
@@ -184,28 +186,16 @@ create_shaders(void)
       char log[1000];
       GLsizei len;
       glGetProgramInfoLog(program, 1000, &len, log);
       char log[1000];
       GLsizei len;
       glGetProgramInfoLog(program, 1000, &len, log);
-      printf("Error: linking:\n%s\n", log);
+      fprintf(stderr, "error: linking:\n%s\n", log);
       exit(1);
    }
 
    glUseProgram(program);
 
       exit(1);
    }
 
    glUseProgram(program);
 
-   if (1) {
-      /* test setting attrib locations */
-      glBindAttribLocation(program, attr_pos, "pos");
-      glBindAttribLocation(program, attr_color, "color");
-      glLinkProgram(program);  /* needed to put attribs into effect */
-   }
-   else {
-      /* test automatic attrib locations */
-      attr_pos = glGetAttribLocation(program, "pos");
-      attr_color = glGetAttribLocation(program, "color");
-   }
+   attr_pos = glGetAttribLocation(program, "pos");
+   attr_color = glGetAttribLocation(program, "color");
 
    u_matrix = glGetUniformLocation(program, "modelviewProjection");
 
    u_matrix = glGetUniformLocation(program, "modelviewProjection");
-   printf("Uniform modelviewProjection at %d\n", u_matrix);
-   printf("Attrib pos at %d\n", attr_pos);
-   printf("Attrib color at %d\n", attr_color);
 }
 
 
 }
 
 
@@ -272,7 +262,7 @@ make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
    root = RootWindow( x_dpy, scrnum );
 
    if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) {
    root = RootWindow( x_dpy, scrnum );
 
    if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) {
-      printf("Error: couldn't get an EGL visual config\n");
+      fprintf(stderr, "error: couldn't get an EGL visual config\n");
       exit(1);
    }
 
       exit(1);
    }
 
@@ -280,7 +270,7 @@ make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
    assert(num_configs > 0);
 
    if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
    assert(num_configs > 0);
 
    if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
-      printf("Error: eglGetConfigAttrib() failed\n");
+      fprintf(stderr, "error: eglGetConfigAttrib() failed\n");
       exit(1);
    }
 
       exit(1);
    }
 
@@ -288,7 +278,7 @@ make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
    visTemplate.visualid = vid;
    visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals);
    if (!visInfo) {
    visTemplate.visualid = vid;
    visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals);
    if (!visInfo) {
-      printf("Error: couldn't get X visual\n");
+      fprintf(stderr, "error: couldn't get X visual\n");
       exit(1);
    }
 
       exit(1);
    }
 
@@ -324,7 +314,7 @@ make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
 
    ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, ctx_attribs );
    if (!ctx) {
 
    ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, ctx_attribs );
    if (!ctx) {
-      printf("Error: eglCreateContext failed\n");
+      fprintf(stderr, "error: eglCreateContext failed\n");
       exit(1);
    }
 
       exit(1);
    }
 
@@ -339,7 +329,7 @@ make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
 
    *surfRet = eglCreateWindowSurface(egl_dpy, config, win, NULL);
    if (!*surfRet) {
 
    *surfRet = eglCreateWindowSurface(egl_dpy, config, win, NULL);
    if (!*surfRet) {
-      printf("Error: eglCreateWindowSurface failed\n");
+      fprintf(stderr, "error: eglCreateWindowSurface failed\n");
       exit(1);
    }
 
       exit(1);
    }
 
@@ -459,19 +449,19 @@ main(int argc, char *argv[])
 
    x_dpy = XOpenDisplay(dpyName);
    if (!x_dpy) {
 
    x_dpy = XOpenDisplay(dpyName);
    if (!x_dpy) {
-      printf("Error: couldn't open display %s\n",
+      fprintf(stderr, "error: couldn't open display %s\n",
             dpyName ? dpyName : getenv("DISPLAY"));
       return -1;
    }
 
    egl_dpy = eglGetDisplay(x_dpy);
    if (!egl_dpy) {
             dpyName ? dpyName : getenv("DISPLAY"));
       return -1;
    }
 
    egl_dpy = eglGetDisplay(x_dpy);
    if (!egl_dpy) {
-      printf("Error: eglGetDisplay() failed\n");
+      fprintf(stderr, "error: eglGetDisplay() failed\n");
       return -1;
    }
 
    if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) {
       return -1;
    }
 
    if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) {
-      printf("Error: eglInitialize() failed\n");
+      fprintf(stderr, "error: eglInitialize() failed\n");
       return -1;
    }
 
       return -1;
    }
 
@@ -493,7 +483,7 @@ main(int argc, char *argv[])
 
    XMapWindow(x_dpy, win);
    if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) {
 
    XMapWindow(x_dpy, win);
    if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) {
-      printf("Error: eglMakeCurrent() failed\n");
+      fprintf(stderr, "error: eglMakeCurrent() failed\n");
       return -1;
    }
 
       return -1;
    }
 
index f73ccd074e9ef866d61b4996d976918112519e07..980ce60a627537663d75fac6ce67ea25e957d524 100644 (file)
@@ -23,16 +23,13 @@ glGetShaderiv(shader = 2, pname = GL_COMPILE_STATUS, params = &1)
 glCreateProgram() = 3
 glAttachShader(program = 3, shader = 1)
 glAttachShader(program = 3, shader = 2)
 glCreateProgram() = 3
 glAttachShader(program = 3, shader = 1)
 glAttachShader(program = 3, shader = 2)
-glBindAttribLocation(program = 3, index = 1, name = "pos")
-glBindAttribLocation(program = 3, index = 0, name = "color")
-glLinkProgram(program = 3)
-glGetProgramiv(program = 3, pname = GL_LINK_STATUS, params = &1)
-glUseProgram(program = 3)
-glBindAttribLocation(program = 3, index = 0, name = "pos")
-glBindAttribLocation(program = 3, index = 1, name = "color")
 glBindAttribLocation(program = 3, index = 0, name = "pos")
 glBindAttribLocation(program = 3, index = 1, name = "color")
 glLinkProgram(program = 3)
 glBindAttribLocation(program = 3, index = 0, name = "pos")
 glBindAttribLocation(program = 3, index = 1, name = "color")
 glLinkProgram(program = 3)
+glGetProgramiv(program = 3, pname = GL_LINK_STATUS, params = &1)
+glUseProgram(program = 3)
+glGetAttribLocation(program = 3, name = "pos") = 0
+glGetAttribLocation(program = 3, name = "color") = 1
 glGetUniformLocation(program = 3, name = "modelviewProjection") = 0
 glViewport(x = 0, y = 0, width = 300, height = 300)
 glViewport(x = 0, y = 0, width = 300, height = 300)
 glGetUniformLocation(program = 3, name = "modelviewProjection") = 0
 glViewport(x = 0, y = 0, width = 300, height = 300)
 glViewport(x = 0, y = 0, width = 300, height = 300)