mesa: remove Driver.ResizeBuffers
[mesa.git] / src / mesa / drivers / dri / common / dri_util.h
index e016a238dcadf180894c1cb1f50593d6744ece76..6987f555e6623c6b4bd9a486f99713ce846a1743 100644 (file)
  * \author Brian Paul <brian@precisioninsight.com>
  */
 
+/**
+ * The following structs are shared between DRISW and DRI2, the DRISW structs
+ * are essentially base classes of the DRI2 structs. DRISW needs to compile on
+ * platforms without DRM, so keep the structs opaque to DRM.
+ */
+
 #ifndef _DRI_UTIL_H_
 #define _DRI_UTIL_H_
 
 #include <GL/gl.h>
-#include <drm.h>
-#include <drm_sarea.h>
-#include <xf86drm.h>
-#include "xmlconfig.h"
-#include "main/glheader.h"
+#include <GL/internal/dri_interface.h>
 #include "main/mtypes.h"
-#include "GL/internal/dri_interface.h"
-
-#define GLX_BAD_CONTEXT                    5
+#include "xmlconfig.h"
+#include <stdbool.h>
 
 /**
  * Extensions.
  */
 extern const __DRIcoreExtension driCoreExtension;
+extern const __DRIswrastExtension driSWRastExtension;
 extern const __DRIdri2Extension driDRI2Extension;
 extern const __DRI2configQueryExtension dri2ConfigQueryExtension;
-
+extern const __DRIcopySubBufferExtension driCopySubBufferExtension;
 /**
  * Driver callback functions.
  *
@@ -78,151 +80,108 @@ extern const __DRI2configQueryExtension dri2ConfigQueryExtension;
 struct __DriverAPIRec {
     const __DRIconfig **(*InitScreen) (__DRIscreen * priv);
 
-    /**
-     * Screen destruction callback
-     */
     void (*DestroyScreen)(__DRIscreen *driScrnPriv);
 
-    /**
-     * Context creation callback
-     */                    
     GLboolean (*CreateContext)(gl_api api,
-                              const struct gl_config *glVis,
-                              __DRIcontext *driContextPriv,
+                               const struct gl_config *glVis,
+                               __DRIcontext *driContextPriv,
+                              unsigned major_version,
+                              unsigned minor_version,
+                              uint32_t flags,
+                               bool notify_reset,
+                              unsigned *error,
                                void *sharedContextPrivate);
 
-    /**
-     * Context destruction callback
-     */
     void (*DestroyContext)(__DRIcontext *driContextPriv);
 
-    /**
-     * Buffer (drawable) creation callback
-     */
     GLboolean (*CreateBuffer)(__DRIscreen *driScrnPriv,
                               __DRIdrawable *driDrawPriv,
                               const struct gl_config *glVis,
                               GLboolean pixmapBuffer);
-    
-    /**
-     * Buffer (drawable) destruction callback
-     */
+
     void (*DestroyBuffer)(__DRIdrawable *driDrawPriv);
 
-    /**
-     * Buffer swapping callback 
-     */
     void (*SwapBuffers)(__DRIdrawable *driDrawPriv);
 
-    /**
-     * Context activation callback
-     */
     GLboolean (*MakeCurrent)(__DRIcontext *driContextPriv,
                              __DRIdrawable *driDrawPriv,
                              __DRIdrawable *driReadPriv);
 
-    /**
-     * Context unbinding callback
-     */
     GLboolean (*UnbindContext)(__DRIcontext *driContextPriv);
-  
-    /**
-     * These are required if GLX_OML_sync_control is supported.
-     */
-    /*@{*/
-    int (*WaitForMSC)( __DRIdrawable *priv, int64_t target_msc, 
-                      int64_t divisor, int64_t remainder,
-                      int64_t * msc );
-    int (*WaitForSBC)( __DRIdrawable *priv, int64_t target_sbc,
-                      int64_t * msc, int64_t * sbc );
-
-    int64_t (*SwapBuffersMSC)( __DRIdrawable *priv, int64_t target_msc,
-                              int64_t divisor, int64_t remainder );
-    /*@}*/
-    void (*CopySubBuffer)(__DRIdrawable *driDrawPriv,
-                         int x, int y, int w, int h);
-
-    /**
-     * New version of GetMSC so we can pass drawable data to the low
-     * level DRM driver (e.g. pipe info).  Required if
-     * GLX_SGI_video_sync or GLX_OML_sync_control is supported.
-     */
-    int (*GetDrawableMSC) ( __DRIscreen * priv,
-                           __DRIdrawable *drawablePrivate,
-                           int64_t *count);
-
-
-
-    /* DRI2 Entry point */
-    const __DRIconfig **(*InitScreen2) (__DRIscreen * priv);
 
     __DRIbuffer *(*AllocateBuffer) (__DRIscreen *screenPrivate,
-                                   unsigned int attachment,
-                                   unsigned int format,
-                                   int width, int height);
+                                    unsigned int attachment,
+                                    unsigned int format,
+                                    int width, int height);
+
     void (*ReleaseBuffer) (__DRIscreen *screenPrivate, __DRIbuffer *buffer);
+
+    void (*CopySubBuffer)(__DRIdrawable *driDrawPriv, int x, int y,
+                          int w, int h);
 };
 
 extern const struct __DriverAPIRec driDriverAPI;
-
+extern const struct __DriverAPIRec *globalDriverAPI;
 
 /**
- * Per-drawable private DRI driver information.
+ * Per-screen private driver information.
  */
-struct __DRIdrawableRec {
+struct __DRIscreenRec {
     /**
-     * Driver's private drawable information.  
-     *
-     * This structure is opaque.
+     * Driver-specific entrypoints provided by the driver's
+     * __DRIDriverVtableExtensionRec.
      */
-    void *driverPrivate;
+    const struct __DriverAPIRec *driver;
 
     /**
-     * Private data from the loader.  We just hold on to it and pass
-     * it back when calling into loader provided functions.
+     * Current screen's number
      */
-    void *loaderPrivate;
+    int myNum;
 
     /**
-     * Reference count for number of context's currently bound to this
-     * drawable.  
-     *
-     * Once it reaches zero, the drawable can be destroyed.
-     *
-     * \note This behavior will change with GLX 1.3.
+     * File descriptor returned when the kernel device driver is opened.
+     * 
+     * Used to:
+     *   - authenticate client to kernel
+     *   - map the frame buffer, SAREA, etc.
+     *   - close the kernel device driver
      */
-    int refcount;
+    int fd;
 
     /**
-     * Pointer to the "drawable has changed ID" stamp in the SAREA (or
-     * to dri2.stamp if DRI2 is being used).
+     * Device-dependent private information (not stored in the SAREA).
+     * 
+     * This pointer is never touched by the DRI layer.
      */
-    unsigned int *pStamp;
+    void *driverPrivate;
 
-    /**
-     * Last value of the stamp.
-     *
-     * If this differs from the value stored at __DRIdrawable::pStamp,
-     * then the drawable information has been modified by the X server, and the
-     * drawable information (below) should be retrieved from the X server.
-     */
-    unsigned int lastStamp;
+    void *loaderPrivate;
 
-    int w, h;
+    int max_gl_core_version;
+    int max_gl_compat_version;
+    int max_gl_es1_version;
+    int max_gl_es2_version;
 
-    /**
-     * Pointer to context to which this drawable is currently bound.
-     */
-    __DRIcontext *driContextPriv;
+    const __DRIextension **extensions;
 
-    /**
-     * Pointer to screen on which this drawable was created.
-     */
-    __DRIscreen *driScreenPriv;
+    const __DRIswrastLoaderExtension *swrast_loader;
 
     struct {
-       unsigned int stamp;
+       /* Flag to indicate that this is a DRI2 screen.  Many of the above
+        * fields will not be valid or initializaed in that case. */
+       const __DRIdri2LoaderExtension *loader;
+       const __DRIimageLookupExtension *image;
+       const __DRIuseInvalidateExtension *useInvalidate;
     } dri2;
+
+    struct {
+        const __DRIimageLoaderExtension *loader;
+    } image;
+
+    driOptionCache optionInfo;
+    driOptionCache optionCache;
+
+    unsigned int api_mask;
 };
 
 /**
@@ -234,6 +193,11 @@ struct __DRIcontextRec {
      */
     void *driverPrivate;
 
+    /**
+     * The loaders's private context data.  This structure is opaque.
+     */
+    void *loaderPrivate;
+
     /**
      * Pointer to drawable currently bound to this context for drawing.
      */
@@ -249,11 +213,6 @@ struct __DRIcontextRec {
      */
     __DRIscreen *driScreenPriv;
 
-    /**
-     * The loaders's private context data.  This structure is opaque.
-     */
-    void *loaderPrivate;
-
     struct {
        int draw_stamp;
        int read_stamp;
@@ -261,63 +220,76 @@ struct __DRIcontextRec {
 };
 
 /**
- * Per-screen private driver information.
+ * Per-drawable private DRI driver information.
  */
-struct __DRIscreenRec {
+struct __DRIdrawableRec {
     /**
-     * Current screen's number
+     * Driver's private drawable information.
+     *
+     * This structure is opaque.
      */
-    int myNum;
+    void *driverPrivate;
 
     /**
-     * Callback functions into the hardware-specific DRI driver code.
+     * Private data from the loader.  We just hold on to it and pass
+     * it back when calling into loader provided functions.
      */
-    struct __DriverAPIRec DriverAPI;
+    void *loaderPrivate;
 
-    const __DRIextension **extensions;
+    /**
+     * Pointer to context to which this drawable is currently bound.
+     */
+    __DRIcontext *driContextPriv;
 
     /**
-     * DRM (kernel module) version information.
+     * Pointer to screen on which this drawable was created.
      */
-    __DRIversion drm_version;
+    __DRIscreen *driScreenPriv;
 
     /**
-     * File descriptor returned when the kernel device driver is opened.
-     * 
-     * Used to:
-     *   - authenticate client to kernel
-     *   - map the frame buffer, SAREA, etc.
-     *   - close the kernel device driver
+     * Reference count for number of context's currently bound to this
+     * drawable.
+     *
+     * Once it reaches zero, the drawable can be destroyed.
+     *
+     * \note This behavior will change with GLX 1.3.
      */
-    int fd;
+    int refcount;
 
     /**
-     * Device-dependent private information (not stored in the SAREA).
-     * 
-     * This pointer is never touched by the DRI layer.
+     * Last value of the stamp.
+     *
+     * If this differs from the value stored at __DRIdrawable::dri2.stamp,
+     * then the drawable information has been modified by the X server, and the
+     * drawable information (below) should be retrieved from the X server.
      */
-#ifdef __cplusplus
-    void *priv;
-#else
-    void *private;
-#endif
+    unsigned int lastStamp;
 
+    int w, h;
+
+    /**
+     * Drawable timestamp.  Increased when the loader calls invalidate.
+     */
     struct {
-       /* Flag to indicate that this is a DRI2 screen.  Many of the above
-        * fields will not be valid or initializaed in that case. */
-       int enabled;
-       __DRIdri2LoaderExtension *loader;
-       __DRIimageLookupExtension *image;
-       __DRIuseInvalidateExtension *useInvalidate;
+       unsigned int stamp;
     } dri2;
-
-    driOptionCache optionInfo;
-    driOptionCache optionCache;
-   unsigned int api_mask;
-   void *loaderPrivate;
 };
 
+extern uint32_t
+driGLFormatToImageFormat(mesa_format format);
+
+extern mesa_format
+driImageFormatToGLFormat(uint32_t image_format);
+
 extern void
 dri2InvalidateDrawable(__DRIdrawable *drawable);
 
+extern void
+driUpdateFramebufferSize(struct gl_context *ctx, const __DRIdrawable *dPriv);
+
+extern void
+driContextSetFlags(struct gl_context *ctx, uint32_t flags);
+
+extern const __DRIimageDriverExtension driImageDriverExtension;
+
 #endif /* _DRI_UTIL_H_ */