gallium: add missing mip level clamp
[mesa.git] / src / gallium / drivers / 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 SP_CONTEXT_H
32 #define SP_CONTEXT_H
33
34 #include "pipe/p_context.h"
35 #include "pipe/p_defines.h"
36
37 #include "draw/draw_vertex.h"
38
39 #include "sp_quad.h"
40
41
42 struct softpipe_winsys;
43 struct softpipe_vbuf_render;
44 struct draw_context;
45 struct draw_stage;
46 struct softpipe_tile_cache;
47 struct sp_fragment_shader;
48 struct sp_vertex_shader;
49
50
51 struct softpipe_context {
52 struct pipe_context pipe; /**< base class */
53 struct softpipe_winsys *winsys; /**< window system interface */
54
55
56 /* The most recent drawing state as set by the driver:
57 */
58 const struct pipe_blend_state *blend;
59 const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS];
60 const struct pipe_depth_stencil_alpha_state *depth_stencil;
61 const struct pipe_rasterizer_state *rasterizer;
62 const struct sp_fragment_shader *fs;
63 const struct sp_vertex_shader *vs;
64
65 struct pipe_blend_color blend_color;
66 struct pipe_clip_state clip;
67 struct pipe_constant_buffer constants[2];
68 struct pipe_framebuffer_state framebuffer;
69 struct pipe_poly_stipple poly_stipple;
70 struct pipe_scissor_state scissor;
71 struct softpipe_texture *texture[PIPE_MAX_SAMPLERS];
72 struct pipe_viewport_state viewport;
73 struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX];
74 struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX];
75 unsigned dirty;
76
77 /* Counter for occlusion queries. Note this supports overlapping
78 * queries.
79 */
80 uint64 occlusion_count;
81
82 /*
83 * Mapped vertex buffers
84 */
85 ubyte *mapped_vbuffer[PIPE_ATTRIB_MAX];
86
87 /** Mapped constant buffers */
88 void *mapped_constants[PIPE_SHADER_TYPES];
89
90 /** Vertex format */
91 struct vertex_info vertex_info;
92 struct vertex_info vertex_info_vbuf;
93
94 int psize_slot;
95
96 #if 0
97 /* Stipple derived state:
98 */
99 ubyte stipple_masks[16][16];
100 #endif
101
102 /** Derived from scissor and surface bounds: */
103 struct pipe_scissor_state cliprect;
104
105 unsigned line_stipple_counter;
106
107 /** Software quad rendering pipeline */
108 struct {
109 struct quad_stage *polygon_stipple;
110 struct quad_stage *earlyz;
111 struct quad_stage *shade;
112 struct quad_stage *alpha_test;
113 struct quad_stage *stencil_test;
114 struct quad_stage *depth_test;
115 struct quad_stage *occlusion;
116 struct quad_stage *coverage;
117 struct quad_stage *bufloop;
118 struct quad_stage *blend;
119 struct quad_stage *colormask;
120 struct quad_stage *output;
121
122 struct quad_stage *first; /**< points to one of the above stages */
123 } quad;
124
125 /** The primitive drawing context */
126 struct draw_context *draw;
127 struct draw_stage *setup;
128 struct draw_stage *vbuf;
129 struct softpipe_vbuf_render *vbuf_render;
130
131 uint current_cbuf; /**< current color buffer being written to */
132
133 struct softpipe_tile_cache *cbuf_cache[PIPE_MAX_COLOR_BUFS];
134 struct softpipe_tile_cache *zsbuf_cache;
135
136 struct softpipe_tile_cache *tex_cache[PIPE_MAX_SAMPLERS];
137
138 int use_sse : 1;
139 int dump_fs : 1;
140 };
141
142
143
144
145 static INLINE struct softpipe_context *
146 softpipe_context( struct pipe_context *pipe )
147 {
148 return (struct softpipe_context *)pipe;
149 }
150
151
152 #endif /* SP_CONTEXT_H */