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);
	}
}
예제 #2
0
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);

}
예제 #3
0
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);
	}
}
예제 #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);
}
예제 #6
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);
}
예제 #7
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(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);
}
예제 #8
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);
	}
}
예제 #10
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);
}
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);
}