anv,i965: Stop warning about incomplete gen11 support
[mesa.git] / src / mesa / drivers / dri / common / dri_util.h
index 3a33d275541d1e3564c382f56585d49d84baeb6d..d6c7d07d4e08ab7468bae4534365db38280f1bc9 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 <GL/internal/dri_interface.h>
-#include "main/mtypes.h"
-#include "xmlconfig.h"
+#include "main/menums.h"
+#include "main/formats.h"
+#include "util/xmlconfig.h"
+#include <stdbool.h>
 
+struct gl_config;
+struct gl_context;
 
 /**
  * Extensions.
  */
 extern const __DRIcoreExtension driCoreExtension;
+extern const __DRIswrastExtension driSWRastExtension;
 extern const __DRIdri2Extension driDRI2Extension;
 extern const __DRI2configQueryExtension dri2ConfigQueryExtension;
+extern const __DRIcopySubBufferExtension driCopySubBufferExtension;
+extern const __DRI2flushControlExtension dri2FlushControlExtension;
+
+/**
+ * Description of the attributes used to create a config.
+ *
+ * This is passed as the context_config parameter to CreateContext. The idea
+ * with this struct is that it can be extended without having to modify all of
+ * the drivers. The first three members (major/minor_version and flags) are
+ * always valid, but the remaining members are only valid if the corresponding
+ * flag is set for the attribute. If the flag is not set then the default
+ * value should be assumed. That way the driver can quickly check if any
+ * attributes were set that it doesn't understand and report an error.
+ */
+struct __DriverContextConfig {
+    /* These members are always valid */
+    unsigned major_version;
+    unsigned minor_version;
+    uint32_t flags;
+
+    /* Flags describing which of the remaining members are valid */
+    uint32_t attribute_mask;
+
+    /* Only valid if __DRIVER_CONTEXT_ATTRIB_RESET_STRATEGY is set */
+    int reset_strategy;
+
+    /* Only valid if __DRIVER_CONTEXT_PRIORITY is set */
+    unsigned priority;
+
+    /* Only valid if __DRIVER_CONTEXT_ATTRIB_RELEASE_BEHAVIOR is set */
+    int release_behavior;
+};
+
+#define __DRIVER_CONTEXT_ATTRIB_RESET_STRATEGY   (1 << 0)
+#define __DRIVER_CONTEXT_ATTRIB_PRIORITY         (1 << 1)
+#define __DRIVER_CONTEXT_ATTRIB_RELEASE_BEHAVIOR (1 << 2)
 
 /**
  * Driver callback functions.
@@ -78,6 +125,8 @@ struct __DriverAPIRec {
     GLboolean (*CreateContext)(gl_api api,
                                const struct gl_config *glVis,
                                __DRIcontext *driContextPriv,
+                               const struct __DriverContextConfig *ctx_config,
+                               unsigned *error,
                                void *sharedContextPrivate);
 
     void (*DestroyContext)(__DRIcontext *driContextPriv);
@@ -103,65 +152,78 @@ struct __DriverAPIRec {
                                     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;
 
     /**
-     * Pointer to context to which this drawable is currently bound.
+     * 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
      */
-    __DRIcontext *driContextPriv;
+    int fd;
 
     /**
-     * Pointer to screen on which this drawable was created.
+     * Device-dependent private information (not stored in the SAREA).
+     * 
+     * This pointer is never touched by the DRI layer.
      */
-    __DRIscreen *driScreenPriv;
+    void *driverPrivate;
 
-    /**
-     * 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 refcount;
+    void *loaderPrivate;
 
-    /**
-     * 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.
-     */
-    unsigned int lastStamp;
+    int max_gl_core_version;
+    int max_gl_compat_version;
+    int max_gl_es1_version;
+    int max_gl_es2_version;
 
-    int w, h;
+    const __DRIextension **extensions;
+
+    const __DRIswrastLoaderExtension *swrast_loader;
 
-    /**
-     * Drawable timestamp.  Increased when the loader calls invalidate.
-     */
     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;
+        const __DRIbackgroundCallableExtension *backgroundCallable;
     } dri2;
+
+    struct {
+        const __DRIimageLoaderExtension *loader;
+    } image;
+
+    struct {
+       const __DRImutableRenderBufferLoaderExtension *loader;
+    } mutableRenderBuffer;
+
+    driOptionCache optionInfo;
+    driOptionCache optionCache;
+
+    unsigned int api_mask;
 };
 
 /**
@@ -200,55 +262,66 @@ 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;
 
     /**
-     * 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
+     * Private data from the loader.  We just hold on to it and pass
+     * it back when calling into loader provided functions.
      */
-    int fd;
+    void *loaderPrivate;
 
     /**
-     * DRM (kernel module) version information.
+     * Pointer to context to which this drawable is currently bound.
      */
-    __DRIversion drm_version;
+    __DRIcontext *driContextPriv;
 
     /**
-     * Device-dependent private information (not stored in the SAREA).
-     * 
-     * This pointer is never touched by the DRI layer.
+     * Pointer to screen on which this drawable was created.
      */
-    void *driverPrivate;
+    __DRIscreen *driScreenPriv;
 
-    void *loaderPrivate;
+    /**
+     * 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 refcount;
 
-    const __DRIextension **extensions;
+    /**
+     * 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.
+     */
+    unsigned int lastStamp;
 
-    const __DRIswrastLoaderExtension *swrast_loader;
+    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. */
-       __DRIdri2LoaderExtension *loader;
-       __DRIimageLookupExtension *image;
-       __DRIuseInvalidateExtension *useInvalidate;
+       unsigned int stamp;
     } dri2;
+};
 
-    driOptionCache optionInfo;
-    driOptionCache optionCache;
+extern uint32_t
+driGLFormatToImageFormat(mesa_format format);
 
-    unsigned int api_mask;
-};
+extern mesa_format
+driImageFormatToGLFormat(uint32_t image_format);
 
 extern void
 dri2InvalidateDrawable(__DRIdrawable *drawable);
@@ -256,4 +329,11 @@ 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;
+
+extern const __DRInoErrorExtension dri2NoErrorExtension;
+
 #endif /* _DRI_UTIL_H_ */