3a1865d7668a7d5c8405f9bc5b57cc423b5a883e
1 /**************************************************************************
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
28 /* Authors: Keith Whitwell <keith@tungstengraphics.com>
31 #include "fo_context.h"
33 /* This looks like a lot of work at the moment - we're keeping a
34 * duplicate copy of the state up-to-date.
36 * This can change in two ways:
37 * - With constant state objects we would only need to save a pointer,
38 * not the whole object.
39 * - By adding a callback in the state tracker to re-emit state. The
40 * state tracker knows the current state already and can re-emit it
41 * without additional complexity.
43 * This works as a proof-of-concept, but a final version will have
48 /* Bring the software pipe uptodate with current state.
50 * With constant state objects we would probably just send all state
51 * to both rasterizers all the time???
54 failover_state_emit( struct failover_context
*failover
)
58 if (failover
->dirty
& FO_NEW_ALPHA_TEST
)
59 failover
->sw
->set_alpha_test_state( failover
->sw
, &failover
->alpha_test
);
61 if (failover
->dirty
& FO_NEW_BLEND
)
62 failover
->sw
->bind_blend_state( failover
->sw
, failover
->blend
);
64 if (failover
->dirty
& FO_NEW_BLEND_COLOR
)
65 failover
->sw
->set_blend_color( failover
->sw
, &failover
->blend_color
);
67 if (failover
->dirty
& FO_NEW_CLIP
)
68 failover
->sw
->set_clip_state( failover
->sw
, &failover
->clip
);
70 if (failover
->dirty
& FO_NEW_CLEAR_COLOR
)
71 failover
->sw
->set_clear_color_state( failover
->sw
, &failover
->clear_color
);
73 if (failover
->dirty
& FO_NEW_DEPTH_STENCIL
)
74 failover
->sw
->bind_depth_stencil_state( failover
->sw
, failover
->depth_stencil
);
76 if (failover
->dirty
& FO_NEW_FRAMEBUFFER
)
77 failover
->sw
->set_framebuffer_state( failover
->sw
, &failover
->framebuffer
);
79 if (failover
->dirty
& FO_NEW_FRAGMENT_SHADER
)
80 failover
->sw
->set_fs_state( failover
->sw
, &failover
->fragment_shader
);
82 if (failover
->dirty
& FO_NEW_VERTEX_SHADER
)
83 failover
->sw
->set_vs_state( failover
->sw
, &failover
->vertex_shader
);
85 if (failover
->dirty
& FO_NEW_STIPPLE
)
86 failover
->sw
->set_polygon_stipple( failover
->sw
, &failover
->poly_stipple
);
88 if (failover
->dirty
& FO_NEW_SETUP
)
89 failover
->sw
->set_setup_state( failover
->sw
, &failover
->setup
);
91 if (failover
->dirty
& FO_NEW_SCISSOR
)
92 failover
->sw
->set_scissor_state( failover
->sw
, &failover
->scissor
);
94 if (failover
->dirty
& FO_NEW_VIEWPORT
)
95 failover
->sw
->set_viewport_state( failover
->sw
, &failover
->viewport
);
97 if (failover
->dirty
& FO_NEW_SAMPLER
) {
98 for (i
= 0; i
< PIPE_MAX_SAMPLERS
; i
++) {
99 if (failover
->dirty_sampler
& (1<<i
)) {
100 failover
->sw
->bind_sampler_state( failover
->sw
, i
,
101 failover
->sampler
[i
] );
106 if (failover
->dirty
& FO_NEW_TEXTURE
) {
107 for (i
= 0; i
< PIPE_MAX_SAMPLERS
; i
++) {
108 if (failover
->dirty_texture
& (1<<i
)) {
109 failover
->sw
->set_texture_state( failover
->sw
, i
,
110 failover
->texture
[i
] );
115 if (failover
->dirty
& FO_NEW_VERTEX_BUFFER
) {
116 for (i
= 0; i
< PIPE_ATTRIB_MAX
; i
++) {
117 if (failover
->dirty_vertex_buffer
& (1<<i
)) {
118 failover
->sw
->set_vertex_buffer( failover
->sw
, i
,
119 &failover
->vertex_buffer
[i
] );
124 if (failover
->dirty
& FO_NEW_VERTEX_ELEMENT
) {
125 for (i
= 0; i
< PIPE_ATTRIB_MAX
; i
++) {
126 if (failover
->dirty_vertex_element
& (1<<i
)) {
127 failover
->sw
->set_vertex_element( failover
->sw
, i
,
128 &failover
->vertex_element
[i
] );
134 failover
->dirty_vertex_element
= 0;
135 failover
->dirty_vertex_buffer
= 0;
136 failover
->dirty_texture
= 0;
137 failover
->dirty_sampler
= 0;