1f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/*
2f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Copyright (C) 2009 Francisco Jerez.
3f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * All Rights Reserved.
4f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
5f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Permission is hereby granted, free of charge, to any person obtaining
6f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * a copy of this software and associated documentation files (the
7f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * "Software"), to deal in the Software without restriction, including
8f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * without limitation the rights to use, copy, modify, merge, publish,
9f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * distribute, sublicense, and/or sell copies of the Software, and to
10f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * permit persons to whom the Software is furnished to do so, subject to
11f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the following conditions:
12f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
13f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The above copyright notice and this permission notice (including the
14f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * next paragraph) shall be included in all copies or substantial
15f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * portions of the Software.
16f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
17f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
21f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
25f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */
26f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
27f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "nouveau_driver.h"
28f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "nouveau_context.h"
29f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "nouveau_texture.h"
30f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "nouveau_util.h"
31f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
32f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "swrast/swrast.h"
33f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "tnl/tnl.h"
34f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
35f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
36f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_alpha_func(struct gl_context *ctx, GLenum func, GLfloat ref)
37f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
38f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, ALPHA_FUNC);
39f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
40f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
41f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
42f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_blend_color(struct gl_context *ctx, const GLfloat color[4])
43f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
44f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, BLEND_COLOR);
45f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
46f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
47f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
48f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_blend_equation_separate(struct gl_context *ctx, GLenum modeRGB, GLenum modeA)
49f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
50f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, BLEND_EQUATION);
51f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
52f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
53f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
54f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_blend_func_separate(struct gl_context *ctx, GLenum sfactorRGB,
55f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			    GLenum dfactorRGB, GLenum sfactorA, GLenum dfactorA)
56f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
57f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, BLEND_FUNC);
58f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
59f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
60f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
61f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_clip_plane(struct gl_context *ctx, GLenum plane, const GLfloat *equation)
62f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
63f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty_i(ctx, CLIP_PLANE, plane - GL_CLIP_PLANE0);
64f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
65f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
66f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
67f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_color_mask(struct gl_context *ctx, GLboolean rmask, GLboolean gmask,
68f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		   GLboolean bmask, GLboolean amask)
69f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
70f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, COLOR_MASK);
71f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
72f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
73f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
74f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_color_material(struct gl_context *ctx, GLenum face, GLenum mode)
75f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
76f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, COLOR_MATERIAL);
77f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, MATERIAL_FRONT_AMBIENT);
78f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, MATERIAL_BACK_AMBIENT);
79f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, MATERIAL_FRONT_DIFFUSE);
80f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, MATERIAL_BACK_DIFFUSE);
81f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, MATERIAL_FRONT_SPECULAR);
82f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, MATERIAL_BACK_SPECULAR);
83f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
84f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
85f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
86f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_cull_face(struct gl_context *ctx, GLenum mode)
87f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
88f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, CULL_FACE);
89f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
90f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
91f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
92f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_front_face(struct gl_context *ctx, GLenum mode)
93f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
94f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, FRONT_FACE);
95f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
96f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
97f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
98f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_depth_func(struct gl_context *ctx, GLenum func)
99f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
100f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, DEPTH);
101f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
102f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
103f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
104f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_depth_mask(struct gl_context *ctx, GLboolean flag)
105f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
106f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, DEPTH);
107f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
108f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
109f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
110f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_depth_range(struct gl_context *ctx, GLclampd nearval, GLclampd farval)
111f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
112f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, VIEWPORT);
113f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
114f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
115f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
116f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_read_buffer(struct gl_context *ctx, GLenum buffer)
117f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
118f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	nouveau_validate_framebuffer(ctx);
119f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
120f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
121f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
122f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_draw_buffers(struct gl_context *ctx, GLsizei n, const GLenum *buffers)
123f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
124f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	nouveau_validate_framebuffer(ctx);
125f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, FRAMEBUFFER);
126f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
127f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
128f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
129f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
130f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
131f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	int i;
132f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
133f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	switch (cap) {
134f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_ALPHA_TEST:
135f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, ALPHA_FUNC);
136f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		break;
137f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_BLEND:
138f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, BLEND_EQUATION);
139f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		break;
140f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_COLOR_LOGIC_OP:
141f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, LOGIC_OPCODE);
142f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		break;
143f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_COLOR_MATERIAL:
144f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, COLOR_MATERIAL);
145f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_FRONT_AMBIENT);
146f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_BACK_AMBIENT);
147f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_FRONT_DIFFUSE);
148f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_BACK_DIFFUSE);
149f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_FRONT_SPECULAR);
150f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_BACK_SPECULAR);
151f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		break;
152f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_COLOR_SUM_EXT:
153f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, FRAG);
154f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, LIGHT_MODEL);
155f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		break;
156f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_CULL_FACE:
157f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, CULL_FACE);
158f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		break;
159f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_DEPTH_TEST:
160f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, DEPTH);
161f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		break;
162f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_DITHER:
163f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, DITHER);
164f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		break;
165f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_FOG:
166f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, FOG);
167f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, FRAG);
168f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MODELVIEW);
169f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		break;
170f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_LIGHT0:
171f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_LIGHT1:
172f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_LIGHT2:
173f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_LIGHT3:
174f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_LIGHT4:
175f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_LIGHT5:
176f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_LIGHT6:
177f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_LIGHT7:
178f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MODELVIEW);
179f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, LIGHT_ENABLE);
180f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty_i(ctx, LIGHT_SOURCE, cap - GL_LIGHT0);
181f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_FRONT_AMBIENT);
182f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_BACK_AMBIENT);
183f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_FRONT_DIFFUSE);
184f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_BACK_DIFFUSE);
185f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_FRONT_SPECULAR);
186f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_BACK_SPECULAR);
187f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_FRONT_SHININESS);
188f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_BACK_SHININESS);
189f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		break;
190f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_LIGHTING:
191f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, FRAG);
192f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MODELVIEW);
193f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, LIGHT_MODEL);
194f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, LIGHT_ENABLE);
195f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
196f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		for (i = 0; i < MAX_LIGHTS; i++) {
197f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			if (ctx->Light.Light[i].Enabled)
198f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org				context_dirty_i(ctx, LIGHT_SOURCE, i);
199f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		}
200f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
201f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_FRONT_AMBIENT);
202f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_BACK_AMBIENT);
203f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_FRONT_DIFFUSE);
204f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_BACK_DIFFUSE);
205f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_FRONT_SPECULAR);
206f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_BACK_SPECULAR);
207f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_FRONT_SHININESS);
208f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_BACK_SHININESS);
209f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		break;
210f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_LINE_SMOOTH:
211f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, LINE_MODE);
212f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		break;
213f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_NORMALIZE:
214f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, LIGHT_ENABLE);
215f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		break;
216f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_POINT_SMOOTH:
217f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, POINT_MODE);
218f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		break;
219f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_POLYGON_OFFSET_POINT:
220f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_POLYGON_OFFSET_LINE:
221f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_POLYGON_OFFSET_FILL:
222f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, POLYGON_OFFSET);
223f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		break;
224f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_POLYGON_SMOOTH:
225f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, POLYGON_MODE);
226f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		break;
227f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_SCISSOR_TEST:
228f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, SCISSOR);
229f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		break;
230f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_STENCIL_TEST:
231f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, STENCIL_FUNC);
232f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		break;
233f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_TEXTURE_1D:
234f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_TEXTURE_2D:
235f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_TEXTURE_3D:
236f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_TEXTURE_RECTANGLE:
237f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty_i(ctx, TEX_ENV, ctx->Texture.CurrentUnit);
238f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty_i(ctx, TEX_OBJ, ctx->Texture.CurrentUnit);
239f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		break;
240f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_TEXTURE_GEN_S:
241f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_TEXTURE_GEN_T:
242f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_TEXTURE_GEN_R:
243f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_TEXTURE_GEN_Q:
244f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty_i(ctx, TEX_GEN, ctx->Texture.CurrentUnit);
245f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MODELVIEW);
246f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		break;
247f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	}
248f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
249f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
250f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
251f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_fog(struct gl_context *ctx, GLenum pname, const GLfloat *params)
252f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
253f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, FOG);
254f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
255f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
256f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
257f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_light(struct gl_context *ctx, GLenum light, GLenum pname, const GLfloat *params)
258f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
259f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	switch (pname) {
260f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_AMBIENT:
261f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_FRONT_AMBIENT);
262f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_BACK_AMBIENT);
263f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		break;
264f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_DIFFUSE:
265f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_FRONT_DIFFUSE);
266f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_BACK_DIFFUSE);
267f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		break;
268f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_SPECULAR:
269f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_FRONT_SPECULAR);
270f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_BACK_SPECULAR);
271f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		break;
272f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_SPOT_CUTOFF:
273f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_POSITION:
274f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MODELVIEW);
275f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, LIGHT_ENABLE);
276f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty_i(ctx, LIGHT_SOURCE, light - GL_LIGHT0);
277f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		break;
278f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	default:
279f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty_i(ctx, LIGHT_SOURCE, light - GL_LIGHT0);
280f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		break;
281f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	}
282f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
283f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
284f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
285f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_light_model(struct gl_context *ctx, GLenum pname, const GLfloat *params)
286f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
287f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, LIGHT_MODEL);
288f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, MODELVIEW);
289f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
290f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
291f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
292f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_line_stipple(struct gl_context *ctx, GLint factor, GLushort pattern )
293f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
294f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, LINE_STIPPLE);
295f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
296f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
297f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
298f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_line_width(struct gl_context *ctx, GLfloat width)
299f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
300f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, LINE_MODE);
301f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
302f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
303f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
304f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_logic_opcode(struct gl_context *ctx, GLenum opcode)
305f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
306f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, LOGIC_OPCODE);
307f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
308f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
309f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
310f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_point_parameter(struct gl_context *ctx, GLenum pname, const GLfloat *params)
311f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
312f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, POINT_PARAMETER);
313f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
314f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
315f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
316f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_point_size(struct gl_context *ctx, GLfloat size)
317f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
318f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, POINT_MODE);
319f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
320f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
321f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
322f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_polygon_mode(struct gl_context *ctx, GLenum face, GLenum mode)
323f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
324f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, POLYGON_MODE);
325f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
326f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
327f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
328f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_polygon_offset(struct gl_context *ctx, GLfloat factor, GLfloat units)
329f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
330f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, POLYGON_OFFSET);
331f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
332f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
333f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
334f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_polygon_stipple(struct gl_context *ctx, const GLubyte *mask)
335f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
336f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, POLYGON_STIPPLE);
337f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
338f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
339f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
340f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_render_mode(struct gl_context *ctx, GLenum mode)
341f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
342f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, RENDER_MODE);
343f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
344f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
345f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
346f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_scissor(struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
347f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
348f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, SCISSOR);
349f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
350f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
351f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
352f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_shade_model(struct gl_context *ctx, GLenum mode)
353f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
354f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, SHADE_MODEL);
355f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
356f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
357f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
358f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_stencil_func_separate(struct gl_context *ctx, GLenum face, GLenum func,
359f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			      GLint ref, GLuint mask)
360f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
361f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, STENCIL_FUNC);
362f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
363f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
364f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
365f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_stencil_mask_separate(struct gl_context *ctx, GLenum face, GLuint mask)
366f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
367f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, STENCIL_MASK);
368f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
369f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
370f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
371f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_stencil_op_separate(struct gl_context *ctx, GLenum face, GLenum fail,
372f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			    GLenum zfail, GLenum zpass)
373f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
374f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, STENCIL_OP);
375f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
376f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
377f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
378f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_tex_gen(struct gl_context *ctx, GLenum coord, GLenum pname,
379f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		const GLfloat *params)
380f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
381f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	switch (pname) {
382f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_TEXTURE_GEN_MODE:
383f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty_i(ctx, TEX_GEN, ctx->Texture.CurrentUnit);
384f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MODELVIEW);
385f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		break;
386f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	default:
387f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty_i(ctx, TEX_GEN, ctx->Texture.CurrentUnit);
388f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		break;
389f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	}
390f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
391f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
392f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
393f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_tex_env(struct gl_context *ctx, GLenum target, GLenum pname,
394f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		const GLfloat *param)
395f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
396f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	switch (target) {
397f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_TEXTURE_FILTER_CONTROL_EXT:
398f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty_i(ctx, TEX_OBJ, ctx->Texture.CurrentUnit);
399f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		break;
400f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	default:
401f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty_i(ctx, TEX_ENV, ctx->Texture.CurrentUnit);
402f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		break;
403f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	}
404f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
405f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
406f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
407f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_tex_parameter(struct gl_context *ctx, GLenum target,
408f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		      struct gl_texture_object *t, GLenum pname,
409f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		      const GLfloat *params)
410f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
411f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	switch (pname) {
412f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_TEXTURE_MAG_FILTER:
413f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_TEXTURE_WRAP_S:
414f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_TEXTURE_WRAP_T:
415f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_TEXTURE_WRAP_R:
416f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_TEXTURE_MIN_LOD:
417f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_TEXTURE_MAX_LOD:
418f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_TEXTURE_MAX_ANISOTROPY_EXT:
419f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_TEXTURE_LOD_BIAS:
420f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty_i(ctx, TEX_OBJ, ctx->Texture.CurrentUnit);
421f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		break;
422f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
423f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_TEXTURE_MIN_FILTER:
424f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_TEXTURE_BASE_LEVEL:
425f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	case GL_TEXTURE_MAX_LEVEL:
426f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		nouveau_texture_reallocate(ctx, t);
427f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty_i(ctx, TEX_OBJ, ctx->Texture.CurrentUnit);
428f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		break;
429f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	}
430f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
431f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
432f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
433f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_viewport(struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
434f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
435f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	context_dirty(ctx, VIEWPORT);
436f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
437f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
438f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid
439f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_emit_nothing(struct gl_context *ctx, int emit)
440f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
441f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
442f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
443f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgint
444f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_next_dirty_state(struct gl_context *ctx)
445f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
446f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct nouveau_context *nctx = to_nouveau_context(ctx);
447f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	int i = BITSET_FFS(nctx->dirty) - 1;
448f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
449f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	if (i < 0 || i >= context_drv(ctx)->num_emit)
450f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		return -1;
451f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
452f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	return i;
453f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
454f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
455f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid
456f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_state_emit(struct gl_context *ctx)
457f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
458f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct nouveau_context *nctx = to_nouveau_context(ctx);
459f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	const struct nouveau_driver *drv = context_drv(ctx);
460f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	int i;
461f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
462f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	while ((i = nouveau_next_dirty_state(ctx)) >= 0) {
463f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		BITSET_CLEAR(nctx->dirty, i);
464f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		drv->emit[i](ctx, i);
465f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	}
466f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
467f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	BITSET_ZERO(nctx->dirty);
468f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
469f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
470f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void
471f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_update_state(struct gl_context *ctx, GLbitfield new_state)
472f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
473f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	int i;
474f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
475f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	if (new_state & (_NEW_PROJECTION | _NEW_MODELVIEW))
476f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, PROJECTION);
477f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
478f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	if (new_state & _NEW_MODELVIEW)
479f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MODELVIEW);
480f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
481f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	if (new_state & _NEW_TEXTURE_MATRIX) {
482f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++)
483f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			context_dirty_i(ctx, TEX_MAT, i);
484f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	}
485f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
486f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	if (new_state & _NEW_CURRENT_ATTRIB &&
487f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	    new_state & _NEW_LIGHT) {
488f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_FRONT_AMBIENT);
489f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_BACK_AMBIENT);
490f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_FRONT_DIFFUSE);
491f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_BACK_DIFFUSE);
492f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_FRONT_SPECULAR);
493f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_BACK_SPECULAR);
494f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_FRONT_SHININESS);
495f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		context_dirty(ctx, MATERIAL_BACK_SHININESS);
496f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	}
497f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
498f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	if (new_state & _NEW_TEXTURE) {
499f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
500f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			if (ctx->Texture.Unit[i].Sampler)
501f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org				context_dirty_i(ctx, TEX_OBJ, i);
502f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org		}
503f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	}
504f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
505f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	_swrast_InvalidateState(ctx, new_state);
506f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	_tnl_InvalidateState(ctx, new_state);
507f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
508f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	nouveau_state_emit(ctx);
509f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
510f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
511f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid
512f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_state_init(struct gl_context *ctx)
513f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
514f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct nouveau_context *nctx = to_nouveau_context(ctx);
515f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
516f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.AlphaFunc = nouveau_alpha_func;
517f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.BlendColor = nouveau_blend_color;
518f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.BlendEquationSeparate = nouveau_blend_equation_separate;
519f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.BlendFuncSeparate = nouveau_blend_func_separate;
520f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.ClipPlane = nouveau_clip_plane;
521f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.ColorMask = nouveau_color_mask;
522f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.ColorMaterial = nouveau_color_material;
523f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.CullFace = nouveau_cull_face;
524f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.FrontFace = nouveau_front_face;
525f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.DepthFunc = nouveau_depth_func;
526f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.DepthMask = nouveau_depth_mask;
527f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.DepthRange = nouveau_depth_range;
528f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.ReadBuffer = nouveau_read_buffer;
529f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.DrawBuffers = nouveau_draw_buffers;
530f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.Enable = nouveau_enable;
531f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.Fogfv = nouveau_fog;
532f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.Lightfv = nouveau_light;
533f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.LightModelfv = nouveau_light_model;
534f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.LineStipple = nouveau_line_stipple;
535f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.LineWidth = nouveau_line_width;
536f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.LogicOpcode = nouveau_logic_opcode;
537f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.PointParameterfv = nouveau_point_parameter;
538f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.PointSize = nouveau_point_size;
539f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.PolygonMode = nouveau_polygon_mode;
540f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.PolygonOffset = nouveau_polygon_offset;
541f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.PolygonStipple = nouveau_polygon_stipple;
542f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.RenderMode = nouveau_render_mode;
543f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.Scissor = nouveau_scissor;
544f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.ShadeModel = nouveau_shade_model;
545f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.StencilFuncSeparate = nouveau_stencil_func_separate;
546f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.StencilMaskSeparate = nouveau_stencil_mask_separate;
547f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.StencilOpSeparate = nouveau_stencil_op_separate;
548f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.TexGen = nouveau_tex_gen;
549f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.TexEnv = nouveau_tex_env;
550f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.TexParameter = nouveau_tex_parameter;
551f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.Viewport = nouveau_viewport;
552f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
553f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	ctx->Driver.UpdateState = nouveau_update_state;
554f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
555f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	BITSET_ONES(nctx->dirty);
556f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
557