i965: Fix typos in license
[mesa.git] / src / mesa / drivers / dri / i965 / intel_state.c
1 /*
2 * Copyright 2003 VMware, Inc.
3 * All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * 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:
12 *
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial portions
15 * of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
21 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26 #include "main/glheader.h"
27 #include "main/context.h"
28 #include "main/macros.h"
29 #include "main/enums.h"
30 #include "main/colormac.h"
31 #include "main/dd.h"
32
33 #include "intel_screen.h"
34 #include "brw_context.h"
35 #include "brw_defines.h"
36
37 int
38 intel_translate_shadow_compare_func(GLenum func)
39 {
40 /* GL specifies the result of shadow comparisons as:
41 * 1 if ref <op> texel,
42 * 0 otherwise.
43 *
44 * The hardware does:
45 * 0 if texel <op> ref,
46 * 1 otherwise.
47 *
48 * So, these look a bit strange because there's both a negation
49 * and swapping of the arguments involved.
50 */
51 switch (func) {
52 case GL_NEVER:
53 return BRW_COMPAREFUNCTION_ALWAYS;
54 case GL_LESS:
55 return BRW_COMPAREFUNCTION_LEQUAL;
56 case GL_LEQUAL:
57 return BRW_COMPAREFUNCTION_LESS;
58 case GL_GREATER:
59 return BRW_COMPAREFUNCTION_GEQUAL;
60 case GL_GEQUAL:
61 return BRW_COMPAREFUNCTION_GREATER;
62 case GL_NOTEQUAL:
63 return BRW_COMPAREFUNCTION_EQUAL;
64 case GL_EQUAL:
65 return BRW_COMPAREFUNCTION_NOTEQUAL;
66 case GL_ALWAYS:
67 return BRW_COMPAREFUNCTION_NEVER;
68 }
69
70 unreachable("Invalid shadow comparison function.");
71 }
72
73 int
74 intel_translate_compare_func(GLenum func)
75 {
76 switch (func) {
77 case GL_NEVER:
78 return BRW_COMPAREFUNCTION_NEVER;
79 case GL_LESS:
80 return BRW_COMPAREFUNCTION_LESS;
81 case GL_LEQUAL:
82 return BRW_COMPAREFUNCTION_LEQUAL;
83 case GL_GREATER:
84 return BRW_COMPAREFUNCTION_GREATER;
85 case GL_GEQUAL:
86 return BRW_COMPAREFUNCTION_GEQUAL;
87 case GL_NOTEQUAL:
88 return BRW_COMPAREFUNCTION_NOTEQUAL;
89 case GL_EQUAL:
90 return BRW_COMPAREFUNCTION_EQUAL;
91 case GL_ALWAYS:
92 return BRW_COMPAREFUNCTION_ALWAYS;
93 }
94
95 unreachable("Invalid comparison function.");
96 }
97
98 int
99 intel_translate_stencil_op(GLenum op)
100 {
101 switch (op) {
102 case GL_KEEP:
103 return BRW_STENCILOP_KEEP;
104 case GL_ZERO:
105 return BRW_STENCILOP_ZERO;
106 case GL_REPLACE:
107 return BRW_STENCILOP_REPLACE;
108 case GL_INCR:
109 return BRW_STENCILOP_INCRSAT;
110 case GL_DECR:
111 return BRW_STENCILOP_DECRSAT;
112 case GL_INCR_WRAP:
113 return BRW_STENCILOP_INCR;
114 case GL_DECR_WRAP:
115 return BRW_STENCILOP_DECR;
116 case GL_INVERT:
117 return BRW_STENCILOP_INVERT;
118 default:
119 return BRW_STENCILOP_ZERO;
120 }
121 }
122
123 int
124 intel_translate_logic_op(GLenum opcode)
125 {
126 switch (opcode) {
127 case GL_CLEAR:
128 return BRW_LOGICOPFUNCTION_CLEAR;
129 case GL_AND:
130 return BRW_LOGICOPFUNCTION_AND;
131 case GL_AND_REVERSE:
132 return BRW_LOGICOPFUNCTION_AND_REVERSE;
133 case GL_COPY:
134 return BRW_LOGICOPFUNCTION_COPY;
135 case GL_COPY_INVERTED:
136 return BRW_LOGICOPFUNCTION_COPY_INVERTED;
137 case GL_AND_INVERTED:
138 return BRW_LOGICOPFUNCTION_AND_INVERTED;
139 case GL_NOOP:
140 return BRW_LOGICOPFUNCTION_NOOP;
141 case GL_XOR:
142 return BRW_LOGICOPFUNCTION_XOR;
143 case GL_OR:
144 return BRW_LOGICOPFUNCTION_OR;
145 case GL_OR_INVERTED:
146 return BRW_LOGICOPFUNCTION_OR_INVERTED;
147 case GL_NOR:
148 return BRW_LOGICOPFUNCTION_NOR;
149 case GL_EQUIV:
150 return BRW_LOGICOPFUNCTION_EQUIV;
151 case GL_INVERT:
152 return BRW_LOGICOPFUNCTION_INVERT;
153 case GL_OR_REVERSE:
154 return BRW_LOGICOPFUNCTION_OR_REVERSE;
155 case GL_NAND:
156 return BRW_LOGICOPFUNCTION_NAND;
157 case GL_SET:
158 return BRW_LOGICOPFUNCTION_SET;
159 default:
160 return BRW_LOGICOPFUNCTION_SET;
161 }
162 }