Ejemplo n.º 1
0
static GLboolean
draw(GLuint vs, GLuint fs, int num_xfb_varyings,
     int max_varyings, const char **xfb_varyings)
{
	GLboolean pass = GL_TRUE;
	int offset;

	for (offset = 0; offset + num_xfb_varyings <= max_varyings; ++offset) {
		GLuint prog;
		float initial_buffer[MAX_VARYING * 6][4];

		prog = glCreateProgram();
		glAttachShader(prog, vs);
		glAttachShader(prog, fs);

		glTransformFeedbackVaryings(prog, num_xfb_varyings,
					    xfb_varyings + offset,
					    GL_INTERLEAVED_ATTRIBS);

		glLinkProgram(prog);
		if (!piglit_link_check_status(prog))
			piglit_report_result(PIGLIT_FAIL);

		glUseProgram(prog);

		glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, xfb_buf);
		memset(initial_buffer, 0, sizeof(initial_buffer));
		glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER,
			     sizeof(initial_buffer), initial_buffer,
			     GL_STREAM_READ);
		glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, xfb_buf);
		glBeginTransformFeedback(GL_TRIANGLES);

		piglit_draw_rect(coord_from_index(offset),
				 coord_from_index(num_xfb_varyings - 1),
				 10,
				 10);

		glEndTransformFeedback();
		pass = check_xfb_output(max_varyings, num_xfb_varyings,
			  offset, xfb_varyings);

		glDeleteProgram(prog);
		if (!pass) {
			break;
		}
	}

	return pass;
}
Ejemplo n.º 2
0
static GLboolean
run_subtest(GLuint vs, GLuint fs, int max_xfb_varyings,
            int max_varyings, const char **xfb_varyings)
{
	GLboolean pass = GL_TRUE;
	int row, col;

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

	for (row = 0; row < max_xfb_varyings; row++) {
		pass = draw(vs, fs, row + 1, max_varyings, xfb_varyings);
		if (!pass) {
			goto end;
		}
	}

	for (row = 0; row < max_xfb_varyings; row++) {
		for (col = 0; col < max_varyings - row; col++) {
			GLboolean ok;
			float green[3] = {0.0, 1.0, 0.0};

			ok = piglit_probe_rect_rgb(coord_from_index(col),
						   coord_from_index(row),
						   10, 10,
						   green);
			if (!ok) {
				printf("  Failure with %d vec4 varyings"
				       " captured and offset %d\n",
				       row + 1, col);
				pass = GL_FALSE;
				goto end;
			}
		}
	}
end:
	return pass;
}
Ejemplo n.º 3
0
enum piglit_result
piglit_display(void)
{
	GLint max_components;
	int max_varyings, row, col;
	int max_xfb_varyings = 0;
	GLint max_xfb_components;
	GLboolean pass = GL_TRUE, warned = GL_FALSE;
	GLuint vs, fs;

	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);

	glGetIntegerv(GL_MAX_VARYING_FLOATS, &max_components);
	max_varyings = max_components / 4;

	printf("GL_MAX_VARYING_FLOATS = %i\n", max_components);

	if (max_varyings > MAX_VARYING) {
		printf("test not designed to handle >%d varying vec4s.\n"
		       "(implementation reports %d components)\n",
		       max_components, MAX_VARYING);
		max_varyings = MAX_VARYING;
		warned = GL_TRUE;
	}

	glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS,
		      &max_xfb_components);
	max_xfb_varyings = MIN2(max_xfb_components / 4, max_varyings);

	printf("GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS = %i\n",
	       max_xfb_components);

	vs = get_vs(max_varyings);
	fs = get_fs(max_varyings);

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

	for (row = 0; row < max_xfb_varyings; row++) {
		pass = draw(vs, fs, row + 1, max_xfb_varyings) && pass;
	}

	for (row = 0; row < max_varyings; row++) {
		for (col = 0; col < max_varyings - row; col++) {
			GLboolean ok;
			float green[3] = {0.0, 1.0, 0.0};

			ok = piglit_probe_rect_rgb(coord_from_index(col),
						   coord_from_index(row),
						   10, 10,
						   green);
			if (!ok) {
				printf("  Failure with %d vec4 varyings"
				       " captured and offset %d\n",
				       row + 1, col);
				pass = GL_FALSE;
				break;
			}
		}
	}

	piglit_present_results();

	if (!pass)
		return PIGLIT_FAIL;
	if (warned)
		return PIGLIT_WARN;
	else
		return PIGLIT_PASS;
}
Ejemplo n.º 4
0
enum piglit_result
piglit_display(void)
{
	GLint max_components;
	int test_varyings, row, col;
	GLboolean pass = GL_TRUE, warned = GL_FALSE;
	bool drew[MAX_VARYING];

	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);

	glGetIntegerv(GL_MAX_VARYING_FLOATS, &max_components);
	max_varyings = max_components / 4;

	printf("GL_MAX_VARYING_FLOATS = %i\n", max_components);

	test_varyings = max_varyings;
	if (exceed_limits)
		test_varyings++;
	if (test_varyings > MAX_VARYING) {
		printf("test not designed to handle >%d varying vec4s.\n"
		       "(implementation reports %d components)\n",
		       MAX_VARYING, max_varyings);
		test_varyings = MAX_VARYING;
		warned = GL_TRUE;
	}

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

	for (row = 0; row < test_varyings; row++) {
		drew[row] = draw(row + 1);
	}

	for (row = 0; row < test_varyings; row++) {
		if (!drew[row])
			continue;

		for (col = 0; col <= row; col++) {
			GLboolean ok;
			float green[3] = {0.0, 1.0, 0.0};

			ok = piglit_probe_rect_rgb(coord_from_index(col),
						   coord_from_index(row),
						   2, 2,
						   green);
			if (!ok) {
				printf("  Failure with %d vec4 varyings used "
				       "in varying index %d\n",
				       row + 1, col);
				pass = GL_FALSE;
				break;
			}
		}
	}

	piglit_present_results();

	if (!pass)
		return PIGLIT_FAIL;
	if (warned)
		return PIGLIT_WARN;
	else
		return PIGLIT_PASS;
}
Ejemplo n.º 5
0
static bool
draw(int num_varyings)
{
	int data_varying;
	float vertex[4][4] = { {0.0, 0.0, 0.0, 1.0},
			       {0.0, 0.0, 0.0, 1.0},
			       {0.0, 0.0, 0.0, 1.0},
			       {0.0, 0.0, 0.0, 1.0} };
	float green[4][4] = { {0.0, 1.0, 0.0, 0.0},
			      {0.0, 1.0, 0.0, 0.0},
			      {0.0, 1.0, 0.0, 0.0},
			      {0.0, 1.0, 0.0, 0.0} };
	float red[4][4] = { {1.0, 0.0, 0.0, 0.0},
			    {1.0, 0.0, 0.0, 0.0},
			    {1.0, 0.0, 0.0, 0.0},
			    {1.0, 0.0, 0.0, 0.0} };

	glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(float),
			      vertex);
	glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(float),
			      green);
	glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(float),
			      red);
	glEnableVertexAttribArray(0);
	glEnableVertexAttribArray(1);
	glEnableVertexAttribArray(2);

	for (data_varying = 0; data_varying < num_varyings; data_varying++) {
		GLuint prog, vs, fs;
		GLint loc;
		float x, y;

		vs = get_vs(num_varyings, data_varying);
		fs = get_fs(num_varyings, data_varying);

		prog = glCreateProgram();
		glAttachShader(prog, vs);
		glAttachShader(prog, fs);

		glBindAttribLocation(prog, 0, "vertex");
		glBindAttribLocation(prog, 1, "green");
		glBindAttribLocation(prog, 2, "red");

		glLinkProgram(prog);
		if (!piglit_link_check_status_quiet(prog)) {
			if (num_varyings > max_varyings) {
				printf("Failed to link with %d out of %d "
				       "varyings used\n",
				       num_varyings, max_varyings);
				return false;
			} else {
				piglit_report_result(PIGLIT_FAIL);
			}
		}

		glUseProgram(prog);

		loc = glGetUniformLocation(prog, "zero");
		if (loc != -1) /* not used for num_varyings == 1 */
			glUniform1f(loc, 0.0);

		loc = glGetUniformLocation(prog, "one");
		assert(loc != -1); /* should always be used */
		glUniform1f(loc, 1.0);

		x = coord_from_index(data_varying);
		y = coord_from_index(num_varyings - 1);
		vertex[0][0] = x;
		vertex[0][1] = y;
		vertex[1][0] = x + 2;
		vertex[1][1] = y;
		vertex[2][0] = x;
		vertex[2][1] = y + 2;
		vertex[3][0] = x + 2;
		vertex[3][1] = y + 2;
		glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

		glDeleteShader(vs);
		glDeleteShader(fs);
		glDeleteProgram(prog);
	}

	return true;
}