8 #include "sp_context.h"
9 #include "sp_headers.h"
11 #include "pipe/p_defines.h"
15 alpha_test_quad(struct quad_stage
*qs
, struct quad_header
*quad
)
17 struct softpipe_context
*softpipe
= qs
->softpipe
;
18 const GLfloat ref
= softpipe
->alpha_test
.ref
;
19 GLuint passMask
= 0x0, j
;
21 switch (softpipe
->alpha_test
.func
) {
27 * If mask were an array [4] we could do this SIMD-style:
28 * passMask = (quad->outputs.color[3] <= vec4(ref));
30 for (j
= 0; j
< QUAD_SIZE
; j
++) {
31 if (quad
->outputs
.color
[3][j
] < ref
) {
37 for (j
= 0; j
< QUAD_SIZE
; j
++) {
38 if (quad
->outputs
.color
[3][j
] == ref
) {
43 case PIPE_FUNC_LEQUAL
:
44 for (j
= 0; j
< QUAD_SIZE
; j
++) {
45 if (quad
->outputs
.color
[3][j
] <= ref
) {
50 case PIPE_FUNC_GREATER
:
51 for (j
= 0; j
< QUAD_SIZE
; j
++) {
52 if (quad
->outputs
.color
[3][j
] > ref
) {
57 case PIPE_FUNC_NOTEQUAL
:
58 for (j
= 0; j
< QUAD_SIZE
; j
++) {
59 if (quad
->outputs
.color
[3][j
] != ref
) {
64 case PIPE_FUNC_GEQUAL
:
65 for (j
= 0; j
< QUAD_SIZE
; j
++) {
66 if (quad
->outputs
.color
[3][j
] >= ref
) {
71 case PIPE_FUNC_ALWAYS
:
78 quad
->mask
&= passMask
;
81 qs
->next
->run(qs
->next
, quad
);
85 static void alpha_test_begin(struct quad_stage
*qs
)
88 qs
->next
->begin(qs
->next
);
93 sp_quad_alpha_test_stage( struct softpipe_context
*softpipe
)
95 struct quad_stage
*stage
= CALLOC_STRUCT(quad_stage
);
97 stage
->softpipe
= softpipe
;
98 stage
->begin
= alpha_test_begin
;
99 stage
->run
= alpha_test_quad
;