2 * Copyright 2014, 2015 Red Hat.
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:
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
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.
23 #ifndef VIRGL_WINSYS_H
24 #define VIRGL_WINSYS_H
26 #include "pipe/p_defines.h"
30 struct pipe_fence_handle
;
34 #define VIRGL_MAX_CMDBUF_DWORDS (16*1024)
36 struct virgl_drm_caps
{
37 union virgl_caps caps
;
40 struct virgl_cmd_buf
{
48 void (*destroy
)(struct virgl_winsys
*vws
);
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
);
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
);
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
,
70 void (*resource_unref
)(struct virgl_winsys
*vws
, struct virgl_hw_res
*res
);
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
);
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
,
80 struct winsys_handle
*whandle
);
82 struct virgl_cmd_buf
*(*cmd_buf_create
)(struct virgl_winsys
*ws
);
83 void (*cmd_buf_destroy
)(struct virgl_cmd_buf
*buf
);
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
);
88 boolean (*res_is_referenced
)(struct virgl_winsys
*vws
,
89 struct virgl_cmd_buf
*buf
,
90 struct virgl_hw_res
*res
);
92 int (*get_caps
)(struct virgl_winsys
*vws
, struct virgl_drm_caps
*caps
);
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
,
100 void (*fence_reference
)(struct virgl_winsys
*vws
,
101 struct pipe_fence_handle
**dst
,
102 struct pipe_fence_handle
*src
);
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
);