Example #1
0
void
piglit_init(int argc, char **argv)
{
	GLuint pipe = 0;
	unsigned glsl_version;

	piglit_require_vertex_shader();
	piglit_require_fragment_shader();
	piglit_require_extension("GL_ARB_separate_shader_objects");
	piglit_require_extension("GL_ARB_explicit_attrib_location");

	glsl_version = pick_a_glsl_version();

	vs = generate_program(vs_template, glsl_version, GL_VERTEX_SHADER,
			      &loc_vs);

	fs = generate_program(fs_template, glsl_version, GL_FRAGMENT_SHADER,
			      &loc_fs);

	if (vs == 0 || fs == 0)
		piglit_report_result(PIGLIT_FAIL);

	glGenProgramPipelines(1, &pipe);
	glBindProgramPipeline(pipe);
	glUseProgramStages(pipe, GL_VERTEX_SHADER_BIT, vs);
	glUseProgramStages(pipe, GL_FRAGMENT_SHADER_BIT, fs);

	if (!piglit_check_gl_error(0))
		piglit_report_result(PIGLIT_FAIL);
}
Example #2
0
void piglit_init(int argc, char **argv)
{
	unsigned glsl_version;
	GLuint vs_prog;
	GLuint fs_prog_same_declaration_order;
	GLuint fs_prog_same_location_order;
	char *source;

	piglit_require_vertex_shader();
	piglit_require_fragment_shader();
	piglit_require_extension("GL_ARB_separate_shader_objects");
	piglit_require_extension("GL_ARB_explicit_attrib_location");

	glsl_version = pick_a_glsl_version();

	(void)!asprintf(&source, vs_code_template, glsl_version);
	vs_prog = glCreateShaderProgramv(GL_VERTEX_SHADER, 1,
					 (const GLchar *const *) &source);
	piglit_link_check_status(vs_prog);
	free(source);

	(void)!asprintf(&source, fs_code_same_declaration_order_template, glsl_version);
	fs_prog_same_declaration_order =
		glCreateShaderProgramv(GL_FRAGMENT_SHADER, 1,
				       (const GLchar *const *) &source);
	piglit_link_check_status(fs_prog_same_declaration_order);
	free(source);

	(void)!asprintf(&source, fs_code_same_location_order_template, glsl_version);
	fs_prog_same_location_order =
		glCreateShaderProgramv(GL_FRAGMENT_SHADER, 1,
				       (const GLchar *const *) &source);
	piglit_link_check_status(fs_prog_same_location_order);
	free(source);

	glGenProgramPipelines(1, &pipeline_same_declaration_order);
	glUseProgramStages(pipeline_same_declaration_order,
			   GL_VERTEX_SHADER_BIT,
			   vs_prog);
	glUseProgramStages(pipeline_same_declaration_order,
			   GL_FRAGMENT_SHADER_BIT,
			   fs_prog_same_declaration_order);
	piglit_program_pipeline_check_status(pipeline_same_declaration_order);

	glGenProgramPipelines(1, &pipeline_same_location_order);
	glUseProgramStages(pipeline_same_location_order,
			   GL_VERTEX_SHADER_BIT,
			   vs_prog);
	glUseProgramStages(pipeline_same_location_order,
			   GL_FRAGMENT_SHADER_BIT,
			   fs_prog_same_location_order);
	piglit_program_pipeline_check_status(pipeline_same_location_order);

	if (!piglit_check_gl_error(0))
		piglit_report_result(PIGLIT_FAIL);
}
void
piglit_init(int argc, char **argv)
{
   int i = 1;

   if (i < argc && strcmp(argv[i], "rect") == 0) {
      TexTarget = GL_TEXTURE_RECTANGLE;
      i++;
   }
   if (i < argc) {
      ErrorScale = atof(argv[i]);
   }

   piglit_require_extension("GL_EXT_framebuffer_object");
   piglit_require_fragment_shader();
   if (TexTarget == GL_TEXTURE_RECTANGLE) {
      piglit_require_extension("GL_ARB_texture_rectangle");
   }

   create_fbo();

   if (ErrorScale == 0.0) {
      /* A 1-bit error/difference in Z values results in a delta of 64 in
       * pixel intensity (where pixels are in [0,255]).
       */
      ErrorScale = ((double) (1ull << Zbits)) * 64.0 / 255.0;
   }

   create_frag_shader();

   if (!piglit_automatic) {
      printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
      printf("Left: Shader showing difference pixels (black=good, red=error)\n");
      printf("Middle: Depth buffer of FBO\n");
      printf("Right: Quad textured with depth values\n");
      printf("Z bits = %d\n", Zbits);
      printf("ErrorScale = %f\n", ErrorScale);
      printf("Texture target: %s\n",
	     TexTarget == GL_TEXTURE_RECTANGLE ? "RECTANGLE" : "2D" );
   }
}
Example #4
0
void
piglit_init(int argc, char **argv)
{
	GLuint vs;
	GLuint fs;
	GLboolean ok;

	piglit_require_vertex_shader();
	piglit_require_fragment_shader();

	vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_text);
	fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_text);
	prog = piglit_link_simple_program(vs, fs);

	glBindAttribLocation(prog, 0, "vertex");
	glLinkProgram(prog);
	ok = piglit_link_check_status(prog);
	if (!ok)
		piglit_report_result(PIGLIT_FAIL);

	glUseProgram(prog);

	glClearColor(blue[0], blue[1], blue[2], blue[3]);
}
Example #5
0
void
piglit_init(int argc, char **argv)
{
	piglit_require_vertex_shader();
	piglit_require_fragment_shader();
}
Example #6
0
void piglit_init(int argc, char **argv)
{
	unsigned glsl_version;
	GLuint vs_prog_3_out;
	GLuint vs_prog_1_out;
	GLuint fs_prog_3_in;
	GLuint fs_prog_1_in;
	GLuint vs_fs_prog_separate_inactive;
	char *vs_source;
	char *fs_source;
	GLint max_varying;
	bool pass = true;

	piglit_require_vertex_shader();
	piglit_require_fragment_shader();
	piglit_require_GLSL_version(130); /* Support layout index on output color */
	piglit_require_extension("GL_ARB_separate_shader_objects");
	piglit_require_extension("GL_ARB_explicit_attrib_location");
	piglit_require_extension("GL_ARB_blend_func_extended");

	glsl_version = pick_a_glsl_version();

	glGetIntegerv(GL_MAX_VARYING_COMPONENTS, &max_varying);
	max_varying = (max_varying / 4u) - 1u;

	/*
	 * Program compilation and link
	 */
	printf("Compile vs_prog_3_out\n");
	vs_prog_3_out = format_and_link_program(GL_VERTEX_SHADER,
			vs_code_3_out_template, glsl_version);

	printf("Compile vs_prog_1_out\n");
	vs_prog_1_out = format_and_link_program(GL_VERTEX_SHADER,
			vs_code_1_out_template, glsl_version);

	printf("Compile fs_prog_3_in\n");
	fs_prog_3_in = format_and_link_program(GL_FRAGMENT_SHADER,
			fs_code_3_in_template, glsl_version);

	printf("Compile fs_prog_1_in\n");
	fs_prog_1_in = format_and_link_program(GL_FRAGMENT_SHADER,
			fs_code_1_in_template, glsl_version);

	(void)!asprintf(&vs_source, vs_code_inactive_template, glsl_version, max_varying);
	(void)!asprintf(&fs_source, fs_code_inactive_template, glsl_version, max_varying);

	pass &= piglit_check_gl_error(0);

	printf("Compile vs_fs_prog_separate_inactive\n");
	vs_fs_prog_separate_inactive = piglit_build_simple_program_unlinked(vs_source, fs_source);
	/* Manual linking so we can pack 2 separate-aware shaders into a single program */
	glProgramParameteri(vs_fs_prog_separate_inactive, GL_PROGRAM_SEPARABLE, GL_TRUE);
	glLinkProgram(vs_fs_prog_separate_inactive);

	if (!piglit_link_check_status(vs_fs_prog_separate_inactive)) {
		piglit_report_subtest_result(PIGLIT_SKIP,
				"Unactive varying optimization in multi-shade separated program");
		vs_fs_prog_separate_inactive = 0; // Skip program
		piglit_reset_gl_error(); // Clear pending error
	}

	free(vs_source);
	free(fs_source);

	/*
	 * Pipeline creation
	 */
	glGenProgramPipelines(1, &pipeline_3_out_1_in);
	glGenProgramPipelines(1, &pipeline_1_out_3_in);
	glBindProgramPipeline(pipeline_3_out_1_in);
	glUseProgramStages(pipeline_3_out_1_in,
			GL_VERTEX_SHADER_BIT, vs_prog_3_out);
	glUseProgramStages(pipeline_3_out_1_in,
			GL_FRAGMENT_SHADER_BIT, fs_prog_1_in);

	glBindProgramPipeline(pipeline_1_out_3_in);
	glUseProgramStages(pipeline_1_out_3_in,
			GL_VERTEX_SHADER_BIT, vs_prog_1_out);
	glUseProgramStages(pipeline_1_out_3_in,
			GL_FRAGMENT_SHADER_BIT, fs_prog_3_in);

	if (vs_fs_prog_separate_inactive) {
		glGenProgramPipelines(1, &pipeline_inactive);
		glBindProgramPipeline(pipeline_inactive);
		glUseProgramStages(pipeline_inactive,
				GL_VERTEX_SHADER_BIT | GL_FRAGMENT_SHADER_BIT,
				vs_fs_prog_separate_inactive);
	} else {
		pipeline_inactive = 0; // Skip the test
	}

	if (!piglit_check_gl_error(0) || !pass)
		piglit_report_result(PIGLIT_FAIL);
}
Example #7
0
void
piglit_init(int argc, char **argv)
{
   GLuint vs, prog;
   GLint numUniforms, i;
   GLint expectedNum = 7;
   GLint loc_f1, loc_f2, loc_sa, loc_sd, loc_v1;
   GLfloat v[4];
   static const GLfloat vVals[4] = {30.0, 31.0, 32.0, 33.0};
   
   piglit_require_vertex_shader();
   piglit_require_fragment_shader();

   vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_text);
   prog = piglit_link_simple_program(vs, 0);

   glUseProgram(prog);

   glGetProgramiv(prog, GL_ACTIVE_UNIFORMS, &numUniforms);
   if (numUniforms != expectedNum) {
      printf("%s: incorrect number of uniforms (found %d, expected %d)\n",
             TestName, numUniforms, expectedNum);
      piglit_report_result(PIGLIT_FAIL);
   }

   /* check types, sizes */
   for (i = 0; i < numUniforms; i++) {
      GLcharARB name[100];
      GLsizei len;
      GLint size, expectedSize;
      GLenum type, expectedType;
      GLint loc;

      glGetActiveUniform(prog,
				 i, sizeof(name), &len, &size, &type, name);
      loc = glGetUniformLocation(prog, name);

      if (loc < 0) {
         printf("%s: bad uniform location for %s: %d\n", TestName, name, loc);
         piglit_report_result(PIGLIT_FAIL);
      }

      if (!piglit_automatic) {
         printf("%d: %s loc=%d size=%d type=0x%x\n", i, name, loc, size, type);
      }

      /* OpenGL ES 3.0 and OpenGL 4.2 require that the "[0]" be appended to
       * the name.  Earlier versions of the spec are ambiguous.  Accept either
       * name.
       */
      if (strcmp(name, "v") == 0 || strcmp(name, "v[0]") == 0) {
         expectedType = GL_FLOAT_VEC4_ARB;
         expectedSize = 3;
      }
      else {
         expectedType = GL_FLOAT;
         expectedSize = 1;
      }

      if (type != expectedType) {
         printf("%s: wrong type for 'v' (found 0x%x, expected 0x%x)\n",
                TestName, type, expectedType);
         piglit_report_result(PIGLIT_FAIL);
      }

      if (size != expectedSize) {
         printf("%s: wrong size for 'v' (found %d, expected %d)\n",
                TestName, size, expectedSize);
         piglit_report_result(PIGLIT_FAIL);
      }
   }

   /* Check setting/getting values */

   loc_f1 = glGetUniformLocation(prog, "f1");
   loc_f2 = glGetUniformLocation(prog, "f2");
   loc_sa = glGetUniformLocation(prog, "s.a");
   loc_sd = glGetUniformLocation(prog, "s.d");
   loc_v1 = glGetUniformLocation(prog, "v[1]");

   glUniform1f(loc_f1, 5.0);
   glUniform1f(loc_f2, 10.0);
   glUniform1f(loc_sa, 15.0);
   glUniform1f(loc_sd, 20.0);
   glUniform4fv(loc_v1, 1, vVals);

   glGetUniformfv(prog, loc_f1, v);
   if (v[0] != 5.0) {
      printf("%s: wrong value for f1 (found %f, expected %f)\n",
             TestName, v[0], 5.0);
      piglit_report_result(PIGLIT_FAIL);
   }

   glGetUniformfv(prog, loc_f2, v);
   if (v[0] != 10.0) {
      printf("%s: wrong value for f2 (found %f, expected %f)\n",
             TestName, v[0], 10.0);
      piglit_report_result(PIGLIT_FAIL);
   }

   glGetUniformfv(prog, loc_sa, v);
   if (v[0] != 15.0) {
      printf("%s: wrong value for s.a (found %f, expected %f)\n",
             TestName, v[0], 15.0);
      piglit_report_result(PIGLIT_FAIL);
   }

   glGetUniformfv(prog, loc_sd, v);
   if (v[0] != 20.0) {
      printf("%s: wrong value for s.d (found %f, expected %f)\n",
             TestName, v[0], 20.0);
      piglit_report_result(PIGLIT_FAIL);
   }

   glGetUniformfv(prog, loc_v1, v);
   if (v[0] != 30.0 ||
       v[1] != 31.0 ||
       v[2] != 32.0 ||
       v[3] != 33.0) {
      printf("%s: wrong value for v[1] (found %g,%g,%g,%g, expected %g,%g,%g,%g)\n",
             TestName, v[0], v[1], v[2], v[3], 30.0, 31.0, 32.0, 33.0);
      piglit_report_result(PIGLIT_FAIL);
   }

   piglit_report_result(PIGLIT_PASS);
}
Example #8
0
void piglit_init(int argc, char **argv)
{
	unsigned glsl_version;
	GLuint vs_prog;
	GLuint fs_prog_same_declaration_order;
	GLuint fs_prog_same_location_order;
	bool es;
	int glsl_major;
	int glsl_minor;
	char *source;

	piglit_require_vertex_shader();
	piglit_require_fragment_shader();
	piglit_require_extension("GL_ARB_separate_shader_objects");
	piglit_require_extension("GL_ARB_explicit_attrib_location");

	/* Some NVIDIA drivers have issues with layout qualifiers, 'in'
	 * keywords, and 'out' keywords in "lower" GLSL versions.  If the
	 * driver supports GLSL >= 1.40, use 1.40.  Otherwise, pick the
	 * highest version that the driver supports.
	 */
	piglit_get_glsl_version(&es, &glsl_major, &glsl_minor);
	glsl_version = ((glsl_major * 100) + glsl_minor) >= 140
		? 140 : ((glsl_major * 100) + glsl_minor);

	asprintf(&source, vs_code_template, glsl_version);
	vs_prog = glCreateShaderProgramv(GL_VERTEX_SHADER, 1,
					 (const GLchar *const *) &source);
	piglit_link_check_status(vs_prog);
	free(source);

	asprintf(&source, fs_code_same_declaration_order_template, glsl_version);
	fs_prog_same_declaration_order =
		glCreateShaderProgramv(GL_FRAGMENT_SHADER, 1,
				       (const GLchar *const *) &source);
	piglit_link_check_status(fs_prog_same_declaration_order);
	free(source);

	asprintf(&source, fs_code_same_location_order_template, glsl_version);
	fs_prog_same_location_order =
		glCreateShaderProgramv(GL_FRAGMENT_SHADER, 1,
				       (const GLchar *const *) &source);
	piglit_link_check_status(fs_prog_same_location_order);
	free(source);

	glGenProgramPipelines(1, &pipeline_same_declaration_order);
	glUseProgramStages(pipeline_same_declaration_order,
			   GL_VERTEX_SHADER_BIT,
			   vs_prog);
	glUseProgramStages(pipeline_same_declaration_order,
			   GL_FRAGMENT_SHADER_BIT,
			   fs_prog_same_declaration_order);
	piglit_program_pipeline_check_status(pipeline_same_declaration_order);

	glGenProgramPipelines(1, &pipeline_same_location_order);
	glUseProgramStages(pipeline_same_location_order,
			   GL_VERTEX_SHADER_BIT,
			   vs_prog);
	glUseProgramStages(pipeline_same_location_order,
			   GL_FRAGMENT_SHADER_BIT,
			   fs_prog_same_location_order);
	piglit_program_pipeline_check_status(pipeline_same_location_order);

	if (!piglit_check_gl_error(0))
		piglit_report_result(PIGLIT_FAIL);
}
Example #9
0
void
piglit_init(int argc, char **argv)
{
	static const float uniform_data[4] = {
		12.0, 0.5, 3.14169, 42.0
	};
	GLint vs;
	GLint fs;
	unsigned i;
	union data_blob buffer[16];

	piglit_require_vertex_shader();
	piglit_require_fragment_shader();

	vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_text);
	fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_text);

	prog = piglit_link_simple_program(vs, fs);

	piglit_UseProgram(prog);

	base_location = piglit_GetUniformLocation(prog, "c");
	if (base_location < 0) {
		printf("Could not get location of `c'.\n");
		piglit_report_result(PIGLIT_FAIL);
	}

	for (i = 0; i < 4; i++) {
		char name[5];

		name[0] = 'c';
		name[1] = '[';
		name[2] = '0' + i;
		name[3] = ']';
		name[4] = '\0';
		array_location[i] = piglit_GetUniformLocation(prog, name);
		if (array_location[i] < 0) {
			printf("Could not get location of `%s'.\n", name);
			piglit_report_result(PIGLIT_FAIL);
		}
	}

	/* From page 80 of the OpenGL 2.1 spec:
	 *
	 *     The first element of a uniform array is identified using the
	 *     name of the uniform array appended with "[0]". Except if the
	 *     last part of the string name indicates a uniform array, then
	 *     the location of the first element of that array can be
	 *     retrieved by either using the name of the uniform array, or the
	 *     name of the uniform array appended with "[0]".
	 */
	if (base_location != array_location[0]) {
		printf("Locations of `c' = %d and `c[0]' = %d, but they "
		       "should be the same.\n",
		       base_location, array_location[0]);
		piglit_report_result(PIGLIT_FAIL);
	}

	piglit_Uniform1fv(base_location, 4, uniform_data);

	/* From page 264 of the OpenGL 2.1 spec:
	 *
	 *     In order to query the values of an array of uniforms, a
	 *     GetUniform* command needs to be issued for each array element.
	 *
	 * This means that querying using the location of 'array' is the same
	 * as 'array[0]'.
	 */
	printf("Getting array element 0 from base location...\n");
	for (i = 0; i < ARRAY_SIZE(buffer); i++) {
		buffer[i].u = 0xdeadbeef;
	}

	piglit_GetUniformfv(prog, base_location, (GLfloat *) buffer);
	validate_buffer(buffer, ARRAY_SIZE(buffer), uniform_data[0]);

	printf("Getting one array element at a time...\n");
	for (i = 0; i < 4; i++) {
		unsigned j;
		for (j = 0; j < ARRAY_SIZE(buffer); j++) {
			buffer[j].u = 0xdeadbeef;
		}

		piglit_GetUniformfv(prog, array_location[i],
				    (GLfloat *) buffer);
		validate_buffer(buffer, ARRAY_SIZE(buffer), uniform_data[i]);
	}

	piglit_report_result(PIGLIT_PASS);
}