コード例 #1
0
ファイル: bitmap.cpp プロジェクト: BNieuwenhuizen/piglit
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;
}
コード例 #2
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 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;
}
コード例 #3
0
ファイル: draw-buffers-common.cpp プロジェクト: RAOF/piglit
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 */);
		}
	}
}
コード例 #4
0
ファイル: draw-buffers-common.cpp プロジェクト: RAOF/piglit
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 */);
		}
	}
}
コード例 #5
0
ファイル: unaligned-blit.cpp プロジェクト: chemecse/piglit
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;
}
コード例 #6
0
ファイル: upsample.cpp プロジェクト: blaztinn/piglit
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;
}
コード例 #7
0
ファイル: line-smooth.cpp プロジェクト: blaztinn/piglit
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;
}
コード例 #8
0
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;
}
コード例 #9
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 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;
}