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

Side by Side Diff: ui/gl/async_pixel_transfer_delegate_android.cc

Issue 12221161: gpu: Enable async uploads again. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adjust DCHECKs Created 7 years, 10 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 | « no previous file | no next file » | 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 "ui/gl/async_pixel_transfer_delegate_android.h" 5 #include "ui/gl/async_pixel_transfer_delegate_android.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 177
178 // Implement AsyncPixelTransferState: 178 // Implement AsyncPixelTransferState:
179 bool TransferIsInProgress() { 179 bool TransferIsInProgress() {
180 return transfer_in_progress_; 180 return transfer_in_progress_;
181 } 181 }
182 182
183 void BindTransfer(AsyncTexImage2DParams* bound_params) { 183 void BindTransfer(AsyncTexImage2DParams* bound_params) {
184 TRACE_EVENT2("gpu", "BindAsyncTransfer glEGLImageTargetTexture2DOES", 184 TRACE_EVENT2("gpu", "BindAsyncTransfer glEGLImageTargetTexture2DOES",
185 "width", late_bind_define_params_.width, 185 "width", late_bind_define_params_.width,
186 "height", late_bind_define_params_.height); 186 "height", late_bind_define_params_.height);
187
188 DCHECK(bound_params); 187 DCHECK(bound_params);
189 DCHECK(texture_id_); 188 DCHECK(texture_id_);
190 DCHECK_NE(EGL_NO_IMAGE_KHR, egl_image_);
191 *bound_params = late_bind_define_params_; 189 *bound_params = late_bind_define_params_;
192 if (!needs_late_bind_) 190 if (!needs_late_bind_)
193 return; 191 return;
192 DCHECK_NE(EGL_NO_IMAGE_KHR, egl_image_);
194 193
195 // We can only change the active texture and unit 0, 194 // We can only change the active texture and unit 0,
196 // as that is all that will be restored. 195 // as that is all that will be restored.
197 glActiveTexture(GL_TEXTURE0); 196 glActiveTexture(GL_TEXTURE0);
198 glBindTexture(GL_TEXTURE_2D, texture_id_); 197 glBindTexture(GL_TEXTURE_2D, texture_id_);
199 glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, egl_image_); 198 glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, egl_image_);
200 needs_late_bind_ = false; 199 needs_late_bind_ = false;
201 200
202 DCHECK(CHECK_GL()); 201 DCHECK(CHECK_GL());
203 } 202 }
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 const AsyncMemoryParams& mem_params); 377 const AsyncMemoryParams& mem_params);
379 378
380 int texture_upload_count_; 379 int texture_upload_count_;
381 base::TimeDelta total_texture_upload_time_; 380 base::TimeDelta total_texture_upload_time_;
382 bool is_imagination_; 381 bool is_imagination_;
383 bool is_qualcomm_; 382 bool is_qualcomm_;
384 383
385 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferDelegateAndroid); 384 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferDelegateAndroid);
386 }; 385 };
387 386
388 namespace {
389 // Imagination has some odd problems still.
390 bool IsImagination() {
391 std::string vendor;
392 vendor = reinterpret_cast<const char*>(glGetString(GL_VENDOR));
393 return vendor.find("Imagination") != std::string::npos;
394 }
395 }
396
397 // We only used threaded uploads when we can: 387 // We only used threaded uploads when we can:
398 // - Create EGLImages out of OpenGL textures (EGL_KHR_gl_texture_2D_image) 388 // - Create EGLImages out of OpenGL textures (EGL_KHR_gl_texture_2D_image)
399 // - Bind EGLImages to OpenGL textures (GL_OES_EGL_image) 389 // - Bind EGLImages to OpenGL textures (GL_OES_EGL_image)
400 // - Use fences (to test for upload completion). 390 // - Use fences (to test for upload completion).
401 scoped_ptr<AsyncPixelTransferDelegate> 391 scoped_ptr<AsyncPixelTransferDelegate>
402 AsyncPixelTransferDelegate::Create(gfx::GLContext* context) { 392 AsyncPixelTransferDelegate::Create(gfx::GLContext* context) {
403 DCHECK(context); 393 DCHECK(context);
404 if (context->HasExtension("EGL_KHR_fence_sync") && 394 if (context->HasExtension("EGL_KHR_fence_sync") &&
405 context->HasExtension("EGL_KHR_image") && 395 context->HasExtension("EGL_KHR_image") &&
406 context->HasExtension("EGL_KHR_image_base") && 396 context->HasExtension("EGL_KHR_image_base") &&
407 context->HasExtension("EGL_KHR_gl_texture_2D_image") && 397 context->HasExtension("EGL_KHR_gl_texture_2D_image") &&
408 context->HasExtension("GL_OES_EGL_image") && 398 context->HasExtension("GL_OES_EGL_image")) {
409 !IsImagination()) {
410 return make_scoped_ptr( 399 return make_scoped_ptr(
411 static_cast<AsyncPixelTransferDelegate*>( 400 static_cast<AsyncPixelTransferDelegate*>(
412 new AsyncPixelTransferDelegateAndroid())); 401 new AsyncPixelTransferDelegateAndroid()));
413 } else { 402 } else {
414 LOG(INFO) << "Async pixel transfers not supported"; 403 LOG(INFO) << "Async pixel transfers not supported";
415 return make_scoped_ptr( 404 return make_scoped_ptr(
416 static_cast<AsyncPixelTransferDelegate*>( 405 static_cast<AsyncPixelTransferDelegate*>(
417 new AsyncPixelTransferDelegateStub())); 406 new AsyncPixelTransferDelegateStub()));
418 } 407 }
419 } 408 }
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 const AsyncMemoryParams& mem_params) { 749 const AsyncMemoryParams& mem_params) {
761 if (!is_imagination_) 750 if (!is_imagination_)
762 return false; 751 return false;
763 752
764 // If the dimensions support fast async uploads, we can use the 753 // If the dimensions support fast async uploads, we can use the
765 // normal async upload path for uploads. 754 // normal async upload path for uploads.
766 if (DimensionsSupportImgFastPath(tex_params.width, tex_params.height)) 755 if (DimensionsSupportImgFastPath(tex_params.width, tex_params.height))
767 return false; 756 return false;
768 757
769 // Fall back on a synchronous stub as we don't have a known fast path. 758 // Fall back on a synchronous stub as we don't have a known fast path.
759 // Also, older ICS drivers crash when we do any glTexSubImage2D on the
760 // same thread. To work around this we do glTexImage2D instead. Since
761 // we didn't create an EGLImage for this texture (see above), this is
762 // okay, but it limits this API to full updates for now.
763 DCHECK(!state->egl_image_);
764 DCHECK_EQ(tex_params.xoffset, 0);
765 DCHECK_EQ(tex_params.yoffset, 0);
766 DCHECK_EQ(state->late_bind_define_params_.width, tex_params.width);
767 DCHECK_EQ(state->late_bind_define_params_.height, tex_params.height);
768 DCHECK_EQ(state->late_bind_define_params_.level, tex_params.level);
769 DCHECK_EQ(state->late_bind_define_params_.format, tex_params.format);
770 DCHECK_EQ(state->late_bind_define_params_.type, tex_params.type);
771
770 void* data = GetAddress(mem_params.shared_memory, 772 void* data = GetAddress(mem_params.shared_memory,
771 mem_params.shm_data_offset); 773 mem_params.shm_data_offset);
772 base::TimeTicks begin_time(base::TimeTicks::HighResNow()); 774 base::TimeTicks begin_time(base::TimeTicks::HighResNow());
773 { 775 {
774 TRACE_EVENT0("gpu", "glTexSubImage2D"); 776 TRACE_EVENT0("gpu", "glTexSubImage2D");
775 DoTexSubImage2D(tex_params, data); 777 // Note we use late_bind_define_params_ instead of tex_params.
778 // The DCHECKs above verify this is always the same.
779 DoTexImage2D(state->late_bind_define_params_, data);
776 } 780 }
777 texture_upload_count_++; 781 texture_upload_count_++;
778 total_texture_upload_time_ += base::TimeTicks::HighResNow() - begin_time; 782 total_texture_upload_time_ += base::TimeTicks::HighResNow() - begin_time;
779 783
780 DCHECK(CHECK_GL()); 784 DCHECK(CHECK_GL());
781 return true; 785 return true;
782 } 786 }
783 787
784 } // namespace gfx 788 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698