xref: /aosp_15_r20/external/deqp/modules/gles2/performance/es2pTextureFilteringTests.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program OpenGL ES 2.0 Module
3  * -------------------------------------------------
4  *
5  * Copyright 2014 The Android Open Source Project
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  *//*!
20  * \file
21  * \brief Texture filtering performance tests.
22  *//*--------------------------------------------------------------------*/
23 
24 #include "es2pTextureFilteringTests.hpp"
25 #include "es2pTextureCases.hpp"
26 #include "tcuMatrixUtil.hpp"
27 
28 #include "glwEnums.hpp"
29 
30 using std::string;
31 
32 namespace deqp
33 {
34 namespace gles2
35 {
36 namespace Performance
37 {
38 
TextureFilteringTests(Context & context)39 TextureFilteringTests::TextureFilteringTests(Context &context)
40     : TestCaseGroup(context, "filter", "Texture Filtering Performance Tests")
41 {
42 }
43 
~TextureFilteringTests(void)44 TextureFilteringTests::~TextureFilteringTests(void)
45 {
46 }
47 
init(void)48 void TextureFilteringTests::init(void)
49 {
50     static const struct
51     {
52         const char *name;
53         uint32_t format;
54         uint32_t dataType;
55     } texFormats[] = {{"rgb565", GL_RGB, GL_UNSIGNED_SHORT_5_6_5}, {"rgba8888", GL_RGBA, GL_UNSIGNED_BYTE}};
56     static const struct
57     {
58         const char *name;
59         uint32_t filter;
60         bool minify;
61     } cases[] = {{"nearest", GL_NEAREST, true},
62                  {"nearest", GL_NEAREST, false},
63                  {"linear", GL_LINEAR, true},
64                  {"linear", GL_LINEAR, false},
65                  {"nearest_mipmap_nearest", GL_NEAREST_MIPMAP_NEAREST, true},
66                  {"nearest_mipmap_linear", GL_NEAREST_MIPMAP_LINEAR, true},
67                  {"linear_mipmap_nearest", GL_LINEAR_MIPMAP_NEAREST, true},
68                  {"linear_mipmap_linear", GL_LINEAR_MIPMAP_LINEAR, true}};
69 
70     tcu::Mat3 minTransform = tcu::translationMatrix(tcu::Vec2(-0.3f, -0.6f)) * tcu::Mat3(tcu::Vec3(1.7f, 2.3f, 1.0f));
71     tcu::Mat3 magTransform = tcu::translationMatrix(tcu::Vec2(0.3f, 0.4f)) * tcu::Mat3(tcu::Vec3(0.3f, 0.2f, 1.0f));
72 
73     for (int caseNdx = 0; caseNdx < DE_LENGTH_OF_ARRAY(cases); caseNdx++)
74     {
75         for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(texFormats); formatNdx++)
76         {
77             uint32_t format    = texFormats[formatNdx].format;
78             uint32_t dataType  = texFormats[formatNdx].dataType;
79             uint32_t minFilter = cases[caseNdx].filter;
80             uint32_t magFilter = (minFilter == GL_NEAREST || minFilter == GL_LINEAR) ? minFilter : GL_LINEAR;
81             uint32_t wrapS     = GL_REPEAT;
82             uint32_t wrapT     = GL_REPEAT;
83             int numTextures    = 1;
84             bool minify        = cases[caseNdx].minify;
85             string name =
86                 string(cases[caseNdx].name) + (minify ? "_minify_" : "_magnify_") + texFormats[formatNdx].name;
87 
88             addChild(new Texture2DRenderCase(m_context, name.c_str(), "", format, dataType, wrapS, wrapT, minFilter,
89                                              magFilter, minify ? minTransform : magTransform, numTextures,
90                                              true /* pot */));
91         }
92     }
93 }
94 
95 } // namespace Performance
96 } // namespace gles2
97 } // namespace deqp
98