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

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

Issue 10441087: Plum through ANGLE_depth_texture (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 6 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/atomicops.h" 7 #include "base/atomicops.h"
8 #include "gpu/command_buffer/common/gl_mock.h" 8 #include "gpu/command_buffer/common/gl_mock.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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 116
117 class GLES2DecoderManualInitTest : public GLES2DecoderWithShaderTest { 117 class GLES2DecoderManualInitTest : public GLES2DecoderWithShaderTest {
118 public: 118 public:
119 GLES2DecoderManualInitTest() { } 119 GLES2DecoderManualInitTest() { }
120 120
121 // Override default setup so nothing gets setup. 121 // Override default setup so nothing gets setup.
122 virtual void SetUp() { 122 virtual void SetUp() {
123 } 123 }
124 }; 124 };
125 125
126 class GLES2DecoderANGLEManualInitTest : public GLES2DecoderANGLETest {
127 public:
128 // Override default setup so nothing gets setup.
129 virtual void SetUp() {
130 }
131 };
132
126 TEST_F(GLES2DecoderWithShaderTest, DrawArraysNoAttributesSucceeds) { 133 TEST_F(GLES2DecoderWithShaderTest, DrawArraysNoAttributesSucceeds) {
127 SetupTexture(); 134 SetupTexture();
128 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); 135 AddExpectationsForSimulatedAttrib0(kNumVertices, 0);
129 SetupExpectationsForApplyingDefaultDirtyState(); 136 SetupExpectationsForApplyingDefaultDirtyState();
130 137
131 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) 138 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
132 .Times(1) 139 .Times(1)
133 .RetiresOnSaturation(); 140 .RetiresOnSaturation();
134 DrawArrays cmd; 141 DrawArrays cmd;
135 cmd.Init(GL_TRIANGLES, 0, kNumVertices); 142 cmd.Init(GL_TRIANGLES, 0, kNumVertices);
(...skipping 6907 matching lines...) Expand 10 before | Expand all | Expand 10 after
7043 EXPECT_EQ(error::kNoError, ExecuteCmd(is_enabled_cmd)); 7050 EXPECT_EQ(error::kNoError, ExecuteCmd(is_enabled_cmd));
7044 EXPECT_NE(0u, *result); 7051 EXPECT_NE(0u, *result);
7045 Disable disable_cmd; 7052 Disable disable_cmd;
7046 disable_cmd.Init(state); 7053 disable_cmd.Init(state);
7047 EXPECT_EQ(error::kNoError, ExecuteCmd(disable_cmd)); 7054 EXPECT_EQ(error::kNoError, ExecuteCmd(disable_cmd));
7048 EXPECT_EQ(error::kNoError, ExecuteCmd(is_enabled_cmd)); 7055 EXPECT_EQ(error::kNoError, ExecuteCmd(is_enabled_cmd));
7049 EXPECT_EQ(0u, *result); 7056 EXPECT_EQ(0u, *result);
7050 } 7057 }
7051 } 7058 }
7052 7059
7060 TEST_F(GLES2DecoderManualInitTest, DepthTextureBadArgs) {
7061 InitDecoder(
7062 "GL_ANGLE_depth_texture", // extensions
7063 false, // has alpha
7064 true, // has depth
7065 true, // has stencil
7066 false, // request alpha
7067 true, // request depth
7068 true, // request stencil
7069 true); // bind generates resource
7070
7071 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
7072 // Check trying to upload data fails.
7073 TexImage2D tex_cmd;
7074 tex_cmd.Init(
7075 GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT,
7076 1, 1, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT,
7077 kSharedMemoryId, kSharedMemoryOffset);
7078 EXPECT_EQ(error::kNoError, ExecuteCmd(tex_cmd));
7079 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
7080 // Try level > 0.
7081 tex_cmd.Init(
7082 GL_TEXTURE_2D, 1, GL_DEPTH_COMPONENT,
7083 1, 1, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 0, 0);
7084 EXPECT_EQ(error::kNoError, ExecuteCmd(tex_cmd));
7085 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
7086 // Make a 1 pixel depth texture.
7087 DoTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT,
7088 1, 1, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 0, 0);
7089 EXPECT_EQ(GL_NO_ERROR, GetGLError());
7090
7091 // Check that trying to update it fails.
7092 TexSubImage2D tex_sub_cmd;
7093 tex_sub_cmd.Init(
7094 GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT,
7095 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE);
7096 EXPECT_EQ(error::kNoError, ExecuteCmd(tex_sub_cmd));
7097 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
7098
7099 // Check that trying to CopyTexImage2D fails
7100 CopyTexImage2D copy_tex_cmd;
7101 copy_tex_cmd.Init(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 0, 0, 1, 1, 0);
7102 EXPECT_EQ(error::kNoError, ExecuteCmd(copy_tex_cmd));
7103 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
7104
7105 // Check that trying to CopyTexSubImage2D fails
7106 CopyTexSubImage2D copy_sub_cmd;
7107 copy_sub_cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 1, 1);
7108 EXPECT_EQ(error::kNoError, ExecuteCmd(copy_sub_cmd));
7109 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
7110 }
7111
7112 TEST_F(GLES2DecoderManualInitTest, GenerateMipmapDepthTexture) {
7113 InitDecoder(
7114 "GL_ANGLE_depth_texture", // extensions
7115 false, // has alpha
7116 true, // has depth
7117 true, // has stencil
7118 false, // request alpha
7119 true, // request depth
7120 true, // request stencil
7121 true); // bind generates resource
7122 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
7123 DoTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT,
7124 2, 2, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT,
7125 0, 0);
7126 GenerateMipmap cmd;
7127 cmd.Init(GL_TEXTURE_2D);
7128 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
7129 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
7130 }
7131
7132 TEST_F(GLES2DecoderANGLEManualInitTest, DrawClearsDepthTexture) {
7133 InitDecoder(
7134 "GL_ANGLE_depth_texture", // extensions
7135 true, // has alpha
7136 true, // has depth
7137 false, // has stencil
7138 true, // request alpha
7139 true, // request depth
7140 false, // request stencil
7141 true); // bind generates resource
7142
7143 SetupDefaultProgram();
7144 SetupAllNeededVertexBuffers();
7145 const GLenum attachment = GL_DEPTH_ATTACHMENT;
7146 const GLenum target = GL_TEXTURE_2D;
7147 const GLint level = 0;
7148 DoBindTexture(target, client_texture_id_, kServiceTextureId);
7149
7150 // Create a depth texture.
7151 DoTexImage2D(target, level, GL_DEPTH_COMPONENT, 1, 1, 0,
7152 GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 0, 0);
7153
7154 EXPECT_CALL(*gl_, GenFramebuffersEXT(1, _))
7155 .Times(1)
7156 .RetiresOnSaturation();
7157 EXPECT_CALL(*gl_, BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, _))
7158 .Times(1)
7159 .RetiresOnSaturation();
7160
7161 EXPECT_CALL(*gl_, FramebufferTexture2DEXT(
7162 GL_DRAW_FRAMEBUFFER_EXT, attachment, target, kServiceTextureId, level))
7163 .Times(1)
7164 .RetiresOnSaturation();
7165 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER_EXT))
7166 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE))
7167 .RetiresOnSaturation();
7168
7169 EXPECT_CALL(*gl_, ClearStencil(0))
7170 .Times(1)
7171 .RetiresOnSaturation();
7172 EXPECT_CALL(*gl_, StencilMask(-1))
7173 .Times(1)
7174 .RetiresOnSaturation();
7175 EXPECT_CALL(*gl_, ClearDepth(1.0f))
7176 .Times(1)
7177 .RetiresOnSaturation();
7178 EXPECT_CALL(*gl_, DepthMask(true))
7179 .Times(1)
7180 .RetiresOnSaturation();
7181 EXPECT_CALL(*gl_, Disable(GL_SCISSOR_TEST))
7182 .Times(1)
7183 .RetiresOnSaturation();
7184
7185 EXPECT_CALL(*gl_, Clear(GL_DEPTH_BUFFER_BIT))
7186 .Times(1)
7187 .RetiresOnSaturation();
7188
7189 SetupExpectationsForRestoreClearState(
7190 0.0f, 0.0f, 0.0f, 0.0f, 0, 1.0f, false);
7191
7192 EXPECT_CALL(*gl_, DeleteFramebuffersEXT(1, _))
7193 .Times(1)
7194 .RetiresOnSaturation();
7195 EXPECT_CALL(*gl_, BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0))
7196 .Times(1)
7197 .RetiresOnSaturation();
7198
7199 SetupExpectationsForApplyingDefaultDirtyState();
7200 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
7201 .Times(1)
7202 .RetiresOnSaturation();
7203 DrawArrays cmd;
7204 cmd.Init(GL_TRIANGLES, 0, kNumVertices);
7205 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
7206 EXPECT_EQ(GL_NO_ERROR, GetGLError());
7207 }
7208
7053 // TODO(gman): Complete this test. 7209 // TODO(gman): Complete this test.
7054 // TEST_F(GLES2DecoderTest, CompressedTexImage2DGLError) { 7210 // TEST_F(GLES2DecoderTest, CompressedTexImage2DGLError) {
7055 // } 7211 // }
7056 7212
7057 // TODO(gman): BufferData 7213 // TODO(gman): BufferData
7058 7214
7059 // TODO(gman): BufferDataImmediate 7215 // TODO(gman): BufferDataImmediate
7060 7216
7061 // TODO(gman): BufferSubData 7217 // TODO(gman): BufferSubData
7062 7218
(...skipping 16 matching lines...) Expand all
7079 // TODO(gman): TexImage2DImmediate 7235 // TODO(gman): TexImage2DImmediate
7080 7236
7081 // TODO(gman): TexSubImage2DImmediate 7237 // TODO(gman): TexSubImage2DImmediate
7082 7238
7083 // TODO(gman): UseProgram 7239 // TODO(gman): UseProgram
7084 7240
7085 // TODO(gman): SwapBuffers 7241 // TODO(gman): SwapBuffers
7086 7242
7087 } // namespace gles2 7243 } // namespace gles2
7088 } // namespace gpu 7244 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder.cc ('k') | gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698