mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-04 11:58:10 +02:00
Compute need_z and need_w properly and use the correct const/linear/perspective interpolation in shade_quad().
This commit is contained in:
parent
2de4c7573e
commit
1475d74cfb
2 changed files with 36 additions and 17 deletions
|
|
@ -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];
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue