Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/gallium/winsys/virgl/drm/virgl_drm_winsys.h
4566 views
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
#include "virgl_resource_cache.h"
33
34
struct pipe_fence_handle;
35
struct hash_table;
36
37
struct virgl_hw_res {
38
struct pipe_reference reference;
39
enum pipe_texture_target target;
40
uint32_t res_handle;
41
uint32_t bo_handle;
42
int num_cs_references;
43
uint32_t size;
44
void *ptr;
45
46
struct virgl_resource_cache_entry cache_entry;
47
uint32_t bind;
48
uint32_t flags;
49
uint32_t flink_name;
50
51
/* false when the resource is known to be typed */
52
bool maybe_untyped;
53
54
/* true when the resource is imported or exported */
55
int external;
56
57
/* false when the resource is known to be idle */
58
int maybe_busy;
59
uint32_t blob_mem;
60
};
61
62
63
struct param {
64
uint64_t param;
65
const char *name;
66
uint64_t value;
67
};
68
69
enum param_id {
70
param_3d_features,
71
param_capset_fix,
72
param_resource_blob,
73
param_host_visible,
74
param_max,
75
};
76
77
#define PARAM(x) (struct param) { x, #x, 0 }
78
79
struct param params[] = { PARAM(VIRTGPU_PARAM_3D_FEATURES),
80
PARAM(VIRTGPU_PARAM_CAPSET_QUERY_FIX),
81
PARAM(VIRTGPU_PARAM_RESOURCE_BLOB),
82
PARAM(VIRTGPU_PARAM_HOST_VISIBLE),
83
PARAM(VIRTGPU_PARAM_CROSS_DEVICE)
84
};
85
86
struct virgl_drm_winsys
87
{
88
struct virgl_winsys base;
89
int fd;
90
struct virgl_resource_cache cache;
91
mtx_t mutex;
92
93
int32_t blob_id;
94
struct hash_table *bo_handles;
95
struct hash_table *bo_names;
96
mtx_t bo_handles_mutex;
97
};
98
99
struct virgl_drm_fence {
100
struct pipe_reference reference;
101
bool external;
102
int fd;
103
struct virgl_hw_res *hw_res;
104
};
105
106
struct virgl_drm_cmd_buf {
107
struct virgl_cmd_buf base;
108
109
uint32_t *buf;
110
111
int in_fence_fd;
112
113
unsigned nres;
114
unsigned cres;
115
struct virgl_hw_res **res_bo;
116
struct virgl_winsys *ws;
117
uint32_t *res_hlist;
118
119
char is_handle_added[512];
120
unsigned reloc_indices_hashlist[512];
121
122
};
123
124
static inline struct virgl_drm_winsys *
125
virgl_drm_winsys(struct virgl_winsys *iws)
126
{
127
return (struct virgl_drm_winsys *)iws;
128
}
129
130
static inline struct virgl_drm_fence *
131
virgl_drm_fence(struct pipe_fence_handle *f)
132
{
133
return (struct virgl_drm_fence *)f;
134
}
135
136
static inline struct virgl_drm_cmd_buf *
137
virgl_drm_cmd_buf(struct virgl_cmd_buf *cbuf)
138
{
139
return (struct virgl_drm_cmd_buf *)cbuf;
140
}
141
142
#endif
143
144