Merge branch 'softpipe_0_1_branch' of git+ssh://brianp@git.freedesktop.org/git/mesa...
[mesa.git] / src / mesa / state_tracker / st_draw.c
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 /*
29 * Authors:
30 * Keith Whitwell <keith@tungstengraphics.com>
31 */
32
33 #include "imports.h"
34
35 #include "tnl/t_context.h"
36 #include "tnl/t_pipeline.h"
37
38 #include "st_context.h"
39 #include "st_atom.h"
40 #include "st_draw.h"
41 #include "pipe/p_context.h"
42
43 /*
44 * TNL stage which feeds into the above.
45 *
46 * XXX: this needs to go into each driver using this code, because we
47 * cannot make the leap from ctx->draw_context in this file. The
48 * driver needs to customize tnl anyway, so this isn't a big deal.
49 */
50 static GLboolean draw( GLcontext * ctx, struct tnl_pipeline_stage *stage )
51 {
52 struct st_context *st = st_context(ctx);
53 struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
54
55 /* Validate driver and pipe state:
56 */
57 st_validate_state( st );
58
59 /* Call into the new draw code to handle the VB:
60 */
61 st->pipe->draw_vb( st->pipe, VB );
62
63 /* Finished
64 */
65 return GL_FALSE;
66 }
67
68 const struct tnl_pipeline_stage st_draw = {
69 "check state and draw",
70 NULL,
71 NULL,
72 NULL,
73 NULL,
74 draw
75 };
76
77 static const struct tnl_pipeline_stage *st_pipeline[] = {
78 &_tnl_vertex_transform_stage,
79 &_tnl_vertex_cull_stage,
80 &_tnl_normal_transform_stage,
81 &_tnl_lighting_stage,
82 &_tnl_fog_coordinate_stage,
83 &_tnl_texgen_stage,
84 &_tnl_texture_transform_stage,
85 &_tnl_point_attenuation_stage,
86 &_tnl_vertex_program_stage,
87 &st_draw, /* ADD: escape to pipe */
88 0,
89 };
90
91 /* This is all a hack to keep using tnl until we have vertex programs
92 * up and running.
93 */
94 void st_init_draw( struct st_context *st )
95 {
96 GLcontext *ctx = st->ctx;
97
98 _tnl_destroy_pipeline( ctx );
99 _tnl_install_pipeline( ctx, st_pipeline );
100 }
101
102
103 void st_destroy_draw( struct st_context *st )
104 {
105 /* Nothing to do.
106 */
107 }
108
109