1 /**************************************************************************
2 *
3 * Copyright (C) 2014 Red Hat Inc.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included
13 * in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 * OTHER DEALINGS IN THE SOFTWARE.
22 *
23 **************************************************************************/
24
25 /*
26 * resource tests
27 * test illegal resource combinations
28 - 1D resources with height or depth
29 - 2D with depth
30 */
31 #include <check.h>
32 #include <stdlib.h>
33 #include <errno.h>
34 #include <virglrenderer.h>
35 #include "virgl_hw.h"
36 #include "testvirgl.h"
37
38 #include "pipe/p_defines.h"
39 #include "pipe/p_format.h"
40
41 #ifndef ARRAY_SIZE
42 # define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
43 #endif
44
45 struct res_test {
46 struct virgl_renderer_resource_create_args args;
47 int retval;
48 };
49
50 #define TEST(thandle, ttarget, tformat, tbind, twidth, theight, tdepth, tarray_size, tnr_samples, tretval) \
51 { .args = { .handle = (thandle), \
52 .target = (ttarget), \
53 .format = (tformat), \
54 .bind = (tbind), \
55 .width = (twidth), \
56 .height = (theight), \
57 .depth = (tdepth), \
58 .array_size = (tarray_size), \
59 .last_level = 0, \
60 .nr_samples = (tnr_samples), \
61 .flags = 0 }, \
62 .retval = (tretval)}
63
64 #define TEST_MIP(thandle, ttarget, tformat, tbind, twidth, theight, tdepth, tarray_size, tnr_samples, tlast_level, tretval) \
65 { .args = { .handle = (thandle), \
66 .target = (ttarget), \
67 .format = (tformat), \
68 .bind = (tbind), \
69 .width = (twidth), \
70 .height = (theight), \
71 .depth = (tdepth), \
72 .array_size = (tarray_size), \
73 .last_level = (tlast_level), \
74 .nr_samples = (tnr_samples), \
75 .flags = 0 }, \
76 .retval = (tretval)}
77
78 #define TEST_F(thandle, ttarget, tformat, tbind, twidth, theight, tdepth, tarray_size, tnr_samples, tflags, tretval) \
79 { .args = { .handle = (thandle), \
80 .target = (ttarget), \
81 .format = (tformat), \
82 .bind = (tbind), \
83 .width = (twidth), \
84 .height = (theight), \
85 .depth = (tdepth), \
86 .array_size = (tarray_size), \
87 .nr_samples = (tnr_samples), \
88 .flags = (tflags) }, \
89 .retval = (tretval)}
90
91
92 static struct res_test testlist[] = {
93 /* 0 illegal target - FAIL */
94 TEST(1, PIPE_MAX_TEXTURE_TYPES + 1, PIPE_FORMAT_R8_UNORM, 0, 50, 1, 1, 1, 0, EINVAL),
95
96 /* 1 illegal format - FAIL */
97 TEST(1, PIPE_BUFFER, PIPE_FORMAT_COUNT + 1, 0, 50, 1, 1, 1, 0, EINVAL),
98
99 /* 2 legal flags - PASS */
100 TEST_F(1, PIPE_TEXTURE_2D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 0, VIRGL_RESOURCE_Y_0_TOP, 0),
101 /* 3 legal flags - PASS */
102 TEST_F(1, PIPE_TEXTURE_RECT, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 0, VIRGL_RESOURCE_Y_0_TOP, 0),
103 /* 4 illegal flags - FAIL */
104 TEST_F(1, PIPE_TEXTURE_2D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 0, 0xF, EINVAL),
105 /* 5 illegal flags - FAIL */
106 TEST_F(1, PIPE_TEXTURE_1D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 0, VIRGL_RESOURCE_Y_0_TOP, EINVAL),
107 /* 6 illegal flags - FAIL */
108 TEST_F(1, PIPE_TEXTURE_3D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 0, VIRGL_RESOURCE_Y_0_TOP, EINVAL),
109
110 /* 7 buffer test - PASS */
111 TEST(1, PIPE_BUFFER, PIPE_FORMAT_R8_UNORM, 0, 50, 1, 1, 1, 0, 0),
112 /* 8 buffer test with height - FAIL */
113 TEST(1, PIPE_BUFFER, PIPE_FORMAT_R8_UNORM, 0, 50, 50, 1, 1, 0, EINVAL),
114 /* 9 buffer test with depth - FAIL */
115 TEST(1, PIPE_BUFFER, PIPE_FORMAT_R8_UNORM, 0, 50, 1, 5, 1, 0, EINVAL),
116 /* 10 buffer test with array - FAIL */
117 TEST(1, PIPE_BUFFER, PIPE_FORMAT_R8_UNORM, 0, 50, 1, 1, 4, 0, EINVAL),
118 /* 11 buffer test with samples - FAIL */
119 TEST(1, PIPE_BUFFER, PIPE_FORMAT_R8_UNORM, 0, 50, 1, 1, 1, 4, EINVAL),
120 /* 12 buffer test with miplevels - FAIL */
121 TEST_MIP(1, PIPE_BUFFER, PIPE_FORMAT_R8_UNORM, 0, 50, 1, 1, 1, 1, 4, EINVAL),
122
123 /* 13 buffer test - sampler view */
124 TEST(1, PIPE_BUFFER, PIPE_FORMAT_R8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 0, 0),
125 /* 14 buffer test - custom binding */
126 TEST(1, PIPE_BUFFER, PIPE_FORMAT_R8_UNORM, PIPE_BIND_CUSTOM, 50, 1, 1, 1, 0, 0),
127 /* 15 buffer test - vertex binding */
128 TEST(1, PIPE_BUFFER, PIPE_FORMAT_R8_UNORM, PIPE_BIND_VERTEX_BUFFER, 50, 1, 1, 1, 0, 0),
129 /* 16 buffer test - index binding */
130 TEST(1, PIPE_BUFFER, PIPE_FORMAT_R8_UNORM, PIPE_BIND_INDEX_BUFFER, 50, 1, 1, 1, 0, 0),
131 /* 17 buffer test - constant binding */
132 TEST(1, PIPE_BUFFER, PIPE_FORMAT_R8_UNORM, PIPE_BIND_CONSTANT_BUFFER, 50, 1, 1, 1, 0, 0),
133 /* 18 buffer test - stream binding */
134 TEST(1, PIPE_BUFFER, PIPE_FORMAT_R8_UNORM, PIPE_BIND_STREAM_OUTPUT, 50, 1, 1, 1, 0, 0),
135
136 /* 19 1D test - stream binding - FAIL */
137 TEST(1, PIPE_TEXTURE_1D, PIPE_FORMAT_R8_UNORM, PIPE_BIND_VERTEX_BUFFER, 50, 1, 1, 1, 0, EINVAL),
138 /* 20 1D test - no binding - FAIL */
139 TEST(1, PIPE_TEXTURE_1D, PIPE_FORMAT_R8_UNORM, 0, 50, 1, 1, 1, 0, EINVAL),
140
141 /* 21 1D texture - PASS */
142 TEST(1, PIPE_TEXTURE_1D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 0, 0),
143 /* 22 1D texture with height - FAIL */
144 TEST(1, PIPE_TEXTURE_1D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 50, 1, 1, 0, EINVAL),
145 /* 23 1D texture with depth - FAIL */
146 TEST(1, PIPE_TEXTURE_1D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 5, 1, 0, EINVAL),
147 /* 24 1D texture with array - FAIL */
148 TEST(1, PIPE_TEXTURE_1D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 5, 0, EINVAL),
149 /* 25 1D texture with samples - FAIL */
150 TEST(1, PIPE_TEXTURE_1D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 4, EINVAL),
151 /* 26 1D texture with miplevels - PASS */
152 TEST_MIP(1, PIPE_TEXTURE_1D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 0, 4, 0),
153
154 /* 27 1D array texture - PASS */
155 TEST(1, PIPE_TEXTURE_1D_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 0, 0),
156 /* 28 1D array texture with height - FAIL */
157 TEST(1, PIPE_TEXTURE_1D_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 50, 1, 1, 0, EINVAL),
158 /* 29 1D texture with depth - FAIL */
159 TEST(1, PIPE_TEXTURE_1D_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 5, 1, 0, EINVAL),
160 /* 30 1D texture with array - PASS */
161 TEST(1, PIPE_TEXTURE_1D_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 5, 0, 0),
162 /* 31 1D texture with samples - FAIL */
163 TEST(1, PIPE_TEXTURE_1D_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 4, EINVAL),
164 /* 32 1D array texture with miplevels - PASS */
165 TEST_MIP(1, PIPE_TEXTURE_1D_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 0, 4, 0),
166
167 /* 33 2D texture - PASS */
168 TEST(1, PIPE_TEXTURE_2D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 0, 0),
169 /* 34 2D texture - PASS */
170 TEST(1, PIPE_TEXTURE_2D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_CURSOR, 50, 50, 1, 1, 0, 0),
171 /* 35 2D texture with height - PASS */
172 TEST(1, PIPE_TEXTURE_2D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 50, 1, 1, 0, 0),
173 /* 36 2D texture with depth - FAIL */
174 TEST(1, PIPE_TEXTURE_2D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 5, 1, 0, EINVAL),
175 /* 37 2D texture with array - FAIL */
176 TEST(1, PIPE_TEXTURE_2D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 5, 0, EINVAL),
177 /* 38 2D texture with samples - PASS */
178 TEST(1, PIPE_TEXTURE_2D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 4, 0),
179 /* 39 2D texture with miplevels - PASS */
180 TEST_MIP(1, PIPE_TEXTURE_2D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 0, 4, 0),
181 /* 40 2D texture with samples and miplevels - FAIL */
182 TEST_MIP(1, PIPE_TEXTURE_2D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 4, 4, EINVAL),
183
184 /* 41 RECT texture - PASS */
185 TEST(1, PIPE_TEXTURE_RECT, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 0, 0),
186 /* 42 RECT texture with height - PASS */
187 TEST(1, PIPE_TEXTURE_RECT, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 50, 1, 1, 0, 0),
188 /* 43 RECT texture with depth - FAIL */
189 TEST(1, PIPE_TEXTURE_RECT, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 5, 1, 0, EINVAL),
190 /* 44 RECT texture with array - FAIL */
191 TEST(1, PIPE_TEXTURE_RECT, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 5, 0, EINVAL),
192 /* 45 RECT texture with samples - FAIL */
193 TEST(1, PIPE_TEXTURE_RECT, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 4, EINVAL),
194 /* 46 RECT texture with miplevels - FAIL */
195 TEST_MIP(1, PIPE_TEXTURE_RECT, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 0, 4, EINVAL),
196
197 /* 47 2D texture array - PASS */
198 TEST(1, PIPE_TEXTURE_2D_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 0, 0),
199 /* 48 2D texture with height - PASS */
200 TEST(1, PIPE_TEXTURE_2D_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 50, 1, 1, 0, 0),
201 /* 49 2D texture with depth - FAIL */
202 TEST(1, PIPE_TEXTURE_2D_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 5, 1, 0, EINVAL),
203 /* 50 2D texture with array - FAIL */
204 TEST(1, PIPE_TEXTURE_2D_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 5, 0, 0),
205 /* 51 2D texture with samples - PASS */
206 TEST(1, PIPE_TEXTURE_2D_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 4, 0),
207 /* 52 2D texture with miplevels - PASS */
208 TEST_MIP(1, PIPE_TEXTURE_2D_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 0, 4, 0),
209 /* 53 2D texture with samplesmiplevels - FAIL */
210 TEST_MIP(1, PIPE_TEXTURE_2D_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 4, 4, EINVAL),
211
212 /* 54 3D texture - PASS */
213 TEST(1, PIPE_TEXTURE_3D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 0, 0),
214 /* 55 3D texture with height - PASS */
215 TEST(1, PIPE_TEXTURE_3D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 50, 1, 1, 0, 0),
216 /* 56 3D texture with depth - PASS */
217 TEST(1, PIPE_TEXTURE_3D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 5, 1, 0, 0),
218 /* 57 3D texture with array - FAIL */
219 TEST(1, PIPE_TEXTURE_3D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 5, 0, EINVAL),
220 /* 58 3D texture with samples - FAIL */
221 TEST(1, PIPE_TEXTURE_3D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 4, EINVAL),
222 /* 59 3D texture with miplevels - PASS */
223 TEST_MIP(1, PIPE_TEXTURE_3D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 0, 4, 0),
224
225 /* 60 CUBE texture with array size == 6 - PASS */
226 TEST(1, PIPE_TEXTURE_CUBE, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 50, 1, 6, 0, 0),
227 /* 61 CUBE texture with array size != 6 - FAIL */
228 TEST(1, PIPE_TEXTURE_CUBE, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 50, 1, 1, 0, EINVAL),
229 /* 62 CUBE texture with depth - FAIL */
230 TEST(1, PIPE_TEXTURE_CUBE, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 50, 5, 6, 0, EINVAL),
231 /* 63 CUBE texture with samples - FAIL */
232 TEST(1, PIPE_TEXTURE_CUBE, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 50, 1, 6, 4, EINVAL),
233 /* 64 CUBE texture with width != height */
234 TEST(1, PIPE_TEXTURE_CUBE, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 6, 0, EINVAL),
235 /* 65 CUBE texture with miplevels - PASS */
236 TEST_MIP(1, PIPE_TEXTURE_CUBE, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 50, 1, 6, 0, 4, 0),
237 };
238
239 /* separate since these may fail on a GL that doesn't support cube map arrays */
240 static struct res_test cubemaparray_testlist[] = {
241 /* 0 CUBE array with array size = 6 - PASS */
242 TEST(1, PIPE_TEXTURE_CUBE_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 50, 1, 6, 0, 0),
243 /* 1 CUBE array with array size = 12 - PASS */
244 TEST(1, PIPE_TEXTURE_CUBE_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 50, 1, 12, 0, 0),
245 /* 2 CUBE array with array size = 10 - FAIL */
246 TEST(1, PIPE_TEXTURE_CUBE_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 50, 1, 10, 0, EINVAL),
247 /* 3 CUBE array with array size = 12 and height - PASS */
248 TEST(1, PIPE_TEXTURE_CUBE_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 50, 1, 12, 0, 0),
249 /* 4 CUBE array with array size = 12 and depth - FAIL */
250 TEST(1, PIPE_TEXTURE_CUBE_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 50, 5, 12, 0, EINVAL),
251 /* 5 CUBE array with array size = 12 and samples - FAIL */
252 TEST(1, PIPE_TEXTURE_CUBE_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 50, 1, 12, 4, EINVAL),
253 /* 6 CUBE array with array size = 12 and miplevels - PASS */
254 TEST_MIP(1, PIPE_TEXTURE_CUBE_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 50, 1, 12, 0, 4, 0),
255 };
256
START_TEST(virgl_res_tests)257 START_TEST(virgl_res_tests)
258 {
259 int ret;
260 ret = testvirgl_init_single_ctx();
261 ck_assert_int_eq(ret, 0);
262
263 /* Do not test if multisample is not available */
264 unsigned multisample = testvirgl_get_multisample_from_caps();
265 if (!multisample) {
266 testvirgl_fini_single_ctx();
267 return;
268 }
269
270 ret = virgl_renderer_resource_create(&testlist[_i].args, NULL, 0);
271 ck_assert_int_eq(ret, testlist[_i].retval);
272
273 testvirgl_fini_single_ctx();
274 }
275 END_TEST
276
START_TEST(cubemaparray_res_tests)277 START_TEST(cubemaparray_res_tests)
278 {
279 int ret;
280 ret = testvirgl_init_single_ctx();
281 ck_assert_int_eq(ret, 0);
282
283 ret = virgl_renderer_resource_create(&cubemaparray_testlist[_i].args, NULL, 0);
284 ck_assert_int_eq(ret, cubemaparray_testlist[_i].retval);
285
286 testvirgl_fini_single_ctx();
287 }
288 END_TEST
289
START_TEST(private_ptr)290 START_TEST(private_ptr)
291 {
292 int ret;
293 ret = testvirgl_init_single_ctx();
294 ck_assert_int_eq(ret, 0);
295 struct virgl_renderer_resource_create_args args = { 1, PIPE_BUFFER, PIPE_FORMAT_R8_UNORM, 0, 50, 1, 1, 1, 0, 0, 0 };
296 ret = virgl_renderer_resource_create(&args, NULL, 0);
297 ck_assert_int_eq(ret, 0);
298
299 void *init_priv = (void*)0xabab;
300 virgl_renderer_resource_set_priv(1, init_priv);
301 void *priv = virgl_renderer_resource_get_priv(1);
302 ck_assert_int_eq((unsigned long)priv, 0xabab);
303 testvirgl_fini_single_ctx();
304 }
305 END_TEST
306
virgl_init_suite(void)307 static Suite *virgl_init_suite(void)
308 {
309 Suite *s;
310 TCase *tc_core;
311
312 s = suite_create("virgl_resource");
313 tc_core = tcase_create("resource");
314
315 tcase_add_loop_test(tc_core, virgl_res_tests, 0, ARRAY_SIZE(testlist));
316 tcase_add_loop_test(tc_core, cubemaparray_res_tests, 0, ARRAY_SIZE(cubemaparray_testlist));
317 tcase_add_test(tc_core, private_ptr);
318 suite_add_tcase(s, tc_core);
319 return s;
320
321 }
322
323
main(void)324 int main(void)
325 {
326 Suite *s;
327 SRunner *sr;
328 int number_failed;
329
330 if (getenv("VRENDTEST_USE_EGL_SURFACELESS"))
331 context_flags |= VIRGL_RENDERER_USE_SURFACELESS;
332 if (getenv("VRENDTEST_USE_EGL_GLES"))
333 context_flags |= VIRGL_RENDERER_USE_GLES;
334
335 s = virgl_init_suite();
336 sr = srunner_create(s);
337
338 srunner_run_all(sr, CK_NORMAL);
339 number_failed = srunner_ntests_failed(sr);
340 srunner_free(sr);
341
342 return number_failed == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
343 }
344