Commit 4ffc254e by Eric Binet Committed by Commit Bot

Only initialize the timestamp query pools if the extension is available.

Also added a few assertions to ensure that timestamp queries aren't attempted when support is missing. Bug: angleproject:4114 Change-Id: Ie6d7d5face59f9bc137aebd86c9d0e965773e6e6 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1992184 Commit-Queue: Eric Binet <ericbinet@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent f567bac0
......@@ -674,10 +674,15 @@ angle::Result ContextVk::initialize()
vk::kDefaultOcclusionQueryPoolSize));
ANGLE_TRY(mQueryPools[gl::QueryType::AnySamplesConservative].init(
this, VK_QUERY_TYPE_OCCLUSION, vk::kDefaultOcclusionQueryPoolSize));
ANGLE_TRY(mQueryPools[gl::QueryType::Timestamp].init(this, VK_QUERY_TYPE_TIMESTAMP,
vk::kDefaultTimestampQueryPoolSize));
ANGLE_TRY(mQueryPools[gl::QueryType::TimeElapsed].init(this, VK_QUERY_TYPE_TIMESTAMP,
vk::kDefaultTimestampQueryPoolSize));
// Only initialize the timestamp query pools if the extension is available.
if (mRenderer->getQueueFamilyProperties().timestampValidBits > 0)
{
ANGLE_TRY(mQueryPools[gl::QueryType::Timestamp].init(this, VK_QUERY_TYPE_TIMESTAMP,
vk::kDefaultTimestampQueryPoolSize));
ANGLE_TRY(mQueryPools[gl::QueryType::TimeElapsed].init(this, VK_QUERY_TYPE_TIMESTAMP,
vk::kDefaultTimestampQueryPoolSize));
}
// Init driver uniforms and get the descriptor set layouts.
constexpr angle::PackedEnumMap<PipelineType, VkShaderStageFlags> kPipelineStages = {
......@@ -731,6 +736,8 @@ angle::Result ContextVk::initialize()
if (mGpuEventsEnabled)
{
// GPU events should only be available if timestamp queries are available.
ASSERT(mRenderer->getQueueFamilyProperties().timestampValidBits > 0);
// Calculate the difference between CPU and GPU clocks for GPU event reporting.
ANGLE_TRY(mGpuEventQueryPool.init(this, VK_QUERY_TYPE_TIMESTAMP,
vk::kDefaultTimestampQueryPoolSize));
......@@ -2522,6 +2529,9 @@ GLint ContextVk::getGPUDisjoint()
GLint64 ContextVk::getTimestamp()
{
// This function should only be called if timestamp queries are available.
ASSERT(mRenderer->getQueueFamilyProperties().timestampValidBits > 0);
uint64_t timestamp = 0;
(void)getTimestamp(&timestamp);
......@@ -2847,6 +2857,10 @@ vk::DynamicQueryPool *ContextVk::getQueryPool(gl::QueryType queryType)
ASSERT(queryType == gl::QueryType::AnySamples ||
queryType == gl::QueryType::AnySamplesConservative ||
queryType == gl::QueryType::Timestamp || queryType == gl::QueryType::TimeElapsed);
// Assert that timestamp extension is available if needed.
ASSERT(queryType != gl::QueryType::Timestamp && queryType != gl::QueryType::TimeElapsed ||
mRenderer->getQueueFamilyProperties().timestampValidBits > 0);
ASSERT(mQueryPools[queryType].isValid());
return &mQueryPools[queryType];
}
......
......@@ -107,6 +107,10 @@ class RendererVk : angle::NonCopyable
const gl::Limitations &getNativeLimitations() const;
uint32_t getQueueFamilyIndex() const { return mCurrentQueueFamilyIndex; }
const VkQueueFamilyProperties &getQueueFamilyProperties() const
{
return mQueueFamilyProperties[mCurrentQueueFamilyIndex];
}
const vk::MemoryProperties &getMemoryProperties() const { return mMemoryProperties; }
......
......@@ -479,6 +479,8 @@ if (build_angle_gles1_conform_tests) {
"test_utils/angle_test_configs.h",
"test_utils/angle_test_instantiate.cpp",
"test_utils/angle_test_instantiate.h",
"test_utils/angle_test_platform.cpp",
"test_utils/angle_test_platform.h",
"test_utils/gl_raii.h",
]
if (is_mac) {
......
......@@ -156,6 +156,8 @@ angle_end2end_tests_sources = [
"test_expectations/GPUTestExpectationsTest.cpp",
"test_utils/ANGLETest.cpp",
"test_utils/ANGLETest.h",
"test_utils/angle_test_platform.cpp",
"test_utils/angle_test_platform.h",
"test_utils/MultiviewTest.cpp",
"test_utils/MultiviewTest.h",
"test_utils/angle_test_configs.cpp",
......
......@@ -12,6 +12,8 @@ _angle_perf_test_common_sources = [
"perf_tests/third_party/perf/perf_result_reporter.h",
"perf_tests/third_party/perf/perf_test.cc",
"perf_tests/third_party/perf/perf_test.h",
"test_utils/angle_test_platform.cpp",
"test_utils/angle_test_platform.h",
"test_utils/angle_test_configs.cpp",
"test_utils/angle_test_configs.h",
"test_utils/angle_test_instantiate.cpp",
......
......@@ -5,6 +5,8 @@
angle_white_box_tests_sources = [
"egl_tests/EGLFeatureControlTest.cpp",
"util_tests/PrintSystemInfoTest.cpp",
"test_utils/angle_test_platform.cpp",
"test_utils/angle_test_platform.h",
"test_utils/angle_test_configs.cpp",
"test_utils/angle_test_configs.h",
"test_utils/angle_test_instantiate.cpp",
......
......@@ -10,6 +10,7 @@
#include "ANGLEPerfTest.h"
#include "ANGLEPerfTestArgs.h"
#include "common/debug.h"
#include "common/platform.h"
#include "common/system_utils.h"
#include "third_party/perf/perf_test.h"
......@@ -378,7 +379,8 @@ ANGLERenderTest::ANGLERenderTest(const std::string &name, const RenderTestParams
OneFrame() ? 1 : testParams.iterationsPerStep),
mTestParams(testParams),
mGLWindow(nullptr),
mOSWindow(nullptr)
mOSWindow(nullptr),
mIsTimestampQueryAvailable(false)
{
// Force fast tests to make sure our slowest bots don't time out.
if (OneFrame())
......@@ -484,6 +486,8 @@ void ANGLERenderTest::SetUp()
// FAIL returns.
}
mIsTimestampQueryAvailable = IsGLExtensionEnabled("GL_EXT_disjoint_timer_query");
if (!areExtensionPrerequisitesFulfilled())
{
mSkipTest = true;
......@@ -586,7 +590,7 @@ void ANGLERenderTest::step()
void ANGLERenderTest::startGpuTimer()
{
if (mTestParams.trackGpuTime)
if (mTestParams.trackGpuTime && mIsTimestampQueryAvailable)
{
glBeginQueryEXT(GL_TIME_ELAPSED_EXT, mTimestampQuery);
}
......@@ -594,7 +598,7 @@ void ANGLERenderTest::startGpuTimer()
void ANGLERenderTest::stopGpuTimer()
{
if (mTestParams.trackGpuTime)
if (mTestParams.trackGpuTime && mIsTimestampQueryAvailable)
{
glEndQueryEXT(GL_TIME_ELAPSED_EXT);
uint64_t gpuTimeNs = 0;
......
......@@ -19,6 +19,7 @@
#include "platform/Platform.h"
#include "test_utils/angle_test_configs.h"
#include "test_utils/angle_test_instantiate.h"
#include "test_utils/angle_test_platform.h"
#include "third_party/perf/perf_result_reporter.h"
#include "util/EGLWindow.h"
#include "util/OSWindow.h"
......@@ -163,6 +164,7 @@ class ANGLERenderTest : public ANGLEPerfTest
angle::PlatformMethods mPlatformMethods;
ConfigParameters mConfigParams;
bool mIsTimestampQueryAvailable;
GLuint mTimestampQuery;
// Trace event record that can be output.
......
......@@ -1220,86 +1220,6 @@ void ANGLETestBase::setWindowVisible(bool isVisible)
mFixture->osWindow->setVisible(isVisible);
}
bool IsAdreno()
{
std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER)));
return (rendererString.find("Adreno") != std::string::npos);
}
bool IsD3D11()
{
std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER)));
return (rendererString.find("Direct3D11 vs_5_0") != std::string::npos);
}
bool IsD3D11_FL93()
{
std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER)));
return (rendererString.find("Direct3D11 vs_4_0_") != std::string::npos);
}
bool IsD3D9()
{
std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER)));
return (rendererString.find("Direct3D9") != std::string::npos);
}
bool IsD3DSM3()
{
return IsD3D9() || IsD3D11_FL93();
}
bool IsDesktopOpenGL()
{
return IsOpenGL() && !IsOpenGLES();
}
bool IsOpenGLES()
{
std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER)));
return (rendererString.find("OpenGL ES") != std::string::npos);
}
bool IsOpenGL()
{
std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER)));
return (rendererString.find("OpenGL") != std::string::npos);
}
bool IsNULL()
{
std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER)));
return (rendererString.find("NULL") != std::string::npos);
}
bool IsVulkan()
{
const char *renderer = reinterpret_cast<const char *>(glGetString(GL_RENDERER));
std::string rendererString(renderer);
return (rendererString.find("Vulkan") != std::string::npos);
}
bool IsMetal()
{
const char *renderer = reinterpret_cast<const char *>(glGetString(GL_RENDERER));
std::string rendererString(renderer);
return (rendererString.find("Metal") != std::string::npos);
}
bool IsDebug()
{
#if !defined(NDEBUG)
return true;
#else
return false;
#endif
}
bool IsRelease()
{
return !IsDebug();
}
ANGLETestBase::TestFixture::TestFixture() = default;
ANGLETestBase::TestFixture::~TestFixture() = default;
......@@ -1406,40 +1326,3 @@ void ANGLEProcessTestArgs(int *argc, char *argv[])
}
}
}
bool EnsureGLExtensionEnabled(const std::string &extName)
{
if (IsGLExtensionEnabled("GL_ANGLE_request_extension") && IsGLExtensionRequestable(extName))
{
glRequestExtensionANGLE(extName.c_str());
}
return IsGLExtensionEnabled(extName);
}
bool IsEGLClientExtensionEnabled(const std::string &extName)
{
return CheckExtensionExists(eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS), extName);
}
bool IsEGLDeviceExtensionEnabled(EGLDeviceEXT device, const std::string &extName)
{
return CheckExtensionExists(eglQueryDeviceStringEXT(device, EGL_EXTENSIONS), extName);
}
bool IsEGLDisplayExtensionEnabled(EGLDisplay display, const std::string &extName)
{
return CheckExtensionExists(eglQueryString(display, EGL_EXTENSIONS), extName);
}
bool IsGLExtensionEnabled(const std::string &extName)
{
return CheckExtensionExists(reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS)),
extName);
}
bool IsGLExtensionRequestable(const std::string &extName)
{
return CheckExtensionExists(
reinterpret_cast<const char *>(glGetString(GL_REQUESTABLE_EXTENSIONS_ANGLE)), extName);
}
......@@ -15,6 +15,7 @@
#include <array>
#include "angle_test_configs.h"
#include "angle_test_platform.h"
#include "common/angleutils.h"
#include "common/system_utils.h"
#include "common/vector_utils.h"
......@@ -594,35 +595,6 @@ class ANGLETestEnvironment : public testing::Environment
static std::unique_ptr<angle::Library> gWGLLibrary;
};
// Driver vendors
bool IsAdreno();
// Renderer back-ends
// Note: FL9_3 is explicitly *not* considered D3D11.
bool IsD3D11();
bool IsD3D11_FL93();
// Is a D3D9-class renderer.
bool IsD3D9();
// Is D3D9 or SM9_3 renderer.
bool IsD3DSM3();
bool IsDesktopOpenGL();
bool IsOpenGLES();
bool IsOpenGL();
bool IsNULL();
bool IsVulkan();
bool IsMetal();
// Debug/Release
bool IsDebug();
bool IsRelease();
bool EnsureGLExtensionEnabled(const std::string &extName);
bool IsEGLClientExtensionEnabled(const std::string &extName);
bool IsEGLDeviceExtensionEnabled(EGLDeviceEXT device, const std::string &extName);
bool IsEGLDisplayExtensionEnabled(EGLDisplay display, const std::string &extName);
bool IsGLExtensionEnabled(const std::string &extName);
bool IsGLExtensionRequestable(const std::string &extName);
extern angle::PlatformMethods gDefaultPlatformMethods;
#endif // ANGLE_TESTS_ANGLE_TEST_H_
//
// Copyright 2020 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.
#include "angle_test_platform.h"
#include "common/platform.h"
#include "gpu_info_util/SystemInfo.h"
#include "util/EGLWindow.h"
#include "util/OSWindow.h"
#include "util/test_utils.h"
#if defined(ANGLE_PLATFORM_WINDOWS)
# include <VersionHelpers.h>
#endif // defined(ANGLE_PLATFORM_WINDOWS)
bool IsAdreno()
{
std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER)));
return (rendererString.find("Adreno") != std::string::npos);
}
bool IsD3D11()
{
std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER)));
return (rendererString.find("Direct3D11 vs_5_0") != std::string::npos);
}
bool IsD3D11_FL93()
{
std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER)));
return (rendererString.find("Direct3D11 vs_4_0_") != std::string::npos);
}
bool IsD3D9()
{
std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER)));
return (rendererString.find("Direct3D9") != std::string::npos);
}
bool IsD3DSM3()
{
return IsD3D9() || IsD3D11_FL93();
}
bool IsDesktopOpenGL()
{
return IsOpenGL() && !IsOpenGLES();
}
bool IsOpenGLES()
{
std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER)));
return (rendererString.find("OpenGL ES") != std::string::npos);
}
bool IsOpenGL()
{
std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER)));
return (rendererString.find("OpenGL") != std::string::npos);
}
bool IsNULL()
{
std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER)));
return (rendererString.find("NULL") != std::string::npos);
}
bool IsVulkan()
{
const char *renderer = reinterpret_cast<const char *>(glGetString(GL_RENDERER));
std::string rendererString(renderer);
return (rendererString.find("Vulkan") != std::string::npos);
}
bool IsMetal()
{
const char *renderer = reinterpret_cast<const char *>(glGetString(GL_RENDERER));
std::string rendererString(renderer);
return (rendererString.find("Metal") != std::string::npos);
}
bool IsDebug()
{
#if !defined(NDEBUG)
return true;
#else
return false;
#endif
}
bool IsRelease()
{
return !IsDebug();
}
bool EnsureGLExtensionEnabled(const std::string &extName)
{
if (IsGLExtensionEnabled("GL_ANGLE_request_extension") && IsGLExtensionRequestable(extName))
{
glRequestExtensionANGLE(extName.c_str());
}
return IsGLExtensionEnabled(extName);
}
bool IsEGLClientExtensionEnabled(const std::string &extName)
{
return CheckExtensionExists(eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS), extName);
}
bool IsEGLDeviceExtensionEnabled(EGLDeviceEXT device, const std::string &extName)
{
return CheckExtensionExists(eglQueryDeviceStringEXT(device, EGL_EXTENSIONS), extName);
}
bool IsEGLDisplayExtensionEnabled(EGLDisplay display, const std::string &extName)
{
return CheckExtensionExists(eglQueryString(display, EGL_EXTENSIONS), extName);
}
bool IsGLExtensionEnabled(const std::string &extName)
{
return CheckExtensionExists(reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS)),
extName);
}
bool IsGLExtensionRequestable(const std::string &extName)
{
return CheckExtensionExists(
reinterpret_cast<const char *>(glGetString(GL_REQUESTABLE_EXTENSIONS_ANGLE)), extName);
}
//
// Copyright 2020 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.
//
#ifndef ANGLE_TESTS_ANGLE_TEST_PLATFORM_H_
#define ANGLE_TESTS_ANGLE_TEST_PLATFORM_H_
#include <string>
#include "util/EGLWindow.h"
// Driver vendors
bool IsAdreno();
// Renderer back-ends
// Note: FL9_3 is explicitly *not* considered D3D11.
bool IsD3D11();
bool IsD3D11_FL93();
// Is a D3D9-class renderer.
bool IsD3D9();
// Is D3D9 or SM9_3 renderer.
bool IsD3DSM3();
bool IsDesktopOpenGL();
bool IsOpenGLES();
bool IsOpenGL();
bool IsNULL();
bool IsVulkan();
bool IsMetal();
// Debug/Release
bool IsDebug();
bool IsRelease();
bool EnsureGLExtensionEnabled(const std::string &extName);
bool IsEGLClientExtensionEnabled(const std::string &extName);
bool IsEGLDeviceExtensionEnabled(EGLDeviceEXT device, const std::string &extName);
bool IsEGLDisplayExtensionEnabled(EGLDisplay display, const std::string &extName);
bool IsGLExtensionEnabled(const std::string &extName);
bool IsGLExtensionRequestable(const std::string &extName);
#endif // ANGLE_TESTS_ANGLE_TEST_PLATFORM_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment