diff --git a/ogles_gpgpu/common/gl/memtransfer_factory.cpp b/ogles_gpgpu/common/gl/memtransfer_factory.cpp index 11bdf05..4f180cc 100644 --- a/ogles_gpgpu/common/gl/memtransfer_factory.cpp +++ b/ogles_gpgpu/common/gl/memtransfer_factory.cpp @@ -11,10 +11,8 @@ #include "../core.h" // clang-off -#if defined(OGLES_GPGPU_IOS) && !defined(OGLES_GPGPU_OPENGL_ES3) +#if defined(OGLES_GPGPU_IOS) # include "../../platform/ios/memtransfer_ios.h" -#elif defined(OGLES_GPGPU_ANDROID) && !defined(OGLES_GPGPU_OPENGL_ES3) -# include "../../platform/android/memtransfer_android.h" #else # include "../../platform/opengl/memtransfer_generic.h" #endif @@ -28,10 +26,8 @@ std::unique_ptr MemTransferFactory::createInstance() { std::unique_ptr instance; if (usePlatformOptimizations) { // create specialized instance -#if defined(OGLES_GPGPU_IOS) && !defined(OGLES_GPGPU_OPENGL_ES3) +#if defined(OGLES_GPGPU_IOS) instance = std::unique_ptr(new MemTransferIOS); -#elif defined(OGLES_GPGPU_ANDROID) && !defined(OGLES_GPGPU_OPENGL_ES3) - instance = std::unique_ptr(new MemTransferAndroid); #else instance = std::unique_ptr(new MemTransfer); #endif @@ -45,10 +41,8 @@ std::unique_ptr MemTransferFactory::createInstance() { } bool MemTransferFactory::tryEnablePlatformOptimizations() { -#if defined(OGLES_GPGPU_IOS) && !defined(OGLES_GPGPU_OPENGL_ES3) +#if defined(OGLES_GPGPU_IOS) usePlatformOptimizations = MemTransferIOS::initPlatformOptimizations(); -#elif defined(OGLES_GPGPU_ANDROID) && !defined(OGLES_GPGPU_OPENGL_ES3) - usePlatformOptimizations = MemTransferAndroid::initPlatformOptimizations(); #else usePlatformOptimizations = false; #endif diff --git a/ogles_gpgpu/common/proc/video.cpp b/ogles_gpgpu/common/proc/video.cpp index 1df2c52..089036e 100644 --- a/ogles_gpgpu/common/proc/video.cpp +++ b/ogles_gpgpu/common/proc/video.cpp @@ -10,6 +10,12 @@ #include "yuv2rgb.h" #include +#if defined(OGLES_GPGPU_OPENGL_ES3) +# define OGLES_GPGPU_BIPLANAR_CHANNEL_KIND Yuv2RgbProc::kRG +#else +# define OGLES_GPGPU_BIPLANAR_CHANNEL_KIND Yuv2RgbProc::kLA +#endif + using namespace ogles_gpgpu; VideoSource::VideoSource(void* glContext) { @@ -44,7 +50,7 @@ GLuint VideoSource::getInputTexId() { void VideoSource::configurePipeline(const Size2d& size, GLenum inputPixFormat) { if (inputPixFormat == 0) { // 0 == NV{12,21} if (!yuv2RgbProc) { - yuv2RgbProc = std::make_shared(); + yuv2RgbProc = std::make_shared(Yuv2RgbProc::k601VideoRange, OGLES_GPGPU_BIPLANAR_CHANNEL_KIND); yuv2RgbProc->setExternalInputDataFormat(inputPixFormat); yuv2RgbProc->init(size.width, size.height, 0, true); frameSize = size; diff --git a/ogles_gpgpu/platform/ios/memtransfer_ios.cpp b/ogles_gpgpu/platform/ios/memtransfer_ios.cpp index df3d6b9..19274cd 100644 --- a/ogles_gpgpu/platform/ios/memtransfer_ios.cpp +++ b/ogles_gpgpu/platform/ios/memtransfer_ios.cpp @@ -13,8 +13,6 @@ #include "../../common/core.h" -#include "../../common/proc/yuv2rgb.h" - /** * Most code as from http://allmybrain.com/2011/12/08/rendering-to-a-texture-with-ios-5-texture-cache-api/ */ @@ -280,10 +278,10 @@ GLuint MemTransferIOS::prepareInput(int inTexW, int inTexH, GLenum inputPxFormat bufRef, NULL, GL_TEXTURE_2D, - GL_LUMINANCE, + OGLES_GPGPU_PLANAR_INTERNAL_FORMAT, inputW, inputH, - GL_LUMINANCE, + OGLES_GPGPU_PLANAR_FORMAT, GL_UNSIGNED_BYTE, 0, &luminanceTextureRef); @@ -305,10 +303,10 @@ GLuint MemTransferIOS::prepareInput(int inTexW, int inTexH, GLenum inputPxFormat bufRef, NULL, GL_TEXTURE_2D, - GL_LUMINANCE_ALPHA, + OGLES_GPGPU_BIPLANAR_INTERNAL_FORMAT, inputW / 2, inputH / 2, - GL_LUMINANCE_ALPHA, + OGLES_GPGPU_BIPLANAR_FORMAT, GL_UNSIGNED_BYTE, 1, &chrominanceTextureRef); diff --git a/ogles_gpgpu/platform/ios/memtransfer_ios.h b/ogles_gpgpu/platform/ios/memtransfer_ios.h index f8433d7..883dbaa 100644 --- a/ogles_gpgpu/platform/ios/memtransfer_ios.h +++ b/ogles_gpgpu/platform/ios/memtransfer_ios.h @@ -22,8 +22,6 @@ namespace ogles_gpgpu { -class Yuv2RgbProc; // forward declaration - /** * MemTransferIOS is a platform specific implementation for fast texture access on iOS platforms. * It uses CoreVideo's TextureCache API as explained at @@ -142,8 +140,6 @@ class MemTransferIOS : public MemTransfer, public MemTransferOptimized { size_t inputPixelBufferSize; // input pixel buffer size in bytes size_t outputPixelBufferSize; // output pixel buffer size in bytes - - std::shared_ptr yuv2rgb; }; } #endif diff --git a/ogles_gpgpu/platform/opengl/gl_includes.h b/ogles_gpgpu/platform/opengl/gl_includes.h index 4138bea..69bb045 100755 --- a/ogles_gpgpu/platform/opengl/gl_includes.h +++ b/ogles_gpgpu/platform/opengl/gl_includes.h @@ -78,6 +78,18 @@ #else # define OGLES_GPGPU_TEXTURE_FORMAT GL_BGRA #endif + +#if defined(OGLES_GPGPU_OPENGL_ES3) +# define OGLES_GPGPU_PLANAR_INTERNAL_FORMAT GL_R8 +# define OGLES_GPGPU_PLANAR_FORMAT GL_RED +# define OGLES_GPGPU_BIPLANAR_INTERNAL_FORMAT GL_RG8 +# define OGLES_GPGPU_BIPLANAR_FORMAT GL_RG +#else +# define OGLES_GPGPU_PLANAR_INTERNAL_FORMAT GL_LUMINANCE +# define OGLES_GPGPU_PLANAR_FORMAT GL_LUMINANCE +# define OGLES_GPGPU_BIPLANAR_INTERNAL_FORMAT GL_LUMINANCE_ALPHA +# define OGLES_GPGPU_BIPLANAR_FORMAT GL_LUMINANCE_ALPHA +#endif // clang-format off #endif // OGLES_GPGPU_OPENGL_GL_INCLUDES diff --git a/ogles_gpgpu/platform/sugar.cmake b/ogles_gpgpu/platform/sugar.cmake index 7b1d910..f2dbb13 100644 --- a/ogles_gpgpu/platform/sugar.cmake +++ b/ogles_gpgpu/platform/sugar.cmake @@ -11,28 +11,12 @@ endif() include(sugar_include) -if(ANDROID OR IOS) - set(ogles_gpgpu_is_mobile TRUE) +# We drop support for sugar_include(android) due to platforms +# specific extensions that require dlopen() based system lib +# access, since dlopen() calls are blocked in recent versions +# of Android. +if(IOS) + sugar_include(ios) else() - set(ogles_gpgpu_is_mobile FALSE) -endif() - -# We will use the vanilla OpenGL implementation in case -# of standard OpenGL platforms (i.e., not OpenGL ES) or -# in cases where >= OpenGL ES 3.0 is available. On those -# platforms we can use PBO for efficient GPU->CPU reads. -# If we are using OpenGL ES 2.0 on mobile devices then -# we will use platform specific extensions to facilitate -# efficient DMA reads of OpenGL textures. -if(OGLES_GPGPU_OPENGL_ES3 OR NOT ${ogles_gpgpu_is_mobile}) sugar_include(opengl) -else() - if(IOS) - sugar_include(ios) - elseif(ANDROID) - sugar_include(android ) - endif() endif() - - -