Ejemplo n.º 1
0
static void
clear_buffer(int i, unsigned offset, unsigned size, unsigned char value, char *cpu)
{
	glClearBufferSubData(GL_ARRAY_BUFFER, GL_R8, offset, size,
			     GL_RED, GL_UNSIGNED_BYTE, &value);
	memset(cpu+offset, value, size);

	if (debug && !check_array_buffer_data(SIZE, cpu)) {
		printf("Clear %i failed: offset=%i (%%4 = %i), size=%i (%%4 = %i)\n",
		       i, offset, offset % 4, size, size % 4);
		piglit_report_result(PIGLIT_FAIL);
	}
}
Ejemplo n.º 2
0
void
piglit_init(int argc, char **argv)
{
	bool pass = true;
	GLuint buffer;
	int i;
	unsigned offset, size;
	char *cpu = malloc(SIZE);

	if (!cpu)
		piglit_report_result(PIGLIT_FAIL);

	for (i = 1; i < argc; i++)
		if (!strcmp(argv[i], "-debug"))
			debug = true;

	piglit_require_extension("GL_ARB_clear_buffer_object");
	glGenBuffers(1, &buffer);
	glBindBuffer(GL_ARRAY_BUFFER, buffer);
	glBufferData(GL_ARRAY_BUFFER, SIZE, NULL, GL_STREAM_READ);

	clear_buffer(0, 0, SIZE, 0, cpu);

	srand(6487216);
	for (i = 1; i <= 200; i++) {
		offset = rand() % SIZE;
		size = 1 + (rand() % (SIZE - offset));

		clear_buffer(i, offset, size, rand(), cpu);
	}

	/* and some small unaligned copies within one dword */
	for (; i < 230; i++) {
		offset = (rand() % (SIZE/4)) * 4 + 1 + (rand() % 2);
		size = 1;

		clear_buffer(i, offset, size, rand(), cpu);
	}

	pass = piglit_check_gl_error(GL_NO_ERROR) &&
	       check_array_buffer_data(SIZE, cpu);
	glDeleteBuffers(1, &buffer);
	free(cpu);
	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
}
Ejemplo n.º 3
0
PIGLIT_GL_TEST_CONFIG_END


void
piglit_init(int argc, char **argv)
{
	bool pass = true;
	const int buffer_size = 1<<20;
	unsigned int buffer;
	static const char *const data_zero = "\x00\x00\x00\x00";
	static const char *const data_init = "\xff\xff\xff\xff"
					     "\xff\xff\xff\xff"
					     "\x00\x00\x00\x00"
					     "\x00\x00\x00\x00"
					     "\x55\x55\x55\x55"
					     "\x55\x55\x55\x55"
					     "\xaa\xaa\xaa\xaa"
					     "\xaa\xaa\xaa\xaa"
					     "\xff\x00\xff\x00"
					     "\xff\x00\xff\x00"
					     "\x00\xff\x00\xff"
					     "\x00\xff\x00\xff"
					     "\x91\xcc\x45\x36"
					     "\xd3\xe4\xe3\x5b"
					     "\x79\x1e\x21\x39"
					     "\xa8\xfa\x69\x6a";

	piglit_require_extension("GL_ARB_clear_buffer_object");

	glGenBuffers(1, &buffer);
	glBindBuffer(GL_ARRAY_BUFFER, buffer);
	glBufferData(GL_ARRAY_BUFFER, buffer_size, NULL, GL_STREAM_READ);
	fill_array_buffer(64, data_init);

	glClearBufferData(GL_ARRAY_BUFFER, GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE,
			NULL);
	pass = check_array_buffer_data(4, data_zero) && pass;

	glBindBuffer(GL_ARRAY_BUFFER, 0);
	glDeleteBuffers(1, &buffer);

	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;

	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
}
Ejemplo n.º 4
0
static bool
test_format(const int i)
{
	static const char *const data_7f   = "\x7f\x7f\x7f\x7f"
					     "\x7f\x7f\x7f\x7f"
					     "\x7f\x7f\x7f\x7f"
					     "\x7f\x7f\x7f\x7f"
					     "\x7f\x7f\x7f\x7f"
					     "\x7f\x7f\x7f\x7f"
					     "\x7f\x7f\x7f\x7f"
					     "\x7f\x7f\x7f\x7f"
					     "\x7f\x7f\x7f\x7f"
					     "\x7f\x7f\x7f\x7f"
					     "\x7f\x7f\x7f\x7f"
					     "\x7f\x7f\x7f\x7f"
					     "\x7f\x7f\x7f\x7f"
					     "\x7f\x7f\x7f\x7f"
					     "\x7f\x7f\x7f\x7f"
					     "\x7f\x7f\x7f\x7f"
					     "\x7f\x7f\x7f\x7f"
					     "\x7f\x7f\x7f\x7f"
					     "\x7f\x7f\x7f\x7f"
					     "\x7f\x7f\x7f\x7f"
					     "\x7f\x7f\x7f\x7f"
					     "\x7f\x7f\x7f\x7f"
					     "\x7f\x7f\x7f\x7f"
					     "\x7f\x7f\x7f\x7f"
					     "\x7f\x7f\x7f\x7f"
					     "\x7f\x7f\x7f\x7f"
					     "\x7f\x7f\x7f\x7f"
					     "\x7f\x7f\x7f\x7f"
					     "\x7f\x7f\x7f\x7f"
					     "\x7f\x7f\x7f\x7f"
					     "\x7f\x7f\x7f\x7f"
					     "\x7f\x7f\x7f\x7f";
	static const char *const data_init = "\xff\xff\xff\xff"
					     "\xff\xff\xff\xff"
					     "\x00\x00\x00\x00"
					     "\x00\x00\x00\x00"
					     "\x55\x55\x55\x55"
					     "\x55\x55\x55\x55"
					     "\xaa\xaa\xaa\xaa"
					     "\xaa\xaa\xaa\xaa"
					     "\xff\x00\xff\x00"
					     "\xff\x00\xff\x00"
					     "\x00\xff\x00\xff"
					     "\x00\xff\x00\xff"
					     "\x91\xcc\x45\x36"
					     "\xd3\xe4\xe3\x5b"
					     "\x79\x1e\x21\x39"
					     "\xa8\xfa\x69\x6a";


	if (piglit_is_core_profile && !formats[i].core_profile)
		return true;
	/* All required extensions are included in GL 3.0. */
	if (piglit_get_gl_version() < 30) {
		int j;
		for (j = 0; j < 3; ++j)
			if (formats[i].ext[j])
				if (!piglit_is_extension_supported(
							formats[i].ext[j]))
					return true;
	}

	printf("Testing %s... ",
			piglit_get_gl_enum_name(formats[i].internal_format));
	fill_array_buffer(64, data_init);
	glClearBufferData(GL_ARRAY_BUFFER, formats[i].internal_format,
			formats[i].format, formats[i].type, data_7f);

	if (!piglit_check_gl_error(GL_NO_ERROR) ||
			!check_array_buffer_data(formats[i].size, data_7f)) {
		printf("Failed!\n");
		return false;
	}
	printf("Passed.\n");
	return true;
}