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

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

Issue 1870483003: Add command buffer support for GL_RGB CHROMIUM image emulation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing braces. Created 4 years, 8 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
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 using ::testing::Mock; 42 using ::testing::Mock;
43 using ::testing::Pointee; 43 using ::testing::Pointee;
44 using ::testing::Return; 44 using ::testing::Return;
45 using ::testing::SaveArg; 45 using ::testing::SaveArg;
46 using ::testing::SetArrayArgument; 46 using ::testing::SetArrayArgument;
47 using ::testing::SetArgumentPointee; 47 using ::testing::SetArgumentPointee;
48 using ::testing::SetArgPointee; 48 using ::testing::SetArgPointee;
49 using ::testing::StrEq; 49 using ::testing::StrEq;
50 using ::testing::StrictMock; 50 using ::testing::StrictMock;
51 51
52 namespace {
53 class EmulatingRGBImageStub : public gl::GLImageStub {
54 protected:
55 ~EmulatingRGBImageStub() override {}
56 bool EmulatingRGB() const override {
57 return true;
58 }
59 };
60 } // namespace
61
52 namespace gpu { 62 namespace gpu {
53 namespace gles2 { 63 namespace gles2 {
54 64
55 using namespace cmds; 65 using namespace cmds;
56 66
57 TEST_P(GLES2DecoderTest, GenerateMipmapWrongFormatsFails) { 67 TEST_P(GLES2DecoderTest, GenerateMipmapWrongFormatsFails) {
58 EXPECT_CALL(*gl_, GenerateMipmapEXT(_)).Times(0); 68 EXPECT_CALL(*gl_, GenerateMipmapEXT(_)).Times(0);
59 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 69 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
60 DoTexImage2D( 70 DoTexImage2D(
61 GL_TEXTURE_2D, 0, GL_RGBA, 16, 17, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); 71 GL_TEXTURE_2D, 0, GL_RGBA, 16, 17, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0);
(...skipping 3607 matching lines...) Expand 10 before | Expand all | Expand 10 after
3669 .Times(1) 3679 .Times(1)
3670 .RetiresOnSaturation(); 3680 .RetiresOnSaturation();
3671 EXPECT_CALL(*gl_, BindTexture(kTarget, _)) 3681 EXPECT_CALL(*gl_, BindTexture(kTarget, _))
3672 .Times(1) 3682 .Times(1)
3673 .RetiresOnSaturation(); 3683 .RetiresOnSaturation();
3674 3684
3675 EXPECT_TRUE(decoder_->ClearLevel3D( 3685 EXPECT_TRUE(decoder_->ClearLevel3D(
3676 texture, kTarget, kLevel, kFormat, kType, kWidth, kHeight, kDepth)); 3686 texture, kTarget, kLevel, kFormat, kType, kWidth, kHeight, kDepth));
3677 } 3687 }
3678 3688
3689 // Test that copyTexImage2D uses the emulated internal format, rather than the
3690 // real internal format.
3691 TEST_P(GLES2DecoderWithShaderTest, CHROMIUMImageEmulatingRGB) {
3692 const GLuint kFBOClientTextureId = 4100;
3693 const GLuint kFBOServiceTextureId = 4101;
3694 GLenum target = GL_TEXTURE_2D;
3695 GLint level = 0;
3696 GLsizei width = 1;
3697 GLsizei height = 1;
3698
3699 // Generate the source framebuffer.
3700 EXPECT_CALL(*gl_, GenTextures(_, _))
3701 .WillOnce(SetArgPointee<1>(kFBOServiceTextureId))
3702 .RetiresOnSaturation();
3703 GenHelper<GenTexturesImmediate>(kFBOClientTextureId);
3704 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_,
3705 kServiceFramebufferId);
3706
3707 GLenum destination_texture_formats[] = {GL_RGBA, GL_RGB};
3708 for (int use_rgb_emulation = 0; use_rgb_emulation < 2; ++ use_rgb_emulation) {
3709 for (size_t destination_texture_index = 0; destination_texture_index < 2;
3710 ++destination_texture_index) {
3711 // Generate and bind the source image. Making a new image for each set of
3712 // parameters is easier than trying to reuse images. Obviously there's no
3713 // performance penalty.
3714 int image_id = use_rgb_emulation * 2 + destination_texture_index;
3715 scoped_refptr<gl::GLImage> image;
3716 if (use_rgb_emulation)
3717 image = new EmulatingRGBImageStub;
3718 else
3719 image = new gl::GLImageStub;
3720 GetImageManager()->AddImage(image.get(), image_id);
3721 EXPECT_FALSE(GetImageManager()->LookupImage(image_id) == NULL);
3722 DoBindTexture(GL_TEXTURE_2D, kFBOClientTextureId, kFBOServiceTextureId);
3723
3724 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D, image_id);
3725 DoFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target,
3726 kFBOClientTextureId, kFBOServiceTextureId, level,
3727 GL_NO_ERROR);
3728
3729 GLenum destination_texture_format =
3730 destination_texture_formats[destination_texture_index];
3731 bool should_succeed =
3732 !use_rgb_emulation || (destination_texture_format == GL_RGB);
3733 if (should_succeed) {
3734 EXPECT_CALL(*gl_, GetError())
3735 .WillOnce(Return(GL_NO_ERROR))
3736 .RetiresOnSaturation();
3737 EXPECT_CALL(*gl_,
3738 CopyTexImage2D(GL_TEXTURE_2D, 0, destination_texture_format,
3739 0, 0, 1, 1, 0))
3740 .Times(1)
3741 .RetiresOnSaturation();
3742 EXPECT_CALL(*gl_, GetError())
3743 .WillOnce(Return(GL_NO_ERROR))
3744 .RetiresOnSaturation();
3745 }
3746
3747 if (destination_texture_index == 0 || !framebuffer_completeness_cache()) {
3748 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER))
3749 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE))
3750 .RetiresOnSaturation();
3751 }
3752
3753 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
3754 CopyTexImage2D cmd;
3755 cmd.Init(target, level, destination_texture_format, 0, 0, width, height);
3756 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
3757 GLenum expectation = should_succeed ? GL_NO_ERROR : GL_INVALID_OPERATION;
3758 EXPECT_EQ(expectation, static_cast<GLenum>(GetGLError()));
3759 }
3760 }
3761 }
3762
3679 // TODO(gman): Complete this test. 3763 // TODO(gman): Complete this test.
3680 // TEST_P(GLES2DecoderTest, CompressedTexImage2DGLError) { 3764 // TEST_P(GLES2DecoderTest, CompressedTexImage2DGLError) {
3681 // } 3765 // }
3682 3766
3683 // TODO(gman): CompressedTexImage2D 3767 // TODO(gman): CompressedTexImage2D
3684 3768
3685 // TODO(gman): CompressedTexImage2DImmediate 3769 // TODO(gman): CompressedTexImage2DImmediate
3686 3770
3687 // TODO(gman): CompressedTexSubImage2DImmediate 3771 // TODO(gman): CompressedTexSubImage2DImmediate
3688 3772
3689 // TODO(gman): TexImage2D 3773 // TODO(gman): TexImage2D
3690 3774
3691 // TODO(gman): TexImage2DImmediate 3775 // TODO(gman): TexImage2DImmediate
3692 3776
3693 // TODO(gman): TexSubImage2DImmediate 3777 // TODO(gman): TexSubImage2DImmediate
3694 3778
3695 } // namespace gles2 3779 } // namespace gles2
3696 } // namespace gpu 3780 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h ('k') | gpu/command_buffer/service/texture_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698