<div dir="ltr">On 4 February 2013 21:48, Chris Forbes <span dir="ltr"><<a href="mailto:chrisf@ijw.co.nz" target="_blank">chrisf@ijw.co.nz</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Gen6, lower this to `ld` with lod=0 and an extra sample_index<br>
parameter.<br>
<br>
On Gen7, use `ld2dms`. We don't support CMS yet for multisample<br>
textures, so we use MCS=0, which does the right thing for both IMS and<br>
UMS surfaces.<br>
<br>
Note: If we do end up emitting specialized shaders based on the MSAA<br>
layout, we can emit a slightly shorter message here in the UMS case.<br>
<br>
V2: Reworked completely, added support for Gen7.<br>
<br>
Signed-off-by: Chris Forbes <<a href="mailto:chrisf@ijw.co.nz">chrisf@ijw.co.nz</a>><br>
---<br>
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 44 ++++++++++++++++++++++++----<br>
 1 file changed, 38 insertions(+), 6 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp<br>
index d4f6fc9..a3b524c 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp<br>
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp<br>
@@ -1061,9 +1061,17 @@ fs_visitor::emit_texture_gen5(ir_texture *ir, fs_reg dst, fs_reg coordinate,<br>
       break;<br>
    case ir_txf:<br>
       mlen = header_present + 4 * reg_width;<br>
+      emit(MOV(fs_reg(MRF, base_mrf + mlen - reg_width, BRW_REGISTER_TYPE_UD), lod));<br>
+      inst = emit(SHADER_OPCODE_TXF, dst);<br>
+      break;<br>
+   case ir_txf_ms:<br>
+      mlen = header_present + 4 * reg_width;<br>
<br>
-      emit(MOV(fs_reg(MRF, base_mrf + mlen - reg_width, BRW_REGISTER_TYPE_UD),<br>
-               lod));<br>
+      /* lod */<br>
+      emit(MOV(fs_reg(MRF, base_mrf + mlen - reg_width, BRW_REGISTER_TYPE_UD), fs_reg(0)));<br>
+      /* sample index */<br>
+      emit(MOV(fs_reg(MRF, base_mrf + mlen, BRW_REGISTER_TYPE_UD), lod /*sample*/));<br></blockquote><div><br></div><div>Similar comment to the previous patch: I think this would be a lot clearer if we went ahead and added a "sample" parameter to this function rather than repurpose the "lod" parameter.<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+      mlen += reg_width;<br>
       inst = emit(SHADER_OPCODE_TXF, dst);<br>
       break;<br>
    }<br>
@@ -1170,16 +1178,35 @@ fs_visitor::emit_texture_gen7(ir_texture *ir, fs_reg dst, fs_reg coordinate,<br>
       mlen += reg_width;<br>
<br>
       for (int i = 1; i < ir->coordinate->type->vector_elements; i++) {<br>
-        emit(ADD(fs_reg(MRF, base_mrf + mlen, BRW_REGISTER_TYPE_D),<br>
+         emit(ADD(fs_reg(MRF, base_mrf + mlen, BRW_REGISTER_TYPE_D),<br>
                   coordinate, offsets[i]));<br>
-        coordinate.reg_offset++;<br>
-        mlen += reg_width;<br>
+         coordinate.reg_offset++;<br>
+         mlen += reg_width;<br></blockquote><div><br></div><div>These look like unintentional diffs (perhaps due to whitespace changes).  Normally I don't get concerned about whitespace conventions, but in this case it's making it hard to follow the patch.<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+      }<br>
+      break;<br>
+   case ir_txf_ms:<br>
+      emit(MOV(fs_reg(MRF, base_mrf + mlen, BRW_REGISTER_TYPE_UD), lod /*sample_index*/));<br>
+      mlen += reg_width;<br>
+<br>
+      /* constant zero MCS; we arrange to never actually have a compressed<br>
+       * multisample surface here for now. TODO: issue ld_mcs to get this first,<br>
+       * if we ever support texturing from compressed multisample surfaces */<br>
+      emit(MOV(fs_reg(MRF, base_mrf + mlen, BRW_REGISTER_TYPE_UD), fs_reg(0u)));<br>
+      mlen += reg_width;<br>
+<br>
+      /* there is no offsetting for this message; just copy in the integer<br>
+       * texture coordinates */<br>
+      for (int i=0; i < ir->coordinate->type->vector_elements; i++) {<br>
+         emit(MOV(fs_reg(MRF, base_mrf + mlen, BRW_REGISTER_TYPE_D),<br>
+                  coordinate));<br>
+         coordinate.reg_offset++;<br>
+         mlen += reg_width;<br>
       }<br>
       break;<br>
    }<br>
<br>
    /* Set up the coordinate (except for cases where it was done above) */<br>
-   if (ir->op != ir_txd && ir->op != ir_txs && ir->op != ir_txf) {<br>
+   if (ir->op != ir_txd && ir->op != ir_txs && ir->op != ir_txf && ir->op != ir_txf_ms) {<br>
       for (int i = 0; i < ir->coordinate->type->vector_elements; i++) {<br>
         emit(MOV(fs_reg(MRF, base_mrf + mlen), coordinate));<br>
         coordinate.reg_offset++;<br>
@@ -1195,6 +1222,7 @@ fs_visitor::emit_texture_gen7(ir_texture *ir, fs_reg dst, fs_reg coordinate,<br>
    case ir_txl: inst = emit(SHADER_OPCODE_TXL, dst); break;<br>
    case ir_txd: inst = emit(SHADER_OPCODE_TXD, dst); break;<br>
    case ir_txf: inst = emit(SHADER_OPCODE_TXF, dst); break;<br>
+   case ir_txf_ms: inst = emit(SHADER_OPCODE_TXF_MS, dst); break;<br>
    case ir_txs: inst = emit(SHADER_OPCODE_TXS, dst); break;<br>
    }<br>
    inst->base_mrf = base_mrf;<br>
@@ -1365,6 +1393,10 @@ fs_visitor::visit(ir_texture *ir)<br>
       ir->lod_info.lod->accept(this);<br>
       lod = this->result;<br>
       break;<br>
+   case ir_txf_ms:<br>
+      ir->lod_info.sample_index->accept(this);<br>
+      lod = this->result;<br>
+      break;<br>
    };<br>
<br>
    /* Writemasking doesn't eliminate channels on SIMD8 texture<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.8.1.2<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>