void
piglit_init(int argc, char **argv)
{
	if (argc != 2)
		print_usage_and_exit(argv[0]);

	/* 1st arg: num_samples */
	char *endptr = NULL;
	num_samples = strtol(argv[1], &endptr, 0);
	if (endptr != argv[1] + strlen(argv[1]))
		print_usage_and_exit(argv[0]);

	piglit_require_extension("GL_ARB_vertex_array_object");
	piglit_require_extension("GL_ARB_sample_shading");
	piglit_require_GLSL_version(130);

	/* Skip the test if num_samples > GL_MAX_SAMPLES */
	GLint max_samples;
	glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
	if (num_samples > max_samples)
		piglit_report_result(PIGLIT_SKIP);

	singlesampled_fbo.setup(FboConfig(0,
					  pattern_width,
					  pattern_height));

	FboConfig msConfig(num_samples, pattern_width, pattern_height);
	multisampled_fbo.setup(msConfig);

	compile_shader();
	if (!piglit_check_gl_error(GL_NO_ERROR)) {
		piglit_report_result(PIGLIT_FAIL);
	}
}
void
piglit_init(int argc, char **argv)
{
	if (argc != 2)
		print_usage_and_exit(argv[0]);

	/* 1st arg: num_samples */
	char *endptr = NULL;
	num_samples = strtol(argv[1], &endptr, 0);
	if (endptr != argv[1] + strlen(argv[1]))
		print_usage_and_exit(argv[0]);

	piglit_require_extension("GL_ARB_texture_multisample");
	piglit_require_extension("GL_ARB_sample_shading");
	piglit_require_GLSL_version(140);

	/* Skip the test if num_samples > GL_MAX_SAMPLES */
	GLint max_samples;
	glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
	if (num_samples > max_samples)
		piglit_report_result(PIGLIT_SKIP);

	FboConfig msConfig(num_samples, pattern_width, pattern_height);
	msConfig.color_format = GL_RGBA_INTEGER;
	msConfig.color_internalformat = GL_RGBA8UI;
	multisampled_fbo.setup(msConfig);

	msConfig.attach_texture = true;
	multisampled_tex.setup(msConfig);

	compile_shader();
	if (!piglit_check_gl_error(GL_NO_ERROR)) {
		piglit_report_result(PIGLIT_FAIL);
	}
}
void
piglit_init(int argc, char **argv)
{
	if (argc < 2)
		print_usage_and_exit(argv[0]);
	{
		char *endptr = NULL;
		num_samples = strtol(argv[1], &endptr, 0);
		if (endptr != argv[1] + strlen(argv[1]))
			print_usage_and_exit(argv[0]);
	}

	piglit_require_gl_version(21);
	piglit_require_extension("GL_ARB_framebuffer_object");
	piglit_require_extension("GL_ARB_vertex_array_object");

	piglit_ortho_projection(pattern_width, pattern_height, GL_TRUE);

	/* Skip the test if num_samples > GL_MAX_SAMPLES */
	GLint max_samples;
	glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
	if (num_samples > max_samples)
		piglit_report_result(PIGLIT_SKIP);

	ms_fbo.setup(FboConfig(num_samples, pattern_width, pattern_height));
	resolve_fbo.setup(FboConfig(0, pattern_width, pattern_height));

	buffer_to_test = GL_COLOR_BUFFER_BIT;
	shader_compile();
	glEnable(GL_POLYGON_STIPPLE);
	glPolygonStipple(stipple_pattern);

}
Beispiel #4
0
void
piglit_init(int argc, char **argv)
{
	int num_samples;
	int src_samples;
	int dst_samples;
	if (argc < 4)
		print_usage_and_exit(argv[0]);

	char *endptr = NULL;
	num_samples = strtol(argv[1], &endptr, 0);
	if (endptr != argv[1] + strlen(argv[1]))
		print_usage_and_exit(argv[0]);

	piglit_require_gl_version(21);
	piglit_require_extension("GL_ARB_framebuffer_object");
	piglit_require_extension("GL_ARB_vertex_array_object");

	/* Skip the test if num_samples > GL_MAX_SAMPLES */
	GLint max_samples;
	glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
	if (num_samples > max_samples)
		piglit_report_result(PIGLIT_SKIP);

	if (strcmp(argv[2], "color") == 0) {
		test_pattern = new Triangles();
		buffer_to_test = GL_COLOR_BUFFER_BIT;
	} else if (strcmp(argv[2], "depth") == 0) {
		test_pattern = new DepthSunburst();
		manifest_program = new ManifestDepth();
		buffer_to_test = GL_DEPTH_BUFFER_BIT;
	} else if (strcmp(argv[2], "stencil") == 0) {
		test_pattern = new StencilSunburst();
		manifest_program = new ManifestStencil();
		buffer_to_test = GL_STENCIL_BUFFER_BIT;
	} else {
		print_usage_and_exit(argv[0]);
	}

	if (strcmp(argv[3], "msaa") == 0) {
		src_samples = dst_samples = num_samples;
	} else if (strcmp(argv[3], "upsample") == 0) {
		src_samples = 0;
		dst_samples = num_samples;
	} else if (strcmp(argv[3], "downsample") == 0) {
		src_samples = num_samples;
		dst_samples = 0;
	} else {
		print_usage_and_exit(argv[0]);
	}

	test_pattern->compile();
	if (manifest_program)
		manifest_program->compile();
	src_fbo.setup(FboConfig(src_samples, pattern_size, pattern_size));
	dst_fbo.setup(FboConfig(dst_samples, pattern_size, pattern_size));
}
void
piglit_init(int argc, char **argv)
{
	piglit_require_gl_version(21);
	piglit_require_extension("GL_ARB_framebuffer_object");
	piglit_require_extension("GL_ARB_vertex_array_object");

	/* Passing sample count = 1 will create the FBOs with minimum supported
	 * sample count. Both FBOs are created with GL_RGBA format by default.
	 */
	src_fbo.setup(FboConfig(1 /* sample count */,
				pattern_width,
				pattern_height));

	dst_fbo.setup(FboConfig(1 /* sample count */,
				pattern_width,
				pattern_height));

	/* Single-sampled FBO used so that we can call glReadPixels to
	 * examine the results.
	 */
	ss_fbo.setup(FboConfig(0 /* sample count */,
			       pattern_width,
			       pattern_height));

	if (!piglit_check_gl_error(GL_NO_ERROR)) {
		printf("Error setting up frame buffer objects\n");
		piglit_report_result(PIGLIT_FAIL);
	}

	test_pattern = new ColorGradientSunburst(GL_FLOAT);
	test_pattern->compile();

	glBindFramebuffer(GL_FRAMEBUFFER, src_fbo.handle);
	test_pattern->draw(TestPattern::no_projection);

	/* Generate a reference image by downsampling between matching
	 * formats.
	 */
	glBindFramebuffer(GL_READ_FRAMEBUFFER, src_fbo.handle);
	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, ss_fbo.handle);
	glBlitFramebuffer(0, 0, pattern_width, pattern_height,
			  0, 0, pattern_width, pattern_height,
			  GL_COLOR_BUFFER_BIT, GL_NEAREST);
	if (!piglit_check_gl_error(GL_NO_ERROR))
		piglit_report_result(PIGLIT_FAIL);

	reference_image = (GLfloat *) malloc(pattern_width *
					     pattern_height * 4 *
					     sizeof(GLfloat));

	glBindFramebuffer(GL_FRAMEBUFFER, ss_fbo.handle);
	glReadPixels(0, 0, pattern_width, pattern_height,
		     GL_RGBA, GL_FLOAT, reference_image);
}
enum piglit_result
piglit_display()
{
	bool pass = true;
	glClearColor(0.0, 0.0, 0.0, 1.0);
	glClear(GL_COLOR_BUFFER_BIT);

	/* Draw test pattern in single sample resolve_fbo with GL_POLYGON_STIPPLE
	 * enabled.
	 */
	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, resolve_fbo.handle);
	resolve_fbo.set_viewport();
	draw_pattern();

	/* Blit resolve_fbo to the right half of window system framebuffer. This
	 * is a reference image.
	 */
	glBindFramebuffer(GL_READ_FRAMEBUFFER, resolve_fbo.handle);
	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, piglit_winsys_fbo);
	glBlitFramebuffer(0, 0, pattern_width, pattern_height,
			  pattern_width, 0, 2 * pattern_width, pattern_height,
			  buffer_to_test, GL_NEAREST);

	/* Test with multisample FBO and GL_POLYGON_STIPPLE enabled */
	pass = test_polygon_stipple() && pass;

	if (!piglit_automatic &&
	    buffer_to_test != GL_DEPTH_BUFFER_BIT)
		piglit_present_results();

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
Beispiel #7
0
void
draw_test_image(bool sample_alpha_to_coverage, bool sample_alpha_to_one)
{
	/* Draw test pattern in multisample ms_fbo with
	 * GL_SAMPLE_ALPHA_TO_COVERAGE enabled
	 */
	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, ms_fbo.handle);
	glDrawBuffers(num_draw_buffers, draw_buffers);
	ms_fbo.set_viewport();

	draw_pattern(sample_alpha_to_coverage,
		     sample_alpha_to_one,
		     false /* is_reference_image */,
		     color);

	for(int i = 0; i < num_draw_buffers; i++) {

		/* Blit ms_fbo to singlesample FBO to resolve multisample
		 * buffer.
		 */
		glBindFramebuffer(GL_READ_FRAMEBUFFER, ms_fbo.handle);
		if(buffer_to_test == GL_COLOR_BUFFER_BIT)
			glReadBuffer(GL_COLOR_ATTACHMENT0_EXT + i);

		if ( is_buffer_zero_integer_format && !i)
			glBindFramebuffer(GL_DRAW_FRAMEBUFFER,
					  resolve_int_fbo.handle);
		else
			glBindFramebuffer(GL_DRAW_FRAMEBUFFER,
					  resolve_fbo.handle);

		/* Blit all the draw buffers to resolve_fbo / resolve_int_fbo
		 * with different y_offset.
		 */
		unsigned y_offset = i * pattern_height;
		glBlitFramebuffer(0, 0,
				  pattern_width, pattern_height,
				  0, y_offset,
				  pattern_width, pattern_height + y_offset,
				  buffer_to_test, GL_NEAREST);

		if(buffer_to_test == GL_COLOR_BUFFER_BIT) {
			draw_image_to_window_system_fb(i /* draw_buffer_count */,
						       false /* rhs */);
		}

		/* Expected color values for all the draw buffers are computed
		 * to aid probe_framebuffer_color() and probe_framebuffer_depth()
		 * in verification.
		 */
		if(sample_alpha_to_coverage || is_dual_src_blending) {
			/* Expected color is different for different draw
			 * buffers
			 */
			compute_expected(sample_alpha_to_coverage,
					 sample_alpha_to_one,
					 i /* draw_buffer_count */);
		}
	}
}
Beispiel #8
0
void Fbo::blitTo( Fbo dst, const Area &srcArea, const Area &dstArea, GLenum filter, GLbitfield mask ) const
{
	ScopedFramebuffer readScp( GL_READ_FRAMEBUFFER, mId );
	ScopedFramebuffer drawScp( GL_DRAW_FRAMEBUFFER, dst.getId() );

	glBlitFramebuffer( srcArea.getX1(), srcArea.getY1(), srcArea.getX2(), srcArea.getY2(), dstArea.getX1(), dstArea.getY1(), dstArea.getX2(), dstArea.getY2(), mask, filter );
}
void
piglit_init(int argc, char **argv)
{
	int num_samples;
	if (argc < 2)
		print_usage_and_exit(argv[0]);
	{
		char *endptr = NULL;
		num_samples = strtol(argv[1], &endptr, 0);
		if (endptr != argv[1] + strlen(argv[1]))
			print_usage_and_exit(argv[0]);
	}

	piglit_require_gl_version(21);
	piglit_require_extension("GL_ARB_framebuffer_object");
	piglit_require_extension("GL_ARB_vertex_array_object");

	/* Skip the test if num_samples > GL_MAX_SAMPLES */
	GLint max_samples;
	glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
	if (num_samples > max_samples)
		piglit_report_result(PIGLIT_SKIP);

	buffer_to_test = GL_COLOR_BUFFER_BIT;

	test_pattern = new Triangles();
	test_pattern->compile();

	ms_fbo.setup(FboConfig(num_samples, pattern_width, pattern_height));

	/* Enable blending to test GL_POLYGON_SMOOTH */
	glEnable (GL_BLEND);
	glBlendFunc (GL_SRC_ALPHA_SATURATE, GL_ONE);
}
Beispiel #10
0
void
piglit_init(int argc, char **argv)
{
	int num_samples;
	if (argc < 2)
		print_usage_and_exit(argv[0]);
	{
		char *endptr = NULL;
		num_samples = strtol(argv[1], &endptr, 0);
		if (endptr != argv[1] + strlen(argv[1]))
			print_usage_and_exit(argv[0]);
	}

	piglit_require_gl_version(30);
	glClear(GL_COLOR_BUFFER_BIT);

	/* Skip the test if num_samples > GL_MAX_SAMPLES */
	GLint max_samples;
	glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
	if (num_samples > max_samples)
		piglit_report_result(PIGLIT_SKIP);

	buffer_to_test = GL_COLOR_BUFFER_BIT;
	test_pattern = new Lines();
	test_pattern->compile();

	test_fbo.setup(FboConfig(num_samples, pattern_width, pattern_height));

	glEnable (GL_BLEND);
	glBlendFunc (GL_SRC_ALPHA_SATURATE, GL_ONE);
}
Beispiel #11
0
enum piglit_result
piglit_display()
{
	bool pass = true;
	glClearColor(0.0, 0.0, 0.0, 1.0);
	glClear(GL_COLOR_BUFFER_BIT);

	/* Draw test pattern in single sample resolve_fbo */
	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, resolve_fbo.handle);
	resolve_fbo.set_viewport();
	draw_pattern();

	/* Blit resolve_fbo to the right half of window system framebuffer. This
	 * is a reference image.
	 */
	glBindFramebuffer(GL_READ_FRAMEBUFFER, resolve_fbo.handle);
	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, piglit_winsys_fbo);
	glBlitFramebuffer(0, 0, pattern_width, pattern_height,
			  pattern_width, 0, 2 * pattern_width, pattern_height,
			  GL_COLOR_BUFFER_BIT, GL_NEAREST);

	/* Test drawing bitmap in multisample FBO */
	pass = test_multisample_bitmap() && pass;

	if (!piglit_automatic)
		piglit_present_results();

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
Beispiel #12
0
void Fbo::blitTo( Fbo dst, const Area &srcArea, const Area &dstArea, GLenum filter, GLbitfield mask ) const
{
	SaveFramebufferBinding saveFboBinding;

	glBindFramebufferEXT( GL_READ_FRAMEBUFFER_EXT, mObj->mId );
	glBindFramebufferEXT( GL_DRAW_FRAMEBUFFER_EXT, dst.getId() );		
	glBlitFramebufferEXT( srcArea.getX1(), srcArea.getY1(), srcArea.getX2(), srcArea.getY2(), dstArea.getX1(), dstArea.getY1(), dstArea.getX2(), dstArea.getY2(), mask, filter );
}
Beispiel #13
0
void
draw_reference_image(bool sample_alpha_to_coverage, bool sample_alpha_to_one)
{
	/* Draw test pattern in multisample ms_fbo with
	 * GL_SAMPLE_ALPHA_TO_COVERAGE disabled.
	 */
	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, ms_fbo.handle);
	glDrawBuffers(num_draw_buffers, draw_buffers);
	ms_fbo.set_viewport();

	if(sample_alpha_to_coverage) {
		draw_pattern(sample_alpha_to_coverage,
			     sample_alpha_to_one,
			     true /* is_reference_image */,
			     color);
	}
	else {
		/* Value of draw_buffer_count doesn't matter in this case */
		compute_expected(sample_alpha_to_coverage,
				 sample_alpha_to_one,
				 0 /* draw_buffer_count */);
		draw_pattern(sample_alpha_to_coverage,
			     sample_alpha_to_one,
			     true /* is_reference_image */,
			     expected_color);
	}

	for(int i = 0; i < num_draw_buffers; i++) {

		/* Blit ms_fbo to resolve_fbo to resolve multisample buffer */
		glBindFramebuffer(GL_READ_FRAMEBUFFER, ms_fbo.handle);
		if (buffer_to_test == GL_COLOR_BUFFER_BIT)
			glReadBuffer(GL_COLOR_ATTACHMENT0_EXT + i);
		if (is_buffer_zero_integer_format && !i) {
			glBindFramebuffer(GL_DRAW_FRAMEBUFFER,
					  resolve_int_fbo.handle);
		}
		else {
			glBindFramebuffer(GL_DRAW_FRAMEBUFFER,
					  resolve_fbo.handle);
		}

		/* Blit all the draw buffers to resolve_fbo with different
		 * y_offset.
		 */
		unsigned y_offset = i * pattern_height;
		glBlitFramebuffer(0, 0,
				  pattern_width, pattern_height,
				  0, y_offset,
				  pattern_width, pattern_height + y_offset,
				  buffer_to_test, GL_NEAREST);

		if(buffer_to_test == GL_COLOR_BUFFER_BIT) {
			draw_image_to_window_system_fb(i /* draw_buffer_count */,
						       true /* rhs */);
		}
	}
}
Beispiel #14
0
enum piglit_result
piglit_display()
{
	bool pass = true;

	/* Draw the test pattern in src_fbo. */
	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, src_fbo.handle);
	src_fbo.set_viewport();
	test_pattern->draw(TestPattern::no_projection);

	/* Blit from src_fbo to dst_fbo, scrambling the pattern as we go. */
	glBindFramebuffer(GL_READ_FRAMEBUFFER, src_fbo.handle);
	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, dst_fbo.handle);
	scrambling_blit(permutation);

	/* Blit from dst_fbo to the left half of the window system
	 * framebuffer, unscrambling as we go.
	 */
	glBindFramebuffer(GL_READ_FRAMEBUFFER, dst_fbo.handle);
	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, piglit_winsys_fbo);
	scrambling_blit(inverse_permutation);

	/* Blit from src_fbo to dst_fbo with no scrambling. */
	glBindFramebuffer(GL_READ_FRAMEBUFFER, src_fbo.handle);
	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, dst_fbo.handle);
	glBlitFramebuffer(0, 0, pattern_size, pattern_size,
			  0, 0, pattern_size, pattern_size,
			  buffer_to_test, GL_NEAREST);

	/* Blit from dst_fbo to the right half of the window system
	 * framebuffer, with no scrambling.
	 */
	glBindFramebuffer(GL_READ_FRAMEBUFFER, dst_fbo.handle);
	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, piglit_winsys_fbo);
	glBlitFramebuffer(0, 0, pattern_size, pattern_size,
			  pattern_size, 0, pattern_size*2, pattern_size,
			  buffer_to_test, GL_NEAREST);

	/* If we were testing depth or stencil, manifest the image so
	 * that we can see it.
	 */
	glViewport(0, 0, piglit_width, piglit_height);
	if (manifest_program)
		manifest_program->run();

	/* Check that the left and right halves of the screen match. */
	glBindFramebuffer(GL_READ_FRAMEBUFFER, piglit_winsys_fbo);
	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;
}
Beispiel #15
0
void Fbo::blit_to(Fbo the_dst_fbo, const Area_<int> &the_src, const Area_<int> &the_dst,
             GLenum filter, GLbitfield mask) const
{
	SaveFramebufferBinding sb;

	glBindFramebuffer(GL_READ_FRAMEBUFFER, m_impl->m_id);
	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, the_dst_fbo.id());
	glBlitFramebuffer(the_src.x0, the_src.y0, the_src.x1, the_src.y1, the_dst.x0, the_dst.y0,
                      the_dst.x1, the_dst.y1, mask, filter);
}
Beispiel #16
0
void
piglit_init(int argc, char **argv)
{
	int num_samples;
	if (argc < 3)
		print_usage_and_exit(argv[0]);
	{
		char *endptr = NULL;
		num_samples = strtol(argv[1], &endptr, 0);
		if (endptr != argv[1] + strlen(argv[1]))
			print_usage_and_exit(argv[0]);
	}

	piglit_require_gl_version(30);
	piglit_require_GLSL_version(130);

	/* Skip the test if num_samples > GL_MAX_SAMPLES */
	GLint max_samples;
	glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
	if (num_samples > max_samples)
		piglit_report_result(PIGLIT_SKIP);

	if (strcmp(argv[2], "color") == 0) {
		test_pattern = new Triangles();
		buffer_to_test = GL_COLOR_BUFFER_BIT;
	} else if (strcmp(argv[2], "depth") == 0) {
		test_pattern = new DepthSunburst();
		manifest_program = new ManifestDepth();
		buffer_to_test = GL_DEPTH_BUFFER_BIT;
	} else if (strcmp(argv[2], "stencil") == 0) {
		test_pattern = new StencilSunburst();
		manifest_program = new ManifestStencil();
		buffer_to_test = GL_STENCIL_BUFFER_BIT;
	} else {
		print_usage_and_exit(argv[0]);
	}
	test_pattern->compile();
	if (manifest_program)
		manifest_program->compile();

	multisample_fbo.setup(FboConfig(num_samples, pattern_width,
					pattern_height));
}
void
piglit_init(int argc, char **argv)
{
	if (argc != 2)
		print_usage_and_exit(argv[0]);

	/* 1st arg: num_samples */
	char *endptr = NULL;
	num_samples = strtol(argv[1], &endptr, 0);
	if (endptr != argv[1] + strlen(argv[1]))
		print_usage_and_exit(argv[0]);

	if (num_samples > 8) {
		puts("This test only supports 8 samples.");
		piglit_report_result(PIGLIT_SKIP);
	}

	piglit_require_extension("GL_ARB_texture_multisample");
	piglit_require_extension("GL_ARB_sample_shading");
	piglit_require_GLSL_version(130);

	/* Skip the test if num_samples > GL_MAX_SAMPLES */
	GLint max_samples;
	glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
	if (num_samples > max_samples)
		piglit_report_result(PIGLIT_SKIP);

	FboConfig msConfig(num_samples, 1 << MAX2(num_samples, 1), 1);
	msConfig.num_rb_attachments = 0;
	msConfig.num_tex_attachments = 1;
	multisampled_tex.setup(msConfig);

	compile_shader();
	if (!piglit_check_gl_error(GL_NO_ERROR)) {
		piglit_report_result(PIGLIT_FAIL);
	}
}
Beispiel #18
0
void
ms_fbo_and_draw_buffers_setup(int samples,
			      int width,
			      int height,
			      int n_attachments,
			      GLenum test_buffer,
			      GLenum color_buffer_zero_format)
{
	int maxBuffers;
	glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &maxBuffers);

	/* Ensure that requested number of color attachments are
	 * supported by the implementation and fragment shader.
	 */
	if (n_attachments <= (int) ARRAY_SIZE(draw_buffers) &&
	    n_attachments <= maxBuffers)
		num_draw_buffers = n_attachments;
	else {
		printf("Number of attachments requested are not supported\n");
		piglit_report_result(PIGLIT_SKIP);
	}

	pattern_width = width;
	pattern_height = height;
	draw_buffer_zero_format = color_buffer_zero_format;

	/* Setup frame buffer objects with required configuration */
	FboConfig ms_config(samples, pattern_width, pattern_height);
	ms_config.color_internalformat = color_buffer_zero_format;
	ms_fbo.setup(ms_config);

	/* Create resolve_fbo with dimensions large enough to accomodate
	 * all the draw buffers
	 */
	FboConfig resolve_config(0, pattern_width,
				 num_draw_buffers * pattern_height);
	resolve_config.color_internalformat = GL_RGBA;
	resolve_fbo.setup(resolve_config);

	/* Create resolve_int_fbo to store downsampled integer draw buffer */
	if (color_buffer_zero_format == GL_RGBA8I) {
		resolve_config.color_internalformat = GL_RGBA8I;
		/* Assuming single integer buffer */
		resolve_config.height = pattern_height;
		resolve_int_fbo.setup(resolve_config);
		is_buffer_zero_integer_format = true;
	}
	else if (color_buffer_zero_format != GL_RGBA &&
		 color_buffer_zero_format != GL_NONE) {
		printf("Draw buffer zero format is not"
		       " supported by test functions.\n");
		piglit_report_result(PIGLIT_FAIL);
	}

        if (!piglit_check_gl_error(GL_NO_ERROR)) {
		printf("Error setting up frame buffer objects\n");
		piglit_report_result(PIGLIT_FAIL);
        }

	/* Query the number of samples used in ms_fbo. OpenGL implementation
	 * may create FBO with more samples per pixel than what is requested.
	 */
	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, ms_fbo.handle);
	glGetIntegerv(GL_SAMPLES, &num_samples);

	/* Attach additional color buffers to multisample FBO with default
	 * non-integer format (GL_RGBA.)
	 */
	GLuint *color_rb = (GLuint *)malloc((num_draw_buffers - 1) *
					    sizeof(GLuint));
	glGenRenderbuffers(num_draw_buffers - 1, color_rb);

	for(int i = 0; i < num_draw_buffers - 1; i++) {
		glBindRenderbuffer(GL_RENDERBUFFER, color_rb[i]);
		glRenderbufferStorageMultisample(GL_RENDERBUFFER,
					ms_fbo.config.num_samples,
					GL_RGBA,
					ms_fbo.config.width,
					ms_fbo.config.height);

		glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER,
					  GL_COLOR_ATTACHMENT0 + (i + 1),
					  GL_RENDERBUFFER,
					  color_rb[i]);
	}

	GLenum status = glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
        if (status != GL_FRAMEBUFFER_COMPLETE) {
		printf("Error attaching additional color buffers\n");
		piglit_report_result(PIGLIT_FAIL);
	}
	buffer_to_test = test_buffer;
	free(color_rb);
}
Beispiel #19
0
int main(int argc, char **argv)
{


	Config cfg = readConfig(); // Misc.cpp
	Scene_SDL* CurrentScene = new Scene_SDL(cfg.ResolutionX,cfg.ResolutionY);

	vec2 resolution = vec2(cfg.ResolutionX, cfg.ResolutionY);

	Vao vaoA = Vao("Mesh/thing.obj");
	vaoA.load(vec4(0,0,0,0));

	Vao vaoB = Vao("Mesh/plane.obj");
	vaoB.load(vec4(0, 0, 0, 0));

	TextureCfg texCfgA = { GL_RGB8, GL_NEAREST, GL_REPEAT };
	Texture texA = Texture("Texture/checker.png", texCfgA);
	texA.load();

	Shader shaderForward = Shader("Shader/test.vert", "Shader/test.frag");
	shaderForward.load();

	Shader shaderGeometry = Shader("Shader/defPass1.vert", "Shader/defPass1.frag");
	shaderGeometry.load();

	Shader shaderDeferred = Shader("Shader/defPassN.vert", "Shader/defPassN.frag");
	shaderDeferred.load();

	Shader shaderDeferredDebug = Shader("Shader/defPassN.vert", "Shader/defPassNDebug.frag");
	shaderDeferredDebug.load();

	Shader* shaderSelected = &shaderDeferred;

	Shader shaderAO = Shader("Shader/defPassN.vert", "Shader/AO.frag");
	shaderAO.load();

	Fbo* fboGeometry = createFboGeometry(cfg); // Misc.cpp

	Fbo* fboAO = createFbo_1ch(cfg);

	Vao2D supportFbo = Vao2D();
	supportFbo.load();

	glm::mat4 projection;
	glm::mat4 modelview;
	glm::mat4 view;

	projection = glm::perspective(70.0*M_PI/180.0, (double)cfg.ResolutionX / (double)cfg.ResolutionY, 0.01, 100.0);
	view = glm::lookAt(glm::vec3(2,2,2), glm::vec3(0, 0, 0.5), glm::vec3(0, 0, 1));

	GLuint mAttach[3] = { GL_COLOR_ATTACHMENT0 , GL_COLOR_ATTACHMENT1 ,GL_COLOR_ATTACHMENT2 };
	Input input;

	int frame = 0;
	while (!input.end()) {
		frame++;


			input.update();

			if (input.getRisingKey(SDL_SCANCODE_SPACE)) {
				shaderSelected = (shaderSelected == &shaderDeferredDebug) ? &shaderDeferred : &shaderDeferredDebug;
			}


			glViewport(0, 0, cfg.ResolutionX, cfg.ResolutionY);
			glBindFramebuffer(GL_FRAMEBUFFER, fboGeometry->getId());
				glDrawBuffers(3, mAttach);
				glDisable(GL_BLEND);
				glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
				glUseProgram(shaderGeometry.getProgramID());

				glUniformMatrix4fv(glGetUniformLocation(shaderGeometry.getProgramID(), "projection"), 1, GL_FALSE, value_ptr(projection));
				glUniform2fv(glGetUniformLocation(shaderGeometry.getProgramID(), "resolution"), 1, value_ptr(resolution));

				glActiveTexture(GL_TEXTURE0);
				glBindTexture(GL_TEXTURE_2D, texA.getId());
				glUniform1i(glGetUniformLocation(shaderGeometry.getProgramID(), "texture_diffuse"), 0);

				modelview = rotate(view, (input.getX() - cfg.ResolutionX) / 200.0f, vec3(0.0f, 0.0f, 1.0f));
				modelview = translate(modelview, vec3(0, 0, 0.8));
				glUniformMatrix4fv(glGetUniformLocation(shaderGeometry.getProgramID(), "modelview"), 1, GL_FALSE, value_ptr(modelview));
				glUniformMatrix3fv(glGetUniformLocation(shaderGeometry.getProgramID(), "normal"), 1, GL_FALSE, value_ptr(transpose(inverse(glm::mat3(modelview)))));

				vaoA.draw();

				modelview = view;
				glUniformMatrix4fv(glGetUniformLocation(shaderGeometry.getProgramID(), "modelview"), 1, GL_FALSE, value_ptr(modelview));
				glUniformMatrix3fv(glGetUniformLocation(shaderGeometry.getProgramID(), "normal"), 1, GL_FALSE, value_ptr(transpose(inverse(glm::mat3(modelview)))));
				vaoB.draw();

				glBindTexture(GL_TEXTURE_2D, 0);
				glUseProgram(0);



			glBindFramebuffer(GL_FRAMEBUFFER, 0);
				glEnable(GL_BLEND);
				glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
				glUseProgram(shaderSelected->getProgramID());

				glActiveTexture(GL_TEXTURE0);
				glBindTexture(GL_TEXTURE_2D, fboGeometry->getColorBufferId(0));
				glUniform1i(glGetUniformLocation(shaderSelected->getProgramID(), "gNormal"), 0);

				glActiveTexture(GL_TEXTURE1);
				glBindTexture(GL_TEXTURE_2D, fboGeometry->getColorBufferId(1));
				glUniform1i(glGetUniformLocation(shaderSelected->getProgramID(), "gDiffuse"), 1);

				glActiveTexture(GL_TEXTURE2);
				glBindTexture(GL_TEXTURE_2D, fboGeometry->getColorBufferId(2));
				glUniform1i(glGetUniformLocation(shaderSelected->getProgramID(), "gPosition"), 2);

				glUniformMatrix4fv(glGetUniformLocation(shaderSelected->getProgramID(), "projection"), 1, GL_FALSE, value_ptr(projection));

				glUniform1f(glGetUniformLocation(shaderSelected->getProgramID(), "varA"), input.getY() / resolution.y);
				glUniform1i(glGetUniformLocation(shaderSelected->getProgramID(), "time"), frame);
				glUniform2fv(glGetUniformLocation(shaderSelected->getProgramID(), "resolution"), 1, value_ptr(resolution));

				supportFbo.draw();

			CurrentScene->flip();


	}

	delete CurrentScene;
	return 0;
}
Beispiel #20
0
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;
}
Beispiel #21
0
int CreateGlContext()
{
	hDC = ::GetDC(glHwnd);
	if(!hDC)
		return -1;
	
	PIXELFORMATDESCRIPTOR pfd;
	memset(&pfd, 0, sizeof(pfd));
	pfd.nSize = sizeof(pfd);
	pfd.nVersion = 1;
	pfd.dwFlags = 
		PFD_DRAW_TO_WINDOW | 
		PFD_DOUBLEBUFFER | 
		PFD_SUPPORT_OPENGL |
		//PFD_SUPPORT_COMPOSITION |
		0x00008000 | 
		PFD_GENERIC_ACCELERATED;
	pfd.iPixelType = PFD_TYPE_RGBA;
	pfd.cColorBits = 32;
	pfd.cDepthBits = 24;
	pfd.cStencilBits = 8;
	pfd.iLayerType = PFD_MAIN_PLANE;
	int pf = ChoosePixelFormat(hDC, &pfd);
	if(!pf) {
		error ="ChoosePixelFormat error";
		return -2;
	}
	RLOG("OpenGL: ChoosePixelFormat ok..");
	if(!SetPixelFormat(hDC, pf, &pfd)) {
		error = "SetPixelFormat error";
		return -3;
	}
	DescribePixelFormat(hDC, pf, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
	hRC = wglCreateContext(hDC);
	if(!hRC)
	{
		error = "wglCreateContext error";
		return -4;
	}
	RLOG("OpenGL: wglCreateContext ok..");
	if(!wglMakeCurrent(hDC, hRC))
	{
		error = "wglMakeCurrent error";
		return -5;
	}
	RLOG("OpenGL: wglMakeCurrent ok..");
	GLenum err = glewInit();
	if(err != GLEW_OK)
	{
		error = "Glew library initialization error: " + String((const char*) glewGetErrorString(err));
		return -6;
	}
	RLOG("OpenGL: glewInit ok..");
	
	Size sz = Ctrl::GetScreenSize();
	if(!screenFbo0.Create(sz.cx, sz.cy))
	{
		error = "Creating screen 0 fbo error: " + screenFbo0.GetError();		
		return -7;
	}

	if(!screenFbo1.Create(sz.cx, sz.cy))
	{
		error = "Creating screen 1 fbo error: " + screenFbo1.GetError();
		return -7;
	}
	
	RLOG("OpenGL: Creating fbo ok..");
	
	alphaMagProg.CompileProgram(alphaMagVert, alphaMagFrag);
	
	if(alphaMagProg.GetProgram() < 0)
	{
		error = alphaMagProg.GetError();
		return -8;
	}

	blurProg.CompileProgram(blurVert, blurFrag);
	
	if(blurProg.GetProgram() < 0)
	{
		error = blurProg.GetError();
		return -8;
	}
	
	RLOG("OpenGL: CompileProgram ok..");
	
	resources.GetFont(Tahoma(), true);
	resources.GetFont(Tahoma().Bold(), true);
	
	RLOG("OpenGL: Preloading fonts ok..");
	
	wglSwapIntervalEXT(1);
	
	if(glDrawMode == DRAW_ON_TIMER)
	{
		SetTimer(glHwnd, 1, 10, NULL);
		RLOG("OpenGL: SetTimer ok..");
	}
	
	glReady = true;
	return 1;
}
enum piglit_result
piglit_display()
{
	bool pass = true;
	int samples, i, j;

	glUseProgram(prog_0);
	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, multisampled_tex.handle);
	multisampled_tex.set_viewport();
	glGetIntegerv(GL_SAMPLES, &samples);
	samples = MAX2(samples, 1);

	glClear(GL_COLOR_BUFFER_BIT);
	glUniform1i(glGetUniformLocation(prog_0, "samples"), samples);
        piglit_draw_rect(-1, -1, 2, 2);

	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, piglit_winsys_fbo);
	glViewport(0, 0, piglit_width, piglit_height);
	glClear(GL_COLOR_BUFFER_BIT);

	glUseProgram(prog_1);
	glUniform1i(glGetUniformLocation(prog_1, "tex"), 0);
	glUniform1i(glGetUniformLocation(prog_1, "samples"), samples);
	if (samples <= 4)
		piglit_draw_rect(-1, -1,
				 8*(1 << samples) * (2.0/piglit_width),
				 8 * (2.0/piglit_height));
	else if (samples == 8)
		piglit_draw_rect(-1, -1,
				 8*16 * (2.0/piglit_width),
				 8*16 * (2.0/piglit_height));
	else
		assert(0 && "Unimplemented");

	for (i = 0; i < multisampled_tex.config.width; i++) {
		float color[4];
		unsigned full_mask = (1 << samples) - 1;
		unsigned expected_mask = i & full_mask;
		unsigned observed_mask = 0;

		if (multisampled_tex.config.num_samples == 0)
			expected_mask = full_mask;

		glReadPixels((i % 16) * 8 + 4,
			     (i / 16) * 8 + 4,
			     1, 1, GL_RGBA, GL_FLOAT, color);

		for (j = 0; j < 4; j++) {
			if (equal(color[j], 1) || equal(color[j], 0.6))
				observed_mask |= 1 << (j + 0);
			if (equal(color[j], 1) || equal(color[j], 0.4))
				observed_mask |= 1 << (j + 4);
		}

		if (expected_mask != observed_mask) {
			printf("Test failed, samples = %u\n"
			       "  Expected sample mask: 0x%x\n"
			       "  Observed sample mask: 0x%x\n",
			       samples, expected_mask, observed_mask);
			pass = false;
		}
	}

	piglit_present_results();
	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
Beispiel #23
0
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 ms_fbo with GL_POLYGON_SMOOTH
	 * disabled.
	 */
	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, ms_fbo.handle);
	ms_fbo.set_viewport();
	test_pattern->draw(proj);

	/* Blit ms_fbo to the right half of window system framebuffer. This
	 * is a reference image to test MSAA with polygon smooth.
	 */
	glBindFramebuffer(GL_READ_FRAMEBUFFER, ms_fbo.handle);
	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, piglit_winsys_fbo);
	glBlitFramebuffer(0, 0, pattern_width, pattern_height,
			  pattern_width, 0, 2 * pattern_width, pattern_height,
			  GL_COLOR_BUFFER_BIT, GL_NEAREST);

	/* Now draw test pattern in mulisample ms_fbo with GL_POLYGON_SMOOTH
	 * enabled
	 */
	glDisable(GL_DEPTH_TEST);
	glEnable(GL_POLYGON_SMOOTH);
	glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);

	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, ms_fbo.handle);
	ms_fbo.set_viewport();

	glClear(buffer_to_test);
	test_pattern->draw(proj);

	glDisable(GL_POLYGON_SMOOTH);

	/* Blit ms_fbo to the left half of window system framebuffer. This
	 * is the test image.
	 */
	glBindFramebuffer(GL_READ_FRAMEBUFFER, ms_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);

	/* Check that the left and right halves of the screen match. If they
	 * don't, then GL_POLYGON_SMOOTH is not ignored with multisample
	 * rendering.
	 */
	glBindFramebuffer(GL_READ_FRAMEBUFFER, piglit_winsys_fbo);
	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;
	GLfloat *expected_image;
	GLuint i;

	FboConfig config_ms(1 , pattern_width, pattern_height);

	for(i = 0; i < ARRAY_SIZE(color_formats); i++) {
		expected_image =
			generate_expected_image(reference_image,
						pattern_width, pattern_height,
						color_formats[i].components);

		config_ms.color_internalformat = color_formats[i].name;
		src_fbo.setup(config_ms);

		if (!piglit_check_gl_error(GL_NO_ERROR)) {
			printf("Error setting up renderbuffer color format\n");
			piglit_report_result(PIGLIT_FAIL);
		}

		glBindFramebuffer(GL_FRAMEBUFFER, src_fbo.handle);
		test_pattern->draw(TestPattern::no_projection);

		/* Blit multisample-to-multisample with non-matching formats */
		glBindFramebuffer(GL_READ_FRAMEBUFFER, src_fbo.handle);
		glBindFramebuffer(GL_DRAW_FRAMEBUFFER, dst_fbo.handle);

		glClear(GL_COLOR_BUFFER_BIT);

		glBlitFramebuffer(0, 0, pattern_width, pattern_height,
				  0, 0, pattern_width, pattern_height,
				  GL_COLOR_BUFFER_BIT, GL_NEAREST);

		/* Blitting between different formats shouldn't
		 * generate an error.
		 */
		pass = piglit_check_gl_error(GL_NO_ERROR) && pass;

		/* Downsample the blitted buffer so we can read the
		 * results
		 */
		glBindFramebuffer(GL_READ_FRAMEBUFFER, dst_fbo.handle);
		glBindFramebuffer(GL_DRAW_FRAMEBUFFER, ss_fbo.handle);
		glClear(GL_COLOR_BUFFER_BIT);
		glBlitFramebuffer(0, 0, pattern_width, pattern_height,
				  0, 0, pattern_width, pattern_height,
				  GL_COLOR_BUFFER_BIT, GL_NEAREST);

		pass = piglit_check_gl_error(GL_NO_ERROR) && pass;

		glBindFramebuffer(GL_FRAMEBUFFER, ss_fbo.handle);
		pass = piglit_probe_image_rgba(0, 0,
					       pattern_width, pattern_height,
					       expected_image) && pass;

		/* Also try a downsample blit with mismatched formats
		 */
		glBindFramebuffer(GL_READ_FRAMEBUFFER, src_fbo.handle);
		glBindFramebuffer(GL_DRAW_FRAMEBUFFER, ss_fbo.handle);
		glClear(GL_COLOR_BUFFER_BIT);
		glBlitFramebuffer(0, 0, pattern_width, pattern_height,
				  0, 0, pattern_width, pattern_height,
				  GL_COLOR_BUFFER_BIT, GL_NEAREST);

		pass = piglit_check_gl_error(GL_NO_ERROR) && pass;

		glBindFramebuffer(GL_FRAMEBUFFER, ss_fbo.handle);
		pass = piglit_probe_image_rgba(0, 0,
					       pattern_width, pattern_height,
					       expected_image) && pass;

		/* Blit the result to the window system buffer so that
		 * something will be displayed in a non-automatic
		 * test.
		 */
		glBindFramebuffer(GL_READ_FRAMEBUFFER, ss_fbo.handle);
		glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
		glClear(GL_COLOR_BUFFER_BIT);
		glBlitFramebuffer(0, 0, pattern_width, pattern_height,
				  0, 0, pattern_width, pattern_height,
				  GL_COLOR_BUFFER_BIT, GL_NEAREST);

		pass = piglit_check_gl_error(GL_NO_ERROR) && pass;

		piglit_present_results();

		free(expected_image);
	}

	return (pass ? PIGLIT_PASS : PIGLIT_FAIL);
}