Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/gallium/drivers/virgl/virgl_winsys.h
4570 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_WINSYS_H
24
#define VIRGL_WINSYS_H
25
26
#include "pipe/p_defines.h"
27
#include "virtio-gpu/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_TBUF_DWORDS 1024
35
#define VIRGL_MAX_CMDBUF_DWORDS ((64 * 1024) + VIRGL_MAX_TBUF_DWORDS)
36
#define VIRGL_MAX_PLANE_COUNT 3
37
38
struct virgl_drm_caps {
39
union virgl_caps caps;
40
};
41
42
struct virgl_cmd_buf {
43
unsigned cdw;
44
uint32_t *buf;
45
};
46
47
struct virgl_winsys {
48
unsigned pci_id;
49
int supports_fences; /* In/Out fences are supported */
50
int supports_encoded_transfers; /* Encoded transfers are supported */
51
int supports_coherent; /* Coherent memory is supported */
52
53
void (*destroy)(struct virgl_winsys *vws);
54
55
int (*transfer_put)(struct virgl_winsys *vws,
56
struct virgl_hw_res *res,
57
const struct pipe_box *box,
58
uint32_t stride, uint32_t layer_stride,
59
uint32_t buf_offset, uint32_t level);
60
61
int (*transfer_get)(struct virgl_winsys *vws,
62
struct virgl_hw_res *res,
63
const struct pipe_box *box,
64
uint32_t stride, uint32_t layer_stride,
65
uint32_t buf_offset, uint32_t level);
66
67
struct virgl_hw_res *(*resource_create)(struct virgl_winsys *vws,
68
enum pipe_texture_target target,
69
uint32_t format, uint32_t bind,
70
uint32_t width, uint32_t height,
71
uint32_t depth, uint32_t array_size,
72
uint32_t last_level, uint32_t nr_samples,
73
uint32_t flags, uint32_t size);
74
75
void (*resource_reference)(struct virgl_winsys *qws,
76
struct virgl_hw_res **dres,
77
struct virgl_hw_res *sres);
78
79
void *(*resource_map)(struct virgl_winsys *vws, struct virgl_hw_res *res);
80
void (*resource_wait)(struct virgl_winsys *vws, struct virgl_hw_res *res);
81
boolean (*resource_is_busy)(struct virgl_winsys *vws,
82
struct virgl_hw_res *res);
83
84
struct virgl_hw_res *(*resource_create_from_handle)(struct virgl_winsys *vws,
85
struct winsys_handle *whandle,
86
uint32_t *plane,
87
uint32_t *stride,
88
uint32_t *plane_offset,
89
uint64_t *modifier,
90
uint32_t *blob_mem);
91
void (*resource_set_type)(struct virgl_winsys *vws,
92
struct virgl_hw_res *res,
93
uint32_t format, uint32_t bind,
94
uint32_t width, uint32_t height,
95
uint32_t usage, uint64_t modifier,
96
uint32_t plane_count,
97
const uint32_t *plane_strides,
98
const uint32_t *plane_offsets);
99
100
boolean (*resource_get_handle)(struct virgl_winsys *vws,
101
struct virgl_hw_res *res,
102
uint32_t stride,
103
struct winsys_handle *whandle);
104
105
struct virgl_cmd_buf *(*cmd_buf_create)(struct virgl_winsys *ws, uint32_t size);
106
void (*cmd_buf_destroy)(struct virgl_cmd_buf *buf);
107
108
void (*emit_res)(struct virgl_winsys *vws, struct virgl_cmd_buf *buf, struct virgl_hw_res *res, boolean write_buffer);
109
int (*submit_cmd)(struct virgl_winsys *vws, struct virgl_cmd_buf *buf,
110
struct pipe_fence_handle **fence);
111
112
boolean (*res_is_referenced)(struct virgl_winsys *vws,
113
struct virgl_cmd_buf *buf,
114
struct virgl_hw_res *res);
115
116
int (*get_caps)(struct virgl_winsys *vws, struct virgl_drm_caps *caps);
117
118
/* fence */
119
struct pipe_fence_handle *(*cs_create_fence)(struct virgl_winsys *vws, int fd);
120
bool (*fence_wait)(struct virgl_winsys *vws,
121
struct pipe_fence_handle *fence,
122
uint64_t timeout);
123
124
void (*fence_reference)(struct virgl_winsys *vws,
125
struct pipe_fence_handle **dst,
126
struct pipe_fence_handle *src);
127
128
/* for sw paths */
129
void (*flush_frontbuffer)(struct virgl_winsys *vws,
130
struct virgl_hw_res *res,
131
unsigned level, unsigned layer,
132
void *winsys_drawable_handle,
133
struct pipe_box *sub_box);
134
void (*fence_server_sync)(struct virgl_winsys *vws,
135
struct virgl_cmd_buf *cbuf,
136
struct pipe_fence_handle *fence);
137
138
int (*fence_get_fd)(struct virgl_winsys *vws,
139
struct pipe_fence_handle *fence);
140
};
141
142
/* this defaults all newer caps,
143
* the kernel will overwrite these if newer version is available.
144
*/
145
static inline void virgl_ws_fill_new_caps_defaults(struct virgl_drm_caps *caps)
146
{
147
caps->caps.v2.min_aliased_point_size = 1.f;
148
caps->caps.v2.max_aliased_point_size = 255.f;
149
caps->caps.v2.min_smooth_point_size = 1.f;
150
caps->caps.v2.max_smooth_point_size = 190.f;
151
caps->caps.v2.min_aliased_line_width = 1.f;
152
caps->caps.v2.max_aliased_line_width = 10.f;
153
caps->caps.v2.min_smooth_line_width = 0.f;
154
caps->caps.v2.max_smooth_line_width = 10.f;
155
caps->caps.v2.max_texture_lod_bias = 15.0f;
156
caps->caps.v2.max_geom_output_vertices = 256;
157
caps->caps.v2.max_geom_total_output_components = 1024;
158
caps->caps.v2.max_vertex_outputs = 32;
159
caps->caps.v2.max_vertex_attribs = 16;
160
caps->caps.v2.max_shader_patch_varyings = 30;
161
caps->caps.v2.min_texel_offset = -8;
162
caps->caps.v2.max_texel_offset = 7;
163
caps->caps.v2.min_texture_gather_offset = -8;
164
caps->caps.v2.max_texture_gather_offset = 7;
165
caps->caps.v2.texture_buffer_offset_alignment = 0;
166
caps->caps.v2.uniform_buffer_offset_alignment = 256;
167
caps->caps.v2.shader_buffer_offset_alignment = 32;
168
caps->caps.v2.capability_bits = 0;
169
caps->caps.v2.max_vertex_attrib_stride = 0;
170
caps->caps.v2.max_image_samples = 0;
171
caps->caps.v2.max_compute_work_group_invocations = 0;
172
caps->caps.v2.max_compute_shared_memory_size = 0;
173
caps->caps.v2.host_feature_check_version = 0;
174
}
175
176
extern enum virgl_formats pipe_to_virgl_format(enum pipe_format format);
177
178
#endif
179
180