Module: Mesa
Branch: 7.8
Commit: bed7d88708eba69118fe3805f95b104194872f3a
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=bed7d88708eba69118fe3805f95b104194872f3a

Author: Maciej Cencora <[email protected]>
Date:   Sun Mar 21 11:34:19 2010 +0100

r300: fix wpos/fog handling

It may happen that the vertex attribute we were going to stuff
the wpos/fog attrs in was already written by vertex program.
In such cases we need to remove instruction accessing these
attributes, so they don't overwrite the wpos/fog related
instructions.

This fixes non-textured models in many wine games.

---

 src/mesa/drivers/dri/r300/r300_vertprog.c |   22 ++++++++++++++++------
 1 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c 
b/src/mesa/drivers/dri/r300/r300_vertprog.c
index 129004f..e77cd61 100644
--- a/src/mesa/drivers/dri/r300/r300_vertprog.c
+++ b/src/mesa/drivers/dri/r300/r300_vertprog.c
@@ -263,15 +263,25 @@ static struct r300_vertex_program 
*build_program(GLcontext *ctx,
        rc_move_output(&compiler.Base, VERT_RESULT_PSIZ, VERT_RESULT_PSIZ, 
WRITEMASK_X);
 
        if (vp->key.WPosAttr != FRAG_ATTRIB_MAX) {
-               rc_copy_output(&compiler.Base,
-                       VERT_RESULT_HPOS,
-                       vp->key.WPosAttr - FRAG_ATTRIB_TEX0 + VERT_RESULT_TEX0);
+               unsigned int vp_wpos_attr = vp->key.WPosAttr - FRAG_ATTRIB_TEX0 
+ VERT_RESULT_TEX0;
+
+               /* Set empty writemask for instructions writing to vp_wpos_attr
+                * before moving the wpos attr there.
+                * Such instructions will be removed by DCE.
+                */
+               rc_move_output(&compiler.Base, vp_wpos_attr, vp->key.WPosAttr, 
0);
+               rc_copy_output(&compiler.Base, VERT_RESULT_HPOS, vp_wpos_attr);
        }
 
        if (vp->key.FogAttr != FRAG_ATTRIB_MAX) {
-               rc_move_output(&compiler.Base,
-                       VERT_RESULT_FOGC,
-                       vp->key.FogAttr - FRAG_ATTRIB_TEX0 + VERT_RESULT_TEX0, 
WRITEMASK_X);
+               unsigned int vp_fog_attr = vp->key.FogAttr - FRAG_ATTRIB_TEX0 + 
VERT_RESULT_TEX0;
+
+               /* Set empty writemask for instructions writing to vp_fog_attr
+                * before moving the fog attr there.
+                * Such instructions will be removed by DCE.
+                */
+               rc_move_output(&compiler.Base, vp_fog_attr, vp->key.FogAttr, 0);
+               rc_move_output(&compiler.Base, VERT_RESULT_FOGC, vp_fog_attr, 
WRITEMASK_X);
        }
 
        r3xx_compile_vertex_program(&compiler);

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to