gbm: Add new gbm_bo_import entry point
[mesa.git] / include / GL / internal / dri_interface.h
index e4c2b3a3eba76f8484d4d79bf5934ef69516bee4..d3a66c52d2cbc00d901d05228792d6548d99153b 100644 (file)
@@ -74,7 +74,6 @@ typedef struct __DRIcoreExtensionRec          __DRIcoreExtension;
 typedef struct __DRIextensionRec               __DRIextension;
 typedef struct __DRIcopySubBufferExtensionRec  __DRIcopySubBufferExtension;
 typedef struct __DRIswapControlExtensionRec    __DRIswapControlExtension;
-typedef struct __DRIallocateExtensionRec       __DRIallocateExtension;
 typedef struct __DRIframeTrackingExtensionRec  __DRIframeTrackingExtension;
 typedef struct __DRImediaStreamCounterExtensionRec     __DRImediaStreamCounterExtension;
 typedef struct __DRItexOffsetExtensionRec      __DRItexOffsetExtension;
@@ -85,6 +84,7 @@ typedef struct __DRIbufferRec                 __DRIbuffer;
 typedef struct __DRIdri2ExtensionRec           __DRIdri2Extension;
 typedef struct __DRIdri2LoaderExtensionRec     __DRIdri2LoaderExtension;
 typedef struct __DRI2flushExtensionRec __DRI2flushExtension;
+typedef struct __DRI2throttleExtensionRec      __DRI2throttleExtension;
 
 /*@}*/
 
@@ -149,23 +149,6 @@ struct __DRIswapControlExtensionRec {
     unsigned int (*getSwapInterval)(__DRIdrawable *drawable);
 };
 
-/**
- * Used by drivers that implement the GLX_MESA_allocate_memory.
- */
-#define __DRI_ALLOCATE "DRI_Allocate"
-#define __DRI_ALLOCATE_VERSION 1
-struct __DRIallocateExtensionRec {
-    __DRIextension base;
-
-    void *(*allocateMemory)(__DRIscreen *screen, GLsizei size,
-                           GLfloat readfreq, GLfloat writefreq,
-                           GLfloat priority);
-   
-    void (*freeMemory)(__DRIscreen *screen, GLvoid *pointer);
-   
-    GLuint (*memoryOffset)(__DRIscreen *screen, const GLvoid *pointer);
-};
-
 /**
  * Used by drivers that implement the GLX_MESA_swap_frame_usage extension.
  */
@@ -269,6 +252,15 @@ struct __DRItexBufferExtensionRec {
                          GLint target,
                          GLint format,
                          __DRIdrawable *pDraw);
+    /**
+     * Method to release texture buffer in case some special platform
+     * need this.
+     *
+     * For GLX_EXT_texture_from_pixmap with AIGLX.
+     */
+    void (*releaseTexBuffer)(__DRIcontext *pDRICtx,
+                       GLint target,
+                       __DRIdrawable *pDraw);
 };
 
 /**
@@ -292,6 +284,27 @@ struct __DRI2flushExtensionRec {
 };
 
 
+/**
+ * Extension that the driver uses to request
+ * throttle callbacks.
+ */
+
+#define __DRI2_THROTTLE "DRI2_Throttle"
+#define __DRI2_THROTTLE_VERSION 1
+
+enum __DRI2throttleReason {
+   __DRI2_THROTTLE_SWAPBUFFER,
+   __DRI2_THROTTLE_COPYSUBBUFFER,
+   __DRI2_THROTTLE_FLUSHFRONT
+};
+
+struct __DRI2throttleExtensionRec {
+   __DRIextension base;
+   void (*throttle)(__DRIcontext *ctx,
+                   __DRIdrawable *drawable,
+                   enum __DRI2throttleReason reason);
+};
+
 /**
  * XML document describing the configuration options supported by the
  * driver.
@@ -508,6 +521,7 @@ struct __DRIuseInvalidateExtensionRec {
 #define __DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE    45
 #define __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS   46
 #define __DRI_ATTRIB_YINVERTED                 47
+#define __DRI_ATTRIB_FRAMEBUFFER_SRGB_CAPABLE  48
 
 /* __DRI_ATTRIB_RENDER_TYPE */
 #define __DRI_ATTRIB_RGBA_BIT                  0x01    
@@ -665,7 +679,7 @@ struct __DRIlegacyExtensionRec {
  * conjunction with the core extension.
  */
 #define __DRI_SWRAST "DRI_SWRast"
-#define __DRI_SWRAST_VERSION 1
+#define __DRI_SWRAST_VERSION 3
 
 struct __DRIswrastExtensionRec {
     __DRIextension base;
@@ -678,6 +692,29 @@ struct __DRIswrastExtensionRec {
     __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
                                        const __DRIconfig *config,
                                        void *loaderPrivate);
+
+   /* Since version 2 */
+   __DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen,
+                                           int api,
+                                           const __DRIconfig *config,
+                                           __DRIcontext *shared,
+                                           void *data);
+
+   /**
+    * Create a context for a particular API with a set of attributes
+    *
+    * \since version 3
+    *
+    * \sa __DRIdri2ExtensionRec::createContextAttribs
+    */
+   __DRIcontext *(*createContextAttribs)(__DRIscreen *screen,
+                                        int api,
+                                        const __DRIconfig *config,
+                                        __DRIcontext *shared,
+                                        unsigned num_attribs,
+                                        const uint32_t *attribs,
+                                        unsigned *error,
+                                        void *loaderPrivate);
 };
 
 /**
@@ -693,6 +730,10 @@ struct __DRIswrastExtensionRec {
 #define __DRI_BUFFER_FAKE_FRONT_LEFT   7
 #define __DRI_BUFFER_FAKE_FRONT_RIGHT  8
 #define __DRI_BUFFER_DEPTH_STENCIL     9  /**< Only available with DRI2 1.1 */
+#define __DRI_BUFFER_HIZ               10
+
+/* Inofficial and for internal use. Increase when adding a new buffer token. */
+#define __DRI_BUFFER_COUNT             11
 
 struct __DRIbufferRec {
     unsigned int attachment;
@@ -756,11 +797,63 @@ struct __DRIdri2LoaderExtensionRec {
  * constructors for DRI2.
  */
 #define __DRI_DRI2 "DRI_DRI2"
-#define __DRI_DRI2_VERSION 2
+#define __DRI_DRI2_VERSION 3
 
-#define __DRI_API_OPENGL       0
+#define __DRI_API_OPENGL       0       /**< OpenGL compatibility profile */
 #define __DRI_API_GLES         1
 #define __DRI_API_GLES2                2
+#define __DRI_API_OPENGL_CORE  3       /**< OpenGL 3.2+ core profile */
+
+#define __DRI_CTX_ATTRIB_MAJOR_VERSION         0
+#define __DRI_CTX_ATTRIB_MINOR_VERSION         1
+#define __DRI_CTX_ATTRIB_FLAGS                 2
+
+/**
+ * \requires __DRI2_ROBUSTNESS.
+ */
+#define __DRI_CTX_ATTRIB_RESET_STRATEGY                3
+
+#define __DRI_CTX_FLAG_DEBUG                   0x00000001
+#define __DRI_CTX_FLAG_FORWARD_COMPATIBLE      0x00000002
+
+/**
+ * \requires __DRI2_ROBUSTNESS.
+ */
+#define __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS    0x00000004
+
+/**
+ * \name Context reset strategies.
+ */
+/*@{*/
+#define __DRI_CTX_RESET_NO_NOTIFICATION                0
+#define __DRI_CTX_RESET_LOSE_CONTEXT           1
+/*@}*/
+
+/**
+ * \name Reasons that __DRIdri2Extension::createContextAttribs might fail
+ */
+/*@{*/
+/** Success! */
+#define __DRI_CTX_ERROR_SUCCESS                        0
+
+/** Memory allocation failure */
+#define __DRI_CTX_ERROR_NO_MEMORY              1
+
+/** Client requested an API (e.g., OpenGL ES 2.0) that the driver can't do. */
+#define __DRI_CTX_ERROR_BAD_API                        2
+
+/** Client requested an API version that the driver can't do. */
+#define __DRI_CTX_ERROR_BAD_VERSION            3
+
+/** Client requested a flag or combination of flags the driver can't do. */
+#define __DRI_CTX_ERROR_BAD_FLAG               4
+
+/** Client requested an attribute the driver doesn't understand. */
+#define __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE      5
+
+/** Client requested a flag the driver doesn't understand. */
+#define __DRI_CTX_ERROR_UNKNOWN_FLAG           6
+/*@}*/
 
 struct __DRIdri2ExtensionRec {
     __DRIextension base;
@@ -787,6 +880,30 @@ struct __DRIdri2ExtensionRec {
                                           const __DRIconfig *config,
                                           __DRIcontext *shared,
                                           void *data);
+
+   __DRIbuffer *(*allocateBuffer)(__DRIscreen *screen,
+                                 unsigned int attachment,
+                                 unsigned int format,
+                                 int width,
+                                 int height);
+   void (*releaseBuffer)(__DRIscreen *screen,
+                        __DRIbuffer *buffer);
+
+   /**
+    * Create a context for a particular API with a set of attributes
+    *
+    * \since version 3
+    *
+    * \sa __DRIswrastExtensionRec::createContextAttribs
+    */
+   __DRIcontext *(*createContextAttribs)(__DRIscreen *screen,
+                                        int api,
+                                        const __DRIconfig *config,
+                                        __DRIcontext *shared,
+                                        unsigned num_attribs,
+                                        const uint32_t *attribs,
+                                        unsigned *error,
+                                        void *loaderPrivate);
 };
 
 
@@ -795,24 +912,49 @@ struct __DRIdri2ExtensionRec {
  * extensions.
  */
 #define __DRI_IMAGE "DRI_IMAGE"
-#define __DRI_IMAGE_VERSION 1
+#define __DRI_IMAGE_VERSION 5
 
 /**
  * These formats correspond to the similarly named MESA_FORMAT_*
  * tokens, except in the native endian of the CPU.  For example, on
  * little endian __DRI_IMAGE_FORMAT_XRGB8888 corresponds to
  * MESA_FORMAT_XRGB8888, but MESA_FORMAT_XRGB8888_REV on big endian.
+ *
+ * __DRI_IMAGE_FORMAT_NONE is for images that aren't directly usable
+ * by the driver (YUV planar formats) but serve as a base image for
+ * creating sub-images for the different planes within the image.
  */
 #define __DRI_IMAGE_FORMAT_RGB565       0x1001
 #define __DRI_IMAGE_FORMAT_XRGB8888     0x1002
 #define __DRI_IMAGE_FORMAT_ARGB8888     0x1003
+#define __DRI_IMAGE_FORMAT_ABGR8888     0x1004
+#define __DRI_IMAGE_FORMAT_XBGR8888     0x1005
+#define __DRI_IMAGE_FORMAT_R8           0x1006 /* Since version 5 */
+#define __DRI_IMAGE_FORMAT_GR88         0x1007
+#define __DRI_IMAGE_FORMAT_NONE         0x1008
+
+#define __DRI_IMAGE_USE_SHARE          0x0001
+#define __DRI_IMAGE_USE_SCANOUT                0x0002
+#define __DRI_IMAGE_USE_CURSOR         0x0004
+#define __DRI_IMAGE_USE_WRITE          0x0008
+
+/**
+ * queryImage attributes
+ */
+
+#define __DRI_IMAGE_ATTRIB_STRIDE      0x2000
+#define __DRI_IMAGE_ATTRIB_HANDLE      0x2001
+#define __DRI_IMAGE_ATTRIB_NAME                0x2002
+#define __DRI_IMAGE_ATTRIB_FORMAT      0x2003 /* available in versions 3+ */
+#define __DRI_IMAGE_ATTRIB_WIDTH       0x2004 /* available in versions 5+ */
+#define __DRI_IMAGE_ATTRIB_HEIGHT      0x2005
 
 typedef struct __DRIimageRec          __DRIimage;
 typedef struct __DRIimageExtensionRec __DRIimageExtension;
 struct __DRIimageExtensionRec {
     __DRIextension base;
 
-    __DRIimage *(*createImageFromName)(__DRIcontext *context,
+    __DRIimage *(*createImageFromName)(__DRIscreen *screen,
                                       int width, int height, int format,
                                       int name, int pitch,
                                       void *loaderPrivate);
@@ -822,8 +964,55 @@ struct __DRIimageExtensionRec {
                                               void *loaderPrivate);
 
     void (*destroyImage)(__DRIimage *image);
+
+    __DRIimage *(*createImage)(__DRIscreen *screen,
+                              int width, int height, int format,
+                              unsigned int use,
+                              void *loaderPrivate);
+
+   GLboolean (*queryImage)(__DRIimage *image, int attrib, int *value);
+
+   /**
+    * The new __DRIimage will share the content with the old one, see dup(2).
+    */
+   __DRIimage *(*dupImage)(__DRIimage *image, void *loaderPrivate);
+
+   /**
+    * Validate that a __DRIimage can be used a certain way.
+    *
+    * \since 2
+    */
+   GLboolean (*validateUsage)(__DRIimage *image, unsigned int use);
+
+   /**
+    * Write data into image.
+    *
+    * \since 4
+    */
+   int (*write)(__DRIimage *image, const void *buf, size_t count);
+
+   /**
+    * Create an image out of a sub-region of a parent image.  This
+    * entry point lets us create individual __DRIimages for different
+    * planes in a planar buffer (typically yuv), for example.  While a
+    * sub-image shares the underlying buffer object with the parent
+    * image and other sibling sub-images, the life times of parent and
+    * sub-images are not dependent.  Destroying the parent or a
+    * sub-image doesn't affect other images.  The underlying buffer
+    * object is free when no __DRIimage remains that references it.
+    *
+    * Sub-images may overlap, but rendering to overlapping sub-images
+    * is undefined.
+    *
+    * \since 5
+    */
+    __DRIimage *(*createSubImage)(__DRIimage *image,
+                                  int width, int height, int format,
+                                  int offset, int pitch,
+                                  void *loaderPrivate);
 };
 
+
 /**
  * This extension must be implemented by the loader and passed to the
  * driver at screen creation time.  The EGLImage entry points in the
@@ -840,7 +1029,7 @@ typedef struct __DRIimageLookupExtensionRec __DRIimageLookupExtension;
 struct __DRIimageLookupExtensionRec {
     __DRIextension base;
 
-    __DRIimage *(*lookupEGLImage)(__DRIcontext *context, void *image,
+    __DRIimage *(*lookupEGLImage)(__DRIscreen *screen, void *image,
                                  void *loaderPrivate);
 };
 
@@ -858,4 +1047,21 @@ struct __DRI2configQueryExtensionRec {
    int (*configQueryi)(__DRIscreen *screen, const char *var, GLint *val);
    int (*configQueryf)(__DRIscreen *screen, const char *var, GLfloat *val);
 };
+
+/**
+ * Robust context driver extension.
+ *
+ * Existence of this extension means the driver can accept the
+ * \c __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS flag and the
+ * \c __DRI_CTX_ATTRIB_RESET_STRATEGY attribute in
+ * \c __DRIdri2ExtensionRec::createContextAttribs.
+ */
+#define __DRI2_ROBUSTNESS "DRI_Robustness"
+#define __DRI2_ROBUSTNESS_VERSION 1
+
+typedef struct __DRIrobustnessExtensionRec __DRIrobustnessExtension;
+struct __DRIrobustnessExtensionRec {
+   __DRIextension base;
+};
+
 #endif