Remove remnants of 'intel' from active state tracker code.
[mesa.git] / src / mesa / pipe / softpipe / sp_quad_alpha_test.c
1
2 /**
3 * quad alpha test
4 */
5
6 #include "sp_context.h"
7 #include "sp_headers.h"
8 #include "sp_quad.h"
9 #include "pipe/p_defines.h"
10 #include "pipe/p_util.h"
11
12
13 static void
14 alpha_test_quad(struct quad_stage *qs, struct quad_header *quad)
15 {
16 struct softpipe_context *softpipe = qs->softpipe;
17 const float ref = softpipe->alpha_test->ref;
18 unsigned passMask = 0x0, j;
19
20 switch (softpipe->alpha_test->func) {
21 case PIPE_FUNC_NEVER:
22 quad->mask = 0x0;
23 break;
24 case PIPE_FUNC_LESS:
25 /*
26 * If mask were an array [4] we could do this SIMD-style:
27 * passMask = (quad->outputs.color[3] <= vec4(ref));
28 */
29 for (j = 0; j < QUAD_SIZE; j++) {
30 if (quad->outputs.color[3][j] < ref) {
31 passMask |= (1 << j);
32 }
33 }
34 break;
35 case PIPE_FUNC_EQUAL:
36 for (j = 0; j < QUAD_SIZE; j++) {
37 if (quad->outputs.color[3][j] == ref) {
38 passMask |= (1 << j);
39 }
40 }
41 break;
42 case PIPE_FUNC_LEQUAL:
43 for (j = 0; j < QUAD_SIZE; j++) {
44 if (quad->outputs.color[3][j] <= ref) {
45 passMask |= (1 << j);
46 }
47 }
48 break;
49 case PIPE_FUNC_GREATER:
50 for (j = 0; j < QUAD_SIZE; j++) {
51 if (quad->outputs.color[3][j] > ref) {
52 passMask |= (1 << j);
53 }
54 }
55 break;
56 case PIPE_FUNC_NOTEQUAL:
57 for (j = 0; j < QUAD_SIZE; j++) {
58 if (quad->outputs.color[3][j] != ref) {
59 passMask |= (1 << j);
60 }
61 }
62 break;
63 case PIPE_FUNC_GEQUAL:
64 for (j = 0; j < QUAD_SIZE; j++) {
65 if (quad->outputs.color[3][j] >= ref) {
66 passMask |= (1 << j);
67 }
68 }
69 break;
70 case PIPE_FUNC_ALWAYS:
71 passMask = MASK_ALL;
72 break;
73 default:
74 abort();
75 }
76
77 quad->mask &= passMask;
78
79 if (quad->mask)
80 qs->next->run(qs->next, quad);
81 }
82
83
84 static void alpha_test_begin(struct quad_stage *qs)
85 {
86 if (qs->next)
87 qs->next->begin(qs->next);
88 }
89
90
91 static void alpha_test_destroy(struct quad_stage *qs)
92 {
93 FREE( qs );
94 }
95
96
97 struct quad_stage *
98 sp_quad_alpha_test_stage( struct softpipe_context *softpipe )
99 {
100 struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
101
102 stage->softpipe = softpipe;
103 stage->begin = alpha_test_begin;
104 stage->run = alpha_test_quad;
105 stage->destroy = alpha_test_destroy;
106
107 return stage;
108 }