Fix support for NativeImage 90/129690/3
authorNick Holland <nick.holland@partner.samsung.com>
Wed, 10 May 2017 14:32:17 +0000 (15:32 +0100)
committerPaul Wisbey <p.wisbey@samsung.com>
Wed, 17 May 2017 15:31:20 +0000 (16:31 +0100)
- Fixed program to recognise uniforms with type: GL_SAMPLER_EXTERNAL_OES
- Fixed Framebuffer renderer to use GL_TEXTURE_EXTERNAL_OES

Change-Id: I337ab3f461aa43fd10b311895b2f186b2462e617

dali/integration-api/gl-defines.h
dali/internal/render/renderers/render-frame-buffer.cpp
dali/internal/render/renderers/render-texture.h
dali/internal/render/shaders/program.cpp

index eebb484..8a2f740 100644 (file)
 #define GL_TEXTURE_EXTERNAL_OES                                 0x8D65
 #endif
 
+/* GL_SAMPLER_EXTERNAL_OES  */
+#ifndef GL_SAMPLER_EXTERNAL_OES
+#define GL_SAMPLER_EXTERNAL_OES                                 0x8D66
+#endif
 
 #endif // __DALI_INTERNAL_GL_DEFINES_H__
index 6281d9b..238a8cf 100644 (file)
@@ -85,7 +85,15 @@ void FrameBuffer::AttachColorTexture( Context& context, Render::Texture* texture
   // Create a color attachment.
   if( texture->GetType() == TextureType::TEXTURE_2D )
   {
-    context.FramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture->GetId(), mipmapLevel );
+    if( !texture->IsNativeImage() )
+    {
+      context.FramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture->GetId(), mipmapLevel );
+    }
+    else
+    {
+      // If it's a native image we need to use GL_TEXTURE_EXTERNAL_OES as the texture target parameter
+      context.FramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_EXTERNAL_OES, texture->GetId(), mipmapLevel );
+    }
   }
   else
   {
index db5988b..e50ec3d 100644 (file)
@@ -145,6 +145,15 @@ public:
     return mType;
   }
 
+  /**
+   * Check if the texture is a native image
+   * @return if the texture is a native image
+   */
+  bool IsNativeImage() const
+  {
+    return mNativeImage;
+  }
+
 private:
 
   /**
@@ -161,7 +170,7 @@ private:
   NativeImageInterfacePtr mNativeImage; ///< Pointer to native image
   GLenum mInternalFormat;               ///< The format of the pixel data
   GLenum mPixelDataType;                ///< The data type of the pixel data
-  unsigned int mWidth;                  ///< Widht of the texture
+  unsigned int mWidth;                  ///< Width of the texture
   unsigned int mHeight;                 ///< Height of the texture
   bool mHasAlpha : 1;                   ///< Whether the format has an alpha channel
   bool mIsCompressed : 1;               ///< Whether the format is compressed
index 0f22758..5739f18 100644 (file)
@@ -261,7 +261,7 @@ void Program::GetActiveSamplerUniforms()
       mGlAbstraction.GetActiveUniform( mProgramId, (GLuint)i, uniformMaxNameLength,
                                        &nameLength, &number, &type, name );
 
-      if( type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE ) /// Is there a native sampler type?
+      if( type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE || type == GL_SAMPLER_EXTERNAL_OES )
       {
         GLuint location = mGlAbstraction.GetUniformLocation( mProgramId, name );
         samplerNames.push_back(name);
@@ -277,7 +277,9 @@ void Program::GetActiveSamplerUniforms()
   int samplerPosition = 0;
   while( token )
   {
-    if( ( strncmp( token, "sampler2D", 9u ) == 0 ) || ( strncmp( token, "samplerCube", 11u ) == 0 ) )
+    if( ( strncmp( token, "sampler2D", 9u )    == 0 ) ||
+        ( strncmp( token, "samplerCube", 11u ) == 0 ) ||
+        ( strncmp( token, "samplerExternalOES", 18u ) == 0 ) )
     {
       bool found( false );
       token = strtok_r( NULL, " ;\n", &nextPtr );