dc12eb78471eaa5272899f0f7716330a0f2b2f28
[mesa.git] / src / gallium / drivers / llvmpipe / lp_setup_context.h
1 /**************************************************************************
2 *
3 * Copyright 2007-2009 VMware, Inc.
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 VMWARE 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 /**
30 * The setup code is concerned with point/line/triangle setup and
31 * putting commands/data into the bins.
32 */
33
34
35 #ifndef LP_SETUP_CONTEXT_H
36 #define LP_SETUP_CONTEXT_H
37
38 #include "lp_setup.h"
39 #include "lp_rast.h"
40 #include "lp_tile_soa.h" /* for TILE_SIZE */
41 #include "lp_bin.h"
42
43 /* We're limited to 2K by 2K for 32bit fixed point rasterization.
44 * Will need a 64-bit version for larger framebuffers.
45 */
46 #define MAXHEIGHT 2048
47 #define MAXWIDTH 2048
48 #define TILES_X (MAXWIDTH / TILE_SIZE)
49 #define TILES_Y (MAXHEIGHT / TILE_SIZE)
50
51
52 #define LP_SETUP_NEW_FS 0x01
53 #define LP_SETUP_NEW_CONSTANTS 0x02
54 #define LP_SETUP_NEW_BLEND_COLOR 0x04
55
56
57 /**
58 * Point/line/triangle setup context.
59 * Note: "stored" below indicates data which is stored in the bins,
60 * not arbitrary malloc'd memory.
61 */
62 struct setup_context {
63
64 struct lp_rasterizer *rast;
65
66 /**
67 * Per-bin data goes into the 'tile' bins.
68 * Shared bin data goes into the 'data' buffer.
69 * When there are multiple threads, will want to double-buffer the
70 * bin arrays:
71 */
72 struct cmd_bin tile[TILES_X][TILES_Y];
73 struct data_block_list data;
74
75 /* size of framebuffer, in tiles */
76 unsigned tiles_x;
77 unsigned tiles_y;
78
79 boolean ccw_is_frontface;
80 unsigned cullmode;
81
82 const struct pipe_framebuffer_state *fb;
83
84 struct {
85 unsigned flags;
86 union lp_rast_cmd_arg color; /**< lp_rast_clear_color() cmd */
87 union lp_rast_cmd_arg zstencil; /**< lp_rast_clear_zstencil() cmd */
88 } clear;
89
90 enum {
91 SETUP_FLUSHED,
92 SETUP_CLEARED,
93 SETUP_ACTIVE
94 } state;
95
96 struct {
97 struct lp_shader_input input[PIPE_MAX_ATTRIBS];
98 unsigned nr_inputs;
99
100 const struct lp_rast_state *stored; /**< what's in the bins */
101 struct lp_rast_state current; /**< currently set state */
102 } fs;
103
104 /** fragment shader constants */
105 struct {
106 struct pipe_buffer *current;
107 unsigned stored_size;
108 const void *stored_data;
109 } constants;
110
111 struct {
112 struct pipe_blend_color current;
113 uint8_t *stored;
114 } blend_color;
115
116 unsigned dirty; /**< bitmask of LP_SETUP_x bits */
117
118 void (*point)( struct setup_context *,
119 const float (*v0)[4]);
120
121 void (*line)( struct setup_context *,
122 const float (*v0)[4],
123 const float (*v1)[4]);
124
125 void (*triangle)( struct setup_context *,
126 const float (*v0)[4],
127 const float (*v1)[4],
128 const float (*v2)[4]);
129 };
130
131 void lp_setup_choose_triangle( struct setup_context *setup );
132 void lp_setup_choose_line( struct setup_context *setup );
133 void lp_setup_choose_point( struct setup_context *setup );
134
135
136 #endif