void piglit_init(int argc, char **argv)
{
	int mask;

	printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));

	piglit_require_fragment_program();

	/*
	 * Fragment programs
	 */
	for(mask = 1; mask < 16; ++mask) {
		char programText[1024];
		char maskstring[5];

		maskstring[0] = 0;
		if (mask & 1) strcat(maskstring, "x");
		if (mask & 2) strcat(maskstring, "y");
		if (mask & 4) strcat(maskstring, "z");
		if (mask & 8) strcat(maskstring, "w");
		sprintf(programText, fragProgramTemplate, maskstring);

		FragProg[mask-1] = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, programText);
	}

	piglit_ortho_projection(4.0, 4.0, GL_FALSE);
}
Exemple #2
0
void
piglit_init(int argc, char **argv)
{
	unsigned i;

	(void) argc;
	(void) argv;

	piglit_require_fragment_program();
	piglit_require_extension("GL_NV_fragment_program_option");
	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);

	reference_prog = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB,
						reference_shader_source);

	for (i = 0; i < ARRAY_SIZE(tests); i++) {
		char shader_source[512];

		sprintf(shader_source, shader_template, tests[i].opcode);
		progs[i] = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB,
						  shader_source);
	}


	glClearColor(0.5, 0.5, 0.5, 1.0);
}
Exemple #3
0
void
piglit_init(int argc, char **argv)
{
	static const char components[] = "xyzw";
	unsigned i;

	(void) argc;
	(void) argv;

	piglit_require_vertex_program();
	piglit_require_fragment_program();
	piglit_require_extension("GL_NV_vertex_program2_option");
	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);

	for (i = 0; i < ARRAY_SIZE(progs); i++) {
		char shader_source[1024];

		snprintf(shader_source, sizeof(shader_source),
			 vertex_source_template,
			 components[i + 0],
			 components[i + 2]);

		progs[i] = piglit_compile_program(GL_VERTEX_PROGRAM_ARB,
						  shader_source);
	}

	glEnable(GL_FRAGMENT_PROGRAM_ARB);
	glEnable(GL_VERTEX_PROGRAM_ARB);
	glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, piglit_ARBfp_pass_through);

	glClearColor(0.5, 0.5, 0.5, 1.0);
}
Exemple #4
0
void
piglit_init(int argc, char **argv)
{
	unsigned i;

	(void) argc;
	(void) argv;

	piglit_require_vertex_program();
	piglit_require_fragment_program();
	piglit_require_extension("GL_NV_vertex_program2_option");
	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);

	for (i = 0; i < ARRAY_SIZE(progs); i++) {
		char shader_source[1024];

		snprintf(shader_source, sizeof(shader_source),
			 vertex_source_template);

		progs[i] = piglit_compile_program(GL_VERTEX_PROGRAM_ARB,
						  shader_source);
	}

	glEnable(GL_FRAGMENT_PROGRAM_ARB);
	glEnable(GL_VERTEX_PROGRAM_ARB);

	frag_prog = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB,
					   fragment_source);
	glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, frag_prog);

	glClearColor(clear_color[0],
		     clear_color[1],
		     clear_color[2],
		     clear_color[3]);
}
void
piglit_init(int argc, char **argv)
{
	piglit_require_fragment_program();

	glEnable(GL_FRAGMENT_PROGRAM_ARB);

	printf("Maximum tex instructions: %d\n",
	       get_program_i(GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB));
	printf("Maximum native tex instructions: %d\n",
	       get_program_i(GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB));
	printf("Maximum tex indirections: %d\n",
	       get_program_i(GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB));
	printf("Maximum native tex indirections: %d\n",
	       get_program_i(GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB));

	/* If the GL reports more than 10000 texture indirections, then we're probably
	 * running on hardware with no limitations - the driver just picked some
	 * arbitrary large number to report back.  The test isn't meaningful, and
	 * the run time explodes with huge limits, so just skip it.
	 *
	 * For reference, Mesa and NVIDIA report 16384; AMD reports 2147483647.
	 * Pineview hardware (where this test is relevant) has a limit of 4.
	 */
	if (get_program_i(GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB) > 10000) {
		printf("Skipping; the hardware doesn't appear to have real limits.\n");
		piglit_report_result(PIGLIT_SKIP);
	}
}
Exemple #6
0
void
piglit_init(int argc, char **argv)
{
	int i;

	printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));

	piglit_require_fragment_program();

	for(i = 0; i < NUM_PROGRAMS; ++i)
		FragProg[i] = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, ProgramText[i]);

	piglit_gen_ortho_projection(0.0, 3.0, 0.0, 2.0, -2.0, 6.0, GL_FALSE);
}
Exemple #7
0
void
piglit_init(int argc, char **argv)
{
    unsigned i;
    float v[TEST_COLS * 3 ];

    (void) argc;
    (void) argv;

    piglit_require_fragment_program();
    piglit_require_extension("GL_NV_fragment_program_option");
    piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);

    reference_prog = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB,
                                            reference_shader_source);

    glClearColor(1.0, 1.0, 1.0, 1.0);

    for (i = 0; i < ARRAY_SIZE(types); i++) {
        generate_shader(types[i]);
        progs[i] = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB,
                                          shader_source);
    }


    /* Generate the possible color values.
     */
    for (i = 0; i <= 127; i++) {
        v[i] = ((float) i) / 127.0;
    }

    for (/* empty */; i < ARRAY_SIZE(v); i++) {
        v[i] = 0.5;
    }


    /* Shuffle the values into random order.  Generate the color data
     * used by the tests from the shuffled values.
     */
    shuffle(v, 128);
    for (i = 0; i < TEST_COLS; i++) {
        assert((i * 3) + 2 < ARRAY_SIZE(v));

        colors[i][0] = v[(i * 3) + 0];
        colors[i][1] = v[(i * 3) + 1];
        colors[i][2] = v[(i * 3) + 2];
        colors[i][3] = 1.0;
    }
}
Exemple #8
0
void
piglit_init(int argc, char **argv)
{
    piglit_require_fragment_program();

    glEnable(GL_FRAGMENT_PROGRAM_ARB);

    printf("Maximum tex instructions: %d\n",
           get_program_i(GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB));
    printf("Maximum native tex instructions: %d\n",
           get_program_i(GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB));
    printf("Maximum tex indirections: %d\n",
           get_program_i(GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB));
    printf("Maximum native tex indirections: %d\n",
           get_program_i(GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB));
}
Exemple #9
0
void
piglit_init(int argc, char **argv)
{
	int i;

	printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));

	glutReshapeFunc(Reshape);

	piglit_require_fragment_program();

	for(i = 0; i < NUM_PROGRAMS; ++i)
		FragProg[i] = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, ProgramText[i]);

	Reshape(piglit_width, piglit_height);
}
Exemple #10
0
void
piglit_init(int argc, char **argv)
{
	(void) argc;
	(void) argv;

	piglit_require_vertex_program();
	piglit_require_fragment_program();
	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);

	progs[0] = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB,
					  cos_shader_source);
	progs[1] = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB,
					  sge_shader_source);

	vert_prog = piglit_compile_program(GL_VERTEX_PROGRAM_ARB,
					   vert_shader_source);

	glClearColor(0.5, 0.5, 0.5, 1.0);
}
Exemple #11
0
void
piglit_init(int argc, char **argv)
{
	int i, x, y;
	GLuint texname;
	GLubyte tex[4][4][4];

	piglit_require_gl_version(13);

	printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));

	piglit_require_fragment_program();

	/*
	 * Fragment programs
	 */
	for(i = 0; i < NUM_PROGRAMS; ++i)
		FragProg[i] = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, ProgramText[i]);

	/*
	 * Textures
	 */
	for(y = 0; y < 4; ++y) {
		for(x = 0; x < 4; ++x) {
			tex[y][x][0] = (x & 1) ? 255 : 0;
			tex[y][x][1] = (x & 2) ? 255 : 0;
			tex[y][x][2] = (y & 1) ? 255 : 0;
			tex[y][x][3] = (y & 2) ? 255 : 0;
		}
	}

	glGenTextures(1, &texname);
	glActiveTexture(GL_TEXTURE0);
	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, texname);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0,
	             GL_RGBA, GL_UNSIGNED_BYTE, tex);

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
}
Exemple #12
0
void
piglit_init(int argc, char **argv)
{
	const GLfloat alpha_data[] = { 0.5 };

	(void) argc;
	(void) argv;

	piglit_require_fragment_program();
	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);

	progs[0] = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB,
					  alpha_source);

	glGenTextures(1, textures);

	glActiveTexture(GL_TEXTURE0);
	glBindTexture(GL_TEXTURE_2D, textures[0]);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 1, 1, 0, GL_ALPHA, GL_FLOAT, alpha_data);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

	glClearColor(1.0, 1.0, 1.0, 1.0);
}
Exemple #13
0
void
piglit_init(int argc, char **argv)
{
	unsigned r;
	unsigned c;
	unsigned i;


	(void) argc;
	(void) argv;

	piglit_require_vertex_program();
	piglit_require_fragment_program();
	piglit_require_extension("GL_NV_fragment_program_option");
	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);

	vert_prog = piglit_compile_program(GL_VERTEX_PROGRAM_ARB,
					   vert_shader_source);
	frag_prog = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB,
					   frag_shader_source);

	glClearColor(0.5, 0.5, 0.5, 1.0);

	i = 0;
	for (r = 0; r < TEST_ROWS; r++) {
		for (c = 0; c < TEST_COLS; c++) {
			position[i + 0] = (float)((BOX_SIZE / 2) + c *
						  (BOX_SIZE + 1) + 1);
			position[i + 1] = (float)((BOX_SIZE / 2) + r *
						  (BOX_SIZE + 1) + 1);
			position[i + 2] = 0.0f;
			position[i + 3] = 1.0f;
			i += 4;
		}
	}


	/* Generate a bunch of random direction vectors.  Based on the random
	 * direction vector, generate an axis such that the reflection of the
	 * random vector across the axis is { 0, 1, 0 }.
	 */
	srand(time(NULL));
	for (i = 0; i < (ARRAY_SIZE(direction) / 4); i++) {
		const double d[3] = {
			random_float(),
			random_float(),
			random_float()
		};
		const double inv_mag_d = 1.0 /
			sqrt((d[0] * d[0]) + (d[1] * d[1]) + (d[2] * d[2]));
		double a[3];
		double mag_a;


		direction[(i * 4) + 0] = d[0] * inv_mag_d;
		direction[(i * 4) + 1] = d[1] * inv_mag_d;
		direction[(i * 4) + 2] = d[2] * inv_mag_d;
		direction[(i * 4) + 3] = 0.0;

		a[0] = direction[(i * 4) + 0] + 0.0;
		a[1] = direction[(i * 4) + 1] + 1.0;
		a[2] = direction[(i * 4) + 2] + 0.0;
		mag_a = sqrt((a[0] * a[0]) + (a[1] * a[1]) + (a[2] * a[2]));

		axis[(i * 4) + 0] = a[0] / mag_a;
		axis[(i * 4) + 1] = a[1] / mag_a;
		axis[(i * 4) + 2] = a[2] / mag_a;
		axis[(i * 4) + 3] = 0.0;
	}
}
Exemple #14
0
void
piglit_init(int argc, char **argv)
{
	GLubyte data[256][256][4];
	int x,y;

	static const char *fragProgramText =
		"!!ARBfp1.0\n"
		"# $Id$\n"
		"# Copyright (C) 2006  Oliver McFadden <*****@*****.**>\n"
		"#\n"
		"# This program is free software; you can redistribute it and/or modify\n"
		"# it under the terms of the GNU General Public License as published by\n"
		"# the Free Software Foundation; either version 2 of the License, or\n"
		"# (at your option) any later version.\n"
		"#\n"
		"# This program is distributed in the hope that it will be useful,\n"
		"# but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
		"# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
		"# GNU General Public License for more details.\n"
		"#\n"
		"# You should have received a copy of the GNU General Public License\n"
		"# along with this program; if not, write to the Free Software\n"
		"# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\n"

		"TEMP H, L, N, V, attenuationxy, attenuationz, color, diffuse, dot, specular, tmp;\n"

		"DP3 L.x, fragment.texcoord[4], fragment.texcoord[4];\n"
		"RSQ L.x, L.x;\n"
		"MUL L.xyz, L.x, fragment.texcoord[4];\n"

		"DP3 V.x, fragment.texcoord[5], fragment.texcoord[5];\n"
		"RSQ V.x, V.x;\n"
		"MUL V.xyz, V.x, fragment.texcoord[5];\n"

		"ADD tmp, L, V;\n"
		"DP3 H.x, tmp, tmp;\n"
		"RSQ H.x, H.x;\n"
		"MUL H.xyz, H.x, tmp;\n"

		"TEX tmp.xyz, fragment.texcoord[1], texture[1], 2D;\n"
		"MAD tmp.xyz, tmp, 2.0, -1.0;\n"
		"DP3 N.x, tmp, tmp;\n"
		"RSQ N.x, N.x;\n"
		"MUL N.xyz, N.x, tmp;\n"

		"DP3_SAT dot.x, N, L;\n"
		"MUL dot.xyz, program.local[0], dot.x;\n"

		"TEX diffuse.xyz, fragment.texcoord[0], texture[0], 2D;\n"

		"DP3_SAT tmp.x, N, H;\n"
		"POW tmp.x, tmp.x, program.local[2].x;\n"
		"TEX specular.xyz, fragment.texcoord[2], texture[2], 2D;\n"
		"MUL specular.xyz, specular, program.local[0];\n"
		"MUL specular.xyz, specular, tmp.x;\n"

		"TEX attenuationxy.xyz, fragment.texcoord[3], texture[3], 2D;\n"

		"MOV tmp.x, fragment.texcoord[3].z;\n"
		"MOV tmp.y, 0;\n"
		"TEX attenuationz.xyz, tmp, texture[4], 2D;\n"

		"MOV color, diffuse;\n"
		"MUL color.xyz, color, dot;\n"
		"ADD color.xyz, color, specular;\n"
		"MUL color.xyz, color, attenuationxy;\n"
		"MUL color.xyz, color, attenuationz;\n"
		"MUL color.xyz, color, program.local[1].x;\n"
		"MOV result.color, color;\n"

		"END";

	piglit_require_gl_version(13);

	printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));

	piglit_require_fragment_program();
	FragProg = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, fragProgramText);

	/*
	 * Initialize textures
	 */
	// Diffuse
	for(y = 0; y < 256; ++y) {
		for(x = 0; x < 256; ++x) {
			data[y][x][0] = 255; // 1.0
			data[y][x][1] = 192; // 0.75
			data[y][x][2] = 255; // 1.0
			data[y][x][3] = 0;
		}
	}

	glBindTexture(GL_TEXTURE_2D, TexDiffuse);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, data );

	// Normal
	for(y = 0; y < 256; ++y) {
		for(x = 0; x < 256; ++x) {
			data[y][x][0] = 255; // 1.0
			data[y][x][1] = 0; // 0.0
			data[y][x][2] = 0; // 0.0
			data[y][x][3] = 0;
		}
	}

	glBindTexture(GL_TEXTURE_2D, TexNormal);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, data );

	// Specular
	for(y = 0; y < 256; ++y) {
		for(x = 0; x < 256; ++x) {
			data[y][x][0] = 255; // 1.0
			data[y][x][1] = 255; // 1.0
			data[y][x][2] = 192; // 0.75
			data[y][x][3] = 0;
		}
	}

	glBindTexture(GL_TEXTURE_2D, TexSpecular);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, data );

	// Lookup texture
	for(y = 0; y < 256; ++y) {
		for(x = 0; x < 256; ++x) {
			data[y][x][0] = 255-x;
			data[y][x][1] = 255-y;
			data[y][x][2] = 255;
			data[y][x][3] = 0;
		}
	}

	glBindTexture(GL_TEXTURE_2D, TexLookup);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, data );

	Reshape(piglit_width, piglit_height);
}
Exemple #15
0
void
piglit_init(int argc, char **argv)
{
	GLint max_address_registers;
	unsigned i;

	(void) argc;
	(void) argv;

	piglit_require_vertex_program();
	piglit_require_fragment_program();
	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);

	glGetProgramivARB(GL_VERTEX_PROGRAM_ARB,
			  GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB,
			  & max_address_registers);
	if (max_address_registers == 0) {
		/* we have to have at least one address register */
		if (! piglit_automatic)
			printf("GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB == 0\n");

		piglit_report_result(PIGLIT_FAIL);
	} else 	if (max_address_registers == 1) {
		if (piglit_is_extension_supported("GL_NV_vertex_program2_option")) {
			/* this extension requires two address regs */
			if (! piglit_automatic)
				printf("GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB "
				       "== 1\n");

			piglit_report_result(PIGLIT_FAIL);
		} else {
			piglit_report_result(PIGLIT_SKIP);
		}
	}

	for (i = 0; i < ARRAY_SIZE(progs); i++) {
		char shader_source[1024];
		int offset[2];
		char direction[2];

		/* We want the constant offset in the instruction plus the
		 * value read from the attribute to be 1.
		 */
		offset[0] = 1 - (int) attrib[(2 * i) + 0];
		offset[1] = 1 - (int) attrib[(2 * i) + 1];

		if (offset[0] < 0) {
			direction[0] = '-';
			offset[0] = -offset[0];
		} else {
			direction[0] = '+';
		}

		if (offset[1] < 0) {
			direction[1] = '-';
			offset[1] = -offset[1];
		} else {
			direction[1] = '+';
		}

		snprintf(shader_source, sizeof(shader_source),
			 vertex_source_template,
			 direction[0], offset[0],
			 direction[1], offset[1]);

		progs[i] = piglit_compile_program(GL_VERTEX_PROGRAM_ARB,
						  shader_source);
	}

	glEnable(GL_FRAGMENT_PROGRAM_ARB);
	glEnable(GL_VERTEX_PROGRAM_ARB);
	glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, piglit_ARBfp_pass_through);

	glClearColor(0.5, 0.5, 0.5, 1.0);
}