0a183ea3855ccfd9689eea8a3bfe98bfef1ed70e
[mesa.git] / src / mesa / pipe / softpipe / sp_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 /* Authors: Keith Whitwell <keith@tungstengraphics.com>
29 */
30
31 #ifndef G_CONTEXT_H
32 #define G_CONTEXT_H
33
34 #include "glheader.h"
35
36 #include "pipe/p_state.h"
37 #include "pipe/p_context.h"
38
39
40
41 struct softpipe_surface;
42 struct draw_context;
43 struct prim_stage;
44
45
46 enum interp_mode {
47 INTERP_CONSTANT,
48 INTERP_LINEAR,
49 INTERP_PERSPECTIVE
50 };
51
52
53 #define G_NEW_VIEWPORT 0x1
54 #define G_NEW_SETUP 0x2
55 #define G_NEW_FS 0x4
56 #define G_NEW_BLEND 0x8
57 #define G_NEW_POINT 0x10
58 #define G_NEW_CLIP 0x20
59 #define G_NEW_SCISSOR 0x40
60 #define G_NEW_STIPPLE 0x80
61 #define G_NEW_FRAMEBUFFER 0x100
62 #define G_NEW_ALPHA_TEST 0x200
63 #define G_NEW_DEPTH_TEST 0x400
64
65
66 struct softpipe_context {
67 struct pipe_context pipe;
68
69
70 /* The most recent drawing state as set by the driver:
71 */
72 struct pipe_framebuffer_state framebuffer;
73 struct pipe_viewport viewport;
74 struct pipe_setup_state setup;
75 struct pipe_fs_state fs;
76 struct pipe_blend_state blend;
77 struct pipe_alpha_test_state alpha_test;
78 struct pipe_clip_state clip;
79 struct pipe_clear_color_state clear_color;
80 struct pipe_point_state point;
81 struct pipe_scissor_rect scissor;
82 struct pipe_poly_stipple poly_stipple;
83 GLuint dirty;
84
85 /* Clip derived state:
86 */
87 GLfloat plane[12][4];
88 GLuint nr_planes;
89
90 /* Setup derived state. TODO: this should be passed in the program
91 * tokens as parameters to DECL instructions.
92 *
93 * For now we just set colors to CONST on flatshade, textures to
94 * perspective always and everything else to linear.
95 */
96 enum interp_mode interp[VF_ATTRIB_MAX];
97
98
99 /* FS + setup derived state:
100 */
101 GLuint fp_attr_to_slot[VF_ATTRIB_MAX];
102 GLuint vf_attr_to_slot[VF_ATTRIB_MAX];
103 GLuint nr_attrs;
104 GLuint nr_frag_attrs;
105 GLuint attr_mask;
106
107 GLboolean need_z;
108 GLboolean need_w;
109
110 /* Stipple derived state:
111 */
112 GLubyte stipple_masks[16][16];
113
114
115 /* The software clipper/setup engine.
116 */
117 struct {
118 struct prim_stage *setup;
119 struct prim_stage *unfilled;
120 struct prim_stage *twoside;
121 struct prim_stage *clip;
122 struct prim_stage *flatshade;
123 struct prim_stage *offset;
124 struct prim_stage *cull;
125
126 struct prim_stage *first;
127
128 GLenum prim;
129 GLuint vertex_size;
130 } prim;
131
132 /* Temp kludge:
133 */
134 struct draw_context *draw;
135 };
136
137
138
139
140 static INLINE struct softpipe_context *
141 softpipe_context( struct pipe_context *pipe )
142 {
143 return (struct softpipe_context *)pipe;
144 }
145
146
147
148
149 #endif