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

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

Issue 851503003: Update from https://crrev.com/311076 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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
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 <GLES2/gl2ext.h> 9 #include <GLES2/gl2ext.h>
10 #include <GLES2/gl2extchromium.h> 10 #include <GLES2/gl2extchromium.h>
11 #include <GLES3/gl3.h>
11 #include <algorithm> 12 #include <algorithm>
12 #include <limits> 13 #include <limits>
13 #include <map> 14 #include <map>
14 #include <queue> 15 #include <queue>
15 #include <set> 16 #include <set>
16 #include <sstream> 17 #include <sstream>
17 #include <string> 18 #include <string>
18 #include "base/bind.h" 19 #include "base/bind.h"
19 #include "gpu/command_buffer/client/buffer_tracker.h" 20 #include "gpu/command_buffer/client/buffer_tracker.h"
20 #include "gpu/command_buffer/client/gpu_control.h" 21 #include "gpu/command_buffer/client/gpu_control.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 bool support_client_side_arrays, 71 bool support_client_side_arrays,
71 GpuControl* gpu_control) 72 GpuControl* gpu_control)
72 : helper_(helper), 73 : helper_(helper),
73 transfer_buffer_(transfer_buffer), 74 transfer_buffer_(transfer_buffer),
74 angle_pack_reverse_row_order_status_(kUnknownExtensionStatus), 75 angle_pack_reverse_row_order_status_(kUnknownExtensionStatus),
75 chromium_framebuffer_multisample_(kUnknownExtensionStatus), 76 chromium_framebuffer_multisample_(kUnknownExtensionStatus),
76 pack_alignment_(4), 77 pack_alignment_(4),
77 unpack_alignment_(4), 78 unpack_alignment_(4),
78 unpack_flip_y_(false), 79 unpack_flip_y_(false),
79 unpack_row_length_(0), 80 unpack_row_length_(0),
81 unpack_image_height_(0),
80 unpack_skip_rows_(0), 82 unpack_skip_rows_(0),
81 unpack_skip_pixels_(0), 83 unpack_skip_pixels_(0),
84 unpack_skip_images_(0),
82 pack_reverse_row_order_(false), 85 pack_reverse_row_order_(false),
83 active_texture_unit_(0), 86 active_texture_unit_(0),
84 bound_framebuffer_(0), 87 bound_framebuffer_(0),
85 bound_read_framebuffer_(0), 88 bound_read_framebuffer_(0),
86 bound_renderbuffer_(0), 89 bound_renderbuffer_(0),
87 bound_valuebuffer_(0), 90 bound_valuebuffer_(0),
88 current_program_(0), 91 current_program_(0),
89 bound_array_buffer_id_(0), 92 bound_array_buffer_id_(0),
90 bound_pixel_pack_transfer_buffer_id_(0), 93 bound_pixel_pack_transfer_buffer_id_(0),
91 bound_pixel_unpack_transfer_buffer_id_(0), 94 bound_pixel_unpack_transfer_buffer_id_(0),
92 async_upload_token_(0), 95 async_upload_token_(0),
93 async_upload_sync_(NULL), 96 async_upload_sync_(NULL),
94 async_upload_sync_shm_id_(0), 97 async_upload_sync_shm_id_(0),
95 async_upload_sync_shm_offset_(0), 98 async_upload_sync_shm_offset_(0),
96 error_bits_(0), 99 error_bits_(0),
97 debug_(false), 100 debug_(false),
98 lose_context_when_out_of_memory_(lose_context_when_out_of_memory), 101 lose_context_when_out_of_memory_(lose_context_when_out_of_memory),
99 support_client_side_arrays_(support_client_side_arrays), 102 support_client_side_arrays_(support_client_side_arrays),
100 use_count_(0), 103 use_count_(0),
101 error_message_callback_(NULL), 104 error_message_callback_(NULL),
105 current_trace_stack_(0),
102 gpu_control_(gpu_control), 106 gpu_control_(gpu_control),
103 capabilities_(gpu_control->GetCapabilities()), 107 capabilities_(gpu_control->GetCapabilities()),
104 weak_ptr_factory_(this) { 108 weak_ptr_factory_(this) {
105 DCHECK(helper); 109 DCHECK(helper);
106 DCHECK(transfer_buffer); 110 DCHECK(transfer_buffer);
107 DCHECK(gpu_control); 111 DCHECK(gpu_control);
108 112
109 std::stringstream ss; 113 std::stringstream ss;
110 ss << std::hex << this; 114 ss << std::hex << this;
111 this_in_hex_ = ss.str(); 115 this_in_hex_ = ss.str();
(...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after
1098 switch (pname) { 1102 switch (pname) {
1099 case GL_PACK_ALIGNMENT: 1103 case GL_PACK_ALIGNMENT:
1100 pack_alignment_ = param; 1104 pack_alignment_ = param;
1101 break; 1105 break;
1102 case GL_UNPACK_ALIGNMENT: 1106 case GL_UNPACK_ALIGNMENT:
1103 unpack_alignment_ = param; 1107 unpack_alignment_ = param;
1104 break; 1108 break;
1105 case GL_UNPACK_ROW_LENGTH_EXT: 1109 case GL_UNPACK_ROW_LENGTH_EXT:
1106 unpack_row_length_ = param; 1110 unpack_row_length_ = param;
1107 return; 1111 return;
1112 case GL_UNPACK_IMAGE_HEIGHT:
1113 unpack_image_height_ = param;
1114 return;
1108 case GL_UNPACK_SKIP_ROWS_EXT: 1115 case GL_UNPACK_SKIP_ROWS_EXT:
1109 unpack_skip_rows_ = param; 1116 unpack_skip_rows_ = param;
1110 return; 1117 return;
1111 case GL_UNPACK_SKIP_PIXELS_EXT: 1118 case GL_UNPACK_SKIP_PIXELS_EXT:
1112 unpack_skip_pixels_ = param; 1119 unpack_skip_pixels_ = param;
1113 return; 1120 return;
1121 case GL_UNPACK_SKIP_IMAGES:
1122 unpack_skip_images_ = param;
1123 return;
1114 case GL_UNPACK_FLIP_Y_CHROMIUM: 1124 case GL_UNPACK_FLIP_Y_CHROMIUM:
1115 unpack_flip_y_ = (param != 0); 1125 unpack_flip_y_ = (param != 0);
1116 break; 1126 break;
1117 case GL_PACK_REVERSE_ROW_ORDER_ANGLE: 1127 case GL_PACK_REVERSE_ROW_ORDER_ANGLE:
1118 pack_reverse_row_order_ = 1128 pack_reverse_row_order_ =
1119 IsAnglePackReverseRowOrderAvailable() ? (param != 0) : false; 1129 IsAnglePackReverseRowOrderAvailable() ? (param != 0) : false;
1120 break; 1130 break;
1121 default: 1131 default:
1122 break; 1132 break;
1123 } 1133 }
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
1604 return; 1614 return;
1605 } 1615 }
1606 if (border != 0) { 1616 if (border != 0) {
1607 SetGLError(GL_INVALID_VALUE, "glTexImage2D", "border != 0"); 1617 SetGLError(GL_INVALID_VALUE, "glTexImage2D", "border != 0");
1608 return; 1618 return;
1609 } 1619 }
1610 uint32 size; 1620 uint32 size;
1611 uint32 unpadded_row_size; 1621 uint32 unpadded_row_size;
1612 uint32 padded_row_size; 1622 uint32 padded_row_size;
1613 if (!GLES2Util::ComputeImageDataSizes( 1623 if (!GLES2Util::ComputeImageDataSizes(
1614 width, height, format, type, unpack_alignment_, &size, 1624 width, height, 1, format, type, unpack_alignment_, &size,
1615 &unpadded_row_size, &padded_row_size)) { 1625 &unpadded_row_size, &padded_row_size)) {
1616 SetGLError(GL_INVALID_VALUE, "glTexImage2D", "image size too large"); 1626 SetGLError(GL_INVALID_VALUE, "glTexImage2D", "image size too large");
1617 return; 1627 return;
1618 } 1628 }
1619 1629
1620 // If there's a pixel unpack buffer bound use it when issuing TexImage2D. 1630 // If there's a pixel unpack buffer bound use it when issuing TexImage2D.
1621 if (bound_pixel_unpack_transfer_buffer_id_) { 1631 if (bound_pixel_unpack_transfer_buffer_id_) {
1622 GLuint offset = ToGLuint(pixels); 1632 GLuint offset = ToGLuint(pixels);
1623 BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid( 1633 BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid(
1624 bound_pixel_unpack_transfer_buffer_id_, 1634 bound_pixel_unpack_transfer_buffer_id_,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1685 // No, so send it using TexSubImage2D. 1695 // No, so send it using TexSubImage2D.
1686 helper_->TexImage2D( 1696 helper_->TexImage2D(
1687 target, level, internalformat, width, height, format, type, 1697 target, level, internalformat, width, height, format, type,
1688 0, 0); 1698 0, 0);
1689 TexSubImage2DImpl( 1699 TexSubImage2DImpl(
1690 target, level, 0, 0, width, height, format, type, unpadded_row_size, 1700 target, level, 0, 0, width, height, format, type, unpadded_row_size,
1691 pixels, src_padded_row_size, GL_TRUE, &buffer, padded_row_size); 1701 pixels, src_padded_row_size, GL_TRUE, &buffer, padded_row_size);
1692 CheckGLError(); 1702 CheckGLError();
1693 } 1703 }
1694 1704
1705 void GLES2Implementation::TexImage3D(
1706 GLenum target, GLint level, GLint internalformat, GLsizei width,
1707 GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type,
1708 const void* pixels) {
1709 GPU_CLIENT_SINGLE_THREAD_CHECK();
1710 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glTexImage3D("
1711 << GLES2Util::GetStringTextureTarget(target) << ", "
1712 << level << ", "
1713 << GLES2Util::GetStringTextureInternalFormat(internalformat) << ", "
1714 << width << ", " << height << ", " << depth << ", " << border << ", "
1715 << GLES2Util::GetStringTextureFormat(format) << ", "
1716 << GLES2Util::GetStringPixelType(type) << ", "
1717 << static_cast<const void*>(pixels) << ")");
1718 if (level < 0 || height < 0 || width < 0 || depth < 0) {
1719 SetGLError(GL_INVALID_VALUE, "glTexImage3D", "dimension < 0");
1720 return;
1721 }
1722 if (border != 0) {
1723 SetGLError(GL_INVALID_VALUE, "glTexImage3D", "border != 0");
1724 return;
1725 }
1726 uint32 size;
1727 uint32 unpadded_row_size;
1728 uint32 padded_row_size;
1729 if (!GLES2Util::ComputeImageDataSizes(
1730 width, height, depth, format, type, unpack_alignment_, &size,
1731 &unpadded_row_size, &padded_row_size)) {
1732 SetGLError(GL_INVALID_VALUE, "glTexImage3D", "image size too large");
1733 return;
1734 }
1735
1736 // If there's a pixel unpack buffer bound use it when issuing TexImage3D.
1737 if (bound_pixel_unpack_transfer_buffer_id_) {
1738 GLuint offset = ToGLuint(pixels);
1739 BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid(
1740 bound_pixel_unpack_transfer_buffer_id_,
1741 "glTexImage3D", offset, size);
1742 if (buffer && buffer->shm_id() != -1) {
1743 helper_->TexImage3D(
1744 target, level, internalformat, width, height, depth, format, type,
1745 buffer->shm_id(), buffer->shm_offset() + offset);
1746 buffer->set_last_usage_token(helper_->InsertToken());
1747 CheckGLError();
1748 }
1749 return;
1750 }
1751
1752 // If there's no data just issue TexImage3D
1753 if (!pixels) {
1754 helper_->TexImage3D(
1755 target, level, internalformat, width, height, depth, format, type,
1756 0, 0);
1757 CheckGLError();
1758 return;
1759 }
1760
1761 // compute the advance bytes per row for the src pixels
1762 uint32 src_padded_row_size;
1763 if (unpack_row_length_ > 0) {
1764 if (!GLES2Util::ComputeImagePaddedRowSize(
1765 unpack_row_length_, format, type, unpack_alignment_,
1766 &src_padded_row_size)) {
1767 SetGLError(
1768 GL_INVALID_VALUE, "glTexImage3D", "unpack row length too large");
1769 return;
1770 }
1771 } else {
1772 src_padded_row_size = padded_row_size;
1773 }
1774 uint32 src_height = unpack_image_height_ > 0 ? unpack_image_height_ : height;
1775
1776 // advance pixels pointer past the skip images/rows/pixels
1777 pixels = reinterpret_cast<const int8*>(pixels) +
1778 unpack_skip_images_ * src_padded_row_size * src_height +
1779 unpack_skip_rows_ * src_padded_row_size;
1780 if (unpack_skip_pixels_) {
1781 uint32 group_size = GLES2Util::ComputeImageGroupSize(format, type);
1782 pixels = reinterpret_cast<const int8*>(pixels) +
1783 unpack_skip_pixels_ * group_size;
1784 }
1785
1786 // Check if we can send it all at once.
1787 ScopedTransferBufferPtr buffer(size, helper_, transfer_buffer_);
1788 if (!buffer.valid()) {
1789 return;
1790 }
1791
1792 if (buffer.size() >= size) {
1793 void* buffer_pointer = buffer.address();
1794 for (GLsizei z = 0; z < depth; ++z) {
1795 // Only the last row of the last image is unpadded.
1796 uint32 src_unpadded_row_size =
1797 (z == depth - 1) ? unpadded_row_size : src_padded_row_size;
1798 // TODO(zmo): Ignore flip_y flag for now.
1799 CopyRectToBuffer(
1800 pixels, height, src_unpadded_row_size, src_padded_row_size, false,
1801 buffer_pointer, padded_row_size);
1802 pixels = reinterpret_cast<const int8*>(pixels) +
1803 src_padded_row_size * src_height;
1804 buffer_pointer = reinterpret_cast<int8*>(buffer_pointer) +
1805 padded_row_size * height;
1806 }
1807 helper_->TexImage3D(
1808 target, level, internalformat, width, height, depth, format, type,
1809 buffer.shm_id(), buffer.offset());
1810 CheckGLError();
1811 return;
1812 }
1813
1814 // No, so send it using TexSubImage3D.
1815 helper_->TexImage3D(
1816 target, level, internalformat, width, height, depth, format, type,
1817 0, 0);
1818 TexSubImage3DImpl(
1819 target, level, 0, 0, 0, width, height, depth, format, type,
1820 unpadded_row_size, pixels, src_padded_row_size, GL_TRUE, &buffer,
1821 padded_row_size);
1822 CheckGLError();
1823 }
1824
1695 void GLES2Implementation::TexSubImage2D( 1825 void GLES2Implementation::TexSubImage2D(
1696 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, 1826 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
1697 GLsizei height, GLenum format, GLenum type, const void* pixels) { 1827 GLsizei height, GLenum format, GLenum type, const void* pixels) {
1698 GPU_CLIENT_SINGLE_THREAD_CHECK(); 1828 GPU_CLIENT_SINGLE_THREAD_CHECK();
1699 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glTexSubImage2D(" 1829 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glTexSubImage2D("
1700 << GLES2Util::GetStringTextureTarget(target) << ", " 1830 << GLES2Util::GetStringTextureTarget(target) << ", "
1701 << level << ", " 1831 << level << ", "
1702 << xoffset << ", " << yoffset << ", " 1832 << xoffset << ", " << yoffset << ", "
1703 << width << ", " << height << ", " 1833 << width << ", " << height << ", "
1704 << GLES2Util::GetStringTextureFormat(format) << ", " 1834 << GLES2Util::GetStringTextureFormat(format) << ", "
1705 << GLES2Util::GetStringPixelType(type) << ", " 1835 << GLES2Util::GetStringPixelType(type) << ", "
1706 << static_cast<const void*>(pixels) << ")"); 1836 << static_cast<const void*>(pixels) << ")");
1707 1837
1708 if (level < 0 || height < 0 || width < 0) { 1838 if (level < 0 || height < 0 || width < 0) {
1709 SetGLError(GL_INVALID_VALUE, "glTexSubImage2D", "dimension < 0"); 1839 SetGLError(GL_INVALID_VALUE, "glTexSubImage2D", "dimension < 0");
1710 return; 1840 return;
1711 } 1841 }
1712 if (height == 0 || width == 0) { 1842 if (height == 0 || width == 0) {
1713 return; 1843 return;
1714 } 1844 }
1715 1845
1716 uint32 temp_size; 1846 uint32 temp_size;
1717 uint32 unpadded_row_size; 1847 uint32 unpadded_row_size;
1718 uint32 padded_row_size; 1848 uint32 padded_row_size;
1719 if (!GLES2Util::ComputeImageDataSizes( 1849 if (!GLES2Util::ComputeImageDataSizes(
1720 width, height, format, type, unpack_alignment_, &temp_size, 1850 width, height, 1, format, type, unpack_alignment_, &temp_size,
1721 &unpadded_row_size, &padded_row_size)) { 1851 &unpadded_row_size, &padded_row_size)) {
1722 SetGLError(GL_INVALID_VALUE, "glTexSubImage2D", "size to large"); 1852 SetGLError(GL_INVALID_VALUE, "glTexSubImage2D", "size to large");
1723 return; 1853 return;
1724 } 1854 }
1725 1855
1726 // If there's a pixel unpack buffer bound use it when issuing TexSubImage2D. 1856 // If there's a pixel unpack buffer bound use it when issuing TexSubImage2D.
1727 if (bound_pixel_unpack_transfer_buffer_id_) { 1857 if (bound_pixel_unpack_transfer_buffer_id_) {
1728 GLuint offset = ToGLuint(pixels); 1858 GLuint offset = ToGLuint(pixels);
1729 BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid( 1859 BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid(
1730 bound_pixel_unpack_transfer_buffer_id_, 1860 bound_pixel_unpack_transfer_buffer_id_,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1763 } 1893 }
1764 1894
1765 ScopedTransferBufferPtr buffer(temp_size, helper_, transfer_buffer_); 1895 ScopedTransferBufferPtr buffer(temp_size, helper_, transfer_buffer_);
1766 TexSubImage2DImpl( 1896 TexSubImage2DImpl(
1767 target, level, xoffset, yoffset, width, height, format, type, 1897 target, level, xoffset, yoffset, width, height, format, type,
1768 unpadded_row_size, pixels, src_padded_row_size, GL_FALSE, &buffer, 1898 unpadded_row_size, pixels, src_padded_row_size, GL_FALSE, &buffer,
1769 padded_row_size); 1899 padded_row_size);
1770 CheckGLError(); 1900 CheckGLError();
1771 } 1901 }
1772 1902
1903 void GLES2Implementation::TexSubImage3D(
1904 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
1905 GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type,
1906 const void* pixels) {
1907 GPU_CLIENT_SINGLE_THREAD_CHECK();
1908 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glTexSubImage3D("
1909 << GLES2Util::GetStringTextureTarget(target) << ", "
1910 << level << ", "
1911 << xoffset << ", " << yoffset << ", " << zoffset << ", "
1912 << width << ", " << height << ", " << depth << ", "
1913 << GLES2Util::GetStringTextureFormat(format) << ", "
1914 << GLES2Util::GetStringPixelType(type) << ", "
1915 << static_cast<const void*>(pixels) << ")");
1916
1917 if (level < 0 || height < 0 || width < 0 || depth < 0) {
1918 SetGLError(GL_INVALID_VALUE, "glTexSubImage3D", "dimension < 0");
1919 return;
1920 }
1921 if (height == 0 || width == 0 || depth == 0) {
1922 return;
1923 }
1924
1925 uint32 temp_size;
1926 uint32 unpadded_row_size;
1927 uint32 padded_row_size;
1928 if (!GLES2Util::ComputeImageDataSizes(
1929 width, height, depth, format, type, unpack_alignment_, &temp_size,
1930 &unpadded_row_size, &padded_row_size)) {
1931 SetGLError(GL_INVALID_VALUE, "glTexSubImage3D", "size to large");
1932 return;
1933 }
1934
1935 // If there's a pixel unpack buffer bound use it when issuing TexSubImage2D.
1936 if (bound_pixel_unpack_transfer_buffer_id_) {
1937 GLuint offset = ToGLuint(pixels);
1938 BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid(
1939 bound_pixel_unpack_transfer_buffer_id_,
1940 "glTexSubImage3D", offset, temp_size);
1941 if (buffer && buffer->shm_id() != -1) {
1942 helper_->TexSubImage3D(
1943 target, level, xoffset, yoffset, zoffset, width, height, depth,
1944 format, type, buffer->shm_id(), buffer->shm_offset() + offset, false);
1945 buffer->set_last_usage_token(helper_->InsertToken());
1946 CheckGLError();
1947 }
1948 return;
1949 }
1950
1951 // compute the advance bytes per row for the src pixels
1952 uint32 src_padded_row_size;
1953 if (unpack_row_length_ > 0) {
1954 if (!GLES2Util::ComputeImagePaddedRowSize(
1955 unpack_row_length_, format, type, unpack_alignment_,
1956 &src_padded_row_size)) {
1957 SetGLError(
1958 GL_INVALID_VALUE, "glTexImage3D", "unpack row length too large");
1959 return;
1960 }
1961 } else {
1962 src_padded_row_size = padded_row_size;
1963 }
1964 uint32 src_height = unpack_image_height_ > 0 ? unpack_image_height_ : height;
1965
1966 // advance pixels pointer past the skip images/rows/pixels
1967 pixels = reinterpret_cast<const int8*>(pixels) +
1968 unpack_skip_images_ * src_padded_row_size * src_height +
1969 unpack_skip_rows_ * src_padded_row_size;
1970 if (unpack_skip_pixels_) {
1971 uint32 group_size = GLES2Util::ComputeImageGroupSize(format, type);
1972 pixels = reinterpret_cast<const int8*>(pixels) +
1973 unpack_skip_pixels_ * group_size;
1974 }
1975
1976 ScopedTransferBufferPtr buffer(temp_size, helper_, transfer_buffer_);
1977 TexSubImage3DImpl(
1978 target, level, xoffset, yoffset, zoffset, width, height, depth,
1979 format, type, unpadded_row_size, pixels, src_padded_row_size, GL_FALSE,
1980 &buffer, padded_row_size);
1981 CheckGLError();
1982 }
1983
1773 static GLint ComputeNumRowsThatFitInBuffer( 1984 static GLint ComputeNumRowsThatFitInBuffer(
1774 uint32 padded_row_size, uint32 unpadded_row_size, 1985 uint32 padded_row_size, uint32 unpadded_row_size,
1775 unsigned int size) { 1986 unsigned int size, GLsizei remaining_rows) {
1776 DCHECK_GE(unpadded_row_size, 0u); 1987 DCHECK_GE(unpadded_row_size, 0u);
1777 if (padded_row_size == 0) { 1988 if (padded_row_size == 0) {
1778 return 1; 1989 return 1;
1779 } 1990 }
1780 GLint num_rows = size / padded_row_size; 1991 GLint num_rows = size / padded_row_size;
1781 return num_rows + (size - num_rows * padded_row_size) / unpadded_row_size; 1992 if (num_rows + 1 == remaining_rows &&
1993 size - num_rows * padded_row_size >= unpadded_row_size) {
1994 num_rows++;
1995 }
1996 return num_rows;
1782 } 1997 }
1783 1998
1784 void GLES2Implementation::TexSubImage2DImpl( 1999 void GLES2Implementation::TexSubImage2DImpl(
1785 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, 2000 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
1786 GLsizei height, GLenum format, GLenum type, uint32 unpadded_row_size, 2001 GLsizei height, GLenum format, GLenum type, uint32 unpadded_row_size,
1787 const void* pixels, uint32 pixels_padded_row_size, GLboolean internal, 2002 const void* pixels, uint32 pixels_padded_row_size, GLboolean internal,
1788 ScopedTransferBufferPtr* buffer, uint32 buffer_padded_row_size) { 2003 ScopedTransferBufferPtr* buffer, uint32 buffer_padded_row_size) {
1789 DCHECK(buffer); 2004 DCHECK(buffer);
1790 DCHECK_GE(level, 0); 2005 DCHECK_GE(level, 0);
1791 DCHECK_GT(height, 0); 2006 DCHECK_GT(height, 0);
1792 DCHECK_GT(width, 0); 2007 DCHECK_GT(width, 0);
1793 2008
1794 const int8* source = reinterpret_cast<const int8*>(pixels); 2009 const int8* source = reinterpret_cast<const int8*>(pixels);
1795 GLint original_yoffset = yoffset; 2010 GLint original_yoffset = yoffset;
1796 // Transfer by rows. 2011 // Transfer by rows.
1797 while (height) { 2012 while (height) {
1798 unsigned int desired_size = 2013 unsigned int desired_size =
1799 buffer_padded_row_size * (height - 1) + unpadded_row_size; 2014 buffer_padded_row_size * (height - 1) + unpadded_row_size;
1800 if (!buffer->valid() || buffer->size() == 0) { 2015 if (!buffer->valid() || buffer->size() == 0) {
1801 buffer->Reset(desired_size); 2016 buffer->Reset(desired_size);
1802 if (!buffer->valid()) { 2017 if (!buffer->valid()) {
1803 return; 2018 return;
1804 } 2019 }
1805 } 2020 }
1806 2021
1807 GLint num_rows = ComputeNumRowsThatFitInBuffer( 2022 GLint num_rows = ComputeNumRowsThatFitInBuffer(
1808 buffer_padded_row_size, unpadded_row_size, buffer->size()); 2023 buffer_padded_row_size, unpadded_row_size, buffer->size(), height);
1809 num_rows = std::min(num_rows, height); 2024 num_rows = std::min(num_rows, height);
1810 CopyRectToBuffer( 2025 CopyRectToBuffer(
1811 source, num_rows, unpadded_row_size, pixels_padded_row_size, 2026 source, num_rows, unpadded_row_size, pixels_padded_row_size,
1812 unpack_flip_y_, buffer->address(), buffer_padded_row_size); 2027 unpack_flip_y_, buffer->address(), buffer_padded_row_size);
1813 GLint y = unpack_flip_y_ ? original_yoffset + height - num_rows : yoffset; 2028 GLint y = unpack_flip_y_ ? original_yoffset + height - num_rows : yoffset;
1814 helper_->TexSubImage2D( 2029 helper_->TexSubImage2D(
1815 target, level, xoffset, y, width, num_rows, format, type, 2030 target, level, xoffset, y, width, num_rows, format, type,
1816 buffer->shm_id(), buffer->offset(), internal); 2031 buffer->shm_id(), buffer->offset(), internal);
1817 buffer->Release(); 2032 buffer->Release();
1818 yoffset += num_rows; 2033 yoffset += num_rows;
1819 source += num_rows * pixels_padded_row_size; 2034 source += num_rows * pixels_padded_row_size;
1820 height -= num_rows; 2035 height -= num_rows;
1821 } 2036 }
1822 } 2037 }
1823 2038
2039 void GLES2Implementation::TexSubImage3DImpl(
2040 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei zoffset,
2041 GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type,
2042 uint32 unpadded_row_size, const void* pixels, uint32 pixels_padded_row_size,
2043 GLboolean internal, ScopedTransferBufferPtr* buffer,
2044 uint32 buffer_padded_row_size) {
2045 DCHECK(buffer);
2046 DCHECK_GE(level, 0);
2047 DCHECK_GT(height, 0);
2048 DCHECK_GT(width, 0);
2049 DCHECK_GT(depth, 0);
2050 const int8* source = reinterpret_cast<const int8*>(pixels);
2051 GLsizei total_rows = height * depth;
2052 GLint row_index = 0, depth_index = 0;
2053 while (total_rows) {
2054 // Each time, we either copy one or more images, or copy one or more rows
2055 // within a single image, depending on the buffer size limit.
2056 GLsizei max_rows;
2057 unsigned int desired_size;
2058 if (row_index > 0) {
2059 // We are in the middle of an image. Send the remaining of the image.
2060 max_rows = height - row_index;
2061 if (total_rows <= height) {
2062 // Last image, so last row is unpadded.
2063 desired_size = buffer_padded_row_size * (max_rows - 1) +
2064 unpadded_row_size;
2065 } else {
2066 desired_size = buffer_padded_row_size * max_rows;
2067 }
2068 } else {
2069 // Send all the remaining data if possible.
2070 max_rows = total_rows;
2071 desired_size =
2072 buffer_padded_row_size * (max_rows - 1) + unpadded_row_size;
2073 }
2074 if (!buffer->valid() || buffer->size() == 0) {
2075 buffer->Reset(desired_size);
2076 if (!buffer->valid()) {
2077 return;
2078 }
2079 }
2080 GLint num_rows = ComputeNumRowsThatFitInBuffer(
2081 buffer_padded_row_size, unpadded_row_size, buffer->size(), total_rows);
2082 num_rows = std::min(num_rows, max_rows);
2083 GLint num_images = num_rows / height;
2084 GLsizei my_height, my_depth;
2085 if (num_images > 0) {
2086 num_rows = num_images * height;
2087 my_height = height;
2088 my_depth = num_images;
2089 } else {
2090 my_height = num_rows;
2091 my_depth = 1;
2092 }
2093
2094 // TODO(zmo): Ignore flip_y flag for now.
2095 if (num_images > 0) {
2096 int8* buffer_pointer = reinterpret_cast<int8*>(buffer->address());
2097 uint32 src_height =
2098 unpack_image_height_ > 0 ? unpack_image_height_ : height;
2099 uint32 image_size_dst = buffer_padded_row_size * height;
2100 uint32 image_size_src = pixels_padded_row_size * src_height;
2101 for (GLint ii = 0; ii < num_images; ++ii) {
2102 uint32 my_unpadded_row_size;
2103 if (total_rows == num_rows && ii + 1 == num_images)
2104 my_unpadded_row_size = unpadded_row_size;
2105 else
2106 my_unpadded_row_size = pixels_padded_row_size;
2107 CopyRectToBuffer(
2108 source + ii * image_size_src, my_height, my_unpadded_row_size,
2109 pixels_padded_row_size, false, buffer_pointer + ii * image_size_dst,
2110 buffer_padded_row_size);
2111 }
2112 } else {
2113 uint32 my_unpadded_row_size;
2114 if (total_rows == num_rows)
2115 my_unpadded_row_size = unpadded_row_size;
2116 else
2117 my_unpadded_row_size = pixels_padded_row_size;
2118 CopyRectToBuffer(
2119 source, my_height, my_unpadded_row_size, pixels_padded_row_size,
2120 false, buffer->address(), buffer_padded_row_size);
2121 }
2122 helper_->TexSubImage3D(
2123 target, level, xoffset, yoffset + row_index, zoffset + depth_index,
2124 width, my_height, my_depth,
2125 format, type, buffer->shm_id(), buffer->offset(), internal);
2126 buffer->Release();
2127
2128 total_rows -= num_rows;
2129 if (total_rows > 0) {
2130 GLint num_image_paddings;
2131 if (num_images > 0) {
2132 DCHECK_EQ(row_index, 0);
2133 depth_index += num_images;
2134 num_image_paddings = num_images;
2135 } else {
2136 row_index = (row_index + my_height) % height;
2137 num_image_paddings = 0;
2138 if (my_height > 0 && row_index == 0) {
2139 depth_index++;
2140 num_image_paddings++;
2141 }
2142 }
2143 source += num_rows * pixels_padded_row_size;
2144 if (unpack_image_height_ > height && num_image_paddings > 0) {
2145 source += num_image_paddings * (unpack_image_height_ - height) *
2146 pixels_padded_row_size;
2147 }
2148 }
2149 }
2150 }
2151
1824 bool GLES2Implementation::GetActiveAttribHelper( 2152 bool GLES2Implementation::GetActiveAttribHelper(
1825 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, 2153 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size,
1826 GLenum* type, char* name) { 2154 GLenum* type, char* name) {
1827 // Clear the bucket so if the command fails nothing will be in it. 2155 // Clear the bucket so if the command fails nothing will be in it.
1828 helper_->SetBucketSize(kResultBucketId, 0); 2156 helper_->SetBucketSize(kResultBucketId, 0);
1829 typedef cmds::GetActiveAttrib::Result Result; 2157 typedef cmds::GetActiveAttrib::Result Result;
1830 Result* result = GetResultAs<Result*>(); 2158 Result* result = GetResultAs<Result*>();
1831 if (!result) { 2159 if (!result) {
1832 return false; 2160 return false;
1833 } 2161 }
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
2180 // write those padding bytes but leave them as they are. 2508 // write those padding bytes but leave them as they are.
2181 2509
2182 TRACE_EVENT0("gpu", "GLES2::ReadPixels"); 2510 TRACE_EVENT0("gpu", "GLES2::ReadPixels");
2183 typedef cmds::ReadPixels::Result Result; 2511 typedef cmds::ReadPixels::Result Result;
2184 2512
2185 int8* dest = reinterpret_cast<int8*>(pixels); 2513 int8* dest = reinterpret_cast<int8*>(pixels);
2186 uint32 temp_size; 2514 uint32 temp_size;
2187 uint32 unpadded_row_size; 2515 uint32 unpadded_row_size;
2188 uint32 padded_row_size; 2516 uint32 padded_row_size;
2189 if (!GLES2Util::ComputeImageDataSizes( 2517 if (!GLES2Util::ComputeImageDataSizes(
2190 width, 2, format, type, pack_alignment_, &temp_size, &unpadded_row_size, 2518 width, 2, 1, format, type, pack_alignment_, &temp_size,
2191 &padded_row_size)) { 2519 &unpadded_row_size, &padded_row_size)) {
2192 SetGLError(GL_INVALID_VALUE, "glReadPixels", "size too large."); 2520 SetGLError(GL_INVALID_VALUE, "glReadPixels", "size too large.");
2193 return; 2521 return;
2194 } 2522 }
2195 2523
2196 if (bound_pixel_pack_transfer_buffer_id_) { 2524 if (bound_pixel_pack_transfer_buffer_id_) {
2197 GLuint offset = ToGLuint(pixels); 2525 GLuint offset = ToGLuint(pixels);
2198 BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid( 2526 BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid(
2199 bound_pixel_pack_transfer_buffer_id_, 2527 bound_pixel_pack_transfer_buffer_id_,
2200 "glReadPixels", offset, padded_row_size * height); 2528 "glReadPixels", offset, padded_row_size * height);
2201 if (buffer && buffer->shm_id() != -1) { 2529 if (buffer && buffer->shm_id() != -1) {
2202 helper_->ReadPixels(xoffset, yoffset, width, height, format, type, 2530 helper_->ReadPixels(xoffset, yoffset, width, height, format, type,
2203 buffer->shm_id(), buffer->shm_offset(), 2531 buffer->shm_id(), buffer->shm_offset(),
2204 0, 0, true); 2532 0, 0, true);
2205 CheckGLError(); 2533 CheckGLError();
2206 } 2534 }
2207 return; 2535 return;
2208 } 2536 }
2209 2537
2210 if (!pixels) { 2538 if (!pixels) {
2211 SetGLError(GL_INVALID_OPERATION, "glReadPixels", "pixels = NULL"); 2539 SetGLError(GL_INVALID_OPERATION, "glReadPixels", "pixels = NULL");
2212 return; 2540 return;
2213 } 2541 }
2214 2542
2215 // Transfer by rows. 2543 // Transfer by rows.
2216 // The max rows we can transfer. 2544 // The max rows we can transfer.
2217 while (height) { 2545 while (height) {
2218 GLsizei desired_size = padded_row_size * height - 1 + unpadded_row_size; 2546 GLsizei desired_size = padded_row_size * (height - 1) + unpadded_row_size;
2219 ScopedTransferBufferPtr buffer(desired_size, helper_, transfer_buffer_); 2547 ScopedTransferBufferPtr buffer(desired_size, helper_, transfer_buffer_);
2220 if (!buffer.valid()) { 2548 if (!buffer.valid()) {
2221 return; 2549 return;
2222 } 2550 }
2223 GLint num_rows = ComputeNumRowsThatFitInBuffer( 2551 GLint num_rows = ComputeNumRowsThatFitInBuffer(
2224 padded_row_size, unpadded_row_size, buffer.size()); 2552 padded_row_size, unpadded_row_size, buffer.size(), height);
2225 num_rows = std::min(num_rows, height); 2553 num_rows = std::min(num_rows, height);
2226 // NOTE: We must look up the address of the result area AFTER allocation 2554 // NOTE: We must look up the address of the result area AFTER allocation
2227 // of the transfer buffer since the transfer buffer may be reallocated. 2555 // of the transfer buffer since the transfer buffer may be reallocated.
2228 Result* result = GetResultAs<Result*>(); 2556 Result* result = GetResultAs<Result*>();
2229 if (!result) { 2557 if (!result) {
2230 return; 2558 return;
2231 } 2559 }
2232 *result = 0; // mark as failed. 2560 *result = 0; // mark as failed.
2233 helper_->ReadPixels( 2561 helper_->ReadPixels(
2234 xoffset, yoffset, width, num_rows, format, type, 2562 xoffset, yoffset, width, num_rows, format, type,
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
2979 } 3307 }
2980 // NOTE: target is NOT checked because the service will check it 3308 // NOTE: target is NOT checked because the service will check it
2981 // and we don't know what targets are valid. 3309 // and we don't know what targets are valid.
2982 if (level < 0 || xoffset < 0 || yoffset < 0 || width < 0 || height < 0) { 3310 if (level < 0 || xoffset < 0 || yoffset < 0 || width < 0 || height < 0) {
2983 SetGLError( 3311 SetGLError(
2984 GL_INVALID_VALUE, "glMapTexSubImage2DCHROMIUM", "bad dimensions"); 3312 GL_INVALID_VALUE, "glMapTexSubImage2DCHROMIUM", "bad dimensions");
2985 return NULL; 3313 return NULL;
2986 } 3314 }
2987 uint32 size; 3315 uint32 size;
2988 if (!GLES2Util::ComputeImageDataSizes( 3316 if (!GLES2Util::ComputeImageDataSizes(
2989 width, height, format, type, unpack_alignment_, &size, NULL, NULL)) { 3317 width, height, 1, format, type, unpack_alignment_, &size, NULL, NULL)) {
2990 SetGLError( 3318 SetGLError(
2991 GL_INVALID_VALUE, "glMapTexSubImage2DCHROMIUM", "image size too large"); 3319 GL_INVALID_VALUE, "glMapTexSubImage2DCHROMIUM", "image size too large");
2992 return NULL; 3320 return NULL;
2993 } 3321 }
2994 int32 shm_id; 3322 int32 shm_id;
2995 unsigned int shm_offset; 3323 unsigned int shm_offset;
2996 void* mem = mapped_memory_->Alloc(size, &shm_id, &shm_offset); 3324 void* mem = mapped_memory_->Alloc(size, &shm_id, &shm_offset);
2997 if (!mem) { 3325 if (!mem) {
2998 SetGLError(GL_OUT_OF_MEMORY, "glMapTexSubImage2DCHROMIUM", "out of memory"); 3326 SetGLError(GL_OUT_OF_MEMORY, "glMapTexSubImage2DCHROMIUM", "out of memory");
2999 return NULL; 3327 return NULL;
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
3523 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glPopGroupMarkerEXT()"); 3851 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glPopGroupMarkerEXT()");
3524 helper_->PopGroupMarkerEXT(); 3852 helper_->PopGroupMarkerEXT();
3525 debug_marker_manager_.PopGroup(); 3853 debug_marker_manager_.PopGroup();
3526 } 3854 }
3527 3855
3528 void GLES2Implementation::TraceBeginCHROMIUM( 3856 void GLES2Implementation::TraceBeginCHROMIUM(
3529 const char* category_name, const char* trace_name) { 3857 const char* category_name, const char* trace_name) {
3530 GPU_CLIENT_SINGLE_THREAD_CHECK(); 3858 GPU_CLIENT_SINGLE_THREAD_CHECK();
3531 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glTraceBeginCHROMIUM(" 3859 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glTraceBeginCHROMIUM("
3532 << category_name << ", " << trace_name << ")"); 3860 << category_name << ", " << trace_name << ")");
3533 if (current_trace_category_.get() || current_trace_name_.get()) {
3534 SetGLError(GL_INVALID_OPERATION, "glTraceBeginCHROMIUM",
3535 "trace already running");
3536 return;
3537 }
3538 TRACE_EVENT_COPY_ASYNC_BEGIN0(category_name, trace_name, this);
3539 SetBucketAsCString(kResultBucketId, category_name); 3861 SetBucketAsCString(kResultBucketId, category_name);
3540 SetBucketAsCString(kResultBucketId + 1, category_name); 3862 SetBucketAsCString(kResultBucketId + 1, trace_name);
3541 helper_->TraceBeginCHROMIUM(kResultBucketId, kResultBucketId + 1); 3863 helper_->TraceBeginCHROMIUM(kResultBucketId, kResultBucketId + 1);
3542 helper_->SetBucketSize(kResultBucketId, 0); 3864 helper_->SetBucketSize(kResultBucketId, 0);
3543 helper_->SetBucketSize(kResultBucketId + 1, 0); 3865 helper_->SetBucketSize(kResultBucketId + 1, 0);
3544 current_trace_category_.reset(new std::string(category_name)); 3866 current_trace_stack_++;
3545 current_trace_name_.reset(new std::string(trace_name));
3546 } 3867 }
3547 3868
3548 void GLES2Implementation::TraceEndCHROMIUM() { 3869 void GLES2Implementation::TraceEndCHROMIUM() {
3549 GPU_CLIENT_SINGLE_THREAD_CHECK(); 3870 GPU_CLIENT_SINGLE_THREAD_CHECK();
3550 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glTraceEndCHROMIUM(" << ")"); 3871 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glTraceEndCHROMIUM(" << ")");
3551 if (!current_trace_category_.get() || !current_trace_name_.get()) { 3872 if (current_trace_stack_ == 0) {
3552 SetGLError(GL_INVALID_OPERATION, "glTraceEndCHROMIUM", 3873 SetGLError(GL_INVALID_OPERATION, "glTraceEndCHROMIUM",
3553 "missing begin trace"); 3874 "missing begin trace");
3554 return; 3875 return;
3555 } 3876 }
3556 helper_->TraceEndCHROMIUM(); 3877 helper_->TraceEndCHROMIUM();
3557 TRACE_EVENT_COPY_ASYNC_END0(current_trace_category_->c_str(), 3878 current_trace_stack_--;
3558 current_trace_name_->c_str(), this);
3559 current_trace_category_.reset();
3560 current_trace_name_.reset();
3561 } 3879 }
3562 3880
3563 void* GLES2Implementation::MapBufferCHROMIUM(GLuint target, GLenum access) { 3881 void* GLES2Implementation::MapBufferCHROMIUM(GLuint target, GLenum access) {
3564 GPU_CLIENT_SINGLE_THREAD_CHECK(); 3882 GPU_CLIENT_SINGLE_THREAD_CHECK();
3565 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glMapBufferCHROMIUM(" 3883 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glMapBufferCHROMIUM("
3566 << target << ", " << GLES2Util::GetStringEnum(access) << ")"); 3884 << target << ", " << GLES2Util::GetStringEnum(access) << ")");
3567 switch (target) { 3885 switch (target) {
3568 case GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM: 3886 case GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM:
3569 if (access != GL_READ_ONLY) { 3887 if (access != GL_READ_ONLY) {
3570 SetGLError(GL_INVALID_ENUM, "glMapBufferCHROMIUM", "bad access mode"); 3888 SetGLError(GL_INVALID_ENUM, "glMapBufferCHROMIUM", "bad access mode");
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
3720 return; 4038 return;
3721 } 4039 }
3722 if (border != 0) { 4040 if (border != 0) {
3723 SetGLError(GL_INVALID_VALUE, "glTexImage2D", "border != 0"); 4041 SetGLError(GL_INVALID_VALUE, "glTexImage2D", "border != 0");
3724 return; 4042 return;
3725 } 4043 }
3726 uint32 size; 4044 uint32 size;
3727 uint32 unpadded_row_size; 4045 uint32 unpadded_row_size;
3728 uint32 padded_row_size; 4046 uint32 padded_row_size;
3729 if (!GLES2Util::ComputeImageDataSizes( 4047 if (!GLES2Util::ComputeImageDataSizes(
3730 width, height, format, type, unpack_alignment_, &size, 4048 width, height, 1, format, type, unpack_alignment_, &size,
3731 &unpadded_row_size, &padded_row_size)) { 4049 &unpadded_row_size, &padded_row_size)) {
3732 SetGLError(GL_INVALID_VALUE, "glTexImage2D", "image size too large"); 4050 SetGLError(GL_INVALID_VALUE, "glTexImage2D", "image size too large");
3733 return; 4051 return;
3734 } 4052 }
3735 4053
3736 // If there's no data/buffer just issue the AsyncTexImage2D 4054 // If there's no data/buffer just issue the AsyncTexImage2D
3737 if (!pixels && !bound_pixel_unpack_transfer_buffer_id_) { 4055 if (!pixels && !bound_pixel_unpack_transfer_buffer_id_) {
3738 helper_->AsyncTexImage2DCHROMIUM( 4056 helper_->AsyncTexImage2DCHROMIUM(
3739 target, level, internalformat, width, height, format, type, 4057 target, level, internalformat, width, height, format, type,
3740 0, 0, 0, 0, 0); 4058 0, 0, 0, 0, 0);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
3780 if (level < 0 || height < 0 || width < 0) { 4098 if (level < 0 || height < 0 || width < 0) {
3781 SetGLError( 4099 SetGLError(
3782 GL_INVALID_VALUE, "glAsyncTexSubImage2DCHROMIUM", "dimension < 0"); 4100 GL_INVALID_VALUE, "glAsyncTexSubImage2DCHROMIUM", "dimension < 0");
3783 return; 4101 return;
3784 } 4102 }
3785 4103
3786 uint32 size; 4104 uint32 size;
3787 uint32 unpadded_row_size; 4105 uint32 unpadded_row_size;
3788 uint32 padded_row_size; 4106 uint32 padded_row_size;
3789 if (!GLES2Util::ComputeImageDataSizes( 4107 if (!GLES2Util::ComputeImageDataSizes(
3790 width, height, format, type, unpack_alignment_, &size, 4108 width, height, 1, format, type, unpack_alignment_, &size,
3791 &unpadded_row_size, &padded_row_size)) { 4109 &unpadded_row_size, &padded_row_size)) {
3792 SetGLError( 4110 SetGLError(
3793 GL_INVALID_VALUE, "glAsyncTexSubImage2DCHROMIUM", "size to large"); 4111 GL_INVALID_VALUE, "glAsyncTexSubImage2DCHROMIUM", "size to large");
3794 return; 4112 return;
3795 } 4113 }
3796 4114
3797 if (!EnsureAsyncUploadSync()) { 4115 if (!EnsureAsyncUploadSync()) {
3798 SetGLError(GL_OUT_OF_MEMORY, "glTexImage2D", "out of memory"); 4116 SetGLError(GL_OUT_OF_MEMORY, "glTexImage2D", "out of memory");
3799 return; 4117 return;
3800 } 4118 }
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
4038 return false; 4356 return false;
4039 } 4357 }
4040 4358
4041 // Include the auto-generated part of this file. We split this because it means 4359 // Include the auto-generated part of this file. We split this because it means
4042 // we can easily edit the non-auto generated parts right here in this file 4360 // we can easily edit the non-auto generated parts right here in this file
4043 // instead of having to edit some template or the code generator. 4361 // instead of having to edit some template or the code generator.
4044 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" 4362 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h"
4045 4363
4046 } // namespace gles2 4364 } // namespace gles2
4047 } // namespace gpu 4365 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/gles2_implementation.h ('k') | gpu/command_buffer/client/gles2_implementation_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698