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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc

Issue 3058043: Clear render buffers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "app/gfx/gl/gl_mock.h" 5 #include "app/gfx/gl/gl_mock.h"
6 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 6 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
7 #include "gpu/command_buffer/common/gles2_cmd_format.h" 7 #include "gpu/command_buffer/common/gles2_cmd_format.h"
8 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 8 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
9 #include "gpu/command_buffer/common/id_allocator.h" 9 #include "gpu/command_buffer/common/id_allocator.h"
10 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h" 10 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h"
(...skipping 2267 matching lines...) Expand 10 before | Expand all | Expand 10 after
2278 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2278 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2279 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 2279 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
2280 cmd.Init(GL_TEXTURE_2D, 1, 0, 0, 0, 0, kWidth + 1, kHeight); 2280 cmd.Init(GL_TEXTURE_2D, 1, 0, 0, 0, 0, kWidth + 1, kHeight);
2281 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2281 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2282 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 2282 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
2283 cmd.Init(GL_TEXTURE_2D, 1, 0, 0, 0, 0, kWidth, kHeight + 1); 2283 cmd.Init(GL_TEXTURE_2D, 1, 0, 0, 0, 0, kWidth, kHeight + 1);
2284 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2284 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2285 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 2285 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
2286 } 2286 }
2287 2287
2288 // Check that if a renderbuffer is attached and GL returns
2289 // GL_FRAMEBUFFER_COMPLETE that the buffer is cleared and state is restored.
2290 TEST_F(GLES2DecoderTest, FramebufferRenderbufferClearColor) {
2291 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_,
2292 kServiceFramebufferId);
2293 ClearColor color_cmd;
2294 ColorMask color_mask_cmd;
2295 Enable enable_cmd;
2296 FramebufferRenderbuffer cmd;
2297 color_cmd.Init(0.1f, 0.2f, 0.3f, 0.4f);
2298 color_mask_cmd.Init(0, 1, 0, 1);
2299 enable_cmd.Init(GL_SCISSOR_TEST);
2300 cmd.Init(
2301 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER,
2302 client_renderbuffer_id_);
2303 InSequence sequence;
2304 EXPECT_CALL(*gl_, ClearColor(0.1f, 0.2f, 0.3f, 0.4f))
2305 .Times(1)
2306 .RetiresOnSaturation();
2307 EXPECT_CALL(*gl_, ColorMask(0, 1, 0, 1))
2308 .Times(1)
2309 .RetiresOnSaturation();
2310 EXPECT_CALL(*gl_, Enable(GL_SCISSOR_TEST))
2311 .Times(1)
2312 .RetiresOnSaturation();
2313 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT(
2314 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER,
2315 kServiceRenderbufferId))
2316 .Times(1)
2317 .RetiresOnSaturation();
2318 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER))
2319 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE))
2320 .RetiresOnSaturation();
2321 EXPECT_CALL(*gl_, ClearColor(0, 0, 0, 0))
2322 .Times(1)
2323 .RetiresOnSaturation();
2324 EXPECT_CALL(*gl_, ColorMask(1, 1, 1, 1))
2325 .Times(1)
2326 .RetiresOnSaturation();
2327 EXPECT_CALL(*gl_, Disable(GL_SCISSOR_TEST))
2328 .Times(1)
2329 .RetiresOnSaturation();
2330 EXPECT_CALL(*gl_, Clear(GL_COLOR_BUFFER_BIT))
2331 .Times(1)
2332 .RetiresOnSaturation();
2333 EXPECT_CALL(*gl_, ClearColor(0.1f, 0.2f, 0.3f, 0.4f))
2334 .Times(1)
2335 .RetiresOnSaturation();
2336 EXPECT_CALL(*gl_, ColorMask(0, 1, 0, 1))
2337 .Times(1)
2338 .RetiresOnSaturation();
2339 EXPECT_CALL(*gl_, ClearStencil(0))
2340 .Times(1)
2341 .RetiresOnSaturation();
2342 EXPECT_CALL(*gl_, StencilMaskSeparate(GL_FRONT, static_cast<GLuint>(-1)))
2343 .Times(1)
2344 .RetiresOnSaturation();
2345 EXPECT_CALL(*gl_, StencilMaskSeparate(GL_BACK, static_cast<GLuint>(-1)))
2346 .Times(1)
2347 .RetiresOnSaturation();
2348 EXPECT_CALL(*gl_, ClearDepth(1.0f))
2349 .Times(1)
2350 .RetiresOnSaturation();
2351 EXPECT_CALL(*gl_, DepthMask(1))
2352 .Times(1)
2353 .RetiresOnSaturation();
2354 EXPECT_CALL(*gl_, Enable(GL_SCISSOR_TEST))
2355 .Times(1)
2356 .RetiresOnSaturation();
2357 EXPECT_EQ(error::kNoError, ExecuteCmd(color_cmd));
2358 EXPECT_EQ(error::kNoError, ExecuteCmd(color_mask_cmd));
2359 EXPECT_EQ(error::kNoError, ExecuteCmd(enable_cmd));
2360 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2361 }
2362
2363 TEST_F(GLES2DecoderTest, FramebufferRenderbufferClearDepth) {
2364 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_,
2365 kServiceFramebufferId);
2366 ClearDepthf depth_cmd;
2367 DepthMask depth_mask_cmd;
2368 FramebufferRenderbuffer cmd;
2369 depth_cmd.Init(0.5f);
2370 depth_mask_cmd.Init(false);
2371 cmd.Init(
2372 GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER,
2373 client_renderbuffer_id_);
2374 InSequence sequence;
2375 EXPECT_CALL(*gl_, ClearDepth(0.5f))
2376 .Times(1)
2377 .RetiresOnSaturation();
2378 EXPECT_CALL(*gl_, DepthMask(0))
2379 .Times(1)
2380 .RetiresOnSaturation();
2381 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT(
2382 GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER,
2383 kServiceRenderbufferId))
2384 .Times(1)
2385 .RetiresOnSaturation();
2386 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER))
2387 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE))
2388 .RetiresOnSaturation();
2389 EXPECT_CALL(*gl_, ClearDepth(1.0f))
2390 .Times(1)
2391 .RetiresOnSaturation();
2392 EXPECT_CALL(*gl_, DepthMask(1))
2393 .Times(1)
2394 .RetiresOnSaturation();
2395 EXPECT_CALL(*gl_, Disable(GL_SCISSOR_TEST))
2396 .Times(1)
2397 .RetiresOnSaturation();
2398 EXPECT_CALL(*gl_, Clear(GL_DEPTH_BUFFER_BIT))
2399 .Times(1)
2400 .RetiresOnSaturation();
2401 EXPECT_CALL(*gl_, ClearColor(0, 0, 0, 0))
2402 .Times(1)
2403 .RetiresOnSaturation();
2404 EXPECT_CALL(*gl_, ColorMask(1, 1, 1, 1))
2405 .Times(1)
2406 .RetiresOnSaturation();
2407 EXPECT_CALL(*gl_, ClearStencil(0))
2408 .Times(1)
2409 .RetiresOnSaturation();
2410 EXPECT_CALL(*gl_, StencilMaskSeparate(GL_FRONT, static_cast<GLuint>(-1)))
2411 .Times(1)
2412 .RetiresOnSaturation();
2413 EXPECT_CALL(*gl_, StencilMaskSeparate(GL_BACK, static_cast<GLuint>(-1)))
2414 .Times(1)
2415 .RetiresOnSaturation();
2416 EXPECT_CALL(*gl_, ClearDepth(0.5f))
2417 .Times(1)
2418 .RetiresOnSaturation();
2419 EXPECT_CALL(*gl_, DepthMask(0))
2420 .Times(1)
2421 .RetiresOnSaturation();
2422 EXPECT_EQ(error::kNoError, ExecuteCmd(depth_cmd));
2423 EXPECT_EQ(error::kNoError, ExecuteCmd(depth_mask_cmd));
2424 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2425 }
2426
2427 TEST_F(GLES2DecoderTest, FramebufferRenderbufferClearStencil) {
2428 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_,
2429 kServiceFramebufferId);
2430 ClearStencil stencil_cmd;
2431 StencilMaskSeparate stencil_mask_separate_cmd;
2432 FramebufferRenderbuffer cmd;
2433 stencil_cmd.Init(123);
2434 stencil_mask_separate_cmd.Init(GL_BACK, 0x1234u);
2435 cmd.Init(
2436 GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
2437 client_renderbuffer_id_);
2438 InSequence sequence;
2439 EXPECT_CALL(*gl_, ClearStencil(123))
2440 .Times(1)
2441 .RetiresOnSaturation();
2442 EXPECT_CALL(*gl_, StencilMaskSeparate(GL_BACK, 0x1234u))
2443 .Times(1)
2444 .RetiresOnSaturation();
2445 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT(
2446 GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
2447 kServiceRenderbufferId))
2448 .Times(1)
2449 .RetiresOnSaturation();
2450 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER))
2451 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE))
2452 .RetiresOnSaturation();
2453 EXPECT_CALL(*gl_, ClearStencil(0))
2454 .Times(1)
2455 .RetiresOnSaturation();
2456 EXPECT_CALL(*gl_, StencilMask(static_cast<GLuint>(-1)))
2457 .Times(1)
2458 .RetiresOnSaturation();
2459 EXPECT_CALL(*gl_, Disable(GL_SCISSOR_TEST))
2460 .Times(1)
2461 .RetiresOnSaturation();
2462 EXPECT_CALL(*gl_, Clear(GL_STENCIL_BUFFER_BIT))
2463 .Times(1)
2464 .RetiresOnSaturation();
2465 EXPECT_CALL(*gl_, ClearColor(0, 0, 0, 0))
2466 .Times(1)
2467 .RetiresOnSaturation();
2468 EXPECT_CALL(*gl_, ColorMask(1, 1, 1, 1))
2469 .Times(1)
2470 .RetiresOnSaturation();
2471 EXPECT_CALL(*gl_, ClearStencil(123))
2472 .Times(1)
2473 .RetiresOnSaturation();
2474 EXPECT_CALL(*gl_, StencilMaskSeparate(GL_FRONT, static_cast<GLuint>(-1)))
2475 .Times(1)
2476 .RetiresOnSaturation();
2477 EXPECT_CALL(*gl_, StencilMaskSeparate(GL_BACK, 0x1234u))
2478 .Times(1)
2479 .RetiresOnSaturation();
2480 EXPECT_CALL(*gl_, ClearDepth(1.0f))
2481 .Times(1)
2482 .RetiresOnSaturation();
2483 EXPECT_CALL(*gl_, DepthMask(1))
2484 .Times(1)
2485 .RetiresOnSaturation();
2486 EXPECT_EQ(error::kNoError, ExecuteCmd(stencil_cmd));
2487 EXPECT_EQ(error::kNoError, ExecuteCmd(stencil_mask_separate_cmd));
2488 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2489 }
2490
2491 #if 0 // Turn this test on once we allow GL_DEPTH_STENCIL_ATTACHMENT
2492 TEST_F(GLES2DecoderTest, FramebufferRenderbufferClearDepthStencil) {
2493 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_,
2494 kServiceFramebufferId);
2495 ClearDepthf depth_cmd;
2496 ClearStencil stencil_cmd;
2497 FramebufferRenderbuffer cmd;
2498 depth_cmd.Init(0.5f);
2499 stencil_cmd.Init(123);
2500 cmd.Init(
2501 GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
2502 client_renderbuffer_id_);
2503 InSequence sequence;
2504 EXPECT_CALL(*gl_, ClearDepth(0.5f))
2505 .Times(1)
2506 .RetiresOnSaturation();
2507 EXPECT_CALL(*gl_, ClearStencil(123))
2508 .Times(1)
2509 .RetiresOnSaturation();
2510 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT(
2511 GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
2512 kServiceRenderbufferId))
2513 .Times(1)
2514 .RetiresOnSaturation();
2515 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER))
2516 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE))
2517 .RetiresOnSaturation();
2518 EXPECT_CALL(*gl_, ClearStencil(0))
2519 .Times(1)
2520 .RetiresOnSaturation();
2521 EXPECT_CALL(*gl_, StencilMask(static_cast<GLuint>(-1)))
2522 .Times(1)
2523 .RetiresOnSaturation();
2524 EXPECT_CALL(*gl_, ClearDepth(1.0f))
2525 .Times(1)
2526 .RetiresOnSaturation();
2527 EXPECT_CALL(*gl_, DepthMask(1))
2528 .Times(1)
2529 .RetiresOnSaturation();
2530 EXPECT_CALL(*gl_, Disable(GL_SCISSOR_TEST))
2531 .Times(1)
2532 .RetiresOnSaturation();
2533 EXPECT_CALL(*gl_, Clear(GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT))
2534 .Times(1)
2535 .RetiresOnSaturation();
2536 EXPECT_CALL(*gl_, ClearColor(0, 0, 0, 0))
2537 .Times(1)
2538 .RetiresOnSaturation();
2539 EXPECT_CALL(*gl_, ColorMask(1, 1, 1, 1))
2540 .Times(1)
2541 .RetiresOnSaturation();
2542 EXPECT_CALL(*gl_, ClearStencil(123))
2543 .Times(1)
2544 .RetiresOnSaturation();
2545 EXPECT_CALL(*gl_, StencilMaskSeparate(GL_FRONT, static_cast<GLuint>(-1)))
2546 .Times(1)
2547 .RetiresOnSaturation();
2548 EXPECT_CALL(*gl_, StencilMaskSeparate(GL_BACK, static_cast<GLuint>(-1)))
2549 .Times(1)
2550 .RetiresOnSaturation();
2551 EXPECT_CALL(*gl_, ClearDepth(0.5f))
2552 .Times(1)
2553 .RetiresOnSaturation();
2554 EXPECT_CALL(*gl_, DepthMask(1))
2555 .Times(1)
2556 .RetiresOnSaturation();
2557 EXPECT_EQ(error::kNoError, ExecuteCmd(depth_cmd));
2558 EXPECT_EQ(error::kNoError, ExecuteCmd(stencil_cmd));
2559 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2560 }
2561 #endif
2562
2288 // TODO(gman): BufferData 2563 // TODO(gman): BufferData
2289 2564
2290 // TODO(gman): BufferDataImmediate 2565 // TODO(gman): BufferDataImmediate
2291 2566
2292 // TODO(gman): BufferSubData 2567 // TODO(gman): BufferSubData
2293 2568
2294 // TODO(gman): BufferSubDataImmediate 2569 // TODO(gman): BufferSubDataImmediate
2295 2570
2296 // TODO(gman): CompressedTexImage2D 2571 // TODO(gman): CompressedTexImage2D
2297 2572
(...skipping 16 matching lines...) Expand all
2314 // TODO(gman): UseProgram 2589 // TODO(gman): UseProgram
2315 2590
2316 // TODO(gman): SwapBuffers 2591 // TODO(gman): SwapBuffers
2317 2592
2318 // TODO(gman): VertexAttribPointer 2593 // TODO(gman): VertexAttribPointer
2319 2594
2320 } // namespace gles2 2595 } // namespace gles2
2321 } // namespace gpu 2596 } // namespace gpu
2322 2597
2323 2598
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder_autogen.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder_unittest_1.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698