f6604a8034aa2896ef4d9aaf398925b980f3782f
[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_scene.h"
42
43
44 #define LP_SETUP_NEW_FS 0x01
45 #define LP_SETUP_NEW_CONSTANTS 0x02
46 #define LP_SETUP_NEW_BLEND_COLOR 0x04
47
48
49 struct lp_scene_queue;
50
51
52 /**
53 * Point/line/triangle setup context.
54 * Note: "stored" below indicates data which is stored in the bins,
55 * not arbitrary malloc'd memory.
56 */
57 struct setup_context {
58
59 struct lp_rasterizer *rast;
60
61
62 struct lp_scene *scene; /**< current scene */
63 struct lp_scene_queue *empty_scenes; /**< queue of empty scenes */
64
65 boolean ccw_is_frontface;
66 unsigned cullmode;
67
68 struct pipe_framebuffer_state fb;
69
70 struct {
71 unsigned flags;
72 union lp_rast_cmd_arg color; /**< lp_rast_clear_color() cmd */
73 union lp_rast_cmd_arg zstencil; /**< lp_rast_clear_zstencil() cmd */
74 } clear;
75
76 enum {
77 SETUP_FLUSHED,
78 SETUP_CLEARED,
79 SETUP_ACTIVE
80 } state;
81
82 struct {
83 struct lp_shader_input input[PIPE_MAX_ATTRIBS];
84 unsigned nr_inputs;
85
86 const struct lp_rast_state *stored; /**< what's in the scene */
87 struct lp_rast_state current; /**< currently set state */
88 } fs;
89
90 /** fragment shader constants */
91 struct {
92 struct pipe_buffer *current;
93 unsigned stored_size;
94 const void *stored_data;
95 } constants;
96
97 struct {
98 struct pipe_blend_color current;
99 uint8_t *stored;
100 } blend_color;
101
102 unsigned dirty; /**< bitmask of LP_SETUP_x bits */
103
104 void (*point)( struct setup_context *,
105 const float (*v0)[4]);
106
107 void (*line)( struct setup_context *,
108 const float (*v0)[4],
109 const float (*v1)[4]);
110
111 void (*triangle)( struct setup_context *,
112 const float (*v0)[4],
113 const float (*v1)[4],
114 const float (*v2)[4]);
115 };
116
117 void lp_setup_choose_triangle( struct setup_context *setup );
118 void lp_setup_choose_line( struct setup_context *setup );
119 void lp_setup_choose_point( struct setup_context *setup );
120
121 struct lp_scene *lp_setup_get_current_scene(struct setup_context *setup);
122
123 #endif