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 1894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1905 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); | 1905 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
1906 DoBindFramebuffer( | 1906 DoBindFramebuffer( |
1907 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); | 1907 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
1908 DoFramebufferTexture2D(GL_FRAMEBUFFER, | 1908 DoFramebufferTexture2D(GL_FRAMEBUFFER, |
1909 GL_COLOR_ATTACHMENT0, | 1909 GL_COLOR_ATTACHMENT0, |
1910 GL_TEXTURE_2D, | 1910 GL_TEXTURE_2D, |
1911 kFBOClientTextureId, | 1911 kFBOClientTextureId, |
1912 kFBOServiceTextureId, | 1912 kFBOServiceTextureId, |
1913 0, | 1913 0, |
1914 GL_NO_ERROR); | 1914 GL_NO_ERROR); |
| 1915 DoEnableDisable(GL_SCISSOR_TEST, false); |
| 1916 DoScissor(0, 0, 1, 1); |
1915 | 1917 |
1916 // Setup "render from" texture. | 1918 // Setup "render from" texture. |
1917 SetupTexture(); | 1919 SetupTexture(); |
1918 | 1920 |
1919 SetupExpectationsForFramebufferClearing(GL_FRAMEBUFFER, // target | 1921 SetupExpectationsForFramebufferClearing(GL_FRAMEBUFFER, // target |
1920 GL_COLOR_BUFFER_BIT, // clear bits | 1922 GL_COLOR_BUFFER_BIT, // clear bits |
1921 0, | 1923 0, 0, 0, |
1922 0, | 1924 0, // color |
1923 0, | 1925 0, // stencil |
1924 0, // color | 1926 1.0f, // depth |
1925 0, // stencil | 1927 false, // scissor test |
1926 1.0f, // depth | 1928 0, 0, 1, 1); |
1927 false); // scissor test | |
1928 | 1929 |
1929 SetupExpectationsForApplyingDirtyState(false, // Framebuffer is RGB | 1930 SetupExpectationsForApplyingDirtyState(false, // Framebuffer is RGB |
1930 false, // Framebuffer has depth | 1931 false, // Framebuffer has depth |
1931 false, // Framebuffer has stencil | 1932 false, // Framebuffer has stencil |
1932 0x1111, // color bits | 1933 0x1111, // color bits |
1933 false, // depth mask | 1934 false, // depth mask |
1934 false, // depth enabled | 1935 false, // depth enabled |
1935 0, // front stencil mask | 1936 0, // front stencil mask |
1936 0, // back stencil mask | 1937 0, // back stencil mask |
1937 false); // stencil enabled | 1938 false); // stencil enabled |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1996 DoBindFramebuffer( | 1997 DoBindFramebuffer( |
1997 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); | 1998 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
1998 DoRenderbufferStorage( | 1999 DoRenderbufferStorage( |
1999 GL_RENDERBUFFER, GL_RGBA4, GL_RGBA, 100, 50, GL_NO_ERROR); | 2000 GL_RENDERBUFFER, GL_RGBA4, GL_RGBA, 100, 50, GL_NO_ERROR); |
2000 DoFramebufferRenderbuffer(GL_FRAMEBUFFER, | 2001 DoFramebufferRenderbuffer(GL_FRAMEBUFFER, |
2001 GL_COLOR_ATTACHMENT0, | 2002 GL_COLOR_ATTACHMENT0, |
2002 GL_RENDERBUFFER, | 2003 GL_RENDERBUFFER, |
2003 client_renderbuffer_id_, | 2004 client_renderbuffer_id_, |
2004 kServiceRenderbufferId, | 2005 kServiceRenderbufferId, |
2005 GL_NO_ERROR); | 2006 GL_NO_ERROR); |
| 2007 DoEnableDisable(GL_SCISSOR_TEST, false); |
| 2008 DoScissor(0, 0, 1, 1); |
2006 | 2009 |
2007 SetupExpectationsForFramebufferClearing(GL_FRAMEBUFFER, // target | 2010 SetupExpectationsForFramebufferClearing(GL_FRAMEBUFFER, // target |
2008 GL_COLOR_BUFFER_BIT, // clear bits | 2011 GL_COLOR_BUFFER_BIT, // clear bits |
2009 0, | 2012 0, 0, 0, |
2010 0, | 2013 0, // color |
2011 0, | 2014 0, // stencil |
2012 0, // color | 2015 1.0f, // depth |
2013 0, // stencil | 2016 false, // scissor test |
2014 1.0f, // depth | 2017 0, 0, 1, 1); |
2015 false); // scissor test | |
2016 | 2018 |
2017 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); | 2019 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); |
2018 SetupExpectationsForApplyingDirtyState(false, // Framebuffer is RGB | 2020 SetupExpectationsForApplyingDirtyState(false, // Framebuffer is RGB |
2019 false, // Framebuffer has depth | 2021 false, // Framebuffer has depth |
2020 false, // Framebuffer has stencil | 2022 false, // Framebuffer has stencil |
2021 0x1111, // color bits | 2023 0x1111, // color bits |
2022 false, // depth mask | 2024 false, // depth mask |
2023 false, // depth enabled | 2025 false, // depth enabled |
2024 0, // front stencil mask | 2026 0, // front stencil mask |
2025 0, // back stencil mask | 2027 0, // back stencil mask |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2131 GL_DEPTH_COMPONENT, | 2133 GL_DEPTH_COMPONENT, |
2132 1, | 2134 1, |
2133 1, | 2135 1, |
2134 GL_NO_ERROR); | 2136 GL_NO_ERROR); |
2135 DoFramebufferRenderbuffer(GL_FRAMEBUFFER, | 2137 DoFramebufferRenderbuffer(GL_FRAMEBUFFER, |
2136 GL_DEPTH_ATTACHMENT, | 2138 GL_DEPTH_ATTACHMENT, |
2137 GL_RENDERBUFFER, | 2139 GL_RENDERBUFFER, |
2138 client_renderbuffer_id_, | 2140 client_renderbuffer_id_, |
2139 kServiceRenderbufferId, | 2141 kServiceRenderbufferId, |
2140 GL_NO_ERROR); | 2142 GL_NO_ERROR); |
2141 | 2143 DoEnableDisable(GL_SCISSOR_TEST, false); |
| 2144 DoScissor(0, 0, 1, 1); |
2142 SetupTexture(); | 2145 SetupTexture(); |
2143 SetupExpectationsForFramebufferClearing( | 2146 SetupExpectationsForFramebufferClearing( |
2144 GL_FRAMEBUFFER, // target | 2147 GL_FRAMEBUFFER, // target |
2145 GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, // clear bits | 2148 GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, // clear bits |
2146 0, | 2149 0, 0, 0, |
2147 0, | 2150 0, // color |
2148 0, | 2151 0, // stencil |
2149 0, // color | 2152 1.0f, // depth |
2150 0, // stencil | 2153 false, // scissor test |
2151 1.0f, // depth | 2154 0, 0, 1, 1); |
2152 false); // scissor test | |
2153 | 2155 |
2154 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); | 2156 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); |
2155 SetupExpectationsForApplyingDirtyState(false, // Framebuffer is RGB | 2157 SetupExpectationsForApplyingDirtyState(false, // Framebuffer is RGB |
2156 true, // Framebuffer has depth | 2158 true, // Framebuffer has depth |
2157 false, // Framebuffer has stencil | 2159 false, // Framebuffer has stencil |
2158 0x1111, // color bits | 2160 0x1111, // color bits |
2159 true, // depth mask | 2161 true, // depth mask |
2160 false, // depth enabled | 2162 false, // depth enabled |
2161 0, // front stencil mask | 2163 0, // front stencil mask |
2162 0, // back stencil mask | 2164 0, // back stencil mask |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2263 level, | 2265 level, |
2264 GL_DEPTH_COMPONENT, | 2266 GL_DEPTH_COMPONENT, |
2265 1, | 2267 1, |
2266 1, | 2268 1, |
2267 0, | 2269 0, |
2268 GL_DEPTH_COMPONENT, | 2270 GL_DEPTH_COMPONENT, |
2269 GL_UNSIGNED_INT, | 2271 GL_UNSIGNED_INT, |
2270 0, | 2272 0, |
2271 0); | 2273 0); |
2272 | 2274 |
2273 // Disable GL_SCISSOR_TEST to make sure we enable it in the clear, | 2275 // Set scissor rect and disable GL_SCISSOR_TEST to make sure we enable it in |
2274 // then disable it again. | 2276 // the clear, then disable it and restore the rect again. |
| 2277 DoScissor(0, 0, 32, 32); |
2275 DoEnableDisable(GL_SCISSOR_TEST, false); | 2278 DoEnableDisable(GL_SCISSOR_TEST, false); |
2276 | 2279 |
2277 EXPECT_CALL(*gl_, GenFramebuffersEXT(1, _)).Times(1).RetiresOnSaturation(); | 2280 EXPECT_CALL(*gl_, GenFramebuffersEXT(1, _)).Times(1).RetiresOnSaturation(); |
2278 EXPECT_CALL(*gl_, BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, _)) | 2281 EXPECT_CALL(*gl_, BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, _)) |
2279 .Times(1) | 2282 .Times(1) |
2280 .RetiresOnSaturation(); | 2283 .RetiresOnSaturation(); |
2281 | 2284 |
2282 EXPECT_CALL(*gl_, | 2285 EXPECT_CALL(*gl_, |
2283 FramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER_EXT, | 2286 FramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER_EXT, |
2284 attachment, | 2287 attachment, |
2285 target, | 2288 target, |
2286 kServiceTextureId, | 2289 kServiceTextureId, |
2287 level)) | 2290 level)) |
2288 .Times(1) | 2291 .Times(1) |
2289 .RetiresOnSaturation(); | 2292 .RetiresOnSaturation(); |
2290 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER_EXT)) | 2293 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER_EXT)) |
2291 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) | 2294 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) |
2292 .RetiresOnSaturation(); | 2295 .RetiresOnSaturation(); |
2293 | 2296 |
2294 EXPECT_CALL(*gl_, ClearStencil(0)).Times(1).RetiresOnSaturation(); | 2297 EXPECT_CALL(*gl_, ClearStencil(0)).Times(1).RetiresOnSaturation(); |
2295 SetupExpectationsForStencilMask(GLES2Decoder::kDefaultStencilMask, | 2298 SetupExpectationsForStencilMask(GLES2Decoder::kDefaultStencilMask, |
2296 GLES2Decoder::kDefaultStencilMask); | 2299 GLES2Decoder::kDefaultStencilMask); |
2297 EXPECT_CALL(*gl_, ClearDepth(1.0f)).Times(1).RetiresOnSaturation(); | 2300 EXPECT_CALL(*gl_, ClearDepth(1.0f)).Times(1).RetiresOnSaturation(); |
2298 SetupExpectationsForDepthMask(true); | 2301 SetupExpectationsForDepthMask(true); |
2299 EXPECT_CALL(*gl_, Scissor(0.0f, 0.0f, 1.0f, 1.0f)) | 2302 SetupExpectationsForEnableDisable(GL_SCISSOR_TEST, true); |
2300 .Times(1) | 2303 EXPECT_CALL(*gl_, Scissor(0, 0, 1, 1)).Times(1).RetiresOnSaturation(); |
2301 .RetiresOnSaturation(); | |
2302 | 2304 |
2303 EXPECT_CALL(*gl_, Clear(GL_DEPTH_BUFFER_BIT)).Times(1).RetiresOnSaturation(); | 2305 EXPECT_CALL(*gl_, Clear(GL_DEPTH_BUFFER_BIT)).Times(1).RetiresOnSaturation(); |
2304 | 2306 |
2305 EXPECT_CALL(*gl_, Disable(GL_SCISSOR_TEST)).Times(1).RetiresOnSaturation(); | 2307 SetupExpectationsForRestoreClearState(0.0f, 0.0f, 0.0f, 0.0f, 0, 1.0f, false, |
2306 SetupExpectationsForRestoreClearState(0.0f, 0.0f, 0.0f, 0.0f, 0, 1.0f, true); | 2308 0, 0, 32, 32); |
2307 | 2309 |
2308 EXPECT_CALL(*gl_, DeleteFramebuffersEXT(1, _)).Times(1).RetiresOnSaturation(); | 2310 EXPECT_CALL(*gl_, DeleteFramebuffersEXT(1, _)).Times(1).RetiresOnSaturation(); |
2309 EXPECT_CALL(*gl_, BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0)) | 2311 EXPECT_CALL(*gl_, BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0)) |
2310 .Times(1) | 2312 .Times(1) |
2311 .RetiresOnSaturation(); | 2313 .RetiresOnSaturation(); |
2312 | 2314 |
2313 SetupExpectationsForApplyingDefaultDirtyState(); | 2315 SetupExpectationsForApplyingDefaultDirtyState(); |
2314 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | 2316 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) |
2315 .Times(1) | 2317 .Times(1) |
2316 .RetiresOnSaturation(); | 2318 .RetiresOnSaturation(); |
2317 DrawArrays cmd; | 2319 DrawArrays cmd; |
2318 cmd.Init(GL_TRIANGLES, 0, kNumVertices); | 2320 cmd.Init(GL_TRIANGLES, 0, kNumVertices); |
2319 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 2321 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
2320 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 2322 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
2321 } | 2323 } |
2322 | 2324 |
2323 } // namespace gles2 | 2325 } // namespace gles2 |
2324 } // namespace gpu | 2326 } // namespace gpu |
OLD | NEW |