enum piglit_result piglit_display(void) { int row, col; bool pass = true; glClear(GL_COLOR_BUFFER_BIT); glUseProgram(prog); glUniform2f(window_size_loc, piglit_width/2, piglit_height); glVertexAttribPointer(vertex_attr, 2, GL_FLOAT, GL_FALSE, sizeof(vertex_patterns[test->pattern][0]), vertex_patterns[test->pattern]); glEnableVertexAttribArray(vertex_attr); for (col = 0; col < NUM_COLS; col++) { if (col == 0) glViewport(0, 0, piglit_width/2, piglit_height); else glViewport(piglit_width/2, 0, piglit_width/2, piglit_height); for (row = 0; row < NUM_ROWS; row++) { glUniform2f(offset_loc, 0, (NUM_ROWS - 1 - row) * PATTERN_SIZE); draw_pattern(row + 1, col == 0); } } glViewport(0, 0, piglit_width, piglit_height); pass = piglit_probe_rect_halves_equal_rgba(0, 0, piglit_width, piglit_height) && pass; pass = piglit_check_gl_error(GL_NO_ERROR) && pass; piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display() { bool pass = true; glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); glClearColor(0.0, 0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); allocate_data_arrays(); draw_reference_image(false /* sample_alpha_to_coverage */, true /* sample_alpha_to_one */); draw_test_image(false /* sample_alpha_to_coverage */, true /* sample_alpha_to_one */); pass = piglit_check_gl_error(GL_NO_ERROR) && pass; glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); pass = piglit_probe_rect_halves_equal_rgba(0, 0, piglit_width, piglit_height) && pass; /* Free the memory allocated for data arrays */ free_data_arrays(); if (!piglit_automatic) piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { bool pass = true; glEnable(GL_BLEND); glBlendEquation(GL_MAX); glClear(GL_COLOR_BUFFER_BIT); /* Left half of the window is the test pattern */ glViewport(0, 0, PATTERN_SIZE, PATTERN_SIZE); draw_test_pattern(); /* Right half of the window is the reference image */ glViewport(PATTERN_SIZE, 0, PATTERN_SIZE, PATTERN_SIZE); draw_ref_pattern(); if (!piglit_check_gl_error(GL_NO_ERROR)) pass = false; /* Compare window halves */ pass = piglit_probe_rect_halves_equal_rgba(0, 0, 2*PATTERN_SIZE, PATTERN_SIZE) && pass; piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
bool test_polygon_stipple() { bool result = true; glBindFramebuffer(GL_DRAW_FRAMEBUFFER, ms_fbo.handle); draw_pattern(); /* Blit ms_fbo to resolve_fbo to resolve multisample buffer */ glBindFramebuffer(GL_READ_FRAMEBUFFER, ms_fbo.handle); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, resolve_fbo.handle); glBlitFramebuffer(0, 0, pattern_width, pattern_height, 0, 0, pattern_width, pattern_height, buffer_to_test, GL_NEAREST); /* Blit resolve_fbo to the left half of window system framebuffer. * This is the test image. */ glBindFramebuffer(GL_READ_FRAMEBUFFER, resolve_fbo.handle); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); glBlitFramebuffer(0, 0, pattern_width, pattern_height, 0, 0, pattern_width, pattern_height, buffer_to_test, GL_NEAREST); /* Check that the left and right halves of the screen match */ glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); result = piglit_probe_rect_halves_equal_rgba(0, 0, piglit_width, piglit_height) && result; glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); result = piglit_check_gl_error(GL_NO_ERROR) && result; return result; }
enum piglit_result piglit_display(void) { GLboolean pass = GL_TRUE; glViewport(0, 0, piglit_width, piglit_height); glClearColor(0.5, 0.5, 0.5, 0.5); glClear(GL_COLOR_BUFFER_BIT); glViewport(0, 0, piglit_width/2, piglit_height); glUseProgram(prog_tex); draw_quad(); glViewport(piglit_width/2, 0, piglit_width/2, piglit_height); glUseProgram(prog_texgrad); draw_quad(); if (!piglit_probe_rect_halves_equal_rgba(0, 0, piglit_width, piglit_height)) pass = GL_FALSE; piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display() { bool pass = true; glBindFramebuffer(GL_DRAW_FRAMEBUFFER, piglit_winsys_fbo); glClearColor(0.0, 0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); allocate_data_arrays(); /* Set sample_alpha_to_one = false to generate the reference image */ draw_reference_image(false /* sample_alpha_to_coverage */, false /* sample_alpha_to_one */); /* Test multisample fbo with GL_SAMPLE_ALPHA_TO_ONE enabled but * GL_MULTISAMPLE disabled */ glDisable(GL_MULTISAMPLE); draw_test_image(false /* sample_alpha_to_coverage */, true /* sample_alpha_to_one */); glEnable(GL_MULTISAMPLE); pass = piglit_check_gl_error(GL_NO_ERROR) && pass; glBindFramebuffer(GL_READ_FRAMEBUFFER, piglit_winsys_fbo); pass = piglit_probe_rect_halves_equal_rgba(0, 0, piglit_width, piglit_height) && pass; /* Free the memory allocated for data arrays */ free_data_arrays(); if (!piglit_automatic) piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display() { bool pass = true; /* Draw the full test pattern on the right half of the piglit * window, as a reference image. * * To map the full test pattern to the right half of the * windows, we need a projection matrix that multiplies the X * coordinate by 0.5 and adds 0.5. */ float proj[4][4] = { { 0.5, 0, 0, 0.5 }, { 0, 1, 0, 0 }, { 0, 0, 1, 0 }, { 0, 0, 0, 1 } }; glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); glViewport(0, 0, piglit_width, piglit_height); test_pattern->draw(proj); /* Blit the test pattern to multisample_fbo, forcing the * implementation to upsample it. */ glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, multisample_fbo.handle); glBlitFramebuffer(pattern_width, 0, pattern_width*2, pattern_height, 0, 0, pattern_width, pattern_height, buffer_to_test, GL_NEAREST); if (manifest_program) { /* Manifest the test pattern in the main framebuffer. */ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); manifest_program->run(); /* Manifest the test pattern in the multisample * framebuffer. */ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, multisample_fbo.handle); multisample_fbo.set_viewport(); manifest_program->run(); } /* Blit the manifested test pattern to the left half of the * main framebuffer, forcing the implementation to downsample * it. */ glBindFramebuffer(GL_READ_FRAMEBUFFER, multisample_fbo.handle); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); glBlitFramebuffer(0, 0, pattern_width, pattern_height, 0, 0, pattern_width, pattern_height, GL_COLOR_BUFFER_BIT, GL_NEAREST); /* Check that the left and right halves of the screen match. * If they don't, then there is either a problem with * upsampling or downsampling. Since downsampling is already * tested by accuracy.cpp, we'll assume that any problem we * see here is due to upsampling. */ glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); pass = piglit_probe_rect_halves_equal_rgba(0, 0, piglit_width, piglit_height) && pass; pass = piglit_check_gl_error(GL_NO_ERROR) && pass; piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display() { bool pass = true; float proj[4][4] = { { 1, 0, 0, 0 }, { 0, 1, 0, 0 }, { 0, 0, 1, 0 }, { 0, 0, 0, 1 } }; /* Draw test pattern in multisample test_fbo with GL_LINE_SMOOTH * disabled. */ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, test_fbo.handle); glClear(buffer_to_test); test_fbo.set_viewport(); test_pattern->draw(proj); /* Blit test_fbo to the right half of window system framebuffer. * This is the reference image. */ glBindFramebuffer(GL_READ_FRAMEBUFFER, test_fbo.handle); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); glBlitFramebuffer(0, 0, pattern_width, pattern_height, pattern_width, 0, 2*pattern_width, pattern_height, GL_COLOR_BUFFER_BIT, GL_NEAREST); /* Draw test pattern in mulisample test_fbo with GL_LINE_SMOOTH * enabled */ glEnable(GL_LINE_SMOOTH); glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); /* Disable depth test to correctly render overlapping smooth * primitives. Otherwise we have to render the primitives in * back to front order */ glDisable (GL_DEPTH_TEST); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, test_fbo.handle); test_fbo.set_viewport(); test_pattern->draw(proj); glDisable(GL_LINE_SMOOTH); /* Now blit test_fbo to the left half of window system framebuffer. * This is the test image. */ glBindFramebuffer(GL_READ_FRAMEBUFFER, test_fbo.handle); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); glBlitFramebuffer(0, 0, pattern_width, pattern_height, 0, 0, pattern_width, pattern_height, GL_COLOR_BUFFER_BIT, GL_NEAREST); /* Check that the left and right halves of the screen match. If they * don't, then GL_LINE_SMOOTH is not ignored with multisample * rendering. */ glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); pass = piglit_probe_rect_halves_equal_rgba(0, 0, piglit_width, piglit_height) && pass; pass = piglit_check_gl_error(GL_NO_ERROR) && pass; piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display() { bool pass = true; /* Draw the test pattern into the multisampled buffer. */ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, multisampled_fbo.handle); multisampled_fbo.set_viewport(); test_pattern->draw(TestPattern::no_projection); /* Blit it to a single-sampled buffer, flipping the * appropriate coordinate. This will only work if the * implementation allows multisampled blits to be flipped. */ glBindFramebuffer(GL_READ_FRAMEBUFFER, multisampled_fbo.handle); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, singlesampled_fbo.handle); glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, 0, 0, pattern_width, pattern_height, GL_COLOR_BUFFER_BIT, GL_NEAREST); pass = piglit_check_gl_error(GL_NO_ERROR) && pass; /* Blit the resulting image to the screen, performing no * additional flip. This is the test image. */ glBindFramebuffer(GL_READ_FRAMEBUFFER, singlesampled_fbo.handle); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, piglit_winsys_fbo); glBlitFramebuffer(0, 0, pattern_width, pattern_height, 0, 0, pattern_width, pattern_height, GL_COLOR_BUFFER_BIT, GL_NEAREST); /* Blit the test pattern into the single-sampled buffer with * no flip. This should always work. */ glBindFramebuffer(GL_READ_FRAMEBUFFER, multisampled_fbo.handle); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, singlesampled_fbo.handle); glBlitFramebuffer(0, 0, pattern_width, pattern_height, 0, 0, pattern_width, pattern_height, GL_COLOR_BUFFER_BIT, GL_NEAREST); /* Blit the resulting image to the screen, flipping the * appropriate coordinate, to produce the reference image. * This should always work (since it is blitting from * single-sampled to single-sampled). */ glBindFramebuffer(GL_READ_FRAMEBUFFER, singlesampled_fbo.handle); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, piglit_winsys_fbo); glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, pattern_width, 0, 2*pattern_width, pattern_height, GL_COLOR_BUFFER_BIT, GL_NEAREST); pass = piglit_check_gl_error(GL_NO_ERROR) && pass; /* Compare the test and reference images. */ glBindFramebuffer(GL_READ_FRAMEBUFFER, piglit_winsys_fbo); pass = piglit_probe_rect_halves_equal_rgba(0, 0, 2*pattern_width, pattern_height) && pass; piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }