summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorChad Versace <chadversary@chromium.org>2018-03-31 01:16:14 -0700
committerChad Versace <chadversary@chromium.org>2018-05-01 03:15:54 -0700
commit2aaeab9fddfc13191a314e4e75ff0df1d8a6dc8c (patch)
treee314593ad91129e9309269c24d649ca79998497e /include
parent0d7eae584741b54e204a58b87fd84b791932056b (diff)
CHROMIUM: dri: Define DRI_MutableRenderBuffer extensions
Define extensions DRI_MutableRenderBufferDriver and DRI_MutableRenderBufferLoader. These are the two halves for EGL_KHR_mutable_render_buffer. Outside the DRI code there is one additional change. Add gl_config::mutableRenderBuffer to match __DRI_ATTRIB_MUTABLE_RENDER_BUFFER. Neither are used yet. BUG=b:77899911 TEST=No android-cts-7.1 regressions on Eve. Change-Id: I4ca03d81e4557380b19c44d8d799a7cc9365d928
Diffstat (limited to 'include')
-rw-r--r--include/GL/internal/dri_interface.h126
1 files changed, 124 insertions, 2 deletions
diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h
index 98402eae057..7d9bf032d79 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -48,6 +48,7 @@ typedef unsigned int drm_drawable_t;
typedef struct drm_clip_rect drm_clip_rect_t;
#endif
+#include <stdbool.h>
#include <stdint.h>
/**
@@ -704,7 +705,8 @@ struct __DRIuseInvalidateExtensionRec {
#define __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS 46
#define __DRI_ATTRIB_YINVERTED 47
#define __DRI_ATTRIB_FRAMEBUFFER_SRGB_CAPABLE 48
-#define __DRI_ATTRIB_MAX (__DRI_ATTRIB_FRAMEBUFFER_SRGB_CAPABLE + 1)
+#define __DRI_ATTRIB_MUTABLE_RENDER_BUFFER 49 /* EGL_MUTABLE_RENDER_BUFFER_BIT_KHR */
+#define __DRI_ATTRIB_MAX 50
/* __DRI_ATTRIB_RENDER_TYPE */
#define __DRI_ATTRIB_RGBA_BIT 0x01
@@ -1810,7 +1812,48 @@ struct __DRI2rendererQueryExtensionRec {
enum __DRIimageBufferMask {
__DRI_IMAGE_BUFFER_BACK = (1 << 0),
- __DRI_IMAGE_BUFFER_FRONT = (1 << 1)
+ __DRI_IMAGE_BUFFER_FRONT = (1 << 1),
+
+ /**
+ * A buffer shared between application and compositor. The buffer may be
+ * simultaneously accessed by each.
+ *
+ * A shared buffer is equivalent to an EGLSurface whose EGLConfig contains
+ * EGL_MUTABLE_RENDER_BUFFER_BIT_KHR and whose active EGL_RENDER_BUFFER (as
+ * opposed to any pending, requested change to EGL_RENDER_BUFFER) is
+ * EGL_SINGLE_BUFFER.
+ *
+ * If the loader returns __DRI_IMAGE_BUFFER_SHARED, then it is returned
+ * alone without accompanying back nor front buffer.
+ *
+ * The loader returns __DRI_IMAGE_BUFFER_SHARED if and only if:
+ * - The loader supports __DRI_MUTABLE_RENDER_BUFFER_LOADER.
+ * - The driver supports __DRI_MUTABLE_RENDER_BUFFER_DRIVER.
+ * - The EGLConfig of the drawable EGLSurface contains
+ * EGL_MUTABLE_RENDER_BUFFER_BIT_KHR.
+ * - The EGLContext's EGL_RENDER_BUFFER is EGL_SINGLE_BUFFER.
+ * Equivalently, the EGLSurface's active EGL_RENDER_BUFFER (as
+ * opposed to any pending,requested change to EGL_RENDER_BUFFER) is
+ * EGL_SINGLE_BUFFER.
+ *
+ * A shared buffer is similar a front buffer in that all rendering to the
+ * buffer should appear promptly on the screen. It is different from
+ * a front buffer in that its behavior is independent from the
+ * GL_DRAW_BUFFER state. Specifically, if GL_DRAW_FRAMEBUFFER is 0 and the
+ * __DRIdrawable's current buffer mask is __DRI_IMAGE_BUFFER_SHARED, then
+ * all rendering should appear promptly on the screen if GL_DRAW_BUFFER is
+ * not GL_NONE.
+ *
+ * The difference between a shared buffer and a front buffer is motivated
+ * by the constraints of Android and OpenGL ES. OpenGL ES does not support
+ * front-buffer rendering. Android's SurfaceFlinger protocol provides the
+ * EGL driver only a back buffer and no front buffer. The shared buffer
+ * mode introduced by EGL_KHR_mutable_render_buffer is a backdoor though
+ * EGL that allows Android OpenGL ES applications to render to what is
+ * effectively the front buffer, a backdoor that required no change to the
+ * OpenGL ES API and little change to the SurfaceFlinger API.
+ */
+ __DRI_IMAGE_BUFFER_SHARED = (1 << 2),
};
struct __DRIimageList {
@@ -1949,4 +1992,83 @@ struct __DRIbackgroundCallableExtensionRec {
GLboolean (*isThreadSafe)(void *loaderPrivate);
};
+/**
+ * The driver portion of EGL_KHR_mutable_render_buffer.
+ *
+ * If the driver creates a __DRIconfig with
+ * __DRI_ATTRIB_MUTABLE_RENDER_BUFFER, then it must support this extension.
+ *
+ * To support this extension:
+ *
+ * - The driver should create at least one __DRIconfig with
+ * __DRI_ATTRIB_MUTABLE_RENDER_BUFFER. This is strongly recommended but
+ * not required.
+ *
+ * - The driver must be able to handle __DRI_IMAGE_BUFFER_SHARED if
+ * returned by __DRIimageLoaderExtension:getBuffers().
+ *
+ * - When rendering to __DRI_IMAGE_BUFFER_SHARED, it must call
+ * __DRImutableRenderBufferLoaderExtension::displaySharedBuffer() on each
+ * application-initiated flush. This includes glFlush, glFinish,
+ * GL_SYNC_FLUSH_COMMANDS_BIT, EGL_SYNC_FLUSH_COMMANDS_BIT, and possibly
+ * more. (Android applications expect that glFlush will immediately
+ * display the buffer when in shared buffer mode because that is common
+ * behavior among Android drivers). It :may: call displaySharedBuffer()
+ * more often than required.
+ *
+ * - When rendering to __DRI_IMAGE_BUFFER_SHARED, it must ensure that the
+ * buffer is always in a format compatible for display because the
+ * display engine (usually SurfaceFlinger or hwcomposer) may display the
+ * image at any time, even concurrently with 3D rendering. For example,
+ * display hardware and the GL hardware may be able to access the buffer
+ * simultaneously. In particular, if the buffer is compressed than take
+ * care that SurfaceFlinger and hwcomposer can consume the compression
+ * format.
+ *
+ * \see __DRI_IMAGE_BUFFER_SHARED
+ * \see __DRI_ATTRIB_MUTABLE_RENDER_BUFFER
+ * \see __DRI_MUTABLE_RENDER_BUFFER_LOADER
+ */
+#define __DRI_MUTABLE_RENDER_BUFFER_DRIVER "DRI_MutableRenderBufferDriver"
+#define __DRI_MUTABLE_RENDER_BUFFER_DRIVER_VERSION 1
+
+typedef struct __DRImutableRenderBufferDriverExtensionRec __DRImutableRenderBufferDriverExtension;
+struct __DRImutableRenderBufferDriverExtensionRec {
+ __DRIextension base;
+};
+
+/**
+ * The loader portion of EGL_KHR_mutable_render_buffer.
+ *
+ * Requires loader extension DRI_IMAGE_LOADER, through which the loader sends
+ * __DRI_IMAGE_BUFFER_SHARED to the driver.
+ *
+ * \see __DRI_MUTABLE_RENDER_BUFFER_DRIVER
+ */
+#define __DRI_MUTABLE_RENDER_BUFFER_LOADER "DRI_MutableRenderBufferLoader"
+#define __DRI_MUTABLE_RENDER_BUFFER_LOADER_VERSION 1
+
+typedef struct __DRImutableRenderBufferLoaderExtensionRec __DRImutableRenderBufferLoaderExtension;
+struct __DRImutableRenderBufferLoaderExtensionRec {
+ __DRIextension base;
+
+ /**
+ * Inform the display engine (usually SurfaceFlinger or hwcomposer)
+ * that the __DRIdrawable has new content. The display engine may ignore
+ * this, for example, if it continually refreshes and displays the buffer
+ * on every frame, as in EGL_ANDROID_front_buffer_auto_refresh. On the
+ * other extreme, the display engine may refresh and display the buffer
+ * only in frames in which the driver calls this.
+ *
+ * If the fence_fd is not -1, then the display engine will display the
+ * buffer only after the fence signals.
+ *
+ * The drawable's current __DRIimageBufferMask, as returned by
+ * __DRIimageLoaderExtension::getBuffers(), must contain
+ * __DRI_IMAGE_BUFFER_SHARED.
+ */
+ void (*displaySharedBuffer)(__DRIdrawable *drawable, int fence_fd,
+ void *loaderPrivate);
+};
+
#endif