enum piglit_result piglit_display(void) { bool pass = true; GLfloat *v; int i; GLuint q, num_prims; glClear(GL_COLOR_BUFFER_BIT); glGenQueries(1, &q); glBeginQuery(GL_PRIMITIVES_GENERATED_EXT, q); glBeginTransformFeedback(GL_POINTS); glBindBuffer(GL_ARRAY_BUFFER, vert_buf); glVertexPointer(3, GL_FLOAT, 0, 0); glEnable(GL_VERTEX_ARRAY); glDrawArrays(GL_POINTS, 0, 3); glEndTransformFeedback(); glEndQuery(GL_PRIMITIVES_GENERATED); glGetQueryObjectuiv(q, GL_QUERY_RESULT, &num_prims); glDeleteQueries(1, &q); printf("%u primitives generated:\n", num_prims); if (num_prims != NUM_VERTS) { printf("Incorrect number of prims generated.\n"); printf("Found %u, expected %u\n", num_prims, NUM_VERTS); pass = false; } glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER_EXT, xfb_buf); v = glMapBuffer(GL_TRANSFORM_FEEDBACK_BUFFER_EXT, GL_READ_ONLY); for (i = 0; i < num_prims; i++) { printf("vertex %2d: pos %5.2g, %5.2g, %5.2g, %5.2g " "color %5.2g, %5.2g, %5.2g, %5.2g\n", i, v[i*8+0], v[i*8+1], v[i*8+2], v[i*8+3], v[i*8+4], v[i*8+5], v[i*8+6], v[i*8+7]); /* spot-check results */ if (!equal(v[i*8+1], 0.1)) { printf("Incorrect Y coord for point %d: %f\n", i, v[i*8+1]); pass = false; } if (!equal(v[i*8+4], 0.9)) { printf("Incorrect red value for point %d: %f\n", i, v[i*8+4]); pass = false; } } glUnmapBuffer(GL_TRANSFORM_FEEDBACK_BUFFER_EXT); piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display() { enum piglit_result result = test->run() ? PIGLIT_PASS : PIGLIT_FAIL; piglit_present_results(); return result; }
enum piglit_result piglit_display(void) { enum piglit_result ret = do_query(queries, ARRAY_SIZE(queries)); #ifdef DISPLAY piglit_present_results(); #endif return ret; }
PIGLIT_GL_TEST_CONFIG_END enum piglit_result piglit_display(void) { static const char *vs_source = "#version 140\n" "in vec4 piglit_vertex;\n" "void main()\n" "{\n" " gl_Position = piglit_vertex;\n" "}\n"; static const char *fs_source = "#version 140\n" "uniform samplerBuffer s;\n" "void main()\n" "{\n" " gl_FragColor = texelFetch(s, 0);\n" "}\n"; bool pass = true; GLuint tex, bo; GLuint prog; float green[] = {0, 1, 0, 0}; float blue[] = {0, 0, 1, 0}; uint8_t g_rgba8[] = {0x00, 0xff, 0x00, 0x00}; uint8_t b_rgba8[] = {0x00, 0x00, 0xff, 0x00}; prog = piglit_build_simple_program(vs_source, fs_source); glUseProgram(prog); glGenBuffers(1, &bo); glBindBuffer(GL_TEXTURE_BUFFER, bo); glBufferData(GL_TEXTURE_BUFFER, sizeof(g_rgba8), g_rgba8, GL_STREAM_DRAW); glGenTextures(1, &tex); glBindTexture(GL_TEXTURE_BUFFER, tex); glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA8, bo); piglit_draw_rect(-1, -1, 1, 2); glBufferData(GL_TEXTURE_BUFFER, sizeof(b_rgba8), b_rgba8, GL_STREAM_DRAW); piglit_draw_rect(0, -1, 1, 2); pass = pass && piglit_probe_rect_rgba(0, 0, piglit_width / 2, piglit_height, green); pass = pass && piglit_probe_rect_rgba(piglit_width / 2, 0, piglit_width / 2, piglit_height, blue); piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { bool pass = true; GLint max_vs, max_fs, max_combined; piglit_require_extension("GL_ARB_uniform_buffer_object"); glGetIntegerv(GL_MAX_VERTEX_UNIFORM_BLOCKS, &max_vs); glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_BLOCKS, &max_fs); glGetIntegerv(GL_MAX_COMBINED_UNIFORM_BLOCKS, &max_combined); printf("Max VS uniform blocks: %d\n", max_vs); printf("Max FS uniform blocks: %d\n", max_fs); printf("Max combined uniform blocks: %d\n", max_combined); glClearColor(0.5, 0.5, 0.5, 0.5); glClear(GL_COLOR_BUFFER_BIT); pass = fail_link_test("vs", max_vs + 1, "vs", 0) && pass; pass = fail_link_test("fs", 0, "fs", max_fs + 1) && pass; if (max_vs + max_fs > max_combined) { pass = fail_link_test("vs", max_vs, "fs", max_combined + 1 - max_vs) && pass; pass = fail_link_test("shared", max_vs, "shared", max_combined + 1 - max_vs) && pass; } pass = pass_link_test(0, "vs", max_vs, "vs", 0) && pass; pass = pass_link_test(1, "fs", 0, "fs", max_fs) && pass; pass = pass_link_test(2, "vs", max_vs, "fs", MIN2(max_fs, max_combined - max_vs)) && pass; pass = pass_link_test(3, "shared", max_vs, "shared", MIN2(max_fs, max_combined - max_vs)) && pass; piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
PIGLIT_GL_TEST_CONFIG_END enum piglit_result piglit_display(void) { GLboolean pass = GL_TRUE; static float red[] = {1.0, 0.0, 0.0, 0.0}; static float green[] = {0.0, 1.0, 0.0, 0.0}; static float blue[] = {0.0, 0.0, 1.0, 0.0}; float *pixels; GLuint pbo, tex; glClearColor(0.5, 0.5, 0.5, 0.0); glClear(GL_COLOR_BUFFER_BIT); glGenBuffersARB(1, &pbo); glBindBufferARB(GL_PIXEL_UNPACK_BUFFER, pbo); glBufferDataARB(GL_PIXEL_UNPACK_BUFFER, 4 * 4 * sizeof(float), NULL, GL_STREAM_DRAW_ARB); pixels = glMapBufferARB(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY_ARB); memcpy(pixels + 0, red, sizeof(red)); memcpy(pixels + 4, green, sizeof(green)); memcpy(pixels + 8, blue, sizeof(blue)); memcpy(pixels + 12, red, sizeof(red)); glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER); 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_RGBA, 2, 2, 0, GL_RGBA, GL_FLOAT, 0); glBindBufferARB(GL_PIXEL_UNPACK_BUFFER, 0); glDeleteBuffersARB(1, &pbo); glEnable(GL_TEXTURE_2D); glBegin(GL_TRIANGLE_FAN); glTexCoord2f(0.0, 0.0); glVertex2f(10, 10); glTexCoord2f(1.0, 0.0); glVertex2f(20, 10); glTexCoord2f(1.0, 1.0); glVertex2f(20, 20); glTexCoord2f(0.0, 1.0); glVertex2f(10, 20); glEnd(); glDeleteTextures(1, &tex); pass &= piglit_probe_pixel_rgb(12, 12, red); pass &= piglit_probe_pixel_rgb(18, 12, green); pass &= piglit_probe_pixel_rgb(12, 18, blue); pass &= piglit_probe_pixel_rgb(18, 18, red); piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
PIGLIT_GL_TEST_CONFIG_END enum piglit_result piglit_display(void) { GLboolean pass = GL_TRUE; static float red[] = {1.0, 0.0, 0.0, 0.0}; static float green[] = {0.0, 1.0, 0.0, 0.0}; static float blue[] = {0.0, 0.0, 1.0, 0.0}; piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE); glClearColor(0.5, 0.0, 0.0, 0.0); glColor4fv(red); /* Make a list containing a clear and a rectangle. It'll draw * colors we don't expect to see, due to COMPILE_AND_EXECUTE. */ glNewList(1, GL_COMPILE_AND_EXECUTE); /* Even though we don't use depth, GL_DEPTH_BUFFER_BIT is what * triggered the metaops clear path which messed up the display list. */ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glBegin(GL_QUADS); glVertex2f(10, 10); glVertex2f(20, 10); glVertex2f(20, 20); glVertex2f(10, 20); glEnd(); glEndList(); /* Now, set up our expected colors, translate the dlist's rectangle * over a little, and do the draw we actually expect to see. */ glClearColor(0.0, 1.0, 0.0, 0.0); glColor4fv(blue); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(20, 0, 0); glCallList(1); pass &= piglit_probe_rect_rgb(0, 0, piglit_width, 10, green); pass &= piglit_probe_rect_rgb(0, 10, 30, 10, green); pass &= piglit_probe_rect_rgb(30, 10, 10, 10, blue); pass &= piglit_probe_rect_rgb(40, 10, piglit_width-40, 10, green); pass &= piglit_probe_rect_rgb(0, 20, piglit_width, piglit_height - 20, green); piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { int x0 = piglit_width * 1 / 4; int x1 = piglit_width * 3 / 4; int y0 = piglit_height * 1 / 4; int y1 = piglit_height * 3 / 4; GLboolean pass = GL_TRUE; glClear(GL_COLOR_BUFFER_BIT); glFrontFace(GL_CCW); /* the default winding */ glBegin(GL_QUADS); /* counter-clockwise / front-facing */ glNormal3f(0, 0, 1); glVertex2f(-1.0, -1.0); glVertex2f( 0.0, -1.0); glVertex2f( 0.0, 0.0); glVertex2f(-1.0, 0.0); /* clockwise / back-facing */ glNormal3f(0, 0, -1); glVertex2f( 0.0, -1.0); glVertex2f( 0.0, 0.0); glVertex2f( 1.0, 0.0); glVertex2f( 1.0, -1.0); glEnd(); glFrontFace(GL_CW); /* reverse winding */ glBegin(GL_QUADS); /* counter-clockwise / back-facing */ glNormal3f(0, 0, -1); glVertex2f(-1.0, 0.0); glVertex2f( 0.0, 0.0); glVertex2f( 0.0, 1.0); glVertex2f(-1.0, 1.0); /* clockwise / front-facing */ glNormal3f(0, 0, 1); glVertex2f( 0.0, 0.0); glVertex2f( 0.0, 1.0); glVertex2f( 1.0, 1.0); glVertex2f( 1.0, 0.0); glEnd(); pass = piglit_probe_pixel_rgb(x0, y0, green) && pass; pass = piglit_probe_pixel_rgb(x1, y0, blue) && pass; pass = piglit_probe_pixel_rgb(x0, y1, blue) && pass; pass = piglit_probe_pixel_rgb(x1, y1, green) && pass; piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { GLuint vs, fs; bool pass = true; GLuint prog; float green[] = {0.0, 1.0, 0.0, 0.0}; GLint status; /* Initial buffer clear. */ glClearColor(1.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_source); fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_source); prog = piglit_link_simple_program(vs, fs); if (!vs || !fs || !prog) piglit_report_result(PIGLIT_FAIL); piglit_DeleteShader(vs); piglit_DeleteShader(fs); piglit_UseProgram(prog); piglit_DeleteProgram(prog); /* Try to blow out the refcount */ piglit_DeleteProgram(prog); piglit_DeleteProgram(prog); piglit_DeleteProgram(prog); /* Sanity check: deleting didn't already unbind our shader program. */ piglit_draw_rect(-1, -1, 2, 2); pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, green) && pass; /* The program should still report being deleted. */ piglit_GetProgramiv(prog, GL_DELETE_STATUS, &status); if (!piglit_check_gl_error(0)) piglit_report_result(PIGLIT_FAIL); if (status != GL_TRUE) { fprintf(stderr, "GL_DELETE_STATUS after a clear reported non-true %d\n", status); pass = false; } /* Now, disable the program and it should be finally deleted. */ piglit_UseProgram(0); piglit_GetProgramiv(prog, GL_DELETE_STATUS, &status); pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass; piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { int x, y; bool pass = true; float expected[64 * 64 * 4]; glClearColor(0.0, 1.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); for (x = 0; x < 8; x++) { for (y = 0; y < 8; y++) { piglit_Uniform2i(coord1_location, x * 9, y * 9); piglit_Uniform2i(coord2_location, x * 9, y * 9); piglit_draw_rect(-1.0 + 0.25 * x, -1.0 + 0.25 * y, 0.25, 0.25); } } for (x = 0; x < 64; x++) { for (y = 0; y < 64; y++) { int sx = x % 8; int sy = y % 8; int dx = fabs(sx - x / 8); int dy = fabs(sy - y / 8); float pixel[4]; if (dx == 0 && dy == 0) { pixel[0] = 0.0; pixel[1] = 1.0; pixel[2] = 0.0; pixel[3] = 0.0; } else { int i; pixel[0] = 0.0; pixel[1] = 0.0; pixel[2] = 0.0; pixel[3] = 0.0; for (i = 0; i < 10; i += (dx + dy)) pixel[2] += 0.1; } memcpy(expected + (y * 64 + x) * 4, pixel, 4 * 4); } } pass = piglit_probe_image_rgba(0, 0, 64, 64, expected); piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { bool pass = true; const float clearColor[3] = { 1, 1, 0 }; /* Clear Defualt Framebuffer */ glBindFramebuffer(GL_FRAMEBUFFER, piglit_winsys_fbo); glClearColor(1,1,0,1); glClear(GL_COLOR_BUFFER_BIT); /* Clear texture[0] with glClear() */ glBindFramebuffer(GL_FRAMEBUFFER, fbo[0]); glClearColor(clearColor[0], clearColor[1], clearColor[2], 1); glClear(GL_COLOR_BUFFER_BIT); /* Clear texture[1] with glClearBuffer() */ glBindFramebuffer(GL_FRAMEBUFFER, fbo[1]); glClearBufferfv(GL_COLOR, 0, clearColor); /* Display glClear texture */ if(!display_layered_texture(0, 0, piglit_width/2, piglit_height, piglit_width, piglit_height, GL_TEXTURE_2D_ARRAY, texture[0], layers)) { printf("Failed to display layered texture for glClear\n"); pass = false; } /* Display glClearBuffer texture */ if(!display_layered_texture(piglit_width/2, 0, piglit_width/2, piglit_height, piglit_width, piglit_height, GL_TEXTURE_2D_ARRAY, texture[1], layers)) { printf("Failed to display layered texture for glClearBuffer\n"); pass = false; } /* Check for passing conditions for glClear*/ if(!piglit_probe_rect_rgb(0, 0, piglit_width/2, piglit_height, clearColor)) { printf("Incorrect probe value for glClear test.\n"); pass = false; } /* Check for passing conditions for glClearBuffer*/ if(!piglit_probe_rect_rgb(piglit_width/2, 0, piglit_width/2, piglit_height, clearColor)) { printf("Incorrect probe value for glClearBuffer test.\n"); pass = false; } if(!piglit_check_gl_error(GL_NO_ERROR)) pass = false; piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { GLboolean pass = GL_TRUE; int x, y; GLuint fb, tex; /* Draw the shader to the fbo. */ fb = create_fbo(WIDTH, HEIGHT, &tex); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb); glViewport(0, 0, WIDTH, HEIGHT); glClearColor(1.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glUseProgram(prog); piglit_draw_rect(-1, -1, 2, 2); /* Draw the FBO to the screen. */ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, piglit_winsys_fbo); glViewport(0, 0, piglit_width, piglit_height); glClearColor(0.0, 0.0, 1.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glBindTexture(GL_TEXTURE_2D, tex); glEnable(GL_TEXTURE_2D); glUseProgram(0); piglit_draw_rect_tex(-1, -1, 2, 2, 0, 0, 1, 1); glDisable(GL_TEXTURE_2D); glDeleteTextures(1, &tex); glDeleteFramebuffersEXT(1, &fb); assert(glGetError() == 0); for (y = 0; y < piglit_height; y++) { for (x = 0; x < piglit_width; x++) { float color[3]; color[0] = x / 256.0; color[1] = y / 256.0; color[2] = 0; pass &= piglit_probe_pixel_rgb(x, y, color); if (!pass) break; } } piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { bool pass = true; float red[4] = {1.0, 0.0, 0.0, 0.0}; float green[4] = {0.0, 1.0, 0.0, 0.0}; GLuint q, texture; glClearColor(0.5, 0.5, 0.5, 0.5); glClear(GL_COLOR_BUFFER_BIT); /* Draw bottom half of window to green. */ glColor4fv(green); piglit_draw_rect(-1, -1, 2, 1); glColor4f(1, 1, 1, 1); /* Set up a red texture. */ glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); fill_tex(0, piglit_width, piglit_height / 2, red); glGenQueries(1, &q); /* Generate query fail. */ glBeginQuery(GL_SAMPLES_PASSED, q); glEndQuery(GL_SAMPLES_PASSED); /* This should not be affected by conditional rendering. */ glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV); glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, piglit_width, piglit_height / 2, 0); glEndConditionalRenderNV(); /* Draw the texture. */ glEnable(GL_TEXTURE_2D); piglit_draw_rect_tex(-1, 0, 2, 1, 0, 0, 1, 1); glDisable(GL_TEXTURE_2D); pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, green); piglit_present_results(); glDeleteQueries(1, &q); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { static const float black[4] = { 0.0f, 0.0f, 0.0f, 1.0f }; bool pass = true; glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo); glViewport(0, 0, TEX_WIDTH, TEX_HEIGHT); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClearDepth(0.0f); glClearStencil(0); glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT); glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo_copy); /* This blit is there on purpose to trigger a bug in stencil decompress * on Radeon. The blit destination is not used. */ glBlitFramebuffer(0, 0, TEX_WIDTH, TEX_WIDTH, 0, 0, TEX_WIDTH, TEX_WIDTH, GL_STENCIL_BUFFER_BIT, GL_NEAREST); glBindFramebuffer(GL_FRAMEBUFFER, fbo); glEnable(GL_STENCIL_TEST); glStencilMask(255); glStencilFunc(GL_LEQUAL, 1, 255); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); glColor4f(1.0, 1.0, 1.0, 1.0); glBegin(GL_TRIANGLE_FAN); glVertex3f( 0.0174f, -0.00413f, 1.0f); glVertex3f(-1.0f, -1.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); glVertex3f(-1.0f, -1.0f, -1.0f); glEnd(); glDisable(GL_STENCIL_TEST); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, piglit_winsys_fbo); glClearColor(1.0, 0.0, 1.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo); glBlitFramebuffer(0, 0, TEX_WIDTH, TEX_HEIGHT, 0, 0, TEX_WIDTH, TEX_HEIGHT, GL_COLOR_BUFFER_BIT, GL_NEAREST); glBindFramebuffer(GL_READ_FRAMEBUFFER, piglit_winsys_fbo); pass = piglit_probe_rect_rgb(0, 0, TEX_WIDTH, TEX_HEIGHT, black) && pass; piglit_present_results(); 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 green[] = {0, 1, 0, 0}; glGenTextures(1, &tex); glBindTexture(GL_TEXTURE_2D, tex); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, piglit_width, piglit_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glGenFramebuffersEXT(1, &fb); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb); 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); } glClearColor(1.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_NEVER); glColor4fv(green); piglit_draw_rect(0, 0, piglit_width, piglit_height); pass = pass && piglit_probe_rect_rgb(0, 0, piglit_width, piglit_height, green); glDisable(GL_DEPTH_TEST); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, piglit_winsys_fbo); glEnable(GL_TEXTURE_2D); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); piglit_draw_rect_tex(0, 0, piglit_width, piglit_height, 0, 0, 1, 1); glDisable(GL_TEXTURE_2D); piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
PIGLIT_GL_TEST_CONFIG_END static bool run_test(bool scissor_clear) { GLuint query; GLint result = -1; piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE); glClearColor(0.0, 1.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glGenQueries(1, &query); glBeginQuery(GL_SAMPLES_PASSED, query); /* Render 64 pixels. This should affect the query */ piglit_draw_rect(0, 0, 8, 8); /* Clear the framebuffer. This shouldn't affect the query */ glClearColor(0.0, 0.0, 1.0, 0.0); if (scissor_clear) { glScissor(0, 0, piglit_width / 2, piglit_height / 2); glEnable(GL_SCISSOR_TEST); } glClear(GL_COLOR_BUFFER_BIT); if (scissor_clear) { glDisable(GL_SCISSOR_TEST); } /* Render another 64 pixels. This should continue adding to * the query */ piglit_draw_rect(4, 0, 8, 8); glEndQuery(GL_SAMPLES_PASSED); glGetQueryObjectiv(query, GL_QUERY_RESULT, &result); glDeleteQueries(1, &query); piglit_present_results(); if (result != 128) { printf("Failure: \n"); printf(" Occlusion query resulted in %d samples " "(expected 128)\n", result); printf(" Scissor enabled? %s\n", scissor_clear ? "yes" : "no"); return false; } else { return true; } }
enum piglit_result piglit_display(void) { bool pass = true; GLint w = pattern_width, h = pattern_height; GLfloat *color_buffer = NULL; test->draw_to_default_framebuffer(); /* Read color buffer */ glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); color_buffer = (GLfloat *) malloc(w * h * 4 * sizeof(float)); glReadPixels(0, 0, w, h, GL_RGBA, GL_FLOAT, color_buffer); /* Draw the test pattern in to test_fbo with num_samples = 0. This * is to verify if glRenderbufferStorageMultisample() with zero sample * count turns off MSAA. */ test->test_fbo.set_samples(0); test->draw_test_image(&test->test_fbo); /* Compare rendered scene with color_buffer */ glBindFramebuffer(GL_READ_FRAMEBUFFER, test->test_fbo.handle); pass = piglit_probe_image_rgba(0, 0, w, h, color_buffer) && pass; /* Switch ON MSAA in this FBO by passing num_samples > 0 */ test->test_fbo.set_samples(num_samples); /* Draw test image in multisample FBO */ test->draw_test_image(&test->test_fbo); /* Draw a reference image for MSAA */ test->draw_reference_image(); /* Measure the accuracy of MSAA in multisample FBO by comparing the * test image to reference image. This varifies if MSAA is actually * switched on. */ pass = test->measure_accuracy() && pass; /* Switch OFF MSAA again in this FBO */ test->test_fbo.set_samples(0); test->draw_test_image(&test->test_fbo); /* Compare rendered scene with color_buffer */ glBindFramebuffer(GL_READ_FRAMEBUFFER, test->test_fbo.handle); pass = piglit_probe_image_rgba(0, 0, w, h, color_buffer) && pass; if (!piglit_automatic) piglit_present_results(); return (pass ? PIGLIT_PASS : PIGLIT_FAIL); }
enum piglit_result piglit_display(void) { #define NUM_QUERIES 5 GLuint queries[NUM_QUERIES], available; bool test_pass = true; GLint result; int i; piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE); glClearColor(1.0, 0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glGenQueries(NUM_QUERIES, queries); glColor4f(0.0f, 1.0f, 0.0f, 1.0f); /* Queue up a bunch of drawing with several queries. */ for (i = 0; i < NUM_QUERIES - 1; i++) { glBeginQuery(GL_SAMPLES_PASSED, queries[i]); draw_some_things((double)i / (NUM_QUERIES - 1)); glEndQuery(GL_SAMPLES_PASSED); } /* Now fire off a query with no drawing. */ glBeginQuery(GL_SAMPLES_PASSED, queries[NUM_QUERIES - 1]); glEndQuery(GL_SAMPLES_PASSED); /* Get the result for the final query. */ glGetQueryObjectiv(queries[NUM_QUERIES - 1], GL_QUERY_RESULT, &result); /* At this point, the results of all the previous queries * should be available. */ for (i = 0; i < NUM_QUERIES - 1; i++) { glGetQueryObjectuiv(queries[i], GL_QUERY_RESULT_AVAILABLE, &available); if (available != 1) { printf("Query #%d result not available (expected in-order processing)\n", i); test_pass = false; } } glDeleteQueries(NUM_QUERIES, queries); piglit_present_results(); return test_pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { int succ; DoFrame(); succ = DoTest(); piglit_present_results(); return succ ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { GLboolean pass = GL_TRUE; int i; GLenum funcs[] = { GL_NEVER, GL_LESS, GL_EQUAL, GL_LEQUAL, GL_GREATER, GL_NOTEQUAL, GL_GEQUAL, GL_ALWAYS, }; const float green[4] = {0, 1, 0, 0}; const float blue[4] = {0, 0, 1, 0}; piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE); /* Clear gray. */ glClearColor(0.5, 0.5, 0.5, 0.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glColor4f(0.0, 1.0, 0.0, 0.0); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_ALWAYS); for (i = 0; i < ARRAY_SIZE(funcs); i++) { draw_rect_depth(10, 10 + 20 * i, 10, 10, 0.0); draw_rect_depth(30, 10 + 20 * i, 10, 10, 0.0); draw_rect_depth(50, 10 + 20 * i, 10, 10, 0.0); } glColor4f(0.0, 0.0, 1.0, 0.0); for (i = 0; i < ARRAY_SIZE(funcs); i++) { glDepthFunc(funcs[i]); draw_rect_depth(10, 10 + 20 * i, 10, 10, 0.5); draw_rect_depth(30, 10 + 20 * i, 10, 10, 0.0); draw_rect_depth(50, 10 + 20 * i, 10, 10, -0.5); } for (i = 0; i < ARRAY_SIZE(funcs); i++) { glDepthFunc(funcs[i]); pass = pass && piglit_probe_pixel_rgb(15, 15 + 20 * i, i & 1 ? blue : green); pass = pass && piglit_probe_pixel_rgb(35, 15 + 20 * i, i & 2 ? blue : green); pass = pass && piglit_probe_pixel_rgb(55, 15 + 20 * i, i & 4 ? blue : green); } piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { bool pass; DoFrame(); pass = DoTest(); piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { bool pass = true; float green[] = {0.0, 1.0, 0.0, 0.0}; float vertex_data[] = { /* quad position */ -1.0, -1.0, 0.0, 1.0, 1.0, -1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, -1.0, 1.0, 0.0, 1.0, }; uint32_t index_data[] = { 0, 1, 2, 3 }; uintptr_t index_offset = sizeof(vertex_data); GLuint prog; glClearColor(1.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); /* Use a vertex shader. Otherwise mesa turns our immediate * color data into a uniform in the fixed function vertex * shader. */ prog = piglit_build_simple_program(vs_source, NULL); glUseProgram(prog); glGenBuffersARB(1, &vbo); glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo); glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, vbo); glBufferDataARB(GL_ARRAY_BUFFER_ARB, index_offset + sizeof(index_data), NULL, GL_DYNAMIC_DRAW); glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, sizeof(vertex_data), vertex_data); glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, index_offset, sizeof(index_data), index_data); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(4, GL_FLOAT, 0, (void *)0); glColor4f(0.0, 1.0, 0.0, 0.0); glDrawElements(GL_TRIANGLE_FAN, 4, GL_UNSIGNED_INT, (void *)index_offset); pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, green); piglit_present_results(); glDisableClientState(GL_VERTEX_ARRAY); glDeleteBuffersARB(1, &vbo); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { glClear(GL_COLOR_BUFFER_BIT); /* This shouldn't crash, but the result is undefined unless * the context was created with robust buffer access. */ draw_rect_core(-1, -1, 1, 1); piglit_present_results(); return PIGLIT_PASS; }
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; }
enum piglit_result piglit_display(void) { piglit_draw_rect(-0.01, -0.01, 0.02, 0.02); bool pass = piglit_probe_pixel_rgb(piglit_width / 2, piglit_height / 2, green_with_a_smitch_of_red); piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
static GLboolean framebuffer_srgb_non_fbo(void) { GLboolean pass; glViewport(0, 0, piglit_width, piglit_height); piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE); pass = test_srgb(); piglit_present_results(); return pass; }
enum piglit_result piglit_display(void) { GLint input_index = glGetAttribLocation(prog, "input_uint"); GLuint *readback; GLuint buffer[BUFFER_SIZE]; GLuint expected[BUFFER_SIZE]; int i; GLboolean pass = GL_TRUE; piglit_UseProgram(prog); glBindBuffer(GL_ARRAY_BUFFER, 0); glVertexAttribIPointer(input_index, 1, GL_UNSIGNED_INT, sizeof(GLuint), &verts); glEnableVertexAttribArray(input_index); pass = piglit_check_gl_error(0) && pass; glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, xfb_buf); memset(buffer, 0xffffffff, sizeof(buffer)); glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, sizeof(buffer), buffer, GL_STREAM_READ); piglit_BindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, xfb_buf, additional_offset, sizeof(buffer) - additional_offset); piglit_BeginTransformFeedback(GL_POINTS); glDrawArrays(GL_POINTS, 0, 4); piglit_EndTransformFeedback(); pass = piglit_check_gl_error(0) && pass; readback = glMapBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, GL_READ_ONLY); pass = piglit_check_gl_error(0) && pass; /* Figure out expected output */ memset(expected, 0xffffffff, sizeof(expected)); for (i = 0; i < EXPECTED_NUM_OUTPUTS; ++i) { expected[i + additional_offset / 4] = 0x00010203 + 0x04040404 * i; } /* Check output */ for (i = 0; i < BUFFER_SIZE; ++i) { if (expected[i] != readback[i]) { printf("readback[%u]: %u, expected: %u\n", i, readback[i], expected[i]); pass = GL_FALSE; } } piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
PIGLIT_GL_TEST_CONFIG_END enum piglit_result piglit_display(void) { bool pass = true; GLuint tex, sampler, fb; const float tex_data[16] = {0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0}; const float *green = tex_data; glClearColor(0, 0, 1, 0); glClear(GL_COLOR_BUFFER_BIT); glGenTextures(1, &tex); glBindTexture(GL_TEXTURE_2D, tex); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 2, 2, 0, GL_RGBA, GL_FLOAT, tex_data); glGenFramebuffers(1, &fb); glBindFramebuffer(GL_FRAMEBUFFER, fb); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, tex, 0); assert(glGetError() == 0); glGenSamplers(1, &sampler); glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glSamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glBindSampler(0, sampler); glBindFramebuffer(GL_READ_FRAMEBUFFER, fb); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, piglit_winsys_fbo); glBlitFramebuffer(0, 0, 1, 1, 0, 0, piglit_width, piglit_height, GL_COLOR_BUFFER_BIT, GL_NEAREST); glBindFramebuffer(GL_FRAMEBUFFER, piglit_winsys_fbo); pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, green); piglit_present_results(); glDeleteSamplers(1, &sampler); glDeleteTextures(1, &tex); glDeleteFramebuffers(1, &fb); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { bool pass; piglit_gen_ortho_projection(0.0, 2.0, 0.0, 2.0, -2.0, 6.0, GL_FALSE); DoFrame(); pass = DoTest(); piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
/** * Draws a single quad into multiple viewport each with a different * color. Reads back the expected color to test if the drawing was correct. * @param changeVPloc; if true then the geometry shader viewport location * is changed with each loop, otherwise viewport location is fixed. */ static bool draw_multi_viewport(const bool changeVPLoc) { bool pass = true; int i, j; const int divX=2, divY=4; GLfloat w = (GLfloat) piglit_width / (GLfloat) divX; GLfloat h = (GLfloat) piglit_height / (GLfloat) divY; const GLfloat colors[][3] = {{0.0, 0.0, 1.0}, {0.0, 1.0, 0.0}, {1.0, 0.0, 0.0}, {1.0, 1.0, 0.0}, {0.0, 1.0, 1.0}, {1.0, 0.0, 1.0}, {1.0, 1.0, 1.0}, {0.0, 0.0, 0.5}, {0.0, 0.0, 0.0} }; assert(ARRAY_SIZE(colors) == divX*divY + 1); glViewport(0, 0, piglit_width, piglit_height); /* for glClear() */ glClear(GL_COLOR_BUFFER_BIT); glUniform1i(vpIndexLoc, divX * divY); glViewportIndexedf(divX * divY, -10.0, -30.0, piglit_width, 20.0); for (i = 0; i < divX; i++) { for (j = 0; j < divY; j++) { int p; GLfloat *expected; glUniform3fv(colorLoc, 1, &colors[j + i*divY][0]); if (changeVPLoc) { glUniform1i(vpIndexLoc, j + i*divY); expected = (GLfloat *) &colors[j + i*divY][0]; } else { expected = (GLfloat *) &colors[divX * divY][0]; } glViewportIndexedf(j + i*divY, i * w, j * h, w, h); piglit_draw_rect(-1, -1, 2, 2); pass = piglit_check_gl_error(GL_NO_ERROR) && pass; p = piglit_probe_pixel_rgb(i * w + w/2, j * h + h/2, expected); piglit_present_results(); if (!p) { printf("Wrong color for viewport i,j %d %d changeVP=%d\n", i, j, changeVPLoc); pass = false; } } } return pass; }