OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 9 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); | 96 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); |
97 EXPECT_FALSE( | 97 EXPECT_FALSE( |
98 texture->GetLevelSize(GL_TEXTURE_2D, 2, &width, &height, nullptr)); | 98 texture->GetLevelSize(GL_TEXTURE_2D, 2, &width, &height, nullptr)); |
99 } | 99 } |
100 | 100 |
101 TEST_P(GLES2DecoderTest, GenerateMipmapClearsUnclearedTexture) { | 101 TEST_P(GLES2DecoderTest, GenerateMipmapClearsUnclearedTexture) { |
102 EXPECT_CALL(*gl_, GenerateMipmapEXT(_)).Times(0); | 102 EXPECT_CALL(*gl_, GenerateMipmapEXT(_)).Times(0); |
103 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 103 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
104 DoTexImage2D( | 104 DoTexImage2D( |
105 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); | 105 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
106 SetupClearTextureExpectations(kServiceTextureId, | 106 SetupClearTextureExpectations(kServiceTextureId, kServiceTextureId, |
107 kServiceTextureId, | 107 GL_TEXTURE_2D, GL_TEXTURE_2D, 0, GL_RGBA, |
108 GL_TEXTURE_2D, | 108 GL_RGBA, GL_UNSIGNED_BYTE, 0, 0, 2, 2); |
109 GL_TEXTURE_2D, | |
110 0, | |
111 GL_RGBA, | |
112 GL_RGBA, | |
113 GL_UNSIGNED_BYTE, | |
114 2, | |
115 2); | |
116 EXPECT_CALL(*gl_, GenerateMipmapEXT(GL_TEXTURE_2D)); | 109 EXPECT_CALL(*gl_, GenerateMipmapEXT(GL_TEXTURE_2D)); |
117 EXPECT_CALL(*gl_, GetError()) | 110 EXPECT_CALL(*gl_, GetError()) |
118 .WillOnce(Return(GL_NO_ERROR)) | 111 .WillOnce(Return(GL_NO_ERROR)) |
119 .WillOnce(Return(GL_NO_ERROR)) | 112 .WillOnce(Return(GL_NO_ERROR)) |
120 .RetiresOnSaturation(); | 113 .RetiresOnSaturation(); |
121 GenerateMipmap cmd; | 114 GenerateMipmap cmd; |
122 cmd.Init(GL_TEXTURE_2D); | 115 cmd.Init(GL_TEXTURE_2D); |
123 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 116 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
124 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 117 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
125 } | 118 } |
126 | 119 |
127 // Same as GenerateMipmapClearsUnclearedTexture, but with workaround | 120 // Same as GenerateMipmapClearsUnclearedTexture, but with workaround |
128 // |set_texture_filters_before_generating_mipmap|. | 121 // |set_texture_filters_before_generating_mipmap|. |
129 TEST_P(GLES2DecoderManualInitTest, SetTextureFiltersBeforeGenerateMipmap) { | 122 TEST_P(GLES2DecoderManualInitTest, SetTextureFiltersBeforeGenerateMipmap) { |
130 base::CommandLine command_line(0, NULL); | 123 base::CommandLine command_line(0, NULL); |
131 command_line.AppendSwitchASCII( | 124 command_line.AppendSwitchASCII( |
132 switches::kGpuDriverBugWorkarounds, | 125 switches::kGpuDriverBugWorkarounds, |
133 base::IntToString(gpu::SET_TEXTURE_FILTER_BEFORE_GENERATING_MIPMAP)); | 126 base::IntToString(gpu::SET_TEXTURE_FILTER_BEFORE_GENERATING_MIPMAP)); |
134 InitState init; | 127 InitState init; |
135 init.bind_generates_resource = true; | 128 init.bind_generates_resource = true; |
136 InitDecoderWithCommandLine(init, &command_line); | 129 InitDecoderWithCommandLine(init, &command_line); |
137 | 130 |
138 EXPECT_CALL(*gl_, GenerateMipmapEXT(_)).Times(0); | 131 EXPECT_CALL(*gl_, GenerateMipmapEXT(_)).Times(0); |
139 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 132 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
140 DoTexImage2D( | 133 DoTexImage2D( |
141 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); | 134 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
142 SetupClearTextureExpectations(kServiceTextureId, | 135 SetupClearTextureExpectations(kServiceTextureId, kServiceTextureId, |
143 kServiceTextureId, | 136 GL_TEXTURE_2D, GL_TEXTURE_2D, 0, GL_RGBA, |
144 GL_TEXTURE_2D, | 137 GL_RGBA, GL_UNSIGNED_BYTE, 0, 0, 2, 2); |
145 GL_TEXTURE_2D, | |
146 0, | |
147 GL_RGBA, | |
148 GL_RGBA, | |
149 GL_UNSIGNED_BYTE, | |
150 2, | |
151 2); | |
152 EXPECT_CALL( | 138 EXPECT_CALL( |
153 *gl_, | 139 *gl_, |
154 TexParameteri( | 140 TexParameteri( |
155 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST)) | 141 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST)) |
156 .Times(1) | 142 .Times(1) |
157 .RetiresOnSaturation(); | 143 .RetiresOnSaturation(); |
158 EXPECT_CALL(*gl_, GenerateMipmapEXT(GL_TEXTURE_2D)); | 144 EXPECT_CALL(*gl_, GenerateMipmapEXT(GL_TEXTURE_2D)); |
159 EXPECT_CALL( | 145 EXPECT_CALL( |
160 *gl_, | 146 *gl_, |
161 TexParameteri( | 147 TexParameteri( |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 cmd.Init(GL_TEXTURE_2D, | 490 cmd.Init(GL_TEXTURE_2D, |
505 0, | 491 0, |
506 GL_RGBA, | 492 GL_RGBA, |
507 kWidth, | 493 kWidth, |
508 kHeight, | 494 kHeight, |
509 GL_RGBA, | 495 GL_RGBA, |
510 GL_UNSIGNED_BYTE, | 496 GL_UNSIGNED_BYTE, |
511 kSharedMemoryId, | 497 kSharedMemoryId, |
512 kSharedMemoryOffset); | 498 kSharedMemoryOffset); |
513 } else { | 499 } else { |
514 SetupClearTextureExpectations(kServiceTextureId, | |
515 kServiceTextureId, | |
516 GL_TEXTURE_2D, | |
517 GL_TEXTURE_2D, | |
518 0, | |
519 GL_RGBA, | |
520 GL_RGBA, | |
521 GL_UNSIGNED_BYTE, | |
522 kWidth, | |
523 kHeight); | |
524 cmd.Init(GL_TEXTURE_2D, | 500 cmd.Init(GL_TEXTURE_2D, |
525 0, | 501 0, |
526 GL_RGBA, | 502 GL_RGBA, |
527 kWidth, | 503 kWidth, |
528 kHeight, | 504 kHeight, |
529 GL_RGBA, | 505 GL_RGBA, |
530 GL_UNSIGNED_BYTE, | 506 GL_UNSIGNED_BYTE, |
531 0, | 507 0, |
532 0); | 508 0); |
533 } | 509 } |
(...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1769 init.gl_version = "opengl es 2.0"; | 1745 init.gl_version = "opengl es 2.0"; |
1770 init.has_alpha = true; | 1746 init.has_alpha = true; |
1771 init.has_depth = true; | 1747 init.has_depth = true; |
1772 init.request_alpha = true; | 1748 init.request_alpha = true; |
1773 init.request_depth = true; | 1749 init.request_depth = true; |
1774 InitDecoder(init); | 1750 InitDecoder(init); |
1775 | 1751 |
1776 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 1752 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
1777 DoTexImage2D( | 1753 DoTexImage2D( |
1778 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); | 1754 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
1779 SetupClearTextureExpectations(kServiceTextureId, | 1755 SetupClearTextureExpectations(kServiceTextureId, kServiceTextureId, |
1780 kServiceTextureId, | 1756 GL_TEXTURE_2D, GL_TEXTURE_2D, 0, GL_RGBA, |
1781 GL_TEXTURE_2D, | 1757 GL_RGBA, GL_UNSIGNED_BYTE, 0, 1, 2, 1); |
1782 GL_TEXTURE_2D, | 1758 EXPECT_CALL(*gl_, TexSubImage2D(GL_TEXTURE_2D, 0, 0, _, _, 1, GL_RGBA, |
1783 0, | 1759 GL_UNSIGNED_BYTE, shared_memory_address_)) |
1784 GL_RGBA, | 1760 .Times(2) |
1785 GL_RGBA, | |
1786 GL_UNSIGNED_BYTE, | |
1787 2, | |
1788 2); | |
1789 EXPECT_CALL(*gl_, | |
1790 TexSubImage2D(GL_TEXTURE_2D, | |
1791 0, | |
1792 1, | |
1793 1, | |
1794 1, | |
1795 1, | |
1796 GL_RGBA, | |
1797 GL_UNSIGNED_BYTE, | |
1798 shared_memory_address_)) | |
1799 .Times(1) | |
1800 .RetiresOnSaturation(); | 1761 .RetiresOnSaturation(); |
1801 TexSubImage2D cmd; | 1762 TexSubImage2D cmd; |
1802 cmd.Init(GL_TEXTURE_2D, | 1763 cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 2, 1, GL_RGBA, GL_UNSIGNED_BYTE, |
1803 0, | 1764 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); |
1804 1, | 1765 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
1805 1, | 1766 cmd.Init(GL_TEXTURE_2D, 0, 0, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, |
1806 1, | 1767 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); |
1807 1, | |
1808 GL_RGBA, | |
1809 GL_UNSIGNED_BYTE, | |
1810 kSharedMemoryId, | |
1811 kSharedMemoryOffset, | |
1812 GL_FALSE); | |
1813 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 1768 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
1814 // Test if we call it again it does not clear. | 1769 // Test if we call it again it does not clear. |
1815 EXPECT_CALL(*gl_, | 1770 EXPECT_CALL(*gl_, TexSubImage2D(GL_TEXTURE_2D, 0, 0, 1, 1, 1, GL_RGBA, |
1816 TexSubImage2D(GL_TEXTURE_2D, | 1771 GL_UNSIGNED_BYTE, shared_memory_address_)) |
1817 0, | |
1818 1, | |
1819 1, | |
1820 1, | |
1821 1, | |
1822 GL_RGBA, | |
1823 GL_UNSIGNED_BYTE, | |
1824 shared_memory_address_)) | |
1825 .Times(1) | 1772 .Times(1) |
1826 .RetiresOnSaturation(); | 1773 .RetiresOnSaturation(); |
1827 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 1774 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
1828 } | 1775 } |
1829 | 1776 |
1830 TEST_P(GLES2DecoderTest, TexSubImage2DDoesNotClearAfterTexImage2DNULLThenData) { | 1777 TEST_P(GLES2DecoderTest, TexSubImage2DDoesNotClearAfterTexImage2DNULLThenData) { |
1831 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 1778 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
1832 DoTexImage2D( | 1779 DoTexImage2D( |
1833 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); | 1780 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
1834 DoTexImage2D(GL_TEXTURE_2D, | 1781 DoTexImage2D(GL_TEXTURE_2D, |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1971 GL_UNSIGNED_BYTE, | 1918 GL_UNSIGNED_BYTE, |
1972 kSharedMemoryId, | 1919 kSharedMemoryId, |
1973 kSharedMemoryOffset); | 1920 kSharedMemoryOffset); |
1974 // Put in no data. | 1921 // Put in no data. |
1975 TexImage2D tex_cmd; | 1922 TexImage2D tex_cmd; |
1976 tex_cmd.Init( | 1923 tex_cmd.Init( |
1977 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); | 1924 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
1978 // It won't actually call TexImage2D, just mark it as uncleared. | 1925 // It won't actually call TexImage2D, just mark it as uncleared. |
1979 EXPECT_EQ(error::kNoError, ExecuteCmd(tex_cmd)); | 1926 EXPECT_EQ(error::kNoError, ExecuteCmd(tex_cmd)); |
1980 // Next call to TexSubImage2d should clear. | 1927 // Next call to TexSubImage2d should clear. |
1981 SetupClearTextureExpectations(kServiceTextureId, | 1928 SetupClearTextureExpectations(kServiceTextureId, kServiceTextureId, |
1982 kServiceTextureId, | 1929 GL_TEXTURE_2D, GL_TEXTURE_2D, 0, GL_RGBA, |
1983 GL_TEXTURE_2D, | 1930 GL_RGBA, GL_UNSIGNED_BYTE, 0, 1, 2, 1); |
1984 GL_TEXTURE_2D, | 1931 EXPECT_CALL(*gl_, TexSubImage2D(GL_TEXTURE_2D, 0, 0, _, _, 1, GL_RGBA, |
1985 0, | 1932 GL_UNSIGNED_BYTE, shared_memory_address_)) |
1986 GL_RGBA, | 1933 .Times(2) |
1987 GL_RGBA, | |
1988 GL_UNSIGNED_BYTE, | |
1989 2, | |
1990 2); | |
1991 EXPECT_CALL(*gl_, | |
1992 TexSubImage2D(GL_TEXTURE_2D, | |
1993 0, | |
1994 1, | |
1995 1, | |
1996 1, | |
1997 1, | |
1998 GL_RGBA, | |
1999 GL_UNSIGNED_BYTE, | |
2000 shared_memory_address_)) | |
2001 .Times(1) | |
2002 .RetiresOnSaturation(); | 1934 .RetiresOnSaturation(); |
2003 TexSubImage2D cmd; | 1935 TexSubImage2D cmd; |
2004 cmd.Init(GL_TEXTURE_2D, | 1936 cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 2, 1, GL_RGBA, GL_UNSIGNED_BYTE, |
2005 0, | 1937 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); |
2006 1, | 1938 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
2007 1, | 1939 cmd.Init(GL_TEXTURE_2D, 0, 0, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, |
2008 1, | 1940 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); |
2009 1, | |
2010 GL_RGBA, | |
2011 GL_UNSIGNED_BYTE, | |
2012 kSharedMemoryId, | |
2013 kSharedMemoryOffset, | |
2014 GL_FALSE); | |
2015 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 1941 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
2016 } | 1942 } |
2017 | 1943 |
2018 TEST_P(GLES2DecoderTest, CopyTexImage2DMarksTextureAsCleared) { | 1944 TEST_P(GLES2DecoderTest, CopyTexImage2DMarksTextureAsCleared) { |
2019 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 1945 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
2020 | 1946 |
2021 TextureManager* manager = group().texture_manager(); | 1947 TextureManager* manager = group().texture_manager(); |
2022 TextureRef* texture_ref = manager->GetTexture(client_texture_id_); | 1948 TextureRef* texture_ref = manager->GetTexture(client_texture_id_); |
2023 ASSERT_TRUE(texture_ref != NULL); | 1949 ASSERT_TRUE(texture_ref != NULL); |
2024 Texture* texture = texture_ref->texture(); | 1950 Texture* texture = texture_ref->texture(); |
2025 | 1951 |
2026 EXPECT_CALL(*gl_, GetError()) | 1952 EXPECT_CALL(*gl_, GetError()) |
2027 .WillOnce(Return(GL_NO_ERROR)) | 1953 .WillOnce(Return(GL_NO_ERROR)) |
2028 .RetiresOnSaturation(); | 1954 .RetiresOnSaturation(); |
2029 EXPECT_CALL(*gl_, CopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 1, 1, 0)) | 1955 EXPECT_CALL(*gl_, CopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 1, 1, 0)) |
2030 .Times(1) | 1956 .Times(1) |
2031 .RetiresOnSaturation(); | 1957 .RetiresOnSaturation(); |
2032 EXPECT_CALL(*gl_, GetError()) | 1958 EXPECT_CALL(*gl_, GetError()) |
2033 .WillOnce(Return(GL_NO_ERROR)) | 1959 .WillOnce(Return(GL_NO_ERROR)) |
2034 .RetiresOnSaturation(); | 1960 .RetiresOnSaturation(); |
2035 CopyTexImage2D cmd; | 1961 CopyTexImage2D cmd; |
2036 cmd.Init(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 1, 1); | 1962 cmd.Init(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 1, 1); |
2037 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 1963 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
2038 | 1964 |
2039 EXPECT_TRUE(texture->SafeToRenderFrom()); | 1965 EXPECT_TRUE(texture->SafeToRenderFrom()); |
2040 } | 1966 } |
2041 | 1967 |
2042 TEST_P(GLES2DecoderTest, CopyTexSubImage2DClearsUnclearedTexture) { | 1968 TEST_P(GLES2DecoderTest, CopyTexSubImage2DTwiceMarksTextureAsCleared) { |
2043 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 1969 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
2044 DoTexImage2D( | 1970 DoTexImage2D( |
2045 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); | 1971 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
2046 | 1972 |
2047 SetupClearTextureExpectations(kServiceTextureId, | 1973 // This will initialize the top part. |
2048 kServiceTextureId, | 1974 { |
2049 GL_TEXTURE_2D, | 1975 EXPECT_CALL(*gl_, CopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 2, 1)) |
2050 GL_TEXTURE_2D, | 1976 .Times(1) |
2051 0, | 1977 .RetiresOnSaturation(); |
2052 GL_RGBA, | 1978 CopyTexSubImage2D cmd; |
2053 GL_RGBA, | 1979 cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 2, 1); |
2054 GL_UNSIGNED_BYTE, | 1980 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
2055 2, | 1981 } |
2056 2); | 1982 |
2057 EXPECT_CALL(*gl_, CopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 1, 1)) | 1983 // This will initialize the bottom part. |
2058 .Times(1) | 1984 { |
2059 .RetiresOnSaturation(); | 1985 EXPECT_CALL(*gl_, CopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 1, 0, 0, 2, 1)) |
2060 CopyTexSubImage2D cmd; | 1986 .Times(1) |
2061 cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 1, 1); | 1987 .RetiresOnSaturation(); |
2062 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 1988 CopyTexSubImage2D cmd; |
| 1989 cmd.Init(GL_TEXTURE_2D, 0, 0, 1, 0, 0, 2, 1); |
| 1990 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1991 } |
2063 | 1992 |
2064 TextureManager* manager = group().texture_manager(); | 1993 TextureManager* manager = group().texture_manager(); |
2065 TextureRef* texture_ref = manager->GetTexture(client_texture_id_); | 1994 TextureRef* texture_ref = manager->GetTexture(client_texture_id_); |
| 1995 ASSERT_TRUE(texture_ref != NULL); |
| 1996 Texture* texture = texture_ref->texture(); |
| 1997 EXPECT_TRUE(texture->SafeToRenderFrom()); |
| 1998 } |
| 1999 |
| 2000 TEST_P(GLES2DecoderTest, CopyTexSubImage2DTwiceClearsUnclearedTexture) { |
| 2001 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 2002 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, |
| 2003 0); |
| 2004 |
| 2005 // This will initialize the top part. |
| 2006 { |
| 2007 EXPECT_CALL(*gl_, CopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 2, 1)) |
| 2008 .Times(1) |
| 2009 .RetiresOnSaturation(); |
| 2010 CopyTexSubImage2D cmd; |
| 2011 cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 2, 1); |
| 2012 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 2013 } |
| 2014 |
| 2015 SetupClearTextureExpectations(kServiceTextureId, kServiceTextureId, |
| 2016 GL_TEXTURE_2D, GL_TEXTURE_2D, 0, GL_RGBA, |
| 2017 GL_RGBA, GL_UNSIGNED_BYTE, 0, 1, 2, 1); |
| 2018 |
| 2019 // This will clear the bottom part as a rectangle is not sufficient to keep |
| 2020 // track of the initialized area. |
| 2021 { |
| 2022 EXPECT_CALL(*gl_, CopyTexSubImage2D(GL_TEXTURE_2D, 0, 1, 1, 0, 0, 1, 1)) |
| 2023 .Times(1) |
| 2024 .RetiresOnSaturation(); |
| 2025 CopyTexSubImage2D cmd; |
| 2026 cmd.Init(GL_TEXTURE_2D, 0, 1, 1, 0, 0, 1, 1); |
| 2027 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 2028 } |
| 2029 |
| 2030 TextureManager* manager = group().texture_manager(); |
| 2031 TextureRef* texture_ref = manager->GetTexture(client_texture_id_); |
2066 ASSERT_TRUE(texture_ref != NULL); | 2032 ASSERT_TRUE(texture_ref != NULL); |
2067 Texture* texture = texture_ref->texture(); | 2033 Texture* texture = texture_ref->texture(); |
2068 EXPECT_TRUE(texture->SafeToRenderFrom()); | 2034 EXPECT_TRUE(texture->SafeToRenderFrom()); |
2069 } | 2035 } |
2070 | 2036 |
2071 TEST_P(GLES2DecoderTest, CopyTexSubImage2DClearsUnclearedBackBufferSizedTexture)
{ | 2037 TEST_P(GLES2DecoderTest, CopyTexSubImage2DClearsUnclearedBackBufferSizedTexture)
{ |
2072 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 2038 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
2073 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kBackBufferWidth, kBackBufferHeight, | 2039 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kBackBufferWidth, kBackBufferHeight, |
2074 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); | 2040 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
2075 | 2041 |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2673 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == image.get()); | 2639 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == image.get()); |
2674 | 2640 |
2675 // ClearLevel should use glTexSubImage2D to avoid unbinding GLImage. | 2641 // ClearLevel should use glTexSubImage2D to avoid unbinding GLImage. |
2676 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId)) | 2642 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId)) |
2677 .Times(2) | 2643 .Times(2) |
2678 .RetiresOnSaturation(); | 2644 .RetiresOnSaturation(); |
2679 EXPECT_CALL(*gl_, TexSubImage2D(target, level, xoffset, yoffset, width, | 2645 EXPECT_CALL(*gl_, TexSubImage2D(target, level, xoffset, yoffset, width, |
2680 height, format, type, _)) | 2646 height, format, type, _)) |
2681 .Times(1) | 2647 .Times(1) |
2682 .RetiresOnSaturation(); | 2648 .RetiresOnSaturation(); |
2683 GetDecoder()->ClearLevel(texture, target, level, format, format, type, width, | 2649 GetDecoder()->ClearLevel(texture, target, level, format, type, 0, 0, width, |
2684 height, false); | 2650 height); |
2685 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == image.get()); | 2651 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == image.get()); |
2686 } | 2652 } |
2687 | 2653 |
2688 TEST_P(GLES2DecoderTest, ReleaseTexImage2DCHROMIUM) { | 2654 TEST_P(GLES2DecoderTest, ReleaseTexImage2DCHROMIUM) { |
2689 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 2655 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
2690 DoTexImage2D( | 2656 DoTexImage2D( |
2691 GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); | 2657 GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
2692 TextureRef* texture_ref = | 2658 TextureRef* texture_ref = |
2693 group().texture_manager()->GetTexture(client_texture_id_); | 2659 group().texture_manager()->GetTexture(client_texture_id_); |
2694 ASSERT_TRUE(texture_ref != NULL); | 2660 ASSERT_TRUE(texture_ref != NULL); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2888 init.has_alpha = true; | 2854 init.has_alpha = true; |
2889 init.has_depth = true; | 2855 init.has_depth = true; |
2890 init.request_alpha = true; | 2856 init.request_alpha = true; |
2891 init.request_depth = true; | 2857 init.request_depth = true; |
2892 init.bind_generates_resource = true; | 2858 init.bind_generates_resource = true; |
2893 InitDecoder(init); | 2859 InitDecoder(init); |
2894 | 2860 |
2895 TextureRef* texture_ref = GetTexture(client_texture_id_); | 2861 TextureRef* texture_ref = GetTexture(client_texture_id_); |
2896 scoped_refptr<MockGLImage> image(new MockGLImage); | 2862 scoped_refptr<MockGLImage> image(new MockGLImage); |
2897 group().texture_manager()->SetTarget(texture_ref, GL_TEXTURE_EXTERNAL_OES); | 2863 group().texture_manager()->SetTarget(texture_ref, GL_TEXTURE_EXTERNAL_OES); |
2898 group().texture_manager()->SetLevelInfo(texture_ref, | 2864 group().texture_manager()->SetLevelInfo(texture_ref, GL_TEXTURE_EXTERNAL_OES, |
2899 GL_TEXTURE_EXTERNAL_OES, | 2865 0, GL_RGBA, 0, 0, 1, 0, GL_RGBA, |
2900 0, | 2866 GL_UNSIGNED_BYTE, gfx::Rect()); |
2901 GL_RGBA, | |
2902 0, | |
2903 0, | |
2904 1, | |
2905 0, | |
2906 GL_RGBA, | |
2907 GL_UNSIGNED_BYTE, | |
2908 true); | |
2909 group().texture_manager()->SetLevelImage( | 2867 group().texture_manager()->SetLevelImage( |
2910 texture_ref, GL_TEXTURE_EXTERNAL_OES, 0, image.get()); | 2868 texture_ref, GL_TEXTURE_EXTERNAL_OES, 0, image.get()); |
2911 | 2869 |
2912 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); | 2870 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); |
2913 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 2871 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
2914 | 2872 |
2915 SetupSamplerExternalProgram(); | 2873 SetupSamplerExternalProgram(); |
2916 SetupIndexBuffer(); | 2874 SetupIndexBuffer(); |
2917 AddExpectationsForSimulatedAttrib0(kMaxValidIndex + 1, 0); | 2875 AddExpectationsForSimulatedAttrib0(kMaxValidIndex + 1, 0); |
2918 SetupExpectationsForApplyingDefaultDirtyState(); | 2876 SetupExpectationsForApplyingDefaultDirtyState(); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3051 DoTexImage2D(GL_TEXTURE_2D, | 3009 DoTexImage2D(GL_TEXTURE_2D, |
3052 0, | 3010 0, |
3053 GL_RGBA32F, | 3011 GL_RGBA32F, |
3054 kWidth, | 3012 kWidth, |
3055 kHeight, | 3013 kHeight, |
3056 0, | 3014 0, |
3057 GL_RGBA, | 3015 GL_RGBA, |
3058 GL_FLOAT, | 3016 GL_FLOAT, |
3059 0, | 3017 0, |
3060 0); | 3018 0); |
3061 SetupClearTextureExpectations(kServiceTextureId, | 3019 SetupClearTextureExpectations(kServiceTextureId, kServiceTextureId, |
3062 kServiceTextureId, | 3020 GL_TEXTURE_2D, GL_TEXTURE_2D, 0, GL_RGBA32F, |
3063 GL_TEXTURE_2D, | 3021 GL_RGBA, GL_FLOAT, 0, kHeight - 1, kWidth, 1); |
3064 GL_TEXTURE_2D, | 3022 EXPECT_CALL(*gl_, TexSubImage2D(GL_TEXTURE_2D, 0, 0, _, _, _, GL_RGBA, |
3065 0, | 3023 GL_FLOAT, shared_memory_address_)) |
3066 GL_RGBA32F, | 3024 .Times(2) |
3067 GL_RGBA, | |
3068 GL_FLOAT, | |
3069 kWidth, | |
3070 kHeight); | |
3071 EXPECT_CALL(*gl_, | |
3072 TexSubImage2D(GL_TEXTURE_2D, | |
3073 0, | |
3074 1, | |
3075 0, | |
3076 kWidth - 1, | |
3077 kHeight, | |
3078 GL_RGBA, | |
3079 GL_FLOAT, | |
3080 shared_memory_address_)) | |
3081 .Times(1) | |
3082 .RetiresOnSaturation(); | 3025 .RetiresOnSaturation(); |
3083 TexSubImage2D cmd; | 3026 TexSubImage2D cmd; |
3084 cmd.Init(GL_TEXTURE_2D, | 3027 cmd.Init(GL_TEXTURE_2D, 0, 0, 0, kWidth, kHeight - 1, GL_RGBA, GL_FLOAT, |
3085 0, | 3028 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); |
3086 1, | 3029 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
3087 0, | 3030 cmd.Init(GL_TEXTURE_2D, 0, 0, kHeight - 1, kWidth - 1, 1, GL_RGBA, GL_FLOAT, |
3088 kWidth - 1, | 3031 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); |
3089 kHeight, | |
3090 GL_RGBA, | |
3091 GL_FLOAT, | |
3092 kSharedMemoryId, | |
3093 kSharedMemoryOffset, | |
3094 GL_FALSE); | |
3095 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 3032 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
3096 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 3033 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
3097 } | 3034 } |
3098 | 3035 |
3099 TEST_P(GLES2DecoderManualInitTest, TexImage2DFloatConvertsFormatDesktop) { | 3036 TEST_P(GLES2DecoderManualInitTest, TexImage2DFloatConvertsFormatDesktop) { |
3100 InitState init; | 3037 InitState init; |
3101 init.extensions = "GL_ARB_texture_float"; | 3038 init.extensions = "GL_ARB_texture_float"; |
3102 InitDecoder(init); | 3039 InitDecoder(init); |
3103 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 3040 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
3104 DoTexImage2D( | 3041 DoTexImage2D( |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3292 // TODO(gman): CompressedTexSubImage2DImmediate | 3229 // TODO(gman): CompressedTexSubImage2DImmediate |
3293 | 3230 |
3294 // TODO(gman): TexImage2D | 3231 // TODO(gman): TexImage2D |
3295 | 3232 |
3296 // TODO(gman): TexImage2DImmediate | 3233 // TODO(gman): TexImage2DImmediate |
3297 | 3234 |
3298 // TODO(gman): TexSubImage2DImmediate | 3235 // TODO(gman): TexSubImage2DImmediate |
3299 | 3236 |
3300 } // namespace gles2 | 3237 } // namespace gles2 |
3301 } // namespace gpu | 3238 } // namespace gpu |
OLD | NEW |