gallium/i965: remove dependencies on pipe_shader_state's semantic info
[mesa.git] / src / gallium / drivers / i965simple / brw_winsys.h
1 /**************************************************************************
2 *
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 /**
29 * \file
30 * This is the interface that i965simple requires any window system
31 * hosting it to implement. This is the only include file in i965simple
32 * which is public.
33 *
34 */
35
36 #ifndef BRW_WINSYS_H
37 #define BRW_WINSYS_H
38
39
40 #include "pipe/p_defines.h"
41
42
43 /* Pipe drivers are (meant to be!) independent of both GL and the
44 * window system. The window system provides a buffer manager and a
45 * set of additional hooks for things like command buffer submission,
46 * etc.
47 *
48 * There clearly has to be some agreement between the window system
49 * driver and the hardware driver about the format of command buffers,
50 * etc.
51 */
52
53 struct pipe_buffer;
54 struct pipe_fence_handle;
55 struct pipe_winsys;
56 struct pipe_screen;
57
58
59 /* The pipe driver currently understands the following chipsets:
60 */
61 #define PCI_CHIP_I965_G 0x29A2
62 #define PCI_CHIP_I965_Q 0x2992
63 #define PCI_CHIP_I965_G_1 0x2982
64 #define PCI_CHIP_I965_GM 0x2A02
65 #define PCI_CHIP_I965_GME 0x2A12
66
67
68 /* These are the names of all the state caches managed by the driver.
69 *
70 * When data is uploaded to a buffer with buffer_subdata, we use the
71 * special version of that function below so that information about
72 * what type of data this is can be passed to the winsys backend.
73 * That in turn allows the correct flags to be set in the aub file
74 * dump to allow human-readable file dumps later on.
75 */
76
77 enum brw_cache_id {
78 BRW_CC_VP,
79 BRW_CC_UNIT,
80 BRW_WM_PROG,
81 BRW_SAMPLER_DEFAULT_COLOR,
82 BRW_SAMPLER,
83 BRW_WM_UNIT,
84 BRW_SF_PROG,
85 BRW_SF_VP,
86 BRW_SF_UNIT,
87 BRW_VS_UNIT,
88 BRW_VS_PROG,
89 BRW_GS_UNIT,
90 BRW_GS_PROG,
91 BRW_CLIP_VP,
92 BRW_CLIP_UNIT,
93 BRW_CLIP_PROG,
94 BRW_SS_SURFACE,
95 BRW_SS_SURF_BIND,
96
97 BRW_MAX_CACHE
98 };
99
100 #define BRW_CONSTANT_BUFFER BRW_MAX_CACHE
101
102 /**
103 * Additional winsys interface for i965simple.
104 *
105 * It is an over-simple batchbuffer mechanism. Will want to improve the
106 * performance of this, perhaps based on the cmdstream stuff. It
107 * would be pretty impossible to implement swz on top of this
108 * interface.
109 *
110 * Will also need additions/changes to implement static/dynamic
111 * indirect state.
112 */
113 struct brw_winsys {
114
115 /**
116 * Reserve space on batch buffer.
117 *
118 * Returns a null pointer if there is insufficient space in the batch buffer
119 * to hold the requested number of dwords and relocations.
120 *
121 * The number of dwords should also include the number of relocations.
122 */
123 unsigned *(*batch_start)(struct brw_winsys *sws,
124 unsigned dwords,
125 unsigned relocs);
126
127 void (*batch_dword)(struct brw_winsys *sws,
128 unsigned dword);
129
130 /**
131 * Emit a relocation to a buffer.
132 *
133 * Used not only when the buffer addresses are not pinned, but also to
134 * ensure refered buffers will not be destroyed until the current batch
135 * buffer execution is finished.
136 *
137 * The access flags is a combination of I915_BUFFER_ACCESS_WRITE and
138 * I915_BUFFER_ACCESS_READ macros.
139 */
140 void (*batch_reloc)(struct brw_winsys *sws,
141 struct pipe_buffer *buf,
142 unsigned access_flags,
143 unsigned delta);
144
145
146 /* Not used yet, but really want this:
147 */
148 void (*batch_end)( struct brw_winsys *sws );
149
150 /**
151 * Flush the batch buffer.
152 *
153 * Fence argument must point to NULL or to a previous fence, and the caller
154 * must call fence_reference when done with the fence.
155 */
156 void (*batch_flush)(struct brw_winsys *sws,
157 struct pipe_fence_handle **fence);
158
159
160 /* A version of buffer_subdata that includes information for the
161 * simulator:
162 */
163 void (*buffer_subdata_typed)(struct brw_winsys *sws,
164 struct pipe_buffer *buf,
165 unsigned long offset,
166 unsigned long size,
167 const void *data,
168 unsigned data_type);
169
170
171 /* A cheat so we don't have to think about relocations in a couple
172 * of places yet:
173 */
174 unsigned (*get_buffer_offset)( struct brw_winsys *sws,
175 struct pipe_buffer *buf,
176 unsigned flags );
177
178 };
179
180 #define BRW_BUFFER_ACCESS_WRITE 0x1
181 #define BRW_BUFFER_ACCESS_READ 0x2
182
183 #define BRW_BUFFER_USAGE_LIT_VERTEX (PIPE_BUFFER_USAGE_CUSTOM << 0)
184
185
186 struct pipe_context *brw_create(struct pipe_screen *,
187 struct brw_winsys *,
188 unsigned pci_id);
189
190 static inline boolean brw_batchbuffer_data(struct brw_winsys *winsys,
191 const void *data,
192 unsigned bytes)
193 {
194 static const unsigned incr = sizeof(unsigned);
195 uint i;
196 const unsigned *udata = (const unsigned*)(data);
197 unsigned size = bytes/incr;
198
199 winsys->batch_start(winsys, size, 0);
200 for (i = 0; i < size; ++i) {
201 winsys->batch_dword(winsys, udata[i]);
202 }
203 winsys->batch_end(winsys);
204
205 return (i == size);
206 }
207 #endif