1 /**************************************************************************
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
30 * This is the interface that i965simple requires any window system
31 * hosting it to implement. This is the only include file in i965simple
40 #include "pipe/p_defines.h"
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,
48 * There clearly has to be some agreement between the window system
49 * driver and the hardware driver about the format of command buffers,
54 struct pipe_fence_handle
;
59 /* The pipe driver currently understands the following chipsets:
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
68 /* These are the names of all the state caches managed by the driver.
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.
81 BRW_SAMPLER_DEFAULT_COLOR
,
100 #define BRW_CONSTANT_BUFFER BRW_MAX_CACHE
103 * Additional winsys interface for i965simple.
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
110 * Will also need additions/changes to implement static/dynamic
115 void (*destroy
)(struct brw_winsys
*);
118 * Reserve space on batch buffer.
120 * Returns a null pointer if there is insufficient space in the batch buffer
121 * to hold the requested number of dwords and relocations.
123 * The number of dwords should also include the number of relocations.
125 unsigned *(*batch_start
)(struct brw_winsys
*sws
,
129 void (*batch_dword
)(struct brw_winsys
*sws
,
133 * Emit a relocation to a buffer.
135 * Used not only when the buffer addresses are not pinned, but also to
136 * ensure refered buffers will not be destroyed until the current batch
137 * buffer execution is finished.
139 * The access flags is a combination of I915_BUFFER_ACCESS_WRITE and
140 * I915_BUFFER_ACCESS_READ macros.
142 void (*batch_reloc
)(struct brw_winsys
*sws
,
143 struct pipe_buffer
*buf
,
144 unsigned access_flags
,
148 /* Not used yet, but really want this:
150 void (*batch_end
)( struct brw_winsys
*sws
);
153 * Flush the batch buffer.
155 * Fence argument must point to NULL or to a previous fence, and the caller
156 * must call fence_reference when done with the fence.
158 void (*batch_flush
)(struct brw_winsys
*sws
,
159 struct pipe_fence_handle
**fence
);
162 /* A version of buffer_subdata that includes information for the
165 void (*buffer_subdata_typed
)(struct brw_winsys
*sws
,
166 struct pipe_buffer
*buf
,
167 unsigned long offset
,
173 /* A cheat so we don't have to think about relocations in a couple
176 unsigned (*get_buffer_offset
)( struct brw_winsys
*sws
,
177 struct pipe_buffer
*buf
,
182 #define BRW_BUFFER_ACCESS_WRITE 0x1
183 #define BRW_BUFFER_ACCESS_READ 0x2
185 #define BRW_BUFFER_USAGE_LIT_VERTEX (PIPE_BUFFER_USAGE_CUSTOM << 0)
188 struct pipe_context
*brw_create(struct pipe_screen
*,
192 static inline boolean
brw_batchbuffer_data(struct brw_winsys
*winsys
,
196 static const unsigned incr
= sizeof(unsigned);
198 const unsigned *udata
= (const unsigned*)(data
);
199 unsigned size
= bytes
/incr
;
201 winsys
->batch_start(winsys
, size
, 0);
202 for (i
= 0; i
< size
; ++i
) {
203 winsys
->batch_dword(winsys
, udata
[i
]);
205 winsys
->batch_end(winsys
);