2 * Copyright 2014, 2015 Red Hat.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE.
23 #ifndef VIRGL_DRM_WINSYS_H
24 #define VIRGL_DRM_WINSYS_H
27 #include "pipe/p_compiler.h"
28 #include "pipe/p_defines.h"
29 #include "pipe/p_state.h"
30 #include "util/list.h"
31 #include "os/os_thread.h"
33 #include "virgl/virgl_winsys.h"
34 #include "vtest_protocol.h"
35 #include "virgl_resource_cache.h"
37 struct pipe_fence_handle
;
39 struct sw_displaytarget
;
41 struct virgl_vtest_winsys
{
42 struct virgl_winsys base
;
44 struct sw_winsys
*sws
;
46 /* fd to remote renderer */
49 struct virgl_resource_cache cache
;
52 unsigned protocol_version
;
56 struct pipe_reference reference
;
58 int num_cs_references
;
68 struct sw_displaytarget
*dt
;
72 struct virgl_resource_cache_entry cache_entry
;
75 struct virgl_vtest_cmd_buf
{
76 struct virgl_cmd_buf base
;
80 struct virgl_winsys
*ws
;
81 struct virgl_hw_res
**res_bo
;
83 char is_handle_added
[512];
84 unsigned reloc_indices_hashlist
[512];
87 static inline struct virgl_hw_res
*
88 virgl_hw_res(struct pipe_fence_handle
*f
)
90 return (struct virgl_hw_res
*)f
;
93 static inline struct virgl_vtest_winsys
*
94 virgl_vtest_winsys(struct virgl_winsys
*iws
)
96 return (struct virgl_vtest_winsys
*)iws
;
99 static inline struct virgl_vtest_cmd_buf
*
100 virgl_vtest_cmd_buf(struct virgl_cmd_buf
*cbuf
)
102 return (struct virgl_vtest_cmd_buf
*)cbuf
;
106 int virgl_vtest_connect(struct virgl_vtest_winsys
*vws
);
107 int virgl_vtest_send_get_caps(struct virgl_vtest_winsys
*vws
,
108 struct virgl_drm_caps
*caps
);
110 int virgl_vtest_send_resource_create(struct virgl_vtest_winsys
*vws
,
112 enum pipe_texture_target target
,
124 int virgl_vtest_send_resource_unref(struct virgl_vtest_winsys
*vws
,
126 int virgl_vtest_submit_cmd(struct virgl_vtest_winsys
*vtws
,
127 struct virgl_vtest_cmd_buf
*cbuf
);
129 int virgl_vtest_send_transfer_get(struct virgl_vtest_winsys
*vws
,
131 uint32_t level
, uint32_t stride
,
132 uint32_t layer_stride
,
133 const struct pipe_box
*box
,
137 int virgl_vtest_send_transfer_put(struct virgl_vtest_winsys
*vws
,
139 uint32_t level
, uint32_t stride
,
140 uint32_t layer_stride
,
141 const struct pipe_box
*box
,
145 int virgl_vtest_send_transfer_put_data(struct virgl_vtest_winsys
*vws
,
148 int virgl_vtest_recv_transfer_get_data(struct virgl_vtest_winsys
*vws
,
152 const struct pipe_box
*box
,
155 int virgl_vtest_busy_wait(struct virgl_vtest_winsys
*vws
, int handle
,