• 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_WINSYS_H
24 #define VIRGL_WINSYS_H
25 
26 #include "pipe/p_defines.h"
27 #include "virgl_hw.h"
28 
29 struct pipe_box;
30 struct pipe_fence_handle;
31 struct winsys_handle;
32 struct virgl_hw_res;
33 
34 #define VIRGL_MAX_CMDBUF_DWORDS (16*1024)
35 
36 struct virgl_drm_caps {
37    union virgl_caps caps;
38 };
39 
40 struct virgl_cmd_buf {
41    unsigned cdw;
42    uint32_t *buf;
43 };
44 
45 struct virgl_winsys {
46    unsigned pci_id;
47 
48    void (*destroy)(struct virgl_winsys *vws);
49 
50    int (*transfer_put)(struct virgl_winsys *vws,
51                        struct virgl_hw_res *res,
52                        const struct pipe_box *box,
53                        uint32_t stride, uint32_t layer_stride,
54                        uint32_t buf_offset, uint32_t level);
55 
56    int (*transfer_get)(struct virgl_winsys *vws,
57                        struct virgl_hw_res *res,
58                        const struct pipe_box *box,
59                        uint32_t stride, uint32_t layer_stride,
60                        uint32_t buf_offset, uint32_t level);
61 
62    struct virgl_hw_res *(*resource_create)(struct virgl_winsys *vws,
63                                enum pipe_texture_target target,
64                                uint32_t format, uint32_t bind,
65                                uint32_t width, uint32_t height,
66                                uint32_t depth, uint32_t array_size,
67                                uint32_t last_level, uint32_t nr_samples,
68                                uint32_t size);
69 
70    void (*resource_unref)(struct virgl_winsys *vws, struct virgl_hw_res *res);
71 
72    void *(*resource_map)(struct virgl_winsys *vws, struct virgl_hw_res *res);
73    void (*resource_wait)(struct virgl_winsys *vws, struct virgl_hw_res *res);
74 
75    struct virgl_hw_res *(*resource_create_from_handle)(struct virgl_winsys *vws,
76                                                        struct winsys_handle *whandle);
77    boolean (*resource_get_handle)(struct virgl_winsys *vws,
78                                   struct virgl_hw_res *res,
79                                   uint32_t stride,
80                                   struct winsys_handle *whandle);
81 
82    struct virgl_cmd_buf *(*cmd_buf_create)(struct virgl_winsys *ws);
83    void (*cmd_buf_destroy)(struct virgl_cmd_buf *buf);
84 
85    void (*emit_res)(struct virgl_winsys *vws, struct virgl_cmd_buf *buf, struct virgl_hw_res *res, boolean write_buffer);
86    int (*submit_cmd)(struct virgl_winsys *vws, struct virgl_cmd_buf *buf);
87 
88    boolean (*res_is_referenced)(struct virgl_winsys *vws,
89                                 struct virgl_cmd_buf *buf,
90                                 struct virgl_hw_res *res);
91 
92    int (*get_caps)(struct virgl_winsys *vws, struct virgl_drm_caps *caps);
93 
94    /* fence */
95    struct pipe_fence_handle *(*cs_create_fence)(struct virgl_winsys *vws);
96    bool (*fence_wait)(struct virgl_winsys *vws,
97                       struct pipe_fence_handle *fence,
98                       uint64_t timeout);
99 
100    void (*fence_reference)(struct virgl_winsys *vws,
101                            struct pipe_fence_handle **dst,
102                            struct pipe_fence_handle *src);
103 
104    /* for sw paths */
105    void (*flush_frontbuffer)(struct virgl_winsys *vws,
106                              struct virgl_hw_res *res,
107                              unsigned level, unsigned layer,
108                              void *winsys_drawable_handle,
109                              struct pipe_box *sub_box);
110 };
111 
112 
113 #endif
114