<div dir="ltr">Browsing the code a little, it's not clear that drivers are using the texture object's BaseLevel in a "safe" manner.<div><br></div><div>Some example uses of BaseLevel:</div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
<div><pre style="margin-top:0px;margin-bottom:0px"><font face="courier new, monospace"><span style="color:rgb(128,128,0)">[intel driver]</span></font></pre><pre style="margin-top:0px;margin-bottom:0px"><font face="courier new, monospace"><span style="color:rgb(128,128,0)">const</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">struct</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">gl_texture_image</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">*</span><span style="color:rgb(0,0,0)">img</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">t</span><span style="color:rgb(0,0,0)">-></span><span style="color:rgb(128,0,0)">Image</span><span style="color:rgb(0,0,0)">[</span><span style="color:rgb(0,0,128)">0</span><span style="color:rgb(0,0,0)">][</span><span style="color:rgb(0,0,0)">t</span><span style="color:rgb(0,0,0)">-></span><span style="color:rgb(128,0,0)">BaseLevel</span><span style="color:rgb(0,0,0)">]; // Without conditioning, this could lead to memory access error. Maybe that's already an issue?</span></font></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)"><font face="courier new, monospace"><br></font></span></pre></div><div><pre style="margin-top:0px;margin-bottom:0px"><pre style="margin-top:0px;margin-bottom:0px">
<font face="courier new, monospace"><span style="color:rgb(0,0,0)">firstImage</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">tObj</span><span style="color:rgb(0,0,0)">-></span><span style="color:rgb(128,0,0)">Image</span><span style="color:rgb(0,0,0)">[</span><span style="color:rgb(0,0,128)">0</span><span style="color:rgb(0,0,0)">][</span><span style="color:rgb(0,0,0)">tObj</span><span style="color:rgb(0,0,0)">-></span><span style="color:rgb(128,0,0)">BaseLevel</span><span style="color:rgb(0,0,0)">]; // Same with this</span></font></pre>
<pre style="margin-top:0px;margin-bottom:0px"><font face="courier new, monospace">
</font><pre style="margin-top:0px;margin-bottom:0px"><font face="courier new, monospace"><span style="color:rgb(128,128,0)">if</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(0,0,0)">sampler</span><span style="color:rgb(0,0,0)">-></span><span style="color:rgb(128,0,0)">MinFilter</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">==</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">GL_NEAREST</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">||</span></font></pre>
<pre style="margin-top:0px;margin-bottom:0px"><font face="courier new, monospace"><font color="#c0c0c0"> </font><span style="color:rgb(0,0,0)">sampler</span><span style="color:rgb(0,0,0)">-></span><span style="color:rgb(128,0,0)">MinFilter</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">==</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">GL_LINEAR</span><span style="color:rgb(0,0,0)">)</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">{</span></font></pre>
<pre style="margin-top:0px;margin-bottom:0px"><font face="courier new, monospace"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">maxlevel</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">tObj</span><span style="color:rgb(0,0,0)">-></span><span style="color:rgb(128,0,0)">BaseLevel</span><span style="color:rgb(0,0,0)">;</span></font></pre>
</pre></pre></div></blockquote><span style="color:rgb(192,192,192)"><font face="courier new, monospace"> </font></span><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><font face="courier new, monospace"><span style="color:rgb(0,0,0)">}</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">else</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">{<br>
</span><span style="color:rgb(0,0,0)"> maxlevel</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">tObj</span><span style="color:rgb(0,0,0)">-></span><span style="color:rgb(128,0,0)">_MaxLevel</span><span style="color:rgb(0,0,0)">;</span></font><pre style="margin-top:0px;margin-bottom:0px">
<pre style="margin-top:0px;margin-bottom:0px"><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)"><font face="courier new, monospace">}</font></span></pre><pre style="margin-top:0px;margin-bottom:0px">
<br></pre></pre></pre></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><pre style="margin-top:0px;margin-bottom:0px"><pre style="margin-top:0px;margin-bottom:0px"><pre style="margin-top:0px;margin-bottom:0px">
[st_atom_sampler]
</pre></pre></pre></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><pre style="margin-top:0px;margin-bottom:0px"><pre style="margin-top:0px;margin-bottom:0px"><pre style="margin-top:0px;margin-bottom:0px">
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)">sampler</span><span style="color:rgb(0,0,0)">-></span>min_lod<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">CLAMP</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(0,0,0)">msamp</span><span style="color:rgb(0,0,0)">-></span><span style="color:rgb(128,0,0)">MinLod</span><span style="color:rgb(0,0,0)">,</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">0.0f</span><span style="color:rgb(0,0,0)">,</span></pre><pre style="margin-top:0px;margin-bottom:0px">
<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(128,0,128)">GLfloat</span><span style="color:rgb(0,0,0)">)</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">texobj</span><span style="color:rgb(0,0,0)">-></span><span style="color:rgb(128,0,0)">MaxLevel</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">-</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">texobj</span><span style="color:rgb(0,0,0)">-></span><span style="color:rgb(128,0,0)">BaseLevel</span><span style="color:rgb(0,0,0)">);</span></pre>
</pre></pre></pre></blockquote><div>
<pre style="margin-top:0px;margin-bottom:0px"><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)"><br></span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)">There are more. All using the values that were set in TexParam.</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)"><br></span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)">Courtney</span></pre></pre></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Thu, Dec 5, 2013 at 9:41 AM, Courtney Goeltzenleuchter <span dir="ltr"><<a href="mailto:courtney@lunarg.com" target="_blank">courtney@lunarg.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Okay, that makes it easier.<div><br></div><div>Should this change be conditional based on the type of context created?</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Courtney</div></font></span></div>
<div class="gmail_extra"><div><div class="h5"><br><br><div class="gmail_quote">
On Thu, Dec 5, 2013 at 8:52 AM, Brian Paul <span dir="ltr"><<a href="mailto:brianp@vmware.com" target="_blank">brianp@vmware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>On 12/04/2013 03:46 PM, Courtney Goeltzenleuchter wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
It's come to my attention that Mesa's handling of GL_TEXTURE_BASE_LEVEL<br>
and GL_TEXTURE_MAX_LEVEL in glTexParameter and glGetTexParameter may be<br>
incorrect. The issue happens with the following sequence:<br>
<br>
glTexStorage2D(GL_TEXTURE_2D, 4, GL_RGBA8, 128, 128);<br>
<br>
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 5);<br>
<br>
glGetTexParameter(GL_TEXTURE_<u></u>2D, GL_TEXTURE_BASE_LEVEL, &n);<br>
<br>
The key question is: What is the value of n?<br>
<br>
Right now, the Mesa driver will clamp the glTexParameter call to the<br>
range 0 .. 3 (as specified by the TexStorage call) and n = 3 after the<br>
GetTexParameter call. However, the value returned on the Intel Windows<br>
driver and NVIDIA's Linux driver return 5. This has apparently been<br>
discussed among Kronos members in bug: 9342<br>
(<a href="https://cvs.khronos.org/bugzilla/show_bug.cgi?id=9342" target="_blank">https://cvs.khronos.org/<u></u>bugzilla/show_bug.cgi?id=9342</a><br></div>
<<a href="https://urldefense.proofpoint.com/v1/url?u=https://cvs.khronos.org/bugzilla/show_bug.cgi?id%3D9342&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=lGQMzzTgII0I7jefp2FHq7WtZ%2BTLs8wadB%2BiIj9xpBY%3D%0A&m=SrPAWBW251dxCErQJNhB0m93E9Vb62KGHxK3yiRBRuU%3D%0A&s=a0c086b7a31a804e3e786118fd1771b53c85717a4cf0c8dea41b60e5acd0406b" target="_blank">https://urldefense.<u></u>proofpoint.com/v1/url?u=https:<u></u>//cvs.khronos.org/bugzilla/<u></u>show_bug.cgi?id%3D9342&k=<u></u>oIvRg1%2BdGAgOoM1BIlLLqw%3D%<u></u>3D%0A&r=<u></u>lGQMzzTgII0I7jefp2FHq7WtZ%<u></u>2BTLs8wadB%2BiIj9xpBY%3D%0A&m=<u></u>SrPAWBW251dxCErQJNhB0m93E9Vb62<u></u>KGHxK3yiRBRuU%3D%0A&s=<u></u>a0c086b7a31a804e3e786118fd1771<u></u>b53c85717a4cf0c8dea41b60e5acd0<u></u>406b</a>>)<div>
<br>
which I don't have visibility of.<br>
<br>
To match that behavior the texture object will likely need two BaseLevel<br>
and MaxLevel attributes. One that's clamped and used locally and the<br>
other that simply holds the set value as given by the application in the<br>
glTexParameter call.<br>
<br>
Thoughts?<br>
</div></blockquote>
<br>
>From reading the bug report, it sounds like the ARB decided that clamping should be done when the texture is used, not when glTexParameter is called. In the GL 4.3 spec I don't see any language about clamping in glTexParameter either.<br>
<br>
We should be doing the use-time clamping already. So I think we just have to remove the clamping step in glTexParameter.<span><font color="#888888"><br>
<br>
-Brian<br>
<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div></div></div><div class="im">-- <br><div dir="ltr">Courtney Goeltzenleuchter<br><div>LunarG</div><div><img src="http://media.lunarg.com/wp-content/themes/LunarG/images/logo.png" width="96" height="65"><br>
</div></div>
</div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Courtney Goeltzenleuchter<br><div>LunarG</div><div><img src="http://media.lunarg.com/wp-content/themes/LunarG/images/logo.png" width="96" height="65"><br>
</div></div>
</div>