887a381cc49c02faaff416077d4569777a42552c
[mesa.git] / src / gallium / winsys / drm / radeon / core / radeon_winsys.h
1 /*
2 * Copyright © 2009 Corbin Simpson
3 * All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sub license, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
15 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16 * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
17 * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 * USE OR OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * The above copyright notice and this permission notice (including the
23 * next paragraph) shall be included in all copies or substantial portions
24 * of the Software.
25 */
26 /*
27 * Authors:
28 * Corbin Simpson <MostAwesomeDude@gmail.com>
29 */
30 #ifndef RADEON_WINSYS_H
31 #define RADEON_WINSYS_H
32
33 #include "util/u_simple_screen.h"
34
35 struct radeon_winsys_priv;
36
37 struct radeon_winsys {
38 /* Parent class. */
39 struct pipe_winsys base;
40
41 /* Winsys private */
42 struct radeon_winsys_priv* priv;
43
44 /* PCI ID */
45 uint32_t pci_id;
46
47 /* GB pipe count */
48 uint32_t gb_pipes;
49
50 /* Z pipe count (rv530 only) */
51 uint32_t z_pipes;
52
53 /* GART size. */
54 uint32_t gart_size;
55
56 /* VRAM size. */
57 uint32_t vram_size;
58
59 /* Create a buffer from a winsys handle. */
60 struct pipe_buffer *(*buffer_from_handle)(struct radeon_winsys *winsys,
61 struct pipe_screen *screen,
62 struct winsys_handle *whandle,
63 unsigned *stride);
64
65 /* Get the handle from a buffer. */
66 boolean (*buffer_get_handle)(struct radeon_winsys *winsys,
67 struct pipe_buffer *buffer,
68 unsigned stride,
69 struct winsys_handle *whandle);
70
71 /* Add a pipe_buffer to the list of buffer objects to validate. */
72 boolean (*add_buffer)(struct radeon_winsys* winsys,
73 struct pipe_buffer* pbuffer,
74 uint32_t rd,
75 uint32_t wd);
76
77 /* Revalidate all currently setup pipe_buffers.
78 * Returns TRUE if a flush is required. */
79 boolean (*validate)(struct radeon_winsys* winsys);
80
81 /* Check to see if there's room for commands. */
82 boolean (*check_cs)(struct radeon_winsys* winsys, int size);
83
84 /* Start a command emit. */
85 void (*begin_cs)(struct radeon_winsys* winsys,
86 int size,
87 const char* file,
88 const char* function,
89 int line);
90
91 /* Write a dword to the command buffer. */
92 void (*write_cs_dword)(struct radeon_winsys* winsys, uint32_t dword);
93
94 /* Write a relocated dword to the command buffer. */
95 void (*write_cs_reloc)(struct radeon_winsys* winsys,
96 struct pipe_buffer* bo,
97 uint32_t rd,
98 uint32_t wd,
99 uint32_t flags);
100
101 /* Finish a command emit. */
102 void (*end_cs)(struct radeon_winsys* winsys,
103 const char* file,
104 const char* function,
105 int line);
106
107 /* Flush the CS. */
108 void (*flush_cs)(struct radeon_winsys* winsys);
109
110 /* winsys flush - callback from winsys when flush required */
111 void (*set_flush_cb)(struct radeon_winsys *winsys,
112 void (*flush_cb)(void *), void *data);
113
114 void (*reset_bos)(struct radeon_winsys *winsys);
115
116 void (*buffer_set_tiling)(struct radeon_winsys* winsys,
117 struct pipe_buffer* buffer,
118 uint32_t pitch,
119 boolean microtiled,
120 boolean macrotiled);
121
122 boolean (*is_buffer_referenced)(struct radeon_winsys *winsys,
123 struct pipe_buffer *buffer);
124 };
125
126 #endif