6 #include "sp_context.h"
7 #include "sp_headers.h"
9 #include "pipe/p_defines.h"
10 #include "pipe/p_util.h"
14 alpha_test_quad(struct quad_stage
*qs
, struct quad_header
*quad
)
16 struct softpipe_context
*softpipe
= qs
->softpipe
;
17 const float ref
= softpipe
->alpha_test
->ref
;
18 unsigned passMask
= 0x0, j
;
20 switch (softpipe
->alpha_test
->func
) {
26 * If mask were an array [4] we could do this SIMD-style:
27 * passMask = (quad->outputs.color[3] <= vec4(ref));
29 for (j
= 0; j
< QUAD_SIZE
; j
++) {
30 if (quad
->outputs
.color
[3][j
] < ref
) {
36 for (j
= 0; j
< QUAD_SIZE
; j
++) {
37 if (quad
->outputs
.color
[3][j
] == ref
) {
42 case PIPE_FUNC_LEQUAL
:
43 for (j
= 0; j
< QUAD_SIZE
; j
++) {
44 if (quad
->outputs
.color
[3][j
] <= ref
) {
49 case PIPE_FUNC_GREATER
:
50 for (j
= 0; j
< QUAD_SIZE
; j
++) {
51 if (quad
->outputs
.color
[3][j
] > ref
) {
56 case PIPE_FUNC_NOTEQUAL
:
57 for (j
= 0; j
< QUAD_SIZE
; j
++) {
58 if (quad
->outputs
.color
[3][j
] != ref
) {
63 case PIPE_FUNC_GEQUAL
:
64 for (j
= 0; j
< QUAD_SIZE
; j
++) {
65 if (quad
->outputs
.color
[3][j
] >= ref
) {
70 case PIPE_FUNC_ALWAYS
:
77 quad
->mask
&= passMask
;
80 qs
->next
->run(qs
->next
, quad
);
84 static void alpha_test_begin(struct quad_stage
*qs
)
87 qs
->next
->begin(qs
->next
);
91 static void alpha_test_destroy(struct quad_stage
*qs
)
98 sp_quad_alpha_test_stage( struct softpipe_context
*softpipe
)
100 struct quad_stage
*stage
= CALLOC_STRUCT(quad_stage
);
102 stage
->softpipe
= softpipe
;
103 stage
->begin
= alpha_test_begin
;
104 stage
->run
= alpha_test_quad
;
105 stage
->destroy
= alpha_test_destroy
;