/* * Copyright © 2011 Intel Corporation * * 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. */ /** @file api.c * * Tests API support for EXT_Transform_feedback */ #include "piglit-util.h" #define GL_GLEXT_PROTOTYPES #include "glew.h" #define BUF_WIDTH 15 #define BUF_HEIGHT 15 int piglit_window_mode = GLUT_DOUBLE | GLUT_RGB | GLUT_ALPHA; int piglit_width = BUF_WIDTH; int piglit_height = BUF_WIDTH; /** * New parameter for BindBuffer, BufferData, * BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData, * GetBufferPointerv, BindBufferRangeEXT, BindBufferOffsetEXT and * BindBufferBaseEXT: * * TRANSFORM_FEEDBACK_BUFFER_EXT */ static bool test_new_tokens_feedback_buffer_ext() { bool pass = true; GLuint buffer; void *data; GLenum valid_target = GL_TRANSFORM_FEEDBACK_BUFFER_EXT; GLenum valid_accesses[] = { GL_READ_ONLY, GL_WRITE_ONLY, GL_READ_WRITE, }; GLenum error; int i; glGenBuffers(1, &buffer); /* BindBuffer test */ glBindBuffer(valid_target, buffer); error = glGetError(); if (error == GL_INVALID_ENUM) { pass = false; } /* Test MapBuffer/UnmapBuffer with all kind of accesses */ for (i=0; i < sizeof(valid_accesses) / sizeof(valid_accesses[0]); i++) { data = glMapBuffer(buffer, valid_accesses[i]); /* TODO: check if data is set correctly - perhaps for operational test */ error = glGetError(); if (error == GL_INVALID_ENUM) { pass = false; } /* UnmapBuffer */ glUnmapBuffer(buffer); error = glGetError(); if (error == GL_INVALID_ENUM) { pass = false; } } /* Test GetBufferSubData */ /* glGetBufferSubData(valid_target, 0, 0, data); error = glGetError(); if (error == GL_INVALID_ENUM) { pass = false; } */ /* TODO: test GetBufferPointerv */ /* New function calls provided by the extension */ /* TODO: test GetBindBufferRangeEXT */ /* TODO: test GetBindBufferOffsetEXT */ /* TODO: test GetBindBufferBaseEXT */ glDeleteBuffers(1, &buffer); return pass; } /** * New parameter for: * GetIntegerIndexedvEXT and GetBooleanIndexedvEX: * * TRANSFORM_FEEDBACK_BUFFER_START_EXT * TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT * */ static bool test_new_tokens_feedback_buffer_start_size() { bool pass = true; /* TODO: those functions will become available when the extension will be * implemented in mesa */ return pass; } /** * * New parameter for: * GetIntegerIndexedvEXT and GetBooleanIndexedvEXT: * Also, new parameter for: * GetBooleanv, GetDoublev, GetIntegerv, and GetFloatv: * * TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT * */ static bool test_new_tokens_feedback_buffer_binding() { bool pass = true; return pass; } /** * New parameters for TransformFeedbackVaryingsEXT: * * INTERLEAVED_ATTRIBS_EXT * SEPARATE_ATTRIBS_EXT * * */ static bool test_new_tokens_feedback_attribs() { bool pass = true; return pass; } /** * New parameter for Enable, Disable, and IsEnabled: * RASTERIZER_DISCARD_EXT * */ static bool test_new_tokens_enable_disable() { bool pass = true; GLenum error; GLenum capability = GL_RASTERIZER_DISCARD_EXT; /* glEnable */ glEnable(capability); error = glGetError(); if (error == GL_INVALID_ENUM) { pass = false; } /* glIsEnabled */ glIsEnabled(capability); error = glGetError(); if (error == GL_INVALID_ENUM) { pass = false; } /* glDisable */ glDisable(capability); error = glGetError(); if (error == GL_INVALID_ENUM) { pass = false; } return pass; } /** * New parameter for GetBooleanv, GetDoublev, GetIntegerv, * and GetFloatv: * * MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT * MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT * MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT * RASTERIZER_DISCARD_EXT * * */ static bool test_new_tokens_get_v() { bool pass = true; GLenum valid_targets[] = { GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT, GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT, GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT, GL_RASTERIZER_DISCARD_EXT, }; GLenum error; GLboolean pvalue_b; GLdouble pvalue_d; GLint pvalue_i; GLfloat pvalue_f; int i; for (i=0; i < sizeof(valid_targets) / sizeof(valid_targets[0]); i++) { /* Getting objects */ glGetBooleanv(valid_targets[i], &pvalue_b); error = glGetError(); if (error == GL_INVALID_ENUM) { pass = false; } glGetDoublev(valid_targets[i], &pvalue_d); error = glGetError(); if (error == GL_INVALID_ENUM) { pass = false; } glGetIntegerv(valid_targets[i], &pvalue_i); error = glGetError(); if (error == GL_INVALID_ENUM) { pass = false; } glGetFloatv(valid_targets[i], &pvalue_f); error = glGetError(); if (error == GL_INVALID_ENUM) { pass = false; } } return pass; } /** * New parameter for GetProgramiv: * * TRANSFORM_FEEDBACK_VARYINGS_EXT * TRANSFORM_FEEDBACK_BUFFER_MODE_EXT * TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT */ static bool test_new_tokens_feedback_getprogramiv() { bool pass = true; return pass; } /** * New parameters for glBeginQuery / glEndQuery: * * PRIMITIVES_GENERATED_EXT * TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT */ static bool test_begin_end_query() { bool pass = true; const GLenum valid_targets[] = { GL_PRIMITIVES_GENERATED_EXT, GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT, }; const GLenum invalid_targets[] = { 0, -1, GL_SEPARATE_ATTRIBS_EXT, }; GLuint query; int i; GLenum error; /* Generate query object */ glGenQueries(1, &query); /** * Test for BeginQuery/EndQuery targets with valid id */ for (i=0; i < sizeof(valid_targets) / sizeof(valid_targets[0]); i++) { glBeginQuery(valid_targets[i], query); error = glGetError(); if (error == GL_INVALID_OPERATION) { pass = false; } glEndQuery(valid_targets[i]); } /** * Test for BeginQuery/EndQuery targets with id of 0 * this test is expected to fail when: * - there is any active query object out there * - its id is not 0 */ for (i=0; i < sizeof(valid_targets) / sizeof(valid_targets[0]); i++) { /* 1st case */ /* TODO: verify if query is not 0 */ glBeginQuery(valid_targets[i], query); glBeginQuery(valid_targets[i], 0); error = glGetError(); if (error != GL_INVALID_OPERATION) { pass = false; } glEndQuery(valid_targets[i]); /* 2nd case */ glBeginQuery(valid_targets[i], 0); error = glGetError(); if (error != GL_INVALID_OPERATION) { pass = false; } glEndQuery(valid_targets[i]); } /** * Test for BeginQuery/EndQuery with invalid targets * this test is expected to fail */ for (i=0; i < sizeof(invalid_targets) / sizeof(invalid_targets[0]); i++) { glBeginQuery(invalid_targets[i], query); error = glGetError(); if (error != GL_INVALID_OPERATION) { pass = false; } glEndQuery(invalid_targets[i]); } glDeleteQueries(1, &query); return pass; } static bool test() { bool pass, result=true; pass = test_new_tokens_feedback_buffer_ext(); if (pass != true) result = false; pass = test_new_tokens_feedback_buffer_start_size(); if (pass != true) result = false; pass = test_new_tokens_feedback_buffer_binding(); if (pass != true) result = false; pass = test_new_tokens_feedback_attribs(); if (pass != true) result = false; pass = test_new_tokens_enable_disable(); if (pass != true) result = false; pass = test_new_tokens_get_v(); if (pass != true) result = false; pass = test_new_tokens_feedback_getprogramiv(); if (pass != true) result = false; pass = test_begin_end_query(); if (pass != true) result = false; return result; } void piglit_init(int argc, char **argv) { bool pass = true; glewInit(); piglit_require_extension("GL_EXT_transform_feedback"); pass = test(); piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); } enum piglit_result piglit_display(void) { /* UNREACHED */ return PIGLIT_FAIL; }