Commit 7a41151b authored by owenlin's avatar owenlin Committed by Commit bot

rendering_helper - Warm up the rendering.

The rendering for the first few frames is much slower (As much as
100ms on Peach Pit). To get stable/correct numbers in performance
tests, we try to warm it up by rendering several frames in the
beginning.

BUG=411123
TEST=Run the vda_unittest on Peach pit.

Review URL: https://codereview.chromium.org/583503002

Cr-Commit-Position: refs/heads/master@{#299861}
parent eb036181
......@@ -58,7 +58,9 @@ static void CreateShader(GLuint program,
namespace content {
RenderingHelperParams::RenderingHelperParams() {}
RenderingHelperParams::RenderingHelperParams()
: rendering_fps(0), warm_up_iterations(0), render_as_thumbnails(false) {
}
RenderingHelperParams::~RenderingHelperParams() {}
......@@ -302,9 +304,36 @@ void RenderingHelper::Initialize(const RenderingHelperParams& params,
glEnableVertexAttribArray(tc_location);
glVertexAttribPointer(tc_location, 2, GL_FLOAT, GL_FALSE, 0, kTextureCoords);
if (frame_duration_ != base::TimeDelta())
WarmUpRendering(params.warm_up_iterations);
done->Signal();
}
// The rendering for the first few frames is slow (e.g., 100ms on Peach Pit).
// This affects the numbers measured in the performance test. We try to render
// several frames here to warm up the rendering.
void RenderingHelper::WarmUpRendering(int warm_up_iterations) {
unsigned int texture_id;
scoped_ptr<GLubyte[]> emptyData(new GLubyte[screen_size_.GetArea() * 2]);
glGenTextures(1, &texture_id);
glBindTexture(GL_TEXTURE_2D, texture_id);
glTexImage2D(GL_TEXTURE_2D,
0,
GL_RGB,
screen_size_.width(),
screen_size_.height(),
0,
GL_RGB,
GL_UNSIGNED_SHORT_5_6_5,
emptyData.get());
for (int i = 0; i < warm_up_iterations; ++i) {
RenderTexture(GL_TEXTURE_2D, texture_id);
gl_surface_->SwapBuffers();
}
glDeleteTextures(1, &texture_id);
}
void RenderingHelper::UnInitialize(base::WaitableEvent* done) {
CHECK_EQ(base::MessageLoop::current(), message_loop_);
......
......@@ -52,6 +52,10 @@ struct RenderingHelperParams {
// The rendering FPS.
int rendering_fps;
// The number of empty frames rendered when the rendering helper is
// initialized.
int warm_up_iterations;
// The desired size of each window. We play each stream in its own window
// on the screen.
std::vector<gfx::Size> window_sizes;
......@@ -149,6 +153,8 @@ class RenderingHelper {
void RenderContent();
void WarmUpRendering(int warm_up_iterations);
void LayoutRenderingAreas(const std::vector<gfx::Size>& window_sizes);
// Render |texture_id| to the current view port of the screen using target
......
......@@ -101,6 +101,9 @@ const base::FilePath::CharType* g_output_log = NULL;
// The value is set by the switch "--rendering_fps".
double g_rendering_fps = 60;
// The value is set by the switch "--rendering_warm_up".
int g_rendering_warm_up = 0;
// Magic constants for differentiating the reasons for NotifyResetDone being
// called.
enum ResetPoint {
......@@ -1070,6 +1073,7 @@ TEST_P(VideoDecodeAcceleratorParamTest, TestSimpleDecode) {
RenderingHelperParams helper_params;
helper_params.rendering_fps = g_rendering_fps;
helper_params.warm_up_iterations = g_rendering_warm_up;
helper_params.render_as_thumbnails = render_as_thumbnails;
if (render_as_thumbnails) {
// Only one decoder is supported with thumbnail rendering
......@@ -1341,6 +1345,7 @@ TEST_F(VideoDecodeAcceleratorTest, TestDecodeTimeMedian) {
// Disable rendering by setting the rendering_fps = 0.
helper_params.rendering_fps = 0;
helper_params.warm_up_iterations = 0;
helper_params.render_as_thumbnails = false;
ClientStateNotification<ClientState>* note =
......@@ -1421,6 +1426,11 @@ int main(int argc, char **argv) {
CHECK(base::StringToDouble(input, &content::g_rendering_fps));
continue;
}
if (it->first == "rendering_warm_up") {
std::string input(it->second.begin(), it->second.end());
CHECK(base::StringToInt(input, &content::g_rendering_warm_up));
continue;
}
// TODO(owenlin): Remove this flag once it is not used in autotest.
if (it->first == "disable_rendering") {
content::g_rendering_fps = 0;
......
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