From 55959b0bb19f18a4dbb41656fbc95ba0b5993ce3 Mon Sep 17 00:00:00 2001 From: Jamie Madill Date: Tue, 5 Mar 2019 10:07:41 -0500 Subject: [PATCH] Add glmark2 to build. glmark2 is a an OpenGL ES 2.0 benchmark licensed under GPL v3. See https://github.com/glmark2/glmark2 ANGLE can use glmark2 as a metric and guide for optimization. It will add a number of useful performance tests. This CL adds the initial build integration. A follow-up CL will integrate glmark2 into our performance tests. Note that glmark2 will not be shipped with Chrome or Android. It will only be used on our test infrastructure. Note that the data path solution is temporary. When integrated into ANGLE we will make sure we CWD into the glmark2 directory before running the benchmark. Bug: angleproject:3139 Change-Id: I5c4f605221c255ab19abd10b321b5867ab459105 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1449984 Commit-Queue: Jamie Madill Reviewed-by: Shahbaz Youssefi --- .gitignore | 4 +- BUILD.gn | 2 +- DEPS | 23 +- build_overrides/angle.gni | 1 + src/tests/BUILD.gn | 7 + third_party/BUILD.gn | 51 ++++ third_party/glmark2/BUILD.gn | 394 +++++++++++++++++++++++++++++++ third_party/glmark2/README.angle | 12 + third_party/libjpeg.gni | 15 ++ 9 files changed, 506 insertions(+), 3 deletions(-) create mode 100644 third_party/BUILD.gn create mode 100644 third_party/glmark2/BUILD.gn create mode 100644 third_party/glmark2/README.angle create mode 100644 third_party/libjpeg.gni diff --git a/.gitignore b/.gitignore index 10a3337266093..7b24c91d435b0 100644 --- a/.gitignore +++ b/.gitignore @@ -30,9 +30,11 @@ /third_party/deqp/src /third_party/fuchsia-sdk /third_party/gles1_conform +/third_party/glmark2/src /third_party/glslang/src /third_party/googletest /third_party/jsoncpp +/third_party/libjpeg_turbo /third_party/libpng/src /third_party/llvm-build /third_party/qemu-linux-x64 @@ -44,6 +46,7 @@ /third_party/vulkan-loader/src /third_party/vulkan-tools/src /third_party/vulkan-validation-layers/src +/third_party/yasm /third_party/zlib angle_internal build @@ -56,7 +59,6 @@ Debug_x64/ diag.txt ipch lib/* -Makefile out patches-* Release/ diff --git a/BUILD.gn b/BUILD.gn index 06f6053be1e59..72497bc4e1492 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -177,11 +177,11 @@ if (is_win && target_cpu != "arm64") { } } +# Holds the shared includes so we only need to list them once. config("includes_config") { include_dirs = [ "include" ] } -# Holds the shared includes so we only need to list them once. angle_source_set("includes") { sources = libangle_includes public_configs = [ ":includes_config" ] diff --git a/DEPS b/DEPS index 2d1d53f1a26e2..4adf6e73aa838 100644 --- a/DEPS +++ b/DEPS @@ -60,10 +60,15 @@ deps = { 'url': '{chromium_git}/external/deqp@{deqp_revision}', }, + # glmark2 is a GPL3-licensed OpenGL ES 2.0 benchmark. We use it for testing. + '{angle_root}/third_party/glmark2/src': { + 'url': '{chromium_git}/external/github.com/glmark2/glmark2@c4b3ff5a481348e8bdc2b71ee275864db91e40b1', + }, + '{angle_root}/third_party/glslang/src': { 'url': '{chromium_git}/external/github.com/KhronosGroup/glslang@{glslang_revision}', 'condition': 'not build_with_chromium', - }, + }, '{angle_root}/third_party/googletest': { 'url': '{chromium_git}/chromium/src/third_party/googletest@660425b1c5ca04559ab7e50c7572b5b771acca1c', @@ -75,6 +80,12 @@ deps = { 'condition': 'not build_with_chromium', }, + # libjpeg_turbo is used by glmark2. + '{angle_root}/third_party/libjpeg_turbo': { + 'url': '{chromium_git}/chromium/deps/libjpeg_turbo@6dcdade8828297e306cabfdae80f3510f3f3eea2', + 'condition': 'not build_with_chromium', + }, + '{angle_root}/third_party/libpng/src': { 'url': '{android_git}/platform/external/libpng@094e181e79a3d6c23fd005679025058b7df1ad6c', 'condition': 'not build_with_chromium', @@ -142,6 +153,16 @@ deps = { 'url': '{chromium_git}/external/github.com/KhronosGroup/Vulkan-ValidationLayers@{vulkan_validation_revision}', }, + '{angle_root}/third_party/yasm': { + 'url': '{chromium_git}/chromium/src/third_party/yasm@86b6058141a42aed51bbd8bb9f9d54d199d9dbd0', + 'condition': 'not build_with_chromium', + }, + + '{angle_root}/third_party/yasm/source/patched-yasm': { + 'url': '{chromium_git}/chromium/deps/yasm/patched-yasm.git@720b70524a4424b15fc57e82263568c8ba0496ad', + 'condition': 'not build_with_chromium', + }, + '{angle_root}/third_party/zlib': { 'url': '{chromium_git}/chromium/src/third_party/zlib@f95aeb0fa7f136ef4a457a6d9ba6f3c2701a444b', 'condition': 'not build_with_chromium', diff --git a/build_overrides/angle.gni b/build_overrides/angle.gni index 153851c56efc1..903a1f51e0dc3 100644 --- a/build_overrides/angle.gni +++ b/build_overrides/angle.gni @@ -5,6 +5,7 @@ # Overrides for ANGLE's dependencies angle_glslang_dir = "//third_party/glslang/src" angle_googletest_dir = "//third_party/googletest/src" +angle_libjpeg_turbo_dir = "//third_party/libjpeg_turbo" angle_jsoncpp_dir = "//third_party/jsoncpp" angle_libpng_dir = "//third_party/libpng" angle_spirv_tools_dir = "//third_party/spirv-tools/src" diff --git a/src/tests/BUILD.gn b/src/tests/BUILD.gn index 38b3618b666fa..5a2c06aff688a 100644 --- a/src/tests/BUILD.gn +++ b/src/tests/BUILD.gn @@ -51,6 +51,13 @@ if (build_with_chromium) { if (build_angle_gles1_conform_tests) { deps += [ "//src/tests:angle_gles1_conformance_tests" ] } + + if (is_win) { + deps += [ + "//third_party/glmark2:glmark2_angle", + "//third_party/glmark2:glmark2_wgl", + ] + } } } diff --git a/third_party/BUILD.gn b/third_party/BUILD.gn new file mode 100644 index 0000000000000..eacbfc14c7f90 --- /dev/null +++ b/third_party/BUILD.gn @@ -0,0 +1,51 @@ +# Copyright 2019 The ANGLE Project Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +# +# See: +# https://chromium.googlesource.com/chromium/src/+/master/third_party/BUILD.gn + +import("//third_party/libjpeg.gni") + +assert(!is_ios, "This is not used on iOS, don't drag it in unintentionally") + +config("system_libjpeg_config") { + libs = [ "jpeg" ] + defines = [ "USE_SYSTEM_LIBJPEG" ] +} + +config("libjpeg_turbo_config") { + defines = [ "USE_LIBJPEG_TURBO=1" ] +} + +# This is a meta target that forwards to the system's libjpeg, +# third_party/libjpeg, or third_party/libjpeg_turbo depending on the build args +# declared in this file. +group("jpeg") { + if (use_system_libjpeg) { + public_configs = [ ":system_libjpeg_config" ] + } else if (use_libjpeg_turbo) { + public_deps = [ + "//third_party/libjpeg_turbo:libjpeg", + ] + public_configs = [ ":libjpeg_turbo_config" ] + } else { + public_deps = [ + "//third_party/libjpeg:libjpeg", + ] + } +} + +# This is a meta target that forwards include paths only to the system's +# libjpeg, third_party/libjpeg, or third_party/libjpeg_turbo depending on the +# build args declared in this file. This is needed, rarely, for targets that +# need to reference libjpeg without explicitly building it. +group("jpeg_includes") { + if (use_system_libjpeg) { + public_configs = [ ":system_libjpeg_config" ] + } else if (use_libjpeg_turbo) { + public_configs = [ "//third_party/libjpeg_turbo:libjpeg_config" ] + } else { + public_configs = [ "//third_party/libjpeg:libjpeg_config" ] + } +} diff --git a/third_party/glmark2/BUILD.gn b/third_party/glmark2/BUILD.gn new file mode 100644 index 0000000000000..427234dff89ae --- /dev/null +++ b/third_party/glmark2/BUILD.gn @@ -0,0 +1,394 @@ +# Copyright 2019 The ANGLE Project Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +# +# Build integration for glmark2. + +import("../../gni/angle.gni") + +glmark2_glad_common_sources = [ + "src/src/glad/include/glad/egl.h", + "src/src/glad/src/egl.c", +] + +config("glmark2_glad_config") { + include_dirs = [ "src/src/glad/include" ] +} + +source_set("glmark2_glad_gles") { + sources = glmark2_glad_common_sources + [ + "src/src/glad/include/glad/gles2.h", + "src/src/glad/src/gles2.c", + ] + public_configs = [ ":glmark2_glad_config" ] +} + +source_set("glmark2_glad_gl") { + sources = glmark2_glad_common_sources + [ + "src/src/glad/include/glad/gl.h", + "src/src/glad/src/gl.c", + ] + public_configs = [ ":glmark2_glad_config" ] +} + +glmark_data_path = "${angle_root}/third_party/glmark2/src/data" +raw_glmark_data_path = rebase_path(glmark_data_path, root_build_dir) + +config("glmark2_common_config") { + defines = [ "GLMARK_DATA_PATH=\"${raw_glmark_data_path}\"" ] + include_dirs = [ "src/src" ] + if (is_win) { + include_dirs += [ "src/src/include" ] + + # M_PI is nonstandard. + defines += [ "_USE_MATH_DEFINES" ] + + if (!is_clang) { + cflags = [ + # MSVC warns about the copyright character being illegal. + "/wd4828", + + # A warning generated in scene-effect-2d in vec2::calc_offset + "/wd4146", + ] + } + } +} + +config("glmark2_gles_config") { + defines = [ "GLMARK2_USE_GLESv2" ] +} + +config("glmark2_gl_config") { + defines = [ "GLMARK2_USE_GL" ] +} + +group("glmark2_gles") { + public_configs = [ + ":glmark2_common_config", + ":glmark2_gles_config", + ] + public_deps = [ + ":glmark2_glad_gles", + ] +} + +group("glmark2_gl") { + public_configs = [ + ":glmark2_common_config", + ":glmark2_gl_config", + ] + public_deps = [ + ":glmark2_glad_gl", + ] +} + +# Supplies compatible headers on Win32. +config("glmark2_headers_config") { + if (is_win) { + if (is_clang) { + cflags = [ + "-Wno-unused-function", + "-Wno-writable-strings", + "-Wno-extra-tokens", + ] + } + } +} + +source_set("glmark2_headers") { + sources = [ + "src/src/canvas.h", + "src/src/gl-headers.h", + "src/src/gl-state-egl.h", + "src/src/gl-state.h", + "src/src/gl-visual-config.h", + "src/src/mesh.h", + "src/src/scene.h", + "src/src/shared-library.h", + "src/src/texture.h", + ] + + if (is_win) { + sources += [ + "src/src/gl-state-wgl.h", + "src/src/include/dirent.h", + "src/src/include/getopt.h", + "src/src/include/sys/time.h", + ] + } + public_configs = [ ":glmark2_headers_config" ] + include_dirs = [ "src/src" ] +} + +config("glmark2_libmatrix_config") { + include_dirs = [ "src/src/libmatrix" ] +} + +template("glmark2_libmatrix") { + source_set(target_name) { + forward_variables_from(invoker, "*") + sources = [ + "src/src/libmatrix/gl-if.h", + "src/src/libmatrix/log.cc", + "src/src/libmatrix/log.h", + "src/src/libmatrix/mat.cc", + "src/src/libmatrix/mat.h", + "src/src/libmatrix/program.cc", + "src/src/libmatrix/program.h", + "src/src/libmatrix/shader-source.cc", + "src/src/libmatrix/shader-source.h", + "src/src/libmatrix/stack.h", + "src/src/libmatrix/util.cc", + "src/src/libmatrix/util.h", + "src/src/libmatrix/vec.h", + ] + + if (is_clang) { + cflags_cc = [ "-Wno-implicit-fallthrough" ] + } + public_deps = [ + ":glmark2_headers", + ] + public_configs = [ ":glmark2_libmatrix_config" ] + } +} + +glmark2_libmatrix("glmark2_libmatrix_gles") { + deps = [ + ":glmark2_gles", + ] +} + +glmark2_libmatrix("glmark2_libmatrix_gl") { + deps = [ + ":glmark2_gl", + ] +} + +config("glmark2_scene_ideas_config") { + include_dirs = [ "src/src/scene-ideas" ] +} + +template("glmark2_scene_ideas") { + source_set(target_name) { + forward_variables_from(invoker, "*") + sources = [ + "src/src/scene-ideas/a.cc", + "src/src/scene-ideas/characters.h", + "src/src/scene-ideas/d.cc", + "src/src/scene-ideas/e.cc", + "src/src/scene-ideas/i.cc", + "src/src/scene-ideas/lamp.cc", + "src/src/scene-ideas/lamp.h", + "src/src/scene-ideas/logo.cc", + "src/src/scene-ideas/logo.h", + "src/src/scene-ideas/m.cc", + "src/src/scene-ideas/n.cc", + "src/src/scene-ideas/o.cc", + "src/src/scene-ideas/s.cc", + "src/src/scene-ideas/splines.cc", + "src/src/scene-ideas/splines.h", + "src/src/scene-ideas/t.cc", + "src/src/scene-ideas/table.cc", + "src/src/scene-ideas/table.h", + ] + public_configs = [ ":glmark2_scene_ideas_config" ] + } +} + +glmark2_scene_ideas("glmark2_scene_ideas_gles") { + deps = [ + ":glmark2_gles", + ":glmark2_libmatrix_gles", + ] +} + +glmark2_scene_ideas("glmark2_scene_ideas_gl") { + deps = [ + ":glmark2_gl", + ":glmark2_libmatrix_gl", + ] +} + +config("glmark2_scene_terrain_config") { + include_dirs = [ "src/src/scene-terrain" ] +} + +template("glmark2_scene_terrain") { + source_set(target_name) { + forward_variables_from(invoker, "*") + sources = [ + "src/src/scene-terrain/base-renderer.cpp", + "src/src/scene-terrain/blur-renderer.cpp", + "src/src/scene-terrain/copy-renderer.cpp", + "src/src/scene-terrain/luminance-renderer.cpp", + "src/src/scene-terrain/normal-from-height-renderer.cpp", + "src/src/scene-terrain/overlay-renderer.cpp", + "src/src/scene-terrain/renderer-chain.cpp", + "src/src/scene-terrain/renderer.h", + "src/src/scene-terrain/simplex-noise-renderer.cpp", + "src/src/scene-terrain/terrain-renderer.cpp", + "src/src/scene-terrain/texture-renderer.cpp", + ] + + public_configs = [ ":glmark2_scene_terrain_config" ] + } +} + +glmark2_scene_terrain("glmark2_scene_terrain_gles") { + deps = [ + ":glmark2_gles", + ":glmark2_libmatrix_gles", + ] +} + +glmark2_scene_terrain("glmark2_scene_terrain_gl") { + deps = [ + ":glmark2_gl", + ":glmark2_libmatrix_gl", + ] +} + +template("glmark2_common") { + source_set(target_name) { + forward_variables_from(invoker, "*") + sources = [ + "src/src/benchmark-collection.cpp", + "src/src/benchmark-collection.h", + "src/src/benchmark.cpp", + "src/src/benchmark.h", + "src/src/default-benchmarks.h", + "src/src/gl-headers.cpp", + "src/src/gl-visual-config.cpp", + "src/src/gl-visual-config.h", + "src/src/image-reader.cpp", + "src/src/image-reader.h", + "src/src/main-loop.cpp", + "src/src/main-loop.h", + "src/src/mesh.cpp", + "src/src/model.cpp", + "src/src/model.h", + "src/src/native-state.h", + "src/src/options.cpp", + "src/src/options.h", + "src/src/scene-buffer.cpp", + "src/src/scene-build.cpp", + "src/src/scene-bump.cpp", + "src/src/scene-clear.cpp", + "src/src/scene-collection.h", + "src/src/scene-conditionals.cpp", + "src/src/scene-default-options.cpp", + "src/src/scene-desktop.cpp", + "src/src/scene-effect-2d.cpp", + "src/src/scene-function.cpp", + "src/src/scene-grid.cpp", + "src/src/scene-ideas.cpp", + "src/src/scene-jellyfish.cpp", + "src/src/scene-jellyfish.h", + "src/src/scene-loop.cpp", + "src/src/scene-pulsar.cpp", + "src/src/scene-refract.cpp", + "src/src/scene-refract.h", + "src/src/scene-shading.cpp", + "src/src/scene-shadow.cpp", + "src/src/scene-terrain.cpp", + "src/src/scene-texture.cpp", + "src/src/scene.cpp", + "src/src/shared-library.cpp", + "src/src/text-renderer.cpp", + "src/src/text-renderer.h", + "src/src/texture.cpp", + ] + + public_deps += [ + ":glmark2_headers", + "${angle_libpng_dir}:libpng", + "${angle_root}/third_party:jpeg", + ] + } +} + +glmark2_common("glmark2_common_gles") { + public_deps = [ + ":glmark2_gles", + ":glmark2_libmatrix_gles", + ":glmark2_scene_ideas_gles", + ":glmark2_scene_terrain_gles", + ] +} + +glmark2_common("glmark2_common_gl") { + public_deps = [ + ":glmark2_gl", + ":glmark2_libmatrix_gl", + ":glmark2_scene_ideas_gl", + ":glmark2_scene_terrain_gl", + ] +} + +glmark2_version = "2017.07" + +template("glmark2_exe") { + executable(target_name) { + forward_variables_from(invoker, "*") + sources += [ + "src/src/canvas-generic.cpp", + "src/src/canvas-generic.h", + "src/src/main.cpp", + ] + data = [ + "src/data", + ] + + defines += [ "GLMARK_VERSION=\"${glmark2_version}\"" ] + + if (is_win) { + defines += [ "GLMARK2_USE_WIN32" ] + sources += [ + "src/src/native-state-win32.cpp", + "src/src/native-state-win32.h", + ] + } + if (is_linux) { + defines += [ "GLMARK2_USE_X11" ] + sources += [ + "src/src/native-state-x11.cpp", + "src/src/native-state-x11.h", + ] + libs = [ "X11" ] + } + } +} + +glmark2_exe("glmark2_angle") { + sources = [ + "src/src/gl-state-egl.cpp", + ] + deps = [ + ":glmark2_common_gles", + ] + data_deps = [ + "${angle_root}:libEGL", + "${angle_root}:libGLESv2", + ] + + defines = [ + "EGL_EGL_PROTOTYPES=1", + "GLMARK2_USE_EGL", + ] +} + +if (is_win) { + glmark2_exe("glmark2_wgl") { + sources = [ + "src/src/gl-state-wgl.cpp", + ] + deps = [ + ":glmark2_common_gl", + ] + + libs = [ "opengl32.lib" ] + defines = [ "GLMARK2_USE_WGL" ] + } +} diff --git a/third_party/glmark2/README.angle b/third_party/glmark2/README.angle new file mode 100644 index 0000000000000..a2b6371fed841 --- /dev/null +++ b/third_party/glmark2/README.angle @@ -0,0 +1,12 @@ +Name: glmark2 +Short Name: glmark2 +URL: https://github.com/glmark2/glmark2 +Security Critical: no +License: GPL v3 +License File: NOT_SHIPPED + +Description: +glmark2 is an OpenGL 2.0 and ES 2.0 benchmark. + +glmark2 is developed by Alexandros Frantzis and Jesse Barker based on the +original glmark benchmark by Ben Smith. diff --git a/third_party/libjpeg.gni b/third_party/libjpeg.gni new file mode 100644 index 0000000000000..8d4527c1358bc --- /dev/null +++ b/third_party/libjpeg.gni @@ -0,0 +1,15 @@ +# Copyright 2019 The ANGLE Project Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +# +# See: +# https://chromium.googlesource.com/chromium/src/+/master/third_party/libjpeg.gni + +declare_args() { + # Uses system libjpeg. If true, overrides use_libjpeg_turbo. + use_system_libjpeg = false + + # Uses libjpeg_turbo as the jpeg implementation. Has no effect if + # use_system_libjpeg is set. + use_libjpeg_turbo = true +}