OLD | NEW |
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 <GLES2/gl2.h> | 9 #include <GLES2/gl2.h> |
10 #include <GLES2/gl2ext.h> | 10 #include <GLES2/gl2ext.h> |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 GLES2Implementation::GLES2Implementation( | 77 GLES2Implementation::GLES2Implementation( |
78 GLES2CmdHelper* helper, | 78 GLES2CmdHelper* helper, |
79 ShareGroup* share_group, | 79 ShareGroup* share_group, |
80 TransferBufferInterface* transfer_buffer, | 80 TransferBufferInterface* transfer_buffer, |
81 bool bind_generates_resource, | 81 bool bind_generates_resource, |
82 bool lose_context_when_out_of_memory, | 82 bool lose_context_when_out_of_memory, |
83 bool support_client_side_arrays, | 83 bool support_client_side_arrays, |
84 GpuControl* gpu_control) | 84 GpuControl* gpu_control) |
85 : helper_(helper), | 85 : helper_(helper), |
86 transfer_buffer_(transfer_buffer), | 86 transfer_buffer_(transfer_buffer), |
87 angle_pack_reverse_row_order_status_(kUnknownExtensionStatus), | |
88 chromium_framebuffer_multisample_(kUnknownExtensionStatus), | 87 chromium_framebuffer_multisample_(kUnknownExtensionStatus), |
89 pack_alignment_(4), | 88 pack_alignment_(4), |
90 pack_row_length_(0), | 89 pack_row_length_(0), |
91 pack_skip_pixels_(0), | 90 pack_skip_pixels_(0), |
92 pack_skip_rows_(0), | 91 pack_skip_rows_(0), |
93 unpack_alignment_(4), | 92 unpack_alignment_(4), |
94 unpack_row_length_(0), | 93 unpack_row_length_(0), |
95 unpack_image_height_(0), | 94 unpack_image_height_(0), |
96 unpack_skip_rows_(0), | 95 unpack_skip_rows_(0), |
97 unpack_skip_pixels_(0), | 96 unpack_skip_pixels_(0), |
98 unpack_skip_images_(0), | 97 unpack_skip_images_(0), |
99 pack_reverse_row_order_(false), | |
100 active_texture_unit_(0), | 98 active_texture_unit_(0), |
101 bound_framebuffer_(0), | 99 bound_framebuffer_(0), |
102 bound_read_framebuffer_(0), | 100 bound_read_framebuffer_(0), |
103 bound_renderbuffer_(0), | 101 bound_renderbuffer_(0), |
104 bound_valuebuffer_(0), | 102 bound_valuebuffer_(0), |
105 current_program_(0), | 103 current_program_(0), |
106 bound_array_buffer_(0), | 104 bound_array_buffer_(0), |
107 bound_copy_read_buffer_(0), | 105 bound_copy_read_buffer_(0), |
108 bound_copy_write_buffer_(0), | 106 bound_copy_write_buffer_(0), |
109 bound_pixel_pack_buffer_(0), | 107 bound_pixel_pack_buffer_(0), |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 return false; | 436 return false; |
439 default: { | 437 default: { |
440 bool available = IsExtensionAvailable(extension); | 438 bool available = IsExtensionAvailable(extension); |
441 *status = available ? kAvailableExtensionStatus : | 439 *status = available ? kAvailableExtensionStatus : |
442 kUnavailableExtensionStatus; | 440 kUnavailableExtensionStatus; |
443 return available; | 441 return available; |
444 } | 442 } |
445 } | 443 } |
446 } | 444 } |
447 | 445 |
448 bool GLES2Implementation::IsAnglePackReverseRowOrderAvailable() { | |
449 return IsExtensionAvailableHelper( | |
450 "GL_ANGLE_pack_reverse_row_order", | |
451 &angle_pack_reverse_row_order_status_); | |
452 } | |
453 | |
454 bool GLES2Implementation::IsChromiumFramebufferMultisampleAvailable() { | 446 bool GLES2Implementation::IsChromiumFramebufferMultisampleAvailable() { |
455 return IsExtensionAvailableHelper( | 447 return IsExtensionAvailableHelper( |
456 "GL_CHROMIUM_framebuffer_multisample", | 448 "GL_CHROMIUM_framebuffer_multisample", |
457 &chromium_framebuffer_multisample_); | 449 &chromium_framebuffer_multisample_); |
458 } | 450 } |
459 | 451 |
460 const std::string& GLES2Implementation::GetLogPrefix() const { | 452 const std::string& GLES2Implementation::GetLogPrefix() const { |
461 const std::string& prefix(debug_marker_manager_.GetMarker()); | 453 const std::string& prefix(debug_marker_manager_.GetMarker()); |
462 return prefix.empty() ? this_in_hex_ : prefix; | 454 return prefix.empty() ? this_in_hex_ : prefix; |
463 } | 455 } |
(...skipping 1337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1801 break; | 1793 break; |
1802 case GL_UNPACK_SKIP_ROWS_EXT: | 1794 case GL_UNPACK_SKIP_ROWS_EXT: |
1803 unpack_skip_rows_ = param; | 1795 unpack_skip_rows_ = param; |
1804 break; | 1796 break; |
1805 case GL_UNPACK_SKIP_PIXELS_EXT: | 1797 case GL_UNPACK_SKIP_PIXELS_EXT: |
1806 unpack_skip_pixels_ = param; | 1798 unpack_skip_pixels_ = param; |
1807 break; | 1799 break; |
1808 case GL_UNPACK_SKIP_IMAGES: | 1800 case GL_UNPACK_SKIP_IMAGES: |
1809 unpack_skip_images_ = param; | 1801 unpack_skip_images_ = param; |
1810 break; | 1802 break; |
1811 case GL_PACK_REVERSE_ROW_ORDER_ANGLE: | |
1812 pack_reverse_row_order_ = | |
1813 IsAnglePackReverseRowOrderAvailable() ? (param != 0) : false; | |
1814 break; | |
1815 default: | 1803 default: |
1816 break; | 1804 break; |
1817 } | 1805 } |
1818 helper_->PixelStorei(pname, param); | 1806 helper_->PixelStorei(pname, param); |
1819 CheckGLError(); | 1807 CheckGLError(); |
1820 } | 1808 } |
1821 | 1809 |
1822 void GLES2Implementation::VertexAttribIPointer( | 1810 void GLES2Implementation::VertexAttribIPointer( |
1823 GLuint index, GLint size, GLenum type, GLsizei stride, const void* ptr) { | 1811 GLuint index, GLint size, GLenum type, GLsizei stride, const void* ptr) { |
1824 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 1812 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
(...skipping 1805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3630 return; | 3618 return; |
3631 } | 3619 } |
3632 *result = 0; // mark as failed. | 3620 *result = 0; // mark as failed. |
3633 helper_->ReadPixels( | 3621 helper_->ReadPixels( |
3634 xoffset, yoffset, width, num_rows, format, type, | 3622 xoffset, yoffset, width, num_rows, format, type, |
3635 buffer.shm_id(), buffer.offset(), | 3623 buffer.shm_id(), buffer.offset(), |
3636 GetResultShmId(), GetResultShmOffset(), | 3624 GetResultShmId(), GetResultShmOffset(), |
3637 false); | 3625 false); |
3638 WaitForCmd(); | 3626 WaitForCmd(); |
3639 if (*result != 0) { | 3627 if (*result != 0) { |
3640 // when doing a y-flip we have to iterate through top-to-bottom chunks | |
3641 // of the dst. The service side handles reversing the rows within a | |
3642 // chunk. | |
3643 int8_t* rows_dst; | |
3644 if (pack_reverse_row_order_) { | |
3645 rows_dst = dest + (height - num_rows) * dst_padded_row_size; | |
3646 } else { | |
3647 rows_dst = dest; | |
3648 } | |
3649 // We have to copy 1 row at a time to avoid writing pad bytes. | 3628 // We have to copy 1 row at a time to avoid writing pad bytes. |
3650 const int8_t* src = static_cast<const int8_t*>(buffer.address()); | 3629 const int8_t* src = static_cast<const int8_t*>(buffer.address()); |
3651 for (GLint yy = 0; yy < num_rows; ++yy) { | 3630 for (GLint yy = 0; yy < num_rows; ++yy) { |
3652 memcpy(rows_dst, src, unpadded_row_size); | 3631 memcpy(dest, src, unpadded_row_size); |
3653 rows_dst += dst_padded_row_size; | 3632 dest += dst_padded_row_size; |
3654 src += padded_row_size; | 3633 src += padded_row_size; |
3655 } | 3634 } |
3656 if (!pack_reverse_row_order_) { | |
3657 dest = rows_dst; | |
3658 } | |
3659 } | 3635 } |
3660 // If it was not marked as successful exit. | 3636 // If it was not marked as successful exit. |
3661 if (*result == 0) { | 3637 if (*result == 0) { |
3662 return; | 3638 return; |
3663 } | 3639 } |
3664 yoffset += num_rows; | 3640 yoffset += num_rows; |
3665 height -= num_rows; | 3641 height -= num_rows; |
3666 } | 3642 } |
3667 CheckGLError(); | 3643 CheckGLError(); |
3668 } | 3644 } |
(...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4829 SetBucketAsCString(kResultBucketId, extension); | 4805 SetBucketAsCString(kResultBucketId, extension); |
4830 helper_->RequestExtensionCHROMIUM(kResultBucketId); | 4806 helper_->RequestExtensionCHROMIUM(kResultBucketId); |
4831 helper_->SetBucketSize(kResultBucketId, 0); | 4807 helper_->SetBucketSize(kResultBucketId, 0); |
4832 | 4808 |
4833 struct ExtensionCheck { | 4809 struct ExtensionCheck { |
4834 const char* extension; | 4810 const char* extension; |
4835 ExtensionStatus* status; | 4811 ExtensionStatus* status; |
4836 }; | 4812 }; |
4837 const ExtensionCheck checks[] = { | 4813 const ExtensionCheck checks[] = { |
4838 { | 4814 { |
4839 "GL_ANGLE_pack_reverse_row_order", | |
4840 &angle_pack_reverse_row_order_status_, | |
4841 }, | |
4842 { | |
4843 "GL_CHROMIUM_framebuffer_multisample", | 4815 "GL_CHROMIUM_framebuffer_multisample", |
4844 &chromium_framebuffer_multisample_, | 4816 &chromium_framebuffer_multisample_, |
4845 }, | 4817 }, |
4846 }; | 4818 }; |
4847 const size_t kNumChecks = sizeof(checks)/sizeof(checks[0]); | 4819 const size_t kNumChecks = sizeof(checks)/sizeof(checks[0]); |
4848 for (size_t ii = 0; ii < kNumChecks; ++ii) { | 4820 for (size_t ii = 0; ii < kNumChecks; ++ii) { |
4849 const ExtensionCheck& check = checks[ii]; | 4821 const ExtensionCheck& check = checks[ii]; |
4850 if (*check.status == kUnavailableExtensionStatus && | 4822 if (*check.status == kUnavailableExtensionStatus && |
4851 !strcmp(extension, check.extension)) { | 4823 !strcmp(extension, check.extension)) { |
4852 *check.status = kUnknownExtensionStatus; | 4824 *check.status = kUnknownExtensionStatus; |
(...skipping 1716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6569 CheckGLError(); | 6541 CheckGLError(); |
6570 } | 6542 } |
6571 | 6543 |
6572 // Include the auto-generated part of this file. We split this because it means | 6544 // Include the auto-generated part of this file. We split this because it means |
6573 // we can easily edit the non-auto generated parts right here in this file | 6545 // we can easily edit the non-auto generated parts right here in this file |
6574 // instead of having to edit some template or the code generator. | 6546 // instead of having to edit some template or the code generator. |
6575 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" | 6547 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" |
6576 | 6548 |
6577 } // namespace gles2 | 6549 } // namespace gles2 |
6578 } // namespace gpu | 6550 } // namespace gpu |
OLD | NEW |