2 Copyright (C) Intel Corp. 2006. All Rights Reserved.
3 Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
4 develop this 3D driver.
6 Permission is hereby granted, free of charge, to any person obtaining
7 a 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, sublicense, 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
16 portions of the Software.
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
22 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **********************************************************************/
29 * Keith Whitwell <keith@tungstengraphics.com>
33 #include "brw_context.h"
34 #include "brw_defines.h"
37 #include "brw_tex_layout.h"
38 #include "brw_winsys.h"
40 #include "pipe/p_winsys.h"
41 #include "pipe/p_context.h"
42 #include "pipe/p_util.h"
43 #include "pipe/p_screen.h"
51 static void brw_destroy(struct pipe_context
*pipe
)
53 struct brw_context
*brw
= brw_context(pipe
);
59 static void brw_clear(struct pipe_context
*pipe
, struct pipe_surface
*ps
,
70 pipe
->surface_fill(pipe
, ps
, x
, y
, w
, h
, clearValue
);
75 brw_is_format_supported( struct pipe_context
*pipe
,
76 enum pipe_format format
, uint type
)
79 /* XXX: This is broken -- rewrite if still needed. */
80 static const unsigned tex_supported
[] = {
81 PIPE_FORMAT_U_R8_G8_B8_A8
,
82 PIPE_FORMAT_U_A8_R8_G8_B8
,
83 PIPE_FORMAT_U_R5_G6_B5
,
89 PIPE_FORMAT_YCBCR_REV
,
94 /* Actually a lot more than this - add later:
96 static const unsigned render_supported
[] = {
97 PIPE_FORMAT_U_A8_R8_G8_B8
,
98 PIPE_FORMAT_U_R5_G6_B5
,
103 static const unsigned z_stencil_supported
[] = {
110 case PIPE_RENDER_FORMAT
:
111 *numFormats
= Elements(render_supported
);
112 return render_supported
;
114 case PIPE_TEX_FORMAT
:
115 *numFormats
= Elements(tex_supported
);
116 return render_supported
;
118 case PIPE_Z_STENCIL_FORMAT
:
119 *numFormats
= Elements(render_supported
);
120 return render_supported
;
128 case PIPE_FORMAT_A8R8G8B8_UNORM
:
129 case PIPE_FORMAT_R5G6B5_UNORM
:
130 case PIPE_FORMAT_S8Z24_UNORM
:
142 struct pipe_context
*brw_create(struct pipe_screen
*screen
,
143 struct brw_winsys
*brw_winsys
,
146 struct brw_context
*brw
;
148 screen
->winsys
->printf(screen
->winsys
,
149 "%s: creating brw_context with pci id 0x%x\n",
150 __FUNCTION__
, pci_id
);
152 brw
= CALLOC_STRUCT(brw_context
);
156 brw
->winsys
= brw_winsys
;
157 brw
->pipe
.winsys
= screen
->winsys
;
158 brw
->pipe
.screen
= screen
;
160 brw
->pipe
.destroy
= brw_destroy
;
161 brw
->pipe
.is_format_supported
= brw_is_format_supported
;
162 brw
->pipe
.clear
= brw_clear
;
164 brw_init_surface_functions(brw
);
165 brw_init_texture_functions(brw
);
166 brw_init_state_functions(brw
);
167 brw_init_flush_functions(brw
);
168 brw_init_draw_functions( brw
);
171 brw_init_state( brw
);
173 brw
->pci_id
= pci_id
;
175 brw
->hardware_dirty
= ~0;
177 memset(&brw
->wm
.bind
, ~0, sizeof(brw
->wm
.bind
));