<div dir="ltr">CC Stephane<div><br></div><div>In my opinion we should not assume sRGB-capable when alpha is requested, because UNORM is the more common use case. I actually have a use case where alpha is requested but not sRGBCapable, and if we assume SRGB by default then we will get really white-washed faded color.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 5, 2016 at 1:52 PM, Ilia Mirkin <span dir="ltr"><<a href="mailto:imirkin@alum.mit.edu" target="_blank">imirkin@alum.mit.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Tue, Apr 5, 2016 at 4:33 PM, Haixia Shi <<a href="mailto:hshi@chromium.org">hshi@chromium.org</a>> wrote:<br>
> It is incorrect to assume that pixel format is always in BGR byte order.<br>
> We need to check bitmask parameters (such as |redMask|) to determine whether<br>
> the RGB or BGR byte order is requested.<br>
><br>
> Furthermore when parameter |sRGBCapable| is set to false, we should be using<br>
> UNORM format by default.<br>
<br>
</span>Unfortunately none of the visuals are exported with that flag, so it<br>
will always be false in practice. The current logic is also very<br>
fragile -- you only get a sRGB-capable fb if you happen to request<br>
alpha.<br>
<div><div class="h5"><br>
><br>
> v2: reformat code to stay within 80 character per line limit.<br>
><br>
> Signed-off-by: Haixia Shi <<a href="mailto:hshi@chromium.org">hshi@chromium.org</a>><br>
> Reviewed-by: Stéphane Marchesin <<a href="mailto:marcheu@chromium.org">marcheu@chromium.org</a>><br>
> Cc: <a href="mailto:kenneth.w.graunke@intel.com">kenneth.w.graunke@intel.com</a><br>
><br>
> Change-Id: Ib75087aef1fbfb51baa72517207fed410dcd7b1e<br>
> ---<br>
> src/mesa/drivers/dri/i965/intel_screen.c | 20 ++++++++++++--------<br>
> 1 file changed, 12 insertions(+), 8 deletions(-)<br>
><br>
> diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c<br>
> index c6eb50a..a27d7ee 100644<br>
> --- a/src/mesa/drivers/dri/i965/intel_screen.c<br>
> +++ b/src/mesa/drivers/dri/i965/intel_screen.c<br>
> @@ -1000,15 +1000,19 @@ intelCreateBuffer(__DRIscreen * driScrnPriv,<br>
> fb->Visual.samples = num_samples;<br>
> }<br>
><br>
> - if (mesaVis->redBits == 5)<br>
> - rgbFormat = MESA_FORMAT_B5G6R5_UNORM;<br>
> - else if (mesaVis->sRGBCapable)<br>
> - rgbFormat = MESA_FORMAT_B8G8R8A8_SRGB;<br>
> - else if (mesaVis->alphaBits == 0)<br>
> - rgbFormat = MESA_FORMAT_B8G8R8X8_UNORM;<br>
> - else {<br>
> - rgbFormat = MESA_FORMAT_B8G8R8A8_SRGB;<br>
> + if (mesaVis->redBits == 5) {<br>
> + rgbFormat = mesaVis->redMask == 0x1f ? MESA_FORMAT_R5G6B5_UNORM<br>
> + : MESA_FORMAT_B5G6R5_UNORM;<br>
> + } else if (mesaVis->alphaBits == 0) {<br>
> + rgbFormat = mesaVis->redMask == 0xff ? MESA_FORMAT_R8G8B8X8_UNORM<br>
> + : MESA_FORMAT_B8G8R8X8_UNORM;<br>
> + } else if (mesaVis->sRGBCapable) {<br>
> + rgbFormat = mesaVis->redMask == 0xff ? MESA_FORMAT_R8G8B8A8_SRGB<br>
> + : MESA_FORMAT_B8G8R8A8_SRGB;<br>
> fb->Visual.sRGBCapable = true;<br>
> + } else {<br>
> + rgbFormat = mesaVis->redMask == 0xff ? MESA_FORMAT_R8G8B8A8_UNORM<br>
> + : MESA_FORMAT_B8G8R8A8_UNORM;<br>
> }<br>
><br>
> /* setup the hardware-based renderbuffers */<br>
> --<br>
> 2.8.0.rc3.226.g39d4020<br>
><br>
</div></div>> _______________________________________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div><br></div>