Hash :
cb1ee485
Author :
Date :
2022-04-08T12:58:12
Vulkan: Add perf test for MSAA swapchain resolve
* Added a perf test for the swap time of the MSAA swapchain resolve
* Average wall time results on Pixel 6:
~ 296992 ns using the subpass
~3163355 ns with the subpass disabled
* Average wall time results on Pixel 6 Pro:
~ 225089 ns using the subpass
~2975449 ns with the subpass disabled
Bug: angleproject:6762
Change-Id: I95f8c4350c5da136afd7f1b28b8c00d6707574ef
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3586181
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Amirali Abdolrashidi <abdolrashidi@google.com>
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
//
// Copyright 2022 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.
//
// MultisampledSwapchainResolveBenchmark:
// Performance test for resolving multisample swapchains in subpass
//
#include "ANGLEPerfTest.h"
#include <iostream>
#include <random>
#include <sstream>
#include "test_utils/gl_raii.h"
#include "util/shader_utils.h"
using namespace angle;
namespace
{
struct MultisampledSwapchainResolveParams final : public RenderTestParams
{
MultisampledSwapchainResolveParams()
{
iterationsPerStep = 1;
windowWidth = 1920;
windowHeight = 1080;
multisample = true;
samples = 4;
}
std::string story() const override;
};
std::ostream &operator<<(std::ostream &os, const MultisampledSwapchainResolveParams ¶ms)
{
return os << params.backendAndStory().substr(1);
}
std::string MultisampledSwapchainResolveParams::story() const
{
std::stringstream strstr;
strstr << RenderTestParams::story();
return strstr.str();
}
class MultisampledSwapchainResolveBenchmark
: public ANGLERenderTest,
public ::testing::WithParamInterface<MultisampledSwapchainResolveParams>
{
public:
MultisampledSwapchainResolveBenchmark();
void initializeBenchmark() override;
void destroyBenchmark() override;
void drawBenchmark() override;
protected:
void initShaders();
GLuint mProgram = 0;
};
MultisampledSwapchainResolveBenchmark::MultisampledSwapchainResolveBenchmark()
: ANGLERenderTest("MultisampledSwapchainResolve", GetParam())
{}
void MultisampledSwapchainResolveBenchmark::initializeBenchmark()
{
initShaders();
glViewport(0, 0, getWindow()->getWidth(), getWindow()->getHeight());
ASSERT_GL_NO_ERROR();
}
void MultisampledSwapchainResolveBenchmark::initShaders()
{
constexpr char kVS[] = R"(void main()
{
gl_Position = vec4(0);
})";
constexpr char kFS[] = R"(void main(void)
{
gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
})";
mProgram = CompileProgram(kVS, kFS);
ASSERT_NE(0u, mProgram);
glUseProgram(mProgram);
ASSERT_GL_NO_ERROR();
}
void MultisampledSwapchainResolveBenchmark::destroyBenchmark()
{
glDeleteProgram(mProgram);
}
void MultisampledSwapchainResolveBenchmark::drawBenchmark()
{
// Initially clear the color attachment to avoid having to load from the resolved image.
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Perform a draw just to have something in the render pass. With the position attributes
// not set, a constant default value is used, resulting in a very cheap draw.
glDrawArrays(GL_TRIANGLES, 0, 3);
ASSERT_GL_NO_ERROR();
}
MultisampledSwapchainResolveParams VulkanParams()
{
MultisampledSwapchainResolveParams params;
params.eglParameters = egl_platform::VULKAN();
params.majorVersion = 3;
params.minorVersion = 0;
return params;
}
} // anonymous namespace
TEST_P(MultisampledSwapchainResolveBenchmark, Run)
{
run();
}
using namespace params;
ANGLE_INSTANTIATE_TEST(MultisampledSwapchainResolveBenchmark, VulkanParams());