diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/pipe/softpipe/sp_quad_fs.c | 32 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_state_derived.c | 21 |
2 files changed, 36 insertions, 17 deletions
diff --git a/src/mesa/pipe/softpipe/sp_quad_fs.c b/src/mesa/pipe/softpipe/sp_quad_fs.c index 846c330056..526992408a 100644 --- a/src/mesa/pipe/softpipe/sp_quad_fs.c +++ b/src/mesa/pipe/softpipe/sp_quad_fs.c @@ -121,12 +121,11 @@ static INLINE void pinterp( struct exec_machine *exec, static void shade_quad( struct quad_stage *qs, struct quad_header *quad ) { - struct softpipe_context *softpipe = qs->softpipe; + const struct softpipe_context *softpipe = qs->softpipe; struct exec_machine exec; - GLfloat fx = quad->x0; - GLfloat fy = quad->y0; + const GLfloat fx = quad->x0; + const GLfloat fy = quad->y0; GLuint i, j; - GLboolean need_z = softpipe->depth_test.enabled; /* XXX hack */ exec.coef = quad->coef; @@ -142,27 +141,22 @@ shade_quad( struct quad_stage *qs, struct quad_header *quad ) exec.attr[FRAG_ATTRIB_WPOS][1][2] = fy + 1.0; exec.attr[FRAG_ATTRIB_WPOS][1][3] = fy + 1.0; - /* Z and W are done by linear interpolation: - * XXX we'll probably have to use integers for Z - */ - if (/*softpipe->*/need_z) { + /* Z and W are done by linear interpolation */ + if (softpipe->need_z) { linterp(&exec, 0, 2); /* attr[0].z */ } if (softpipe->need_w) { linterp(&exec, 0, 3); /* attr[0].w */ -// invert(&exec, 0, 3); + /*invert(&exec, 0, 3);*/ } /* Interpolate all the remaining attributes. This will get pushed * into the fragment program's responsibilities at some point. + * Start at 1 to skip fragment position attribute (computed above). */ for (i = 1; i < quad->nr_attrs; i++) { -#if 1 - for (j = 0; j < NUM_CHANNELS; j++) - linterp(&exec, i, j); -#else - switch (quad->interp[i]) { + switch (softpipe->interp[i]) { case INTERP_CONSTANT: for (j = 0; j < NUM_CHANNELS; j++) cinterp(&exec, i, j); @@ -178,7 +172,6 @@ shade_quad( struct quad_stage *qs, struct quad_header *quad ) pinterp(&exec, i, j); break; } -#endif } #if 1 @@ -243,6 +236,13 @@ shade_quad( struct quad_stage *qs, struct quad_header *quad ) memcpy(quad->outputs.color, &aoutputs[FRAG_ATTRIB_COL0].xyzw[0].f[0], sizeof(quad->outputs.color)); + if (softpipe->need_z) { + /* XXX temporary */ + quad->outputs.depth[0] = exec.attr[0][2][0]; + quad->outputs.depth[1] = exec.attr[0][2][1]; + quad->outputs.depth[2] = exec.attr[0][2][2]; + quad->outputs.depth[3] = exec.attr[0][2][3]; + } } #else { @@ -253,7 +253,7 @@ shade_quad( struct quad_stage *qs, struct quad_header *quad ) exec.attr[attr], sizeof(quad->outputs.color)); - if (need_z) { + if (softpipe->need_z) { quad->outputs.depth[0] = exec.attr[0][2][0]; quad->outputs.depth[1] = exec.attr[0][2][1]; quad->outputs.depth[2] = exec.attr[0][2][2]; diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c index a470cc256e..84a1ec79f8 100644 --- a/src/mesa/pipe/softpipe/sp_state_derived.c +++ b/src/mesa/pipe/softpipe/sp_state_derived.c @@ -75,6 +75,24 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) GLbitfield attr_mask = 0x0; GLuint i; + /* Need Z if depth test is enabled or the fragment program uses the + * fragment position (XYZW). + */ + if (softpipe->depth_test.enabled || + (inputsRead & FRAG_ATTRIB_WPOS)) + softpipe->need_z = GL_TRUE; + else + softpipe->need_z = GL_FALSE; + + /* Need W if we do any perspective-corrected interpolation or the + * fragment program uses the fragment position. + */ + if (inputsRead & FRAG_ATTRIB_WPOS) + softpipe->need_w = GL_TRUE; + else + softpipe->need_w = GL_FALSE; + + softpipe->nr_attrs = 0; memset(slot_to_vf_attr, 0, sizeof(slot_to_vf_attr)); @@ -101,7 +119,8 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) for (i = FRAG_ATTRIB_TEX0; i < FRAG_ATTRIB_MAX; i++) { if (inputsRead & (1 << i)) { - EMIT_ATTR(frag_to_vf[i], i, INTERP_PERSPECTIVE); + EMIT_ATTR(frag_to_vf[i], i, INTERP_PERSPECTIVE); + softpipe->need_w = GL_TRUE; } } |