diff options
Diffstat (limited to 'chromium/third_party/angle/samples')
7 files changed, 79 insertions, 36 deletions
diff --git a/chromium/third_party/angle/samples/BUILD.gn b/chromium/third_party/angle/samples/BUILD.gn index b0ce2088b04..aef9928f8cf 100644 --- a/chromium/third_party/angle/samples/BUILD.gn +++ b/chromium/third_party/angle/samples/BUILD.gn @@ -201,7 +201,14 @@ if (angle_build_capture_replay_sample) { "ANGLE_CAPTURE_REPLAY_SAMPLE_CONTEXT_ID=${_contextid}", "ANGLE_CAPTURE_REPLAY_SAMPLE_HEADER=angle_capture_context${_contextid}.h", ] + suppressed_configs = [ "$angle_root:constructor_and_destructor_warnings" ] + + # Disable optimization to avoid optimizing huge files. + if (!is_debug) { + suppressed_configs += [ "//build/config/compiler:default_optimization" ] + configs += [ "//build/config/compiler:no_optimize" ] + } } } diff --git a/chromium/third_party/angle/samples/capture_replay/CaptureReplay.cpp b/chromium/third_party/angle/samples/capture_replay/CaptureReplay.cpp index cd12e4511df..e85fb47a041 100644 --- a/chromium/third_party/angle/samples/capture_replay/CaptureReplay.cpp +++ b/chromium/third_party/angle/samples/capture_replay/CaptureReplay.cpp @@ -11,11 +11,6 @@ #include "util/frame_capture_utils.h" -#define ANGLE_MACRO_STRINGIZE_AUX(a) #a -#define ANGLE_MACRO_STRINGIZE(a) ANGLE_MACRO_STRINGIZE_AUX(a) -#define ANGLE_MACRO_CONCAT_AUX(a, b) a##b -#define ANGLE_MACRO_CONCAT(a, b) ANGLE_MACRO_CONCAT_AUX(a, b) - // Build the right context header based on replay ID // This will expand to "angle_capture_context<#>.h" #include ANGLE_MACRO_STRINGIZE(ANGLE_CAPTURE_REPLAY_SAMPLE_HEADER) @@ -61,8 +56,7 @@ class CaptureReplaySample : public SampleApplication { // Compute the current frame, looping from kReplayFrameStart to kReplayFrameEnd. uint32_t frame = - kReplayFrameStart + (mCurrentFrame % (kReplayFrameEnd - kReplayFrameStart)); - + kReplayFrameStart + (mCurrentFrame % ((kReplayFrameEnd - kReplayFrameStart) + 1)); if (mPreviousFrame > frame) { ResetContextReplay(); diff --git a/chromium/third_party/angle/samples/post_sub_buffer/PostSubBuffer.cpp b/chromium/third_party/angle/samples/post_sub_buffer/PostSubBuffer.cpp index 0a568db3d20..cce4559879a 100644 --- a/chromium/third_party/angle/samples/post_sub_buffer/PostSubBuffer.cpp +++ b/chromium/third_party/angle/samples/post_sub_buffer/PostSubBuffer.cpp @@ -29,13 +29,6 @@ class PostSubBufferSample : public SampleApplication bool initialize() override { - mPostSubBufferNV = (PFNEGLPOSTSUBBUFFERNVPROC)eglGetProcAddress("eglPostSubBufferNV"); - if (!mPostSubBufferNV) - { - std::cerr << "Could not load eglPostSubBufferNV."; - return false; - } - constexpr char kVS[] = R"(uniform mat4 u_mvpMatrix; attribute vec4 a_position; attribute vec2 a_texcoord; @@ -136,7 +129,7 @@ void main() EGLint windowHeight = static_cast<EGLint>(getWindow()->getHeight()); EGLDisplay display = getDisplay(); EGLSurface surface = getSurface(); - mPostSubBufferNV(display, surface, 60, 60, windowWidth - 120, windowHeight - 120); + eglPostSubBufferNV(display, surface, 60, 60, windowWidth - 120, windowHeight - 120); } private: @@ -155,9 +148,6 @@ void main() // Geometry data CubeGeometry mCube; - - // eglPostSubBufferNV entry point - PFNEGLPOSTSUBBUFFERNVPROC mPostSubBufferNV; }; int main(int argc, char **argv) diff --git a/chromium/third_party/angle/samples/sample_util/SampleApplication.cpp b/chromium/third_party/angle/samples/sample_util/SampleApplication.cpp index 2c5e33c5e2e..c4cf062027e 100644 --- a/chromium/third_party/angle/samples/sample_util/SampleApplication.cpp +++ b/chromium/third_party/angle/samples/sample_util/SampleApplication.cpp @@ -6,6 +6,7 @@ #include "SampleApplication.h" +#include "common/debug.h" #include "util/EGLWindow.h" #include "util/gles_loader_autogen.h" #include "util/random_utils.h" @@ -15,9 +16,14 @@ #include <iostream> #include <utility> +#if defined(ANGLE_PLATFORM_WINDOWS) +# include "util/windows/WGLWindow.h" +#endif // defined(ANGLE_PLATFORM_WINDOWS) + namespace { const char *kUseAngleArg = "--use-angle="; +const char *kUseGlArg = "--use-gl=native"; using DisplayTypeInfo = std::pair<const char *, EGLint>; @@ -71,29 +77,56 @@ SampleApplication::SampleApplication(std::string name, mWidth(width), mHeight(height), mRunning(false), + mGLWindow(nullptr), mEGLWindow(nullptr), - mOSWindow(nullptr) + mOSWindow(nullptr), + mDriverType(angle::GLESDriverType::AngleEGL) { mPlatformParams.renderer = EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE; + bool useNativeGL = false; - if (argc > 1 && strncmp(argv[1], kUseAngleArg, strlen(kUseAngleArg)) == 0) + for (int argIndex = 1; argIndex < argc; argIndex++) { - const char *arg = argv[1] + strlen(kUseAngleArg); - mPlatformParams.renderer = GetDisplayTypeFromArg(arg); - mPlatformParams.deviceType = GetDeviceTypeFromArg(arg); + if (strncmp(argv[argIndex], kUseAngleArg, strlen(kUseAngleArg)) == 0) + { + const char *arg = argv[argIndex] + strlen(kUseAngleArg); + mPlatformParams.renderer = GetDisplayTypeFromArg(arg); + mPlatformParams.deviceType = GetDeviceTypeFromArg(arg); + } + + if (strncmp(argv[argIndex], kUseGlArg, strlen(kUseGlArg)) == 0) + { + useNativeGL = true; + } } - // Load EGL library so we can initialize the display. - mEntryPointsLib.reset( - angle::OpenSharedLibrary(ANGLE_EGL_LIBRARY_NAME, angle::SearchType::ApplicationDir)); + mOSWindow = OSWindow::New(); - mEGLWindow = EGLWindow::New(glesMajorVersion, glesMinorVersion); - mOSWindow = OSWindow::New(); + // Load EGL library so we can initialize the display. + if (useNativeGL) + { +#if defined(ANGLE_PLATFORM_WINDOWS) + mGLWindow = WGLWindow::New(glesMajorVersion, glesMinorVersion); + mEntryPointsLib.reset(angle::OpenSharedLibrary("opengl32", angle::SearchType::SystemDir)); + mDriverType = angle::GLESDriverType::SystemWGL; +#else + mGLWindow = EGLWindow::New(glesMajorVersion, glesMinorVersion); + mEntryPointsLib.reset( + angle::OpenSharedLibraryWithExtension(angle::GetNativeEGLLibraryNameWithExtension())); + mDriverType = angle::GLESDriverType::SystemEGL; +#endif // defined(ANGLE_PLATFORM_WINDOWS) + } + else + { + mGLWindow = mEGLWindow = EGLWindow::New(glesMajorVersion, glesMinorVersion); + mEntryPointsLib.reset( + angle::OpenSharedLibrary(ANGLE_EGL_LIBRARY_NAME, angle::SearchType::ApplicationDir)); + } } SampleApplication::~SampleApplication() { - EGLWindow::Delete(&mEGLWindow); + GLWindowBase::Delete(&mGLWindow); OSWindow::Delete(&mOSWindow); } @@ -110,7 +143,7 @@ void SampleApplication::draw() {} void SampleApplication::swap() { - mEGLWindow->swap(); + mGLWindow->swap(); } OSWindow *SampleApplication::getWindow() const @@ -120,21 +153,25 @@ OSWindow *SampleApplication::getWindow() const EGLConfig SampleApplication::getConfig() const { + ASSERT(mEGLWindow); return mEGLWindow->getConfig(); } EGLDisplay SampleApplication::getDisplay() const { + ASSERT(mEGLWindow); return mEGLWindow->getDisplay(); } EGLSurface SampleApplication::getSurface() const { + ASSERT(mEGLWindow); return mEGLWindow->getSurface(); } EGLContext SampleApplication::getContext() const { + ASSERT(mEGLWindow); return mEGLWindow->getContext(); } @@ -155,20 +192,18 @@ int SampleApplication::run() configParams.depthBits = 24; configParams.stencilBits = 8; - if (!mEGLWindow->initializeGL(mOSWindow, mEntryPointsLib.get(), angle::GLESDriverType::AngleEGL, - mPlatformParams, configParams)) + if (!mGLWindow->initializeGL(mOSWindow, mEntryPointsLib.get(), mDriverType, mPlatformParams, + configParams)) { return -1; } // Disable vsync - if (!mEGLWindow->setSwapInterval(0)) + if (!mGLWindow->setSwapInterval(0)) { return -1; } - angle::LoadGLES(eglGetProcAddress); - mRunning = true; int result = 0; @@ -223,7 +258,7 @@ int SampleApplication::run() } destroy(); - mEGLWindow->destroyGL(); + mGLWindow->destroyGL(); mOSWindow->destroy(); return result; diff --git a/chromium/third_party/angle/samples/sample_util/SampleApplication.h b/chromium/third_party/angle/samples/sample_util/SampleApplication.h index 9206f154f1f..be1e9d61722 100644 --- a/chromium/third_party/angle/samples/sample_util/SampleApplication.h +++ b/chromium/third_party/angle/samples/sample_util/SampleApplication.h @@ -19,6 +19,7 @@ #include "util/egl_loader_autogen.h" class EGLWindow; +class GLWindowBase; namespace angle { @@ -66,8 +67,10 @@ class SampleApplication bool mRunning; Timer mTimer; + GLWindowBase *mGLWindow; EGLWindow *mEGLWindow; OSWindow *mOSWindow; + angle::GLESDriverType mDriverType; EGLPlatformParameters mPlatformParams; diff --git a/chromium/third_party/angle/samples/sample_util/tga_utils.h b/chromium/third_party/angle/samples/sample_util/tga_utils.h index 2678074ddc7..f7f5e50bcf5 100644 --- a/chromium/third_party/angle/samples/sample_util/tga_utils.h +++ b/chromium/third_party/angle/samples/sample_util/tga_utils.h @@ -8,6 +8,7 @@ #define SAMPLE_UTIL_TGA_UTILS_HPP #include <array> +#include <string> #include <vector> #include "util/gles_loader_autogen.h" diff --git a/chromium/third_party/angle/samples/simple_texture_2d/SimpleTexture2D.cpp b/chromium/third_party/angle/samples/simple_texture_2d/SimpleTexture2D.cpp index 0f880d3af96..d1bd1a6e880 100644 --- a/chromium/third_party/angle/samples/simple_texture_2d/SimpleTexture2D.cpp +++ b/chromium/third_party/angle/samples/simple_texture_2d/SimpleTexture2D.cpp @@ -61,6 +61,8 @@ void main() glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + mTimer.start(); + return true; } @@ -110,6 +112,14 @@ void main() glUniform1i(mSamplerLoc, 0); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices); + + mDrawCount++; + + if (mDrawCount % 100 == 0) + { + printf("Rate: %0.2lf iterations / second\n", + static_cast<double>(mDrawCount) / mTimer.getElapsedTime()); + } } private: @@ -125,6 +135,9 @@ void main() // Texture handle GLuint mTexture; + + Timer mTimer; + uint32_t mDrawCount = 0; }; int main(int argc, char **argv) |