summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShuang He <shuang.he@intel.com>2010-01-20 13:09:53 +0800
committerIan Romanick <ian.d.romanick@intel.com>2010-03-05 12:21:22 -0800
commitd7f4e195f8eb0e4a5bce266012a7d435f9a258c8 (patch)
treea3c63d689eeca3746cf2677cb10a2ed430ef2d66
parent926bbdcc84f43cdb09de21c8b69659c251d1a3be (diff)
object_purgeable-api-pbo: New testcase to simply exercise API
-rw-r--r--tests/all.tests1
-rw-r--r--tests/general/CMakeLists.txt1
-rw-r--r--tests/general/object_purgeable-api-pbo.c282
3 files changed, 284 insertions, 0 deletions
diff --git a/tests/all.tests b/tests/all.tests
index 6139d524..8e762441 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -95,6 +95,7 @@ add_plain_test(general, 'dlist-fdo3129-01')
add_plain_test(general, 'dlist-fdo3129-02')
add_plain_test(general, 'draw-elements-base-vertex')
add_plain_test(general, 'linestipple')
+add_plain_test(general, 'object_purgeable-api-pbo')
add_plain_test(general, 'object_purgeable-api-texture')
add_plain_test(general, 'object_purgeable-api-vbo')
add_plain_test(general, 'occlusion_query')
diff --git a/tests/general/CMakeLists.txt b/tests/general/CMakeLists.txt
index a808112b..b9a6c741 100644
--- a/tests/general/CMakeLists.txt
+++ b/tests/general/CMakeLists.txt
@@ -55,6 +55,7 @@ add_executable (varray-disabled varray-disabled.c)
add_executable (vbo-map-remap vbo-map-remap.c)
add_executable (vbo-subdata-sync vbo-subdata-sync.c)
add_executable (windowoverlap windowoverlap.c)
+add_executable (object_purgeable-api-pbo object_purgeable-api-pbo.c)
add_executable (object_purgeable-api-texture object_purgeable-api-texture.c)
add_executable (object_purgeable-api-vbo object_purgeable-api-vbo.c)
add_executable (occlusion_query occlusion_query.c)
diff --git a/tests/general/object_purgeable-api-pbo.c b/tests/general/object_purgeable-api-pbo.c
new file mode 100644
index 00000000..21a74c16
--- /dev/null
+++ b/tests/general/object_purgeable-api-pbo.c
@@ -0,0 +1,282 @@
+/*
+ * Copyright © 2010 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.
+ *
+ * Authors:
+ * Shuang He <shuang.he@intel.com>
+ */
+
+/**
+ * \file object_purgeable-api-pbo.c
+ * Simple test of the API for GL_APPLE_object_purgeable with GL_ARB_pixel_buffer_object.
+ */
+
+#include "piglit-util.h"
+
+#define FAIL_ON_ERROR(string) \
+ do { \
+ const GLenum err = glGetError(); \
+ if (err != GL_NO_ERROR) { \
+ fprintf(stderr, "%s generated error 0x%04x\n", \
+ string, err); \
+ pass = GL_FALSE; \
+ } \
+ } while (0)
+
+#ifndef APIENTRY
+#define APIENTRY
+#endif
+#ifndef APIENTRYP
+#define APIENTRYP APIENTRY *
+#endif
+
+#ifndef GL_APPLE_object_purgeable
+#define GL_APPLE_object_purgeable 1
+
+#define GL_RELEASED_APPLE 0x8A19
+#define GL_VOLATILE_APPLE 0x8A1A
+#define GL_RETAINED_APPLE 0x8A1B
+#define GL_UNDEFINED_APPLE 0x8A1C
+#define GL_PURGEABLE_APPLE 0x8A1D
+#define GL_BUFFER_OBJECT_APPLE 0x85B3
+
+typedef GLenum (APIENTRYP PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option);
+typedef GLenum (APIENTRYP PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option);
+typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint* params);
+
+#endif
+
+#ifndef GL_ARB_pixel_buffer_object
+#define GL_ARB_pixel_buffer_object 1
+
+#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB
+#define GL_STATIC_DRAW_ARB 0x88E0
+
+typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer);
+typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers);
+typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers);
+typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage);
+
+#endif
+
+// GL_APPLE_object_purgeable
+static PFNGLOBJECTPURGEABLEAPPLEPROC pglObjectPurgeableAPPLE = NULL;
+static PFNGLOBJECTUNPURGEABLEAPPLEPROC pglObjectUnpurgeableAPPLE = NULL;
+static PFNGLGETOBJECTPARAMETERIVAPPLEPROC pglGetObjectParameterivAPPLE = NULL;
+
+
+// GL_ARB_vertex_buffer_object GL_ARB_pixel_buffer_object
+static PFNGLBINDBUFFERARBPROC pglBindBufferARB = NULL;
+static PFNGLDELETEBUFFERSARBPROC pglDeleteBuffersARB = NULL;
+static PFNGLGENBUFFERSARBPROC pglGenBuffersARB = NULL;
+static PFNGLBUFFERDATAARBPROC pglBufferDataARB = NULL;
+
+
+static GLboolean Automatic = GL_FALSE;
+
+static void
+init(void)
+{
+ piglit_require_extension("GL_APPLE_object_purgeable");
+ piglit_require_extension("GL_ARB_pixel_buffer_object");
+
+ pglObjectPurgeableAPPLE = (PFNGLOBJECTPURGEABLEAPPLEPROC) piglit_get_proc_address("glObjectPurgeableAPPLE");
+ pglObjectUnpurgeableAPPLE = (PFNGLOBJECTUNPURGEABLEAPPLEPROC) piglit_get_proc_address("glObjectUnpurgeableAPPLE");
+ pglGetObjectParameterivAPPLE = (PFNGLGETOBJECTPARAMETERIVAPPLEPROC) piglit_get_proc_address("glGetObjectParameterivAPPLE");
+
+ pglGenBuffersARB = (PFNGLGENBUFFERSARBPROC) piglit_get_proc_address("glGenBuffersARB");
+ pglBindBufferARB = (PFNGLBINDBUFFERARBPROC) piglit_get_proc_address("glBindBufferARB");
+ pglDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC) piglit_get_proc_address("glDeleteBuffersARB");
+ pglBufferDataARB = (PFNGLBUFFERDATAARBPROC) piglit_get_proc_address("glBufferDataARB");
+
+ glClearColor(0.1, 0.1, 0.3, 0.0);
+}
+
+
+static void
+reshape(int width, int height)
+{
+ glViewport(0, 0, (GLint) width, (GLint) height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+
+GLboolean
+test_ObjectpurgeableAPPLE(GLenum objectType, GLuint name, GLenum option)
+{
+ GLboolean pass = GL_TRUE;
+ GLenum ret;
+ ret = (*pglObjectPurgeableAPPLE)(objectType, name, option);
+ FAIL_ON_ERROR("pglObjectpurgeableAPPLE");
+ switch (option) {
+ case GL_VOLATILE_APPLE:
+ if (ret != GL_VOLATILE_APPLE) {
+ fprintf(stderr, "GL_VOLATILE_APPLE should be returned when call purgeable with GL_VOLATILE_APPLE\n");
+ pass = GL_FALSE;
+ }
+ break;
+ case GL_RELEASED_APPLE:
+ if (ret != GL_VOLATILE_APPLE && ret != GL_RELEASED_APPLE) {
+ fprintf(stderr, "GL_VOLATILE_APPLE or GL_RELEASED_APPLE should be returned when call purgeable with GL_RELEASED_APPLE\n");
+ pass = GL_FALSE;
+ }
+ break;
+ }
+
+ return pass;
+}
+
+
+GLboolean
+test_ObjectunpurgeableAPPLE(GLenum objectType, GLuint name, GLenum option)
+{
+ GLboolean pass = GL_TRUE;
+ GLenum ret;
+ ret = (*pglObjectUnpurgeableAPPLE)(objectType, name, option);
+ FAIL_ON_ERROR("pglObjectunpurgeableAPPLE");
+ switch (option) {
+ case GL_RETAINED_APPLE:
+ if (ret != GL_RETAINED_APPLE && ret != GL_UNDEFINED_APPLE) {
+ fprintf(stderr, "GL_RETAINED_APPLE or GL_UNDEFINED_APPLE should be returned when call purgeable with GL_RETAINED_APPLE\n");
+ pass = GL_FALSE;
+ }
+ break;
+ case GL_UNDEFINED_APPLE:
+ if (ret != GL_UNDEFINED_APPLE) {
+ fprintf(stderr, "GL_UNDEFINED_APPLE should be returned when call purgeable with GL_UNDEFINED_APPLE\n");
+ pass = GL_FALSE;
+ }
+ break;
+ }
+ return pass;
+}
+
+GLboolean
+test_GetObjectParameterivAPPLE(GLenum objectType, GLuint name, GLenum expect)
+{
+ GLboolean pass = GL_TRUE;
+ GLint param;
+ (*pglGetObjectParameterivAPPLE)(objectType, name, GL_PURGEABLE_APPLE, &param);
+ FAIL_ON_ERROR("glGetObjectParameterivAPPLE");
+
+ if (param != expect) {
+ fprintf(stderr, "GL_PURGEABLE_APPLE state is not set to GL_TRUE for texture object\n");
+ pass = GL_FALSE;
+ }
+
+ return pass;
+}
+
+
+static void
+display(void)
+{
+ GLuint pbo;
+ GLboolean pass = GL_TRUE;
+
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glGetError();
+
+ (*pglGenBuffersARB)(1, &pbo);
+ (*pglBindBufferARB)(GL_PIXEL_PACK_BUFFER_ARB, pbo);
+ (*pglBufferDataARB)(GL_PIXEL_PACK_BUFFER_ARB, 100*100, NULL, GL_STATIC_DRAW_ARB);
+ (*pglBindBufferARB)(GL_PIXEL_PACK_BUFFER_ARB, 0);
+
+
+ if (test_GetObjectParameterivAPPLE(GL_BUFFER_OBJECT_APPLE, pbo, GL_FALSE) != GL_TRUE) {
+ fprintf(stderr, "Default GL_PURGEABLE_APPLE state should GL_FALSE for texture object\n");
+ pass = GL_FALSE;
+ }
+
+ if (test_ObjectpurgeableAPPLE(GL_BUFFER_OBJECT_APPLE, pbo, GL_VOLATILE_APPLE) != GL_TRUE) {
+ fprintf(stderr, "Error when mark object %x to purgeable(GL_VOLATILE_APPLE)\n", pbo);
+ pass = GL_FALSE;
+ }
+
+ if (test_GetObjectParameterivAPPLE(GL_BUFFER_OBJECT_APPLE, pbo, GL_TRUE) != GL_TRUE) {
+ fprintf(stderr, "Object %x is not set to purgeable\n", pbo);
+ pass = GL_FALSE;
+ }
+
+ if (test_ObjectunpurgeableAPPLE(GL_BUFFER_OBJECT_APPLE, pbo, GL_RETAINED_APPLE) != GL_TRUE) {
+ fprintf(stderr, "Error when mark object %x to unpurgeable(GL_RETAINED_APPLE)\n", pbo);
+ pass = GL_FALSE;
+ }
+
+ if (test_GetObjectParameterivAPPLE(GL_BUFFER_OBJECT_APPLE, pbo, GL_FALSE) != GL_TRUE) {
+ fprintf(stderr, "Object %x is not set to unpurgeable\n", pbo);
+ pass = GL_FALSE;
+ }
+
+ if (test_ObjectpurgeableAPPLE(GL_BUFFER_OBJECT_APPLE, pbo, GL_RELEASED_APPLE) != GL_TRUE) {
+ fprintf(stderr, "Error when mark object %x to purgeable(GL_RELEASED_APPLE)\n", pbo);
+ pass = GL_FALSE;
+ }
+
+ if (test_GetObjectParameterivAPPLE(GL_BUFFER_OBJECT_APPLE, pbo, GL_TRUE) != GL_TRUE) {
+ fprintf(stderr, "Object %x is not set to purgeable\n", pbo);
+ pass = GL_FALSE;
+ }
+
+ if (test_ObjectunpurgeableAPPLE(GL_BUFFER_OBJECT_APPLE, pbo, GL_UNDEFINED_APPLE) != GL_TRUE) {
+ fprintf(stderr, "Error when mark object %x to unpurgeable(GL_UNDEFINED_APPLE)\n", pbo);
+ pass = GL_FALSE;
+ }
+
+ if (test_GetObjectParameterivAPPLE(GL_BUFFER_OBJECT_APPLE, pbo, GL_FALSE) != GL_TRUE) {
+ fprintf(stderr, "Object %x is not set to unpurgeable\n", pbo);
+ pass = GL_FALSE;
+ }
+
+
+ (*pglDeleteBuffersARB)(1, &pbo);
+
+
+ if (Automatic)
+ piglit_report_result(pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE);
+}
+
+
+int main(int argc, char **argv)
+{
+ glutInit(&argc, argv);
+
+ if (argc == 2 && !strcmp(argv[1], "-auto"))
+ Automatic = GL_TRUE;
+
+ glutInitWindowSize(400, 300);
+ glutInitDisplayMode(GLUT_RGB);
+ glutCreateWindow("GL_APPLE_object_purgeable API test with GL_ARB_pixel_buffer_object");
+ glutReshapeFunc(reshape);
+ glutKeyboardFunc(piglit_escape_exit_key);
+ glutDisplayFunc(display);
+
+ init();
+
+ glutMainLoop();
+ return 0;
+}
+