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

Side by Side Diff: gpu/command_buffer/client/gles2_implementation.cc

Issue 16831004: Perform glReadPixels with PBOs in the gpu, if PBOs are available. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use webglid where approperiate Created 7 years, 6 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
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 // A class to emulate GLES2 over command buffers. 5 // A class to emulate GLES2 over command buffers.
6 6
7 #include "gpu/command_buffer/client/gles2_implementation.h" 7 #include "gpu/command_buffer/client/gles2_implementation.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 2211 matching lines...) Expand 10 before | Expand all | Expand 10 after
2222 } 2222 }
2223 2223
2224 if (bound_pixel_pack_transfer_buffer_id_) { 2224 if (bound_pixel_pack_transfer_buffer_id_) {
2225 GLuint offset = ToGLuint(pixels); 2225 GLuint offset = ToGLuint(pixels);
2226 BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid( 2226 BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid(
2227 bound_pixel_pack_transfer_buffer_id_, 2227 bound_pixel_pack_transfer_buffer_id_,
2228 "glReadPixels", offset, padded_row_size * height); 2228 "glReadPixels", offset, padded_row_size * height);
2229 if (buffer && buffer->shm_id() != -1) { 2229 if (buffer && buffer->shm_id() != -1) {
2230 helper_->ReadPixels(xoffset, yoffset, width, height, format, type, 2230 helper_->ReadPixels(xoffset, yoffset, width, height, format, type,
2231 buffer->shm_id(), buffer->shm_offset(), 2231 buffer->shm_id(), buffer->shm_offset(),
2232 0, 0); 2232 0, 0, true);
2233 buffer->set_transfer_ready_token(helper_->InsertToken());
2234 CheckGLError(); 2233 CheckGLError();
2235 } 2234 }
2236 return; 2235 return;
2237 } 2236 }
2238 2237
2239 if (!pixels) { 2238 if (!pixels) {
2240 SetGLError(GL_INVALID_OPERATION, "glReadPixels", "pixels = NULL"); 2239 SetGLError(GL_INVALID_OPERATION, "glReadPixels", "pixels = NULL");
2241 return; 2240 return;
2242 } 2241 }
2243 2242
(...skipping 11 matching lines...) Expand all
2255 // NOTE: We must look up the address of the result area AFTER allocation 2254 // NOTE: We must look up the address of the result area AFTER allocation
2256 // of the transfer buffer since the transfer buffer may be reallocated. 2255 // of the transfer buffer since the transfer buffer may be reallocated.
2257 Result* result = GetResultAs<Result*>(); 2256 Result* result = GetResultAs<Result*>();
2258 if (!result) { 2257 if (!result) {
2259 return; 2258 return;
2260 } 2259 }
2261 *result = 0; // mark as failed. 2260 *result = 0; // mark as failed.
2262 helper_->ReadPixels( 2261 helper_->ReadPixels(
2263 xoffset, yoffset, width, num_rows, format, type, 2262 xoffset, yoffset, width, num_rows, format, type,
2264 buffer.shm_id(), buffer.offset(), 2263 buffer.shm_id(), buffer.offset(),
2265 GetResultShmId(), GetResultShmOffset()); 2264 GetResultShmId(), GetResultShmOffset(),
2265 false);
2266 WaitForCmd(); 2266 WaitForCmd();
2267 if (*result != 0) { 2267 if (*result != 0) {
2268 // when doing a y-flip we have to iterate through top-to-bottom chunks 2268 // when doing a y-flip we have to iterate through top-to-bottom chunks
2269 // of the dst. The service side handles reversing the rows within a 2269 // of the dst. The service side handles reversing the rows within a
2270 // chunk. 2270 // chunk.
2271 int8* rows_dst; 2271 int8* rows_dst;
2272 if (pack_reverse_row_order_) { 2272 if (pack_reverse_row_order_) {
2273 rows_dst = dest + (height - num_rows) * padded_row_size; 2273 rows_dst = dest + (height - num_rows) * padded_row_size;
2274 } else { 2274 } else {
2275 rows_dst = dest; 2275 rows_dst = dest;
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after
3167 "glDeleteTextures", "id not created by this context."); 3167 "glDeleteTextures", "id not created by this context.");
3168 return; 3168 return;
3169 } 3169 }
3170 // When you delete a query you can't mark its memory as unused until it's 3170 // When you delete a query you can't mark its memory as unused until it's
3171 // completed. 3171 // completed.
3172 // Note: If you don't do this you won't mess up the service but you will mess 3172 // Note: If you don't do this you won't mess up the service but you will mess
3173 // up yourself. 3173 // up yourself.
3174 3174
3175 // TODO(gman): Consider making this faster by putting pending quereies 3175 // TODO(gman): Consider making this faster by putting pending quereies
3176 // on some queue to be removed when they are finished. 3176 // on some queue to be removed when they are finished.
3177 // TODO(hubbe): Consider using signalQuery callback to delete pending
3178 // queries.
3177 bool query_pending = false; 3179 bool query_pending = false;
3178 for (GLsizei ii = 0; ii < n; ++ii) { 3180 for (GLsizei ii = 0; ii < n; ++ii) {
3179 QueryTracker::Query* query = query_tracker_->GetQuery(queries[ii]); 3181 QueryTracker::Query* query = query_tracker_->GetQuery(queries[ii]);
3180 if (query && query->Pending()) { 3182 if (query && !query->CheckResultsAvailable(helper_)) {
3181 query_pending = true; 3183 query_pending = true;
3182 break; 3184 break;
3183 } 3185 }
3184 } 3186 }
3185 3187
3186 if (query_pending) { 3188 if (query_pending) {
3189 helper_->Finish();
3187 WaitForCmd(); 3190 WaitForCmd();
3188 } 3191 }
3189 3192
3190 for (GLsizei ii = 0; ii < n; ++ii) { 3193 for (GLsizei ii = 0; ii < n; ++ii) {
3191 QueryTracker::Query* query = query_tracker_->GetQuery(queries[ii]); 3194 QueryTracker::Query* query = query_tracker_->GetQuery(queries[ii]);
3192 if (query && query->Pending()) { 3195 if (query && !query->CheckResultsAvailable(helper_)) {
3193 if (!query->CheckResultsAvailable(helper_)) { 3196 // Should only get here on context lost.
3194 // Should only get here on context lost. 3197 MustBeContextLost();
3195 MustBeContextLost();
3196 }
3197 } 3198 }
3198 query_tracker_->RemoveQuery(queries[ii], helper_->IsContextLost()); 3199 query_tracker_->RemoveQuery(queries[ii], helper_->IsContextLost());
3199 } 3200 }
3200 helper_->DeleteQueriesEXTImmediate(n, queries); 3201 helper_->DeleteQueriesEXTImmediate(n, queries);
3201 } 3202 }
3202 3203
3203 // TODO(gman): Remove this. Queries are not shared resources. 3204 // TODO(gman): Remove this. Queries are not shared resources.
3204 void GLES2Implementation::DeleteQueriesStub( 3205 void GLES2Implementation::DeleteQueriesStub(
3205 GLsizei /* n */, const GLuint* /* queries */) { 3206 GLsizei /* n */, const GLuint* /* queries */) {
3206 } 3207 }
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
3844 CheckGLError(); 3845 CheckGLError();
3845 } 3846 }
3846 3847
3847 // Include the auto-generated part of this file. We split this because it means 3848 // Include the auto-generated part of this file. We split this because it means
3848 // we can easily edit the non-auto generated parts right here in this file 3849 // we can easily edit the non-auto generated parts right here in this file
3849 // instead of having to edit some template or the code generator. 3850 // instead of having to edit some template or the code generator.
3850 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" 3851 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h"
3851 3852
3852 } // namespace gles2 3853 } // namespace gles2
3853 } // namespace gpu 3854 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698