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