2 * Copyright (c) 2007 Intel Corporation. All Rights Reserved.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sub license, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
20 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 #define TEST_DESCRIPTION "Create and destory surfaces"
27 #include "test_common.c"
34 #define DEAD_SURFACE_ID (VASurfaceID) 0xbeefdead
36 void test_unique_surfaces(VASurface *surface_list1, int surface_count1, VASurface *surface_list2, int surface_count2)
40 for(i = 0; i < surface_count1; i++)
42 for(j = 0; j < surface_count2; j++)
44 if ((surface_list1 == surface_list2) && (i == j)) continue;
45 ASSERT(surface_list1[i].surface_id != VA_INVALID_SURFACE);
46 ASSERT(surface_list2[j].surface_id != VA_INVALID_SURFACE);
47 ASSERT(surface_list1[i].surface_id != surface_list2[j].surface_id);
55 VASurface surfaces_1[1+1];
56 VASurface surfaces_4[4+1];
57 VASurface surfaces_16[16+1];
58 VASurface surfaces_6[6+1];
60 memset(surfaces_1, 0xff, sizeof(surfaces_1));
61 memset(surfaces_4, 0xff, sizeof(surfaces_4));
62 memset(surfaces_16, 0xff, sizeof(surfaces_16));
63 memset(surfaces_6, 0xff, sizeof(surfaces_6));
65 status("vaCreateSurfaces 1 surface\n");
66 surfaces_1[1].surface_id = DEAD_SURFACE_ID;
67 va_status = vaCreateSurfaces(va_dpy, 352, 288, VA_RT_FORMAT_YUV420, 1, surfaces_1);
68 ASSERT( VA_STATUS_SUCCESS == va_status );
69 ASSERT( DEAD_SURFACE_ID == surfaces_1[1].surface_id ); /* bounds check */
71 status("vaCreateSurfaces 4 surfaces\n");
72 surfaces_4[4].surface_id = DEAD_SURFACE_ID;
73 va_status = vaCreateSurfaces(va_dpy, 352, 288, VA_RT_FORMAT_YUV420, 4, surfaces_4);
74 ASSERT( VA_STATUS_SUCCESS == va_status );
75 ASSERT( DEAD_SURFACE_ID == surfaces_4[4].surface_id ); /* bounds check */
77 status("vaCreateSurfaces 16 surfaces\n");
78 surfaces_16[16].surface_id = DEAD_SURFACE_ID;
79 va_status = vaCreateSurfaces(va_dpy, 352, 288, VA_RT_FORMAT_YUV420, 16, surfaces_16);
80 ASSERT( VA_STATUS_SUCCESS == va_status );
81 ASSERT( DEAD_SURFACE_ID == surfaces_16[16].surface_id ); /* bounds check */
83 test_unique_surfaces(surfaces_1, 1, surfaces_4, 4);
84 test_unique_surfaces(surfaces_4, 4, surfaces_16, 4);
85 test_unique_surfaces(surfaces_4, 4, surfaces_16, 16);
86 test_unique_surfaces(surfaces_4, 1, surfaces_16, 16);
87 test_unique_surfaces(surfaces_1, 16, surfaces_16, 16);
89 status("vaDestroySurface 4 surfaces\n");
90 va_status = vaDestroySurface(va_dpy, surfaces_4, 4);
91 ASSERT( VA_STATUS_SUCCESS == va_status );
93 status("vaCreateSurfaces 6 surfaces\n");
94 surfaces_6[6].surface_id = DEAD_SURFACE_ID;
95 va_status = vaCreateSurfaces(va_dpy, 352, 288, VA_RT_FORMAT_YUV420, 6, surfaces_6);
96 ASSERT( VA_STATUS_SUCCESS == va_status );
97 ASSERT( DEAD_SURFACE_ID == surfaces_6[6].surface_id ); /* bounds check */
99 test_unique_surfaces(surfaces_1, 1, surfaces_6, 6);
100 test_unique_surfaces(surfaces_6, 6, surfaces_16, 16);
101 test_unique_surfaces(surfaces_1, 6, surfaces_16, 6);
103 status("vaDestroySurface 16 surfaces\n");
104 va_status = vaDestroySurface(va_dpy, surfaces_16, 16);
105 ASSERT( VA_STATUS_SUCCESS == va_status );
107 status("vaDestroySurface 1 surface\n");
108 va_status = vaDestroySurface(va_dpy, surfaces_1, 1);
109 ASSERT( VA_STATUS_SUCCESS == va_status );
111 status("vaDestroySurface 6 surfaces\n");
112 va_status = vaDestroySurface(va_dpy, surfaces_6, 6);
113 ASSERT( VA_STATUS_SUCCESS == va_status );