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

Side by Side Diff: cc/CCTextureUpdateController.cpp

Issue 10937007: cc: Only use upload throttling when performing full texture uploads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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/CCTextureUpdateControllerTest.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"
(...skipping 16 matching lines...) Expand all
27 27
28 } // anonymous namespace 28 } // anonymous namespace
29 29
30 namespace cc { 30 namespace cc {
31 31
32 size_t CCTextureUpdateController::maxPartialTextureUpdates() 32 size_t CCTextureUpdateController::maxPartialTextureUpdates()
33 { 33 {
34 return textureUpdatesPerTick; 34 return textureUpdatesPerTick;
35 } 35 }
36 36
37 void CCTextureUpdateController::updateTextures(CCResourceProvider* resourceProvi der, TextureCopier* copier, TextureUploader* uploader, CCTextureUpdateQueue* que ue, size_t count) 37 void CCTextureUpdateController::updateTextures(CCResourceProvider* resourceProvi der, TextureCopier* copier, TextureUploader* uploader, CCTextureUpdateQueue* que ue)
38 { 38 {
39 if (queue->fullUploadSize() || queue->partialUploadSize()) { 39 size_t uploadCount = 0;
40 if (uploader->isBusy()) 40 while (queue->fullUploadSize()) {
41 return; 41 if (!(uploadCount % textureUploadFlushPeriod) && uploadCount)
42
43 uploader->beginUploads();
44
45 size_t fullUploadCount = 0;
46 while (queue->fullUploadSize() && fullUploadCount < count) {
47 uploader->uploadTexture(resourceProvider, queue->takeFirstFullUpload ());
48 fullUploadCount++;
49 if (!(fullUploadCount % textureUploadFlushPeriod))
50 resourceProvider->shallowFlushIfSupported();
51 }
52
53 // Make sure there are no dangling uploads without a flush.
54 if (fullUploadCount % textureUploadFlushPeriod)
55 resourceProvider->shallowFlushIfSupported(); 42 resourceProvider->shallowFlushIfSupported();
56 43
57 bool moreUploads = queue->fullUploadSize(); 44 uploader->uploadTexture(
45 resourceProvider, queue->takeFirstFullUpload());
46 uploadCount++;
47 }
58 48
59 ASSERT(queue->partialUploadSize() <= count); 49 while (queue->partialUploadSize()) {
60 // We need another update batch if the number of updates remaining 50 if (!(uploadCount % textureUploadFlushPeriod) && uploadCount)
61 // in |count| is greater than the remaining partial entries.
62 if ((count - fullUploadCount) < queue->partialUploadSize())
63 moreUploads = true;
64
65 if (moreUploads) {
66 uploader->endUploads();
67 return;
68 }
69
70 size_t partialUploadCount = 0;
71 while (queue->partialUploadSize()) {
72 uploader->uploadTexture(resourceProvider, queue->takeFirstPartialUpl oad());
73 partialUploadCount++;
74 if (!(partialUploadCount % textureUploadFlushPeriod))
75 resourceProvider->shallowFlushIfSupported();
76 }
77
78 // Make sure there are no dangling partial uploads without a flush.
79 if (partialUploadCount % textureUploadFlushPeriod)
80 resourceProvider->shallowFlushIfSupported(); 51 resourceProvider->shallowFlushIfSupported();
81 52
82 uploader->endUploads(); 53 uploader->uploadTexture(
54 resourceProvider, queue->takeFirstPartialUpload());
55 uploadCount++;
83 } 56 }
84 57
85 size_t copyCount = 0; 58 if (uploadCount)
nduca 2012/09/18 06:03:58 I'm so confused, how do you even have incremental
reveman 2012/09/18 06:26:03 Incremental uploads are now done in CCTextureUpdat
86 while (queue->copySize()) { 59 resourceProvider->shallowFlushIfSupported();
87 copier->copyTexture(queue->takeFirstCopy()); 60
88 copyCount++; 61 if (queue->copySize()) {
62 while (queue->copySize())
63 copier->copyTexture(queue->takeFirstCopy());
64
65 // If we've performed any texture copies, we need to insert a flush
66 // here into the compositor context before letting the main thread
67 // proceed as it may make draw calls to the source texture of one of
68 // our copy operations.
69 copier->flush();
89 } 70 }
90
91 // If we've performed any texture copies, we need to insert a flush here int o the compositor context
92 // before letting the main thread proceed as it may make draw calls to the s ource texture of one of
93 // our copy operations.
94 if (copyCount)
95 copier->flush();
96 } 71 }
97 72
98 CCTextureUpdateController::CCTextureUpdateController(CCTextureUpdateControllerCl ient* client, CCThread* thread, PassOwnPtr<CCTextureUpdateQueue> queue, CCResour ceProvider* resourceProvider, TextureCopier* copier, TextureUploader* uploader) 73 CCTextureUpdateController::CCTextureUpdateController(CCTextureUpdateControllerCl ient* client, CCThread* thread, PassOwnPtr<CCTextureUpdateQueue> queue, CCResour ceProvider* resourceProvider, TextureCopier* copier, TextureUploader* uploader)
99 : m_client(client) 74 : m_client(client)
100 , m_timer(adoptPtr(new CCTimer(thread, this))) 75 , m_timer(adoptPtr(new CCTimer(thread, this)))
101 , m_queue(queue) 76 , m_queue(queue)
102 , m_resourceProvider(resourceProvider) 77 , m_resourceProvider(resourceProvider)
103 , m_copier(copier) 78 , m_copier(copier)
104 , m_uploader(uploader) 79 , m_uploader(uploader)
105 , m_monotonicTimeLimit(0) 80 , m_monotonicTimeLimit(0)
(...skipping 24 matching lines...) Expand all
130 if (!updateMoreTexturesIfEnoughTimeRemaining()) 105 if (!updateMoreTexturesIfEnoughTimeRemaining())
131 m_timer->startOneShot(0); 106 m_timer->startOneShot(0);
132 107
133 m_firstUpdateAttempt = false; 108 m_firstUpdateAttempt = false;
134 } else 109 } else
135 updateMoreTexturesNow(); 110 updateMoreTexturesNow();
136 } 111 }
137 112
138 void CCTextureUpdateController::finalize() 113 void CCTextureUpdateController::finalize()
139 { 114 {
140 while (m_queue->hasMoreUpdates()) 115 updateTextures(m_resourceProvider, m_copier, m_uploader, m_queue.get());
141 updateTextures(m_resourceProvider, m_copier, m_uploader, m_queue.get(),
142 updateMoreTexturesSize());
143 } 116 }
144 117
145 void CCTextureUpdateController::onTimerFired() 118 void CCTextureUpdateController::onTimerFired()
146 { 119 {
147 if (!updateMoreTexturesIfEnoughTimeRemaining()) 120 if (!updateMoreTexturesIfEnoughTimeRemaining())
148 m_client->readyToFinalizeTextureUpdates(); 121 m_client->readyToFinalizeTextureUpdates();
149 } 122 }
150 123
151 double CCTextureUpdateController::monotonicTimeNow() const 124 double CCTextureUpdateController::monotonicTimeNow() const
152 { 125 {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 } 178 }
206 179
207 // Make sure there are no dangling partial uploads without a flush. 180 // Make sure there are no dangling partial uploads without a flush.
208 if (uploadCount % textureUploadFlushPeriod) 181 if (uploadCount % textureUploadFlushPeriod)
209 m_resourceProvider->shallowFlushIfSupported(); 182 m_resourceProvider->shallowFlushIfSupported();
210 183
211 m_uploader->endUploads(); 184 m_uploader->endUploads();
212 } 185 }
213 186
214 } 187 }
OLDNEW
« no previous file with comments | « cc/CCTextureUpdateController.h ('k') | cc/CCTextureUpdateControllerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698