diff --git a/CMakeLists.txt b/CMakeLists.txt index cb7b327..0fb82dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,16 +9,34 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/modules") include("cmake/HunterGate.cmake") HunterGate( - URL "https://github.com/ruslo/hunter/archive/v0.22.13.tar.gz" - SHA1 "8b361d14d17c3526d41ecb62b6e905bdd9f3ee1d" + URL "https://github.com/ruslo/hunter/archive/v0.23.151.tar.gz" + SHA1 "68657b81508c2d3c248731b5a0c2125f19866721" LOCAL -) + ) -project(ogles_gpgpu VERSION 0.3.6) +project(ogles_gpgpu VERSION 0.3.7) -hunter_add_package(check_ci_tag) -find_package(check_ci_tag CONFIG REQUIRED) -check_ci_tag() +# !!! Make sure option OGLES_GPGPU_OPENG_ES3 occurs prior to the first +# hunter_add_package() call. This will allow us to modify settings +# in dependencies appropriately (see cmake/Hunter/config.cmake) + +if(IOS OR ANDROID) + set(ogles_gpgpu_opengl_es2_dflt ON) + set(ogles_gpgpu_opengl_es3_dflt OFF) +else() + set(ogles_gpgpu_opengl_es2_dflt OFF) + set(ogles_gpgpu_opengl_es3_dflt OFF) +endif() + +option(OGLES_GPGPU_OPENGL_ES2 "Use OpenGL ES 2.0" ${ogles_gpgpu_opengl_es2_dflt}) +option(OGLES_GPGPU_OPENGL_ES3 "Use OpenGL ES 3.0" ${ogles_gpgpu_opengl_es3_dflt}) +option(OGLES_GPGPU_USE_EGL "Use EGL to manage the context (supports ES)" OFF) + +if(OGLES_GPGPU_OPENGL_ES2 AND OGLES_GPGPU_OPENGL_ES3) + message(FATAL_ERROR + "OGLES_GPGPU_OPENGL_ES2 and OGLES_GPGPU_OPENGL_ES3 are mutually exclusive" + ) +endif() set_property(GLOBAL PROPERTY USE_FOLDERS ON) @@ -30,10 +48,9 @@ option(OGLES_GPGPU_VERBOSE "Perform per filter logging" OFF) option(OGLES_GPGPU_BUILD_TESTS "Build shader unit tests" OFF) option(OGLES_GPGPU_USE_OSMESA "Use MESA CPU OpenGL (via glfw)" OFF) -# !!! Make sure option OGLES_GPGPU_OPENG_ES3 occurs prior to the first -# hunter_add_package() call. This will allow us to modify settings -# in dependencies appropriately (see cmake/Hunter/config.cmake) -option(OGLES_GPGPU_OPENGL_ES3 "Use OpenGL ES 3.0" OFF) +hunter_add_package(check_ci_tag) +find_package(check_ci_tag CONFIG REQUIRED) +check_ci_tag() # See: cmake/Hunter/config.cmake hunter_add_package(sugar) @@ -71,37 +88,11 @@ endif() # but they may only be run on platforms where an OpenGL context # is available if(OGLES_GPGPU_BUILD_TESTS) - if(IOS AND DRISHTI_CI) # do not run test on CI (TODO: remote device testing) else() enable_testing() endif() - - # Use GTest as unit test framework - hunter_add_package(GTest) - find_package(GTest CONFIG REQUIRED) - list(APPEND OGLES_GPGPU_TEST_LIBS GTest::gtest) - - if(MSVC) - # TODO: Temporary aglet fix for appveyor? Shouldn't be needed. - hunter_add_package(glew) - find_package(glew CONFIG REQUIRED) - endif() - - # Use aglet for portable lightweight off screen opengl context - hunter_add_package(aglet) - find_package(aglet CONFIG REQUIRED) - list(APPEND OGLES_GPGPU_TEST_LIBS aglet::aglet) - - # Use gauze for cross platform ctesting - hunter_add_package(gauze) - find_package(gauze CONFIG REQUIRED) - list(APPEND OGLES_GPGPU_TEST_LIBS gauze::gauze) - - hunter_add_package(OpenCV) - find_package(OpenCV REQUIRED) - list(APPEND OGLES_GPGPU_TEST_LIBS "${OpenCV_LIBS}") endif() ## ################################################################# diff --git a/cmake/Config.cmake.in b/cmake/Config.cmake.in index bd9458f..37370ba 100644 --- a/cmake/Config.cmake.in +++ b/cmake/Config.cmake.in @@ -24,7 +24,13 @@ elseif(@APPLE@) find_package(OpenGL REQUIRED) endif() else() - find_package(OpenGL REQUIRED) + if(@OGLES_GPGPU_OPENGL_ES2@) + find_package(gles2 REQUIRED) + elseif(@OGLES_GPGPU_OPENGL_ES3@) + find_package(gles3 REQUIRED) + else() + find_package(OpenGL REQUIRED) + endif() endif() include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake") diff --git a/cmake/Hunter/config.cmake b/cmake/Hunter/config.cmake index bb3efba..d2c3be7 100644 --- a/cmake/Hunter/config.cmake +++ b/cmake/Hunter/config.cmake @@ -17,16 +17,16 @@ if(OGLES_GPGPU_USE_OSMESA) hunter_config(glfw VERSION ${HUNTER_glfw_VERSION} CMAKE_ARGS GLFW_USE_OSMESA=ON) endif() -# Note: Aglet is currently used to provide an OpenGL context for the unit tests -# We need to make sure it is configured appropriately to provide one of: -# * OpenGL ES 3.0 (or OpenGL 3.0) -# * OpenGL ES 2.0 -# The context must be allocated approprately and we need to pull in the correct -# set of headers with mixing them. -if(OGLES_GPGPU_OPENGL_ES3) - set(aglet_es3 ON) -else() - set(aglet_es3 OFF) -endif() +message("AGLET_OPENGL_ES3=${OGLES_GPGPU_OPENGL_ES3}") + +set(aglet_url "https://github.com/elucideye/aglet/archive/v1.3.3.tar.gz") +set(aglet_sha1 432ad86638c30d221ad444ab73af214c2fe5a180) +set(aglet_args + "AGLET_USE_EGL=${OGLES_GPGPU_USE_EGL}" + "AGLET_OPENGL_ES2=${OGLES_GPGPU_OPENGL_ES2}" + "AGLET_OPENGL_ES3=${OGLES_GPGPU_OPENGL_ES3}" +) + +#hunter_config(aglet VERSION ${HUNTER_aglet_VERSION} CMAKE_ARGS AGLET_OPENGL_ES3=${aglet_es3}) +hunter_config(aglet URL ${aglet_url} SHA1 ${aglet_sha1} CMAKE_ARGS ${aglet_args}) -hunter_config(aglet VERSION ${HUNTER_aglet_VERSION} CMAKE_ARGS AGLET_OPENGL_ES3=${aglet_es3}) diff --git a/cmake/HunterGate.cmake b/cmake/HunterGate.cmake index c24c0e5..e78d3e8 100644 --- a/cmake/HunterGate.cmake +++ b/cmake/HunterGate.cmake @@ -1,4 +1,4 @@ -# Copyright (c) 2013-2017, Ruslan Baratov +# Copyright (c) 2013-2019, Ruslan Baratov # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -25,7 +25,7 @@ # This is a gate file to Hunter package manager. # Include this file using `include` command and add package you need, example: # -# cmake_minimum_required(VERSION 3.0) +# cmake_minimum_required(VERSION 3.2) # # include("cmake/HunterGate.cmake") # HunterGate( @@ -43,10 +43,14 @@ # * https://github.com/ruslo/hunter option(HUNTER_ENABLED "Enable Hunter package manager support" ON) + if(HUNTER_ENABLED) - if(CMAKE_VERSION VERSION_LESS "3.0") - message(FATAL_ERROR "At least CMake version 3.0 required for hunter dependency management." - " Update CMake or set HUNTER_ENABLED to OFF.") + if(CMAKE_VERSION VERSION_LESS "3.2") + message( + FATAL_ERROR + "At least CMake version 3.2 required for Hunter dependency management." + " Update CMake or set HUNTER_ENABLED to OFF." + ) endif() endif() @@ -56,28 +60,28 @@ option(HUNTER_STATUS_PRINT "Print working status" ON) option(HUNTER_STATUS_DEBUG "Print a lot info" OFF) option(HUNTER_TLS_VERIFY "Enable/disable TLS certificate checking on downloads" ON) -set(HUNTER_WIKI "https://github.com/ruslo/hunter/wiki") +set(HUNTER_ERROR_PAGE "https://docs.hunter.sh/en/latest/reference/errors") function(hunter_gate_status_print) - foreach(print_message ${ARGV}) - if(HUNTER_STATUS_PRINT OR HUNTER_STATUS_DEBUG) + if(HUNTER_STATUS_PRINT OR HUNTER_STATUS_DEBUG) + foreach(print_message ${ARGV}) message(STATUS "[hunter] ${print_message}") - endif() - endforeach() + endforeach() + endif() endfunction() function(hunter_gate_status_debug) - foreach(print_message ${ARGV}) - if(HUNTER_STATUS_DEBUG) + if(HUNTER_STATUS_DEBUG) + foreach(print_message ${ARGV}) string(TIMESTAMP timestamp) message(STATUS "[hunter *** DEBUG *** ${timestamp}] ${print_message}") - endif() - endforeach() + endforeach() + endif() endfunction() -function(hunter_gate_wiki wiki_page) - message("------------------------------ WIKI -------------------------------") - message(" ${HUNTER_WIKI}/${wiki_page}") +function(hunter_gate_error_page error_page) + message("------------------------------ ERROR ------------------------------") + message(" ${HUNTER_ERROR_PAGE}/${error_page}.html") message("-------------------------------------------------------------------") message("") message(FATAL_ERROR "") @@ -90,14 +94,13 @@ function(hunter_gate_internal_error) endforeach() message("[hunter ** INTERNAL **] [Directory:${CMAKE_CURRENT_LIST_DIR}]") message("") - hunter_gate_wiki("error.internal") + hunter_gate_error_page("error.internal") endfunction() function(hunter_gate_fatal_error) - cmake_parse_arguments(hunter "" "WIKI" "" "${ARGV}") - string(COMPARE EQUAL "${hunter_WIKI}" "" have_no_wiki) - if(have_no_wiki) - hunter_gate_internal_error("Expected wiki") + cmake_parse_arguments(hunter "" "ERROR_PAGE" "" "${ARGV}") + if("${hunter_ERROR_PAGE}" STREQUAL "") + hunter_gate_internal_error("Expected ERROR_PAGE") endif() message("") foreach(x ${hunter_UNPARSED_ARGUMENTS}) @@ -105,11 +108,11 @@ function(hunter_gate_fatal_error) endforeach() message("[hunter ** FATAL ERROR **] [Directory:${CMAKE_CURRENT_LIST_DIR}]") message("") - hunter_gate_wiki("${hunter_WIKI}") + hunter_gate_error_page("${hunter_ERROR_PAGE}") endfunction() function(hunter_gate_user_error) - hunter_gate_fatal_error(${ARGV} WIKI "error.incorrect.input.data") + hunter_gate_fatal_error(${ARGV} ERROR_PAGE "error.incorrect.input.data") endfunction() function(hunter_gate_self root version sha1 result) @@ -130,14 +133,10 @@ function(hunter_gate_self root version sha1 result) string(SUBSTRING "${sha1}" 0 7 archive_id) - if(EXISTS "${root}/cmake/Hunter") - set(hunter_self "${root}") - else() - set( - hunter_self - "${root}/_Base/Download/Hunter/${version}/${archive_id}/Unpacked" - ) - endif() + set( + hunter_self + "${root}/_Base/Download/Hunter/${version}/${archive_id}/Unpacked" + ) set("${result}" "${hunter_self}" PARENT_SCOPE) endfunction() @@ -191,24 +190,10 @@ function(hunter_gate_detect_root) hunter_gate_fatal_error( "Can't detect HUNTER_ROOT" - WIKI "error.detect.hunter.root" + ERROR_PAGE "error.detect.hunter.root" ) endfunction() -macro(hunter_gate_lock dir) - if(NOT HUNTER_SKIP_LOCK) - if("${CMAKE_VERSION}" VERSION_LESS "3.2") - hunter_gate_fatal_error( - "Can't lock, upgrade to CMake 3.2 or use HUNTER_SKIP_LOCK" - WIKI "error.can.not.lock" - ) - endif() - hunter_gate_status_debug("Locking directory: ${dir}") - file(LOCK "${dir}" DIRECTORY GUARD FUNCTION) - hunter_gate_status_debug("Lock done") - endif() -endmacro() - function(hunter_gate_download dir) string( COMPARE @@ -224,7 +209,7 @@ function(hunter_gate_download dir) "Settings:" " HUNTER_ROOT: ${HUNTER_GATE_ROOT}" " HUNTER_SHA1: ${HUNTER_GATE_SHA1}" - WIKI "error.run.install" + ERROR_PAGE "error.run.install" ) endif() string(COMPARE EQUAL "${dir}" "" is_bad) @@ -248,7 +233,10 @@ function(hunter_gate_download dir) set(build_dir "${dir}/Build") set(cmakelists "${dir}/CMakeLists.txt") - hunter_gate_lock("${dir}") + hunter_gate_status_debug("Locking directory: ${dir}") + file(LOCK "${dir}" DIRECTORY GUARD FUNCTION) + hunter_gate_status_debug("Lock done") + if(EXISTS "${done_location}") # while waiting for lock other instance can do all the job hunter_gate_status_debug("File '${done_location}' found, skip install") @@ -265,7 +253,7 @@ function(hunter_gate_download dir) file( WRITE "${cmakelists}" - "cmake_minimum_required(VERSION 3.0)\n" + "cmake_minimum_required(VERSION 3.2)\n" "project(HunterDownload LANGUAGES NONE)\n" "include(ExternalProject)\n" "ExternalProject_Add(\n" @@ -330,7 +318,11 @@ function(hunter_gate_download dir) ) if(NOT download_result EQUAL 0) - hunter_gate_internal_error("Configure project failed") + hunter_gate_internal_error( + "Configure project failed." + "To reproduce the error run: ${CMAKE_COMMAND} -H${dir} -B${build_dir} -G${CMAKE_GENERATOR} ${toolchain_arg} ${make_arg}" + "In directory ${dir}" + ) endif() hunter_gate_status_print( @@ -396,14 +388,14 @@ macro(HunterGate) ) include("${_hunter_self}/cmake/Hunter") else() - set(HUNTER_GATE_LOCATION "${CMAKE_CURRENT_LIST_DIR}") + set(HUNTER_GATE_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}") string(COMPARE NOTEQUAL "${PROJECT_NAME}" "" _have_project_name) if(_have_project_name) hunter_gate_fatal_error( "Please set HunterGate *before* 'project' command. " "Detected project: ${PROJECT_NAME}" - WIKI "error.huntergate.before.project" + ERROR_PAGE "error.huntergate.before.project" ) endif() @@ -473,7 +465,7 @@ macro(HunterGate) "HUNTER_ROOT (${HUNTER_GATE_ROOT}) contains spaces." "Set HUNTER_ALLOW_SPACES_IN_PATH=ON to skip this error" "(Use at your own risk!)" - WIKI "error.spaces.in.hunter.root" + ERROR_PAGE "error.spaces.in.hunter.root" ) endif() endif() @@ -498,44 +490,37 @@ macro(HunterGate) ) set(_master_location "${_hunter_self}/cmake/Hunter") - if(EXISTS "${HUNTER_GATE_ROOT}/cmake/Hunter") - # Hunter downloaded manually (e.g. by 'git clone') - set(_unused "xxxxxxxxxx") - set(HUNTER_GATE_SHA1 "${_unused}") - set(HUNTER_GATE_VERSION "${_unused}") - else() - get_filename_component(_archive_id_location "${_hunter_self}/.." ABSOLUTE) - set(_done_location "${_archive_id_location}/DONE") - set(_sha1_location "${_archive_id_location}/SHA1") - - # Check Hunter already downloaded by HunterGate - if(NOT EXISTS "${_done_location}") - hunter_gate_download("${_archive_id_location}") - endif() + get_filename_component(_archive_id_location "${_hunter_self}/.." ABSOLUTE) + set(_done_location "${_archive_id_location}/DONE") + set(_sha1_location "${_archive_id_location}/SHA1") - if(NOT EXISTS "${_done_location}") - hunter_gate_internal_error("hunter_gate_download failed") - endif() + # Check Hunter already downloaded by HunterGate + if(NOT EXISTS "${_done_location}") + hunter_gate_download("${_archive_id_location}") + endif() - if(NOT EXISTS "${_sha1_location}") - hunter_gate_internal_error("${_sha1_location} not found") - endif() - file(READ "${_sha1_location}" _sha1_value) - string(COMPARE EQUAL "${_sha1_value}" "${HUNTER_GATE_SHA1}" _is_equal) - if(NOT _is_equal) - hunter_gate_internal_error( - "Short SHA1 collision:" - " ${_sha1_value} (from ${_sha1_location})" - " ${HUNTER_GATE_SHA1} (HunterGate)" - ) - endif() - if(NOT EXISTS "${_master_location}") - hunter_gate_user_error( - "Master file not found:" - " ${_master_location}" - "try to update Hunter/HunterGate" - ) - endif() + if(NOT EXISTS "${_done_location}") + hunter_gate_internal_error("hunter_gate_download failed") + endif() + + if(NOT EXISTS "${_sha1_location}") + hunter_gate_internal_error("${_sha1_location} not found") + endif() + file(READ "${_sha1_location}" _sha1_value) + string(COMPARE EQUAL "${_sha1_value}" "${HUNTER_GATE_SHA1}" _is_equal) + if(NOT _is_equal) + hunter_gate_internal_error( + "Short SHA1 collision:" + " ${_sha1_value} (from ${_sha1_location})" + " ${HUNTER_GATE_SHA1} (HunterGate)" + ) + endif() + if(NOT EXISTS "${_master_location}") + hunter_gate_user_error( + "Master file not found:" + " ${_master_location}" + "try to update Hunter/HunterGate" + ) endif() include("${_master_location}") set_property(GLOBAL PROPERTY HUNTER_GATE_DONE YES) diff --git a/ogles_gpgpu/CMakeLists.txt b/ogles_gpgpu/CMakeLists.txt index cfbb0d5..bbcbda8 100644 --- a/ogles_gpgpu/CMakeLists.txt +++ b/ogles_gpgpu/CMakeLists.txt @@ -11,6 +11,24 @@ endif() ## Dependencies - OpenGL stuff ## ################################################################# +# +# generate permanent preprocessor defs via gl_definitions.h +# + +if(OGLES_GPGPU_OPENGL_ES2) + set(OGLES_GPGPU_OPENGL_ES2_FLAG 1) + set(OGLES_GPGPU_OPENGL_ES3_FLAG 0) +elseif(OGLES_GPGPU_OPENGL_ES3) + set(OGLES_GPGPU_OPENGL_ES2_FLAG 0) + set(OGLES_GPGPU_OPENGL_ES3_FLAG 1) +else() + set(OGLES_GPGPU_OPENGL_ES2_FLAG 0) + set(OGLES_GPGPU_OPENGL_ES3_FLAG 0) +endif() +set(gl_config_dir "${CMAKE_CURRENT_BINARY_DIR}/platform/opengl") +set(gl_config_header "${gl_config_dir}/gl_definitions.h") +configure_file("platform/opengl/gl_definitions.h.in" "${gl_config_header}" @ONLY) + if(APPLE) find_package(imageio REQUIRED) find_package(corefoundation REQUIRED) @@ -83,19 +101,14 @@ else() set_property(TARGET ogles_gpgpu_cpu PROPERTY FOLDER "libs/ogles_gpgpu") target_include_directories( - ogles_gpgpu_cpu PUBLIC "$" - ) - - if(OGLES_GPGPU_OPENGL_ES3) - target_compile_definitions(ogles_gpgpu_cpu PUBLIC OGLES_GPGPU_OPENGL_ES3=1) - endif() + ogles_gpgpu_cpu + PUBLIC + "$" + "$" # gl_definitions.h + ) endif() - # Link epxported ogles_gpgpu with the stanrda OpenGL lib - find_package(OpenGL REQUIRED) - target_link_libraries(ogles_gpgpu PUBLIC OpenGL::GL) - if(MSVC) # ogles_gpgpu/platform/opengl/gl_includes.h: #include hunter_add_package(glew) @@ -103,17 +116,31 @@ else() target_link_libraries(ogles_gpgpu PUBLIC glew::glew) target_compile_definitions(ogles_gpgpu PUBLIC NOMINMAX) # avoid std::{min,max} conflicts target_compile_definitions(ogles_gpgpu PUBLIC _USE_MATH_DEFINES) # M_PI, etc + else() + + # *nix variants + if(OGLES_GPGPU_OPENGL_ES2) + find_package(gles2 REQUIRED) + target_link_libraries(ogles_gpgpu PUBLIC gles2::gles2) + elseif(OGLES_GPGPU_OPENGL_ES3) + find_package(gles3 REQUIRED) + target_link_libraries(ogles_gpgpu PUBLIC gles3::gles3) + else() + find_package(OpenGL REQUIRED) + target_link_libraries(ogles_gpgpu PUBLIC OpenGL::GL) + endif() + endif() + endif() set_property(TARGET ogles_gpgpu PROPERTY FOLDER "libs/ogles_gpgpu") target_include_directories( - ogles_gpgpu PUBLIC "$" - ) - -if(OGLES_GPGPU_OPENGL_ES3) - target_compile_definitions(ogles_gpgpu PUBLIC OGLES_GPGPU_OPENGL_ES3=1) -endif() + ogles_gpgpu + PUBLIC + "$" + "$" # gl_definitions.h +) ## ################################################################# ## Testing: @@ -169,6 +196,11 @@ install( DESTINATION "${include_install_dir}/${PROJECT_NAME}" ) +install( + FILES "${gl_config_header}" + DESTINATION "${include_install_dir}/${PROJECT_NAME}/platform/opengl/" +) + install( DIRECTORY "${CMAKE_SOURCE_DIR}/ogles_gpgpu/" # Trailing slash is required DESTINATION "${include_install_dir}/${PROJECT_NAME}" diff --git a/ogles_gpgpu/common/common_includes.h b/ogles_gpgpu/common/common_includes.h index 8665cc7..e3d4a07 100644 --- a/ogles_gpgpu/common/common_includes.h +++ b/ogles_gpgpu/common/common_includes.h @@ -32,23 +32,25 @@ #include "../platform/opengl/gl_includes.h" -#if defined(OGLES_GPGPU_IOS) && !defined(OGLES_GPGPU_OPENGL_ES3) -# include "../platform/ios/gl_includes.h" +#if defined(OGLES_GPGPU_IOS) # include "macros.h" #elif defined(OGLES_GPGPU_ANDROID) && !defined(OGLES_GPGPU_OPENGL_ES3) +// NOTE: The GraphicsBuffer acceleration tricks don't work in recent +// Android versions and are only relevant in OpenGL ES 2.0 # include "../platform/android/gl_includes.h" # include "../platform/android/macros.h" # include "../platform/android/egl.h" #else -# define OGLES_GPGPU_OPENGL 1 # include "../platform/opengl/gl_includes.h" # include "macros.h" #endif // clang-format on // clang-format off -#if defined(OGLES_GPGPU_ANDROID) || defined(OGLES_GPGPU_IOS) +#if defined(OGLES_GPGPU_OPENGL_ES2) || defined(OGLES_GPGPU_OPENGL_ES3) # define OGLES_GPGPU_OPENGLES 1 +#else +# define OGLES_GPGPU_OPENGL 1 #endif // clang-format on diff --git a/ogles_gpgpu/common/proc/video.h b/ogles_gpgpu/common/proc/video.h index bb4f26e..4b7f7f5 100644 --- a/ogles_gpgpu/common/proc/video.h +++ b/ogles_gpgpu/common/proc/video.h @@ -21,12 +21,6 @@ BEGIN_OGLES_GPGPU -#if __ANDROID__ -#define DFLT_PIX_FORMAT GL_RGBA -#else -#define DFLT_PIX_FORMAT GL_BGRA -#endif - struct FrameInput { FrameInput() {} FrameInput(const Size2d& size, void* pixelBuffer, bool useRawPixels, GLuint inputTexture, GLenum textureFormat) @@ -62,11 +56,11 @@ class VideoSource { void init(void* glContext); - void configure(const Size2d& size, GLenum inputPixFormat = DFLT_PIX_FORMAT); + void configure(const Size2d& size, GLenum inputPixFormat = OGLES_GPGPU_TEXTURE_FORMAT); void operator()(const FrameInput& frame); - void operator()(const Size2d& size, void* pixelBuffer, bool useRawPixels, GLuint inputTexture = 0, GLenum inputPixFormat = DFLT_PIX_FORMAT); + void operator()(const Size2d& size, void* pixelBuffer, bool useRawPixels, GLuint inputTexture = 0, GLenum inputPixFormat = OGLES_GPGPU_TEXTURE_FORMAT); virtual void preConfig() {} diff --git a/ogles_gpgpu/platform/opengl/gl_definitions.h.in b/ogles_gpgpu/platform/opengl/gl_definitions.h.in new file mode 100644 index 0000000..ed17daa --- /dev/null +++ b/ogles_gpgpu/platform/opengl/gl_definitions.h.in @@ -0,0 +1,19 @@ +/*! + * @file gl_definitions.h.in + * @brief OpenGL definitions + * + * OpenGL version definitions + */ + +#ifndef OGLES_GPGPU_GL_DEFINITIONS_H +#define OGLES_GPGPU_GL_DEFINITIONS_H + +#if @OGLES_GPGPU_OPENGL_ES2_FLAG@ +# define OGLES_GPGPU_OPENGL_ES2 +#elif @OGLES_GPGPU_OPENGL_ES3_FLAG@ +# define OGLES_GPGPU_OPENGL_ES3 +#endif + +#endif // OGLES_GPGPU_GL_DEFINITIONS_H + + diff --git a/ogles_gpgpu/platform/opengl/gl_includes.h b/ogles_gpgpu/platform/opengl/gl_includes.h index 69bb045..7c77177 100755 --- a/ogles_gpgpu/platform/opengl/gl_includes.h +++ b/ogles_gpgpu/platform/opengl/gl_includes.h @@ -16,6 +16,8 @@ // clang-format off +#include "../platform/opengl/gl_definitions.h" + //define something for Windows (64-bit) #if defined(_WIN32) || defined(_WIN64) # include // min/max @@ -64,19 +66,30 @@ # include # endif #elif defined(__linux__) || defined(__unix__) || defined(__posix__) +# define OGLES_GPGPU_NIX 1 # define GL_GLEXT_PROTOTYPES 1 -# include -# include +# if defined(OGLES_GPGPU_OPENGL_ES2) +# include +# include +# elif defined(OGLES_GPGPU_OPENGL_ES3) +# include +# include +# else +# include +# include +# endif #else # error platform not supported. #endif // clang-format on // clang-format off -#ifdef ANDROID +#if defined(ANDROID) || defined(OGLES_GPGPU_NIX) # define OGLES_GPGPU_TEXTURE_FORMAT GL_RGBA +# define OGLES_GPGPU_RGBA_FORMAT 1 #else # define OGLES_GPGPU_TEXTURE_FORMAT GL_BGRA +# define OGLES_GPGPU_RGBA_FORMAT 0 #endif #if defined(OGLES_GPGPU_OPENGL_ES3) diff --git a/ogles_gpgpu/ut/CMakeLists.txt b/ogles_gpgpu/ut/CMakeLists.txt index 558ea6d..3686402 100644 --- a/ogles_gpgpu/ut/CMakeLists.txt +++ b/ogles_gpgpu/ut/CMakeLists.txt @@ -1,6 +1,25 @@ set(test_name OGLES_GPGPU_Test) set(test_app test-ogles_gpgpu) +# Use GTest as unit test framework +hunter_add_package(GTest) +find_package(GTest CONFIG REQUIRED) +list(APPEND OGLES_GPGPU_TEST_LIBS GTest::gtest) + +# Use aglet for portable lightweight off screen opengl context +hunter_add_package(aglet) +find_package(aglet CONFIG REQUIRED) +list(APPEND OGLES_GPGPU_TEST_LIBS aglet::aglet) + +# Use gauze for cross platform ctesting +hunter_add_package(gauze) +find_package(gauze CONFIG REQUIRED) +list(APPEND OGLES_GPGPU_TEST_LIBS gauze::gauze) + +hunter_add_package(OpenCV) +find_package(OpenCV REQUIRED) +list(APPEND OGLES_GPGPU_TEST_LIBS "${OpenCV_LIBS}") + add_executable(${test_app} test-ogles_gpgpu.cpp) if(TARGET ogles_gpgpu_cpu) diff --git a/ogles_gpgpu/ut/test-ogles_gpgpu.cpp b/ogles_gpgpu/ut/test-ogles_gpgpu.cpp index abe6ee6..a5865eb 100644 --- a/ogles_gpgpu/ut/test-ogles_gpgpu.cpp +++ b/ogles_gpgpu/ut/test-ogles_gpgpu.cpp @@ -10,19 +10,6 @@ #include #include -// NOTE: GL_BGRA is absent in Android NDK -// clang-format off -#ifdef ANDROID -# define TEXTURE_FORMAT GL_RGBA -static cv::Vec4b torgba(const cv::Vec4b &p) { return cv::Vec4b(p[0], p[1], p[2], p[3]); } -static cv::Vec3b torgb(const cv::Vec3b &p) { return cv::Vec3b(p[0], p[1], p[2]); } -#else -# define TEXTURE_FORMAT GL_BGRA -static cv::Vec4b torgba(const cv::Vec4b &p) { return cv::Vec4b(p[2], p[1], p[0], p[3]); } -static cv::Vec3b torgb(const cv::Vec3b &p) { return cv::Vec3b(p[2], p[1], p[0]); } -#endif -// clang-format off - #define OGLES_GPGPU_DEBUG_YUV 0 #include "../common/gl/memtransfer_optimized.h" @@ -72,6 +59,17 @@ static cv::Vec3b torgb(const cv::Vec3b &p) { return cv::Vec3b(p[2], p[1], p[0]); //#include "../common/proc/two.h" //#include "../common/proc/three.h" +// NOTE: GL_BGRA is absent in Android NDK +// clang-format off +#if OGLES_GPGPU_RGBA_FORMAT +static cv::Vec4b torgba(const cv::Vec4b &p) { return cv::Vec4b(p[0], p[1], p[2], p[3]); } +static cv::Vec3b torgb(const cv::Vec3b &p) { return cv::Vec3b(p[0], p[1], p[2]); } +#else +static cv::Vec4b torgba(const cv::Vec4b &p) { return cv::Vec4b(p[2], p[1], p[0], p[3]); } +static cv::Vec3b torgb(const cv::Vec3b &p) { return cv::Vec3b(p[2], p[1], p[0]); } +#endif +// clang-format off + #include // https://stackoverflow.com/a/8024562 @@ -241,10 +239,12 @@ static cv::Mat getTestImage(int width, int height, int stripe, bool alpha, GLenu static int gWidth = 640; static int gHeight = 480; -#if defined(OGLES_GPGPU_OPENGL_ES3) +#if defined(OGLES_GPGPU_OPENGL_ES2) +static aglet::GLContext::GLVersion gVersion = aglet::GLContext::kGLES20; +#elif defined(OGLES_GPGPU_OPENGL_ES3) static aglet::GLContext::GLVersion gVersion = aglet::GLContext::kGLES30; #else -static aglet::GLContext::GLVersion gVersion = aglet::GLContext::kGLES20; +static aglet::GLContext::GLVersion gVersion = aglet::GLContext::kGL; #endif #if defined(OGLES_GPGPU_OPENGL_ES3) @@ -267,7 +267,7 @@ TEST(OGLESGPGPUTest, PingPong) { cv::Mat tmp(height, width, CV_8UC4, cv::Scalar::all(0)); for (int i = 0; i < 4; i++) { - video({ { test.cols, test.rows }, test.ptr(), true, 0, TEXTURE_FORMAT }); + video({ { test.cols, test.rows }, test.ptr(), true, 0, OGLES_GPGPU_TEXTURE_FORMAT }); gain.getResultData(nullptr, (i + 0) % 2); // queue up transfer for current frame: if (i > 0) { @@ -294,7 +294,7 @@ TEST(OGLESGPGPUTest, LetterboxProc) { (*context)(); ASSERT_TRUE(context && (*context)); if (context && *context) { - cv::Mat test = getTestImage(gWidth, gHeight, 10, true, TEXTURE_FORMAT); + cv::Mat test = getTestImage(gWidth, gHeight, 10, true, OGLES_GPGPU_TEXTURE_FORMAT); glActiveTexture(GL_TEXTURE0); ogles_gpgpu::VideoSource video; ogles_gpgpu::LetterboxProc letterbox; @@ -303,7 +303,7 @@ TEST(OGLESGPGPUTest, LetterboxProc) { letterbox.setColor(1.0f, 1.0f, 1.0f); video.set(&letterbox); - video({ { test.cols, test.rows }, test.ptr(), true, 0, TEXTURE_FORMAT }); + video({ { test.cols, test.rows }, test.ptr(), true, 0, OGLES_GPGPU_TEXTURE_FORMAT }); cv::Mat result; getImage(letterbox, result); @@ -328,13 +328,13 @@ TEST(OGLESGPGPUTest, Rgb2LuvProc) { (*context)(); ASSERT_TRUE(context && (*context)); if (context && *context) { - cv::Mat test = getTestImage(gWidth, gHeight, 10, true, TEXTURE_FORMAT); + cv::Mat test = getTestImage(gWidth, gHeight, 10, true, OGLES_GPGPU_TEXTURE_FORMAT); glActiveTexture(GL_TEXTURE0); ogles_gpgpu::VideoSource video; ogles_gpgpu::Rgb2LuvProc rgb2luv; video.set(&rgb2luv); - video({ { test.cols, test.rows }, test.ptr(), true, 0, TEXTURE_FORMAT }); + video({ { test.cols, test.rows }, test.ptr(), true, 0, OGLES_GPGPU_TEXTURE_FORMAT }); cv::Mat result; getImage(rgb2luv, result); @@ -358,7 +358,7 @@ TEST(OGLESGPGPUTest, SwizzleProc) { (*context)(); ASSERT_TRUE(context && (*context)); if (context && *context) { - cv::Mat test = getTestImage(gWidth, gHeight, 10, true, TEXTURE_FORMAT); + cv::Mat test = getTestImage(gWidth, gHeight, 10, true, OGLES_GPGPU_TEXTURE_FORMAT); glActiveTexture(GL_TEXTURE0); ogles_gpgpu::VideoSource video; ogles_gpgpu::SwizzleProc noop(ogles_gpgpu::SwizzleProc::kSwizzleRGBA); @@ -366,7 +366,7 @@ TEST(OGLESGPGPUTest, SwizzleProc) { video.set(&noop); noop.add(&swizzle); - video({ { test.cols, test.rows }, test.ptr(), true, 0, TEXTURE_FORMAT }); + video({ { test.cols, test.rows }, test.ptr(), true, 0, OGLES_GPGPU_TEXTURE_FORMAT }); cv::Mat result1, result2; @@ -387,7 +387,7 @@ TEST(OGLESGPGPUTest, GrayScaleProc) { (*context)(); ASSERT_TRUE(context && (*context)); if (context && *context) { - cv::Mat test = getTestImage(gWidth, gHeight, 10, true, TEXTURE_FORMAT); + cv::Mat test = getTestImage(gWidth, gHeight, 10, true, OGLES_GPGPU_TEXTURE_FORMAT); glActiveTexture(GL_TEXTURE0); ogles_gpgpu::VideoSource video; ogles_gpgpu::GrayscaleProc gray; @@ -395,14 +395,14 @@ TEST(OGLESGPGPUTest, GrayScaleProc) { gray.setGrayscaleConvType(ogles_gpgpu::GRAYSCALE_INPUT_CONVERSION_RGB); video.set(&gray); - video({ { test.cols, test.rows }, test.ptr(), true, 0, TEXTURE_FORMAT }); + video({ { test.cols, test.rows }, test.ptr(), true, 0, OGLES_GPGPU_TEXTURE_FORMAT }); cv::Mat result; getImage(gray, result); ASSERT_FALSE(result.empty()); cv::Mat truth; - cv::cvtColor(test, truth, (TEXTURE_FORMAT == GL_RGBA) ? cv::COLOR_RGBA2GRAY : cv::COLOR_BGRA2GRAY); + cv::cvtColor(test, truth, (OGLES_GPGPU_TEXTURE_FORMAT == GL_RGBA) ? cv::COLOR_RGBA2GRAY : cv::COLOR_BGRA2GRAY); cv::cvtColor(truth, truth, cv::COLOR_GRAY2BGRA); ASSERT_TRUE(almost_equal(cv::Mat4b(result), cv::Mat4b(truth), static_cast(2))); } @@ -413,7 +413,7 @@ TEST(OGLESGPGPUTest, WriteAndRead) { (*context)(); ASSERT_TRUE(context && (*context)); if (context && *context) { - cv::Mat test = getTestImage(gWidth, gHeight, 10, true, TEXTURE_FORMAT); + cv::Mat test = getTestImage(gWidth, gHeight, 10, true, OGLES_GPGPU_TEXTURE_FORMAT); glActiveTexture(GL_TEXTURE0); ogles_gpgpu::GainProc gain; @@ -422,7 +422,7 @@ TEST(OGLESGPGPUTest, WriteAndRead) { static const bool prepareForExternalInput = true; // Set pixel data format for input data to . Must be set before init() / reinit(). - filter->setExternalInputDataFormat(TEXTURE_FORMAT); + filter->setExternalInputDataFormat(OGLES_GPGPU_TEXTURE_FORMAT); // Init the processor for input frames of size x which is at position // in the processing pipeline. @@ -504,7 +504,7 @@ TEST(OGLESGPGPUTest, Yuv2RgbProc) { // Be sure to specify standard (GL_RGBA) output texture type // for this case where input textures == 0 are handled as special // separate Y and UV textures. - yuv2rgb.getMemTransferObj()->setOutputPixelFormat(TEXTURE_FORMAT); + yuv2rgb.getMemTransferObj()->setOutputPixelFormat(OGLES_GPGPU_TEXTURE_FORMAT); // Create an FBO yuv2rgb.createFBOTex(false); @@ -584,7 +584,7 @@ TEST(OGLESGPGPUTest, Yuv2RgbProc) { // Be sure to specify standard (GL_RGBA) output texture type // for this case where input textures == 0 are handled as special // separate Y and UV textures. - yuv2rgb.getMemTransferObj()->setOutputPixelFormat(TEXTURE_FORMAT); + yuv2rgb.getMemTransferObj()->setOutputPixelFormat(OGLES_GPGPU_TEXTURE_FORMAT); // Create an FBO yuv2rgb.createFBOTex(false); @@ -614,13 +614,13 @@ TEST(OGLESGPGPUTest, AdaptThreshProc) { ASSERT_TRUE(context && (*context)); ASSERT_EQ(glGetError(), GL_NO_ERROR); if (context && *context) { - cv::Mat test = getTestImage(gWidth, gHeight, 10, true, TEXTURE_FORMAT); + cv::Mat test = getTestImage(gWidth, gHeight, 10, true, OGLES_GPGPU_TEXTURE_FORMAT); glActiveTexture(GL_TEXTURE0); ogles_gpgpu::VideoSource video; ogles_gpgpu::AdaptThreshProc thresh; video.set(&thresh); - video({ { test.cols, test.rows }, test.ptr(), true, 0, TEXTURE_FORMAT }); + video({ { test.cols, test.rows }, test.ptr(), true, 0, OGLES_GPGPU_TEXTURE_FORMAT }); cv::Mat result; getImage(thresh, result); @@ -642,7 +642,7 @@ TEST(OGLESGPGPUTest, GainProc) { ogles_gpgpu::GainProc gain(g); video.set(&gain); - video({ { test.cols, test.rows }, test.ptr(), true, 0, TEXTURE_FORMAT }); + video({ { test.cols, test.rows }, test.ptr(), true, 0, OGLES_GPGPU_TEXTURE_FORMAT }); cv::Mat result; getImage(gain, result); @@ -671,7 +671,7 @@ TEST(OGLESGPGPUTest, BlendProc) { gain10.add(&blend, 1); video.set(&gain1); - video({ test.cols, test.rows }, test.ptr(), true, 0, TEXTURE_FORMAT); + video({ test.cols, test.rows }, test.ptr(), true, 0, OGLES_GPGPU_TEXTURE_FORMAT); cv::Mat result; getImage(blend, result); @@ -692,7 +692,7 @@ TEST(OGLESGPGPUTest, FIFOProc) { for (int i = 0; i < 3; i++) { cv::Mat test(gWidth, gHeight, CV_8UC4, cv::Scalar(i, i, i, 255)); - video({ test.cols, test.rows }, test.ptr(), true, 0, TEXTURE_FORMAT); + video({ test.cols, test.rows }, test.ptr(), true, 0, OGLES_GPGPU_TEXTURE_FORMAT); } for (int i = 0; i < 3; i++) { @@ -728,8 +728,8 @@ TEST(OGLESGPGPUTest, TransformProc) { transform.setTransformMatrix(matrix); - cv::Mat test = getTestImage(gWidth, gHeight, 10, true, TEXTURE_FORMAT); - video({ test.cols, test.rows }, test.ptr(), true, 0, TEXTURE_FORMAT); + cv::Mat test = getTestImage(gWidth, gHeight, 10, true, OGLES_GPGPU_TEXTURE_FORMAT); + video({ test.cols, test.rows }, test.ptr(), true, 0, OGLES_GPGPU_TEXTURE_FORMAT); cv::Mat result; getImage(transform, result); @@ -744,7 +744,7 @@ TEST(OGLESGPGPUTest, MeshProc) { ASSERT_EQ(glGetError(), GL_NO_ERROR); if (context && *context) { - cv::Mat test = getTestImage(gWidth, gHeight, 10, true, TEXTURE_FORMAT); + cv::Mat test = getTestImage(gWidth, gHeight, 10, true, OGLES_GPGPU_TEXTURE_FORMAT); const float w = gWidth; const float h = gHeight; @@ -756,7 +756,7 @@ TEST(OGLESGPGPUTest, MeshProc) { {{0.f, h, 0.f}}, {{w/2.f,h/2.f,0.f}} // demonstrate stretching center point }; - + std::vector> coordsT, coords { {{0.f, 0.f}}, @@ -806,7 +806,7 @@ TEST(OGLESGPGPUTest, MeshProc) { mesh.setModelViewProjection(matrix); - video({ test.cols, test.rows }, test.ptr(), true, 0, TEXTURE_FORMAT); + video({ test.cols, test.rows }, test.ptr(), true, 0, OGLES_GPGPU_TEXTURE_FORMAT); cv::Mat result; getImage(mesh, result); @@ -837,7 +837,7 @@ TEST(OGLESGPGPUTest, DiffProc) { gain10.add(&diff, 0); video.set(&gain1); - video({ test.cols, test.rows }, test.ptr(), true, 0, TEXTURE_FORMAT); + video({ test.cols, test.rows }, test.ptr(), true, 0, OGLES_GPGPU_TEXTURE_FORMAT); cv::Mat result; getImage(diff, result); @@ -851,7 +851,7 @@ TEST(OGLESGPGPUTest, GaussianProc) { ASSERT_TRUE(context && (*context)); ASSERT_EQ(glGetError(), GL_NO_ERROR); if (context && *context) { - cv::Mat test = getTestImage(gWidth, gHeight, 1, true, TEXTURE_FORMAT); + cv::Mat test = getTestImage(gWidth, gHeight, 1, true, OGLES_GPGPU_TEXTURE_FORMAT); glActiveTexture(GL_TEXTURE0); ogles_gpgpu::VideoSource video; @@ -859,7 +859,7 @@ TEST(OGLESGPGPUTest, GaussianProc) { video.set(&gauss1); gauss1.add(&gauss2); - video({ test.cols, test.rows }, test.ptr(), true, 0, TEXTURE_FORMAT); + video({ test.cols, test.rows }, test.ptr(), true, 0, OGLES_GPGPU_TEXTURE_FORMAT); cv::Mat result; getImage(gauss2, result); @@ -873,14 +873,14 @@ TEST(OGLESGPGPUTest, GaussianOptProc) { ASSERT_TRUE(context && (*context)); ASSERT_EQ(glGetError(), GL_NO_ERROR); if (context && *context) { - cv::Mat test = getTestImage(gWidth, gHeight, 1, true, TEXTURE_FORMAT); + cv::Mat test = getTestImage(gWidth, gHeight, 1, true, OGLES_GPGPU_TEXTURE_FORMAT); glActiveTexture(GL_TEXTURE0); ogles_gpgpu::VideoSource video; ogles_gpgpu::GaussOptProc gauss; video.set(&gauss); - video({ test.cols, test.rows }, test.ptr(), true, 0, TEXTURE_FORMAT); + video({ test.cols, test.rows }, test.ptr(), true, 0, OGLES_GPGPU_TEXTURE_FORMAT); cv::Mat result; getImage(gauss, result); @@ -894,14 +894,14 @@ TEST(OGLESGPGPUTest, BoxOptProc) { ASSERT_TRUE(context && (*context)); ASSERT_EQ(glGetError(), GL_NO_ERROR); if (context && *context) { - cv::Mat test = getTestImage(gWidth, gHeight, 1, true, TEXTURE_FORMAT); + cv::Mat test = getTestImage(gWidth, gHeight, 1, true, OGLES_GPGPU_TEXTURE_FORMAT); glActiveTexture(GL_TEXTURE0); ogles_gpgpu::VideoSource video; ogles_gpgpu::BoxOptProc box; video.set(&box); - video({ test.cols, test.rows }, test.ptr(), true, 0, TEXTURE_FORMAT); + video({ test.cols, test.rows }, test.ptr(), true, 0, OGLES_GPGPU_TEXTURE_FORMAT); cv::Mat result; getImage(box, result); @@ -932,7 +932,7 @@ TEST(OGLESGPGPUTest, HessianProc) { ogles_gpgpu::HessianProc hessian(100.f); video.set(&hessian); - video({ test.cols, test.rows }, test.ptr(), true, 0, TEXTURE_FORMAT); + video({ test.cols, test.rows }, test.ptr(), true, 0, OGLES_GPGPU_TEXTURE_FORMAT); cv::Mat result, alpha; getImage(hessian, result); @@ -947,14 +947,14 @@ TEST(OGLESGPGPUTest, LbpProc) { ASSERT_TRUE(context && (*context)); ASSERT_EQ(glGetError(), GL_NO_ERROR); if (context && *context) { - cv::Mat test = getTestImage(gWidth, gHeight, 1, true, TEXTURE_FORMAT); + cv::Mat test = getTestImage(gWidth, gHeight, 1, true, OGLES_GPGPU_TEXTURE_FORMAT); glActiveTexture(GL_TEXTURE0); ogles_gpgpu::VideoSource video; ogles_gpgpu::LbpProc lbp; video.set(&lbp); - video({ test.cols, test.rows }, test.ptr(), true, 0, TEXTURE_FORMAT); + video({ test.cols, test.rows }, test.ptr(), true, 0, OGLES_GPGPU_TEXTURE_FORMAT); cv::Mat result; getImage(lbp, result); @@ -999,7 +999,7 @@ TEST(OGLESGPGPUTest, Fir3Proc) { fifo.addWithDelay(&fir3, 2, 2); for (int i = 0; i < 3; i++) { - video({ test[i].cols, test[i].rows }, test[i].ptr(), true, 0, TEXTURE_FORMAT); + video({ test[i].cols, test[i].rows }, test[i].ptr(), true, 0, OGLES_GPGPU_TEXTURE_FORMAT); } cv::Mat result; @@ -1014,14 +1014,14 @@ TEST(OGLESGPGPUTest, GradProc) { ASSERT_TRUE(context && (*context)); ASSERT_EQ(glGetError(), GL_NO_ERROR); if (context && *context) { - cv::Mat test = getTestImage(gWidth, gHeight, 2, true, TEXTURE_FORMAT); + cv::Mat test = getTestImage(gWidth, gHeight, 2, true, OGLES_GPGPU_TEXTURE_FORMAT); glActiveTexture(GL_TEXTURE0); ogles_gpgpu::VideoSource video; ogles_gpgpu::GradProc grad; video.set(&grad); - video({ test.cols, test.rows }, test.ptr(), true, 0, TEXTURE_FORMAT); + video({ test.cols, test.rows }, test.ptr(), true, 0, OGLES_GPGPU_TEXTURE_FORMAT); cv::Mat result; getImage(grad, result); @@ -1047,7 +1047,7 @@ TEST(OGLESGPGPUTest, LowPassProc) { for (int i = 0; i < 5; i++) { cv::Mat& test = images[i % 2]; - video({ test.cols, test.rows }, test.ptr(), true, 0, TEXTURE_FORMAT); + video({ test.cols, test.rows }, test.ptr(), true, 0, OGLES_GPGPU_TEXTURE_FORMAT); } cv::Mat result; @@ -1074,7 +1074,7 @@ TEST(OGLESGPGPUTest, HighPassProc) { for (int i = 0; i < 5; i++) { cv::Mat& test = images[i % 2]; - video({ test.cols, test.rows }, test.ptr(), true, 0, TEXTURE_FORMAT); + video({ test.cols, test.rows }, test.ptr(), true, 0, OGLES_GPGPU_TEXTURE_FORMAT); } cv::Mat result; @@ -1089,14 +1089,14 @@ TEST(OGLESGPGPUTest, ThreshProc) { ASSERT_TRUE(context && (*context)); ASSERT_EQ(glGetError(), GL_NO_ERROR); if (context && *context) { - cv::Mat test = getTestImage(gWidth, gHeight, 2, true, TEXTURE_FORMAT); + cv::Mat test = getTestImage(gWidth, gHeight, 2, true, OGLES_GPGPU_TEXTURE_FORMAT); glActiveTexture(GL_TEXTURE0); ogles_gpgpu::VideoSource video; ogles_gpgpu::ThreshProc thresh; video.set(&thresh); - video({ test.cols, test.rows }, test.ptr(), true, 0, TEXTURE_FORMAT); + video({ test.cols, test.rows }, test.ptr(), true, 0, OGLES_GPGPU_TEXTURE_FORMAT); cv::Mat result; getImage(thresh, result); @@ -1110,14 +1110,14 @@ TEST(OGLESGPGPUTest, PyramidProc) { ASSERT_TRUE(context && (*context)); ASSERT_EQ(glGetError(), GL_NO_ERROR); if (context && *context) { - cv::Mat test = getTestImage(gWidth, gHeight, 2, true, TEXTURE_FORMAT); + cv::Mat test = getTestImage(gWidth, gHeight, 2, true, OGLES_GPGPU_TEXTURE_FORMAT); glActiveTexture(GL_TEXTURE0); ogles_gpgpu::VideoSource video; ogles_gpgpu::PyramidProc pyramid(10); video.set(&pyramid); - video({ test.cols, test.rows }, test.ptr(), true, 0, TEXTURE_FORMAT); + video({ test.cols, test.rows }, test.ptr(), true, 0, OGLES_GPGPU_TEXTURE_FORMAT); cv::Mat result; getImage(pyramid, result); @@ -1144,8 +1144,8 @@ TEST(OGLESGPGPUTest, IxytProc) { fifo.addWithDelay(&ixyt, 0, 0); for (int i = 0; i < 5; i++) { - cv::Mat test = getTestImage(gWidth, gHeight, 2, true, TEXTURE_FORMAT); - video({ test.cols, test.rows }, test.ptr(), true, 0, TEXTURE_FORMAT); + cv::Mat test = getTestImage(gWidth, gHeight, 2, true, OGLES_GPGPU_TEXTURE_FORMAT); + video({ test.cols, test.rows }, test.ptr(), true, 0, OGLES_GPGPU_TEXTURE_FORMAT); } cv::Mat result; @@ -1164,14 +1164,14 @@ TEST(OGLESGPGPUTest, TensorProc) { ASSERT_TRUE(context && (*context)); ASSERT_EQ(glGetError(), GL_NO_ERROR); if (context && *context) { - cv::Mat test = getTestImage(gWidth, gHeight, 2, true, TEXTURE_FORMAT); + cv::Mat test = getTestImage(gWidth, gHeight, 2, true, OGLES_GPGPU_TEXTURE_FORMAT); glActiveTexture(GL_TEXTURE0); ogles_gpgpu::VideoSource video; ogles_gpgpu::TensorProc tensor; video.set(&tensor); - video({ test.cols, test.rows }, test.ptr(), true, 0, TEXTURE_FORMAT); + video({ test.cols, test.rows }, test.ptr(), true, 0, OGLES_GPGPU_TEXTURE_FORMAT); cv::Mat result; getImage(tensor, result); @@ -1185,7 +1185,7 @@ TEST(OGLESGPGPUTest, ShiTomasiProc) { ASSERT_TRUE(context && (*context)); ASSERT_EQ(glGetError(), GL_NO_ERROR); if (context && *context) { - cv::Mat test = getTestImage(gWidth, gHeight, 2, true, TEXTURE_FORMAT); + cv::Mat test = getTestImage(gWidth, gHeight, 2, true, OGLES_GPGPU_TEXTURE_FORMAT); for (int i = 0; i < 100; i++) { cv::Point p0(rand() % test.cols, rand() % test.rows); cv::Point p1(rand() % test.cols, rand() % test.rows); @@ -1205,7 +1205,7 @@ TEST(OGLESGPGPUTest, ShiTomasiProc) { gauss.add(&tensor); tensor.add(&shiTomasi); - video({ test.cols, test.rows }, test.ptr(), true, 0, TEXTURE_FORMAT); + video({ test.cols, test.rows }, test.ptr(), true, 0, OGLES_GPGPU_TEXTURE_FORMAT); cv::Mat result; getImage(shiTomasi, result); @@ -1219,7 +1219,7 @@ TEST(OGLESGPGPUTest, HarrisProc) { ASSERT_TRUE(context && (*context)); ASSERT_EQ(glGetError(), GL_NO_ERROR); if (context && *context) { - cv::Mat test = getTestImage(gWidth, gHeight, 2, true, TEXTURE_FORMAT); + cv::Mat test = getTestImage(gWidth, gHeight, 2, true, OGLES_GPGPU_TEXTURE_FORMAT); for (int i = 0; i < 100; i++) { cv::Point p0(rand() % test.cols, rand() % test.rows); cv::Point p1(rand() % test.cols, rand() % test.rows); @@ -1239,7 +1239,7 @@ TEST(OGLESGPGPUTest, HarrisProc) { gauss.add(&tensor); tensor.add(&harris); - video({ test.cols, test.rows }, test.ptr(), true, 0, TEXTURE_FORMAT); + video({ test.cols, test.rows }, test.ptr(), true, 0, OGLES_GPGPU_TEXTURE_FORMAT); cv::Mat result; getImage(harris, result); @@ -1272,7 +1272,7 @@ TEST(OGLESGPGPUTest, NmsProc) { video.set(&hessian); hessian.add(&nms); - video({ test.cols, test.rows }, test.ptr(), true, 0, TEXTURE_FORMAT); + video({ test.cols, test.rows }, test.ptr(), true, 0, OGLES_GPGPU_TEXTURE_FORMAT); cv::Mat result, alpha; getImage(nms, result); @@ -1287,7 +1287,7 @@ TEST(OGLESGPGPUTest, FlowProc) { ASSERT_TRUE(context && (*context)); ASSERT_EQ(glGetError(), GL_NO_ERROR); if (context && *context) { - cv::Mat test = getTestImage(gWidth, gHeight, 3, true, TEXTURE_FORMAT); + cv::Mat test = getTestImage(gWidth, gHeight, 3, true, OGLES_GPGPU_TEXTURE_FORMAT); glActiveTexture(GL_TEXTURE0); ogles_gpgpu::VideoSource video; @@ -1301,7 +1301,7 @@ TEST(OGLESGPGPUTest, FlowProc) { cv::Mat shifted; cv::Matx23f M(1, 0, i * 4, 0, 1, i * 4); cv::warpAffine(test, shifted, M, test.size()); - video({ shifted.cols, shifted.rows }, shifted.ptr(), true, 0, TEXTURE_FORMAT); + video({ shifted.cols, shifted.rows }, shifted.ptr(), true, 0, OGLES_GPGPU_TEXTURE_FORMAT); } cv::Mat result; @@ -1316,14 +1316,14 @@ TEST(OGLESGPGPUTest, Rgb2HsvProc) { ASSERT_TRUE(context && (*context)); ASSERT_EQ(glGetError(), GL_NO_ERROR); if (context && *context) { - cv::Mat test = getTestImage(gWidth, gHeight, 3, true, TEXTURE_FORMAT); + cv::Mat test = getTestImage(gWidth, gHeight, 3, true, OGLES_GPGPU_TEXTURE_FORMAT); glActiveTexture(GL_TEXTURE0); ogles_gpgpu::VideoSource video; ogles_gpgpu::Rgb2HsvProc rgb2hsv; video.set(&rgb2hsv); - video({ test.cols, test.rows }, test.ptr(), true, 0, TEXTURE_FORMAT); + video({ test.cols, test.rows }, test.ptr(), true, 0, OGLES_GPGPU_TEXTURE_FORMAT); cv::Mat result; getImage(rgb2hsv, result); @@ -1337,14 +1337,14 @@ TEST(OGLESGPGPUTest, Hsv2RgbProc) { ASSERT_TRUE(context && (*context)); ASSERT_EQ(glGetError(), GL_NO_ERROR); if (context && *context) { - cv::Mat test = getTestImage(gWidth, gHeight, 3, true, TEXTURE_FORMAT); + cv::Mat test = getTestImage(gWidth, gHeight, 3, true, OGLES_GPGPU_TEXTURE_FORMAT); glActiveTexture(GL_TEXTURE0); ogles_gpgpu::VideoSource video; ogles_gpgpu::Hsv2RgbProc hsv2rgb; video.set(&hsv2rgb); - video({ test.cols, test.rows }, test.ptr(), true, 0, TEXTURE_FORMAT); + video({ test.cols, test.rows }, test.ptr(), true, 0, OGLES_GPGPU_TEXTURE_FORMAT); cv::Mat result; getImage(hsv2rgb, result); @@ -1358,7 +1358,7 @@ TEST(OGLESGPGPUTest, LNormProc) { ASSERT_TRUE(context && (*context)); ASSERT_EQ(glGetError(), GL_NO_ERROR); if (context && *context) { - cv::Mat test = getTestImage(gWidth, gHeight, 3, true, TEXTURE_FORMAT); + cv::Mat test = getTestImage(gWidth, gHeight, 3, true, OGLES_GPGPU_TEXTURE_FORMAT); glActiveTexture(GL_TEXTURE0); ogles_gpgpu::VideoSource video; @@ -1367,7 +1367,7 @@ TEST(OGLESGPGPUTest, LNormProc) { video.set(&gainProc); gainProc.add(&normProc); - video({ test.cols, test.rows }, test.ptr(), true, 0, TEXTURE_FORMAT); + video({ test.cols, test.rows }, test.ptr(), true, 0, OGLES_GPGPU_TEXTURE_FORMAT); cv::Mat result; getImage(normProc, result); @@ -1384,7 +1384,7 @@ TEST(OGLESGPGPUTest, MedianProc) { (*context)(); ASSERT_TRUE(context && (*context)); if (context && *context) { - cv::Mat test = getTestImage(gWidth, gHeight, 20, true, TEXTURE_FORMAT); + cv::Mat test = getTestImage(gWidth, gHeight, 20, true, OGLES_GPGPU_TEXTURE_FORMAT); glActiveTexture(GL_TEXTURE0); ogles_gpgpu::VideoSource video; @@ -1397,7 +1397,7 @@ TEST(OGLESGPGPUTest, MedianProc) { test.setTo(0, noise < 30); test.setTo(255, noise > 225); - video({ test.cols, test.rows }, test.ptr(), true, 0, TEXTURE_FORMAT); + video({ test.cols, test.rows }, test.ptr(), true, 0, OGLES_GPGPU_TEXTURE_FORMAT); cv::Mat result; getImage(median, result);