f5c92a1b4e6c9cfa692e7ffdcdc02f757bf72a30
[mesa.git] / src / mesa / drivers / dri / nouveau / nouveau_swtcl.c
1 /**************************************************************************
2
3 Copyright 2006 Stephane Marchesin
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 "Software"),
8 to deal in the Software without restriction, including without limitation
9 on the rights to use, copy, modify, merge, publish, distribute, sub
10 license, and/or sell copies of the Software, and to permit persons to whom
11 the Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice (including the next
14 paragraph) shall be included in all copies or substantial portions of the
15 Software.
16
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
20 ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP BE LIABLE FOR ANY CLAIM,
21 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
23 USE OR OTHER DEALINGS IN THE SOFTWARE.
24
25 **************************************************************************/
26
27 /* Common software TCL code */
28
29 #include "nouveau_context.h"
30 #include "nouveau_swtcl.h"
31 #include "nv10_swtcl.h"
32 #include "nouveau_span.h"
33 #include "swrast/swrast.h"
34 #include "swrast_setup/swrast_setup.h"
35 #include "tnl/tnl.h"
36 #include "tnl/t_pipeline.h"
37
38 /* Common tri functions */
39
40 /* The fallbacks */
41 void nouveau_fallback_tri(struct nouveau_context *nmesa,
42 nouveauVertex *v0,
43 nouveauVertex *v1,
44 nouveauVertex *v2)
45 {
46 GLcontext *ctx = nmesa->glCtx;
47 SWvertex v[3];
48 _swsetup_Translate(ctx, v0, &v[0]);
49 _swsetup_Translate(ctx, v1, &v[1]);
50 _swsetup_Translate(ctx, v2, &v[2]);
51 _swrast_Triangle(ctx, &v[0], &v[1], &v[2]);
52 }
53
54
55 void nouveau_fallback_line(struct nouveau_context *nmesa,
56 nouveauVertex *v0,
57 nouveauVertex *v1)
58 {
59 GLcontext *ctx = nmesa->glCtx;
60 SWvertex v[2];
61 _swsetup_Translate(ctx, v0, &v[0]);
62 _swsetup_Translate(ctx, v1, &v[1]);
63 _swrast_Line(ctx, &v[0], &v[1]);
64 }
65
66
67 void nouveau_fallback_point(struct nouveau_context *nmesa,
68 nouveauVertex *v0)
69 {
70 GLcontext *ctx = nmesa->glCtx;
71 SWvertex v[1];
72 _swsetup_Translate(ctx, v0, &v[0]);
73 _swrast_Point(ctx, &v[0]);
74 }
75
76 void nouveauFallback(struct nouveau_context *nmesa, GLuint bit, GLboolean mode)
77 {
78 GLcontext *ctx = nmesa->glCtx;
79 GLuint oldfallback = nmesa->Fallback;
80
81 if (mode) {
82 nmesa->Fallback |= bit;
83 if (oldfallback == 0) {
84 if (nmesa->screen->card->type<NV_10) {
85 //nv04FinishPrimitive(nmesa);
86 } else {
87 nv10FinishPrimitive(nmesa);
88 }
89
90 _swsetup_Wakeup(ctx);
91 nmesa->render_index = ~0;
92 }
93 }
94 else {
95 nmesa->Fallback &= ~bit;
96 if (oldfallback == bit) {
97 _swrast_flush( ctx );
98
99 if (nmesa->screen->card->type<NV_10) {
100 //nv04TriInitFunctions(ctx);
101 } else {
102 nv10TriInitFunctions(ctx);
103 }
104
105 _tnl_invalidate_vertex_state( ctx, ~0 );
106 _tnl_invalidate_vertices( ctx, ~0 );
107 _tnl_install_attrs( ctx,
108 nmesa->vertex_attrs,
109 nmesa->vertex_attr_count,
110 nmesa->viewport.m, 0 );
111 }
112 }
113 }
114
115
116 void nouveauRunPipeline( GLcontext *ctx )
117 {
118 struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
119
120 if (nmesa->new_state) {
121 nmesa->new_render_state |= nmesa->new_state;
122 }
123
124 _tnl_run_pipeline( ctx );
125 }
126
127