enum piglit_result piglit_display(void)
{
	GLboolean pass = GL_TRUE;
	int i;

	glBindTexture(GL_TEXTURE_2D, tex);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 16, 16, 0, GL_RGBA, GL_FLOAT, tex_data);
	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
	glViewport(0, 0, 16, 16);

	glUseProgram(prog);
	glUniform1i(texloc, 0);

	for (i = 0; i < PASSES; i++) {
		if (i != 0)
			glTextureBarrierNV();
		piglit_draw_rect_tex(-1, -1, 2, 2, 0, 0, 1, 1);
	}

	pass = piglit_probe_image_rgba(0, 0, 16, 16, res_data);

	glUseProgram(0);
	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, piglit_winsys_fbo);
	glViewport(0, 0, piglit_width, piglit_height);

	piglit_draw_rect_tex(-1, -1, 2, 2, 0, 0, 1, 1);

	piglit_present_results();

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
enum piglit_result
piglit_display(void)
{
	static const char *fp_source =
		"!!ARBfp1.0\n"
		"TEX result.color, fragment.texcoord[0], texture[1], 2D;\n"
		"END\n";
	bool pass = true;
	GLuint tex;
	GLuint prog;

	texrect_w = piglit_width / 4 / 2;
	texrect_h = piglit_height / 2;

	glGenProgramsARB(1, &prog);
	glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, prog);
	glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB,
			   GL_PROGRAM_FORMAT_ASCII_ARB,
			   strlen(fp_source),
			   (const GLubyte *) fp_source);

	glEnable(GL_FRAGMENT_PROGRAM_ARB);

	glActiveTexture(GL_TEXTURE1);
	tex = piglit_rgbw_texture(GL_RGBA, 2, 2, false, false,
				  GL_UNSIGNED_NORMALIZED);

	/* Given that the failure mode we had that led to this test
	 * being written was that the sampler state read was
	 * pseudo-random, go through several statechanges on the
	 * sampler to make sure we're reliably getting our sampler
	 * state.
	 */
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	piglit_draw_rect_tex(-1, -1, 0.5, 2,
			     0, 0, 1, 1);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	piglit_draw_rect_tex(-0.5, -1, 0.5, 2,
			     0, 0, 1, 1);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	piglit_draw_rect_tex(0, -1, 0.5, 2,
			     0, 0, 1, 1);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	piglit_draw_rect_tex(0.5, -1, 0.5, 2,
			     0, 0, 1, 1);

	pass = pass && test_nearest(piglit_width * 0 / 4);
	pass = pass && test_linear(piglit_width * 1 / 4);
	pass = pass && test_nearest(piglit_width * 2 / 4);
	pass = pass && test_linear(piglit_width * 3 / 4);

	piglit_present_results();

	glDeleteTextures(1, &tex);
	glDisable(GL_FRAGMENT_PROGRAM_ARB);
	glDeleteProgramsARB(1, &prog);

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
Beispiel #3
0
enum piglit_result
piglit_display(void)
{
	float black[4] = {0.0, 0.0, 0.0, 0.0};
	float white[4] = {1.0, 1.0, 1.0, 0.0};
	float red[4] =   {1.0, 0.0, 0.0, 0.0};
	float green[4] = {0.0, 1.0, 0.0, 0.0};
	float blue[4] =  {0.0, 0.0, 1.0, 0.0};
	GLboolean pass = GL_TRUE;
	GLuint tex;

	tex = piglit_checkerboard_texture(0, /* name */
					  0, /* level */
					  2, 2, /* width/height */
					  1, 1, /* checkerboard size */
					  black, white);

	glEnable(GL_TEXTURE_2D);
	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

	glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, red);
	piglit_draw_rect_tex(-1, -1, 1, 1,
			     -2, -2, 0, 0);

	glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, green);
	piglit_draw_rect_tex( 0, -1, 1, 1,
			     -2, -2, 0, 0);

	glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, blue);
	piglit_draw_rect_tex(-1,  0, 1, 1,
			     -2, -2, 0, 0);

	glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, white);
	piglit_draw_rect_tex( 0,  0, 1, 1,
			     -2, -2, 0, 0);

	pass = piglit_probe_pixel_rgb(piglit_width * 1 / 4,
				      piglit_height * 1 / 4, red) && pass;
	pass = piglit_probe_pixel_rgb(piglit_width * 3 / 4,
				      piglit_height * 1 / 4, green) && pass;
	pass = piglit_probe_pixel_rgb(piglit_width * 1 / 4,
				      piglit_height * 3 / 4, blue) && pass;
	pass = piglit_probe_pixel_rgb(piglit_width * 3 / 4,
				      piglit_height * 3 / 4, white) && pass;

	glDeleteTextures(1, &tex);

	glutSwapBuffers();

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
Beispiel #4
0
enum piglit_result
piglit_display(void)
{
	bool pass = true;

	if (!piglit_check_gl_error(GL_NO_ERROR))
		piglit_report_result(PIGLIT_FAIL);

	/* Clear the whole first texture with green */
	glClearTexImage(texture[0], 0, GL_RGB, GL_FLOAT, green);
	pass &= piglit_check_gl_error(GL_NO_ERROR);

	/* Clear the left half of the second texture with blue */
	glClearTexSubImage(texture[1], 0,
			   0, 0, 0,
			   32, 64, 1,
			   GL_RGB, GL_FLOAT, blue);
	pass &= piglit_check_gl_error(GL_NO_ERROR);
	/* And the right half with yellow */
	glClearTexSubImage(texture[1], 0,
			   32, 0, 0,
			   32, 64, 1,
			   GL_RGB, GL_FLOAT, yellow);
	pass &= piglit_check_gl_error(GL_NO_ERROR);

	/* Render both textures to the screen */
	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);

	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, piglit_winsys_fbo);
	glEnable(GL_TEXTURE_2D);
	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

	glBindTexture(GL_TEXTURE_2D, texture[0]);
	piglit_draw_rect_tex(0, 0, 64, 64, 0, 0, 1, 1);

	glBindTexture(GL_TEXTURE_2D, texture[1]);
	piglit_draw_rect_tex(64, 0, 64, 64, 0, 0, 1, 1);

	glDisable(GL_TEXTURE_2D);
	glDeleteTextures(2, texture);

	/* Check for the 3 separate regions */
	pass &= piglit_probe_rect_rgb(0, 0, 64, 64, green);
	pass &= piglit_probe_rect_rgb(64, 0, 32, 64, blue);
	pass &= piglit_probe_rect_rgb(96, 0, 32, 64, yellow);

	piglit_present_results();

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
enum piglit_result
piglit_display(void)
{
	glBindFramebuffer(GL_FRAMEBUFFER, fbo);
	glClearColor(0,0,1,0);
	glClear(GL_COLOR_BUFFER_BIT);

	glAlphaFunc(GL_GEQUAL, 0.5f);
	glEnable(GL_ALPHA_TEST);

	glUseProgram(prog);
	glViewport(0, 0, 64, 64);
	piglit_draw_rect(-1, -1, 2, 2);

	glDisable(GL_ALPHA_TEST);

	/* visualize it */
	glUseProgram(0);
	glBindFramebuffer(GL_FRAMEBUFFER, piglit_winsys_fbo);
	glViewport(0, 0, 128, 64);
	glClearColor(0,0,0.5,0);
	glClear(GL_COLOR_BUFFER_BIT);

	glEnable(GL_TEXTURE_2D);

	glBindTexture(GL_TEXTURE_2D, color0);
	piglit_draw_rect_tex(-1, -1, 1, 2,
			0, 0, 1, 1);
	glBindTexture(GL_TEXTURE_2D, color1);
	piglit_draw_rect_tex(0, -1, 1, 2,
			0, 0, 1, 1);

	glDisable(GL_TEXTURE_2D);

	{
		bool pass = true;
		float red[] = {1,0,0};
		float green[] = {0,1,0};
		float blue[] = {0,0,1};
		pass = piglit_probe_pixel_rgb(4, 4, blue) && pass;
		pass = piglit_probe_pixel_rgb(12, 4, red) && pass;
		pass = piglit_probe_pixel_rgb(64 + 4, 4, blue) && pass;
		pass = piglit_probe_pixel_rgb(64 + 12, 4, green) && pass;

		piglit_present_results();

		return pass ? PIGLIT_PASS : PIGLIT_FAIL;
	}
}
Beispiel #6
0
enum piglit_result
piglit_display(void)
{
	static const GLfloat color[4] = { 0.0, 1.0, 0.0, 1.0 };
	enum piglit_result result = PIGLIT_PASS;
	unsigned i;

	glClear(GL_COLOR_BUFFER_BIT);

	for (i = 0; i < ARRAY_SIZE(progs); i++) {
		const int x = 1 + (i * (BOX_SIZE + 1));

		glBindProgramARB(GL_VERTEX_PROGRAM_ARB, progs[i]);
		glEnable(GL_CLIP_PLANE0 + i);
		piglit_draw_rect_tex(x, 1, BOX_SIZE, BOX_SIZE,
				     1.0, 1.0, -2.0, 0.0);
		glDisable(GL_CLIP_PLANE0 + i);

		if (!piglit_probe_pixel_rgb(x + (BOX_SIZE / 2),
					    1 + (BOX_SIZE / 2),
					    color)) {
			result = PIGLIT_FAIL;
		}
	}

	piglit_present_results();
	return result;
}
Beispiel #7
0
enum piglit_result
piglit_display(void)
{
	const int tile_size = BOX_SIZE / 4;
	GLboolean pass = GL_TRUE;
	unsigned i;

	glClear(GL_COLOR_BUFFER_BIT);

	for (i = 0; i < TEST_COLS; i++) { 
		const int x = 1 + ((BOX_SIZE + 2) * i);

		glUniform1f(bias_loc, (float) i);

		/* Draw the rectangle the same size as the texture.  This
		 * guarantees that the unbiased LOD will be 0.0.
		 */
		piglit_draw_rect_tex((float) x, 1.0,
				     BOX_SIZE, BOX_SIZE,
				     0.0, 0.0, 1.0, 1.0);

		/* The middle of the lower left tile should be green, and the
		 * middle of the tile next to it should be the clear color.
		 */
		if (!piglit_probe_pixel_rgb(x + (3 * tile_size / 2), 2, clear_color)
		    || !piglit_probe_pixel_rgb(x + (tile_size / 2), 2, green)) {
			pass = GL_FALSE;
		}
	}

	glutSwapBuffers();

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
Beispiel #8
0
static GLboolean
draw_and_test(int x_offset, int y_offset, float min_lod, float max_lod)
{
	GLfloat y;
	int dim;
	int level;
	GLboolean pass = GL_TRUE;

	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, max_lod);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, min_lod);

	y = y_offset;
	for (level = 0, dim = MAX_SIZE; dim > 0; level++, dim /= 2) {
		piglit_draw_rect_tex(x_offset, y, dim, dim,
				     0.0, 0.0, 1.0, 1.0);

		y += dim + PAD;
	}

	y = y_offset;
	for (level = 0, dim = MAX_SIZE; dim > 0; level++, dim /= 2) {
		pass = pass && test_results(x_offset, y,
					    dim, level,
					    min_lod, max_lod) && pass;

		y += dim + PAD;
	}

	return pass;
}
static enum piglit_result
draw(struct egl_state *state)
{
	EGLSurface *pixmap;
	EGLint inv;
	float red[] = { 0.4, 0.0, 0.0, 1.0 };
	float purple[] = { 0.5, 0.0, 0.5, 1.0 };
	enum piglit_result result = PIGLIT_PASS;

	if (!eglGetConfigAttrib(state->egl_dpy, state->cfg,
				EGL_Y_INVERTED_NOK, &inv)) {
		fprintf(stderr,
			"eglGetConfigAttrib(EGL_Y_INVERTED_NOK) failed\n");
		return PIGLIT_FAIL;
	}
	
	printf("EGL_Y_INVERTED_NOK: %s\n", inv ? "TRUE" : "FALSE");

	pixmap = egl_util_create_pixmap(state, 100, 100, pixmap_attribs);
	if (!eglMakeCurrent(state->egl_dpy, pixmap, pixmap, state->ctx)) {
		fprintf(stderr, "eglMakeCurrent() failed\n");
		piglit_report_result(PIGLIT_FAIL);
	}
	
	/* Clear pixmap to purple */
	glClearColor(0.5, 0.0, 0.5, 1.0);
	glClear(GL_COLOR_BUFFER_BIT);

	if (!eglMakeCurrent(state->egl_dpy,
			    state->surf, state->surf, state->ctx)) {
		fprintf(stderr, "eglMakeCurrent() failed\n");
		piglit_report_result(PIGLIT_FAIL);
	}

	glViewport(0, 0, state->width, state->height);
	piglit_ortho_projection(state->width, state->height, GL_FALSE);

	glClearColor(0.4, 0.0, 0.0, 1.0);
	glClear(GL_COLOR_BUFFER_BIT);

	glEnable(GL_TEXTURE_2D);
	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

	eglBindTexImage(state->egl_dpy, pixmap, EGL_BACK_BUFFER);
	piglit_draw_rect_tex(20, 20, 100, 100,  0, 0, 1, 1);

	if (!piglit_probe_pixel_rgba(10, 10, red) ||
	    !piglit_probe_pixel_rgba(50, 10, red) ||
	    !piglit_probe_pixel_rgba(10, 50, red) ||
	    !piglit_probe_pixel_rgba(50, 50, purple) ||
	    !piglit_probe_pixel_rgba(110, 110, purple) ||
	    !piglit_probe_pixel_rgba(130, 130, red))
		result = PIGLIT_FAIL;

	eglSwapBuffers(state->egl_dpy, state->surf);

	return result;
}
static int
test_etc1_rgb8_texture_8x8(const struct etc1_rgb8_texture_8x8 *tex)
{
    const GLenum format = GL_ETC1_RGB8_OES;
    const GLsizei width = 8, height = 8;
    unsigned x, y;
    int pass = GL_TRUE;

    glCompressedTexImage2D(GL_TEXTURE_2D, 0,
            format, width, height, 0, sizeof(tex->data), tex->data);
    pass = piglit_check_gl_error(GL_NO_ERROR) && pass;

    glEnable(GL_TEXTURE_2D);

    piglit_draw_rect_tex(0, 0, width, height, 0.0f, 0.0f, 1.0f, 1.0f);

    glDisable(GL_TEXTURE_2D);

    for (y = 0; y < height; y++) {
        for (x = 0; x < width; x++) {
            const GLubyte *rgb = tex->rgb[y * width + x];
            float expected[3] = {
                rgb[0] / 255.0f,
                rgb[1] / 255.0f,
                rgb[2] / 255.0f
            };

            pass = piglit_probe_pixel_rgb(x, y, expected) && pass;
        }
    }

    return pass;
}
static void
draw_rect(int pos)
{
	int x, y, w, h;
	get_rect_bounds(pos, &x, &y, &w, &h);
	piglit_draw_rect_tex(x, y, w, h, 0, 0, 1, 1);
}
/** Draw quad textured with depth image on right side of window */
static void
draw_quad_with_depth_texture(void)
{
   GLfloat s1, t1;

   if (TexTarget == GL_TEXTURE_2D) {
      s1 = t1 = 1.0;
   }
   else {
      s1 = SIZE;
      t1 = SIZE;
   }

   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, piglit_winsys_fbo);

   glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

   glViewport(2 * SIZE, 0, SIZE, SIZE);

   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   glOrtho(-1.0, 1.0, -1.0, 1.0, -1, 1.0);

   glBindTexture(TexTarget, DepthTex);
   glEnable(TexTarget);

   piglit_draw_rect_tex(-1, -1, 2, 2, 0, 0, s1, t1);

   glDisable(TexTarget);
}
Beispiel #13
0
enum piglit_result
piglit_display(void)
{
	glEnable(GL_TEXTURE_2D);

	glBindTexture(GL_TEXTURE_2D, rgba_tex);
	piglit_draw_rect_tex(-1.0, -1.0, 1.0, 2.0,
			     0.0, 0.0, 1.0, 1.0);

	glBindTexture(GL_TEXTURE_2D, other_tex);
	piglit_draw_rect_tex(0.0, -1.0, 1.0, 2.0,
			     0.0, 0.0, 1.0, 1.0);

	piglit_present_results();

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
Beispiel #14
0
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;
}
Beispiel #15
0
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;
	int tex_size = 64;
	int i;

	glClearColor(0.5, 0.5, 0.5, 0.5);
	glClear(GL_COLOR_BUFFER_BIT);

	/* Set up a texture object with green at level 0, red elsewhere */
	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);

	for (i = 0; tex_size / (1 << i) > 0; i++)
		fill_level(i, tex_size / (1 << i), i == 0 ? green : red);

	glGenQueries(1, &q);

	/* Generate query fail. */
	glBeginQuery(GL_SAMPLES_PASSED, q);
	glEndQuery(GL_SAMPLES_PASSED);

	/* Mipmap generation should not be affected by conditional rendering. */
	glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV);
	glGenerateMipmapEXT(GL_TEXTURE_2D);
	glEndConditionalRenderNV();

	/* This should draw level 1, since starting window size is 32
	 * and texture is 64.
	 */
	glEnable(GL_TEXTURE_2D);
	piglit_draw_rect_tex(-1, -1, 2, 2,
			     0, 0, 1, 1);
	glDisable(GL_TEXTURE_2D);

	pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,
				      green);

	glutSwapBuffers();

	glDeleteQueries(1, &q);

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
Beispiel #16
0
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;
}
Beispiel #17
0
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*2, 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);
	glCopyTexSubImage2D(GL_TEXTURE_2D, 0, piglit_width, 0, 0, 0, piglit_width, piglit_height / 2);
	glEndConditionalRenderNV();

	/* Draw the right half of the texture. */
	glEnable(GL_TEXTURE_2D);
	piglit_draw_rect_tex(-1, 0, 2, 1,
			     0.5, 0, 1, 1);
	glDisable(GL_TEXTURE_2D);

	pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,
				      green);

	glutSwapBuffers();

	glDeleteQueries(1, &q);

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
Beispiel #18
0
enum piglit_result
piglit_display(void)
{
	bool pass = true;

	pass &= run_all_factor_sets();
	
	if (!piglit_automatic) {
		/* 
		 * Draw our three images, separated by some space. 
		 * This will show only the results of the last test.
		 */

		/* Draw dst */
		glEnable(GL_TEXTURE_2D);
		glBindTexture(GL_TEXTURE_2D, dst_img.name);
		piglit_draw_rect_tex(0, 0, img_width, img_height, 0, 0, 1, 1);

		/* Draw src */
		glBindTexture(GL_TEXTURE_2D, src_img.name);
		piglit_draw_rect_tex(img_width + 2, 0, 
			img_width, img_height, 0, 0, 1, 1);

		/* Draw exp */
		glBindTexture(GL_TEXTURE_2D, exp_img.name);
		/* Have to resend the texture to GL to update GL's copy */
		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
			     img_width, img_height, 0, 
			     GL_RGBA, GL_FLOAT, exp_img.data);
		piglit_draw_rect_tex(2*(img_width + 2), 0, 
			img_width, img_height, 0, 0, 1, 1);
		glDisable(GL_TEXTURE_2D);
		
		piglit_present_results();
	}


	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
} /* piglit_display */
Beispiel #19
0
static void
draw_mipmap(int x, int y, int dim)
{
	glEnable(GL_TEXTURE_2D);
	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

	piglit_draw_rect_tex(x, y, dim, dim,
			     0, 0, 1, 1);

	glDisable(GL_TEXTURE_2D);
}
enum piglit_result
piglit_display(void)
{
	glBindFramebuffer(GL_FRAMEBUFFER, fbo);
	glClearColor(0,0,1,0);
	glClear(GL_COLOR_BUFFER_BIT);

	glAlphaFunc(GL_GEQUAL, 0.5f);
	glEnable(GL_ALPHA_TEST);

	glUseProgram(prog);
	glViewport(0, 0, 64, 64);
	piglit_draw_rect(-1, -1, 2, 2);

	glDisable(GL_ALPHA_TEST);

	/* Visualize it */
	glUseProgram(0);
	glBindFramebuffer(GL_FRAMEBUFFER, piglit_winsys_fbo);
	glViewport(0, 0, 128, 64);
	glClearColor(0,0,0.5,0);
	glClear(GL_COLOR_BUFFER_BIT);

	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, color1);
	piglit_draw_rect_tex(-1, -1, 1, 2,
			0, 0, 1, 1);
	glBindTexture(GL_TEXTURE_2D, color2);
	piglit_draw_rect_tex(0, -1, 1, 2,
			0, 0, 1, 1);
	glDisable(GL_TEXTURE_2D);
	piglit_present_results();

	/* The fragment colors are undefined in this test. So, we can't probe the
	 * pixels. If test executes to completion, return PIGLIT_PASS.
	 */
	return PIGLIT_PASS;
}
static void
display_mipmaps(int x, int y)
{
	int i;

	glEnable(GL_TEXTURE_2D);

	/* Disply all the mipmap levels */
	for (i = SIZE; i > 0; i /= 2) {
		piglit_draw_rect_tex(x, y, i, i,
				     0, 0, 1, 1);

		x += i + 5;
	}
}
Beispiel #22
0
static void
draw_mipmap(int x, int y, int dim)
{
	glViewport(0, 0, piglit_width, piglit_height);
	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);

	glEnable(GL_TEXTURE_2D);
	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

	piglit_draw_rect_tex(x, y, dim, dim,
			     0, 0, 1, 1);
	glDisable(GL_TEXTURE_2D);
}
enum piglit_result
piglit_display(void)
{
	unsigned i;

	for (i = 0; i < num_tex; i++) {
		glBindTexture(GL_TEXTURE_2D, tex[i]);

		piglit_draw_rect_tex(-1.0 + ((float) (2 * i) / num_tex), -1.0,
				     2.0 / num_tex, 2.0,
				     0.0, 0.0, 1.0, 1.0);
	}

	piglit_present_results();
	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
Beispiel #24
0
enum piglit_result
piglit_display(void)
{
	int pass;

	glClearColor(0.0, 0.0, 0.0, 1.0);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glEnable(GL_TEXTURE_2D);
	glBindTextureUnit(0, name);
	piglit_draw_rect_tex(0, 0, 1, 1, 0, 0, 1, 1);

	piglit_present_results();

	pass = test_getteximage();

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
Beispiel #25
0
static void draw_fbo_1d(int x, int y)
{
	glViewport(0, 0, piglit_width, piglit_height);
	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);

	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, piglit_winsys_fbo);

	glEnable(GL_TEXTURE_1D);
	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
	glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
	glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
	glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);

	piglit_draw_rect_tex(x, y, BUF_WIDTH, 1,
			     0, 0, 1, 1);
}
enum piglit_result piglit_display(void)
{
	GLboolean pass = GL_TRUE;
	float black[] = {0, 0, 0, 0};
	float white[] = {1, 1, 1, 1};
	GLuint tex;

	glClearColor(0.0, 1.0, 0.0, 0.0);
	glClear(GL_COLOR_BUFFER_BIT);

	create_fbo(&tex);

	glBindTexture(GL_TEXTURE_2D, tex);
	glViewport(0, 0, piglit_width, piglit_height);

	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, piglit_winsys_fbo);

	glEnable(GL_TEXTURE_2D);
	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	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_WRAP_R, GL_CLAMP_TO_EDGE);
	glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY);

	piglit_draw_rect_tex(-1, -1, 2, 2,
			     0, 0, 1, 1);

	glDisable(GL_TEXTURE_2D);

	pass = pass && piglit_probe_rect_rgba(0, 0,
					      piglit_width / 2, piglit_height,
					      black);
	pass = pass && piglit_probe_rect_rgba(piglit_width / 2, 0,
					      piglit_width / 2, piglit_height,
					      white);

	glDeleteTextures(1, &tex);

	piglit_present_results();

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
/*
 * Texture using thread: draws with successive textures and checks that the
 * correct color is drawn.  Return NULL on failure, else non-NULL.
 */
static void *
draw_func(void *arg)
{
    int count = 0;
    int ret;

    ret = glXMakeCurrent(dpy, draw_win, draw_ctx);
    assert(ret);

    piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);

    glEnable(GL_TEXTURE_2D);
    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

    while (!quit && count < num_test) {
        struct texture *tex = advance(&count, DRAW);
        float expect[] = {
            tex->color / 255.,
            tex->color / 255.,
            tex->color / 255.,
        };

        assert(tex->user == DRAW);

        glBindTexture(GL_TEXTURE_2D, tex->id);
        piglit_draw_rect_tex(0, 0, piglit_width, piglit_height,
                             0, 0, 1, 1);
        glXSwapBuffers(dpy, draw_win);

        /* first texture not filled so don't check it */
        if (count > 0 &&
                !piglit_probe_rect_rgb(0, 0, piglit_width,
                                       piglit_height, expect)) {
            break;
        }
    }

    if (count < num_test) {
        quit = true;
        return NULL;
    }

    return "";
}
Beispiel #28
0
static bool
check_rendering_(int width, int height, int line)
{
	const int w = width / 2 - 2;
	const int h = height / 2 - 2;
	bool pass = true;

	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);

	glClear(GL_COLOR_BUFFER_BIT);

	glEnable(GL_TEXTURE_2D);
	glColor3f(1, 1, 1);

	/* draw the texture */
	piglit_draw_rect_tex(0, 0, width, height, 0, 0, 1, 1);

	/* NOTE: don't probe the border pixels of the quadrants just to
	 * avoid potential off-by one errors.
	 */

	/* lower-left red */
	pass = piglit_probe_rect_rgb(1, 1, w, h, red) && pass;

	/* lower-right green */
	pass = piglit_probe_rect_rgb(width/2 + 1, 1, w, h, green) && pass;

	/* upper-left blue */
	pass = piglit_probe_rect_rgb(1, height/2 + 1, w, h, blue) && pass;

	/* upper-right white */
	pass = piglit_probe_rect_rgb(width/2 + 1, height/2 + 1,
				     w, h, white) && pass;

	piglit_present_results();

	if (!pass) {
		printf("s3tc-errors failure at line %d\n", line);
	}

	return pass;
}
Beispiel #29
0
enum piglit_result
piglit_display(void)
{
	GLboolean pass = GL_TRUE;

	glColor4fv(green);
	piglit_draw_rect_tex(0.0, 0.0,
			     (float) piglit_width, (float) piglit_height,
			     0.0, 0.0, 1.0, 1.0);

	pass &= piglit_probe_pixel_rgb(0, 0, black);
	pass &= piglit_probe_pixel_rgb(piglit_width - 1, 0, green);
	pass &= piglit_probe_pixel_rgb(0, piglit_height - 1, green);
	pass &= piglit_probe_pixel_rgb(piglit_width - 1, piglit_height - 1,
				       black);

	piglit_present_results();

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
static void
draw_level(int x, int y, int level)
{
	int loc;

	glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_LOD, level);
	glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAX_LOD, level);

	glUseProgram(prog);
	loc = glGetUniformLocation(prog, "tex");
	glUniform1i(loc, 0); /* texture unit p */

	glViewport(0, 0, piglit_width, piglit_height);
	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);

	glBindFramebuffer(GL_FRAMEBUFFER, piglit_winsys_fbo);

	piglit_draw_rect_tex(x, y, TEX_SIZE, 5, 0, 0, 1, 1);
	glUseProgram(0);
}