<html>
    <head>
      <base href="https://bugs.freedesktop.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Gen4-5 code lost: runtime_check_aads_emit"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=78679#c1">Comment # 1</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Gen4-5 code lost: runtime_check_aads_emit"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=78679">bug 78679</a>
              from <span class="vcard"><a class="email" href="mailto:itoral@igalia.com" title="Iago Toral <itoral@igalia.com>"> <span class="fn">Iago Toral</span></a>
</span></b>
        <pre>The code needs to be fixed:

On an IronLake laptop here I can make the current implementation break badly 
producing a global system freeze. To reproduce the problem the requirements
are:

- Enable line smoothing: glEnable(GL_LINE_SMOOTH)
- Enable line rendering mode for front-faces: glPolygonMode(GL_FRONT, GL_LINE)
- Render a triangle

Long explanation:

The setup I describe above the makes the code in brw_wm_populate_key() set
key->line_aa = AA_SOMETIMES, which will then make c->runtime_check_aads_emit be
TRUE.

The original code removed with the mentioned commit checked
c->runtime_check_aads_emit and did different things depending on its value. I
think the current code for this, which now seems to live in
fs_visitor::emit_fb_writes() handles the original case where
runtime_check_aads_emit is FALSE, but does not consider the other case.

This works in Gen >= 6 in all cases because as far as I can see, the code in
brw_wm_populate_key() will never set line_aa to anything other than AA_NEVER.
The reason for this is that brw_wm_populate_key() checks the value of
brw->reduced_primitive to decide the value of line_aa but this field is only
set in Gen <= 5 (Gen >= 6 uses brw->primitive). I suppose these checks against
reduced_primitive for the value of line_aa are only meaningful in Gen < 6
(otherwise this code is not correct for Gen >= 6).

I think the work to do here involves adding the code that handles the case were
runtime_check_aads_emit is TRUE. The old code doing this was this:

-   else {
-      struct brw_reg v1_null_ud = vec1(retype(brw_null_reg(),
BRW_REGISTER_TYPE_UD));
-      struct brw_reg ip = brw_ip_reg();
-      int jmp;
-      
-      brw_set_compression_control(p, BRW_COMPRESSION_NONE);
-      brw_set_conditionalmod(p, BRW_CONDITIONAL_Z);
-      brw_AND(p, 
-             v1_null_ud, 
-             get_element_ud(brw_vec8_grf(1,0), 6), 
-             brw_imm_ud(1<<26)); 
-
-      jmp = brw_JMPI(p, ip, ip, brw_imm_w(0)) - p->store;
-      {
-        emit_aa(c, arg1, 2);
-        fire_fb_write(c, 0, nr, target, eot);
-        /* note - thread killed in subroutine */
-      }
-      brw_land_fwd_jump(p, jmp);
-
-      /* ELSE: Shuffle up one register to fill in the hole left for AA:
-       */
-      fire_fb_write(c, 1, nr-1, target, eot);
-   }

Unfortunately, the code base has changed quite a bit since this code was
removed so it is not as easy as putting the code back, many of the functions
used do not exist any more and the code . I'll have to see if I can figure how
to get an up-to-date version of this code in place.

I'll attach a sample program that reproduces the problem too.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the QA Contact for the bug.</li>
      </ul>
    </body>
</html>