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 **************************************************************************/
36 #include "pipe/p_defines.h"
37 #include "pipe/p_format.h"
38 #include "util/u_memory.h"
39 #include "pipe/p_winsys.h"
40 #include "pipe/p_screen.h"
42 #include "draw/draw_context.h"
43 #include "draw/draw_private.h"
45 #include "cell/common.h"
46 #include "cell_clear.h"
47 #include "cell_context.h"
48 #include "cell_draw_arrays.h"
49 #include "cell_flush.h"
50 #include "cell_render.h"
51 #include "cell_state.h"
52 #include "cell_surface.h"
54 #include "cell_pipe_state.h"
55 #include "cell_texture.h"
56 #include "cell_vbuf.h"
61 cell_destroy_context( struct pipe_context
*pipe
)
63 struct cell_context
*cell
= cell_context(pipe
);
71 static struct draw_context
*
72 cell_draw_create(struct cell_context
*cell
)
74 struct draw_context
*draw
= draw_create();
77 if (getenv("GALLIUM_CELL_VS")) {
78 /* plug in SPU-based vertex transformation code */
79 draw
->shader_queue_flush
= cell_vertex_shader_queue_flush
;
80 draw
->driver_private
= cell
;
89 cell_create_context(struct pipe_screen
*screen
,
90 struct cell_winsys
*cws
)
92 struct cell_context
*cell
;
95 /* some fields need to be 16-byte aligned, so align the whole object */
96 cell
= (struct cell_context
*) align_malloc(sizeof(struct cell_context
), 16);
100 memset(cell
, 0, sizeof(*cell
));
103 cell
->pipe
.winsys
= screen
->winsys
;
104 cell
->pipe
.screen
= screen
;
105 cell
->pipe
.destroy
= cell_destroy_context
;
108 cell
->pipe
.set_vertex_buffers
= cell_set_vertex_buffers
;
109 cell
->pipe
.set_vertex_elements
= cell_set_vertex_elements
;
111 cell
->pipe
.draw_arrays
= cell_draw_arrays
;
112 cell
->pipe
.draw_elements
= cell_draw_elements
;
113 cell
->pipe
.draw_range_elements
= cell_draw_range_elements
;
114 cell
->pipe
.set_edgeflags
= cell_set_edgeflags
;
116 cell
->pipe
.clear
= cell_clear_surface
;
117 cell
->pipe
.flush
= cell_flush
;
120 cell
->pipe
.begin_query
= cell_begin_query
;
121 cell
->pipe
.end_query
= cell_end_query
;
122 cell
->pipe
.wait_query
= cell_wait_query
;
125 cell_init_state_functions(cell
);
126 cell_init_shader_functions(cell
);
127 cell_init_surface_functions(cell
);
128 cell_init_texture_functions(cell
);
130 cell
->draw
= cell_draw_create(cell
);
132 cell_init_vbuf(cell
);
133 draw_set_rasterize_stage(cell
->draw
, cell
->vbuf
);
135 /* convert all points/lines to tris for the time being */
136 draw_wide_point_threshold(cell
->draw
, 0.0);
137 draw_wide_line_threshold(cell
->draw
, 0.0);
143 /* XXX is this in SDK 3.0 only?
144 cell->num_spus = spe_cpu_info_get(SPE_COUNT_PHYSICAL_SPES, -1);
147 cell_start_spus(cell
);
149 /* init command, vertex/index buffer info */
150 for (buf
= 0; buf
< CELL_NUM_BUFFERS
; buf
++) {
151 cell
->buffer_size
[buf
] = 0;
153 /* init batch buffer status values,
154 * mark 0th buffer as used, rest as free.
156 for (spu
= 0; spu
< cell
->num_spus
; spu
++) {
158 cell
->buffer_status
[spu
][buf
][0] = CELL_BUFFER_STATUS_USED
;
160 cell
->buffer_status
[spu
][buf
][0] = CELL_BUFFER_STATUS_FREE
;