Code reorganization: update build.
[mesa.git] / src / gallium / drivers / cell / ppu / cell_context.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 #ifndef CELL_CONTEXT_H
30 #define CELL_CONTEXT_H
31
32
33 #include "pipe/p_context.h"
34 #include "pipe/p_defines.h"
35 #include "draw/draw_vertex.h"
36 #include "draw/draw_vbuf.h"
37 #include "cell_winsys.h"
38 #include "cell/common.h"
39
40
41 struct cell_vbuf_render;
42
43 struct cell_vertex_shader_state
44 {
45 struct pipe_shader_state shader;
46 void *draw_data;
47 };
48
49
50 struct cell_fragment_shader_state
51 {
52 struct pipe_shader_state shader;
53 void *data;
54 };
55
56
57 struct cell_context
58 {
59 struct pipe_context pipe;
60
61 struct cell_winsys *winsys;
62
63 const struct pipe_blend_state *blend;
64 const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS];
65 const struct pipe_depth_stencil_alpha_state *depth_stencil;
66 const struct pipe_rasterizer_state *rasterizer;
67 const struct cell_vertex_shader_state *vs;
68 const struct cell_fragment_shader_state *fs;
69
70 struct pipe_blend_color blend_color;
71 struct pipe_clip_state clip;
72 struct pipe_constant_buffer constants[2];
73 struct pipe_framebuffer_state framebuffer;
74 struct pipe_poly_stipple poly_stipple;
75 struct pipe_scissor_state scissor;
76 struct cell_texture *texture[PIPE_MAX_SAMPLERS];
77 struct pipe_viewport_state viewport;
78 struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX];
79 struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX];
80
81 ubyte *cbuf_map[PIPE_MAX_COLOR_BUFS];
82 ubyte *zsbuf_map;
83
84 struct pipe_surface *tex_surf;
85 uint *tex_map;
86
87 uint dirty;
88
89 /** The primitive drawing context */
90 struct draw_context *draw;
91 struct draw_stage *render_stage;
92
93 /** For post-transformed vertex buffering: */
94 struct cell_vbuf_render *vbuf_render;
95 struct draw_stage *vbuf;
96
97 struct vertex_info vertex_info;
98
99 /** Mapped constant buffers */
100 void *mapped_constants[PIPE_SHADER_TYPES];
101
102
103 uint num_spus;
104
105 /** Buffers for command batches, vertex/index data */
106 uint buffer_size[CELL_NUM_BUFFERS];
107 ubyte buffer[CELL_NUM_BUFFERS][CELL_BUFFER_SIZE] ALIGN16_ATTRIB;
108
109 int cur_batch; /**< which buffer is being filled w/ commands */
110
111 /** [4] to ensure 16-byte alignment for each status word */
112 uint buffer_status[CELL_MAX_SPUS][CELL_NUM_BUFFERS][4] ALIGN16_ATTRIB;
113
114 };
115
116
117
118
119 static INLINE struct cell_context *
120 cell_context(struct pipe_context *pipe)
121 {
122 return (struct cell_context *) pipe;
123 }
124
125
126 extern struct pipe_context *
127 cell_create_context(struct pipe_winsys *ws, struct cell_winsys *cws);
128
129 extern void
130 cell_vertex_shader_queue_flush(struct draw_context *draw);
131
132
133
134
135 #endif /* CELL_CONTEXT_H */