Merge branch 'llvm-cliptest-viewport'
[mesa.git] / src / gallium / state_trackers / dri / common / dri_screen.c
index 81523b82ba9efcab74dd13a6f9dc1d6e8d7f9efd..252ad1768d80d89fc0b5140758711794764611fd 100644 (file)
  */
 
 #include "utils.h"
-#ifndef __NOT_HAVE_DRM_H
-#include "vblank.h"
-#endif
 #include "xmlpool.h"
 
 #include "dri_screen.h"
-#include "dri_context.h"
-#include "dri_drawable.h"
-#include "dri1_helper.h"
-#ifndef __NOT_HAVE_DRM_H
-#include "dri1.h"
-#include "dri2.h"
-#else
-#include "drisw.h"
-#endif
 
 #include "util/u_inlines.h"
 #include "pipe/p_screen.h"
@@ -239,7 +227,7 @@ dri_fill_in_modes(struct dri_screen *screen,
  */
 void
 dri_fill_st_visual(struct st_visual *stvis, struct dri_screen *screen,
-                   const __GLcontextModes *mode)
+                   const struct gl_config *mode)
 {
    memset(stvis, 0, sizeof(*stvis));
 
@@ -296,33 +284,16 @@ dri_fill_st_visual(struct st_visual *stvis, struct dri_screen *screen,
    /* let the state tracker allocate the accum buffer */
 }
 
-#ifndef __NOT_HAVE_DRM_H
-
-/**
- * Get information about previous buffer swaps.
- */
-static int
-dri_get_swap_info(__DRIdrawable * dPriv, __DRIswapInfo * sInfo)
-{
-   if (dPriv == NULL || dPriv->driverPrivate == NULL || sInfo == NULL)
-      return -1;
-   else
-      return 0;
-}
-
-#endif
-
 static boolean
 dri_get_egl_image(struct st_manager *smapi,
-                             struct st_egl_image *stimg)
+                  void *egl_image,
+                  struct st_egl_image *stimg)
 {
-   struct dri_context *ctx =
-      (struct dri_context *)stimg->stctxi->st_manager_private;
-   struct dri_screen *screen = dri_screen(ctx->sPriv);
+   struct dri_screen *screen = (struct dri_screen *)smapi;
    __DRIimage *img = NULL;
 
    if (screen->lookup_egl_image) {
-      img = screen->lookup_egl_image(ctx, stimg->egl_image);
+      img = screen->lookup_egl_image(screen, egl_image);
    }
 
    if (!img)
@@ -337,6 +308,20 @@ dri_get_egl_image(struct st_manager *smapi,
    return TRUE;
 }
 
+static int
+dri_get_param(struct st_manager *smapi,
+              enum st_manager_param param)
+{
+   struct dri_screen *screen = (struct dri_screen *)smapi;
+
+   switch(param) {
+   case ST_MANAGER_BROKEN_INVALIDATE:
+      return screen->broken_invalidate;
+   default:
+      return 0;
+   }
+}
+
 static void
 dri_destroy_option_cache(struct dri_screen * screen)
 {
@@ -356,8 +341,6 @@ dri_destroy_option_cache(struct dri_screen * screen)
 void
 dri_destroy_screen_helper(struct dri_screen * screen)
 {
-   dri1_destroy_pipe_context(screen);
-
    if (screen->st_api && screen->st_api->destroy)
       screen->st_api->destroy(screen->st_api);
 
@@ -367,7 +350,7 @@ dri_destroy_screen_helper(struct dri_screen * screen)
    dri_destroy_option_cache(screen);
 }
 
-static void
+void
 dri_destroy_screen(__DRIscreen * sPriv)
 {
    struct dri_screen *screen = dri_screen(sPriv);
@@ -391,49 +374,21 @@ dri_init_screen_helper(struct dri_screen *screen,
    }
 
    screen->base.get_egl_image = dri_get_egl_image;
-   screen->st_api = st_gl_api_create();
+   screen->base.get_param = dri_get_param;
 
+   screen->st_api = st_gl_api_create();
    if (!screen->st_api)
       return NULL;
 
+   if(pscreen->get_param(pscreen, PIPE_CAP_NPOT_TEXTURES))
+      screen->target = PIPE_TEXTURE_2D;
+   else
+      screen->target = PIPE_TEXTURE_RECT;
+
    driParseOptionInfo(&screen->optionCache,
                       __driConfigOptions, __driNConfigOptions);
 
    return dri_fill_in_modes(screen, pixel_bits);
 }
 
-/**
- * DRI driver virtual function table.
- *
- * DRI versions differ in their implementation of init_screen and swap_buffers.
- */
-const struct __DriverAPIRec driDriverAPI = {
-   .DestroyScreen = dri_destroy_screen,
-   .CreateContext = dri_create_context,
-   .DestroyContext = dri_destroy_context,
-   .CreateBuffer = dri_create_buffer,
-   .DestroyBuffer = dri_destroy_buffer,
-   .MakeCurrent = dri_make_current,
-   .UnbindContext = dri_unbind_context,
-
-#ifndef __NOT_HAVE_DRM_H
-
-   .GetSwapInfo = dri_get_swap_info,
-   .GetDrawableMSC = driDrawableGetMSC32,
-   .WaitForMSC = driWaitForMSC32,
-   .InitScreen2 = dri2_init_screen,
-
-   .InitScreen = dri1_init_screen,
-   .SwapBuffers = dri1_swap_buffers,
-   .CopySubBuffer = dri1_copy_sub_buffer,
-
-#else
-
-   .InitScreen = drisw_init_screen,
-   .SwapBuffers = drisw_swap_buffers,
-
-#endif
-
-};
-
 /* vim: set sw=3 ts=8 sts=3 expandtab: */