From 87c5589605271fd9c875fbf5ab5a8a31db243672 Mon Sep 17 00:00:00 2001 From: Jesse Natalie Date: Tue, 31 Oct 2023 14:00:55 -0700 Subject: [PATCH] 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 Reviewed-by: Neha Bhende Part-of: --- 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;