Merge branch '7.8'
[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_screen;
36
37 /* Creates a new r300 screen. */
38 struct pipe_screen* r300_create_screen(struct r300_winsys_screen *rws);
39
40 struct r300_winsys_buffer;
41
42
43 boolean r300_get_texture_buffer(struct pipe_screen* screen,
44 struct pipe_texture* texture,
45 struct r300_winsys_buffer** buffer,
46 unsigned *stride);
47
48 enum r300_value_id {
49 R300_VID_PCI_ID,
50 R300_VID_GB_PIPES,
51 R300_VID_Z_PIPES,
52 R300_VID_SQUARE_TILING_SUPPORT
53 };
54
55 struct r300_winsys_screen {
56 void (*destroy)(struct r300_winsys_screen *ws);
57
58 /**
59 * Buffer management. Buffer attributes are mostly fixed over its lifetime.
60 *
61 * Remember that gallium gets to choose the interface it needs, and the
62 * window systems must then implement that interface (rather than the
63 * other way around...).
64 *
65 * usage is a bitmask of R300_WINSYS_BUFFER_USAGE_PIXEL/VERTEX/INDEX/CONSTANT. This
66 * usage argument is only an optimization hint, not a guarantee, therefore
67 * proper behavior must be observed in all circumstances.
68 *
69 * alignment indicates the client's alignment requirements, eg for
70 * SSE instructions.
71 */
72 struct r300_winsys_buffer *(*buffer_create)(struct r300_winsys_screen *ws,
73 unsigned alignment,
74 unsigned usage,
75 unsigned size);
76
77 /**
78 * Map the entire data store of a buffer object into the client's address.
79 * flags is bitmask of R300_WINSYS_BUFFER_USAGE_CPU_READ/WRITE flags.
80 */
81 void *(*buffer_map)( struct r300_winsys_screen *ws,
82 struct r300_winsys_buffer *buf,
83 unsigned usage);
84
85 void (*buffer_unmap)( struct r300_winsys_screen *ws,
86 struct r300_winsys_buffer *buf );
87
88 void (*buffer_destroy)( struct r300_winsys_buffer *buf );
89
90
91 void (*buffer_reference)(struct r300_winsys_screen *rws,
92 struct r300_winsys_buffer **pdst,
93 struct r300_winsys_buffer *src);
94
95 boolean (*buffer_references)(struct r300_winsys_buffer *a,
96 struct r300_winsys_buffer *b);
97
98 void (*buffer_flush_range)(struct r300_winsys_screen *rws,
99 struct r300_winsys_buffer *buf,
100 unsigned offset,
101 unsigned length);
102
103 /* Add a pipe_buffer to the list of buffer objects to validate. */
104 boolean (*add_buffer)(struct r300_winsys_screen *winsys,
105 struct r300_winsys_buffer *buf,
106 uint32_t rd,
107 uint32_t wd);
108
109
110 /* Revalidate all currently setup pipe_buffers.
111 * Returns TRUE if a flush is required. */
112 boolean (*validate)(struct r300_winsys_screen* winsys);
113
114 /* Check to see if there's room for commands. */
115 boolean (*check_cs)(struct r300_winsys_screen* winsys, int size);
116
117 /* Start a command emit. */
118 void (*begin_cs)(struct r300_winsys_screen* winsys,
119 int size,
120 const char* file,
121 const char* function,
122 int line);
123
124 /* Write a dword to the command buffer. */
125 void (*write_cs_dword)(struct r300_winsys_screen* winsys, uint32_t dword);
126
127 /* Write a relocated dword to the command buffer. */
128 void (*write_cs_reloc)(struct r300_winsys_screen *winsys,
129 struct r300_winsys_buffer *buf,
130 uint32_t rd,
131 uint32_t wd,
132 uint32_t flags);
133
134 /* Finish a command emit. */
135 void (*end_cs)(struct r300_winsys_screen* winsys,
136 const char* file,
137 const char* function,
138 int line);
139
140 /* Flush the CS. */
141 void (*flush_cs)(struct r300_winsys_screen* winsys);
142
143 /* winsys flush - callback from winsys when flush required */
144 void (*set_flush_cb)(struct r300_winsys_screen *winsys,
145 void (*flush_cb)(void *), void *data);
146
147 void (*reset_bos)(struct r300_winsys_screen *winsys);
148
149 void (*buffer_set_tiling)(struct r300_winsys_screen *winsys,
150 struct r300_winsys_buffer *buffer,
151 uint32_t pitch,
152 enum r300_buffer_tiling microtiled,
153 enum r300_buffer_tiling macrotiled);
154
155 uint32_t (*get_value)(struct r300_winsys_screen *winsys,
156 enum r300_value_id vid);
157
158 struct r300_winsys_buffer *(*buffer_from_handle)(struct r300_winsys_screen *winsys,
159 struct pipe_screen *screen,
160 struct winsys_handle *whandle,
161 unsigned *stride);
162 boolean (*buffer_get_handle)(struct r300_winsys_screen *winsys,
163 struct r300_winsys_buffer *buffer,
164 unsigned stride,
165 struct winsys_handle *whandle);
166
167 boolean (*is_buffer_referenced)(struct r300_winsys_screen *winsys,
168 struct r300_winsys_buffer *buffer);
169
170
171 };
172
173 struct r300_winsys_screen *
174 r300_winsys_screen(struct pipe_screen *screen);
175
176 #endif /* R300_WINSYS_H */