<div class="gmail_quote">On Mon, May 3, 2010 at 1:57 PM, José Fonseca <span dir="ltr">&lt;<a href="mailto:jfonseca@vmware.com">jfonseca@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 class="im">On Mon, 2010-05-03 at 01:36 -0700, Xavier Chantry wrote:<br>
&gt; I am trying to understand the s3tc init code as nv50 gallium has a<br>
&gt; problem with that.<br>
&gt;<br>
&gt; It looks like some drivers (r300g and llvmpipe) actually inits s3tc in<br>
&gt; two places :<br>
&gt; ./src/mesa/main/texcompress_s3tc.c _mesa_init_texture_s3tc()<br>
&gt; ./src/gallium/auxiliary/util/u_format_s3tc.c util_format_s3tc_init()<br>
&gt;<br>
&gt; Here is an extract of the backtrace calls while loading fgfs on llvmpipe :<br>
&gt; driCreateScreen -&gt; llvmpipe_create_screen -&gt; util_format_s3tc_init<br>
&gt; driCreateContext -&gt; st_create_context -&gt; _mesa_create_context_for_api<br>
&gt; -&gt; init_attrib_groups -&gt; _mesa_init_texture_s3tc<br>
&gt;<br>
&gt; These two functions seem to do more or less the same job, and<br>
&gt; apparently, the classic mesa init is unused for a gallium driver.<br>
&gt; So I suppose that init is not necessary, but it happens because<br>
&gt; gallium and mesa are tightly tied together, and create context is<br>
&gt; handled similarly, but it shouldn&#39;t hurt ?<br>
<br>
</div>Both inits are necessary. The same .so is used for both paths, but given<br>
that gallium and mesa do not depend on each other that&#39;s the way to do<br>
it. Gallium and mesa also have seperate format translation functions.<br>
<br>
At least until we start factoring code into a separate library. (I said<br>
I&#39;d do it, but stuff came up and I couldn&#39;t do when I thought, and I<br>
don&#39;t know when I&#39;ll be able to do it...)<br>
<div><div></div><div class="h5"><br>
&gt; Additionally r300g and llvmpipe added util_format_s3tc_init to their<br>
&gt; create_screen functions, and util/u_format_s3tc.c apparently contains<br>
&gt; all the functions that a gallium driver uses.<br>
&gt; So I suppose that nvfx and nv50 should do the same ?<br>
&gt;<br>
&gt; If that&#39;s correct, the patch below might not be completely wrong.<br>
&gt;<br>
&gt; On Mon, May 3, 2010 at 12:44 AM, Xavier Chantry<br>
&gt; &lt;<a href="mailto:chantry.xavier@gmail.com">chantry.xavier@gmail.com</a>&gt; wrote:<br>
&gt; &gt; flightgear now dies with :<br>
&gt; &gt; Mesa warning: external dxt library not available: texstore_rgba_dxt3<br>
&gt; &gt; util/u_format_s3tc.c:66:util_format_dxt3_rgba_fetch_stub: Assertion `0&#39; failed.<br>
&gt; &gt;<br>
&gt; &gt; I don&#39;t really understand what these stubs are about, they were<br>
&gt; &gt; introduced by following commit :<br>
&gt; &gt; commit d96e87c3c513f8ed350ae24425edb74b6d6fcc13<br>
&gt; &gt; Author: José Fonseca &lt;<a href="mailto:jfonseca@vmware.com">jfonseca@vmware.com</a>&gt;<br>
&gt; &gt; Date:   Wed Apr 7 20:47:38 2010 +0100<br>
&gt; &gt;<br>
&gt; &gt;    util: Use stubs for the dynamically loaded S3TC functions.<br>
&gt; &gt;<br>
&gt; &gt;    Loosely based on Luca Barbieri&#39;s commit<br>
&gt; &gt;    52e9b990a192a9329006d5f7dd2ac222effea5a5.<br>
&gt; &gt;<br>
&gt; &gt; Looking at llvm and r300 code and trying to guess, I came up with the<br>
&gt; &gt; following patch that allows flightgear to start again. But I don&#39;t<br>
&gt; &gt; really understand that stuff so it could be wrong.<br>
&gt; &gt; nvfx is probably affected as well.<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c<br>
&gt; &gt; b/src/gallium/drivers/nouveau/nouveau_screen.c<br>
&gt; &gt; index 233a91a..a91b00b 100644<br>
&gt; &gt; --- a/src/gallium/drivers/nouveau/nouveau_screen.c<br>
&gt; &gt; +++ b/src/gallium/drivers/nouveau/nouveau_screen.c<br>
&gt; &gt; @@ -5,6 +5,7 @@<br>
&gt; &gt;  #include &quot;util/u_memory.h&quot;<br>
&gt; &gt;  #include &quot;util/u_inlines.h&quot;<br>
&gt; &gt;  #include &quot;util/u_format.h&quot;<br>
&gt; &gt; +#include &quot;util/u_format_s3tc.h&quot;<br>
&gt; &gt;<br>
&gt; &gt;  #include &lt;stdio.h&gt;<br>
&gt; &gt;  #include &lt;errno.h&gt;<br>
&gt; &gt; @@ -248,6 +249,8 @@ nouveau_screen_init(struct nouveau_screen *screen,<br>
&gt; &gt; struct nouveau_device *dev)<br>
&gt; &gt;        pscreen-&gt;fence_signalled = nouveau_screen_fence_signalled;<br>
&gt; &gt;        pscreen-&gt;fence_finish = nouveau_screen_fence_finish;<br>
&gt; &gt;<br>
&gt; &gt; +       util_format_s3tc_init();<br>
&gt; &gt; +<br>
&gt; &gt;        return 0;<br>
&gt; &gt;  }<br>
&gt; &gt;<br>
&gt; &gt; diff --git a/src/gallium/drivers/nv50/nv50_screen.c<br>
&gt; &gt; b/src/gallium/drivers/nv50/nv50_screen.c<br>
&gt; &gt; index 2dd1042..0d74c90 100644<br>
&gt; &gt; --- a/src/gallium/drivers/nv50/nv50_screen.c<br>
&gt; &gt; +++ b/src/gallium/drivers/nv50/nv50_screen.c<br>
&gt; &gt; @@ -20,6 +20,7 @@<br>
&gt; &gt;  * SOFTWARE.<br>
&gt; &gt;  */<br>
&gt; &gt;<br>
&gt; &gt; +#include &quot;util/u_format_s3tc.h&quot;<br>
&gt; &gt;  #include &quot;pipe/p_screen.h&quot;<br>
&gt; &gt;<br>
&gt; &gt;  #include &quot;nv50_context.h&quot;<br>
&gt; &gt; @@ -72,10 +73,6 @@ nv50_screen_is_format_supported(struct pipe_screen *pscreen,<br>
&gt; &gt;                case PIPE_FORMAT_A8_UNORM:<br>
&gt; &gt;                case PIPE_FORMAT_I8_UNORM:<br>
&gt; &gt;                case PIPE_FORMAT_L8A8_UNORM:<br>
&gt; &gt; -               case PIPE_FORMAT_DXT1_RGB:<br>
&gt; &gt; -               case PIPE_FORMAT_DXT1_RGBA:<br>
&gt; &gt; -               case PIPE_FORMAT_DXT3_RGBA:<br>
&gt; &gt; -               case PIPE_FORMAT_DXT5_RGBA:<br>
&gt; &gt;                case PIPE_FORMAT_S8_USCALED_Z24_UNORM:<br>
&gt; &gt;                case PIPE_FORMAT_Z24_UNORM_S8_USCALED:<br>
&gt; &gt;                case PIPE_FORMAT_Z32_FLOAT:<br>
&gt; &gt; @@ -85,6 +82,11 @@ nv50_screen_is_format_supported(struct pipe_screen *pscreen,<br>
&gt; &gt;                case PIPE_FORMAT_R16G16_SNORM:<br>
&gt; &gt;                case PIPE_FORMAT_R16G16_UNORM:<br>
&gt; &gt;                        return TRUE;<br>
&gt; &gt; +               case PIPE_FORMAT_DXT1_RGB:<br>
&gt; &gt; +               case PIPE_FORMAT_DXT1_RGBA:<br>
&gt; &gt; +               case PIPE_FORMAT_DXT3_RGBA:<br>
&gt; &gt; +               case PIPE_FORMAT_DXT5_RGBA:<br>
&gt; &gt; +                       return util_format_s3tc_enabled;<br>
&gt; &gt;                default:<br>
&gt; &gt;                        break;<br>
&gt; &gt;                }<br>
&gt; &gt;<br>
<br>
</div></div>You should only advertise PIPE_FORMAT_DXT* for BIND_SAMPLER_VIEW, or you<br>
may end up in very weird paths. Same for YUV.<br></blockquote></div><br>I think my hw supports rendering to YUV textures, it&#39;s been even implemented in r300g but not tested. I am not sure who&#39;s gonna use such a feature. Should I disable it then?<br>

<br>-Marek<br>