i965: Delete previous workaround for textureGrad with shadow samplers.
authorKenneth Graunke <kenneth@whitecape.org>
Tue, 10 Jul 2012 04:25:37 +0000 (21:25 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 12 Jul 2012 17:20:26 +0000 (10:20 -0700)
It had many problems:
- The shadow comparison was done post-filtering.
- It required state-dependent recompiles whenever the comparison
  function changed.
- It didn't even work: many cases hit assertion failures.
- I never implemented it for the VS.

The new lowering pass which converts textureGrad to textureLod by
computing the LOD value works much better.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/drivers/dri/i965/brw_fs.cpp
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
src/mesa/drivers/dri/i965/brw_program.h
src/mesa/drivers/dri/i965/brw_wm.c

index 175e36e4257f47ee54a8f036fc2f7825c15edae4..b3b25cc1adfb48898652c544737ed5dbe3d0548b 100644 (file)
@@ -2163,9 +2163,6 @@ brw_fs_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
    key.clamp_fragment_color = true;
 
    for (int i = 0; i < BRW_MAX_TEX_UNIT; i++) {
-      if (fp->Base.ShadowSamplers & (1 << i))
-        key.tex.compare_funcs[i] = GL_LESS;
-
       /* FINISHME: depth compares might use (0,0,0,W) for example */
       key.tex.swizzles[i] = SWIZZLE_XYZW;
    }
index 28adf331eaf56fbe57a2b2b178d95e338a723137..7224cbe04f569f9d667d1e6f7688a345d4cba885 100644 (file)
@@ -712,7 +712,7 @@ fs_visitor::emit_texture_gen4(ir_texture *ir, fs_reg dst, fs_reg coordinate,
    /* g0 header. */
    mlen = 1;
 
-   if (ir->shadow_comparitor && ir->op != ir_txd) {
+   if (ir->shadow_comparitor) {
       for (int i = 0; i < ir->coordinate->type->vector_elements; i++) {
         emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen + i), coordinate);
         coordinate.reg_offset++;
@@ -931,7 +931,7 @@ fs_visitor::emit_texture_gen5(ir_texture *ir, fs_reg dst, fs_reg coordinate,
    }
    mlen += vector_elements * reg_width;
 
-   if (ir->shadow_comparitor && ir->op != ir_txd) {
+   if (ir->shadow_comparitor) {
       mlen = MAX2(mlen, header_present + 4 * reg_width);
 
       ir->shadow_comparitor->accept(this);
@@ -1038,7 +1038,7 @@ fs_visitor::emit_texture_gen7(ir_texture *ir, fs_reg dst, fs_reg coordinate,
       base_mrf--;
    }
 
-   if (ir->shadow_comparitor && ir->op != ir_txd) {
+   if (ir->shadow_comparitor) {
       ir->shadow_comparitor->accept(this);
       emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen), this->result);
       mlen += reg_width;
@@ -1163,19 +1163,6 @@ fs_visitor::visit(ir_texture *ir)
    int sampler = _mesa_get_sampler_uniform_value(ir->sampler, prog, &fp->Base);
    sampler = fp->Base.SamplerUnits[sampler];
 
-   /* Our hardware doesn't have a sample_d_c message, so shadow compares
-    * for textureGrad/TXD need to be emulated with instructions.
-    */
-   bool hw_compare_supported = ir->op != ir_txd;
-   if (ir->shadow_comparitor && !hw_compare_supported) {
-      assert(c->key.tex.compare_funcs[sampler] != GL_NONE);
-      /* No need to even sample for GL_ALWAYS or GL_NEVER...bail early */
-      if (c->key.tex.compare_funcs[sampler] == GL_ALWAYS)
-        return swizzle_result(ir, fs_reg(1.0f), sampler);
-      else if (c->key.tex.compare_funcs[sampler] == GL_NEVER)
-        return swizzle_result(ir, fs_reg(0.0f), sampler);
-   }
-
    if (ir->coordinate)
       ir->coordinate->accept(this);
    fs_reg coordinate = this->result;
@@ -1325,47 +1312,8 @@ fs_visitor::visit(ir_texture *ir)
 
    inst->sampler = sampler;
 
-   if (ir->shadow_comparitor) {
-      if (hw_compare_supported) {
-        inst->shadow_compare = true;
-      } else {
-        ir->shadow_comparitor->accept(this);
-        fs_reg ref = this->result;
-
-        fs_reg value = dst;
-        dst = fs_reg(this, glsl_type::vec4_type);
-
-        /* FINISHME: This needs to be done pre-filtering. */
-
-        uint32_t conditional = 0;
-        switch (c->key.tex.compare_funcs[sampler]) {
-        /* GL_ALWAYS and GL_NEVER were handled at the top of the function */
-        case GL_LESS:     conditional = BRW_CONDITIONAL_L;   break;
-        case GL_GREATER:  conditional = BRW_CONDITIONAL_G;   break;
-        case GL_LEQUAL:   conditional = BRW_CONDITIONAL_LE;  break;
-        case GL_GEQUAL:   conditional = BRW_CONDITIONAL_GE;  break;
-        case GL_EQUAL:    conditional = BRW_CONDITIONAL_EQ;  break;
-        case GL_NOTEQUAL: conditional = BRW_CONDITIONAL_NEQ; break;
-        default: assert(!"Should not get here: bad shadow compare function");
-        }
-
-        /* Use conditional moves to load 0 or 1 as the result */
-        this->current_annotation = "manual shadow comparison";
-        for (int i = 0; i < 4; i++) {
-           inst = emit(BRW_OPCODE_MOV, dst, fs_reg(0.0f));
-
-           inst = emit(BRW_OPCODE_CMP, reg_null_f, ref, value);
-           inst->conditional_mod = conditional;
-
-           inst = emit(BRW_OPCODE_MOV, dst, fs_reg(1.0f));
-           inst->predicated = true;
-
-           dst.reg_offset++;
-           value.reg_offset++;
-        }
-        dst.reg_offset = 0;
-      }
-   }
+   if (ir->shadow_comparitor)
+      inst->shadow_compare = true;
 
    swizzle_result(ir, dst, sampler);
 }
index a2698cf2e29839c7ddeaee33e40b620797e605dd..287994f5262b78a0124b6ef04b20d12f75903098 100644 (file)
  * Sampler information needed by VS, WM, and GS program cache keys.
  */
 struct brw_sampler_prog_key_data {
-   /**
-    * Per-sampler comparison functions:
-    *
-    * If comparison mode is GL_COMPARE_R_TO_TEXTURE, then this is set to one
-    * of GL_NEVER, GL_LESS, GL_EQUAL, GL_LEQUAL, GL_GREATER, GL_NOTEQUAL,
-    * GL_GEQUAL, or GL_ALWAYS.  Otherwise (comparison mode is GL_NONE), this
-    * field is irrelevant so it's left as GL_NONE (0).
-    *
-    * While this is a GLenum, all possible values fit in 16-bits.
-    */
-   uint16_t compare_funcs[BRW_MAX_TEX_UNIT];
-
    /**
     * EXT_texture_swizzle and DEPTH_TEXTURE_MODE swizzles.
     */
index ae6c6bfe6847de39b1a1d357f5de1c5b3436b247..880564619c85909ace55eb7e8ac2b5f624115ae0 100644 (file)
@@ -366,9 +366,6 @@ brw_populate_sampler_prog_key_data(struct gl_context *ctx,
 
       if (img->_BaseFormat == GL_DEPTH_COMPONENT ||
          img->_BaseFormat == GL_DEPTH_STENCIL) {
-        if (sampler->CompareMode == GL_COMPARE_R_TO_TEXTURE_ARB)
-           key->compare_funcs[i] = sampler->CompareFunc;
-
         /* We handle GL_DEPTH_TEXTURE_MODE here instead of as surface format
          * overrides because shadow comparison always returns the result of
          * the comparison in all channels anyway.