r300g: Move bootstrap code to targets
[mesa.git] / src / gallium / drivers / r300 / r300_winsys.h
1 /*
2 * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
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 R300_WINSYS_H
24 #define R300_WINSYS_H
25
26 /* The public interface header for the r300 pipe driver.
27 * Any winsys hosting this pipe needs to implement r300_winsys and then
28 * call r300_create_screen to start things. */
29
30 #include "pipe/p_defines.h"
31 #include "pipe/p_state.h"
32
33 #include "r300_defines.h"
34
35 struct r300_winsys_buffer;
36
37 enum r300_value_id {
38 R300_VID_PCI_ID,
39 R300_VID_GB_PIPES,
40 R300_VID_Z_PIPES,
41 R300_VID_SQUARE_TILING_SUPPORT,
42 R300_VID_DRM_2_3_0,
43 };
44
45 enum r300_reference_domain { /* bitfield */
46 R300_REF_CS = 1,
47 R300_REF_HW = 2
48 };
49
50 struct r300_cs_info {
51 /* In DWORDs. */
52 unsigned used;
53 unsigned free;
54 unsigned capacity;
55 };
56
57 struct r300_winsys_screen {
58 void (*destroy)(struct r300_winsys_screen *ws);
59
60 /**
61 * Buffer management. Buffer attributes are mostly fixed over its lifetime.
62 *
63 * Remember that gallium gets to choose the interface it needs, and the
64 * window systems must then implement that interface (rather than the
65 * other way around...).
66 *
67 * usage is a bitmask of R300_WINSYS_BUFFER_USAGE_PIXEL/VERTEX/INDEX/CONSTANT. This
68 * usage argument is only an optimization hint, not a guarantee, therefore
69 * proper behavior must be observed in all circumstances.
70 *
71 * alignment indicates the client's alignment requirements, eg for
72 * SSE instructions.
73 */
74 struct r300_winsys_buffer *(*buffer_create)(struct r300_winsys_screen *ws,
75 unsigned alignment,
76 unsigned usage,
77 enum r300_buffer_domain domain,
78 unsigned size);
79
80 /**
81 * Map the entire data store of a buffer object into the client's address.
82 * flags is bitmask of R300_WINSYS_BUFFER_USAGE_CPU_READ/WRITE flags.
83 */
84 void *(*buffer_map)( struct r300_winsys_screen *ws,
85 struct r300_winsys_buffer *buf,
86 unsigned usage);
87
88 void (*buffer_unmap)( struct r300_winsys_screen *ws,
89 struct r300_winsys_buffer *buf );
90
91 void (*buffer_destroy)( struct r300_winsys_buffer *buf );
92
93
94 void (*buffer_reference)(struct r300_winsys_screen *rws,
95 struct r300_winsys_buffer **pdst,
96 struct r300_winsys_buffer *src);
97
98 void (*buffer_wait)(struct r300_winsys_screen *rws,
99 struct r300_winsys_buffer *buf);
100
101 /* Add a pipe_resource to the list of buffer objects to validate. */
102 boolean (*add_buffer)(struct r300_winsys_screen *winsys,
103 struct r300_winsys_buffer *buf,
104 enum r300_buffer_domain rd,
105 enum r300_buffer_domain wd);
106
107
108 /* Revalidate all currently setup pipe_buffers.
109 * Returns TRUE if a flush is required. */
110 boolean (*validate)(struct r300_winsys_screen* winsys);
111
112 /* Return current CS info. */
113 void (*get_cs_info)(struct r300_winsys_screen *winsys,
114 struct r300_cs_info *info);
115
116 /* Start a command emit. */
117 void (*begin_cs)(struct r300_winsys_screen* winsys,
118 int size,
119 const char* file,
120 const char* function,
121 int line);
122
123 /* Write a dword to the command buffer. */
124 void (*write_cs_dword)(struct r300_winsys_screen* winsys, uint32_t dword);
125
126 /* Write a table of dwords to the command buffer. */
127 void (*write_cs_table)(struct r300_winsys_screen* winsys,
128 const void *dwords, unsigned count);
129
130 /* Write a relocated dword to the command buffer. */
131 void (*write_cs_reloc)(struct r300_winsys_screen *winsys,
132 struct r300_winsys_buffer *buf,
133 enum r300_buffer_domain rd,
134 enum r300_buffer_domain wd,
135 uint32_t flags);
136
137 /* Finish a command emit. */
138 void (*end_cs)(struct r300_winsys_screen* winsys,
139 const char* file,
140 const char* function,
141 int line);
142
143 /* Flush the CS. */
144 void (*flush_cs)(struct r300_winsys_screen* winsys);
145
146 /* winsys flush - callback from winsys when flush required */
147 void (*set_flush_cb)(struct r300_winsys_screen *winsys,
148 void (*flush_cb)(void *), void *data);
149
150 void (*reset_bos)(struct r300_winsys_screen *winsys);
151
152 void (*buffer_get_tiling)(struct r300_winsys_screen *winsys,
153 struct r300_winsys_buffer *buffer,
154 enum r300_buffer_tiling *microtiled,
155 enum r300_buffer_tiling *macrotiled);
156
157 void (*buffer_set_tiling)(struct r300_winsys_screen *winsys,
158 struct r300_winsys_buffer *buffer,
159 uint32_t pitch,
160 enum r300_buffer_tiling microtiled,
161 enum r300_buffer_tiling macrotiled);
162
163 uint32_t (*get_value)(struct r300_winsys_screen *winsys,
164 enum r300_value_id vid);
165
166 struct r300_winsys_buffer *(*buffer_from_handle)(struct r300_winsys_screen *winsys,
167 struct pipe_screen *screen,
168 struct winsys_handle *whandle,
169 unsigned *stride);
170 boolean (*buffer_get_handle)(struct r300_winsys_screen *winsys,
171 struct r300_winsys_buffer *buffer,
172 unsigned stride,
173 struct winsys_handle *whandle);
174
175 boolean (*is_buffer_referenced)(struct r300_winsys_screen *winsys,
176 struct r300_winsys_buffer *buffer,
177 enum r300_reference_domain domain);
178 };
179
180 struct r300_winsys_screen *
181 r300_winsys_screen(struct pipe_screen *screen);
182
183 #endif /* R300_WINSYS_H */