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 #ifndef TESTVIRGL_H
26 #define TESTVIRGL_H
27 
28 #include "virglrenderer.h"
29 #include "pipe/p_state.h"
30 
31 #define VIRGL_MAX_CMDBUF_DWORDS (16*1024)
32 
33 struct virgl_cmd_buf {
34     unsigned cdw;
35     uint32_t *buf;
36 };
37 
38 struct virgl_context {
39     void (*flush)(struct virgl_context *ctx);
40     struct virgl_cmd_buf *cbuf;
41     int ctx_id;
42 };
43 
44 struct virgl_so_target {
45     uint32_t handle;
46 };
47 struct virgl_sampler_view {
48     uint32_t handle;
49 };
50 
51 struct virgl_resource {
52     struct pipe_resource base;
53     uint32_t handle;
54     struct iovec *iovs;
55     int niovs;
56 };
57 
58 
59 void testvirgl_init_simple_buffer(struct virgl_renderer_resource_create_args *res, int handle);
60 void testvirgl_init_simple_buffer_sized(struct virgl_renderer_resource_create_args *res, int handle, int width);
61 void testvirgl_init_simple_1d_resource(struct virgl_renderer_resource_create_args *args, int handle);
62 void testvirgl_init_simple_2d_resource(struct virgl_renderer_resource_create_args *res, int handle);
63 int testvirgl_init_single_ctx(void);
64 void testvirgl_init_single_ctx_nr(void);
65 void testvirgl_fini_single_ctx(void);
66 
67 uint32_t testvirgl_get_last_fence(void);
68 void testvirgl_reset_fence(void);
69 
70 int testvirgl_init_ctx_cmdbuf(struct virgl_context *ctx);
71 void testvirgl_fini_ctx_cmdbuf(struct virgl_context *ctx);
72 
73 int testvirgl_create_backed_simple_1d_res(struct virgl_resource *res,
74 					  int handle);
75 int testvirgl_create_backed_simple_2d_res(struct virgl_resource *res,
76 					  int handle, int w, int h);
77 int testvirgl_create_backed_simple_buffer(struct virgl_resource *res,
78 					  int handle, int size, int bind);
79 void testvirgl_destroy_backed_res(struct virgl_resource *res);
80 uint32_t testvirgl_get_glsl_level_from_caps(void);
81 unsigned testvirgl_get_multisample_from_caps(void);
82 #endif
83