Don't reemit hardware state *every* primitive.
[mesa.git] / src / mesa / pipe / i915simple / i915_context.h
1 /**************************************************************************
2 *
3 * Copyright 2003 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 #ifndef I915_CONTEXT_H
29 #define I915_CONTEXT_H
30
31
32 #include "pipe/p_context.h"
33 #include "pipe/p_state.h"
34
35 struct i915_context
36 {
37 struct pipe_context pipe;
38 struct i915_winsys *winsys;
39 struct draw_context *draw;
40
41 /* The most recent drawing state as set by the driver:
42 */
43 struct pipe_alpha_test_state alpha_test;
44 struct pipe_blend_state blend;
45 struct pipe_blend_color blend_color;
46 struct pipe_clear_color_state clear_color;
47 struct pipe_clip_state clip;
48 struct pipe_depth_state depth_test;
49 struct pipe_framebuffer_state framebuffer;
50 struct pipe_fs_state fs;
51 struct pipe_poly_stipple poly_stipple;
52 struct pipe_scissor_state scissor;
53 struct pipe_sampler_state sampler[PIPE_MAX_SAMPLERS];
54 struct pipe_setup_state setup;
55 struct pipe_stencil_state stencil;
56 struct pipe_mipmap_tree *texture[PIPE_MAX_SAMPLERS];
57 struct pipe_viewport_state viewport;
58 GLuint dirty;
59 GLuint hw_dirty;
60
61 GLuint *batch_start;
62
63 struct pipe_scissor_state cliprect;
64 };
65
66 #define I915_NEW_VIEWPORT 0x1
67 #define I915_NEW_SETUP 0x2
68 #define I915_NEW_FS 0x4
69 #define I915_NEW_BLEND 0x8
70 #define I915_NEW_CLIP 0x10
71 #define I915_NEW_SCISSOR 0x20
72 #define I915_NEW_STIPPLE 0x40
73 #define I915_NEW_FRAMEBUFFER 0x80
74 #define I915_NEW_ALPHA_TEST 0x100
75 #define I915_NEW_DEPTH_TEST 0x200
76 #define I915_NEW_SAMPLER 0x400
77 #define I915_NEW_TEXTURE 0x800
78 #define I915_NEW_STENCIL 0x1000
79
80
81 /***********************************************************************
82 * i915_prim_emit.c:
83 */
84 struct draw_stage *i915_draw_render_stage( struct i915_context *i915 );
85
86
87 /***********************************************************************
88 * i915_state_emit.c:
89 */
90 void i915_emit_hardware_state(struct i915_context *i915 );
91 unsigned *i915_passthrough_program( unsigned *dwords );
92
93
94
95 /***********************************************************************
96 * i915_clear.c:
97 */
98 void i915_clear(struct pipe_context *pipe, struct pipe_surface *ps,
99 GLuint clearValue);
100
101
102 /***********************************************************************
103 * i915_buffer.c:
104 */
105 void i915_init_buffer_functions( struct i915_context *i915 );
106 void i915_init_region_functions( struct i915_context *i915 );
107 void i915_init_surface_functions( struct i915_context *i915 );
108 void i915_init_state_functions( struct i915_context *i915 );
109 void i915_init_flush_functions( struct i915_context *i915 );
110
111
112
113 /***********************************************************************
114 * Inline conversion functions. These are better-typed than the
115 * macros used previously:
116 */
117 static INLINE struct i915_context *
118 i915_context( struct pipe_context *pipe )
119 {
120 return (struct i915_context *)pipe;
121 }
122
123
124
125 #endif