Subversion Repositories Kolibri OS

Rev

Rev 5362 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5362 Rev 5366
1
/*
1
/*
2
 * Copyright (c) 2007 Intel Corporation. All Rights Reserved.
2
 * Copyright (c) 2007 Intel Corporation. All Rights Reserved.
3
 *
3
 *
4
 * Permission is hereby granted, free of charge, to any person obtaining a
4
 * Permission is hereby granted, free of charge, to any person obtaining a
5
 * copy of this software and associated documentation files (the
5
 * copy of this software and associated documentation files (the
6
 * "Software"), to deal in the Software without restriction, including
6
 * "Software"), to deal in the Software without restriction, including
7
 * without limitation the rights to use, copy, modify, merge, publish,
7
 * without limitation the rights to use, copy, modify, merge, publish,
8
 * distribute, sub license, and/or sell copies of the Software, and to
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
9
 * permit persons to whom the Software is furnished to do so, subject to
10
 * the following conditions:
10
 * the following conditions:
11
 * 
11
 *
12
 * The above copyright notice and this permission notice (including the
12
 * The above copyright notice and this permission notice (including the
13
 * next paragraph) shall be included in all copies or substantial portions
13
 * next paragraph) shall be included in all copies or substantial portions
14
 * of the Software.
14
 * of the Software.
15
 * 
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
18
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19
 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
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,
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
21
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
 */
23
 */
24
 
24
 
25
#define TEST_DESCRIPTION	"Create and destory surfaces"
25
#define TEST_DESCRIPTION	"Create and destory surfaces"
26
 
26
 
27
#include "test_common.c"
27
#include "test_common.c"
28
 
28
 
29
void pre()
29
void pre()
30
{
30
{
31
    test_init();
31
    test_init();
32
}
32
}
33
 
33
 
34
#define DEAD_SURFACE_ID 	(VASurfaceID) 0xbeefdead
34
#define DEAD_SURFACE_ID 	(VASurfaceID) 0xbeefdead
35
 
35
 
36
void test_unique_surfaces(VASurfaceID *surface_list1, int surface_count1, VASurfaceID *surface_list2, int surface_count2)
36
void test_unique_surfaces(VASurfaceID *surface_list1, int surface_count1, VASurfaceID *surface_list2, int surface_count2)
37
{
37
{
38
    int i,j;
38
    int i,j;
39
    
39
 
40
    for(i = 0; i < surface_count1; i++)
40
    for(i = 0; i < surface_count1; i++)
41
    {
41
    {
42
        for(j = 0; j < surface_count2; j++)
42
        for(j = 0; j < surface_count2; j++)
43
        {
43
        {
44
            if ((surface_list1 == surface_list2) && (i == j)) continue;
44
            if ((surface_list1 == surface_list2) && (i == j)) continue;
45
            ASSERT(surface_list1[i] != VA_INVALID_SURFACE);
45
            ASSERT(surface_list1[i] != VA_INVALID_SURFACE);
46
            ASSERT(surface_list2[j] != VA_INVALID_SURFACE);
46
            ASSERT(surface_list2[j] != VA_INVALID_SURFACE);
47
            ASSERT(surface_list1[i] != surface_list2[j]);
47
            ASSERT(surface_list1[i] != surface_list2[j]);
48
        }
48
        }
49
    }
49
    }
50
}
50
}
51
 
51
 
52
 
52
 
53
void test()
53
void test()
54
{
54
{
55
    VASurfaceID surfaces_1[1+1];
55
    VASurfaceID surfaces_1[1+1];
56
    VASurfaceID surfaces_4[4+1];
56
    VASurfaceID surfaces_4[4+1];
57
    VASurfaceID surfaces_16[16+1];
57
    VASurfaceID surfaces_16[16+1];
58
    VASurfaceID surfaces_6[6+1];
58
    VASurfaceID surfaces_6[6+1];
59
    
59
 
60
    memset(surfaces_1, 0xff, sizeof(surfaces_1));
60
    memset(surfaces_1, 0xff, sizeof(surfaces_1));
61
    memset(surfaces_4, 0xff, sizeof(surfaces_4));
61
    memset(surfaces_4, 0xff, sizeof(surfaces_4));
62
    memset(surfaces_16, 0xff, sizeof(surfaces_16));
62
    memset(surfaces_16, 0xff, sizeof(surfaces_16));
63
    memset(surfaces_6, 0xff, sizeof(surfaces_6));
63
    memset(surfaces_6, 0xff, sizeof(surfaces_6));
64
 
64
 
65
    status("vaCreateSurfaces 1 surface\n");
65
    status("vaCreateSurfaces 1 surface\n");
66
    surfaces_1[1] = DEAD_SURFACE_ID;
66
    surfaces_1[1] = DEAD_SURFACE_ID;
67
    va_status = vaCreateSurfaces(va_dpy, VA_RT_FORMAT_YUV420, 352, 288, surfaces_1, 1, NULL, 0);
67
    va_status = vaCreateSurfaces(va_dpy, VA_RT_FORMAT_YUV420, 352, 288, surfaces_1, 1, NULL, 0);
68
    ASSERT( VA_STATUS_SUCCESS == va_status );
68
    ASSERT( VA_STATUS_SUCCESS == va_status );
69
    ASSERT( DEAD_SURFACE_ID == surfaces_1[1] ); /* bounds check */
69
    ASSERT( DEAD_SURFACE_ID == surfaces_1[1] ); /* bounds check */
70
 
70
 
71
    status("vaCreateSurfaces 4 surfaces\n");
71
    status("vaCreateSurfaces 4 surfaces\n");
72
    surfaces_4[4] = DEAD_SURFACE_ID;
72
    surfaces_4[4] = DEAD_SURFACE_ID;
73
    va_status = vaCreateSurfaces(va_dpy, VA_RT_FORMAT_YUV420, 352, 288, surfaces_4, 4, NULL, 0);
73
    va_status = vaCreateSurfaces(va_dpy, VA_RT_FORMAT_YUV420, 352, 288, surfaces_4, 4, NULL, 0);
74
    ASSERT( VA_STATUS_SUCCESS == va_status );
74
    ASSERT( VA_STATUS_SUCCESS == va_status );
75
    ASSERT( DEAD_SURFACE_ID == surfaces_4[4] ); /* bounds check */
75
    ASSERT( DEAD_SURFACE_ID == surfaces_4[4] ); /* bounds check */
76
 
76
 
77
    status("vaCreateSurfaces 16 surfaces\n");
77
    status("vaCreateSurfaces 16 surfaces\n");
78
    surfaces_16[16] = DEAD_SURFACE_ID;
78
    surfaces_16[16] = DEAD_SURFACE_ID;
79
    va_status = vaCreateSurfaces(va_dpy, VA_RT_FORMAT_YUV420, 352, 288, surfaces_16, 16, NULL, 0);
79
    va_status = vaCreateSurfaces(va_dpy, VA_RT_FORMAT_YUV420, 352, 288, surfaces_16, 16, NULL, 0);
80
    ASSERT( VA_STATUS_SUCCESS == va_status );
80
    ASSERT( VA_STATUS_SUCCESS == va_status );
81
    ASSERT( DEAD_SURFACE_ID == surfaces_16[16] ); /* bounds check */
81
    ASSERT( DEAD_SURFACE_ID == surfaces_16[16] ); /* bounds check */
82
    
82
 
83
    test_unique_surfaces(surfaces_1, 1, surfaces_4, 4);
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);
84
    test_unique_surfaces(surfaces_4, 4, surfaces_16, 16);
86
    test_unique_surfaces(surfaces_4, 1, surfaces_16, 16);
85
    test_unique_surfaces(surfaces_4, 1, surfaces_16, 16);
87
    test_unique_surfaces(surfaces_1, 16, surfaces_16, 16);
-
 
88
 
86
 
89
    status("vaDestroySurface 4 surfaces\n");
87
    status("vaDestroySurface 4 surfaces\n");
90
    va_status = vaDestroySurfaces(va_dpy, surfaces_4, 4);
88
    va_status = vaDestroySurfaces(va_dpy, surfaces_4, 4);
91
    ASSERT( VA_STATUS_SUCCESS == va_status );
89
    ASSERT( VA_STATUS_SUCCESS == va_status );
92
    
90
 
93
    status("vaCreateSurfaces 6 surfaces\n");
91
    status("vaCreateSurfaces 6 surfaces\n");
94
    surfaces_6[6] = DEAD_SURFACE_ID;
92
    surfaces_6[6] = DEAD_SURFACE_ID;
95
    va_status = vaCreateSurfaces(va_dpy, VA_RT_FORMAT_YUV420, 352, 288, surfaces_6, 6, NULL, 0);
93
    va_status = vaCreateSurfaces(va_dpy, VA_RT_FORMAT_YUV420, 352, 288, surfaces_6, 6, NULL, 0);
96
    ASSERT( VA_STATUS_SUCCESS == va_status );
94
    ASSERT( VA_STATUS_SUCCESS == va_status );
97
    ASSERT( DEAD_SURFACE_ID == surfaces_6[6] ); /* bounds check */
95
    ASSERT( DEAD_SURFACE_ID == surfaces_6[6] ); /* bounds check */
98
 
96
 
99
    test_unique_surfaces(surfaces_1, 1, surfaces_6, 6);
97
    test_unique_surfaces(surfaces_1, 1, surfaces_6, 6);
100
    test_unique_surfaces(surfaces_6, 6, surfaces_16, 16);
98
    test_unique_surfaces(surfaces_6, 6, surfaces_16, 16);
101
    test_unique_surfaces(surfaces_1, 6, surfaces_16, 6);
99
    test_unique_surfaces(surfaces_1, 1, surfaces_16, 16);
102
 
100
 
103
    status("vaDestroySurface 16 surfaces\n");
101
    status("vaDestroySurface 16 surfaces\n");
104
    va_status = vaDestroySurfaces(va_dpy, surfaces_16, 16);
102
    va_status = vaDestroySurfaces(va_dpy, surfaces_16, 16);
105
    ASSERT( VA_STATUS_SUCCESS == va_status );
103
    ASSERT( VA_STATUS_SUCCESS == va_status );
106
    
104
 
107
    status("vaDestroySurface 1 surface\n");
105
    status("vaDestroySurface 1 surface\n");
108
    va_status = vaDestroySurfaces(va_dpy, surfaces_1, 1);
106
    va_status = vaDestroySurfaces(va_dpy, surfaces_1, 1);
109
    ASSERT( VA_STATUS_SUCCESS == va_status );
107
    ASSERT( VA_STATUS_SUCCESS == va_status );
110
 
108
 
111
    status("vaDestroySurface 6 surfaces\n");
109
    status("vaDestroySurface 6 surfaces\n");
112
    va_status = vaDestroySurfaces(va_dpy, surfaces_6, 6);
110
    va_status = vaDestroySurfaces(va_dpy, surfaces_6, 6);
113
    ASSERT( VA_STATUS_SUCCESS == va_status );
111
    ASSERT( VA_STATUS_SUCCESS == va_status );
114
}
112
}
115
 
113
 
116
void post()
114
void post()
117
{
115
{
118
    test_terminate();
116
    test_terminate();
119
}
117
}