OSDN Git Service

start moving is synced check into winsys
[android-x86/external-mesa.git] / src / gallium / winsys / virgl / drm / virgl_drm_winsys.h
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 "os/os_thread.h"
28 #include "pipe/p_state.h"
29 #include "util/list.h"
30
31 #include "virgl/virgl_winsys.h"
32
33 struct pipe_fence_handle;
34 struct util_hash_table;
35
36 struct virgl_hw_res {
37    struct pipe_reference reference;
38    uint32_t res_handle;
39    uint32_t bo_handle;
40    uint32_t name;
41    int num_cs_references;
42    uint32_t size;
43    void *ptr;
44    uint32_t stride;
45
46    struct list_head head;
47    uint32_t format;
48    uint32_t bind;
49    boolean cacheable;
50    int64_t start, end;
51    boolean flinked;
52    uint32_t flink;
53
54    bool synced; /* guest copy is synced with host copy */
55 };
56
57 struct virgl_drm_winsys
58 {
59    struct virgl_winsys base;
60    int fd;
61    struct list_head delayed;
62    int num_delayed;
63    unsigned usecs;
64    pipe_mutex mutex;
65
66    struct util_hash_table *bo_handles;
67    struct util_hash_table *bo_names;
68    pipe_mutex bo_handles_mutex;
69 };
70
71 struct virgl_drm_cmd_buf {
72    struct virgl_cmd_buf base;
73
74    uint32_t buf[VIRGL_MAX_CMDBUF_DWORDS];
75
76    unsigned nres;
77    unsigned cres;
78    struct virgl_hw_res **res_bo;
79    enum virgl_bo_usage bo_usage[512];
80    struct virgl_winsys *ws;
81    uint32_t *res_hlist;
82
83    char                        is_handle_added[512];
84    unsigned                    reloc_indices_hashlist[512];
85
86 };
87
88 static inline struct virgl_hw_res *
89 virgl_hw_res(struct pipe_fence_handle *f)
90 {
91    return (struct virgl_hw_res *)f;
92 }
93
94 static inline struct virgl_drm_winsys *
95 virgl_drm_winsys(struct virgl_winsys *iws)
96 {
97    return (struct virgl_drm_winsys *)iws;
98 }
99
100 static inline struct virgl_drm_cmd_buf *
101 virgl_drm_cmd_buf(struct virgl_cmd_buf *cbuf)
102 {
103    return (struct virgl_drm_cmd_buf *)cbuf;
104 }
105
106 #endif