Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(936)

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 1835303002: Implementation of the GreenWeb language extensions. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change GreenWeb-related CSS property names such that they apply in the desired order at runtime. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gpu/DEPS ('k') | ipc/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
11 #include <iostream>
11 #include <list> 12 #include <list>
12 #include <map> 13 #include <map>
13 #include <queue> 14 #include <queue>
14 15
15 #include "base/callback.h" 16 #include "base/callback.h"
16 #include "base/callback_helpers.h" 17 #include "base/callback_helpers.h"
17 #include "base/command_line.h" 18 #include "base/command_line.h"
18 #include "base/logging.h" 19 #include "base/logging.h"
19 #include "base/memory/linked_ptr.h" 20 #include "base/memory/linked_ptr.h"
20 #include "base/memory/scoped_ptr.h" 21 #include "base/memory/scoped_ptr.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 #include "ui/gl/gl_surface.h" 70 #include "ui/gl/gl_surface.h"
70 #include "ui/gl/gl_version_info.h" 71 #include "ui/gl/gl_version_info.h"
71 #include "ui/gl/gpu_timing.h" 72 #include "ui/gl/gpu_timing.h"
72 73
73 #if defined(OS_MACOSX) 74 #if defined(OS_MACOSX)
74 #include <IOSurface/IOSurface.h> 75 #include <IOSurface/IOSurface.h>
75 // Note that this must be included after gl_bindings.h to avoid conflicts. 76 // Note that this must be included after gl_bindings.h to avoid conflicts.
76 #include <OpenGL/CGLIOSurface.h> 77 #include <OpenGL/CGLIOSurface.h>
77 #endif 78 #endif
78 79
80 #include "content/renderer/greenweb_latency_tracking.h"
81
79 namespace gpu { 82 namespace gpu {
80 namespace gles2 { 83 namespace gles2 {
81 84
82 namespace { 85 namespace {
83 86
84 const char kOESDerivativeExtension[] = "GL_OES_standard_derivatives"; 87 const char kOESDerivativeExtension[] = "GL_OES_standard_derivatives";
85 const char kEXTFragDepthExtension[] = "GL_EXT_frag_depth"; 88 const char kEXTFragDepthExtension[] = "GL_EXT_frag_depth";
86 const char kEXTDrawBuffersExtension[] = "GL_EXT_draw_buffers"; 89 const char kEXTDrawBuffersExtension[] = "GL_EXT_draw_buffers";
87 const char kEXTShaderTextureLodExtension[] = "GL_EXT_shader_texture_lod"; 90 const char kEXTShaderTextureLodExtension[] = "GL_EXT_shader_texture_lod";
88 91
(...skipping 11831 matching lines...) Expand 10 before | Expand all | Expand 10 after
11920 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glShaderBinary", "unknown shader"); 11923 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glShaderBinary", "unknown shader");
11921 return error::kNoError; 11924 return error::kNoError;
11922 } 11925 }
11923 service_ids[ii] = shader->service_id(); 11926 service_ids[ii] = shader->service_id();
11924 } 11927 }
11925 // TODO(gman): call glShaderBinary 11928 // TODO(gman): call glShaderBinary
11926 return error::kNoError; 11929 return error::kNoError;
11927 #endif 11930 #endif
11928 } 11931 }
11929 11932
11933 void set_freq(uint32 freq)
11934 {
11935 FILE *cpufreq = NULL;
11936
11937 if(!cpufreq)
11938 {
11939 cpufreq = fopen("/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed", "w" );
11940 if(!cpufreq)
11941 dbg_sched_fprintf(stdout, "[EBS] file open failed\n");
11942 }
11943
11944 if(cpufreq)
11945 {
11946 int bytes = fprintf(cpufreq, "%u", freq);
11947 if((bytes != 6) && (bytes != 7))
11948 dbg_sched_fprintf(stdout, "[EBS] cpufreq not set\n");
11949 fclose(cpufreq);
11950 }
11951 }
11952
11953 uint32 schedule(int64 latency, uint32 freq, int64 target) {
11954 uint32 next_freq;
11955 float target_f, latency_f;
11956 target_f = (float)target;
11957 latency_f = (float)latency;
11958
11959 if (latency_f > target_f * 0.9) {
11960 // Under predicting
11961 if (latency_f > target_f * 2)
11962 next_freq = 16;
11963 else {
11964 if(freq == 16) next_freq = 16;
11965 else if(freq == 6) next_freq = 8;
11966 else next_freq = freq + 1;
11967 }
11968 }
11969 else if (latency_f < target_f * 0.8) {
11970 // Over predicting
11971 if (target_f > latency_f * 2)
11972 next_freq = 4;
11973 else {
11974 if(freq == 4) next_freq = 4;
11975 else if(freq == 8) next_freq = 6;
11976 else next_freq = freq - 1;
11977 }
11978 }
11979 else {
11980 // Keep last prediction
11981 next_freq = freq;
11982 }
11983
11984 #ifdef EBS_DEBUG_TRACE_EVENT
11985 TRACE_EVENT2("gpu", "SetFrequency",
11986 "previous frame latency", latency,
11987 "freq", next_freq);
11988 #endif
11989
11990 return next_freq;
11991 }
11992
11930 void GLES2DecoderImpl::DoSwapBuffers() { 11993 void GLES2DecoderImpl::DoSwapBuffers() {
11994 static base::TimeTicks frame_ts;
11995 base::TimeTicks ts = base::TimeTicks::Now();
11996 base::TimeDelta frame_latency = ts - frame_ts;
11997 int64 frame_latency_in_ms = frame_latency.InMilliseconds();
11998 frame_ts = ts;
11999
12000 dbg_ipc_cout("GPU: g_ebs_enabled " << g_ebs_enabled <<
12001 ", g_qos_type " << g_qos_type <<
12002 ", g_qos_target" << g_qos_target);
12003 if (g_ebs_enabled && (g_qos_type == 'c')) {
12004 static uint32 last_freq;
12005
12006 uint32 next_freq = schedule(frame_latency_in_ms,
12007 last_freq,
12008 g_qos_target);
12009 set_freq(next_freq * 100000);
12010 last_freq = next_freq;
12011 dbg_sched_fprintf(stdout, "[EBS] set freq to %u last_latency %lld\n", next_f req, frame_latency_in_ms);
12012 }
12013 #ifdef EBS_DEBUG_OS
12014 else {
12015 fprintf(stdout, "[OS] last_latency %lld\n", frame_latency_in_ms);
12016 }
12017 #endif
12018 fflush(stdout);
12019
11931 bool is_offscreen = !!offscreen_target_frame_buffer_.get(); 12020 bool is_offscreen = !!offscreen_target_frame_buffer_.get();
11932 12021
11933 int this_frame_number = frame_number_++; 12022 int this_frame_number = frame_number_++;
11934 // TRACE_EVENT for gpu tests: 12023 // TRACE_EVENT for gpu tests:
11935 TRACE_EVENT_INSTANT2("test_gpu", "SwapBuffersLatency", 12024 TRACE_EVENT_INSTANT2("test_gpu", "SwapBuffersLatency",
11936 TRACE_EVENT_SCOPE_THREAD, 12025 TRACE_EVENT_SCOPE_THREAD,
11937 "GLImpl", static_cast<int>(gfx::GetGLImplementation()), 12026 "GLImpl", static_cast<int>(gfx::GetGLImplementation()),
11938 "width", (is_offscreen ? offscreen_size_.width() : 12027 "width", (is_offscreen ? offscreen_size_.width() :
11939 surface_->GetSize().width())); 12028 surface_->GetSize().width()));
11940 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoSwapBuffers", 12029 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoSwapBuffers",
(...skipping 3486 matching lines...) Expand 10 before | Expand all | Expand 10 after
15427 return error::kNoError; 15516 return error::kNoError;
15428 } 15517 }
15429 15518
15430 // Include the auto-generated part of this file. We split this because it means 15519 // Include the auto-generated part of this file. We split this because it means
15431 // we can easily edit the non-auto generated parts right here in this file 15520 // we can easily edit the non-auto generated parts right here in this file
15432 // instead of having to edit some template or the code generator. 15521 // instead of having to edit some template or the code generator.
15433 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 15522 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
15434 15523
15435 } // namespace gles2 15524 } // namespace gles2
15436 } // namespace gpu 15525 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/DEPS ('k') | ipc/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698