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 **************************************************************************/
32 #include <spu_mfcio.h>
34 #include "cell/common.h"
35 #include "draw/draw_vertex.h"
36 #include "pipe/p_state.h"
40 #define MAX_WIDTH 1024
41 #define MAX_HEIGHT 1024
45 ushort us
[TILE_SIZE
][TILE_SIZE
];
46 uint ui
[TILE_SIZE
][TILE_SIZE
];
47 vector
unsigned short us8
[TILE_SIZE
/2][TILE_SIZE
/4];
48 vector
unsigned int ui4
[TILE_SIZE
/2][TILE_SIZE
/2];
52 #define TILE_STATUS_CLEAR 1
53 #define TILE_STATUS_DEFINED 2 /**< defined in FB, but not in local store */
54 #define TILE_STATUS_CLEAN 3 /**< in local store, but not changed */
55 #define TILE_STATUS_DIRTY 4 /**< modified locally, but not put back yet */
56 #define TILE_STATUS_GETTING 5 /**< mfc_get() called but not yet arrived */
59 struct spu_frag_test_results
{
65 typedef struct spu_frag_test_results (*frag_test_func
)(qword frag_mask
,
66 qword pixel_depth
, qword pixel_stencil
, qword frag_depth
,
67 qword frag_alpha
, qword facing
);
70 struct spu_blend_results
{
77 typedef struct spu_blend_results (*blend_func
)(
78 qword frag_r
, qword frag_g
, qword frag_b
, qword frag_a
,
79 qword pixel_r
, qword pixel_g
, qword pixel_b
, qword pixel_a
,
80 qword const_r
, qword const_g
, qword const_b
, qword const_a
);
82 typedef struct spu_blend_results (*logicop_func
)(
83 qword pixel_r
, qword pixel_g
, qword pixel_b
, qword pixel_a
,
84 qword frag_r
, qword frag_g
, qword frag_b
, qword frag_a
,
88 typedef vector
float (*sample_texture_func
)(uint unit
, vector
float texcoord
);
90 struct spu_framebuffer
{
91 void *color_start
; /**< addr of color surface in main memory */
92 void *depth_start
; /**< addr of depth surface in main memory */
93 enum pipe_format color_format
;
94 enum pipe_format depth_format
;
95 uint width
, height
; /**< size in pixels */
96 uint width_tiles
, height_tiles
; /**< width and height in tiles */
98 uint color_clear_value
;
99 uint depth_clear_value
;
101 uint zsize
; /**< 0, 2 or 4 bytes per Z */
108 ushort width
, height
;
109 ushort tiles_per_row
;
110 vector
float tex_size
;
111 vector
unsigned int tex_size_mask
; /**< == int(size - 1) */
112 vector
unsigned int tex_size_x_mask
; /**< == int(size - 1) */
113 vector
unsigned int tex_size_y_mask
; /**< == int(size - 1) */
118 * All SPU global/context state will be in singleton object of this type:
122 struct cell_init_info init
;
124 struct spu_framebuffer fb
;
126 boolean read_stencil
;
127 frag_test_func frag_test
; /**< Current depth/stencil test code */
129 boolean read_fb
; /**< Does current blend mode require framebuffer read? */
130 blend_func blend
; /**< Current blend code */
131 qword const_blend_color
[4] ALIGN16_ATTRIB
;
133 logicop_func logicop
; /**< Current logicop code **/
135 struct pipe_sampler_state sampler
[PIPE_MAX_SAMPLERS
];
136 struct spu_texture texture
[PIPE_MAX_SAMPLERS
];
138 struct vertex_info vertex_info
;
140 /* XXX more state to come */
143 /** current color and Z tiles */
144 tile_t ctile ALIGN16_ATTRIB
;
145 tile_t ztile ALIGN16_ATTRIB
;
147 /** Current tiles' status */
148 ubyte cur_ctile_status
, cur_ztile_status
;
150 /** Status of all tiles in framebuffer */
151 ubyte ctile_status
[MAX_HEIGHT
/TILE_SIZE
][MAX_WIDTH
/TILE_SIZE
] ALIGN16_ATTRIB
;
152 ubyte ztile_status
[MAX_HEIGHT
/TILE_SIZE
][MAX_WIDTH
/TILE_SIZE
] ALIGN16_ATTRIB
;
155 /** for converting RGBA to PIPE_FORMAT_x colors */
156 vector
unsigned char color_shuffle
;
158 sample_texture_func sample_texture
[CELL_MAX_SAMPLERS
];
163 extern struct spu_global spu
;
164 extern boolean Debug
;
171 #define TAG_SURFACE_CLEAR 10
172 #define TAG_VERTEX_BUFFER 11
173 #define TAG_READ_TILE_COLOR 12
174 #define TAG_READ_TILE_Z 13
175 #define TAG_WRITE_TILE_COLOR 14
176 #define TAG_WRITE_TILE_Z 15
177 #define TAG_INDEX_BUFFER 16
178 #define TAG_BATCH_BUFFER 17
180 #define TAG_DCACHE0 20
181 #define TAG_DCACHE1 21
182 #define TAG_DCACHE2 22
183 #define TAG_DCACHE3 23
188 wait_on_mask(unsigned tagMask
)
190 mfc_write_tag_mask( tagMask
);
191 /* wait for completion of _any_ DMAs specified by tagMask */
192 mfc_read_tag_status_any();
197 wait_on_mask_all(unsigned tagMask
)
199 mfc_write_tag_mask( tagMask
);
200 /* wait for completion of _any_ DMAs specified by tagMask */
201 mfc_read_tag_status_all();
209 memset16(ushort
*d
, ushort value
, uint count
)
212 for (i
= 0; i
< count
; i
++)
218 memset32(uint
*d
, uint value
, uint count
)
221 for (i
= 0; i
< count
; i
++)
226 #endif /* SPU_MAIN_H */