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 **************************************************************************/
29 #ifndef CELL_CONTEXT_H
30 #define CELL_CONTEXT_H
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 #include "rtasm/rtasm_ppc_spe.h"
40 #include "tgsi/tgsi_scan.h"
43 struct cell_vbuf_render
;
47 * Cell vertex shader state, subclass of pipe_shader_state.
49 struct cell_vertex_shader_state
51 struct pipe_shader_state shader
;
52 struct tgsi_shader_info info
;
58 * Cell fragment shader state, subclass of pipe_shader_state.
60 struct cell_fragment_shader_state
62 struct pipe_shader_state shader
;
63 struct tgsi_shader_info info
;
64 struct spe_function code
;
70 * Per-context state, subclass of pipe_context.
74 struct pipe_context pipe
;
76 struct cell_winsys
*winsys
;
78 const struct pipe_blend_state
*blend
;
79 const struct pipe_sampler_state
*sampler
[PIPE_MAX_SAMPLERS
];
81 const struct pipe_depth_stencil_alpha_state
*depth_stencil
;
82 const struct pipe_rasterizer_state
*rasterizer
;
83 const struct cell_vertex_shader_state
*vs
;
84 const struct cell_fragment_shader_state
*fs
;
86 struct spe_function logic_op
;
88 struct pipe_blend_color blend_color
;
89 struct pipe_clip_state clip
;
90 struct pipe_constant_buffer constants
[2];
91 struct pipe_framebuffer_state framebuffer
;
92 struct pipe_poly_stipple poly_stipple
;
93 struct pipe_scissor_state scissor
;
94 struct cell_texture
*texture
[PIPE_MAX_SAMPLERS
];
96 struct pipe_viewport_state viewport
;
97 struct pipe_vertex_buffer vertex_buffer
[PIPE_MAX_ATTRIBS
];
98 uint num_vertex_buffers
;
99 struct pipe_vertex_element vertex_element
[PIPE_MAX_ATTRIBS
];
100 uint num_vertex_elements
;
102 ubyte
*cbuf_map
[PIPE_MAX_COLOR_BUFS
];
105 struct pipe_surface
*tex_surf
;
110 /** The primitive drawing context */
111 struct draw_context
*draw
;
112 struct draw_stage
*render_stage
;
114 /** For post-transformed vertex buffering: */
115 struct cell_vbuf_render
*vbuf_render
;
116 struct draw_stage
*vbuf
;
118 struct vertex_info vertex_info
;
120 /** Mapped constant buffers */
121 void *mapped_constants
[PIPE_SHADER_TYPES
];
123 struct cell_spu_function_info spu_functions ALIGN16_ATTRIB
;
127 /** Buffers for command batches, vertex/index data */
128 uint buffer_size
[CELL_NUM_BUFFERS
];
129 ubyte buffer
[CELL_NUM_BUFFERS
][CELL_BUFFER_SIZE
] ALIGN16_ATTRIB
;
131 int cur_batch
; /**< which buffer is being filled w/ commands */
133 /** [4] to ensure 16-byte alignment for each status word */
134 uint buffer_status
[CELL_MAX_SPUS
][CELL_NUM_BUFFERS
][4] ALIGN16_ATTRIB
;
137 struct spe_function attrib_fetch
;
138 unsigned attrib_fetch_offsets
[PIPE_MAX_ATTRIBS
];
140 unsigned debug_flags
;
146 static INLINE
struct cell_context
*
147 cell_context(struct pipe_context
*pipe
)
149 return (struct cell_context
*) pipe
;
153 extern struct pipe_context
*
154 cell_create_context(struct pipe_screen
*screen
, struct cell_winsys
*cws
);
157 cell_vertex_shader_queue_flush(struct draw_context
*draw
);
160 /* XXX find a better home for this */
161 extern void cell_update_vertex_fetch(struct draw_context
*draw
);
164 #endif /* CELL_CONTEXT_H */