Module: Mesa Branch: main Commit: 87c5589605271fd9c875fbf5ab5a8a31db243672 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=87c5589605271fd9c875fbf5ab5a8a31db243672
Author: Jesse Natalie <[email protected]> Date: Tue Oct 31 14:00:55 2023 -0700 wgl: Take pixelformat color channels into account for choosing a PFD Otherwise there's no way to target PIPE_FORMAT_B4G4R4A4_UNORM instead of the B5G6R5 or B5G5R5A1 if those are supported. This gets the behavior closer to the Windows PFD selection. Reviewed-by: Jose Fonseca <[email protected]> Reviewed-by: Neha Bhende <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25979> --- src/gallium/frontends/wgl/stw_pixelformat.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/gallium/frontends/wgl/stw_pixelformat.c b/src/gallium/frontends/wgl/stw_pixelformat.c index 16d00707dde..461e11a5b1e 100644 --- a/src/gallium/frontends/wgl/stw_pixelformat.c +++ b/src/gallium/frontends/wgl/stw_pixelformat.c @@ -531,7 +531,6 @@ stw_pixelformat_choose(HDC hdc, CONST PIXELFORMATDESCRIPTOR *ppfd) * - Giving no more bits than requested is given lowest priority. */ - /* FIXME: Take in account individual channel bits */ if (ppfd->cColorBits && !pfi->pfd.cColorBits) delta += 10000; else if (ppfd->cColorBits > pfi->pfd.cColorBits) @@ -560,6 +559,27 @@ stw_pixelformat_choose(HDC hdc, CONST PIXELFORMATDESCRIPTOR *ppfd) else if (ppfd->cAlphaBits < pfi->pfd.cAlphaBits) delta++; + if (ppfd->cRedBits && !pfi->pfd.cRedBits) + delta += 10000; + else if (ppfd->cRedBits > pfi->pfd.cRedBits) + delta += 100; + else if (ppfd->cRedBits < pfi->pfd.cRedBits) + delta++; + + if (ppfd->cGreenBits && !pfi->pfd.cGreenBits) + delta += 10000; + else if (ppfd->cGreenBits > pfi->pfd.cGreenBits) + delta += 100; + else if (ppfd->cGreenBits < pfi->pfd.cGreenBits) + delta++; + + if (ppfd->cBlueBits && !pfi->pfd.cBlueBits) + delta += 10000; + else if (ppfd->cBlueBits > pfi->pfd.cBlueBits) + delta += 100; + else if (ppfd->cBlueBits < pfi->pfd.cBlueBits) + delta++; + if (delta < bestdelta) { bestindex = index; bestdelta = delta;
