• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2014, 2015 Red Hat.
3  *
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:
10  *
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
13  * Software.
14  *
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.
22  */
23 #ifndef VIRGL_DRM_WINSYS_H
24 #define VIRGL_DRM_WINSYS_H
25 
26 #include <stdint.h>
27 #include "util/compiler.h"
28 #include "pipe/p_defines.h"
29 #include "pipe/p_state.h"
30 #include "util/list.h"
31 #include "util/u_thread.h"
32 
33 #include "virgl/virgl_winsys.h"
34 #include "vtest/vtest_protocol.h"
35 #include "virgl_resource_cache.h"
36 
37 struct pipe_fence_handle;
38 struct sw_winsys;
39 struct sw_displaytarget;
40 
41 struct virgl_vtest_winsys {
42    struct virgl_winsys base;
43 
44    struct sw_winsys *sws;
45 
46    /* fd to remote renderer */
47    int sock_fd;
48 
49    struct virgl_resource_cache cache;
50    mtx_t mutex;
51 
52    int32_t blob_id;
53    unsigned protocol_version;
54 };
55 
56 struct virgl_hw_res {
57    struct pipe_reference reference;
58    uint32_t res_handle;
59    int num_cs_references;
60 
61    void *ptr;
62    int size;
63 
64    uint32_t format;
65    uint32_t stride;
66    uint32_t width;
67    uint32_t height;
68 
69    struct sw_displaytarget *dt;
70    void *mapped;
71 
72    uint32_t bind;
73    struct virgl_resource_cache_entry cache_entry;
74 };
75 
76 struct virgl_vtest_cmd_buf {
77    struct virgl_cmd_buf base;
78    uint32_t *buf;
79    unsigned nres;
80    unsigned cres;
81    struct virgl_winsys *ws;
82    struct virgl_hw_res **res_bo;
83 };
84 
85 static inline struct virgl_hw_res *
virgl_hw_res(struct pipe_fence_handle * f)86 virgl_hw_res(struct pipe_fence_handle *f)
87 {
88    return (struct virgl_hw_res *)f;
89 }
90 
91 static inline struct virgl_vtest_winsys *
virgl_vtest_winsys(struct virgl_winsys * iws)92 virgl_vtest_winsys(struct virgl_winsys *iws)
93 {
94    return (struct virgl_vtest_winsys *)iws;
95 }
96 
97 static inline struct virgl_vtest_cmd_buf *
virgl_vtest_cmd_buf(struct virgl_cmd_buf * cbuf)98 virgl_vtest_cmd_buf(struct virgl_cmd_buf *cbuf)
99 {
100    return (struct virgl_vtest_cmd_buf *)cbuf;
101 }
102 
103 
104 int virgl_vtest_connect(struct virgl_vtest_winsys *vws);
105 int virgl_vtest_send_get_caps(struct virgl_vtest_winsys *vws,
106                               struct virgl_drm_caps *caps);
107 
108 int virgl_vtest_send_resource_create(struct virgl_vtest_winsys *vws,
109                                      uint32_t handle,
110                                      enum pipe_texture_target target,
111                                      uint32_t format,
112                                      uint32_t bind,
113                                      uint32_t width,
114                                      uint32_t height,
115                                      uint32_t depth,
116                                      uint32_t array_size,
117                                      uint32_t last_level,
118                                      uint32_t nr_samples,
119                                      uint32_t size,
120                                      int *out_fd);
121 
122 int virgl_vtest_send_resource_unref(struct virgl_vtest_winsys *vws,
123                                     uint32_t handle);
124 
125 int virgl_vtest_submit_cmd(struct virgl_vtest_winsys *vws,
126                            uint32_t *buf, uint32_t buf_len);
127 
128 int virgl_vtest_send_transfer_get(struct virgl_vtest_winsys *vws,
129                                   uint32_t handle,
130                                   uint32_t level, uint32_t stride,
131                                   uint32_t layer_stride,
132                                   const struct pipe_box *box,
133                                   uint32_t data_size,
134                                   uint32_t offset);
135 
136 int virgl_vtest_send_transfer_put(struct virgl_vtest_winsys *vws,
137                                   uint32_t handle,
138                                   uint32_t level, uint32_t stride,
139                                   uint32_t layer_stride,
140                                   const struct pipe_box *box,
141                                   uint32_t data_size,
142                                   uint32_t offset);
143 
144 int virgl_vtest_send_transfer_put_data(struct virgl_vtest_winsys *vws,
145                                        void *data,
146                                        uint32_t data_size);
147 int virgl_vtest_recv_transfer_get_data(struct virgl_vtest_winsys *vws,
148                                        void *data,
149                                        uint32_t data_size,
150                                        uint32_t stride,
151                                        const struct pipe_box *box,
152                                        uint32_t format);
153 
154 int virgl_vtest_busy_wait(struct virgl_vtest_winsys *vws, int handle,
155                           int flags);
156 
157 int
158 virgl_vtest_send_create_blob(struct virgl_vtest_winsys *vws,
159                              uint32_t size, uint32_t blob_id, int *fd);
160 #endif
161