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

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

Issue 2351093002: Fix crash in BlitFramebufferCHROMIUM if a read or draw depth/stencil buffer is not present (Closed)
Patch Set: rebase Created 4 years, 3 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
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <limits.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 3679 matching lines...) Expand 10 before | Expand all | Expand 10 after
3690 .Times(1) 3690 .Times(1)
3691 .RetiresOnSaturation(); 3691 .RetiresOnSaturation();
3692 SetupExpectationsForEnableDisable(GL_SCISSOR_TEST, false); 3692 SetupExpectationsForEnableDisable(GL_SCISSOR_TEST, false);
3693 BlitFramebufferCHROMIUM cmd; 3693 BlitFramebufferCHROMIUM cmd;
3694 cmd.Init(0, 0, 1, 1, 0, 0, 1, 1, GL_COLOR_BUFFER_BIT, GL_LINEAR); 3694 cmd.Init(0, 0, 1, 1, 0, 0, 1, 1, GL_COLOR_BUFFER_BIT, GL_LINEAR);
3695 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 3695 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
3696 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 3696 EXPECT_EQ(GL_NO_ERROR, GetGLError());
3697 } 3697 }
3698 } 3698 }
3699 3699
3700 TEST_P(GLES3DecoderTest, BlitFramebufferMissingDepthOrStencil) {
3701 // Run BlitFramebufferCHROMIUM with depth or stencil bits, from/to a read/draw
3702 // framebuffer that doesn't have depth/stencil. The bits should be silently
3703 // ignored.
3704 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_,
3705 kServiceRenderbufferId);
3706 DoRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8,
3707 GL_DEPTH24_STENCIL8, 1, 1, GL_NO_ERROR);
3708 GLuint color_renderbuffer = client_renderbuffer_id_ + 1;
3709 GLuint color_renderbuffer_service = kServiceRenderbufferId + 1;
3710 EXPECT_CALL(*gl_, GenRenderbuffersEXT(1, _))
3711 .WillOnce(SetArgPointee<1>(color_renderbuffer_service))
3712 .RetiresOnSaturation();
3713 DoBindRenderbuffer(GL_RENDERBUFFER, color_renderbuffer,
3714 color_renderbuffer_service);
3715 DoRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, GL_RGBA8, 1, 1, GL_NO_ERROR);
3716 DoBindFramebuffer(GL_DRAW_FRAMEBUFFER, client_framebuffer_id_,
3717 kServiceFramebufferId);
3718 DoFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
3719 GL_RENDERBUFFER, client_renderbuffer_id_,
3720 kServiceRenderbufferId, GL_NO_ERROR);
3721 DoFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
3722 GL_RENDERBUFFER, client_renderbuffer_id_,
3723 kServiceRenderbufferId, GL_NO_ERROR);
3724 DoFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
3725 GL_RENDERBUFFER, color_renderbuffer,
3726 color_renderbuffer_service, GL_NO_ERROR);
3727
3728 EXPECT_CALL(*gl_, GenFramebuffersEXT(1, _))
3729 .WillOnce(SetArgPointee<1>(kNewServiceId))
3730 .RetiresOnSaturation();
3731 GLuint color_fbo = client_framebuffer_id_ + 1;
3732 DoBindFramebuffer(GL_READ_FRAMEBUFFER, color_fbo, kNewServiceId);
3733 DoFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
3734 GL_RENDERBUFFER, color_renderbuffer,
3735 color_renderbuffer_service, GL_NO_ERROR);
3736
3737 {
3738 SetupExpectationsForFramebufferClearing(
3739 GL_DRAW_FRAMEBUFFER, // target
3740 GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT |
3741 GL_STENCIL_BUFFER_BIT, // clear bits
3742 0,
3743 0, 0, 0, // color
3744 0, // stencil
3745 1.0f, // depth
3746 false, // scissor test
3747 0, 0, 128, 64);
3748 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER))
3749 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE))
3750 .RetiresOnSaturation();
3751 EXPECT_CALL(*gl_, BlitFramebufferEXT(0, 0, 1, 1, 0, 0, 1, 1,
3752 _, _))
3753 .Times(0);
3754 BlitFramebufferCHROMIUM cmd;
3755 cmd.Init(0, 0, 1, 1, 0, 0, 1, 1, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
3756 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
3757 EXPECT_EQ(GL_NO_ERROR, GetGLError());
3758 cmd.Init(0, 0, 1, 1, 0, 0, 1, 1, GL_STENCIL_BUFFER_BIT, GL_NEAREST);
3759 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
3760 EXPECT_EQ(GL_NO_ERROR, GetGLError());
3761 }
3762
3763 // Same using DEPTH_STENCIL_ATTACHMENT instead of separate ones.
3764 DoFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
3765 GL_RENDERBUFFER, 0, 0, GL_NO_ERROR);
3766 DoFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
3767 GL_RENDERBUFFER, 0, 0, GL_NO_ERROR);
3768 DoFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
3769 GL_RENDERBUFFER, client_renderbuffer_id_,
3770 kServiceRenderbufferId, GL_NO_ERROR);
3771 {
3772 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER))
3773 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE))
3774 .RetiresOnSaturation();
3775 EXPECT_CALL(*gl_, BlitFramebufferEXT(0, 0, 1, 1, 0, 0, 1, 1,
3776 _, _))
3777 .Times(0);
3778 BlitFramebufferCHROMIUM cmd;
3779 cmd.Init(0, 0, 1, 1, 0, 0, 1, 1, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
3780 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
3781 EXPECT_EQ(GL_NO_ERROR, GetGLError());
3782 cmd.Init(0, 0, 1, 1, 0, 0, 1, 1, GL_STENCIL_BUFFER_BIT, GL_NEAREST);
3783 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
3784 EXPECT_EQ(GL_NO_ERROR, GetGLError());
3785 }
3786
3787 // Switch FBOs and try the same.
3788 DoBindFramebuffer(GL_READ_FRAMEBUFFER, client_framebuffer_id_,
3789 kServiceFramebufferId);
3790 DoBindFramebuffer(GL_DRAW_FRAMEBUFFER, color_fbo, kNewServiceId);
3791 {
3792 EXPECT_CALL(*gl_, BlitFramebufferEXT(0, 0, 1, 1, 0, 0, 1, 1,
3793 _, _))
3794 .Times(0);
3795 BlitFramebufferCHROMIUM cmd;
3796 cmd.Init(0, 0, 1, 1, 0, 0, 1, 1, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
3797 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
3798 EXPECT_EQ(GL_NO_ERROR, GetGLError());
3799 cmd.Init(0, 0, 1, 1, 0, 0, 1, 1, GL_STENCIL_BUFFER_BIT, GL_NEAREST);
3800 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
3801 EXPECT_EQ(GL_NO_ERROR, GetGLError());
3802 }
3803 }
3804
3700 // TODO(gman): PixelStorei 3805 // TODO(gman): PixelStorei
3701 3806
3702 // TODO(gman): SwapBuffers 3807 // TODO(gman): SwapBuffers
3703 3808
3704 } // namespace gles2 3809 } // namespace gles2
3705 } // namespace gpu 3810 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698