2 * Copyright (C) 2009 Francisco Jerez.
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial
15 * portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
21 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 #include "nouveau_driver.h"
28 #include "nouveau_context.h"
29 #include "nouveau_gldefs.h"
30 #include "nouveau_class.h"
31 #include "nv10_driver.h"
34 nv10_emit_alpha_func(GLcontext
*ctx
, int emit
)
36 struct nouveau_channel
*chan
= context_chan(ctx
);
37 struct nouveau_grobj
*celsius
= context_eng3d(ctx
);
39 BEGIN_RING(chan
, celsius
, NV10TCL_ALPHA_FUNC_ENABLE
, 1);
40 OUT_RING(chan
, ctx
->Color
.AlphaEnabled
? 1 : 0);
42 BEGIN_RING(chan
, celsius
, NV10TCL_ALPHA_FUNC_FUNC
, 2);
43 OUT_RING(chan
, nvgl_comparison_op(ctx
->Color
.AlphaFunc
));
44 OUT_RING(chan
, FLOAT_TO_UBYTE(ctx
->Color
.AlphaRef
));
48 nv10_emit_blend_color(GLcontext
*ctx
, int emit
)
50 struct nouveau_channel
*chan
= context_chan(ctx
);
51 struct nouveau_grobj
*celsius
= context_eng3d(ctx
);
53 BEGIN_RING(chan
, celsius
, NV10TCL_BLEND_COLOR
, 1);
54 OUT_RING(chan
, FLOAT_TO_UBYTE(ctx
->Color
.BlendColor
[3]) << 24 |
55 FLOAT_TO_UBYTE(ctx
->Color
.BlendColor
[0]) << 16 |
56 FLOAT_TO_UBYTE(ctx
->Color
.BlendColor
[1]) << 8 |
57 FLOAT_TO_UBYTE(ctx
->Color
.BlendColor
[2]) << 0);
61 nv10_emit_blend_equation(GLcontext
*ctx
, int emit
)
63 struct nouveau_channel
*chan
= context_chan(ctx
);
64 struct nouveau_grobj
*celsius
= context_eng3d(ctx
);
66 BEGIN_RING(chan
, celsius
, NV10TCL_BLEND_FUNC_ENABLE
, 1);
67 OUT_RING(chan
, ctx
->Color
.BlendEnabled
? 1 : 0);
69 BEGIN_RING(chan
, celsius
, NV10TCL_BLEND_EQUATION
, 1);
70 OUT_RING(chan
, nvgl_blend_eqn(ctx
->Color
.BlendEquationRGB
));
74 nv10_emit_blend_func(GLcontext
*ctx
, int emit
)
76 struct nouveau_channel
*chan
= context_chan(ctx
);
77 struct nouveau_grobj
*celsius
= context_eng3d(ctx
);
79 BEGIN_RING(chan
, celsius
, NV10TCL_BLEND_FUNC_SRC
, 2);
80 OUT_RING(chan
, nvgl_blend_func(ctx
->Color
.BlendSrcRGB
));
81 OUT_RING(chan
, nvgl_blend_func(ctx
->Color
.BlendDstRGB
));
85 nv10_emit_color_mask(GLcontext
*ctx
, int emit
)
87 struct nouveau_channel
*chan
= context_chan(ctx
);
88 struct nouveau_grobj
*celsius
= context_eng3d(ctx
);
90 BEGIN_RING(chan
, celsius
, NV10TCL_COLOR_MASK
, 1);
91 OUT_RING(chan
, ((ctx
->Color
.ColorMask
[0][3] ? 1 << 24 : 0) |
92 (ctx
->Color
.ColorMask
[0][0] ? 1 << 16 : 0) |
93 (ctx
->Color
.ColorMask
[0][1] ? 1 << 8 : 0) |
94 (ctx
->Color
.ColorMask
[0][2] ? 1 << 0 : 0)));
98 nv10_emit_depth(GLcontext
*ctx
, int emit
)
100 struct nouveau_channel
*chan
= context_chan(ctx
);
101 struct nouveau_grobj
*celsius
= context_eng3d(ctx
);
103 BEGIN_RING(chan
, celsius
, NV10TCL_DEPTH_TEST_ENABLE
, 1);
104 OUT_RING(chan
, ctx
->Depth
.Test
? 1 : 0);
105 BEGIN_RING(chan
, celsius
, NV10TCL_DEPTH_WRITE_ENABLE
, 1);
106 OUT_RING(chan
, ctx
->Depth
.Mask
? 1 : 0);
107 BEGIN_RING(chan
, celsius
, NV10TCL_DEPTH_FUNC
, 1);
108 OUT_RING(chan
, nvgl_comparison_op(ctx
->Depth
.Func
));
112 nv10_emit_dither(GLcontext
*ctx
, int emit
)
114 struct nouveau_channel
*chan
= context_chan(ctx
);
115 struct nouveau_grobj
*celsius
= context_eng3d(ctx
);
117 BEGIN_RING(chan
, celsius
, NV10TCL_DITHER_ENABLE
, 1);
118 OUT_RING(chan
, ctx
->Color
.DitherFlag
? 1 : 0);
122 nv10_emit_logic_opcode(GLcontext
*ctx
, int emit
)
124 struct nouveau_channel
*chan
= context_chan(ctx
);
125 struct nouveau_grobj
*celsius
= context_eng3d(ctx
);
127 assert(!ctx
->Color
.ColorLogicOpEnabled
128 || context_chipset(ctx
) >= 0x11);
130 BEGIN_RING(chan
, celsius
, NV11TCL_COLOR_LOGIC_OP_ENABLE
, 2);
131 OUT_RING(chan
, ctx
->Color
.ColorLogicOpEnabled
? 1 : 0);
132 OUT_RING(chan
, nvgl_logicop_func(ctx
->Color
.LogicOp
));
136 nv10_emit_shade_model(GLcontext
*ctx
, int emit
)
138 struct nouveau_channel
*chan
= context_chan(ctx
);
139 struct nouveau_grobj
*celsius
= context_eng3d(ctx
);
141 BEGIN_RING(chan
, celsius
, NV10TCL_SHADE_MODEL
, 1);
142 OUT_RING(chan
, ctx
->Light
.ShadeModel
== GL_SMOOTH
?
143 NV10TCL_SHADE_MODEL_SMOOTH
: NV10TCL_SHADE_MODEL_FLAT
);
147 nv10_emit_stencil_func(GLcontext
*ctx
, int emit
)
149 struct nouveau_channel
*chan
= context_chan(ctx
);
150 struct nouveau_grobj
*celsius
= context_eng3d(ctx
);
152 BEGIN_RING(chan
, celsius
, NV10TCL_STENCIL_ENABLE
, 1);
153 OUT_RING(chan
, ctx
->Stencil
.Enabled
? 1 : 0);
155 BEGIN_RING(chan
, celsius
, NV10TCL_STENCIL_FUNC_FUNC
, 3);
156 OUT_RING(chan
, nvgl_comparison_op(ctx
->Stencil
.Function
[0]));
157 OUT_RING(chan
, ctx
->Stencil
.Ref
[0]);
158 OUT_RING(chan
, ctx
->Stencil
.ValueMask
[0]);
162 nv10_emit_stencil_mask(GLcontext
*ctx
, int emit
)
164 struct nouveau_channel
*chan
= context_chan(ctx
);
165 struct nouveau_grobj
*celsius
= context_eng3d(ctx
);
167 BEGIN_RING(chan
, celsius
, NV10TCL_STENCIL_MASK
, 1);
168 OUT_RING(chan
, ctx
->Stencil
.WriteMask
[0]);
172 nv10_emit_stencil_op(GLcontext
*ctx
, int emit
)
174 struct nouveau_channel
*chan
= context_chan(ctx
);
175 struct nouveau_grobj
*celsius
= context_eng3d(ctx
);
177 BEGIN_RING(chan
, celsius
, NV10TCL_STENCIL_OP_FAIL
, 3);
178 OUT_RING(chan
, nvgl_stencil_op(ctx
->Stencil
.FailFunc
[0]));
179 OUT_RING(chan
, nvgl_stencil_op(ctx
->Stencil
.ZFailFunc
[0]));
180 OUT_RING(chan
, nvgl_stencil_op(ctx
->Stencil
.ZPassFunc
[0]));