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

Side by Side Diff: cc/ThrottledTextureUploader.cpp

Issue 11008017: cc: Never block on uploads from previous frame and increase max pending uploads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename numPendingUploads to numBlockingUploads and discardPendingUploads to markPendingUploadsAsNon… Created 8 years, 2 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/ThrottledTextureUploader.h ('k') | cc/ThrottledTextureUploaderTest.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 #include "ThrottledTextureUploader.h" 6 #include "ThrottledTextureUploader.h"
7 7
8 #include "Extensions3DChromium.h" 8 #include "Extensions3DChromium.h"
9 #include <algorithm> 9 #include <algorithm>
10 #include <public/WebGraphicsContext3D.h> 10 #include <public/WebGraphicsContext3D.h>
(...skipping 12 matching lines...) Expand all
23 } // anonymous namespace 23 } // anonymous namespace
24 24
25 namespace cc { 25 namespace cc {
26 26
27 ThrottledTextureUploader::Query::Query(WebKit::WebGraphicsContext3D* context) 27 ThrottledTextureUploader::Query::Query(WebKit::WebGraphicsContext3D* context)
28 : m_context(context) 28 : m_context(context)
29 , m_queryId(0) 29 , m_queryId(0)
30 , m_value(0) 30 , m_value(0)
31 , m_hasValue(false) 31 , m_hasValue(false)
32 , m_texturesUploaded(0) 32 , m_texturesUploaded(0)
33 , m_isNonBlocking(false)
33 { 34 {
34 m_queryId = m_context->createQueryEXT(); 35 m_queryId = m_context->createQueryEXT();
35 } 36 }
36 37
37 ThrottledTextureUploader::Query::~Query() 38 ThrottledTextureUploader::Query::~Query()
38 { 39 {
39 m_context->deleteQueryEXT(m_queryId); 40 m_context->deleteQueryEXT(m_queryId);
40 } 41 }
41 42
42 void ThrottledTextureUploader::Query::begin() 43 void ThrottledTextureUploader::Query::begin()
43 { 44 {
44 m_hasValue = false; 45 m_hasValue = false;
46 m_isNonBlocking = false;
45 m_context->beginQueryEXT(Extensions3DChromium::COMMANDS_ISSUED_CHROMIUM, m_q ueryId); 47 m_context->beginQueryEXT(Extensions3DChromium::COMMANDS_ISSUED_CHROMIUM, m_q ueryId);
46 } 48 }
47 49
48 void ThrottledTextureUploader::Query::end(size_t texturesUploaded) 50 void ThrottledTextureUploader::Query::end(size_t texturesUploaded)
49 { 51 {
50 m_context->endQueryEXT(Extensions3DChromium::COMMANDS_ISSUED_CHROMIUM); 52 m_context->endQueryEXT(Extensions3DChromium::COMMANDS_ISSUED_CHROMIUM);
51 m_texturesUploaded = texturesUploaded; 53 m_texturesUploaded = texturesUploaded;
52 } 54 }
53 55
54 bool ThrottledTextureUploader::Query::isPending() 56 bool ThrottledTextureUploader::Query::isPending()
(...skipping 16 matching lines...) Expand all
71 m_hasValue = true; 73 m_hasValue = true;
72 } 74 }
73 return m_value; 75 return m_value;
74 } 76 }
75 77
76 size_t ThrottledTextureUploader::Query::texturesUploaded() 78 size_t ThrottledTextureUploader::Query::texturesUploaded()
77 { 79 {
78 return m_texturesUploaded; 80 return m_texturesUploaded;
79 } 81 }
80 82
83 void ThrottledTextureUploader::Query::markAsNonBlocking()
84 {
85 m_isNonBlocking = true;
86 }
87
88 bool ThrottledTextureUploader::Query::isNonBlocking()
89 {
90 return m_isNonBlocking;
91 }
92
81 ThrottledTextureUploader::ThrottledTextureUploader(WebKit::WebGraphicsContext3D* context) 93 ThrottledTextureUploader::ThrottledTextureUploader(WebKit::WebGraphicsContext3D* context)
82 : m_context(context) 94 : m_context(context)
83 , m_texturesPerSecondHistory(uploadHistorySize, estimatedTexturesPerSecondGl obal) 95 , m_texturesPerSecondHistory(uploadHistorySize, estimatedTexturesPerSecondGl obal)
84 , m_texturesUploaded(0) 96 , m_texturesUploaded(0)
85 , m_numPendingTextureUploads(0) 97 , m_numBlockingTextureUploads(0)
86 { 98 {
87 } 99 }
88 100
89 ThrottledTextureUploader::~ThrottledTextureUploader() 101 ThrottledTextureUploader::~ThrottledTextureUploader()
90 { 102 {
91 } 103 }
92 104
93 size_t ThrottledTextureUploader::numPendingUploads() 105 size_t ThrottledTextureUploader::numBlockingUploads()
94 { 106 {
95 processQueries(); 107 processQueries();
96 108
97 return m_numPendingTextureUploads; 109 return m_numBlockingTextureUploads;
110 }
111
112 void ThrottledTextureUploader::markPendingUploadsAsNonBlocking()
113 {
114 for (Deque<OwnPtr<Query> >::iterator it = m_pendingQueries.begin();
115 it != m_pendingQueries.end(); ++it) {
116 if (it->get()->isNonBlocking())
117 continue;
118
119 m_numBlockingTextureUploads -= it->get()->texturesUploaded();
120 it->get()->markAsNonBlocking();
121 }
122
123 ASSERT(!m_numBlockingTextureUploads);
98 } 124 }
99 125
100 double ThrottledTextureUploader::estimatedTexturesPerSecond() 126 double ThrottledTextureUploader::estimatedTexturesPerSecond()
101 { 127 {
102 processQueries(); 128 processQueries();
103 129
104 // The history should never be empty because we initialize all elements with an estimate. 130 // The history should never be empty because we initialize all elements with an estimate.
105 ASSERT(m_texturesPerSecondHistory.size() == uploadHistorySize); 131 ASSERT(m_texturesPerSecondHistory.size() == uploadHistorySize);
106 132
107 // Sort the history and use the median as our estimate. 133 // Sort the history and use the median as our estimate.
(...skipping 14 matching lines...) Expand all
122 if (m_availableQueries.isEmpty()) 148 if (m_availableQueries.isEmpty())
123 m_availableQueries.append(Query::create(m_context)); 149 m_availableQueries.append(Query::create(m_context));
124 150
125 m_availableQueries.first()->begin(); 151 m_availableQueries.first()->begin();
126 } 152 }
127 153
128 void ThrottledTextureUploader::endUploads() 154 void ThrottledTextureUploader::endUploads()
129 { 155 {
130 m_availableQueries.first()->end(m_texturesUploaded); 156 m_availableQueries.first()->end(m_texturesUploaded);
131 m_pendingQueries.append(m_availableQueries.takeFirst()); 157 m_pendingQueries.append(m_availableQueries.takeFirst());
132 m_numPendingTextureUploads += m_texturesUploaded; 158 m_numBlockingTextureUploads += m_texturesUploaded;
133 } 159 }
134 160
135 void ThrottledTextureUploader::uploadTexture(CCResourceProvider* resourceProvide r, Parameters upload) 161 void ThrottledTextureUploader::uploadTexture(CCResourceProvider* resourceProvide r, Parameters upload)
136 { 162 {
137 m_texturesUploaded++; 163 m_texturesUploaded++;
138 upload.texture->updateRect(resourceProvider, upload.sourceRect, upload.destO ffset); 164 upload.texture->updateRect(resourceProvider, upload.sourceRect, upload.destO ffset);
139 } 165 }
140 166
141 void ThrottledTextureUploader::processQueries() 167 void ThrottledTextureUploader::processQueries()
142 { 168 {
143 while (!m_pendingQueries.isEmpty()) { 169 while (!m_pendingQueries.isEmpty()) {
144 if (m_pendingQueries.first()->isPending()) 170 if (m_pendingQueries.first()->isPending())
145 break; 171 break;
146 172
147 unsigned usElapsed = m_pendingQueries.first()->value(); 173 unsigned usElapsed = m_pendingQueries.first()->value();
148 size_t texturesUploaded = m_pendingQueries.first()->texturesUploaded(); 174 size_t texturesUploaded = m_pendingQueries.first()->texturesUploaded();
149 double texturesPerSecond = static_cast<double>(texturesUploaded) / 175 double texturesPerSecond = static_cast<double>(texturesUploaded) /
150 (usElapsed * 1e-6); 176 (usElapsed * 1e-6);
151 177
178 if (!m_pendingQueries.first()->isNonBlocking())
179 m_numBlockingTextureUploads -= texturesUploaded;
180
152 // Remove the oldest values from our history and insert the new one 181 // Remove the oldest values from our history and insert the new one
153 m_texturesPerSecondHistory.pop_back(); 182 m_texturesPerSecondHistory.pop_back();
154 m_texturesPerSecondHistory.push_front(texturesPerSecond); 183 m_texturesPerSecondHistory.push_front(texturesPerSecond);
155 184
156 m_availableQueries.append(m_pendingQueries.takeFirst()); 185 m_availableQueries.append(m_pendingQueries.takeFirst());
157 m_numPendingTextureUploads -= texturesUploaded;
158 } 186 }
159 } 187 }
160 188
161 } 189 }
OLDNEW
« no previous file with comments | « cc/ThrottledTextureUploader.h ('k') | cc/ThrottledTextureUploaderTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698