Merge commit 'origin/7.8'
[mesa.git] / include / GL / internal / dri_interface.h
index ec6238f873420401741a3544c70215ceaca55768..fa9b7c4bf2197ad09e6bbfd6c292e1cc8d1bcd0f 100644 (file)
 #define DRI_INTERFACE_H
 
 /* For archs with no drm.h */
-#if !defined(__APPLE__) && !defined(__CYGWIN__) && !defined(__GNU__)
+#if defined(__APPLE__) || defined(__CYGWIN__) || defined(__GNU__)
+#ifndef __NOT_HAVE_DRM_H
+#define __NOT_HAVE_DRM_H
+#endif
+#endif
+
+#ifndef __NOT_HAVE_DRM_H
 #include <drm.h>
 #else
 typedef unsigned int drm_context_t;
@@ -230,6 +236,13 @@ struct __DRItexOffsetExtensionRec {
 };
 
 
+/* Valid values for format in the setTexBuffer2 function below.  These
+ * values match the GLX tokens for compatibility reasons, but we
+ * define them here since the DRI interface can't depend on GLX. */
+#define __DRI_TEXTURE_FORMAT_NONE        0x20D8
+#define __DRI_TEXTURE_FORMAT_RGB         0x20D9
+#define __DRI_TEXTURE_FORMAT_RGBA        0x20DA
+
 #define __DRI_TEX_BUFFER "DRI_TexBuffer"
 #define __DRI_TEX_BUFFER_VERSION 2
 struct __DRItexBufferExtensionRec {
@@ -262,22 +275,20 @@ struct __DRItexBufferExtensionRec {
  * Used by drivers that implement DRI2
  */
 #define __DRI2_FLUSH "DRI2_Flush"
-#define __DRI2_FLUSH_VERSION 2
+#define __DRI2_FLUSH_VERSION 3
 struct __DRI2flushExtensionRec {
     __DRIextension base;
     void (*flush)(__DRIdrawable *drawable);
 
     /**
-     * Flush all rendering queue in the driver to the drm and
-     * invalidate all buffers.  The driver will call out to
-     * getBuffers/getBuffersWithFormat before it starts rendering
-     * again.
+     * Ask the driver to call getBuffers/getBuffersWithFormat before
+     * it starts rendering again.
      *
-     * \param drawable the drawable to flush and invalidate
+     * \param drawable the drawable to invalidate
      *
-     * \since 2
+     * \since 3
      */
-    void (*flushInvalidate)(__DRIdrawable *drawable);
+    void (*invalidate)(__DRIdrawable *drawable);
 };
 
 
@@ -405,15 +416,15 @@ struct __DRIswrastLoaderExtensionRec {
      * Put image to drawable
      */
     void (*putImage)(__DRIdrawable *drawable, int op,
-                    int x, int y, int width, int height, char *data,
-                    void *loaderPrivate);
+                    int x, int y, int width, int height,
+                    char *data, void *loaderPrivate);
 
     /**
-     * Get image from drawable
+     * Get image from readable
      */
-    void (*getImage)(__DRIdrawable *drawable,
-                    int x, int y, int width, int height, char *data,
-                    void *loaderPrivate);
+    void (*getImage)(__DRIdrawable *readable,
+                    int x, int y, int width, int height,
+                    char *data, void *loaderPrivate);
 };
 
 /**
@@ -746,4 +757,59 @@ struct __DRIdri2ExtensionRec {
 
 };
 
+
+/**
+ * This extension provides functionality to enable various EGLImage
+ * extensions.
+ */
+#define __DRI_IMAGE "DRI_IMAGE"
+#define __DRI_IMAGE_VERSION 1
+
+/**
+ * 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.
+ */
+#define __DRI_IMAGE_FORMAT_RGB565       0x1001
+#define __DRI_IMAGE_FORMAT_XRGB8888     0x1002
+#define __DRI_IMAGE_FORMAT_ARGB8888     0x1003
+
+typedef struct __DRIimageRec          __DRIimage;
+typedef struct __DRIimageExtensionRec __DRIimageExtension;
+struct __DRIimageExtensionRec {
+    __DRIextension base;
+
+    __DRIimage *(*createImageFromName)(__DRIcontext *context,
+                                      int width, int height, int format,
+                                      int name, int pitch,
+                                      void *loaderPrivate);
+
+    __DRIimage *(*createImageFromRenderbuffer)(__DRIcontext *context,
+                                              int renderbuffer,
+                                              void *loaderPrivate);
+
+    void (*destroyImage)(__DRIimage *image);
+};
+
+/**
+ * This extension must be implemented by the loader and passed to the
+ * driver at screen creation time.  The EGLImage entry points in the
+ * various client APIs take opaque EGLImage handles and use this
+ * extension to map them to a __DRIimage.  At version 1, this
+ * extensions allows mapping EGLImage pointers to __DRIimage pointers,
+ * but future versions could support other EGLImage-like, opaque types
+ * with new lookup functions.
+ */
+#define __DRI_IMAGE_LOOKUP "DRI_IMAGE_LOOKUP"
+#define __DRI_IMAGE_LOOKUP_VERSION 1
+
+typedef struct __DRIimageLookupExtensionRec __DRIimageLookupExtension;
+struct __DRIimageLookupExtensionRec {
+    __DRIextension base;
+
+    __DRIimage *(*lookupEGLImage)(__DRIcontext *context, void *image,
+                                 void *loaderPrivate);
+};
+
 #endif