vl: Add support for max level query v2
[mesa.git] / src / gallium / drivers / r300 / r300_fs.c
index 4c502fefb3fce365c3c50b0a668ff45074e4def9..6e1b4e44ad3ef3e17736b1c29af2970d32b54854 100644 (file)
@@ -22,6 +22,7 @@
  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  * USE OR OTHER DEALINGS IN THE SOFTWARE. */
 
+#include "util/u_format.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
 
 #include "r300_screen.h"
 #include "r300_fs.h"
 #include "r300_reg.h"
+#include "r300_texture.h"
 #include "r300_tgsi_to_rc.h"
 
-#include "radeon_code.h"
-#include "radeon_compiler.h"
+#include "compiler/radeon_compiler.h"
 
 /* Convert info about FS input semantics to r300_shader_semantics. */
 void r300_shader_read_fs_inputs(struct tgsi_shader_info* info,
@@ -147,9 +148,8 @@ static void get_external_state(
 {
     struct r300_textures_state *texstate = r300->textures_state.state;
     unsigned i;
-    unsigned char *swizzle;
 
-    state->frag_clamp = 0;
+    state->alpha_to_one = r300->alpha_to_one && r300->msaa_enable;
 
     for (i = 0; i < texstate->sampler_state_count; i++) {
         struct r300_sampler_state *s = texstate->sampler_states[i];
@@ -160,27 +160,38 @@ static void get_external_state(
             continue;
         }
 
-        t = r300_resource(texstate->sampler_views[i]->base.texture);
+        t = r300_resource(v->base.texture);
 
         if (s->state.compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) {
             state->unit[i].compare_mode_enabled = 1;
 
-            /* Pass depth texture swizzling to the compiler. */
-            if (texstate->sampler_views[i]) {
-                swizzle = texstate->sampler_views[i]->swizzle;
-
-                state->unit[i].depth_texture_swizzle =
-                    RC_MAKE_SWIZZLE(swizzle[0], swizzle[1],
-                                    swizzle[2], swizzle[3]);
-            } else {
-                state->unit[i].depth_texture_swizzle = RC_SWIZZLE_XYZW;
-            }
-
             /* Fortunately, no need to translate this. */
             state->unit[i].texture_compare_func = s->state.compare_func;
         }
 
         state->unit[i].non_normalized_coords = !s->state.normalized_coords;
+        state->unit[i].convert_unorm_to_snorm =
+                v->base.format == PIPE_FORMAT_RGTC1_SNORM ||
+                v->base.format == PIPE_FORMAT_LATC1_SNORM;
+
+        /* Pass texture swizzling to the compiler, some lowering passes need it. */
+        if (v->base.format == PIPE_FORMAT_RGTC1_SNORM ||
+            v->base.format == PIPE_FORMAT_LATC1_SNORM) {
+            unsigned char swizzle[4];
+
+            util_format_compose_swizzles(
+                            util_format_description(v->base.format)->swizzle,
+                            v->swizzle,
+                            swizzle);
+
+            state->unit[i].texture_swizzle =
+                    RC_MAKE_SWIZZLE(swizzle[0], swizzle[1],
+                                    swizzle[2], swizzle[3]);
+        } else if (state->unit[i].compare_mode_enabled) {
+            state->unit[i].texture_swizzle =
+                RC_MAKE_SWIZZLE(v->swizzle[0], v->swizzle[1],
+                                v->swizzle[2], v->swizzle[3]);
+        }
 
         /* XXX this should probably take into account STR, not just S. */
         if (t->tex.is_npot) {
@@ -203,7 +214,7 @@ static void get_external_state(
                 state->unit[i].wrap_mode = RC_WRAP_NONE;
             }
 
-            if (t->b.b.b.target == PIPE_TEXTURE_3D)
+            if (t->b.b.target == PIPE_TEXTURE_3D)
                 state->unit[i].clamp_and_scale_before_fetch = TRUE;
         }
     }
@@ -433,7 +444,7 @@ static void r300_translate_fragment_shader(
 
     /* Setup the compiler. */
     memset(&compiler, 0, sizeof(compiler));
-    rc_init(&compiler.Base);
+    rc_init(&compiler.Base, &r300->fs_regalloc_state);
     DBG_ON(r300, DBG_FP) ? compiler.Base.Debug |= RC_DBG_LOG : 0;
     DBG_ON(r300, DBG_P_STAT) ? compiler.Base.Debug |= RC_DBG_STATS : 0;
 
@@ -444,6 +455,7 @@ static void r300_translate_fragment_shader(
     compiler.Base.disable_optimizations = DBG_ON(r300, DBG_NO_OPT);
     compiler.Base.has_half_swizzles = TRUE;
     compiler.Base.has_presub = TRUE;
+    compiler.Base.has_omod = TRUE;
     compiler.Base.max_temp_regs =
         compiler.Base.is_r500 ? 128 : (compiler.Base.is_r400 ? 64 : 32);
     compiler.Base.max_constants = compiler.Base.is_r500 ? 256 : 32;