<div dir="ltr">Hi Merek,<div><pre style="margin-top:0px;margin-bottom:0px"><font face="arial"><span style="white-space:normal"> </span></font></pre></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jan 22, 2014 at 2:49 PM, Marek Olšák <span dir="ltr"><<a href="mailto:maraeo@gmail.com" target="_blank">maraeo@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi Mark,<br>
<br>
Could you please mention or document somewhere in the code (e.g. in<br>
main/formats.h) which _REV formats are incorrect according to you?<br>
Sorry if you did so already, I haven't read your other patches yet.<br>
<br></blockquote><div><br></div><div>There was not a universally correct solution for some of the _REV MESA_FORMATs thus I defaulted to the OGL definition of _REV when eliminating the _REV decoration. For the examples below, MESA_FORMAT's use of _REV sometimes differs from what is described in the OGL pixel transfer doc, which says the following about GL_UNSIGNED_SHORT_5_6_5, for example:</div>
<div>"This can have a _REV​ at the end of it. This would mean to reverse the order of the components in the data. In "REV" mode, the first component, the one that matches the first 5, would go into the last component specified by the format​." </div>
<div><br></div><div>Using _REV with MESA_FORMATs to have a big and little endian representation of a format agrees with the OGL definition most of the time but not for formats where each color components isn't equally divided on a byte boundary: </div>
<div><br></div><div><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">   </span><span style="color:rgb(128,0,128)">MESA_FORMAT_RGB565</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(192,192,192)">             </span><span style="color:rgb(0,128,0)">/*</span><span style="color:rgb(192,192,192)">                     </span><span style="color:rgb(0,128,0)">RRRR</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">RGGG</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">GGGB</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">BBBB</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">*/</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">   </span><span style="color:rgb(128,0,128)">MESA_FORMAT_RGB565_REV</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(192,192,192)">     </span><span style="color:rgb(0,128,0)">/*</span><span style="color:rgb(192,192,192)">                     </span><span style="color:rgb(0,128,0)">GGGB</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">BBBB</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">RRRR</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">RGGG</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">*/</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">   </span><span style="color:rgb(128,0,128)">MESA_FORMAT_ARGB4444</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(192,192,192)">       </span><span style="color:rgb(0,128,0)">/*</span><span style="color:rgb(192,192,192)">                     </span><span style="color:rgb(0,128,0)">AAAA</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">RRRR</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">GGGG</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">BBBB</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">*/</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">   </span><span style="color:rgb(128,0,128)">MESA_FORMAT_ARGB4444_REV</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(192,192,192)">   </span><span style="color:rgb(0,128,0)">/*</span><span style="color:rgb(192,192,192)">                     </span><span style="color:rgb(0,128,0)">GGGG</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">BBBB</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">AAAA</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">RRRR</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">*/</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">   </span><span style="color:rgb(128,0,128)">MESA_FORMAT_RGBA5551</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(192,192,192)">        </span><span style="color:rgb(0,128,0)">/*</span><span style="color:rgb(192,192,192)">                     </span><span style="color:rgb(0,128,0)">RRRR</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">RGGG</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">GGBB</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">BBBA</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">*/</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">   </span><span style="color:rgb(128,0,128)">MESA_FORMAT_ARGB1555</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(192,192,192)">       </span><span style="color:rgb(0,128,0)">/*</span><span style="color:rgb(192,192,192)">                     </span><span style="color:rgb(0,128,0)">ARRR</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">RRGG</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">GGGB</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">BBBB</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">*/</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">   </span><span style="color:rgb(128,0,128)">MESA_FORMAT_ARGB1555_REV</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(192,192,192)">   </span><span style="color:rgb(0,128,0)">/*</span><span style="color:rgb(192,192,192)">                     </span><span style="color:rgb(0,128,0)">GGGB</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">BBBB</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">ARRR</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">RRGG</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">*/</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px"><font face="arial"><span style="white-space:normal">Searching all of Mesa for the above _REV formats reveals few hits within the drivers that are actually employing the endianess interpretation of _REV, vs the OGL interpretation. For example radeon_screen.c:</span></font></pre>
<pre style="margin-top:0px;margin-bottom:0px"><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">        </span><span style="color:rgb(0,0,0)">rgbFormat</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)">_mesa_little_endian</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><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">MESA_FORMAT_RGB565</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(128,0,128)">MESA_FORMAT_RGB565_REV</span><span style="color:rgb(0,0,0)">;</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre></pre><pre style="margin-top:0px;margin-bottom:0px"><font face="arial"><span style="white-space:normal">vs radeon_pixel_read.c</span></font></pre><pre style="margin-top:0px;margin-bottom:0px">
<pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:arial;color:rgb(192,192,192)">                </span><span style="font-family:arial;color:rgb(128,128,0)">case</span><span style="font-family:arial;color:rgb(192,192,192)"> </span><span style="font-family:arial;color:rgb(0,0,128)">GL_UNSIGNED_SHORT_5_6_5</span><span style="font-family:arial;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(128,128,0)">return</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">MESA_FORMAT_RGB565</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(128,128,0)">case</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">GL_UNSIGNED_SHORT_5_6_5_REV</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(128,128,0)">return</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">MESA_FORMAT_RGB565_REV</span><span style="color:rgb(0,0,0)">;</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><font face="arial"><span style="white-space:normal"><br></span></font></pre><pre style="margin-top:0px;margin-bottom:0px"><font face="arial"><span style="white-space:normal">In many of the cases that rely on the endianess interpretation,  the _REV decoration is ignored anyway.</span></font></pre>
<pre style="margin-top:0px;margin-bottom:0px"><font face="arial"><span style="white-space:normal"><br></span></font></pre><pre style="margin-top:0px;margin-bottom:0px"><font face="arial"><span style="white-space:normal">So, based on your request, I should add a comment above the applicable format_unpack and format pack functions that says "this function does not match the current Mesa definition of <insert format here>". Is that acceptable? With the latest patch set I just buried my head in the sand on this one.</span></font></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px"><font face="arial"><span style="white-space:normal"><br></span></font></pre></pre></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

Also, I have a proposal for SRGB formats. MESA_FORMAT_SRGB_UNORM8 and<br>
MESA_FORMAT_SA8B8G8R8_UNORM<br>
look weird, because they are not really UNORM and there is also no<br>
stencil. :) How about this: MESA_FORMAT_RGB_SRGB8 (denoting an array<br>
format of the SRGB type and 8 bits per channel) and<br>
MESA_FORMAT_A8B8G8R8_SRGB (denoting a packed format of the SRGB type).<br></blockquote><div><br></div><div>I agree it could be better. My reasoning for avoiding what you suggested is that it creates an ambiguity between color information and storage type. For instance, sRBG color space values could feasibly be stored as floats, half floats, snorms, or unorms, could they not? Thus the S is a color component modifier, not storage type. Would it be too awkward to use M for stencil mask instead of S? Is there a clearer method that doesn't hide storage type information?</div>
<div><br></div><div> Mark</div></div></div></div>