st/dri: implement the fence interface
[mesa.git] / src / gallium / state_trackers / wgl / stw_device.c
index 4ece4e4979abb3ed4a6cadeb45aab87915653ee0..25b6341ecad4c24006b75ffddc3341e4ccacd77e 100644 (file)
@@ -1,6 +1,6 @@
 /**************************************************************************
  *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2008 VMware, Inc.
  * All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -18,7 +18,7 @@
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -41,8 +41,6 @@
 #include "stw_framebuffer.h"
 #include "stw_st.h"
 
-extern _glthread_Mutex OneTimeLock;
-
 
 struct stw_device *stw_dev = NULL;
 
@@ -50,7 +48,19 @@ static int
 stw_get_param(struct st_manager *smapi,
               enum st_manager_param param)
 {
-   return 0;
+   switch (param) {
+   case ST_MANAGER_BROKEN_INVALIDATE:
+      /*
+       * Force framebuffer validation on glViewport.
+       *
+       * Certain applications, like Rhinoceros 4, uses glReadPixels
+       * exclusively (never uses SwapBuffers), so framebuffers never get
+       * resized unless we check on glViewport.
+       */
+      return 1;
+   default:
+      return 0;
+   }
 }
 
 boolean
@@ -59,6 +69,8 @@ stw_init(const struct stw_winsys *stw_winsys)
    static struct stw_device stw_dev_storage;
    struct pipe_screen *screen;
 
+   debug_disable_error_message_boxes();
+
    debug_printf("%s\n", __FUNCTION__);
    
    assert(!stw_dev);
@@ -74,8 +86,6 @@ stw_init(const struct stw_winsys *stw_winsys)
    
    stw_dev->stw_winsys = stw_winsys;
 
-   _glthread_INIT_MUTEX(OneTimeLock);
-
    stw_dev->stapi = stw_st_create_api();
    stw_dev->smapi = CALLOC_STRUCT(st_manager);
    if (!stw_dev->stapi || !stw_dev->smapi)
@@ -109,8 +119,7 @@ stw_init(const struct stw_winsys *stw_winsys)
    return TRUE;
 
 error1:
-   if (stw_dev->smapi)
-      FREE(stw_dev->smapi);
+   FREE(stw_dev->smapi);
    if (stw_dev->stapi)
       stw_dev->stapi->destroy(stw_dev->stapi);
 
@@ -168,8 +177,6 @@ stw_cleanup(void)
 
    stw_dev->screen->destroy(stw_dev->screen);
 
-   _glthread_DESTROY_MUTEX(OneTimeLock);
-
    /* glapi is statically linked: we can call the local destroy function. */
 #ifdef _GLAPI_NO_EXPORTS
    _glapi_destroy_multithread();
@@ -185,19 +192,6 @@ stw_cleanup(void)
 }
 
 
-struct stw_context *
-stw_lookup_context_locked( DHGLRC dhglrc )
-{
-   if (dhglrc == 0)
-      return NULL;
-
-   if (stw_dev == NULL)
-      return NULL;
-
-   return (struct stw_context *) handle_table_get(stw_dev->ctx_table, dhglrc);
-}
-
-
 void APIENTRY
 DrvSetCallbackProcs(
    INT nProcs,
@@ -219,6 +213,14 @@ BOOL APIENTRY
 DrvValidateVersion(
    ULONG ulVersion )
 {
-   /* TODO: get the expected version from the winsys */
-   return ulVersion == 1;
+   /* ulVersion is the version reported by the KMD:
+    * - via D3DKMTQueryAdapterInfo(KMTQAITYPE_UMOPENGLINFO) on WDDM,
+    * - or ExtEscape on XPDM and can be used to ensure the KMD and OpenGL ICD
+    *   versions match.
+    *
+    * We should get the expected version number from the winsys, but for now
+    * ignore it.
+    */
+   (void)ulVersion;
+   return TRUE;
 }