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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.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 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <list> 10 #include <list>
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 #include "gpu/command_buffer/service/renderbuffer_manager.h" 52 #include "gpu/command_buffer/service/renderbuffer_manager.h"
53 #include "gpu/command_buffer/service/shader_manager.h" 53 #include "gpu/command_buffer/service/shader_manager.h"
54 #include "gpu/command_buffer/service/shader_translator.h" 54 #include "gpu/command_buffer/service/shader_translator.h"
55 #include "gpu/command_buffer/service/shader_translator_cache.h" 55 #include "gpu/command_buffer/service/shader_translator_cache.h"
56 #include "gpu/command_buffer/service/stream_texture.h" 56 #include "gpu/command_buffer/service/stream_texture.h"
57 #include "gpu/command_buffer/service/stream_texture_manager.h" 57 #include "gpu/command_buffer/service/stream_texture_manager.h"
58 #include "gpu/command_buffer/service/texture_manager.h" 58 #include "gpu/command_buffer/service/texture_manager.h"
59 #include "gpu/command_buffer/service/vertex_array_manager.h" 59 #include "gpu/command_buffer/service/vertex_array_manager.h"
60 #include "gpu/command_buffer/service/vertex_attrib_manager.h" 60 #include "gpu/command_buffer/service/vertex_attrib_manager.h"
61 #include "ui/gl/gl_bindings.h" 61 #include "ui/gl/gl_bindings.h"
62 #include "ui/gl/gl_fence.h"
62 #include "ui/gl/gl_image.h" 63 #include "ui/gl/gl_image.h"
63 #include "ui/gl/gl_implementation.h" 64 #include "ui/gl/gl_implementation.h"
64 #include "ui/gl/gl_surface.h" 65 #include "ui/gl/gl_surface.h"
65 #if defined(OS_MACOSX) 66 #if defined(OS_MACOSX)
66 #include "ui/surface/io_surface_support_mac.h" 67 #include "ui/surface/io_surface_support_mac.h"
67 #endif 68 #endif
68 69
69 // TODO(zmo): we can't include "City.h" due to type def conflicts. 70 // TODO(zmo): we can't include "City.h" due to type def conflicts.
70 extern uint64 CityHash64(const char*, size_t); 71 extern uint64 CityHash64(const char*, size_t);
71 72
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 GLuint id() const { 470 GLuint id() const {
470 return id_; 471 return id_;
471 } 472 }
472 473
473 private: 474 private:
474 GLES2DecoderImpl* decoder_; 475 GLES2DecoderImpl* decoder_;
475 GLuint id_; 476 GLuint id_;
476 DISALLOW_COPY_AND_ASSIGN(BackFramebuffer); 477 DISALLOW_COPY_AND_ASSIGN(BackFramebuffer);
477 }; 478 };
478 479
480 struct FenceCallback {
481 explicit FenceCallback(base::Closure callback_)
482 : callback(callback_),
483 fence(gfx::GLFence::Create()) {
484 DCHECK(fence);
485 }
486 base::Closure callback;
487 scoped_ptr<gfx::GLFence> fence;
488 };
489
490
479 // } // anonymous namespace. 491 // } // anonymous namespace.
480 492
481 bool GLES2Decoder::GetServiceTextureId(uint32 client_texture_id, 493 bool GLES2Decoder::GetServiceTextureId(uint32 client_texture_id,
482 uint32* service_texture_id) { 494 uint32* service_texture_id) {
483 return false; 495 return false;
484 } 496 }
485 497
486 GLES2Decoder::GLES2Decoder() 498 GLES2Decoder::GLES2Decoder()
487 : initialized_(false), 499 : initialized_(false),
488 debug_(false), 500 debug_(false),
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 virtual QueryManager* GetQueryManager() OVERRIDE { 591 virtual QueryManager* GetQueryManager() OVERRIDE {
580 return query_manager_.get(); 592 return query_manager_.get();
581 } 593 }
582 virtual VertexArrayManager* GetVertexArrayManager() OVERRIDE { 594 virtual VertexArrayManager* GetVertexArrayManager() OVERRIDE {
583 return vertex_array_manager_.get(); 595 return vertex_array_manager_.get();
584 } 596 }
585 virtual bool ProcessPendingQueries() OVERRIDE; 597 virtual bool ProcessPendingQueries() OVERRIDE;
586 virtual bool HasMoreIdleWork() OVERRIDE; 598 virtual bool HasMoreIdleWork() OVERRIDE;
587 virtual void PerformIdleWork() OVERRIDE; 599 virtual void PerformIdleWork() OVERRIDE;
588 600
601 virtual void WaitForReadPixels(base::Closure callback) OVERRIDE;
602
589 virtual void SetResizeCallback( 603 virtual void SetResizeCallback(
590 const base::Callback<void(gfx::Size, float)>& callback) OVERRIDE; 604 const base::Callback<void(gfx::Size, float)>& callback) OVERRIDE;
591 605
592 virtual Logger* GetLogger() OVERRIDE; 606 virtual Logger* GetLogger() OVERRIDE;
593 virtual ErrorState* GetErrorState() OVERRIDE; 607 virtual ErrorState* GetErrorState() OVERRIDE;
594 608
595 virtual void SetShaderCacheCallback( 609 virtual void SetShaderCacheCallback(
596 const ShaderCacheCallback& callback) OVERRIDE; 610 const ShaderCacheCallback& callback) OVERRIDE;
597 virtual void SetWaitSyncPointCallback( 611 virtual void SetWaitSyncPointCallback(
598 const WaitSyncPointCallback& callback) OVERRIDE; 612 const WaitSyncPointCallback& callback) OVERRIDE;
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after
1547 state_.bound_draw_framebuffer.get() == NULL && 1561 state_.bound_draw_framebuffer.get() == NULL &&
1548 surface_->DeferDraws(); 1562 surface_->DeferDraws();
1549 } 1563 }
1550 1564
1551 bool ShouldDeferReads() { 1565 bool ShouldDeferReads() {
1552 return !offscreen_target_frame_buffer_.get() && 1566 return !offscreen_target_frame_buffer_.get() &&
1553 state_.bound_read_framebuffer.get() == NULL && 1567 state_.bound_read_framebuffer.get() == NULL &&
1554 surface_->DeferDraws(); 1568 surface_->DeferDraws();
1555 } 1569 }
1556 1570
1571 void ProcessPendingReadPixels();
1572 void FinishReadPixels(const cmds::ReadPixels& c, GLuint buffer);
1573
1557 void ForceCompileShaderIfPending(Shader* shader); 1574 void ForceCompileShaderIfPending(Shader* shader);
1558 1575
1559 // Generate a member function prototype for each command in an automated and 1576 // Generate a member function prototype for each command in an automated and
1560 // typesafe way. 1577 // typesafe way.
1561 #define GLES2_CMD_OP(name) \ 1578 #define GLES2_CMD_OP(name) \
1562 Error Handle ## name( \ 1579 Error Handle ## name( \
1563 uint32 immediate_data_size, \ 1580 uint32 immediate_data_size, \
1564 const cmds::name& args); \ 1581 const cmds::name& args); \
1565 1582
1566 GLES2_COMMAND_LIST(GLES2_CMD_OP) 1583 GLES2_COMMAND_LIST(GLES2_CMD_OP)
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1715 GLsizei viewport_max_width_; 1732 GLsizei viewport_max_width_;
1716 GLsizei viewport_max_height_; 1733 GLsizei viewport_max_height_;
1717 1734
1718 // Command buffer stats. 1735 // Command buffer stats.
1719 int texture_upload_count_; 1736 int texture_upload_count_;
1720 base::TimeDelta total_texture_upload_time_; 1737 base::TimeDelta total_texture_upload_time_;
1721 base::TimeDelta total_processing_commands_time_; 1738 base::TimeDelta total_processing_commands_time_;
1722 1739
1723 scoped_ptr<GPUTracer> gpu_tracer_; 1740 scoped_ptr<GPUTracer> gpu_tracer_;
1724 1741
1742 std::queue<linked_ptr<FenceCallback> > pending_fences_;
1743
1725 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); 1744 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl);
1726 }; 1745 };
1727 1746
1728 ScopedGLErrorSuppressor::ScopedGLErrorSuppressor( 1747 ScopedGLErrorSuppressor::ScopedGLErrorSuppressor(
1729 const char* function_name, GLES2DecoderImpl* decoder) 1748 const char* function_name, GLES2DecoderImpl* decoder)
1730 : function_name_(function_name), 1749 : function_name_(function_name),
1731 decoder_(decoder) { 1750 decoder_(decoder) {
1732 ERRORSTATE_COPY_REAL_GL_ERRORS_TO_WRAPPER(decoder_->GetErrorState(), 1751 ERRORSTATE_COPY_REAL_GL_ERRORS_TO_WRAPPER(decoder_->GetErrorState(),
1733 function_name_); 1752 function_name_);
1734 } 1753 }
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after
2489 // that can be safely migrated between the iGPU and the dGPU. Mark 2508 // that can be safely migrated between the iGPU and the dGPU. Mark
2490 // those contexts as safe to forcibly transition between the GPUs. 2509 // those contexts as safe to forcibly transition between the GPUs.
2491 // http://crbug.com/180876, http://crbug.com/227228 2510 // http://crbug.com/180876, http://crbug.com/227228
2492 if (!offscreen) 2511 if (!offscreen)
2493 context_->SetSafeToForceGpuSwitch(); 2512 context_->SetSafeToForceGpuSwitch();
2494 2513
2495 async_pixel_transfer_manager_.reset( 2514 async_pixel_transfer_manager_.reset(
2496 AsyncPixelTransferManager::Create(context.get())); 2515 AsyncPixelTransferManager::Create(context.get()));
2497 async_pixel_transfer_manager_->Initialize(texture_manager()); 2516 async_pixel_transfer_manager_->Initialize(texture_manager());
2498 2517
2518
2499 return true; 2519 return true;
2500 } 2520 }
2501 2521
2502 void GLES2DecoderImpl::UpdateCapabilities() { 2522 void GLES2DecoderImpl::UpdateCapabilities() {
2503 util_.set_num_compressed_texture_formats( 2523 util_.set_num_compressed_texture_formats(
2504 validators_->compressed_texture_format.GetValues().size()); 2524 validators_->compressed_texture_format.GetValues().size());
2505 util_.set_num_shader_binary_formats( 2525 util_.set_num_shader_binary_formats(
2506 validators_->shader_binary_format.GetValues().size()); 2526 validators_->shader_binary_format.GetValues().size());
2507 } 2527 }
2508 2528
(...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after
3530 } 3550 }
3531 GLuint service_id = glCreateShader(type); 3551 GLuint service_id = glCreateShader(type);
3532 if (service_id != 0) { 3552 if (service_id != 0) {
3533 CreateShader(client_id, service_id, type); 3553 CreateShader(client_id, service_id, type);
3534 } 3554 }
3535 return true; 3555 return true;
3536 } 3556 }
3537 3557
3538 void GLES2DecoderImpl::DoFinish() { 3558 void GLES2DecoderImpl::DoFinish() {
3539 glFinish(); 3559 glFinish();
3560 ProcessPendingReadPixels();
3540 ProcessPendingQueries(); 3561 ProcessPendingQueries();
3541 } 3562 }
3542 3563
3543 void GLES2DecoderImpl::DoFlush() { 3564 void GLES2DecoderImpl::DoFlush() {
3544 glFlush(); 3565 glFlush();
3545 ProcessPendingQueries(); 3566 ProcessPendingQueries();
3546 } 3567 }
3547 3568
3548 void GLES2DecoderImpl::DoActiveTexture(GLenum texture_unit) { 3569 void GLES2DecoderImpl::DoActiveTexture(GLenum texture_unit) {
3549 GLuint texture_index = texture_unit - GL_TEXTURE0; 3570 GLuint texture_index = texture_unit - GL_TEXTURE0;
(...skipping 3142 matching lines...) Expand 10 before | Expand all | Expand 10 after
6692 return error::kNoError; 6713 return error::kNoError;
6693 } 6714 }
6694 6715
6695 state_.vertex_attrib_manager->SetDivisor( 6716 state_.vertex_attrib_manager->SetDivisor(
6696 index, 6717 index,
6697 divisor); 6718 divisor);
6698 glVertexAttribDivisorANGLE(index, divisor); 6719 glVertexAttribDivisorANGLE(index, divisor);
6699 return error::kNoError; 6720 return error::kNoError;
6700 } 6721 }
6701 6722
6723 void GLES2DecoderImpl::FinishReadPixels(
6724 const cmds::ReadPixels& c,
6725 GLuint buffer) {
6726 TRACE_EVENT0("gpu", "GLES2DecoderImpl::FinishReadPixels");
6727 GLsizei width = c.width;
6728 GLsizei height = c.height;
6729 GLenum format = c.format;
6730 GLenum type = c.type;
6731 typedef cmds::ReadPixels::Result Result;
6732 uint32 pixels_size;
6733 GLES2Util::ComputeImageDataSizes(
6734 width, height, format, type, state_.pack_alignment, &pixels_size,
6735 NULL, NULL);
6736 void* pixels = GetSharedMemoryAs<void*>(
6737 c.pixels_shm_id, c.pixels_shm_offset, pixels_size);
6738 if (!pixels) {
6739 if (buffer != 0) {
6740 glDeleteBuffersARB(1, &buffer);
6741 return;
6742 }
6743 }
6744
6745 if (buffer != 0) {
6746 glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, buffer);
6747 void* data = glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY);
6748 memcpy(pixels, data, pixels_size);
6749 // GL_PIXEL_PACK_BUFFER_ARB is currently unused, so we don't
6750 // have to restore the state.
6751 glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB);
6752 glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0);
6753 glDeleteBuffersARB(1, &buffer);
6754 }
6755 Result* result = NULL;
6756 if (c.result_shm_id != 0) {
6757 result = GetSharedMemoryAs<Result*>(
6758 c.result_shm_id, c.result_shm_offset, sizeof(*result));
6759 if (!result) {
6760 // No way to mark failure.
6761 return;
6762 }
6763 }
6764
6765 if (result != NULL) {
6766 *result = true;
6767 }
6768
6769 GLenum read_format = GetBoundReadFrameBufferInternalFormat();
6770 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format);
6771 if ((channels_exist & 0x0008) == 0 &&
6772 workarounds().clear_alpha_in_readpixels) {
6773 // Set the alpha to 255 because some drivers are buggy in this regard.
6774 uint32 temp_size;
6775
6776 uint32 unpadded_row_size;
6777 uint32 padded_row_size;
6778 if (!GLES2Util::ComputeImageDataSizes(
6779 width, 2, format, type, state_.pack_alignment, &temp_size,
6780 &unpadded_row_size, &padded_row_size)) {
6781 return;
6782 }
6783 // NOTE: Assumes the type is GL_UNSIGNED_BYTE which was true at the time
6784 // of this implementation.
6785 if (type != GL_UNSIGNED_BYTE) {
6786 return;
6787 }
6788 switch (format) {
6789 case GL_RGBA:
6790 case GL_BGRA_EXT:
6791 case GL_ALPHA: {
6792 int offset = (format == GL_ALPHA) ? 0 : 3;
6793 int step = (format == GL_ALPHA) ? 1 : 4;
6794 uint8* dst = static_cast<uint8*>(pixels) + offset;
6795 for (GLint yy = 0; yy < height; ++yy) {
6796 uint8* end = dst + unpadded_row_size;
6797 for (uint8* d = dst; d < end; d += step) {
6798 *d = 255;
6799 }
6800 dst += padded_row_size;
6801 }
6802 break;
6803 }
6804 default:
6805 break;
6806 }
6807 }
6808 }
6809
6810
6702 error::Error GLES2DecoderImpl::HandleReadPixels( 6811 error::Error GLES2DecoderImpl::HandleReadPixels(
6703 uint32 immediate_data_size, const cmds::ReadPixels& c) { 6812 uint32 immediate_data_size, const cmds::ReadPixels& c) {
6704 if (ShouldDeferReads()) 6813 if (ShouldDeferReads())
6705 return error::kDeferCommandUntilLater; 6814 return error::kDeferCommandUntilLater;
6706 GLint x = c.x; 6815 GLint x = c.x;
6707 GLint y = c.y; 6816 GLint y = c.y;
6708 GLsizei width = c.width; 6817 GLsizei width = c.width;
6709 GLsizei height = c.height; 6818 GLsizei height = c.height;
6710 GLenum format = c.format; 6819 GLenum format = c.format;
6711 GLenum type = c.type; 6820 GLenum type = c.type;
6821 GLboolean async = c.async;
6712 if (width < 0 || height < 0) { 6822 if (width < 0 || height < 0) {
6713 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glReadPixels", "dimensions < 0"); 6823 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glReadPixels", "dimensions < 0");
6714 return error::kNoError; 6824 return error::kNoError;
6715 } 6825 }
6716 typedef cmds::ReadPixels::Result Result; 6826 typedef cmds::ReadPixels::Result Result;
6717 uint32 pixels_size; 6827 uint32 pixels_size;
6718 if (!GLES2Util::ComputeImageDataSizes( 6828 if (!GLES2Util::ComputeImageDataSizes(
6719 width, height, format, type, state_.pack_alignment, &pixels_size, 6829 width, height, format, type, state_.pack_alignment, &pixels_size,
6720 NULL, NULL)) { 6830 NULL, NULL)) {
6721 return error::kOutOfBounds; 6831 return error::kOutOfBounds;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
6801 memset(dst, 0, unpadded_row_size); 6911 memset(dst, 0, unpadded_row_size);
6802 6912
6803 // If the row is in range, copy it. 6913 // If the row is in range, copy it.
6804 if (ry >= 0 && ry < max_size.height() && read_width > 0) { 6914 if (ry >= 0 && ry < max_size.height() && read_width > 0) {
6805 glReadPixels( 6915 glReadPixels(
6806 read_x, ry, read_width, 1, format, type, dst + dest_row_offset); 6916 read_x, ry, read_width, 1, format, type, dst + dest_row_offset);
6807 } 6917 }
6808 dst += padded_row_size; 6918 dst += padded_row_size;
6809 } 6919 }
6810 } else { 6920 } else {
6921 if (async && features().use_async_readpixels) {
6922 GLuint buffer;
6923 glGenBuffersARB(1, &buffer);
6924 glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, buffer);
6925 glBufferData(GL_PIXEL_PACK_BUFFER_ARB, pixels_size, NULL, GL_STREAM_READ);
6926 GLenum error = glGetError();
6927 if (error == GL_NO_ERROR) {
6928 glReadPixels(x, y, width, height, format, type, 0);
6929 WaitForReadPixels(base::Bind(
6930 &GLES2DecoderImpl::FinishReadPixels,
6931 base::internal::SupportsWeakPtrBase::StaticAsWeakPtr
6932 <GLES2DecoderImpl>(this),
6933 c, buffer));
6934 glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0);
6935 return error::kNoError;
6936 }
6937 }
6811 glReadPixels(x, y, width, height, format, type, pixels); 6938 glReadPixels(x, y, width, height, format, type, pixels);
6812 } 6939 }
6813 GLenum error = LOCAL_PEEK_GL_ERROR("glReadPixels"); 6940 GLenum error = LOCAL_PEEK_GL_ERROR("glReadPixels");
6814 if (error == GL_NO_ERROR) { 6941 if (error == GL_NO_ERROR) {
6815 if (result != NULL) { 6942 if (result != NULL) {
6816 *result = true; 6943 *result = true;
6817 } 6944 }
6818 6945 FinishReadPixels(c, 0);
6819 GLenum read_format = GetBoundReadFrameBufferInternalFormat();
6820 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format);
6821 if ((channels_exist & 0x0008) == 0 &&
6822 workarounds().clear_alpha_in_readpixels) {
6823 // Set the alpha to 255 because some drivers are buggy in this regard.
6824 uint32 temp_size;
6825
6826 uint32 unpadded_row_size;
6827 uint32 padded_row_size;
6828 if (!GLES2Util::ComputeImageDataSizes(
6829 width, 2, format, type, state_.pack_alignment, &temp_size,
6830 &unpadded_row_size, &padded_row_size)) {
6831 LOCAL_SET_GL_ERROR(
6832 GL_INVALID_VALUE, "glReadPixels", "dimensions out of range");
6833 return error::kNoError;
6834 }
6835 // NOTE: Assumes the type is GL_UNSIGNED_BYTE which was true at the time
6836 // of this implementation.
6837 if (type != GL_UNSIGNED_BYTE) {
6838 LOCAL_SET_GL_ERROR(
6839 GL_INVALID_OPERATION, "glReadPixels",
6840 "unsupported readPixel format");
6841 return error::kNoError;
6842 }
6843 switch (format) {
6844 case GL_RGBA:
6845 case GL_BGRA_EXT:
6846 case GL_ALPHA: {
6847 int offset = (format == GL_ALPHA) ? 0 : 3;
6848 int step = (format == GL_ALPHA) ? 1 : 4;
6849 uint8* dst = static_cast<uint8*>(pixels) + offset;
6850 for (GLint yy = 0; yy < height; ++yy) {
6851 uint8* end = dst + unpadded_row_size;
6852 for (uint8* d = dst; d < end; d += step) {
6853 *d = 255;
6854 }
6855 dst += padded_row_size;
6856 }
6857 break;
6858 }
6859 default:
6860 break;
6861 }
6862 }
6863 } 6946 }
6864 6947
6865 return error::kNoError; 6948 return error::kNoError;
6866 } 6949 }
6867 6950
6868 error::Error GLES2DecoderImpl::HandlePixelStorei( 6951 error::Error GLES2DecoderImpl::HandlePixelStorei(
6869 uint32 immediate_data_size, const cmds::PixelStorei& c) { 6952 uint32 immediate_data_size, const cmds::PixelStorei& c) {
6870 GLenum pname = c.pname; 6953 GLenum pname = c.pname;
6871 GLenum param = c.param; 6954 GLenum param = c.param;
6872 if (!validators_->pixel_store.IsValid(pname)) { 6955 if (!validators_->pixel_store.IsValid(pname)) {
(...skipping 2209 matching lines...) Expand 10 before | Expand all | Expand 10 after
9082 bool GLES2DecoderImpl::ProcessPendingQueries() { 9165 bool GLES2DecoderImpl::ProcessPendingQueries() {
9083 if (query_manager_.get() == NULL) { 9166 if (query_manager_.get() == NULL) {
9084 return false; 9167 return false;
9085 } 9168 }
9086 if (!query_manager_->ProcessPendingQueries()) { 9169 if (!query_manager_->ProcessPendingQueries()) {
9087 current_decoder_error_ = error::kOutOfBounds; 9170 current_decoder_error_ = error::kOutOfBounds;
9088 } 9171 }
9089 return query_manager_->HavePendingQueries(); 9172 return query_manager_->HavePendingQueries();
9090 } 9173 }
9091 9174
9175 void GLES2DecoderImpl::WaitForReadPixels(base::Closure callback) {
9176 if (features().use_async_readpixels) {
9177 pending_fences_.push(linked_ptr<FenceCallback>(
9178 new FenceCallback(callback)));
9179 } else {
9180 callback.Run();
9181 }
9182 }
9183
9184 void GLES2DecoderImpl::ProcessPendingReadPixels() {
9185 while (!pending_fences_.empty() &&
9186 pending_fences_.front()->fence->HasCompleted()) {
9187 pending_fences_.front()->callback.Run();
9188 pending_fences_.pop();
9189 }
9190 }
9191
9092 bool GLES2DecoderImpl::HasMoreIdleWork() { 9192 bool GLES2DecoderImpl::HasMoreIdleWork() {
9093 return async_pixel_transfer_manager_->NeedsProcessMorePendingTransfers(); 9193 return !pending_fences_.empty() ||
9194 async_pixel_transfer_manager_->NeedsProcessMorePendingTransfers();
9094 } 9195 }
9095 9196
9096 void GLES2DecoderImpl::PerformIdleWork() { 9197 void GLES2DecoderImpl::PerformIdleWork() {
9198 ProcessPendingReadPixels();
9097 if (!async_pixel_transfer_manager_->NeedsProcessMorePendingTransfers()) 9199 if (!async_pixel_transfer_manager_->NeedsProcessMorePendingTransfers())
9098 return; 9200 return;
9099 async_pixel_transfer_manager_->ProcessMorePendingTransfers(); 9201 async_pixel_transfer_manager_->ProcessMorePendingTransfers();
9100 ProcessFinishedAsyncTransfers(); 9202 ProcessFinishedAsyncTransfers();
9101 } 9203 }
9102 9204
9103 error::Error GLES2DecoderImpl::HandleBeginQueryEXT( 9205 error::Error GLES2DecoderImpl::HandleBeginQueryEXT(
9104 uint32 immediate_data_size, const cmds::BeginQueryEXT& c) { 9206 uint32 immediate_data_size, const cmds::BeginQueryEXT& c) {
9105 GLenum target = static_cast<GLenum>(c.target); 9207 GLenum target = static_cast<GLenum>(c.target);
9106 GLuint client_id = static_cast<GLuint>(c.id); 9208 GLuint client_id = static_cast<GLuint>(c.id);
(...skipping 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after
10337 return error::kNoError; 10439 return error::kNoError;
10338 } 10440 }
10339 10441
10340 // Include the auto-generated part of this file. We split this because it means 10442 // Include the auto-generated part of this file. We split this because it means
10341 // we can easily edit the non-auto generated parts right here in this file 10443 // we can easily edit the non-auto generated parts right here in this file
10342 // instead of having to edit some template or the code generator. 10444 // instead of having to edit some template or the code generator.
10343 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 10445 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
10344 10446
10345 } // namespace gles2 10447 } // namespace gles2
10346 } // namespace gpu 10448 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698