[Mesa-stable] [Mesa-dev] [PATCH] gallium: improve selection of pixel format
Brian Paul
brianp at vmware.com
Sun Jul 9 20:09:27 UTC 2017
Fine by me.
-Brian
On 07/08/2017 02:07 PM, Andres Gomez wrote:
> Olivier, Brian, do we want this into -stable?
>
> On Thu, 2017-07-06 at 17:08 +0200, Olivier Lauffenburger wrote:
>> Current selection of pixel format does not enforce the request of
>> stencil or depth buffer if the color depth is not the same as
>> requested.
>> For instance, GLUT requests a 32-bit color buffer with an 8-bit
>> stencil buffer, but because color buffers are only 24-bit, no
>> priority is given to creating a stencil buffer.
>>
>> This patch gives more priority to the creation of requested buffers
>> and less priority to the difference in bit depth.
>>
>> Bugzilla: https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.freedesktop.org_show-5Fbug.cgi-3Fid-3D101703&d=DwICaQ&c=uilaK90D4TOVoH58JNXRgQ&r=Ie7_encNUsqxbSRbqbNgofw0ITcfE8JKfaUjIQhncGA&m=XntoSWqo66V6e3XageiwVIojKjh0lIwmsgkNzpG9j-c&s=u7cWNhxdwRY1GObOrc6fmSOEOwqx_6ixsmw93jteRCk&e=
>>
>> Signed-off-by: Olivier Lauffenburger <o.lauffenburger at topsolid.com>
>> ---
>> src/gallium/state_trackers/wgl/stw_pixelformat.c | 36 +++++++++++++++++++-----
>> 1 file changed, 29 insertions(+), 7 deletions(-)
>>
>> diff --git a/src/gallium/state_trackers/wgl/stw_pixelformat.c b/src/gallium/state_trackers/wgl/stw_pixelformat.c
>> index 7763f71cbc..833308d964 100644
>> --- a/src/gallium/state_trackers/wgl/stw_pixelformat.c
>> +++ b/src/gallium/state_trackers/wgl/stw_pixelformat.c
>> @@ -432,17 +432,39 @@ stw_pixelformat_choose(HDC hdc, CONST PIXELFORMATDESCRIPTOR *ppfd)
>> !!(pfi->pfd.dwFlags & PFD_DOUBLEBUFFER))
>> continue;
>>
>> - /* FIXME: Take in account individual channel bits */
>> - if (ppfd->cColorBits != pfi->pfd.cColorBits)
>> - delta += 8;
>> + /* Selection logic:
>> + * - Enabling a feature (depth, stencil...) is given highest priority.
>> + * - Giving as many bits as requested is given medium priority.
>> + * - Giving no more bits than requested is given lowest priority.
>> + */
>>
>> - if (ppfd->cDepthBits != pfi->pfd.cDepthBits)
>> - delta += 4;
>> + /* FIXME: Take in account individual channel bits */
>> + if (ppfd->cColorBits && !pfi->pfd.cColorBits)
>> + delta += 10000;
>> + else if (ppfd->cColorBits > pfi->pfd.cColorBits)
>> + delta += 100;
>> + else if (ppfd->cColorBits < pfi->pfd.cColorBits)
>> + delta++;
>>
>> - if (ppfd->cStencilBits != pfi->pfd.cStencilBits)
>> + if (ppfd->cDepthBits && !pfi->pfd.cDepthBits)
>> + delta += 10000;
>> + else if (ppfd->cDepthBits > pfi->pfd.cDepthBits)
>> + delta += 200;
>> + else if (ppfd->cDepthBits < pfi->pfd.cDepthBits)
>> delta += 2;
>>
>> - if (ppfd->cAlphaBits != pfi->pfd.cAlphaBits)
>> + if (ppfd->cStencilBits && !pfi->pfd.cStencilBits)
>> + delta += 10000;
>> + else if (ppfd->cStencilBits > pfi->pfd.cStencilBits)
>> + delta += 400;
>> + else if (ppfd->cStencilBits < pfi->pfd.cStencilBits)
>> + delta++;
>> +
>> + if (ppfd->cAlphaBits && !pfi->pfd.cAlphaBits)
>> + delta += 10000;
>> + else if (ppfd->cAlphaBits > pfi->pfd.cAlphaBits)
>> + delta += 100;
>> + else if (ppfd->cAlphaBits < pfi->pfd.cAlphaBits)
>> delta++;
>>
>> if (delta < bestdelta) {
More information about the mesa-stable
mailing list