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_compiler.h"
31 #define VIRGL_MAX_CMDBUF_DWORDS (16*1024)
33 struct virgl_drm_caps
{
34 union virgl_caps caps
;
37 struct virgl_cmd_buf
{
45 void (*destroy
)(struct virgl_winsys
*vws
);
47 int (*transfer_put
)(struct virgl_winsys
*vws
,
48 struct virgl_hw_res
*res
,
49 const struct pipe_box
*box
,
50 uint32_t stride
, uint32_t layer_stride
,
51 uint32_t buf_offset
, uint32_t level
);
53 int (*transfer_get
)(struct virgl_winsys
*vws
,
54 struct virgl_hw_res
*res
,
55 const struct pipe_box
*box
,
56 uint32_t stride
, uint32_t layer_stride
,
57 uint32_t buf_offset
, uint32_t level
);
59 struct virgl_hw_res
*(*resource_create
)(struct virgl_winsys
*vws
,
60 enum pipe_texture_target target
,
61 uint32_t format
, uint32_t bind
,
62 uint32_t width
, uint32_t height
,
63 uint32_t depth
, uint32_t array_size
,
64 uint32_t last_level
, uint32_t nr_samples
,
67 void (*resource_unref
)(struct virgl_winsys
*vws
, struct virgl_hw_res
*res
);
69 void *(*resource_map
)(struct virgl_winsys
*vws
, struct virgl_hw_res
*res
);
70 void (*resource_wait
)(struct virgl_winsys
*vws
, struct virgl_hw_res
*res
);
72 struct virgl_hw_res
*(*resource_create_from_handle
)(struct virgl_winsys
*vws
,
73 struct winsys_handle
*whandle
);
74 boolean (*resource_get_handle
)(struct virgl_winsys
*vws
,
75 struct virgl_hw_res
*res
,
77 struct winsys_handle
*whandle
);
79 struct virgl_cmd_buf
*(*cmd_buf_create
)(struct virgl_winsys
*ws
);
80 void (*cmd_buf_destroy
)(struct virgl_cmd_buf
*buf
);
82 void (*emit_res
)(struct virgl_winsys
*vws
, struct virgl_cmd_buf
*buf
, struct virgl_hw_res
*res
, boolean write_buffer
);
83 int (*submit_cmd
)(struct virgl_winsys
*vws
, struct virgl_cmd_buf
*buf
);
85 boolean (*res_is_referenced
)(struct virgl_winsys
*vws
,
86 struct virgl_cmd_buf
*buf
,
87 struct virgl_hw_res
*res
);
89 int (*get_caps
)(struct virgl_winsys
*vws
, struct virgl_drm_caps
*caps
);
92 struct pipe_fence_handle
*(*cs_create_fence
)(struct virgl_winsys
*vws
);
93 bool (*fence_wait
)(struct virgl_winsys
*vws
,
94 struct pipe_fence_handle
*fence
,
97 void (*fence_reference
)(struct virgl_winsys
*vws
,
98 struct pipe_fence_handle
**dst
,
99 struct pipe_fence_handle
*src
);
102 void (*flush_frontbuffer
)(struct virgl_winsys
*vws
,
103 struct virgl_hw_res
*res
,
104 unsigned level
, unsigned layer
,
105 void *winsys_drawable_handle
,
106 struct pipe_box
*sub_box
);