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

Side by Side Diff: cc/CCTextureUpdateController.cpp

Issue 10917265: cc: Remove partial texture updates from scheduler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove using directive and add comment about uploader being busy Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « cc/CCTextureUpdateController.h ('k') | cc/CCThreadProxy.cpp » ('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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "config.h" 5 #include "config.h"
6 6
7 #include "CCTextureUpdateController.h" 7 #include "CCTextureUpdateController.h"
8 8
9 #include "GraphicsContext3D.h" 9 #include "GraphicsContext3D.h"
10 #include "TextureCopier.h" 10 #include "TextureCopier.h"
11 #include "TextureUploader.h" 11 #include "TextureUploader.h"
12 #include <wtf/CurrentTime.h> 12 #include <wtf/CurrentTime.h>
13 13
14 namespace { 14 namespace {
15 15
16 // Number of textures to update with each call to updateMoreTexturesIfEnoughTime Remaining(). 16 // Number of textures to update with each call to updateMoreTexturesIfEnoughTime Remaining().
17 static const size_t textureUpdatesPerTick = 12; 17 static const size_t textureUpdatesPerTick = 12;
18 18
19 // Measured in seconds. 19 // Measured in seconds.
20 static const double textureUpdateTickRate = 0.004; 20 static const double textureUpdateTickRate = 0.004;
21 21
22 // Measured in seconds.
23 static const double uploaderBusyTickRate = 0.001;
24
22 // Flush interval when performing texture uploads. 25 // Flush interval when performing texture uploads.
23 static const int textureUploadFlushPeriod = 4; 26 static const int textureUploadFlushPeriod = 4;
24 27
25 } // anonymous namespace 28 } // anonymous namespace
26 29
27 namespace cc { 30 namespace cc {
28 31
29 size_t CCTextureUpdateController::maxPartialTextureUpdates() 32 size_t CCTextureUpdateController::maxPartialTextureUpdates()
30 { 33 {
31 return textureUpdatesPerTick; 34 return textureUpdatesPerTick;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 // Post a 0-delay task when no updates were left. When it runs, 127 // Post a 0-delay task when no updates were left. When it runs,
125 // updateTexturesCompleted() will be called. 128 // updateTexturesCompleted() will be called.
126 if (!updateMoreTexturesIfEnoughTimeRemaining()) 129 if (!updateMoreTexturesIfEnoughTimeRemaining())
127 m_timer->startOneShot(0); 130 m_timer->startOneShot(0);
128 131
129 m_firstUpdateAttempt = false; 132 m_firstUpdateAttempt = false;
130 } else 133 } else
131 updateMoreTexturesNow(); 134 updateMoreTexturesNow();
132 } 135 }
133 136
137 void CCTextureUpdateController::updateAllTexturesNow()
138 {
139 while (m_queue->hasMoreUpdates())
140 updateTextures(m_resourceProvider, m_copier, m_uploader, m_queue.get(),
141 updateMoreTexturesSize());
142 }
143
134 void CCTextureUpdateController::onTimerFired() 144 void CCTextureUpdateController::onTimerFired()
135 { 145 {
136 if (!updateMoreTexturesIfEnoughTimeRemaining()) 146 if (!updateMoreTexturesIfEnoughTimeRemaining())
137 m_client->updateTexturesCompleted(); 147 m_client->updateTexturesCompleted();
138 } 148 }
139 149
140 double CCTextureUpdateController::monotonicTimeNow() const 150 double CCTextureUpdateController::monotonicTimeNow() const
141 { 151 {
142 return monotonicallyIncreasingTime(); 152 return monotonicallyIncreasingTime();
143 } 153 }
144 154
145 double CCTextureUpdateController::updateMoreTexturesTime() const 155 double CCTextureUpdateController::updateMoreTexturesTime() const
146 { 156 {
147 return textureUpdateTickRate; 157 return textureUpdateTickRate;
148 } 158 }
149 159
150 size_t CCTextureUpdateController::updateMoreTexturesSize() const 160 size_t CCTextureUpdateController::updateMoreTexturesSize() const
151 { 161 {
152 return textureUpdatesPerTick; 162 return textureUpdatesPerTick;
153 } 163 }
154 164
155 bool CCTextureUpdateController::updateMoreTexturesIfEnoughTimeRemaining() 165 bool CCTextureUpdateController::updateMoreTexturesIfEnoughTimeRemaining()
156 { 166 {
157 if (!m_queue->hasMoreUpdates()) 167 // Uploader might be busy when we're too aggressive in our upload time
168 // estimate. We use a different timeout here to prevent unnecessary
169 // amounts idle time.
170 if (m_uploader->isBusy()) {
171 m_timer->startOneShot(uploaderBusyTickRate);
172 return true;
173 }
174
175 if (!m_queue->fullUploadSize())
158 return false; 176 return false;
159 177
160 bool hasTimeRemaining = monotonicTimeNow() < m_monotonicTimeLimit - updateMo reTexturesTime(); 178 bool hasTimeRemaining = monotonicTimeNow() < m_monotonicTimeLimit - updateMo reTexturesTime();
161 if (hasTimeRemaining) 179 if (hasTimeRemaining)
162 updateMoreTexturesNow(); 180 updateMoreTexturesNow();
163 181
164 return true; 182 return true;
165 } 183 }
166 184
167 void CCTextureUpdateController::updateMoreTexturesNow() 185 void CCTextureUpdateController::updateMoreTexturesNow()
nduca 2012/09/17 18:26:15 I think you could make this whole patch a lot clea
168 { 186 {
169 m_timer->startOneShot(updateMoreTexturesTime()); 187 size_t uploads = std::min(
170 updateTextures(m_resourceProvider, m_copier, m_uploader, m_queue.get(), upda teMoreTexturesSize()); 188 m_queue->fullUploadSize(), updateMoreTexturesSize());
189 m_timer->startOneShot(
190 updateMoreTexturesTime() / updateMoreTexturesSize() * uploads);
191
192 if (!uploads)
193 return;
194
195 m_uploader->beginUploads();
196
197 size_t uploadCount = 0;
198 while (uploads--) {
199 m_uploader->uploadTexture(
200 m_resourceProvider, m_queue->takeFirstFullUpload());
201 uploadCount++;
202 if (!(uploadCount % textureUploadFlushPeriod))
203 m_resourceProvider->shallowFlushIfSupported();
204 }
205
206 // Make sure there are no dangling partial uploads without a flush.
207 if (uploadCount % textureUploadFlushPeriod)
208 m_resourceProvider->shallowFlushIfSupported();
209
210 m_uploader->endUploads();
171 } 211 }
172 212
173 } 213 }
OLDNEW
« no previous file with comments | « cc/CCTextureUpdateController.h ('k') | cc/CCThreadProxy.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698