Hash :
d193d51b
Author :
Date :
2024-06-17T22:46:08
Replace issue ids post migration to new issue tracker This change replaces anglebug.com/NNNN links. Bug: None Change-Id: I8ac3aec8d2a8a844b3d7b99fc0a6b2be8da31761 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5637912 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
//
// Copyright 2021 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.
//
// QueryObjectValidation.cpp : Tests between gl.*Query.* functions and interactions with
// EGL_CONTEXT_OPENGL_NO_ERROR_KHR
#include <gtest/gtest.h>
#include "test_utils/ANGLETest.h"
#include "util/EGLWindow.h"
#include "util/test_utils.h"
namespace angle
{
using QueryObjectTestParams = std::tuple<angle::PlatformParameters, bool>;
std::string PrintToStringParamName(const ::testing::TestParamInfo<QueryObjectTestParams> &info)
{
std::stringstream ss;
ss << std::get<0>(info.param);
if (std::get<1>(info.param))
{
ss << "__ValidationDisabled";
}
else
{
ss << "__ValidationEnabled";
}
return ss.str();
}
class QueryObjectTest : public ANGLETest<QueryObjectTestParams>
{
protected:
QueryObjectTest() : mQueryObjectName(0), mQueryResult(false)
{
setNoErrorEnabled(testing::get<1>(GetParam()));
}
void createQuery()
{
glGenQueries(1, &mQueryObjectName);
ASSERT_NE(mQueryObjectName, (GLuint)0u);
ASSERT_GL_NO_ERROR();
}
void testSetUp() override { createQuery(); }
void testTearDown() override
{
if (mQueryObjectName)
{
glDeleteQueries(1, &mQueryObjectName);
}
}
GLuint mQueryObjectName = 0;
GLuint mQueryResult = 0;
};
class QueryObjectTestES32 : public QueryObjectTest
{};
// Test if a generated query is a query before glBeginQuery
TEST_P(QueryObjectTest, QueryObjectIsQuery)
{
GLboolean isQueryResult = glIsQuery(mQueryObjectName);
ASSERT_GL_NO_ERROR();
ASSERT_FALSE(isQueryResult);
}
// Negative test for glGetQueryObjectuiv before glBegin with GL_QUERY_RESULT
TEST_P(QueryObjectTest, QueryObjectResultBeforeBegin)
{
glGetQueryObjectuiv(mQueryObjectName, GL_QUERY_RESULT, &mQueryResult);
bool isNoError = testing::get<1>(GetParam());
if (isNoError)
{
ASSERT_GL_NO_ERROR();
}
else
{
ASSERT_EQ(glGetError(), (GLenum)GL_INVALID_OPERATION);
}
}
// Negative test for glGetQueryObjectuiv before glBegin with GL_QUERY_RESULT_AVAILABLE
TEST_P(QueryObjectTest, QueryObjectResultAvailableBeforeBegin)
{
glGetQueryObjectuiv(mQueryObjectName, GL_QUERY_RESULT_AVAILABLE, &mQueryResult);
bool isNoError = testing::get<1>(GetParam());
if (isNoError)
{
ASSERT_GL_NO_ERROR();
}
else
{
ASSERT_EQ(glGetError(), (GLenum)GL_INVALID_OPERATION);
}
}
// Test glGetQueryObjectuiv after glEndQuery
TEST_P(QueryObjectTest, QueryObjectResultAfterEnd)
{
glBeginQuery(GL_ANY_SAMPLES_PASSED, mQueryObjectName);
ASSERT_GL_NO_ERROR();
glEndQuery(GL_ANY_SAMPLES_PASSED);
ASSERT_GL_NO_ERROR();
glGetQueryObjectuiv(mQueryObjectName, GL_QUERY_RESULT_AVAILABLE, &mQueryResult);
}
// Test glGetQueryObjectuiv after glEndQuery with GL_PRIMITIVES_GENERATED
TEST_P(QueryObjectTestES32, QueryObjectResultAfterEndPrimitivesGenerated)
{
// TODO(anglebug.com/42263969): Allow GL_PRIMITIVES_GENERATED query objects
// when transform feedback is not active
ANGLE_SKIP_TEST_IF(IsVulkan());
glBeginQuery(GL_PRIMITIVES_GENERATED, mQueryObjectName);
ASSERT_GL_NO_ERROR();
glEndQuery(GL_PRIMITIVES_GENERATED);
ASSERT_GL_NO_ERROR();
while (mQueryResult != GL_TRUE)
{
glGetQueryObjectuiv(mQueryObjectName, GL_QUERY_RESULT_AVAILABLE, &mQueryResult);
ASSERT_GL_NO_ERROR();
angle::Sleep(50);
}
GLboolean isQueryResult = glIsQuery(mQueryObjectName);
ASSERT_GL_NO_ERROR();
ASSERT_TRUE(isQueryResult);
}
static const bool noErrorFlags[] = {true, false};
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(QueryObjectTest);
ANGLE_INSTANTIATE_TEST_COMBINE_1(QueryObjectTest,
PrintToStringParamName,
testing::ValuesIn(noErrorFlags),
ANGLE_ALL_TEST_PLATFORMS_ES3);
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(QueryObjectTestES32);
ANGLE_INSTANTIATE_TEST_COMBINE_1(QueryObjectTestES32,
PrintToStringParamName,
testing::ValuesIn(noErrorFlags),
ANGLE_ALL_TEST_PLATFORMS_ES32);
} // namespace angle