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"
36 struct pipe_fence_handle;
38 struct sw_displaytarget;
40 struct virgl_vtest_winsys {
41 struct virgl_winsys base;
43 struct sw_winsys *sws;
45 /* fd to remote renderer */
48 struct list_head delayed;
55 struct pipe_reference reference;
57 int num_cs_references;
67 struct sw_displaytarget *dt;
70 struct list_head head;
77 struct virgl_vtest_cmd_buf {
78 struct virgl_cmd_buf base;
79 uint32_t buf[VIRGL_MAX_CMDBUF_DWORDS];
82 struct virgl_winsys *ws;
83 struct virgl_hw_res **res_bo;
85 char is_handle_added[512];
86 unsigned reloc_indices_hashlist[512];
89 static inline struct virgl_hw_res *
90 virgl_hw_res(struct pipe_fence_handle *f)
92 return (struct virgl_hw_res *)f;
95 static inline struct virgl_vtest_winsys *
96 virgl_vtest_winsys(struct virgl_winsys *iws)
98 return (struct virgl_vtest_winsys *)iws;
101 static inline struct virgl_vtest_cmd_buf *
102 virgl_vtest_cmd_buf(struct virgl_cmd_buf *cbuf)
104 return (struct virgl_vtest_cmd_buf *)cbuf;
108 int virgl_vtest_connect(struct virgl_vtest_winsys *vws);
109 int virgl_vtest_send_get_caps(struct virgl_vtest_winsys *vws,
110 struct virgl_drm_caps *caps);
112 int virgl_vtest_send_resource_create(struct virgl_vtest_winsys *vws,
114 enum pipe_texture_target target,
122 uint32_t nr_samples);
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_cmd(struct virgl_vtest_winsys *vws,
132 uint32_t level, uint32_t stride,
133 uint32_t layer_stride,
134 const struct pipe_box *box,
137 int virgl_vtest_send_transfer_put_data(struct virgl_vtest_winsys *vws,
140 int virgl_vtest_recv_transfer_get_data(struct virgl_vtest_winsys *vws,
144 const struct pipe_box *box, uint32_t format);
146 int virgl_vtest_busy_wait(struct virgl_vtest_winsys *vws, int handle,