softpipe: rename PRIM_x to QUAD_PRIM_x
[mesa.git] / src / gallium / drivers / softpipe / sp_quad_pipe.c
1 /**************************************************************************
2 *
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28
29 #include "sp_context.h"
30 #include "sp_state.h"
31 #include "pipe/p_shader_tokens.h"
32
33 static void
34 sp_push_quad_first(
35 struct softpipe_context *sp,
36 struct quad_stage *quad,
37 uint i )
38 {
39 quad->next = sp->quad[i].first;
40 sp->quad[i].first = quad;
41 }
42
43 static void
44 sp_build_depth_stencil(
45 struct softpipe_context *sp,
46 uint i )
47 {
48 if (sp->depth_stencil->stencil[0].enabled ||
49 sp->depth_stencil->stencil[1].enabled) {
50 sp_push_quad_first( sp, sp->quad[i].stencil_test, i );
51 }
52 else if (sp->depth_stencil->depth.enabled &&
53 sp->framebuffer.zsbuf) {
54 sp_push_quad_first( sp, sp->quad[i].depth_test, i );
55 }
56 }
57
58 void
59 sp_build_quad_pipeline(struct softpipe_context *sp)
60 {
61 uint i;
62
63 boolean early_depth_test =
64 sp->depth_stencil->depth.enabled &&
65 sp->framebuffer.zsbuf &&
66 !sp->depth_stencil->alpha.enabled &&
67 !sp->fs->info.uses_kill &&
68 !sp->fs->info.writes_z;
69
70 /* build up the pipeline in reverse order... */
71 for (i = 0; i < SP_NUM_QUAD_THREADS; i++) {
72 sp->quad[i].first = sp->quad[i].output;
73
74 if (sp->blend->colormask != 0xf) {
75 sp_push_quad_first( sp, sp->quad[i].colormask, i );
76 }
77
78 if (sp->blend->blend_enable ||
79 sp->blend->logicop_enable) {
80 sp_push_quad_first( sp, sp->quad[i].blend, i );
81 }
82
83 if (sp->depth_stencil->depth.occlusion_count) {
84 sp_push_quad_first( sp, sp->quad[i].occlusion, i );
85 }
86
87 if (sp->rasterizer->poly_smooth ||
88 sp->rasterizer->line_smooth ||
89 sp->rasterizer->point_smooth) {
90 sp_push_quad_first( sp, sp->quad[i].coverage, i );
91 }
92
93 if (!early_depth_test) {
94 sp_build_depth_stencil( sp, i );
95 }
96
97 if (sp->depth_stencil->alpha.enabled) {
98 sp_push_quad_first( sp, sp->quad[i].alpha_test, i );
99 }
100
101 /* XXX always enable shader? */
102 if (1) {
103 sp_push_quad_first( sp, sp->quad[i].shade, i );
104 }
105
106 if (early_depth_test) {
107 sp_build_depth_stencil( sp, i );
108 sp_push_quad_first( sp, sp->quad[i].earlyz, i );
109 }
110
111 #if !USE_DRAW_STAGE_PSTIPPLE
112 if (sp->rasterizer->poly_stipple_enable) {
113 sp_push_quad_first( sp, sp->quad[i].polygon_stipple, i );
114 }
115 #endif
116 }
117 }
118