enum piglit_result piglit_display(void) { #ifdef GL_ARB_ES2_compatibility GLboolean pass = GL_TRUE; float green[] = {0.0, 1.0, 0.0, 0.0}; float blue[] = {0.0, 0.0, 1.0, 0.0}; draw(green, 0.0f); glReleaseShaderCompiler(); draw(blue, 1.0f); pass &= piglit_probe_pixel_rgba(piglit_width / 4, piglit_height / 2, green); pass &= piglit_probe_pixel_rgba(piglit_width * 3 / 4, piglit_height / 2, blue); assert(!glGetError()); glutSwapBuffers(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; #else return PIGLIT_SKIP; #endif /* GL_ARB_ES2_compatibility */ }
enum piglit_result piglit_display(void) { bool pass = true; float green[] = {0, 1, 0, 1}; float blue[] = {0, 0, 1, 1}; glClearColor(blue[0], blue[1], blue[2], 1.0); glClear(GL_COLOR_BUFFER_BIT); glBindVertexArray(vao); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer); glMultiDrawElementsBaseVertexEXT(GL_TRIANGLES, indices_count, GL_UNSIGNED_SHORT, (GLvoid*)indices_offset, 2, basevertex); /* Check for test pass */ pass = piglit_probe_pixel_rgba(100, 175, blue) && pass; pass = piglit_probe_pixel_rgba(100, 125, green) && pass; pass = piglit_probe_pixel_rgba(100, 75, blue) && pass; pass = piglit_probe_pixel_rgba(100, 25, green) && pass; piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { GLboolean pass = GL_TRUE; const float red[4] = {1, 0, 0, 1}; const float green[4] = {0, 1, 0, 1}; const float yellow[4] = {1, 1, 0, 1}; const float black[4] = {0, 0, 0, 1}; const float vert[] = { -1.0 + 2.0 * (point_size / 2.0) / piglit_width, -1.0 + 2.0 * (point_size / 2.0) / piglit_height }; GLint point_size_loc; glClearColor(0.5, 0.5, 0.5, 1.0); glClear(GL_COLOR_BUFFER_BIT); point_size_loc = glGetUniformLocation(prog, "point_size"); glUniform1f(point_size_loc, point_size); glVertexAttribPointer(PIGLIT_ATTRIB_POS, 2, GL_FLOAT, false, 0, vert); glEnableVertexAttribArray(PIGLIT_ATTRIB_POS); glDrawArrays(GL_POINTS, 0, 1); pass = pass && piglit_probe_pixel_rgba(0, 0, green); pass = pass && piglit_probe_pixel_rgba(point_size - 1, 0, yellow); pass = pass && piglit_probe_pixel_rgba(0, point_size - 1, black); pass = pass && piglit_probe_pixel_rgba(point_size - 1, point_size - 1, red); piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { static const float black[4] = { 0.0, 0.0, 0.0, 1.0 }; static const float red50[4] = { 0.5, 0.0, 0.0, 1.0 }; static const float red100[4] = { 1.0, 0.0, 0.0, 1.0 }; bool pass = true; glViewport(0, 0, piglit_width, piglit_height); /* This should draw a red gradient ranging from black * at the bottom of the window to full red at the top. */ glClearColor(0.2, 0.2, 0.8, 1.0); glClear(GL_COLOR_BUFFER_BIT); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); if (!piglit_probe_pixel_rgba(0, 0, black)) pass = false; if (!piglit_probe_pixel_rgba(0, piglit_height/2, red50)) pass = false; if (!piglit_probe_pixel_rgba(0, piglit_height-1, red100)) pass = false; piglit_present_results(); pass = piglit_check_gl_error(GL_NO_ERROR) && pass; return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { GLboolean pass = GL_TRUE; float green[4] = {0.0, 1.0, 0.0, 0.0}; float blue[4] = {0.0, 0.0, 1.0, 0.0}; glUseProgram(prog1); glBegin(GL_TRIANGLE_FAN); glVertex2f(-1.0, -1.0); glVertex2f(-0.5, -1.0); glVertex2f(-0.5, 1.0); glVertex2f(-1.0, 1.0); glEnd(); glUseProgram(prog2); glBegin(GL_TRIANGLE_FAN); glVertex2f(-0.5, -1.0); glVertex2f( 0.0, -1.0); glVertex2f( 0.0, 1.0); glVertex2f(-0.5, 1.0); glEnd(); glUseProgram(prog1); glBegin(GL_TRIANGLE_FAN); glVertex2f(0.0, -1.0); glVertex2f(0.5, -1.0); glVertex2f(0.5, 1.0); glVertex2f(0.0, 1.0); glEnd(); glUseProgram(prog2); glBegin(GL_TRIANGLE_FAN); glVertex2f(0.5, -1.0); glVertex2f(1.0, -1.0); glVertex2f(1.0, 1.0); glVertex2f(0.5, 1.0); glEnd(); pass &= piglit_probe_pixel_rgba(piglit_width * 1 / 8, piglit_height / 2, green); pass &= piglit_probe_pixel_rgba(piglit_width * 3 / 8, piglit_height / 2, blue); pass &= piglit_probe_pixel_rgba(piglit_width * 5 / 8, piglit_height / 2, green); pass &= piglit_probe_pixel_rgba(piglit_width * 7 / 8, piglit_height / 2, blue); glutSwapBuffers(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
static bool test(bool use_dlist) { GLuint list1 = 0, list2 = 0; bool pass; glClear(GL_COLOR_BUFFER_BIT); if (use_dlist) { list1 = glGenLists(1); glNewList(list1, GL_COMPILE); } glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_FLOAT, 0, verts); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); if (use_dlist) { glEndList(); list2 = glGenLists(1); glNewList(list2, GL_COMPILE); } glDrawArrays(GL_TRIANGLE_FAN, 4, 4); if (use_dlist) { glEndList(); glCallList(list1); glCallList(list2); glDeleteLists(list1, 1); glDeleteLists(list2, 1); } pass = piglit_probe_pixel_rgba(piglit_width*1/4, piglit_height/2, white); pass = piglit_probe_pixel_rgba(piglit_width*3/4, piglit_height/2, white) && pass; pass = piglit_probe_pixel_rgba(piglit_width*3/4, 2, black) && pass; piglit_present_results(); if (!pass) { printf("Fail while testing %s\n", use_dlist ? "display list" : "immediate mode"); } return true; }
/* Test texenv-combine with a single texture unit. */ static bool run_single_texture_test(const struct test_param test_params[], const char *test_name) { assert(num_tex_units == 1); setup_colors(); const int num_tests = count_test_combinations(test_params); for (int test = 0; test < num_tests; test += test_stride) { /* 0. Setup state */ reset_machine(); setup_test_env(test, test_params); /* 1. Render with OpenGL */ glTexCoord2f(0, 0); /* use texcoord (0,0) for all vertices */ piglit_draw_rect(-1, -1, 2, 2); /* 2. Compute expected result */ float expected[4]; expected[3] = -1.0f; compute_tex_combine(0, machine.frag_color, expected); /* 3. Compare rendered result to expected result */ if (!piglit_probe_pixel_rgba(0, 0, expected)) { printf("Single Texture Test %s %d\n", test_name, test); print_test_env(test, test_params); return false; } } return true; }
enum piglit_result piglit_display(void) { int x, y; float green[4] = {0.0, 1.0, 0.0, 0.0}; bool pass = true; piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE); glClearColor(1.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glColor4fv(green); for (y = 0; y < piglit_height; y++) { for (x = 0; x < piglit_width; x++) { piglit_draw_rect(x, y, 1, 1); pass = pass && piglit_probe_pixel_rgba(x, y, green); } } glutSwapBuffers(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { #define N_VECTOR_ITEMS 4 GLboolean pass = GL_TRUE; int count, i, j; float expected[N_VECTOR_ITEMS] = {0}; glClearColor(0.5, 0.5, 0.5, 0.5); glClear(GL_COLOR_BUFFER_BIT); for (count = 1; count <= max_targets; count++) { generate_and_display_drawbuffers(count); } for (count = 1; count <= max_targets; count++) { for (i = 0; i < count; i++) { for (j = 0; j < N_VECTOR_ITEMS; j++) { expected[j] = output_values[(i * N_VECTOR_ITEMS) + j] + clear_value; } pass = pass && piglit_probe_pixel_rgba(16 * i + 8, 16 * (count - 1) + 8, expected); } } glutSwapBuffers(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { int i, j; bool pass = true; glViewport(0, 0, texture_width, texture_height); glClearColor(0.4, 0.4, 0.4, 0.4); glClear(GL_COLOR_BUFFER_BIT); if (swizzle >= 0) { GLint sw[] = { GL_ZERO, GL_ZERO, GL_ZERO, GL_ZERO }; if (comp_select != -1) sw[comp_select] = swizzles[swizzle]; else sw[0] = swizzles[swizzle]; glTexParameteriv(target_for_sampler[sampler], GL_TEXTURE_SWIZZLE_RGBA, sw); } if (stage == FS) glDrawArrays(GL_TRIANGLES, 0, 6); else glDrawArrays(GL_POINTS, 0, texture_width * texture_height); for (j = 1; j < texture_height - 1; j++) for (i = 1; i < texture_width - 1; i++) { float *pe = &expected[4 * (j * texture_width + i)]; pass = piglit_probe_pixel_rgba(i, j, pe) && pass; } piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { static const float white[4] = { 1.0, 1.0, 1.0, 1.0, }; static const float b[] = { 1.0, 1.0, -1.0, 1.0, -1.0, -1.0, 1.0, -1.0 }; GLboolean pass = GL_TRUE; unsigned i; unsigned j; glClear(GL_COLOR_BUFFER_BIT); for (i = 0; i < 4; i++) { glUseProgram(prog[i]); glDrawArrays(GL_QUADS, i * 4, 4); for (j = 0; j < 8; j += 2) { const unsigned k = 8 * i; if (!piglit_probe_pixel_rgba(pos[k + j + 0] + b[j + 0], pos[k + j + 1] + b[j + 1], white)) pass = GL_FALSE; } } glutSwapBuffers(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { bool pass = true; float green[] = {0, 1, 0, 0}; float clear[] = {0.5, 0.5, 0.5, 0.5}; struct { GLfloat x, y; GLfloat r, g, b, a; GLboolean edgeflag; } verts[] = { { 1.5, 1.5, 0.0, 1.0, 0.0, 0.0, GL_TRUE }, { 5.5, 1.5, 0.0, 1.0, 0.0, 0.0, GL_FALSE }, { 5.5, 5.5, 0.0, 1.0, 0.0, 0.0, GL_TRUE }, { 1.5, 5.5, 0.0, 1.0, 0.0, 0.0, GL_FALSE }, }; piglit_ortho_projection(piglit_width, piglit_height, false); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glClearColor(0.5, 0.5, 0.5, 0.5); glClear(GL_COLOR_BUFFER_BIT); glColor4f(0, 1, 0, 0); glVertexPointer(2, GL_FLOAT, sizeof(verts[0]), &verts[0].x); glVertexAttribPointer(color_index, 4, GL_FLOAT, GL_FALSE, sizeof(verts[0]), &verts[0].r); glEdgeFlagPointer(sizeof(verts[0]), &verts[0].edgeflag); glEnableClientState(GL_VERTEX_ARRAY); glEnableVertexAttribArray(color_index); glEnableClientState(GL_EDGE_FLAG_ARRAY); glDrawArrays(GL_POLYGON, 0, 4); pass = piglit_probe_pixel_rgba(3, 1, green) && pass; pass = piglit_probe_pixel_rgba(3, 5, green) && pass; pass = piglit_probe_pixel_rgba(1, 3, clear) && pass; pass = piglit_probe_pixel_rgba(5, 3, clear) && pass; piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
static GLboolean test_instancing(GLuint divisor) { static const GLfloat verts[4][2] = { {-1, -1}, {1, -1}, {1, 1}, {-1, 1} }; glVertexPointer(2, GL_FLOAT, 0, verts); glEnableClientState(GL_VERTEX_ARRAY); glVertexAttribPointer(PosAttrib, 2, GL_FLOAT, GL_FALSE, 0, Positions); glVertexAttribPointer(ColorAttrib, 4, GL_FLOAT, GL_FALSE, 0, Colors); glEnableVertexAttribArray(PosAttrib); glEnableVertexAttribArray(ColorAttrib); glVertexAttribDivisorARB(PosAttrib, 1); /* advance color once every 'n' instances */ glVertexAttribDivisorARB(ColorAttrib, divisor); glClear(GL_COLOR_BUFFER_BIT); glUseProgram(Program); glDrawArraysInstancedARB(GL_POLYGON, 0, 4, PRIMS); glUseProgram(0); { GLint i; GLint pos[4]; for (i = 0; i < PRIMS; i++) { GLuint elem = i / divisor; /* use glRasterPos to determine where to read a sample pixel */ glRasterPos2fv(Positions[i]); glGetIntegerv(GL_CURRENT_RASTER_POSITION, pos); if (!piglit_probe_pixel_rgba(pos[0], pos[1], Colors[elem])) { fprintf(stderr, "%s: instance %d failed to draw correctly\n", TestName, i); fprintf(stderr, "%s: color instance divisor = %u\n", TestName, divisor); glutSwapBuffers(); return GL_FALSE; } } } glDisableClientState(GL_VERTEX_ARRAY); glDisableVertexAttribArray(PosAttrib); glDisableVertexAttribArray(ColorAttrib); glutSwapBuffers(); return GL_TRUE; }
PIGLIT_GL_TEST_CONFIG_END enum piglit_result piglit_display(void) { bool pass = true; float green[] = {0, 1, 0, 0}; float clear[] = {0, 0, 0, 0}; piglit_ortho_projection(piglit_width, piglit_height, false); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glColor4f(0, 1, 0, 0); /* Draw a rectangle, but set the flag to false for the verticals. */ glBegin(GL_QUADS); glEdgeFlag(GL_TRUE); glVertex2f(1.5, 1.5); glEdgeFlag(GL_FALSE); glVertex2f(5.5, 1.5); glEdgeFlag(GL_TRUE); glVertex2f(5.5, 5.5); glEdgeFlag(GL_FALSE); glVertex2f(1.5, 5.5); glEdgeFlag(GL_TRUE); glVertex2f(11.5, 1.5); glEdgeFlag(GL_FALSE); glVertex2f(15.5, 1.5); glEdgeFlag(GL_TRUE); glVertex2f(15.5, 5.5); glEdgeFlag(GL_FALSE); glVertex2f(11.5, 5.5); glEnd(); pass = piglit_probe_pixel_rgba(3, 1, green) && pass; pass = piglit_probe_pixel_rgba(3, 5, green) && pass; pass = piglit_probe_pixel_rgba(1, 3, clear) && pass; pass = piglit_probe_pixel_rgba(5, 3, clear) && pass; pass = piglit_probe_pixel_rgba(13, 1, green) && pass; pass = piglit_probe_pixel_rgba(13, 5, green) && pass; pass = piglit_probe_pixel_rgba(11, 3, clear) && pass; pass = piglit_probe_pixel_rgba(15, 3, clear) && pass; piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
static bool test_linear(int x) { float average[4]; int i; /* For an even framebuffer size we don't sample exactly at the center * of the texture. The centers of the texels are a quarter framebuffer * (25 pixels) to the sides of the center of the framebuffer. We sample * half a pixel off the center of the framebuffer. The lerp factors for * the expected color are thus 0.5 +/- 0.5/25. */ const float offset = 1.0f/(float)texrect_w; const float lfm = 0.5f - offset; const float lfp = 0.5f + offset; /* Increase tolerance a bit for linear filtering. */ for (i = 0; i < 4; i++) piglit_tolerance[i] = linear_tolerance[i]; for (i = 0; i < 4; i++) average[i] = (r[i] *lfm*lfm + g[i] *lfm*lfp + b[i] *lfp*lfm + w[i] *lfp*lfp); return (piglit_probe_pixel_rgba(x, 0, r) && piglit_probe_pixel_rgba(x + texrect_w * 2 - 1, 0, g) && piglit_probe_pixel_rgba(x, texrect_h * 2 - 1, b) && piglit_probe_pixel_rgba(x + texrect_w * 2 - 1, texrect_h * 2 - 1, w) && piglit_probe_pixel_rgba(x + texrect_w, texrect_h, average)); }
static enum piglit_result draw(struct egl_state *state) { EGLSurface *pixmap; EGLint inv; float red[] = { 0.4, 0.0, 0.0, 1.0 }; float purple[] = { 0.5, 0.0, 0.5, 1.0 }; enum piglit_result result = PIGLIT_PASS; if (!eglGetConfigAttrib(state->egl_dpy, state->cfg, EGL_Y_INVERTED_NOK, &inv)) { fprintf(stderr, "eglGetConfigAttrib(EGL_Y_INVERTED_NOK) failed\n"); return PIGLIT_FAIL; } printf("EGL_Y_INVERTED_NOK: %s\n", inv ? "TRUE" : "FALSE"); pixmap = egl_util_create_pixmap(state, 100, 100, pixmap_attribs); if (!eglMakeCurrent(state->egl_dpy, pixmap, pixmap, state->ctx)) { fprintf(stderr, "eglMakeCurrent() failed\n"); piglit_report_result(PIGLIT_FAIL); } /* Clear pixmap to purple */ glClearColor(0.5, 0.0, 0.5, 1.0); glClear(GL_COLOR_BUFFER_BIT); if (!eglMakeCurrent(state->egl_dpy, state->surf, state->surf, state->ctx)) { fprintf(stderr, "eglMakeCurrent() failed\n"); piglit_report_result(PIGLIT_FAIL); } glViewport(0, 0, state->width, state->height); piglit_ortho_projection(state->width, state->height, GL_FALSE); glClearColor(0.4, 0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); glEnable(GL_TEXTURE_2D); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); eglBindTexImage(state->egl_dpy, pixmap, EGL_BACK_BUFFER); piglit_draw_rect_tex(20, 20, 100, 100, 0, 0, 1, 1); if (!piglit_probe_pixel_rgba(10, 10, red) || !piglit_probe_pixel_rgba(50, 10, red) || !piglit_probe_pixel_rgba(10, 50, red) || !piglit_probe_pixel_rgba(50, 50, purple) || !piglit_probe_pixel_rgba(110, 110, purple) || !piglit_probe_pixel_rgba(130, 130, red)) result = PIGLIT_FAIL; eglSwapBuffers(state->egl_dpy, state->surf); return result; }
enum piglit_result piglit_display(void) { GLboolean pass = GL_TRUE; static const float red[] = {1.0, 0.0, 0.0, 1.0}; static const float green[] = {0.0, 1.0, 0.0, 1.0}; static const float blue[] = {0.0, 0.0, 1.0, 1.0}; static const float white[] = {1.0, 1.0, 1.0, 1.0}; GLuint tex; glActiveTexture(GL_TEXTURE1); tex = piglit_rgbw_texture(GL_RGBA, 8, 8, GL_FALSE, GL_FALSE, GL_UNSIGNED_NORMALIZED); glEnable(GL_TEXTURE_2D); glMatrixMode(GL_TEXTURE); glLoadIdentity(); glRotatef(90, 0, 0, 1); piglit_draw_rect(-1, -1, 2, 2); pass = piglit_probe_pixel_rgba(piglit_width * 1 / 4, piglit_height * 1 / 4, blue) && pass; pass = piglit_probe_pixel_rgba(piglit_width * 3 / 4, piglit_height * 1 / 4, red) && pass; pass = piglit_probe_pixel_rgba(piglit_width * 1 / 4, piglit_height * 3 / 4, white) && pass; pass = piglit_probe_pixel_rgba(piglit_width * 3 / 4, piglit_height * 3 / 4, green) && pass; piglit_present_results(); glDeleteTextures(1, &tex); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
static bool probe(int x, int y, int color_index) { float expected[4]; /* mul color by color_scale */ expected[0] = color[color_index][0] * color[color_index][4]; expected[1] = color[color_index][1] * color[color_index][4]; expected[2] = color[color_index][2] * color[color_index][4]; expected[3] = color[color_index][3] * color[color_index][4]; return piglit_probe_pixel_rgba(x, y, expected); }
static bool draw_multi_viewport(void) { bool pass = true; int i, j; const int divX=4, divY=4; GLfloat w = (GLfloat) piglit_width / (GLfloat) divX; GLfloat h = (GLfloat) piglit_height / (GLfloat) divY; GLfloat data[16 * 4 /* 4x4 * (x + y + w + h) */]; int idx; int p; idx = 0; for (i = 0; i < divX; i++) { for (j = 0; j < divY; j++) { data[idx * 4 + 0] = (GLfloat)(i * w); data[idx * 4 + 1] = (GLfloat)(j * h); data[idx * 4 + 2] = w; data[idx * 4 + 3] = h; idx++; } } glViewport(0, 0, piglit_width, piglit_height); /* for glClear() */ glClear(GL_COLOR_BUFFER_BIT); glViewportArrayv(0, 16, data); glDrawArrays(GL_POINTS, 0, 1); pass = piglit_check_gl_error(GL_NO_ERROR) && pass; for (i = 0; i < divX; i++) { for (j = 0; j < divY; j++) { GLfloat expected[4]; expected[0] = 1.0 / (1 + i*4 + j); expected[1] = 0.0; expected[2] = 0.0; expected[3] = 1.0; p = piglit_probe_pixel_rgba(i * w + w/2, j * h + h /2, expected); if (!p) { printf("Wrong color for viewport i,j %d %d\n", i, j); pass = false; } } } piglit_present_results(); return pass; }
static bool DoTest( void ) { int idx = 0; bool pass = true; while(Probes[idx].name) { pass = piglit_probe_pixel_rgba( (int)(Probes[idx].x * piglit_width / 3), (int)(Probes[idx].y * piglit_height / 2), Probes[idx].expected) && pass; idx++; } return pass; }
/** * Test drawing with GLSL shaders and no vertex arrays. * Use a vertex shader with a hard-coded vertex position. */ static GLboolean test_glsl_no_arrays(void) { static const char *noVertexVertShaderText = "varying vec4 colorVar; \n" "void main() \n" "{ \n" " colorVar = vec4(1.0, 1.0, 0.0, 1.0); \n" " gl_Position = vec4(0.0, 0.0, 0.0, 1.0); \n" "} \n"; static const char *fragShaderText = "varying vec4 colorVar; \n" "void main() \n" "{ \n" " gl_FragColor = colorVar; \n" "} \n"; static const GLfloat expected[4] = {1.0, 1.0, 0.0, 1.0}; GLboolean p, pass = GL_TRUE; GLuint vertShader, fragShader, program; vertShader = piglit_compile_shader_text(GL_VERTEX_SHADER, noVertexVertShaderText); fragShader = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fragShaderText); program = piglit_link_simple_program(vertShader, fragShader); glUseProgram(program); glClear(GL_COLOR_BUFFER_BIT); glPointSize(3.0); glDrawArrays(GL_POINTS, 0, 1); glPointSize(1.0); p = piglit_probe_pixel_rgba(piglit_width/2, piglit_height/2, expected); piglit_present_results(); if (!p) { printf("%s: failed when drawing with GLSL and no vertex arrays\n", TestName); pass = GL_FALSE; } glDeleteShader(vertShader); glDeleteProgram(program); return pass; }
enum piglit_result piglit_display(void) { GLboolean pass = GL_TRUE; int i; glClear(GL_COLOR_BUFFER_BIT); glDrawArrays(GL_QUADS, 0, 16); for (i = 0; i < 4; i++) { pass = piglit_probe_pixel_rgba(opos[i*2]+25, opos[i*2+1]+25, &ocol[i*4]) && pass; } glutSwapBuffers(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
GLboolean test() { GLboolean pass = GL_TRUE; unsigned read_clamp; for(read_clamp = 0; read_clamp < 3; ++read_clamp) { unsigned clamped = clamp_enums[read_clamp] == GL_TRUE || (clamp_enums[read_clamp] == GL_FIXED_ONLY_ARB && fixed); unsigned x, y; float* expected; printf("probe_pixel of fbo with read clamp %s (expecting %sclamping)\n", clamp_strings[read_clamp], clamped ? "" : "no "); if (!sanity) glClampColorARB(GL_CLAMP_READ_COLOR_ARB, clamp_enums[read_clamp]); expected = clamped ? clamped_pixels : fixed_snorm ? signed_clamped_pixels : fixed ? clamped_pixels : pixels; for(y = 0; y < 2; ++y) for(x = 0; x < 2; ++x) { GLboolean cpass = piglit_probe_pixel_rgba(x, y, expected + 8 * y + 4 * x); GLboolean opass = cpass; if(!cpass && clamped && ati_driver) { printf("ATI driver known bug: 1x1 glReadPixels ignores the read clamp!\n"); opass = GL_TRUE; } if(!cpass && nvidia_driver && clamped) { printf("nVidia driver known *** MAJOR BUG ***: they ignore the read clamp!\n"); opass = GL_TRUE; } pass = opass && pass; } } if (!sanity) glClampColorARB(GL_CLAMP_READ_COLOR_ARB, GL_FALSE); return pass; }
enum piglit_result piglit_display(void) { GLboolean pass = GL_TRUE; GLfloat expected[4] = {0.5, 0.0, 0.0, 1.0}; glClear(GL_COLOR_BUFFER_BIT); glPointSize(10); glBegin(GL_POINTS); glVertex2f(0.5, 0.5); glEnd(); pass = piglit_probe_pixel_rgba(0, 0, expected); glutSwapBuffers(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { static const GLfloat expColor[4] = {0, 1, 0, 1}; GLint vs; GLint prog; GLint stat; enum piglit_result result; vs = glCreateShader(GL_VERTEX_SHADER); glShaderSource(vs, 1, &vertShaderText, NULL); glCompileShader(vs); glGetShaderiv(vs, GL_COMPILE_STATUS, &stat); if (!stat) { printf("glsl-novertexdata: error compiling vertex shader!\n"); exit(1); } prog = glCreateProgram(); glAttachShader(prog, vs); glLinkProgram(prog); glUseProgram(prog); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); glPointSize(20.0); glDrawArrays(GL_POINTS, 0, 1); result = piglit_probe_pixel_rgba(piglit_width /2, piglit_height / 2, expColor) ? PIGLIT_PASS : PIGLIT_FAIL; glutSwapBuffers(); return result; }
GLboolean test() { GLboolean pass = GL_TRUE; unsigned vert_clamp, frag_clamp; for (vert_clamp = 0; vert_clamp < (sanity ? 1 : 3); ++vert_clamp) { for (frag_clamp = sanity ? 1 : 0; frag_clamp < (sanity ? 2 : 3); ++frag_clamp) { GLboolean cpass; GLboolean opass; float* expected; printf("glClear of fbo with vertex clamp %s and fragment clamp %s (expecting no clamping)\n", clamp_strings[vert_clamp], clamp_strings[frag_clamp]); if (!sanity) { glClampColorARB(GL_CLAMP_VERTEX_COLOR_ARB, clamp_enums[vert_clamp]); glClampColorARB(GL_CLAMP_FRAGMENT_COLOR_ARB, clamp_enums[frag_clamp]); } glClearColor(pixels[0], pixels[1], pixels[2], pixels[3]); glClear(GL_COLOR_BUFFER_BIT); expected = fixed ? (fixed_snorm ? signed_clamped_pixels : clamped_pixels) : pixels; cpass = piglit_probe_pixel_rgba(0, 0, expected); opass = cpass; if(!cpass && ati_driver && format == GL_RGBA16F_ARB) { printf("ATI driver known *** MAJOR BUG ***: they always clamp clears for fp16 targets!\n"); opass = GL_TRUE; } pass = opass && pass; } } return pass; }
static bool DoTest(void) { int mask; bool pass = true; for(mask = 1; mask < 16; ++mask) { float expected[4]; int i; for(i = 0; i < 4; ++i) { if (mask & (1 << i)) expected[i] = LitExpected[i]; else expected[i] = 0.8; } pass = piglit_probe_pixel_rgba(piglit_width * (2*(mask%4)+1)/8, piglit_height * (2*(mask/4)+1)/8, expected) && pass; } return pass; }
enum piglit_result draw(Display *dpy) { GLboolean pass = GL_TRUE; float green[] = {0.0, 1.0, 0.0, 0.0}; GLXContext ctx; ctx = piglit_get_glx_context(dpy, visinfo); glXMakeCurrent(dpy, win, ctx); /* Clear background to gray */ glClearColor(0.0, 1.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glXSwapBuffers(dpy, win); glClearColor(1.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glXSwapBuffers(dpy, win); pass = piglit_probe_pixel_rgba(0, 0, green); glXSwapBuffers(dpy, win); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { GLboolean pass = GL_TRUE; /* result = mix(args1, args2, args3) */ static const float args1[4] = {1.0, 0.0, 2.0, 0.0}; static const float args2[4] = {0.0, 1.0, 0.0, 2.0}; static const float args3[4] = {0.5, 0.5, 0.75, 0.25}; static const float gray[] = {0.5, 0.5, 0.5, 0.5}; glClearColor(0.0, 1.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glUniform4fv(args1_location, 1, args1); glUniform4fv(args2_location, 1, args2); glUniform4fv(args3_location, 1, args3); piglit_draw_rect(10, 10, 10, 10); pass &= piglit_probe_pixel_rgba(15, 15, gray); glutSwapBuffers(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
PIGLIT_GL_TEST_CONFIG_END enum piglit_result piglit_display(void) { GLboolean pass = GL_TRUE; GLuint tex, fb; GLenum status; float fbo_white[] = {0.0, 0.0, 0.0, 1.0}; float fbo_black[] = {0.0, 0.0, 0.0, 0.0}; float fbo_gray[] = {0.0, 0.0, 0.0, 0.5}; float white[] = {1.0, 1.0, 1.0, 1.0}; float black[] = {0.0, 0.0, 0.0, 0.0}; float gray[] = {0.5, 0.5, 0.5, 0.5}; int fbo_width = 64; int fbo_height = 64; glGenFramebuffersEXT(1, &fb); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb); glViewport(0, 0, fbo_width, fbo_height); glGenTextures(1, &tex); glBindTexture(GL_TEXTURE_2D, tex); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, fbo_width, fbo_height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, NULL); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, tex, 0); assert(glGetError() == 0); status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); if (status != GL_FRAMEBUFFER_COMPLETE_EXT) { fprintf(stderr, "fbo incomplete (status = 0x%04x)\n", status); piglit_report_result(PIGLIT_SKIP); } /* Clear to no alpha. */ glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glColor4f(0.0, 0.0, 0.0, 0.0); piglit_draw_rect(-1.0, -1.0, 0.5, 2.0); glColor4f(0.0, 0.0, 0.0, 1.0); piglit_draw_rect(-0.5, -1.0, 0.5, 2.0); glColor4f(0.0, 0.0, 0.0, 0.5); piglit_draw_rect(0.0, -1.0, 0.5, 2.0); glEnable(GL_BLEND); glBlendFunc(GL_DST_ALPHA, GL_ZERO); glColor4f(0.0, 0.0, 0.0, 1.0); piglit_draw_rect(0.0, -1.0, 0.5, 2.0); glDisable(GL_BLEND); glColor4f(0.0, 0.0, 0.0, 0.5); piglit_draw_rect(0.5, -1.0, 0.5, 2.0); glEnable(GL_BLEND); glBlendFunc(GL_ZERO, GL_SRC_ALPHA); glColor4f(0.0, 0.0, 0.0, 1.0); piglit_draw_rect(0.5, -1.0, 0.5, 2.0); glDisable(GL_BLEND); printf("Testing FBO result.\n"); pass = piglit_probe_pixel_rgba(fbo_width * 1 / 8, 0, fbo_black) && pass; pass = piglit_probe_pixel_rgba(fbo_width * 3 / 8, 0, fbo_white) && pass; pass = piglit_probe_pixel_rgba(fbo_width * 5 / 8, 0, fbo_gray) && pass; pass = piglit_probe_pixel_rgba(fbo_width * 7 / 8, 0, fbo_gray) && pass; /* Draw the two textures to halves of the window. */ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, piglit_winsys_fbo); glViewport(0, 0, piglit_width, piglit_height); glEnable(GL_TEXTURE_2D); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_ALPHA); glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE); glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE); glBindTexture(GL_TEXTURE_2D, tex); piglit_draw_rect_tex(-1, -1, 2, 2, 0, 0, 1, 1); glDisable(GL_TEXTURE_2D); glDeleteTextures(1, &tex); glDeleteFramebuffersEXT(1, &fb); printf("Testing window result.\n"); pass = piglit_probe_pixel_rgba(piglit_width * 1 / 8, 0, black) && pass; pass = piglit_probe_pixel_rgba(piglit_width * 3 / 8, 0, white) && pass; pass = piglit_probe_pixel_rgba(piglit_width * 5 / 8, 0, gray) && pass; pass = piglit_probe_pixel_rgba(piglit_width * 7 / 8, 0, gray) && pass; piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }