r300g: fix regression in texdepth.
[mesa.git] / src / gallium / drivers / r300 / r300_fs.c
index 6af6028447fbdb501857d13d82b724e03117b90b..dab57fdcc77e73d2a489b81b2785f0d00646f8b3 100644 (file)
@@ -31,6 +31,7 @@
 #include "r300_context.h"
 #include "r300_screen.h"
 #include "r300_fs.h"
+#include "r300_reg.h"
 #include "r300_tgsi_to_rc.h"
 
 #include "radeon_code.h"
@@ -139,14 +140,11 @@ static void get_external_state(
 
     for (i = 0; i < texstate->sampler_state_count; i++) {
         struct r300_sampler_state* s = texstate->sampler_states[i];
-        struct r300_texture *t;
 
-        if (!s || !texstate->sampler_views[i]) {
+        if (!s) {
             continue;
         }
 
-        t = (struct r300_texture*)texstate->sampler_views[i]->base.texture;
-
         if (s->state.compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) {
             /* XXX Gallium doesn't provide us with any information regarding
              * this mode, so we are screwed. I'm setting 0 = LUMINANCE. */
@@ -156,7 +154,12 @@ static void get_external_state(
             state->unit[i].texture_compare_func = s->state.compare_func;
         }
 
-        state->unit[i].fake_npot = t->uses_pitch;
+        if (texstate->sampler_views[i]) {
+            struct r300_texture *t;
+            t = (struct r300_texture*)texstate->sampler_views[i]->base.texture;
+
+            state->unit[i].fake_npot = t->uses_pitch;
+        }
         state->unit[i].non_normalized_coords = !s->state.normalized_coords;
 
         /* XXX this should probably take into account STR, not just S. */
@@ -253,8 +256,6 @@ static void r300_translate_fragment_shader(
 
     r300_tgsi_to_rc(&ttr, tokens);
 
-    shader->shadow_samplers = compiler.Base.Program.ShadowSamplers;
-
     /**
      * Transform the program to support WPOS.
      *
@@ -279,7 +280,10 @@ static void r300_translate_fragment_shader(
                     "Giving up...\n");
             abort();
         }
+
+        rc_destroy(&compiler.Base);
         r300_dummy_fragment_shader(r300, shader);
+        return;
     }
 
     /* Initialize numbers of constants for each type. */
@@ -300,6 +304,15 @@ static void r300_translate_fragment_shader(
         }
     }
 
+    /* Setup shader depth output. */
+    if (shader->code.writes_depth) {
+        shader->fg_depth_src = R300_FG_DEPTH_SRC_SHADER;
+        shader->us_out_w = R300_W_FMT_W24 | R300_W_SRC_US;
+    } else {
+        shader->fg_depth_src = R300_FG_DEPTH_SRC_SCAN;
+        shader->us_out_w = R300_W_FMT_W0 | R300_W_SRC_US;
+    }
+
     /* And, finally... */
     rc_destroy(&compiler.Base);
 }