void piglit_init(int argc, char **argv) { bool pass = true; const char *glsl_version_string; piglit_require_vertex_shader(); glsl_version_string = (const char *) glGetString(GL_SHADING_LANGUAGE_VERSION); if (strtod(glsl_version_string, NULL) < 1.2) { printf("Requires GLSL 1.20 (have version `%s')\n", glsl_version_string); piglit_report_result(PIGLIT_SKIP); } if (argc == 1) { pass = do_named_test(NULL); } else { int i; for (i = 1; i < argc; i++) { pass = do_named_test(argv[i]) && pass; } } piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); }
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); }
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) { static const char name[] = "attrib"; char alt_name[sizeof(name)]; GLint vs; GLint prog; GLint attrib_loc; piglit_require_vertex_shader(); vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vertShaderText); if (vs == 0) { piglit_report_result(PIGLIT_FAIL); } prog = piglit_CreateProgram(); piglit_AttachShader(prog, vs); /* Bind "attrib" to location 3. Once the attribute is bound, smash * the string containing the name. After smashing the name, link the * shader. If the implementation kept our name pointer, there will be * problems linking. */ memcpy(alt_name, name, sizeof(name)); piglit_BindAttribLocation(prog, 3, alt_name); memset(alt_name, 0, sizeof(alt_name)); piglit_LinkProgram(prog); if (!piglit_link_check_status(prog)) piglit_report_result(PIGLIT_FAIL); attrib_loc = piglit_GetAttribLocation(prog, "attrib"); if (attrib_loc != 3) { fprintf(stderr, "Expected location 3, got location %d\n", attrib_loc); piglit_report_result(PIGLIT_FAIL); } piglit_report_result(PIGLIT_PASS); }
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]); }
void piglit_init(int argc, char **argv) { piglit_require_vertex_shader(); piglit_require_fragment_shader(); }
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); }
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); }
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); }
void piglit_init(int argc, char **argv) { bool pass = true; int gl_version; int glsl_major; int glsl_minor; int glsl_version; const char *version_for_float_shader = NULL; const char *version_for_double_shader = NULL; const char *version_for_int_shader = NULL; GLint context_flags = 0; piglit_require_vertex_shader(); piglit_require_extension("GL_ARB_separate_shader_objects"); gl_version = piglit_get_gl_version(); if (gl_version >= 30) glGetIntegerv(GL_CONTEXT_FLAGS, &context_flags); piglit_get_glsl_version(NULL, &glsl_major, &glsl_minor); glsl_version = (glsl_major * 100) + glsl_minor; /* Select a shading language version string based on the GL version * and whether or not we're running in a core profile. */ switch (gl_version / 10) { case 1: case 2: /* Selecting 1.20 will enable the non-square matrix tests. */ version_for_float_shader = (glsl_version >= 120) ? "#version 120\n" : "#version 110\n"; if (glsl_version >= 130) version_for_int_shader = "#version 130\n"; break; case 3: /* OpenGL 3.0 deprecated GLSL 1.10 and 1.20. OpenGL 3.1 * removed almost all deprecated features. * Forworad-compatible contexts remove all deprecated * features. */ if (gl_version == 30) { version_for_float_shader = (context_flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT) ? "#version 130\n" : "#version 120\n"; version_for_int_shader = "#version 130\n"; } else { /* Section 1.6.1 (OpenGL Shading Language) of the * OpenGL 3.1 spec says: * * "OpenGL 3.1 implementations are guaranteed to * support at least version 1.30 of the shading * language." * * This is likely a copy-and-paste error from version * 3.0. This should be 1.40. * * Section 1.6.1 (OpenGL Shading Language) of the * OpenGL 3.2 spec says: * * "OpenGL 3.2 implementations are guaranteed to * support versions 1.40 and 1.50 of the OpenGL * Shading Language." * * Section 1.7.1 (OpenGL Shading Language) of the * OpenGL 3.3 spec says: * * "OpenGL 3.3 implementations are guaranteed to * support version 3.30 of the OpenGL Shading * Language." * * Based on all of this, pick version 1.40 for OpenGL * versions before 3.3, and version 3.30 for version * 3.3. */ if (gl_version < 33) { version_for_float_shader = "#version 140\n"; version_for_int_shader = "#version 140\n"; } else { version_for_float_shader = "#version 330 core\n"; version_for_int_shader = "#version 330 core\n"; } if (piglit_is_extension_supported("GL_ARB_gpu_shader_fp64")) { /* The GL_ARB_gpu_shader_fp64 extensions spec * says: * * "OpenGL 3.2 and GLSL 1.50 are required." */ version_for_double_shader = "#version 150 core\n" "#extension GL_ARB_gpu_shader_fp64: require\n" ; } } break; case 4: /* Section 1.7.1 (OpenGL Shading Language) of the * OpenGL 4.0 spec says: * * "OpenGL 4.0 implementations are guaranteed to support * version 4.00 of the OpenGL Shading Language." * * Section 1.7.1 (OpenGL Shading Language) of the * OpenGL 4.1 spec says: * * "OpenGL 4.1 implementations are guaranteed to support * version 4.10 of the OpenGL Shading Language." * * Section 1.7.1 (OpenGL Shading Language) of the * OpenGL 4.2 spec says: * * "OpenGL 4.2 implementations are guaranteed to support * version 4.20 of the OpenGL Shading Language....The core * profile of OpenGL 4.2 is also guaranteed to support all * previous versions of the OpenGL Shading Language back * to version 1.40." * * Section 1.3.1 (OpenGL Shading Language) of the * OpenGL 4.3 spec says: * * "OpenGL 4.3 implementations are guaranteed to support * version 4.30 of the OpenGL Shading Language....The core * profile of OpenGL 4.3 is also guaranteed to support all * previous versions of the OpenGL Shading Language back * to version 1.40." * * Section 1.3.1 (OpenGL Shading Language) of the * OpenGL 4.4 spec says: * * "OpenGL 4.4 implementations are guaranteed to support * version 4.40 of the OpenGL Shading Language....The core * profile of OpenGL 4.4 is also guaranteed to support all * previous versions of the OpenGL Shading Language back * to version 1.40." * * Even though 4.1 doesn't say anything about GLSL 4.00, the * inference is that the addition starting in 4.2 was a * clarification. */ version_for_float_shader = "#version 400 core\n"; version_for_double_shader = "#version 400 core\n"; version_for_int_shader = "#version 400 core\n"; break; default: fprintf(stderr, "Unknown GL version!\n"); piglit_report_result(PIGLIT_FAIL); } pass = test_float(version_for_float_shader) && pass; pass = test_square_mat(version_for_float_shader) && pass; pass = test_nonsquare_mat(version_for_float_shader) && pass; pass = test_int(version_for_int_shader) && pass; pass = test_uint(version_for_int_shader) && pass; pass = test_double(version_for_double_shader) && pass; pass = test_dmat(version_for_double_shader) && pass; piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); }
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); }