<html>
    <head>
      <base href="https://bugs.freedesktop.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - UBO access seems to mask address on nouveau"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=67215">67215</a>
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>nouveau@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>UBO access seems to mask address on nouveau
          </td>
        </tr>

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

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>wickmarkus@web.de
          </td>
        </tr>

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

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

        <tr>
          <th>Version</th>
          <td>git
          </td>
        </tr>

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

        <tr>
          <th>Product</th>
          <td>Mesa
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Hi,

The UBO support seems to be broken when used with dolphin-emu. To try it
yourself, I created an apitrace dump:
<a href="http://markus.members.selfnet.de/dolphin/dolphin-emu.trace">http://markus.members.selfnet.de/dolphin/dolphin-emu.trace</a> (~48M)
This works fine on i965 and r600g, but it only show some random polygons on
nouveau.

This bug only happens when the uniform buffer is bigger than 64k bytes. More
precisely it happens when any read offset (related to buffer begin) goes above
the 64k mark.
The offset per uniform block is restricted to 64k, but the offsets per uniform
buffers should allow to access the complete memory.

It seems that the shader fetch mask locations to the first 64k bytes of the
buffer. To proove this, I moved the uniform block to offset 63k so that the
first 1k bytes are read correctly and everything else starts at zero.
My uniform buffer was 128k big and I copyed as I wanted to proove and I got a
correct rendering.

I think the mask is because of 16bit indices for uniform locations. This is
valid for uniform block offsets, but not for uniform buffer offsets.
eg:

u16 uniform_block_offset_per_variable; // hard coded in shader
u32 uniform_buffer_offset_per_uniform_block; // set by glBindBufferRange
u8* uniform_buffer_base; // location of this uniform buffer

// The way I think it's done:
u8* fetched_location = uniform_buffer_base +
u16(uniform_buffer_offset_per_uniform_block +
uniform_block_offset_per_variable);

// The correct way:
u8* fetched_location = uniform_buffer_base +
uniform_buffer_offset_per_uniform_block +
u32(uniform_block_offset_per_variable);</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>