Bug 1366512 - Export some EGL functions for D3D NV12 texture format. v2. r=jgilbert
authorJerryShih <hshih@mozilla.com>
Sun, 28 May 2017 21:15:07 -0700
changeset 409196 22b07d362869f35af94524f077e0613f9b041fb9
parent 409195 d3bad87d7582da33b4e8d163fdf11be1851688c3
child 409197 cce4d83d2b99ffedbd67a2f40ce26e53e9ae27ab
child 409297 ea4280e958948bcd94157e5d2fa81e94a0e2ba66
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert
bugs1366512
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1366512 - Export some EGL functions for D3D NV12 texture format. v2. r=jgilbert These EGL functions will be used to convert D3D NV12 texture handle to GL handle. MozReview-Commit-ID: JpH0P3mAanU
gfx/gl/GLLibraryEGL.cpp
gfx/gl/GLLibraryEGL.h
gfx/gl/GLTypes.h
--- a/gfx/gl/GLLibraryEGL.cpp
+++ b/gfx/gl/GLLibraryEGL.cpp
@@ -50,16 +50,22 @@ static const char* sEGLExtensionNames[] 
     "EGL_KHR_image",
     "EGL_KHR_fence_sync",
     "EGL_ANDROID_native_fence_sync",
     "EGL_ANDROID_image_crop",
     "EGL_ANGLE_platform_angle",
     "EGL_ANGLE_platform_angle_d3d",
     "EGL_ANGLE_d3d_share_handle_client_buffer",
     "EGL_KHR_create_context",
+    "EGL_KHR_stream",
+    "EGL_KHR_stream_consumer_gltexture",
+    "EGL_EXT_device_base",
+    "EGL_EXT_device_query",
+    "EGL_NV_stream_consumer_gltexture_yuv",
+    "EGL_ANGLE_stream_producer_d3d_texture_nv12",
 };
 
 #if defined(ANDROID)
 
 static PRLibrary* LoadApitraceLibrary()
 {
     // Initialization of gfx prefs here is only needed during the unit tests...
     gfxPrefs::GetSingleton();
@@ -591,16 +597,86 @@ GLLibraryEGL::EnsureInitialized(bool for
             END_OF_SYMBOLS
         };
         if (!fnLoadSymbols(nativeFenceSymbols)) {
             NS_ERROR("EGL supports ANDROID_native_fence_sync without exposing its functions!");
             MarkExtensionUnsupported(ANDROID_native_fence_sync);
         }
     }
 
+    if (IsExtensionSupported(KHR_stream)) {
+        const GLLibraryLoader::SymLoadStruct streamSymbols[] = {
+            SYMBOL(CreateStreamKHR),
+            SYMBOL(DestroyStreamKHR),
+            SYMBOL(QueryStreamKHR),
+            END_OF_SYMBOLS
+        };
+        if (!fnLoadSymbols(streamSymbols)) {
+            NS_ERROR("EGL supports KHR_stream without exposing its functions!");
+            MarkExtensionUnsupported(KHR_stream);
+        }
+    }
+
+    if (IsExtensionSupported(KHR_stream_consumer_gltexture)) {
+        const GLLibraryLoader::SymLoadStruct streamConsumerSymbols[] = {
+            SYMBOL(StreamConsumerAcquireKHR),
+            SYMBOL(StreamConsumerReleaseKHR),
+            END_OF_SYMBOLS
+        };
+        if (!fnLoadSymbols(streamConsumerSymbols)) {
+            NS_ERROR("EGL supports KHR_stream_consumer_gltexture without exposing its functions!");
+            MarkExtensionUnsupported(KHR_stream_consumer_gltexture);
+        }
+    }
+
+    if (IsExtensionSupported(EXT_device_base)) {
+        const GLLibraryLoader::SymLoadStruct deviceBaseSymbols[] = {
+            SYMBOL(QueryDisplayAttribEXT),
+            END_OF_SYMBOLS
+        };
+        if (!fnLoadSymbols(deviceBaseSymbols)) {
+            NS_ERROR("EGL supports EXT_device_base without exposing its functions!");
+            MarkExtensionUnsupported(EXT_device_base);
+        }
+    }
+
+    if (IsExtensionSupported(EXT_device_query)) {
+        const GLLibraryLoader::SymLoadStruct queryDisplaySymbols[] = {
+            SYMBOL(QueryDeviceAttribEXT),
+            END_OF_SYMBOLS
+        };
+        if (!fnLoadSymbols(queryDisplaySymbols)) {
+            NS_ERROR("EGL supports EXT_device_query without exposing its functions!");
+            MarkExtensionUnsupported(EXT_device_query);
+        }
+    }
+
+    if (IsExtensionSupported(NV_stream_consumer_gltexture_yuv)) {
+        const GLLibraryLoader::SymLoadStruct nvStreamSymbols[] = {
+            SYMBOL(StreamConsumerGLTextureExternalAttribsNV),
+            END_OF_SYMBOLS
+        };
+        if (!fnLoadSymbols(nvStreamSymbols)) {
+            NS_ERROR("EGL supports NV_stream_consumer_gltexture_yuv without exposing its functions!");
+            MarkExtensionUnsupported(NV_stream_consumer_gltexture_yuv);
+        }
+    }
+
+    if (IsExtensionSupported(ANGLE_stream_producer_d3d_texture_nv12)) {
+        const GLLibraryLoader::SymLoadStruct nvStreamSymbols[] = {
+            SYMBOL(CreateStreamProducerD3DTextureNV12ANGLE),
+            SYMBOL(StreamPostD3DTextureNV12ANGLE),
+            END_OF_SYMBOLS
+        };
+        if (!fnLoadSymbols(nvStreamSymbols)) {
+            NS_ERROR("EGL supports ANGLE_stream_producer_d3d_texture_nv12 without exposing its functions!");
+            MarkExtensionUnsupported(ANGLE_stream_producer_d3d_texture_nv12);
+        }
+    }
+
     mInitialized = true;
     reporter.SetSuccessful();
     return true;
 }
 
 #undef SYMBOL
 #undef END_OF_SYMBOLS
 
--- a/gfx/gl/GLLibraryEGL.h
+++ b/gfx/gl/GLLibraryEGL.h
@@ -101,16 +101,22 @@ public:
         KHR_image,
         KHR_fence_sync,
         ANDROID_native_fence_sync,
         EGL_ANDROID_image_crop,
         ANGLE_platform_angle,
         ANGLE_platform_angle_d3d,
         ANGLE_d3d_share_handle_client_buffer,
         KHR_create_context,
+        KHR_stream,
+        KHR_stream_consumer_gltexture,
+        EXT_device_base,
+        EXT_device_query,
+        NV_stream_consumer_gltexture_yuv,
+        ANGLE_stream_producer_d3d_texture_nv12,
         Extensions_Max
     };
 
     bool IsExtensionSupported(EGLExtensions aKnownExtension) const {
         return mAvailableExtensions[aKnownExtension];
     }
 
     void MarkExtensionUnsupported(EGLExtensions aKnownExtension) {
@@ -277,16 +283,52 @@ public:
         WRAP( fClientWaitSyncKHR(dpy, sync, flags, timeout) )
 
     EGLBoolean fGetSyncAttrib(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLint* value) const
         WRAP(  fGetSyncAttribKHR(dpy, sync, attribute, value) )
 
     EGLint    fDupNativeFenceFDANDROID(EGLDisplay dpy, EGLSync sync) const
         WRAP( fDupNativeFenceFDANDROID(dpy, sync) )
 
+    //KHR_stream
+    EGLStreamKHR fCreateStreamKHR(EGLDisplay dpy, const EGLint* attrib_list) const
+        WRAP(    fCreateStreamKHR(dpy, attrib_list) )
+
+    EGLStreamKHR fDestroyStreamKHR(EGLDisplay dpy, EGLStreamKHR stream) const
+        WRAP(    fDestroyStreamKHR(dpy, stream) )
+
+    EGLBoolean  fQueryStreamKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint* value) const
+        WRAP(   fQueryStreamKHR(dpy, stream, attribute, value) )
+
+    // KHR_stream_consumer_gltexture
+    EGLBoolean  fStreamConsumerAcquireKHR(EGLDisplay dpy, EGLStreamKHR stream) const
+        WRAP(   fStreamConsumerAcquireKHR(dpy, stream) )
+
+    EGLBoolean  fStreamConsumerReleaseKHR(EGLDisplay dpy, EGLStreamKHR stream) const
+        WRAP(   fStreamConsumerReleaseKHR(dpy, stream) )
+
+    // EXT_device_base
+    EGLBoolean  fQueryDisplayAttribEXT(EGLDisplay dpy, EGLint attribute, EGLAttrib* value) const
+        WRAP(   fQueryDisplayAttribEXT(dpy, attribute, value) )
+
+    // EXT_device_query
+    EGLBoolean  fQueryDeviceAttribEXT(EGLDeviceEXT device, EGLint attribute, EGLAttrib* value) const
+        WRAP(   fQueryDeviceAttribEXT(device, attribute, value) )
+
+    // NV_stream_consumer_gltexture_yuv
+    EGLBoolean  fStreamConsumerGLTextureExternalAttribsNV(EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib* attrib_list) const
+        WRAP(   fStreamConsumerGLTextureExternalAttribsNV(dpy, stream, attrib_list) )
+
+    // ANGLE_stream_producer_d3d_texture_nv12
+    EGLBoolean  fCreateStreamProducerD3DTextureNV12ANGLE(EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib* attrib_list) const
+        WRAP(   fCreateStreamProducerD3DTextureNV12ANGLE(dpy, stream, attrib_list) )
+
+    EGLBoolean  fStreamPostD3DTextureNV12ANGLE(EGLDisplay dpy, EGLStreamKHR stream, void* texture, const EGLAttrib* attrib_list) const
+        WRAP(   fStreamPostD3DTextureNV12ANGLE(dpy, stream, texture, attrib_list) )
+
     void           fANGLEPlatformInitialize(angle::Platform* platform) const
         VOID_WRAP( fANGLEPlatformInitialize(platform) )
 
     void fANGLEPlatformShutdown() const
         VOID_WRAP( fANGLEPlatformShutdown() )
 
 #undef WRAP
 #undef VOID_WRAP
@@ -405,16 +447,48 @@ private:
                                                  const EGLint* attrib_list);
         EGLBoolean (GLAPIENTRY * fDestroySyncKHR)(EGLDisplay dpy, EGLSync sync);
         EGLint     (GLAPIENTRY * fClientWaitSyncKHR)(EGLDisplay dpy, EGLSync sync,
                                                      EGLint flags,
                                                      EGLTime timeout);
         EGLBoolean (GLAPIENTRY * fGetSyncAttribKHR)(EGLDisplay dpy, EGLSync sync,
                                                     EGLint attribute, EGLint* value);
         EGLint     (GLAPIENTRY * fDupNativeFenceFDANDROID)(EGLDisplay dpy, EGLSync sync);
+        //KHR_stream
+        EGLStreamKHR (GLAPIENTRY * fCreateStreamKHR)(EGLDisplay dpy, const EGLint* attrib_list);
+        EGLStreamKHR (GLAPIENTRY * fDestroyStreamKHR)(EGLDisplay dpy, EGLStreamKHR stream);
+        EGLBoolean (GLAPIENTRY * fQueryStreamKHR)(EGLDisplay dpy,
+                                                  EGLStreamKHR stream,
+                                                  EGLenum attribute,
+                                                  EGLint* value);
+        // KHR_stream_consumer_gltexture
+        EGLBoolean (GLAPIENTRY * fStreamConsumerAcquireKHR)(EGLDisplay dpy,
+                                                            EGLStreamKHR stream);
+        EGLBoolean (GLAPIENTRY * fStreamConsumerReleaseKHR)(EGLDisplay dpy,
+                                                            EGLStreamKHR stream);
+        // EXT_device_base
+        EGLBoolean (GLAPIENTRY * fQueryDisplayAttribEXT)(EGLDisplay dpy,
+                                                         EGLint attribute,
+                                                         EGLAttrib* value);
+        // EXT_device_query
+        EGLBoolean (GLAPIENTRY * fQueryDeviceAttribEXT)(EGLDeviceEXT device,
+                                                        EGLint attribute,
+                                                        EGLAttrib* value);
+        // NV_stream_consumer_gltexture_yuv
+        EGLBoolean (GLAPIENTRY * fStreamConsumerGLTextureExternalAttribsNV)(EGLDisplay dpy,
+                                                                            EGLStreamKHR stream,
+                                                                            const EGLAttrib* attrib_list);
+        // ANGLE_stream_producer_d3d_texture_nv12
+        EGLBoolean (GLAPIENTRY * fCreateStreamProducerD3DTextureNV12ANGLE)(EGLDisplay dpy,
+                                                                           EGLStreamKHR stream,
+                                                                           const EGLAttrib* attrib_list);
+        EGLBoolean (GLAPIENTRY * fStreamPostD3DTextureNV12ANGLE)(EGLDisplay dpy,
+                                                                 EGLStreamKHR stream,
+                                                                 void* texture,
+                                                                 const EGLAttrib* attrib_list);
         void       (GLAPIENTRY * fANGLEPlatformInitialize)(angle::Platform* platform);
         void       (GLAPIENTRY * fANGLEPlatformShutdown)();
     } mSymbols;
 
 public:
 #ifdef MOZ_B2G
     EGLContext CachedCurrentContext() {
         return sCurrentContext.get();
--- a/gfx/gl/GLTypes.h
+++ b/gfx/gl/GLTypes.h
@@ -69,24 +69,27 @@ typedef void (GLAPIENTRY *GLDEBUGPROC)(G
                                        const GLchar* message,
                                        const GLvoid* userParam);
 
 // EGL types
 typedef void* EGLImage;
 typedef int EGLint;
 typedef unsigned int EGLBoolean;
 typedef unsigned int EGLenum;
+typedef intptr_t EGLAttrib;
 typedef void* EGLConfig;
 typedef void* EGLContext;
 typedef void* EGLDisplay;
+typedef void* EGLDeviceEXT;
 typedef void* EGLSurface;
 typedef void* EGLClientBuffer;
 typedef void* EGLCastToRelevantPtr;
 typedef void* EGLImage;
 typedef void* EGLSync;
+typedef void* EGLStreamKHR;
 typedef uint64_t EGLTime;
 
 #define EGL_NO_CONTEXT       ((EGLContext)0)
 #define EGL_NO_DISPLAY       ((EGLDisplay)0)
 #define EGL_NO_SURFACE       ((EGLSurface)0)
 #define EGL_NO_CONFIG        ((EGLConfig)nullptr)
 #define EGL_NO_SYNC          ((EGLSync)0)
 #define EGL_NO_IMAGE         ((EGLImage)0)