Merge branch '7.8'
[mesa.git] / src / gallium / drivers / failover / fo_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 FO_CONTEXT_H
32 #define FO_CONTEXT_H
33
34 #include "pipe/p_state.h"
35 #include "pipe/p_context.h"
36
37
38
39 #define FO_NEW_VIEWPORT 0x1
40 #define FO_NEW_RASTERIZER 0x2
41 #define FO_NEW_FRAGMENT_SHADER 0x4
42 #define FO_NEW_BLEND 0x8
43 #define FO_NEW_CLIP 0x10
44 #define FO_NEW_SCISSOR 0x20
45 #define FO_NEW_STIPPLE 0x40
46 #define FO_NEW_FRAMEBUFFER 0x80
47 #define FO_NEW_ALPHA_TEST 0x100
48 #define FO_NEW_DEPTH_STENCIL 0x200
49 #define FO_NEW_SAMPLER 0x400
50 #define FO_NEW_TEXTURE 0x800
51 #define FO_NEW_VERTEX 0x2000
52 #define FO_NEW_VERTEX_SHADER 0x4000
53 #define FO_NEW_BLEND_COLOR 0x8000
54 #define FO_NEW_STENCIL_REF 0x10000
55 #define FO_NEW_CLEAR_COLOR 0x20000
56 #define FO_NEW_VERTEX_BUFFER 0x40000
57 #define FO_NEW_VERTEX_ELEMENT 0x80000
58
59
60
61 #define FO_HW 0
62 #define FO_SW 1
63
64 struct fo_state {
65 void *sw_state;
66 void *hw_state;
67 };
68 struct failover_context {
69 struct pipe_context pipe; /**< base class */
70
71
72 /* The most recent drawing state as set by the driver:
73 */
74 const struct fo_state *blend;
75 const struct fo_state *sampler[PIPE_MAX_SAMPLERS];
76 const struct fo_state *vertex_samplers[PIPE_MAX_VERTEX_SAMPLERS];
77 const struct fo_state *depth_stencil;
78 const struct fo_state *rasterizer;
79 const struct fo_state *fragment_shader;
80 const struct fo_state *vertex_shader;
81 const struct fo_state *vertex_elements;
82
83 struct pipe_blend_color blend_color;
84 struct pipe_stencil_ref stencil_ref;
85 struct pipe_clip_state clip;
86 struct pipe_framebuffer_state framebuffer;
87 struct pipe_poly_stipple poly_stipple;
88 struct pipe_scissor_state scissor;
89 struct pipe_texture *texture[PIPE_MAX_SAMPLERS];
90 struct pipe_texture *vertex_textures[PIPE_MAX_VERTEX_SAMPLERS];
91 struct pipe_viewport_state viewport;
92 struct pipe_vertex_buffer vertex_buffers[PIPE_MAX_ATTRIBS];
93
94 uint num_vertex_buffers;
95
96 void *sw_sampler_state[PIPE_MAX_SAMPLERS];
97 void *hw_sampler_state[PIPE_MAX_SAMPLERS];
98 void *sw_vertex_sampler_state[PIPE_MAX_VERTEX_SAMPLERS];
99 void *hw_vertex_sampler_state[PIPE_MAX_VERTEX_SAMPLERS];
100
101 unsigned dirty;
102
103 unsigned num_samplers;
104 unsigned num_vertex_samplers;
105 unsigned num_textures;
106 unsigned num_vertex_textures;
107
108 unsigned mode;
109 struct pipe_context *hw;
110 struct pipe_context *sw;
111 };
112
113
114
115 void failover_init_state_functions( struct failover_context *failover );
116 void failover_state_emit( struct failover_context *failover );
117
118 static INLINE struct failover_context *
119 failover_context( struct pipe_context *pipe )
120 {
121 return (struct failover_context *)pipe;
122 }
123
124 /* Internal functions
125 */
126 void
127 failover_set_constant_buffer(struct pipe_context *pipe,
128 uint shader, uint index,
129 struct pipe_buffer *buf);
130
131
132 #endif /* FO_CONTEXT_H */