<div class="gmail_quote">On Mon, Mar 7, 2011 at 11:38 AM, Keith Whitwell <span dir="ltr">&lt;<a href="mailto:keithw@vmware.com" target="_blank">keithw@vmware.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">


<div>On Sun, 2011-03-06 at 18:42 +0100, Marek Olšák wrote:<br>
&gt;<br>
&gt; Hi,<br>
&gt;<br>
&gt; I have several questions about Gallium. Some of them are about<br>
&gt; undocumented<br>
&gt; stuff, others are just little things from the top of my head. Please<br>
&gt; consider these as things I may do when time allows.<br>
&gt;<br>
&gt;<br>
&gt; 1) Flush flags<br>
&gt;<br>
&gt; Which PIPE_FLUSH_* flag is used to flush the command stream? There<br>
&gt; doesn&#39;t<br>
&gt; seem to be one and we need it for glFlush.<br>
&gt;<br>
&gt; What is PIPE_FLUSH_FRAME for? To my knowledge, Gallium doesn&#39;t know<br>
&gt; &quot;frames&quot;. What a driver should do when it gets that flag? The same for<br>
&gt; PIPE_FLUSH_SWAPBUFFERS.<br>
&gt;<br>
&gt; I propose replacing the current flags with:<br>
&gt; - PIPE_FLUSH_COMMANDS // flush the command stream<br>
&gt; - PIPE_FLUSH_FRAMEBUFFER_CACHE // flush the write cache of the<br>
&gt; currently-set<br>
&gt; framebuffer<br>
&gt; - PIPE_FLUSH_TEXTURE_CACHE // invalidate the read cache of the<br>
&gt; currently-set<br>
&gt; textures<br>
<br>
</div>I&#39;m not sure if the flags add any value &amp; have been the source of<br>
bugs/confusion in the past.<br>
<br>
How about just removing the parameter?<br></blockquote><div><br>I was thinking the flush cache flags could be used to implement GL_NV_texture_barrier (or we could add another entrypoint for it). I don&#39;t know of any other use, though.<br>


<br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div><br>
&gt;<br>
&gt; 2) is_resource_referenced<br>
&gt;<br>
&gt; Now that the transfer functions are in pipe_context, is this hook<br>
&gt; really<br>
&gt; necessary?<br>
<br>
</div>Good question.  I&#39;d like to see those functions go away as they are<br>
round-trips baked into the interface which is a pain if you try and<br>
remote this stuff.<br>
<br>
I guess you&#39;d still need to catch the write-after-read case within a<br>
single context and turn that into a flush.<br>
<br>
I think others (Jose in particular) should comment, but I suspect that<br>
individual drivers could now do this internally &amp; not need to expose the<br>
interface in gallium.<br></blockquote><div><br>Yes, drivers can do it internally very easily (and st/mesa doesn&#39;t even use is_resource_referenced now).<br><br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">



<div><br>
&gt; 3) fence_signalled and fence_finish<br>
&gt;<br>
&gt; Both of these functions take a driver-specific &quot;flags&quot; parameter<br>
&gt; (according<br>
&gt; to p_screen.h) and return an integer (probably driver-specific too),<br>
&gt; where<br>
&gt; zero means success. Could we either:<br>
&gt; - specify a valid set of arguments for &quot;flags&quot; and the return values,<br>
&gt; - or remove the &quot;flags&quot; parameters and change the return types to<br>
&gt; boolean?<br>
<br>
</div>I&#39;d prefer the latter.<br>
<div><br>
&gt;<br>
&gt; 4) geom_flags in is_format_supported<br>
&gt;<br>
&gt; Not only are these unused by any driver, they also are redundant.<br>
&gt; - PIPE_TEXTURE_GEOM_NON_SQUARE was obsoleted by PIPE_TEXTURE_RECT,<br>
&gt; which can<br>
&gt; be directly passed to is_format_supported.<br>
&gt; - PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO was obsoleted by<br>
&gt; PIPE_CAP_NPOT_TEXTURES.<br>
&gt;<br>
&gt; Could the geom flags be removed?<br>
<br>
</div>This is OK with me too.<br>
<div><div></div><div><br>
&gt; 5) Block compression formats naming<br>
&gt;<br>
&gt; Would anyone object to cleaning up the names of compression formats?<br>
&gt;<br>
&gt; There are (or will be) these formats: DXTn, RGTCn, LATCn, BPTCx. They<br>
&gt; have<br>
&gt; many things in common:<br>
&gt; - All of them have 4x4 pixel blocks.<br>
&gt; - One block is either 64 bits of 128 bits large.<br>
&gt; - RGTC and LATC are equal except for swizzling.<br>
&gt; - RGTC and LATC are based on DXTn encoding.<br>
&gt;<br>
&gt; I propose to copy the more consistent D3D11 naming and use the form<br>
&gt; PIPE_FORMAT_encoding_swizzle_type for all of them:<br>
&gt;<br>
&gt; PIPE_FORMAT_BC1_RGB_UNORM // DXT1 = BC1<br>
&gt; PIPE_FORMAT_BC1_RGB_SRGB<br>
&gt; PIPE_FORMAT_BC1_RGBA_UNORM<br>
&gt; PIPE_FORMAT_BC1_RGBA_SRGB<br>
&gt; PIPE_FORMAT_BC2_RGBA_UNORM // DXT3 = BC2<br>
&gt; PIPE_FORMAT_BC2_RGBA_SRGB<br>
&gt; PIPE_FORMAT_BC3_RGBA_UNORM // DXT5 = BC3<br>
&gt; PIPE_FORMAT_BC3_RGBA_SRGB<br>
&gt; PIPE_FORMAT_BC4_R_UNORM // RGTC1 = BC4<br>
&gt; PIPE_FORMAT_BC4_R_SNORM<br>
&gt; PIPE_FORMAT_BC4_L_UNORM // LATC1 = BC4<br>
&gt; PIPE_FORMAT_BC4_L_SNORM<br>
&gt; PIPE_FORMAT_BC5_RG_UNORM // RGTC2 = D3D/3DC = BC5<br>
&gt; PIPE_FORMAT_BC5_RG_SNORM<br>
&gt; PIPE_FORMAT_BC5_LA_UNORM // LATC2 = GL/3DC = BC5<br>
&gt; PIPE_FORMAT_BC5_LA_SNORM<br>
&gt; PIPE_FORMAT_BC6_RGB_FLOAT // BPTC (BC6H)<br>
&gt; PIPE_FORMAT_BC6_RGB_UFLOAT<br>
&gt; PIPE_FORMAT_BC7_RGBA_UNORM // BPTC<br>
&gt; PIPE_FORMAT_BC7_RGBA_SRGB<br>
&gt;<br>
&gt; The layout for all of them would be UTIL_FORMAT_LAYOUT_BC.<br>
&gt;<br>
&gt; UFLOAT is a float without the sign bit. I guess UFLOAT should be used<br>
&gt; for<br>
&gt; R11G11B10_FLOAT and R9G9B9E5_FLOAT too.<br>
<br>
</div></div>Sounds good again, though this is more Jose&#39;s domain than mine.<br>
<div><br>
&gt; 6) Pixel buffer objects<br>
&gt;<br>
&gt; It woud be nice to have hardware-accelerated PBO copy in Gallium.<br>
&gt; Would<br>
&gt; resource_copy_region be a good candidate for this, where one of the<br>
&gt; arguments would be PIPE_BUFFER and the other one would be<br>
&gt; PIPE_TEXTURE_*, or<br>
&gt; am I missing something?<br>
<br>
</div>Do you have a more concrete proposal?<br>
<br>
For me, it&#39;s always been a bit difficult to pin down what a PBO really<br>
should map to either in hardware or gallium&#39;s abstraction of hardware.<br>
Sometimes it&#39;s a long lived entity (eg. pipe_buffer), other times it&#39;s<br>
just a transient object used for uploads - dma memory from a pool or a<br>
pipe_transfer in gallium.<br>
<br>
But if there&#39;s a sensible addition to gallium that improves the<br>
situation, I&#39;m all for it.<br></blockquote><div><br>A PBO to me is just a way to copy data between a buffer and a texture. Two cases may arise:<br>- The copy can be implemented using util_copy_rect (basically it&#39;s a memcpy with strides), in this case, resource_copy_region could be used to let drivers do the copy in hardware.<br>

- The copy cannot be implemented using util_copy_rect, in this case, the state tracker would use the current software implementation of PBOs.<br><br>Again, another two cases may arise inside resource_copy_region:<br>- If the strides are well aligned, the copy can done in hardware. (what is &quot;well aligned&quot; is hardware-specific)<br>

- If they are not, a util function similar to util_resource_copy_region could be used as a fallback.<br><br>But then resource_copy_region needs to know the stride for the buffer being copied. New entrypoint maybe?<br></div>

</div><br>Marek<br>