svga: Only emit Z depth work if it is actually read
authorJakob Bornecrantz <jakob@vmware.com>
Thu, 7 Apr 2011 13:07:20 +0000 (14:07 +0100)
committerBrian Paul <brianp@vmware.com>
Fri, 23 Sep 2011 13:58:46 +0000 (07:58 -0600)
src/gallium/drivers/svga/svga_tgsi_decl_sm30.c
src/gallium/drivers/svga/svga_tgsi_insn.c

index 1c385cc7e81b526193f7c9719232b9f4ca3f7f31..3b70a3a7635200c961f2553d946e5a473000d65d 100644 (file)
@@ -121,29 +121,35 @@ static boolean ps30_input( struct svga_shader_emitter *emit,
    SVGA3dShaderDestToken reg;
 
    if (semantic.Name == TGSI_SEMANTIC_POSITION) {
+
       emit->ps_true_pos = src_register( SVGA3DREG_MISCTYPE,
                                         SVGA3DMISCREG_POSITION );
-
       emit->ps_true_pos.base.swizzle = TRANSLATE_SWIZZLE( TGSI_SWIZZLE_X,
                                                           TGSI_SWIZZLE_Y,
                                                           TGSI_SWIZZLE_Y,
                                                           TGSI_SWIZZLE_Y );
+      reg = writemask( dst(emit->ps_true_pos),
+                       TGSI_WRITEMASK_XY );
+      emit->ps_reads_pos = TRUE;
 
-      emit->ps_temp_pos = dst_register( SVGA3DREG_TEMP,
-                                        emit->nr_hw_temp );
-      emit->ps_depth_pos = src_register( SVGA3DREG_INPUT, emit->ps30_input_count++ );
-
-      emit->input_map[idx] = src_register( SVGA3DREG_TEMP,
+      if (emit->info.reads_z) {
+         emit->ps_temp_pos = dst_register( SVGA3DREG_TEMP,
                                            emit->nr_hw_temp );
-      emit->nr_hw_temp++;
+         emit->ps_depth_pos = src_register( SVGA3DREG_INPUT,
+                                            emit->ps30_input_count++ );
 
-      reg = writemask( dst(emit->ps_true_pos),
-                       TGSI_WRITEMASK_XY );
+         emit->input_map[idx] = src_register( SVGA3DREG_TEMP,
+                                              emit->nr_hw_temp );
+         emit->nr_hw_temp++;
+
+         if (!emit_decl( emit, dst( emit->ps_depth_pos ),
+                         SVGA3D_DECLUSAGE_TEXCOORD, 1 ))
+            return FALSE;
+      }
+      else {
+         emit->input_map[idx] = emit->ps_true_pos;
+      }
 
-      emit->ps_reads_pos = TRUE;
-      if (!emit_decl( emit, dst(emit->ps_depth_pos),
-                      SVGA3D_DECLUSAGE_TEXCOORD, 1 ))
-         return FALSE;
       return emit_decl( emit, reg, 0, 0 );
    }
    else if (emit->key.fkey.light_twoside &&
index ec1906eb6190905f5ca019adf03b0649acea9e84..e6ec5966eaa255197fc411b31cce3b224fdd0e26 100644 (file)
@@ -2550,7 +2550,7 @@ static boolean emit_ps_preamble( struct svga_shader_emitter *emit )
                return FALSE;
          }
       }
-   } else if (emit->ps_reads_pos) {
+   } else if (emit->ps_reads_pos && emit->info.reads_z) {
       /*
        * Assemble the position from various bits of inputs. Depth and W are
        * passed in a texcoord this is due to D3D's vPos not hold Z or W.
@@ -2579,7 +2579,7 @@ static boolean emit_ps_preamble( struct svga_shader_emitter *emit )
                        scalar( src(emit->ps_temp_pos), TGSI_SWIZZLE_W ) ))
          return FALSE;
    }
-   
+
    return TRUE;
 }