summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Lauffenburger <o.lauffenburger@topsolid.com>2017-07-06 09:08:00 -0600
committerBrian Paul <brianp@vmware.com>2017-07-06 17:25:58 -0600
commit80c6598cdba36edb43d618f97175103e560d61a1 (patch)
treedc957b4ef36a1f035b87dd01b8bcf75bc00a34f7
parentc2a5cb64272da3cd8d97b0a58da6c6992b0417d3 (diff)
st/wgl: improve selection of pixel format
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://bugs.freedesktop.org/show_bug.cgi?id=101703 Signed-off-by: Olivier Lauffenburger <o.lauffenburger@topsolid.com> Tested-by: Brian Paul <brianp@vmware.com> Reviewed-by: Brian Paul <brianp@vmware.com>
-rw-r--r--src/gallium/state_trackers/wgl/stw_pixelformat.c36
1 files 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 7763f71cbc6..833308d964c 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) {