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)
{
	GLuint vs_prog, fs_prog;

	piglit_require_extension("GL_ARB_separate_shader_objects");

	vs_prog = glCreateShaderProgramv(GL_VERTEX_SHADER, 1,
					 (const GLchar *const*) &vs_code);
	piglit_link_check_status(vs_prog);

	fs_prog = glCreateShaderProgramv(GL_FRAGMENT_SHADER, 1,
					 (const GLchar *const *) &fs_code);
	piglit_link_check_status(fs_prog);

	glGenProgramPipelines(1, &pipeline);
	glUseProgramStages(pipeline, GL_VERTEX_SHADER_BIT, vs_prog);
	glUseProgramStages(pipeline, GL_FRAGMENT_SHADER_BIT, fs_prog);
	piglit_program_pipeline_check_status(pipeline);

	if (!piglit_check_gl_error(0))
		piglit_report_result(PIGLIT_FAIL);
}
Exemple #3
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);
}