<html>
    <head>
      <base href="https://bugs.freedesktop.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Fetching from imageBuffer creates very poor GEN assembly"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=101562">101562</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Fetching from imageBuffer creates very poor GEN assembly
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Mesa
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>17.1
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>x86-64 (AMD64)
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux (All)
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Drivers/DRI/i965
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>intel-3d-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>kevin.rogovin@intel.com
          </td>
        </tr>

        <tr>
          <th>QA Contact</th>
          <td>intel-3d-bugs@lists.freedesktop.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=132153" name="attach_132153" title="tarball of results: .shader.txt is input shader, .asm.txt is outout of INTEL_DEBUG=fs">attachment 132153</a> <a href="attachment.cgi?id=132153&action=edit" title="tarball of results: .shader.txt is input shader, .asm.txt is outout of INTEL_DEBUG=fs">[details]</a></span>
tarball of results: .shader.txt is input shader, .asm.txt is outout of
INTEL_DEBUG=fs

If one uses an imageBuffer to fetch values and add them in either of the forms:

 value = start_value + get_value(0) + get_value(1) + ... 
or
 value = ((((((...(start_value + get_value(0)) + get_value(1)) + ... )

then the generated assembly is quite poor. It reserves O(n) registers (where n
is the number of constants to fetch) at shader start, with those values placed
into the registers having a large number of duplicates.

However, if the shader is:

 value = start_value;
 value += get_value(0);
 value += get_value(1); 

or if the constants are fetched though other means (UBO, TBO, SSBO) then the
generated assembly is fine. This is in spite of the fact that the above is
equivalent to the 2nd form of a one line add.

Attached is a battery of machine generated shaders and the output of
INTEL_DEBUG=fs when compiling such shaders with a matching, but trivial, vertex
shader.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
          <li>You are the QA Contact for the bug.</li>
      </ul>
    </body>
</html>