<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 --- - glTexStorage*() functions don't work properly with proxy textures"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=67516">67516</a>
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>mesa-dev@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>glTexStorage*() functions don't work properly with proxy textures
          </td>
        </tr>

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

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

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>mikjuo@gmail.com
          </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>Mesa core
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Mesa
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=83259" name="attach_83259" title="texstorage_fail.c, shows the problems as they appear to user code">attachment 83259</a> <a href="attachment.cgi?id=83259&action=edit" title="texstorage_fail.c, shows the problems as they appear to user code">[details]</a></span>
texstorage_fail.c, shows the problems as they appear to user code

There appears to be problems with proxy textures and the texture storage
functions. I identified three separate issues:

- The calculation (_mesa_get_tex_max_num_levels() in teximage.c) that checks
how many mipmap levels a texture could have has not been written to check proxy
textures as well.

- The error checking in the storage functions checks if a non-zero texture has
been bound. Proxy textures don't care about that but the check makes
glTexStorage*() fail when they should not. As far as I know, you cannot bind a
proxy texture to anything so this makes glTexStorage*() always fail for a proxy
texture.

- The use of glTexStorage*() on a proxy texture makes the texture immutable.
This is not normally detectable by the users (because it is a proxy texture)
but the immutability flag makes further glTexStorage*() calls fail. This last
issue cannot be seen until the two previous issues are fixed.


I would not be surprised if there were more issues with proxy textures lurking
here, given that it looks like these functions were not tested with proxy
textures.

I'm attaching three patches that I used to make things work for me. I also
attached a short testing program that shows how user code would see these
problems.</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>