diff options
author | Marek Olšák <maraeo@gmail.com> | 2011-08-24 06:36:05 +0200 |
---|---|---|
committer | Marek Olšák <maraeo@gmail.com> | 2011-08-24 06:38:45 +0200 |
commit | 29bea467dbaa00be0deb792065b263aed379ab43 (patch) | |
tree | f144117b61b2229c62aaab7a8581277513c77f89 | |
parent | 1754f1947e77bda9cb01ec5eb56432735930c815 (diff) |
Add an ARB_transform_feedback2 test.
-rw-r--r-- | tests/all.tests | 4 | ||||
-rw-r--r-- | tests/spec/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/spec/arb_transform_feedback2/CMakeLists.gl.txt | 17 | ||||
-rw-r--r-- | tests/spec/arb_transform_feedback2/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/spec/arb_transform_feedback2/draw-auto.c | 173 |
5 files changed, 196 insertions, 0 deletions
diff --git a/tests/all.tests b/tests/all.tests index 0ea2eff5f..f91c34e21 100644 --- a/tests/all.tests +++ b/tests/all.tests @@ -1191,6 +1191,10 @@ ext_transform_feedback['query-primitives_written-bufferrange-discard'] = PlainE ext_transform_feedback['interleaved-attribs'] = PlainExecTest(['ext_transform_feedback-interleaved', '-auto']) ext_transform_feedback['separate-attribs'] = PlainExecTest(['ext_transform_feedback-separate', '-auto']) +arb_transform_feedback2 = Group() +spec['ARB_transform_feedback2'] = arb_transform_feedback2 +arb_transform_feedback2['draw-auto'] = PlainExecTest(['arb_transform_feedback2-draw-auto', '-auto']) + ati_draw_buffers = Group() spec['ATI_draw_buffers'] = ati_draw_buffers add_plain_test(ati_draw_buffers, 'ati_draw_buffers-arbfp') diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt index 4fd529173..94c53b8a0 100644 --- a/tests/spec/CMakeLists.txt +++ b/tests/spec/CMakeLists.txt @@ -9,6 +9,7 @@ add_subdirectory (arb_shader_texture_lod/execution) add_subdirectory (ati_draw_buffers) add_subdirectory (arb_texture_compression) add_subdirectory (arb_texture_float) +add_subdirectory (arb_transform_feedback2) add_subdirectory (ati_envmap_bumpmap) add_subdirectory (ext_fog_coord) add_subdirectory (ext_packed_depth_stencil) diff --git a/tests/spec/arb_transform_feedback2/CMakeLists.gl.txt b/tests/spec/arb_transform_feedback2/CMakeLists.gl.txt new file mode 100644 index 000000000..32b9a702c --- /dev/null +++ b/tests/spec/arb_transform_feedback2/CMakeLists.gl.txt @@ -0,0 +1,17 @@ +include_directories( + ${GLEXT_INCLUDE_DIR} + ${OPENGL_INCLUDE_PATH} + ${GLUT_INCLUDE_DIR} + ${piglit_SOURCE_DIR}/tests/util +) + +link_libraries ( + piglitutil + ${OPENGL_gl_LIBRARY} + ${OPENGL_glu_LIBRARY} + ${GLUT_glut_LIBRARY} +) + +add_executable (arb_transform_feedback2-draw-auto draw-auto.c) + +# vim: ft=cmake: diff --git a/tests/spec/arb_transform_feedback2/CMakeLists.txt b/tests/spec/arb_transform_feedback2/CMakeLists.txt new file mode 100644 index 000000000..144a306f4 --- /dev/null +++ b/tests/spec/arb_transform_feedback2/CMakeLists.txt @@ -0,0 +1 @@ +piglit_include_target_api() diff --git a/tests/spec/arb_transform_feedback2/draw-auto.c b/tests/spec/arb_transform_feedback2/draw-auto.c new file mode 100644 index 000000000..350af30e8 --- /dev/null +++ b/tests/spec/arb_transform_feedback2/draw-auto.c @@ -0,0 +1,173 @@ +/* + * Copyright © 2011 Marek Olšák <maraeo@gmail.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +/** + * Basic ARB_transform_feedback2 test. + * + * Test Pause, Resume, and DrawTF. + */ + +#include "piglit-util.h" + +int piglit_width = 64; +int piglit_height = 64; +int piglit_window_mode = GLUT_DOUBLE | GLUT_RGB | GLUT_ALPHA; + +static const char *vstext = { + "void main() {" + " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;" + " gl_FrontColor = gl_Color;" + "}" +}; +static const char *vstext_notransform = { + "void main() {" + " gl_Position = gl_Vertex + vec4(0.0, 0.625, 0.0, 0.0);" + " gl_FrontColor = gl_Color;" + "}" +}; + +static const char *varyings[] = {"gl_FrontColor", "gl_Position"}; +GLuint buf; +GLuint prog, prog_notransform; +GLuint tfb; + +void piglit_init(int argc, char **argv) +{ + GLuint vs; + GLint maxcomps; + + piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE); + + /* Check the driver. */ + if (!GLEW_VERSION_1_5) { + fprintf(stderr, "OpenGL 1.5 required.\n"); + piglit_report_result(PIGLIT_SKIP); + } + piglit_require_GLSL(); + piglit_require_extension("GL_EXT_transform_feedback"); + piglit_require_extension("GL_ARB_transform_feedback2"); + + glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT, &maxcomps); + if (maxcomps < 8) { + fprintf(stderr, "Not enough interleaved 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); + glTransformFeedbackVaryingsEXT(prog, sizeof(varyings)/sizeof(varyings[0]), + 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, vstext_notransform); + prog_notransform = piglit_link_simple_program(vs, 0); + + /* Set up transform feedback. */ + glGenBuffers(1, &buf); + glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER_EXT, buf); + glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER_EXT, + 18*8*sizeof(float), NULL, GL_STREAM_READ); + + glGenTransformFeedbacks(1, &tfb); + glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, tfb); + glBindBufferBaseEXT(GL_TRANSFORM_FEEDBACK_BUFFER_EXT, 0, buf); + glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0); + + assert(glGetError() == 0); + + glClearColor(0.2, 0.2, 0.2, 1.0); + glEnableClientState(GL_VERTEX_ARRAY); +} + +enum piglit_result piglit_display(void) +{ + GLboolean pass = GL_TRUE; + static const float verts[] = { + 10, 10, + 10, 20, + 20, 20, + 20, 10 + }; + static const float red[] = {1, 0, 0}; + static const float green[] = {0, 1, 0}; + static const float blue[] = {0, 0, 1}; + static const float clearcolor[] = {0.2, 0.2, 0.2}; + + glClear(GL_COLOR_BUFFER_BIT); + + /* Render into the TFBO. */ + piglit_UseProgram(prog); + glLoadIdentity(); + + glVertexPointer(2, GL_FLOAT, 0, verts); + + glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, tfb); + glBeginTransformFeedbackEXT(GL_TRIANGLES); + glColor3f(1, 0, 0); + glDrawArrays(GL_QUADS, 0, 4); + glPauseTransformFeedback(); + glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0); + + glTranslatef(20, 0, 0); + glColor3f(0, 1, 0); + glDrawArrays(GL_QUADS, 0, 4); + + glTranslatef(20, 0, 0); + glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, tfb); + glResumeTransformFeedback(); + glColor3f(0, 0, 1); + glDrawArrays(GL_QUADS, 0, 4); + glEndTransformFeedbackEXT(); + glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0); + + assert(glGetError() == 0); + + piglit_UseProgram(prog_notransform); + glBindBuffer(GL_ARRAY_BUFFER, buf); + glEnableClientState(GL_COLOR_ARRAY); + glColorPointer(4, GL_FLOAT, sizeof(float)*8, NULL); + glVertexPointer(4, GL_FLOAT, sizeof(float)*8, (void*)(intptr_t)(4*sizeof(float))); + glDrawTransformFeedback(GL_TRIANGLES, tfb); + glDisableClientState(GL_COLOR_ARRAY); + glBindBuffer(GL_ARRAY_BUFFER, 0); + + assert(glGetError() == 0); + + pass = piglit_probe_pixel_rgb(15, 15, red) && pass; + pass = piglit_probe_pixel_rgb(35, 15, green) && pass; + pass = piglit_probe_pixel_rgb(55, 15, blue) && pass; + + pass = piglit_probe_pixel_rgb(15, 35, red) && pass; + pass = piglit_probe_pixel_rgb(35, 35, clearcolor) && pass; + pass = piglit_probe_pixel_rgb(55, 35, blue) && pass; + + glutSwapBuffers(); + + return pass ? PIGLIT_PASS : PIGLIT_FAIL; +} |