void piglit_init(int argc, char **argv) { char *endptr; GLuint vs, fs; /* Interpret command line args */ if (argc != 2) print_usage_and_exit(argv[0]); endptr = argv[1]; additional_offset = strtoul(argv[1], &endptr, 0); if (*endptr != '\0') print_usage_and_exit(argv[0]); if (additional_offset > 12 || additional_offset % 4 != 0) print_usage_and_exit(argv[0]); piglit_require_GLSL_version(130); piglit_require_gl_version(30); piglit_require_transform_feedback(); vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vstext); fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fstext); prog = piglit_CreateProgram(); piglit_AttachShader(prog, vs); piglit_AttachShader(prog, fs); piglit_TransformFeedbackVaryings(prog, 5, varyings, GL_INTERLEAVED_ATTRIBS); piglit_LinkProgram(prog); if (!piglit_link_check_status(prog)) piglit_report_result(PIGLIT_FAIL); glGenBuffers(1, &xfb_buf); if (!piglit_check_gl_error(0)) piglit_report_result(PIGLIT_FAIL); }
void piglit_init(int argc, char **argv) { GLuint vs; GLint maxcomps, maxattrs; unsigned i; piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE); /* Check the driver. */ if (piglit_get_gl_version() < 15) { fprintf(stderr, "OpenGL 1.5 required.\n"); piglit_report_result(PIGLIT_SKIP); } piglit_require_GLSL(); piglit_require_transform_feedback(); glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT, &maxattrs); if (maxattrs < 4) { fprintf(stderr, "Not enough separate attribs supported by transform feedback.\n"); piglit_report_result(PIGLIT_SKIP); } glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT, &maxcomps); if (maxcomps < 4) { fprintf(stderr, "Not enough separate components supported by transform feedback.\n"); piglit_report_result(PIGLIT_SKIP); } /* Create shaders. */ vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vstext); prog = piglit_CreateProgram(); piglit_AttachShader(prog, vs); piglit_TransformFeedbackVaryings(prog, sizeof(varyings)/sizeof(varyings[0]), varyings, GL_SEPARATE_ATTRIBS_EXT); piglit_LinkProgram(prog); if (!piglit_link_check_status(prog)) { piglit_DeleteProgram(prog); piglit_report_result(PIGLIT_FAIL); } /* Set up the transform feedback buffer. */ glGenBuffers(4, buf); for (i = 0; i < 4; i++) { unsigned j; float *ptr; glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER_EXT, buf[i]); glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER_EXT, NUM_OUT_VERTICES*4*sizeof(float), NULL, GL_STREAM_READ); ptr = glMapBuffer(GL_TRANSFORM_FEEDBACK_BUFFER_EXT, GL_WRITE_ONLY); for (j = 0; j < NUM_OUT_VERTICES*4; j++) { ptr[j] = 0.123456; } glUnmapBuffer(GL_TRANSFORM_FEEDBACK_BUFFER_EXT); piglit_BindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER_EXT, i, buf[i]); } assert(glGetError() == 0); glClearColor(0.2, 0.2, 0.2, 1.0); glEnableClientState(GL_VERTEX_ARRAY); }
void piglit_init(int argc, char **argv) { GLuint vs; int num_varyings; piglit_require_GLSL(); piglit_require_transform_feedback(); vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vstext); for (num_varyings = 1; num_varyings <= 2; ++num_varyings) { GLuint prog = piglit_CreateProgram(); piglit_AttachShader(prog, vs); piglit_BindAttribLocation(prog, 0, "vertex_num"); piglit_TransformFeedbackVaryings(prog, num_varyings, varyings, GL_INTERLEAVED_ATTRIBS); piglit_LinkProgram(prog); if (!piglit_link_check_status(prog)) { piglit_DeleteProgram(prog); piglit_report_result(PIGLIT_FAIL); } progs[num_varyings - 1] = prog; } glGenBuffers(1, &xfb_buf); glGenQueries(1, &query_prims_generated); glGenQueries(1, &query_prims_written); }
void setup_glsl_programs() { GLuint vs; GLuint fs; GLuint prog; char vert[4096]; char frag[4096]; char *version_directive; if (use_glsl_130) { version_directive = "#version 130"; } else { version_directive = ""; } sprintf(vert, "%s\n" "uniform float position_angle;\n" "uniform float clipVertex_angle;\n" "mat4 rotate(float angle)\n" "{\n" " angle = radians(angle);\n" " return mat4( cos(angle), sin(angle), 0.0, 0.0,\n" " -sin(angle), cos(angle), 0.0, 0.0,\n" " 0.0, 0.0, 1.0, 0.0,\n" " 0.0, 0.0, 0.0, 1.0);\n" "}\n" "void main()\n" "{\n" "%s\n" "}", version_directive, setters); sprintf(frag, "%s\n" "void main()\n" "{\n" " gl_FragColor = vec4(1.0);\n" "}", version_directive); vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vert); fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, frag); prog = piglit_CreateProgram(); piglit_AttachShader(prog, vs); piglit_AttachShader(prog, fs); piglit_LinkProgram(prog); piglit_DeleteShader(vs); piglit_DeleteShader(fs); piglit_UseProgram(prog); position_angle_loc = piglit_GetUniformLocation(prog, "position_angle"); if (use_clip_vertex) { clipVertex_angle_loc = piglit_GetUniformLocation(prog, "clipVertex_angle"); } }
void piglit_init(int argc, char **argv) { GLuint vs; GLuint fs; piglit_require_GLSL(); piglit_require_GLSL_version(130); vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vert); fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, frag); prog = piglit_CreateProgram(); piglit_AttachShader(prog, vs); piglit_AttachShader(prog, fs); piglit_LinkProgram(prog); piglit_DeleteShader(vs); piglit_DeleteShader(fs); piglit_UseProgram(prog); }
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); }
static void initialize_shader_and_xfb() { GLuint prog, vs; const char *varying = "tf"; piglit_require_gl_version(30); piglit_require_GLSL_version(130); piglit_require_transform_feedback(); vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vstext); prog = piglit_CreateProgram(); piglit_AttachShader(prog, vs); piglit_TransformFeedbackVaryings(prog, 1, &varying, GL_INTERLEAVED_ATTRIBS); piglit_LinkProgram(prog); if (!piglit_link_check_status(prog)) { piglit_DeleteProgram(prog); piglit_report_result(PIGLIT_FAIL); } piglit_UseProgram(prog); }
void piglit_init(int argc, char **argv) { GLint program; bool expect; bool result; unsigned i; const char *invalid_file = NULL; if (piglit_get_gl_version() < 20) { printf("Requires OpenGL 2.0\n"); piglit_report_result(PIGLIT_SKIP); } piglit_require_GLSL(); program = piglit_CreateProgram(); for (i = 1; i < argc; i++) { size_t len; GLint shader; GLenum target; if (strcmp(argv[i], "pass") == 0) { expect = true; break; } if (strcmp(argv[i], "fail") == 0) { expect = false; break; } /* Expect that the name is at least one character plus * ".vert", ".geom", or ".frag" */ len = strlen(argv[i]); if (len < 6) { invalid_file = argv[i]; break; } if (strcmp(argv[i] + len - 5, ".vert") == 0) { target = GL_VERTEX_SHADER; } else if (strcmp(argv[i] + len - 5, ".geom") == 0) { target = GL_GEOMETRY_SHADER; if (piglit_get_gl_version() < 32 && !piglit_is_extension_supported("GL_ARB_geometry_shader4")) { printf("Requires geometry shaders.\n"); piglit_report_result(PIGLIT_SKIP); } } else if (strcmp(argv[i] + len - 5, ".frag") == 0) { target = GL_FRAGMENT_SHADER; } else { invalid_file = argv[i]; break; } shader = piglit_compile_shader(target, argv[i]); glAttachShader(program, shader); glDeleteShader(shader); } /* The loop above will break when an option of either 'pass' or 'fail' * is encountered. If this happens at the last commandline argument, * the loop counter will be (argc-1). Any other value is an error. */ if (i != (argc - 1)) { fprintf(stderr, "Last command line option must be either " "\"pass\" or \"fail\".\n"); piglit_report_result(PIGLIT_FAIL); } if (invalid_file != NULL) { fprintf(stderr, "Invalid shader file name \"%s\".\n", invalid_file); piglit_report_result(PIGLIT_FAIL); } piglit_LinkProgram(program); result = piglit_link_check_status_quiet(program); if (result != expect) fprintf(stderr, "Program should have %s linking, but " "it was (incorrectly) %s.\n", expect ? "succeeded" : "failed", expect ? "unsuccesful" : "succesful"); piglit_report_result((result == expect) ? PIGLIT_PASS : PIGLIT_FAIL); }
void piglit_init(int argc, char **argv) { GLuint vs; unsigned i; float data[BUF_FLOATS]; for (i = 0; i < BUF_FLOATS; i++) { data[i] = DEFAULT_VALUE; } /* Parse params. */ for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "discard")) { discard = GL_TRUE; } else if (!strcmp(argv[i], "offset")) { /* BindBufferOffset only exists in the EXT specification */ piglit_require_extension("GL_EXT_transform_feedback"); offset = OFFSET; } else if (!strcmp(argv[i], "range")) { offset = OFFSET; range = MAX_RANGE-7; } else if (!strcmp(argv[i], "render")) { test = RENDER; } else if (!strcmp(argv[i], "primgen")) { test = PRIMGEN; } else if (!strcmp(argv[i], "primwritten")) { test = PRIMWRITTEN; } } piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE); /* Check the driver. */ if (piglit_get_gl_version() < 15) { fprintf(stderr, "OpenGL 1.5 required.\n"); piglit_report_result(PIGLIT_SKIP); } piglit_require_GLSL(); piglit_require_transform_feedback(); /* Create shaders. */ vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vstext); prog = piglit_CreateProgram(); piglit_AttachShader(prog, vs); piglit_TransformFeedbackVaryings(prog, 1, varyings, GL_INTERLEAVED_ATTRIBS_EXT); piglit_LinkProgram(prog); if (!piglit_link_check_status(prog)) { piglit_DeleteProgram(prog); piglit_report_result(PIGLIT_FAIL); } vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vspassthrough); prog_passthrough = piglit_CreateProgram(); piglit_AttachShader(prog_passthrough, vs); piglit_TransformFeedbackVaryings(prog_passthrough, 1, varyings, GL_INTERLEAVED_ATTRIBS_EXT); piglit_LinkProgram(prog_passthrough); if (!piglit_link_check_status(prog_passthrough)) { piglit_DeleteProgram(prog_passthrough); piglit_report_result(PIGLIT_FAIL); } /* Set up the transform feedback buffer. */ glGenBuffers(1, &buf); glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER_EXT, buf); glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER_EXT, BUF_FLOATS*sizeof(float), data, GL_STREAM_READ); assert(glGetError() == 0); if (range) { puts("Testing BindBufferRange."); piglit_BindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER_EXT, 0, buf, offset*sizeof(float), range*sizeof(float)); } else if (offset) { puts("Testing BindBufferOffset."); glBindBufferOffsetEXT(GL_TRANSFORM_FEEDBACK_BUFFER_EXT, 0, buf, offset*sizeof(float)); } else { puts("Testing BindBufferBase."); piglit_BindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER_EXT, 0, buf); } if (!range) { range = MAX_RANGE; } else { range = MAX_RANGE/2; /* just one primitive is going to be written */ } assert(glGetError() == 0); glClearColor(0.2, 0.2, 0.2, 1.0); glEnableClientState(GL_VERTEX_ARRAY); }