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 1802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1813 | 1813 |
1814 TEST_P(GLES2DecoderWithShaderTest, DrawArraysClearsAfterTexImage2DNULL) { | 1814 TEST_P(GLES2DecoderWithShaderTest, DrawArraysClearsAfterTexImage2DNULL) { |
1815 SetupAllNeededVertexBuffers(); | 1815 SetupAllNeededVertexBuffers(); |
1816 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 1816 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
1817 // Create an uncleared texture with 2 levels. | 1817 // Create an uncleared texture with 2 levels. |
1818 DoTexImage2D( | 1818 DoTexImage2D( |
1819 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); | 1819 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
1820 DoTexImage2D( | 1820 DoTexImage2D( |
1821 GL_TEXTURE_2D, 1, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); | 1821 GL_TEXTURE_2D, 1, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
1822 // Expect 2 levels will be cleared. | 1822 // Expect 2 levels will be cleared. |
1823 SetupClearTextureExpectations(kServiceTextureId, | 1823 SetupClearTextureExpectations(kServiceTextureId, kServiceTextureId, |
1824 kServiceTextureId, | 1824 GL_TEXTURE_2D, GL_TEXTURE_2D, 0, GL_RGBA, |
1825 GL_TEXTURE_2D, | 1825 GL_RGBA, GL_UNSIGNED_BYTE, 0, 0, 2, 2); |
1826 GL_TEXTURE_2D, | 1826 SetupClearTextureExpectations(kServiceTextureId, kServiceTextureId, |
1827 0, | 1827 GL_TEXTURE_2D, GL_TEXTURE_2D, 1, GL_RGBA, |
1828 GL_RGBA, | 1828 GL_RGBA, GL_UNSIGNED_BYTE, 0, 0, 1, 1); |
1829 GL_RGBA, | |
1830 GL_UNSIGNED_BYTE, | |
1831 2, | |
1832 2); | |
1833 SetupClearTextureExpectations(kServiceTextureId, | |
1834 kServiceTextureId, | |
1835 GL_TEXTURE_2D, | |
1836 GL_TEXTURE_2D, | |
1837 1, | |
1838 GL_RGBA, | |
1839 GL_RGBA, | |
1840 GL_UNSIGNED_BYTE, | |
1841 1, | |
1842 1); | |
1843 SetupExpectationsForApplyingDefaultDirtyState(); | 1829 SetupExpectationsForApplyingDefaultDirtyState(); |
1844 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | 1830 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) |
1845 .Times(1) | 1831 .Times(1) |
1846 .RetiresOnSaturation(); | 1832 .RetiresOnSaturation(); |
1847 DrawArrays cmd; | 1833 DrawArrays cmd; |
1848 cmd.Init(GL_TRIANGLES, 0, kNumVertices); | 1834 cmd.Init(GL_TRIANGLES, 0, kNumVertices); |
1849 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 1835 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
1850 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 1836 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
1851 | 1837 |
1852 // But not again | 1838 // But not again |
1853 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | 1839 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) |
1854 .Times(1) | 1840 .Times(1) |
1855 .RetiresOnSaturation(); | 1841 .RetiresOnSaturation(); |
1856 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 1842 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
1857 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 1843 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
1858 } | 1844 } |
1859 | 1845 |
1860 TEST_P(GLES2DecoderWithShaderTest, DrawElementsClearsAfterTexImage2DNULL) { | 1846 TEST_P(GLES2DecoderWithShaderTest, DrawElementsClearsAfterTexImage2DNULL) { |
1861 SetupAllNeededVertexBuffers(); | 1847 SetupAllNeededVertexBuffers(); |
1862 SetupIndexBuffer(); | 1848 SetupIndexBuffer(); |
1863 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 1849 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
1864 // Create an uncleared texture with 2 levels. | 1850 // Create an uncleared texture with 2 levels. |
1865 DoTexImage2D( | 1851 DoTexImage2D( |
1866 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); | 1852 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
1867 DoTexImage2D( | 1853 DoTexImage2D( |
1868 GL_TEXTURE_2D, 1, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); | 1854 GL_TEXTURE_2D, 1, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
1869 // Expect 2 levels will be cleared. | 1855 // Expect 2 levels will be cleared. |
1870 SetupClearTextureExpectations(kServiceTextureId, | 1856 SetupClearTextureExpectations(kServiceTextureId, kServiceTextureId, |
1871 kServiceTextureId, | 1857 GL_TEXTURE_2D, GL_TEXTURE_2D, 0, GL_RGBA, |
1872 GL_TEXTURE_2D, | 1858 GL_RGBA, GL_UNSIGNED_BYTE, 0, 0, 2, 2); |
1873 GL_TEXTURE_2D, | 1859 SetupClearTextureExpectations(kServiceTextureId, kServiceTextureId, |
1874 0, | 1860 GL_TEXTURE_2D, GL_TEXTURE_2D, 1, GL_RGBA, |
1875 GL_RGBA, | 1861 GL_RGBA, GL_UNSIGNED_BYTE, 0, 0, 1, 1); |
1876 GL_RGBA, | |
1877 GL_UNSIGNED_BYTE, | |
1878 2, | |
1879 2); | |
1880 SetupClearTextureExpectations(kServiceTextureId, | |
1881 kServiceTextureId, | |
1882 GL_TEXTURE_2D, | |
1883 GL_TEXTURE_2D, | |
1884 1, | |
1885 GL_RGBA, | |
1886 GL_RGBA, | |
1887 GL_UNSIGNED_BYTE, | |
1888 1, | |
1889 1); | |
1890 SetupExpectationsForApplyingDefaultDirtyState(); | 1862 SetupExpectationsForApplyingDefaultDirtyState(); |
1891 | 1863 |
1892 EXPECT_CALL(*gl_, | 1864 EXPECT_CALL(*gl_, |
1893 DrawElements(GL_TRIANGLES, | 1865 DrawElements(GL_TRIANGLES, |
1894 kValidIndexRangeCount, | 1866 kValidIndexRangeCount, |
1895 GL_UNSIGNED_SHORT, | 1867 GL_UNSIGNED_SHORT, |
1896 BufferOffset(kValidIndexRangeStart * 2))) | 1868 BufferOffset(kValidIndexRangeStart * 2))) |
1897 .Times(1) | 1869 .Times(1) |
1898 .RetiresOnSaturation(); | 1870 .RetiresOnSaturation(); |
1899 DrawElements cmd; | 1871 DrawElements cmd; |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2100 GL_RGBA, | 2072 GL_RGBA, |
2101 1, | 2073 1, |
2102 1, | 2074 1, |
2103 0, | 2075 0, |
2104 GL_RGBA, | 2076 GL_RGBA, |
2105 GL_UNSIGNED_BYTE, | 2077 GL_UNSIGNED_BYTE, |
2106 shm_id, | 2078 shm_id, |
2107 shm_offset); | 2079 shm_offset); |
2108 } | 2080 } |
2109 // Expect 2 levels will be cleared. | 2081 // Expect 2 levels will be cleared. |
2110 SetupClearTextureExpectations(kServiceTextureId, | 2082 SetupClearTextureExpectations(kServiceTextureId, kServiceTextureId, |
2111 kServiceTextureId, | |
2112 GL_TEXTURE_CUBE_MAP, | 2083 GL_TEXTURE_CUBE_MAP, |
2113 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, | 2084 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA, |
2114 0, | 2085 GL_RGBA, GL_UNSIGNED_BYTE, 0, 0, 2, 2); |
2115 GL_RGBA, | 2086 SetupClearTextureExpectations(kServiceTextureId, kServiceTextureId, |
2116 GL_RGBA, | |
2117 GL_UNSIGNED_BYTE, | |
2118 2, | |
2119 2); | |
2120 SetupClearTextureExpectations(kServiceTextureId, | |
2121 kServiceTextureId, | |
2122 GL_TEXTURE_CUBE_MAP, | 2087 GL_TEXTURE_CUBE_MAP, |
2123 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, | 2088 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 1, GL_RGBA, |
2124 1, | 2089 GL_RGBA, GL_UNSIGNED_BYTE, 0, 0, 1, 1); |
2125 GL_RGBA, | |
2126 GL_RGBA, | |
2127 GL_UNSIGNED_BYTE, | |
2128 1, | |
2129 1); | |
2130 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); | 2090 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); |
2131 SetupExpectationsForApplyingDefaultDirtyState(); | 2091 SetupExpectationsForApplyingDefaultDirtyState(); |
2132 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | 2092 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) |
2133 .Times(1) | 2093 .Times(1) |
2134 .RetiresOnSaturation(); | 2094 .RetiresOnSaturation(); |
2135 DrawArrays cmd; | 2095 DrawArrays cmd; |
2136 cmd.Init(GL_TRIANGLES, 0, kNumVertices); | 2096 cmd.Init(GL_TRIANGLES, 0, kNumVertices); |
2137 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 2097 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
2138 } | 2098 } |
2139 | 2099 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2303 level, | 2263 level, |
2304 GL_DEPTH_COMPONENT, | 2264 GL_DEPTH_COMPONENT, |
2305 1, | 2265 1, |
2306 1, | 2266 1, |
2307 0, | 2267 0, |
2308 GL_DEPTH_COMPONENT, | 2268 GL_DEPTH_COMPONENT, |
2309 GL_UNSIGNED_INT, | 2269 GL_UNSIGNED_INT, |
2310 0, | 2270 0, |
2311 0); | 2271 0); |
2312 | 2272 |
2313 // Enable GL_SCISSOR_TEST to make sure we disable it in the clear, | 2273 // Disable GL_SCISSOR_TEST to make sure we enable it in the clear, |
2314 // then re-enable it. | 2274 // then disable it again. |
2315 DoEnableDisable(GL_SCISSOR_TEST, true); | 2275 DoEnableDisable(GL_SCISSOR_TEST, false); |
2316 | 2276 |
2317 EXPECT_CALL(*gl_, GenFramebuffersEXT(1, _)).Times(1).RetiresOnSaturation(); | 2277 EXPECT_CALL(*gl_, GenFramebuffersEXT(1, _)).Times(1).RetiresOnSaturation(); |
2318 EXPECT_CALL(*gl_, BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, _)) | 2278 EXPECT_CALL(*gl_, BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, _)) |
2319 .Times(1) | 2279 .Times(1) |
2320 .RetiresOnSaturation(); | 2280 .RetiresOnSaturation(); |
2321 | 2281 |
2322 EXPECT_CALL(*gl_, | 2282 EXPECT_CALL(*gl_, |
2323 FramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER_EXT, | 2283 FramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER_EXT, |
2324 attachment, | 2284 attachment, |
2325 target, | 2285 target, |
2326 kServiceTextureId, | 2286 kServiceTextureId, |
2327 level)) | 2287 level)) |
2328 .Times(1) | 2288 .Times(1) |
2329 .RetiresOnSaturation(); | 2289 .RetiresOnSaturation(); |
2330 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER_EXT)) | 2290 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER_EXT)) |
2331 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) | 2291 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) |
2332 .RetiresOnSaturation(); | 2292 .RetiresOnSaturation(); |
2333 | 2293 |
2334 EXPECT_CALL(*gl_, ClearStencil(0)).Times(1).RetiresOnSaturation(); | 2294 EXPECT_CALL(*gl_, ClearStencil(0)).Times(1).RetiresOnSaturation(); |
2335 SetupExpectationsForStencilMask(GLES2Decoder::kDefaultStencilMask, | 2295 SetupExpectationsForStencilMask(GLES2Decoder::kDefaultStencilMask, |
2336 GLES2Decoder::kDefaultStencilMask); | 2296 GLES2Decoder::kDefaultStencilMask); |
2337 EXPECT_CALL(*gl_, ClearDepth(1.0f)).Times(1).RetiresOnSaturation(); | 2297 EXPECT_CALL(*gl_, ClearDepth(1.0f)).Times(1).RetiresOnSaturation(); |
2338 SetupExpectationsForDepthMask(true); | 2298 SetupExpectationsForDepthMask(true); |
2339 SetupExpectationsForEnableDisable(GL_SCISSOR_TEST, false); | 2299 EXPECT_CALL(*gl_, Scissor(0.0f, 0.0f, 1.0f, 1.0f)) |
| 2300 .Times(1) |
| 2301 .RetiresOnSaturation(); |
2340 | 2302 |
2341 EXPECT_CALL(*gl_, Clear(GL_DEPTH_BUFFER_BIT)).Times(1).RetiresOnSaturation(); | 2303 EXPECT_CALL(*gl_, Clear(GL_DEPTH_BUFFER_BIT)).Times(1).RetiresOnSaturation(); |
2342 | 2304 |
| 2305 EXPECT_CALL(*gl_, Disable(GL_SCISSOR_TEST)).Times(1).RetiresOnSaturation(); |
2343 SetupExpectationsForRestoreClearState(0.0f, 0.0f, 0.0f, 0.0f, 0, 1.0f, true); | 2306 SetupExpectationsForRestoreClearState(0.0f, 0.0f, 0.0f, 0.0f, 0, 1.0f, true); |
2344 | 2307 |
2345 EXPECT_CALL(*gl_, DeleteFramebuffersEXT(1, _)).Times(1).RetiresOnSaturation(); | 2308 EXPECT_CALL(*gl_, DeleteFramebuffersEXT(1, _)).Times(1).RetiresOnSaturation(); |
2346 EXPECT_CALL(*gl_, BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0)) | 2309 EXPECT_CALL(*gl_, BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0)) |
2347 .Times(1) | 2310 .Times(1) |
2348 .RetiresOnSaturation(); | 2311 .RetiresOnSaturation(); |
2349 | 2312 |
2350 SetupExpectationsForApplyingDefaultDirtyState(); | 2313 SetupExpectationsForApplyingDefaultDirtyState(); |
2351 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | 2314 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) |
2352 .Times(1) | 2315 .Times(1) |
2353 .RetiresOnSaturation(); | 2316 .RetiresOnSaturation(); |
2354 DrawArrays cmd; | 2317 DrawArrays cmd; |
2355 cmd.Init(GL_TRIANGLES, 0, kNumVertices); | 2318 cmd.Init(GL_TRIANGLES, 0, kNumVertices); |
2356 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 2319 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
2357 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 2320 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
2358 } | 2321 } |
2359 | 2322 |
2360 } // namespace gles2 | 2323 } // namespace gles2 |
2361 } // namespace gpu | 2324 } // namespace gpu |
OLD | NEW |