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