Mesa (master): st/wgl: Don't rely on GDI to bookkeep pixelformat for us.

Jose Fonseca jrfonseca at kemper.freedesktop.org
Mon Nov 9 11:30:46 UTC 2015


Module: Mesa
Branch: master
Commit: e524df5ef32fe8fada0695417bd86413d836a6bb
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e524df5ef32fe8fada0695417bd86413d836a6bb

Author: José Fonseca <jfonseca at vmware.com>
Date:   Thu Mar 22 12:16:17 2012 +0000

st/wgl: Don't rely on GDI to bookkeep pixelformat for us.

This allows to use apitrace's retracediff script on Windows to retrace and
compare two builds of a Mesa based opengl32.dll/ICD side-by-side.

See also https://github.com/apitrace/apitrace/commit/e4a4f15f5b92e0abbd24d7d053da25f8278c9f64

---

 src/gallium/state_trackers/wgl/stw_context.c     |    9 +++------
 src/gallium/state_trackers/wgl/stw_framebuffer.c |    4 +++-
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/gallium/state_trackers/wgl/stw_context.c b/src/gallium/state_trackers/wgl/stw_context.c
index 3e99cc4..19f0620 100644
--- a/src/gallium/state_trackers/wgl/stw_context.c
+++ b/src/gallium/state_trackers/wgl/stw_context.c
@@ -160,21 +160,18 @@ stw_create_context_attribs(HDC hdc, INT iLayerPlane, DHGLRC hShareContext,
    if (iLayerPlane != 0)
       return 0;
 
-   iPixelFormat = GetPixelFormat(hdc);
-   if(!iPixelFormat)
-      return 0;
-
    /*
     * GDI only knows about displayable pixel formats, so determine the pixel
     * format from the framebuffer.
     *
-    * TODO: Remove the GetPixelFormat() above, and stop relying on GDI.
+    * This also allows to use a OpenGL DLL / ICD without installing.
     */
    fb = stw_framebuffer_from_hdc( hdc );
    if (fb) {
-      assert(iPixelFormat == fb->iDisplayablePixelFormat);
       iPixelFormat = fb->iPixelFormat;
       stw_framebuffer_release(fb);
+   } else {
+      return 0;
    }
 
    pfi = stw_pixelformat_get_info( iPixelFormat );
diff --git a/src/gallium/state_trackers/wgl/stw_framebuffer.c b/src/gallium/state_trackers/wgl/stw_framebuffer.c
index 7b34fcb..cd8990d 100644
--- a/src/gallium/state_trackers/wgl/stw_framebuffer.c
+++ b/src/gallium/state_trackers/wgl/stw_framebuffer.c
@@ -466,7 +466,9 @@ DrvSetPixelFormat(HDC hdc, LONG iPixelFormat)
     * avoid opengl32.dll's wglCreateContext to fail */
    if (GetPixelFormat(hdc) == 0) {
       BOOL bRet = SetPixelFormat(hdc, iPixelFormat, NULL);
-      assert(bRet);
+      if (!bRet) {
+	  debug_printf("SetPixelFormat failed\n");
+      }
    }
 
    return TRUE;




More information about the mesa-commit mailing list