From 16ddfbb1aed77603d7e816467cbcb51299371384 Mon Sep 17 00:00:00 2001 From: Sreelakshmi Haridas Maruthur Date: Mon, 9 Nov 2020 04:04:57 -0700 Subject: [PATCH] gles: Fix compile errors. (#976) * fix gles build error * fix format check fail * fix Werror and link error * gles: Makefile changes Change-Id: Ie493a730e6004f9251bbf9b534f758e0dc920191 Co-authored-by: Guang <891528583@qq.com> --- CMakeLists.txt | 4 +++ test_common/gles/gl_headers.h | 21 ++++++++++----- test_common/gles/helpers.cpp | 1 + test_conformance/gles/CMakeLists.txt | 7 +---- test_conformance/gles/main.cpp | 20 ++++++++++----- test_conformance/gles/setup_egl.cpp | 31 ++++++++++++++--------- test_conformance/gles/test_fence_sync.cpp | 2 +- 7 files changed, 54 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 64f513e8..844283aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -197,6 +197,10 @@ if(LINK_PTHREAD) list(APPEND CLConform_LIBRARIES pthread) endif() +if(DEFINED USE_GLES3) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGLES3") +endif() + if(APPLE) find_library(corefoundation CoreFoundation) find_library(iokit IOKit) diff --git a/test_common/gles/gl_headers.h b/test_common/gles/gl_headers.h index 849da719..e0d46322 100644 --- a/test_common/gles/gl_headers.h +++ b/test_common/gles/gl_headers.h @@ -24,10 +24,12 @@ #include #else #include +#define glTexImage3DOES glTexImage3D +#define glUnmapBufferOES glUnmapBuffer +#define glMapBufferRangeEXT glMapBufferRange #endif #include -#include // Some macros to minimize the changes in the tests from GL to GLES2 #define glGenRenderbuffersEXT glGenRenderbuffers @@ -40,21 +42,26 @@ #define glDeleteFramebuffersEXT glDeleteFramebuffers #define glBindFramebufferEXT glBindFramebuffer #define glFramebufferRenderbufferEXT glFramebufferRenderbuffer -#define glTexImage3D glTexImage3DOES + +#ifndef GL_ES_VERSION_3_0 +#define GL_RGBA32F GL_RGBA32F_EXT +#define GL_READ_ONLY GL_BUFFER_ACCESS_OES +#define GL_HALF_FLOAT_ARB GL_HALF_FLOAT_OES +#define GL_BGRA GL_BGRA_EXT +#else +#define GL_HALF_FLOAT_ARB GL_HALF_FLOAT +#endif + #define glutGetProcAddress eglGetProcAddress #define GL_FRAMEBUFFER_EXT GL_FRAMEBUFFER #define GL_FRAMEBUFFER_COMPLETE_EXT GL_FRAMEBUFFER_COMPLETE #define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT GL_RENDERBUFFER_INTERNAL_FORMAT #define GL_RENDERBUFFER_EXT GL_RENDERBUFFER -#define GL_COLOR_ATTACHMENT0_EXT GL_COLOR_ATTACHMENT0 #define GL_DEPTH_ATTACHMENT_EXT GL_DEPTH_ATTACHMENT -#define GL_TEXTURE_3D GL_TEXTURE_3D_OES -#define GL_READ_ONLY GL_BUFFER_ACCESS_OES -#define GL_HALF_FLOAT_ARB GL_HALF_FLOAT_OES -#define GL_BGRA GL_BGRA_EXT #define GL_RGBA32F_ARB GL_RGBA +#define GL_BGRA GL_BGRA_EXT typedef unsigned short GLhalf; diff --git a/test_common/gles/helpers.cpp b/test_common/gles/helpers.cpp index 579c841b..34f40b4c 100644 --- a/test_common/gles/helpers.cpp +++ b/test_common/gles/helpers.cpp @@ -16,6 +16,7 @@ #include "helpers.h" #include "gl_headers.h" +#include "CL/cl_half.h" #define CHECK_ERROR()\ {GLint __error = glGetError(); if(__error) {log_error( "GL ERROR: %s!\n", gluErrorString( err ));}} diff --git a/test_conformance/gles/CMakeLists.txt b/test_conformance/gles/CMakeLists.txt index f3674903..c76fe512 100644 --- a/test_conformance/gles/CMakeLists.txt +++ b/test_conformance/gles/CMakeLists.txt @@ -15,11 +15,6 @@ set (${MODULE_NAME}_SOURCES ../../test_common/gles/helpers.cpp ) -if(ANDROID) - list(APPEND CLConform_LIBRARIES GLESv2) -elseif(WIN32) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGLES3") - list(APPEND CLConform_LIBRARIES libEGL libGLESv2 ) -endif(ANDROID) +list(APPEND CLConform_LIBRARIES EGL GLESv2) include(../CMakeCommon.txt) diff --git a/test_conformance/gles/main.cpp b/test_conformance/gles/main.cpp index d0c12c91..644fa63c 100644 --- a/test_conformance/gles/main.cpp +++ b/test_conformance/gles/main.cpp @@ -62,8 +62,8 @@ TEST_FN_REDIRECTOR( renderbuffer_read ) TEST_FN_REDIRECTOR( renderbuffer_write ) TEST_FN_REDIRECTOR( renderbuffer_getinfo ) -#ifndef GL_ES_VERSION_2_0 -TEST_FN_REDIRECTOR( test_fence_sync ) +#ifdef GL_ES_VERSION_3_0 +TEST_FN_REDIRECTOR(fence_sync) #endif test_definition test_list[] = { @@ -82,14 +82,17 @@ test_definition test_list[] = { TEST_FN_REDIRECT( renderbuffer_getinfo ) }; -#ifndef GL_ES_VERSION_2_0 +#ifdef GL_ES_VERSION_3_0 test_definition test_list32[] = { TEST_FN_REDIRECT( fence_sync ) }; #endif const int test_num = ARRAY_SIZE( test_list ); + +#ifdef GL_ES_VERSION_3_0 const int test_num32 = ARRAY_SIZE( test_list32 ); +#endif int main(int argc, const char *argv[]) @@ -113,12 +116,15 @@ int main(int argc, const char *argv[]) for( int i = 0; i < test_num; i++ ) log_info( "\t%s\n", test_list[i].name ); +#ifdef GL_ES_VERSION_3_0 log_info( "Available 3.2 tests:\n" ); for( int i = 0; i < test_num32; i++ ) log_info( "\t%s\n", test_list32[i].name ); +#endif - log_info( "Note: Any 3.2 test names must follow 2.1 test names on the command line." ); - log_info( "Use environment variables to specify desired device." ); + log_info("Note: Any 3.2 test names must follow 2.1 test names on the " + "command line."); + log_info("Use environment variables to specify desired device."); return 0; } @@ -141,12 +147,14 @@ int main(int argc, const char *argv[]) // Check to see if any 2.x or 3.2 test names were specified on the command line. unsigned first_32_testname = 0; +#ifdef GL_ES_VERSION_3_0 for (int j=1; (j