Honestly I&#39;d like to have one way to recognize that a texture is addressed by non-normalized coordinates.<br><br>Right now we have two:<br>1) in TGSI via TGSI_TEXTURE_RECT (like OpenGL)<br>2) in pipe_sampler_state via normalized_coord (like OpenCL)<br>
<br>And Luca&#39;s proposal completes the OpenGL way.<br><br>I think the first two don&#39;t get along well with each other. What if I get the RECT sampler target and normalized_coord == 1?<br><br>r300 likes the first way because the &quot;normalized&quot; bit is part of the TEX instruction, though recompiling shaders is not a big deal from the implementation point of view since we already do this for shadow samplers and newly for the repeat and mirrored wrap modes of NPOT textures, thanks to the flexibility of our compiler, but it&#39;s a burden and pollutes the command stream with fragment shader instructions and constants, and probably impacts performance too.<br>
<br>nv50 seems to use the second way but it could also go well with Luca&#39;s one. I&#39;d vote for the &quot;normalized&quot; bit to be an immutable property of pipe_texture, possibly introducing a PIPE_TEXTURE_RECT target as that would make life of D3D9-level hw drivers easier.<br>
<br>-Marek<br><br><div class="gmail_quote">On Thu, Apr 15, 2010 at 6:34 PM, Roland Scheidegger <span dir="ltr">&lt;<a href="mailto:sroland@vmware.com" target="_blank">sroland@vmware.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<div><div></div><div>On 15.04.2010 09:36, Luca Barbieri wrote:<br>
&gt; See also the RFC-gallium-unnormalized-coords-hint branch.<br>
&gt;<br>
&gt; Currently the Gallium driver has no way of telling that a texture was created<br>
&gt; with GL_TEXTURE_RECTANGLE as opposed to GL_TEXTURE_2D.<br>
&gt;<br>
&gt; Unfortunately, some hardware like nv30 has two texture layouts, and the<br>
&gt; first only works with unnormalized coordinates (and has no mipmap support),<br>
&gt; and the second only works with normalized coordinates (and requires POT sizes).<br>
&gt;<br>
&gt; Thus, it is beneficial to know which kind of coordinates are going to be used at<br>
&gt; texture creation time.<br>
&gt;<br>
&gt; Fortunately, with OpenGL, whether normalized or unnormalized coordinates can<br>
&gt; be used is decided at creation time, but we don&#39;t currently pass this to<br>
&gt; the driver.<br>
&gt;<br>
&gt; This branch adds a new resource flag that is used by the state trackers to<br>
&gt; tell the driver whether it is going to typically use sampler states with<br>
&gt; normalized_coords = 0.<br>
&gt;<br>
&gt; In practice, the OpenGL state tracker sets it if and only if GL_TEXTURE_RECTANGLE<br>
&gt; is being used as the texture target.<br>
&gt;<br>
&gt; Note that this patch series does *not* make this a mandatory flag, but rather an<br>
&gt; hint: the driver is theoretically supposed to either change the texture layout<br>
&gt; or alter the fragment shader if a normalization mismatch happens.<br>
&gt;<br>
&gt; The general idea is that the weird pre-DirectX 10 restrictions for texture sizes<br>
&gt; should be hidden by the driver, and not exposed to the state tracker.<br>
&gt;<br>
&gt; Currently the NPOT cap exposes them a bit, but r300g just lifted all restrictions<br>
&gt; and hopefully nv30 will too (nv40 also has the minor restriction of not supporting<br>
&gt; unnormalized coordinates with mipmaps).<br>
&gt;<br>
&gt; However, this flag is still likely to be useful to avoid unnecessary overhead.<br>
&gt;<br>
&gt; Right now, it&#39;s required to correctly support ARB_texture_rectangle on nv30.<br>
&gt;<br>
&gt; The impact on Gallium is quite minimal.<br>
<br>
</div></div>So, since one layout requires pot sizes, I guess the problem you have is<br>
if a texture rectangle just happens to be POT you don&#39;t know that in the<br>
driver upon texture creation time?<br>
It&#39;s quite common for hw to have different layouts for pot and npot,<br>
though normally they don&#39;t tie normalized vs non-normalized coordinates<br>
to it... Seems like an odd choice, so if you do render to texture (to a<br>
npot size) then you need to adjust the fragment shader for the<br>
non-normalized texture coords?<br>
Your solution looks acceptable to me, since drivers are free to ignore<br>
that flag, though maybe someone else has objections.<br>
<font color="#888888"><br>
Roland<br>
</font><div><div></div><div>_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</div></div></blockquote></div><br>