| OLD | NEW |
| 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_unittest.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" |
| 11 #include "gpu/command_buffer/common/id_allocator.h" | 11 #include "gpu/command_buffer/common/id_allocator.h" |
| 12 #include "gpu/command_buffer/service/async_pixel_transfer_delegate_mock.h" | 12 #include "gpu/command_buffer/service/async_pixel_transfer_delegate_mock.h" |
| 13 #include "gpu/command_buffer/service/async_pixel_transfer_manager.h" | 13 #include "gpu/command_buffer/service/async_pixel_transfer_manager.h" |
| 14 #include "gpu/command_buffer/service/async_pixel_transfer_manager_mock.h" | 14 #include "gpu/command_buffer/service/async_pixel_transfer_manager_mock.h" |
| 15 #include "gpu/command_buffer/service/cmd_buffer_engine.h" | 15 #include "gpu/command_buffer/service/cmd_buffer_engine.h" |
| 16 #include "gpu/command_buffer/service/context_group.h" | 16 #include "gpu/command_buffer/service/context_group.h" |
| 17 #include "gpu/command_buffer/service/context_state.h" | 17 #include "gpu/command_buffer/service/context_state.h" |
| 18 #include "gpu/command_buffer/service/gl_surface_mock.h" | 18 #include "gpu/command_buffer/service/gl_surface_mock.h" |
| 19 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h" | 19 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 20 #include "gpu/command_buffer/service/gpu_switches.h" | 20 #include "gpu/command_buffer/service/gpu_switches.h" |
| 21 #include "gpu/command_buffer/service/image_manager.h" | 21 #include "gpu/command_buffer/service/image_manager.h" |
| 22 #include "gpu/command_buffer/service/mailbox_manager.h" | 22 #include "gpu/command_buffer/service/mailbox_manager.h" |
| 23 #include "gpu/command_buffer/service/mocks.h" | 23 #include "gpu/command_buffer/service/mocks.h" |
| 24 #include "gpu/command_buffer/service/program_manager.h" | 24 #include "gpu/command_buffer/service/program_manager.h" |
| 25 #include "gpu/command_buffer/service/test_helper.h" | 25 #include "gpu/command_buffer/service/test_helper.h" |
| 26 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
| 27 #include "ui/gl/gl_implementation.h" | 27 #include "ui/gl/gl_implementation.h" |
| 28 #include "ui/gl/gl_mock.h" | 28 #include "ui/gl/gl_mock.h" |
| 29 #include "ui/gl/gl_surface_stub.h" | 29 #include "ui/gl/gl_surface_stub.h" |
| 30 | 30 |
| 31 | 31 |
| 32 #if !defined(GL_DEPTH24_STENCIL8) | 32 #if !defined(GL_DEPTH24_STENCIL8) |
| 33 #define GL_DEPTH24_STENCIL8 0x88F0 | 33 #define GL_DEPTH24_STENCIL8 0x88F0 |
| 34 #endif | 34 #endif |
| 35 | 35 |
| 36 using ::gfx::MockGLInterface; | 36 using ::gfx::MockGLInterface; |
| 37 using ::testing::_; | 37 using ::testing::_; |
| 38 using ::testing::DoAll; | 38 using ::testing::DoAll; |
| 39 using ::testing::InSequence; | 39 using ::testing::InSequence; |
| 40 using ::testing::Invoke; | 40 using ::testing::Invoke; |
| 41 using ::testing::MatcherCast; | 41 using ::testing::MatcherCast; |
| 42 using ::testing::Mock; |
| 42 using ::testing::Pointee; | 43 using ::testing::Pointee; |
| 43 using ::testing::Return; | 44 using ::testing::Return; |
| 44 using ::testing::SaveArg; | 45 using ::testing::SaveArg; |
| 45 using ::testing::SetArrayArgument; | 46 using ::testing::SetArrayArgument; |
| 46 using ::testing::SetArgumentPointee; | 47 using ::testing::SetArgumentPointee; |
| 47 using ::testing::SetArgPointee; | 48 using ::testing::SetArgPointee; |
| 48 using ::testing::StrEq; | 49 using ::testing::StrEq; |
| 49 using ::testing::StrictMock; | 50 using ::testing::StrictMock; |
| 50 | 51 |
| 51 namespace gpu { | 52 namespace gpu { |
| 52 namespace gles2 { | 53 namespace gles2 { |
| 53 | 54 |
| 54 using namespace cmds; | 55 using namespace cmds; |
| 55 | 56 |
| 56 class GLES2DecoderTest : public GLES2DecoderTestBase { | 57 void GLES2DecoderRGBBackbufferTest::SetUp() { |
| 57 public: | 58 // Test codepath with workaround clear_alpha_in_readpixels because |
| 58 GLES2DecoderTest() { } | 59 // ReadPixelsEmulator emulates the incorrect driver behavior. |
| 59 | |
| 60 protected: | |
| 61 void CheckReadPixelsOutOfRange( | |
| 62 GLint in_read_x, GLint in_read_y, | |
| 63 GLsizei in_read_width, GLsizei in_read_height, | |
| 64 bool init); | |
| 65 }; | |
| 66 | |
| 67 class GLES2DecoderTestWithExtensionsOnGLES2 | |
| 68 : public GLES2DecoderTest, | |
| 69 public ::testing::WithParamInterface<const char*> { | |
| 70 public: | |
| 71 GLES2DecoderTestWithExtensionsOnGLES2() {} | |
| 72 | |
| 73 virtual void SetUp() { | |
| 74 InitState init; | |
| 75 init.extensions = GetParam(); | |
| 76 init.gl_version = "opengl es 2.0"; | |
| 77 init.has_alpha = true; | |
| 78 init.has_depth = true; | |
| 79 init.request_alpha = true; | |
| 80 init.request_depth = true; | |
| 81 InitDecoder(init); | |
| 82 } | |
| 83 }; | |
| 84 | |
| 85 class GLES2DecoderWithShaderTest : public GLES2DecoderWithShaderTestBase { | |
| 86 public: | |
| 87 GLES2DecoderWithShaderTest() | |
| 88 : GLES2DecoderWithShaderTestBase() { | |
| 89 } | |
| 90 | |
| 91 void CheckTextureChangesMarkFBOAsNotComplete(bool bound_fbo); | |
| 92 void CheckRenderbufferChangesMarkFBOAsNotComplete(bool bound_fbo); | |
| 93 }; | |
| 94 | |
| 95 class GLES2DecoderGeometryInstancingTest : public GLES2DecoderWithShaderTest { | |
| 96 public: | |
| 97 GLES2DecoderGeometryInstancingTest() | |
| 98 : GLES2DecoderWithShaderTest() { | |
| 99 } | |
| 100 | |
| 101 virtual void SetUp() { | |
| 102 InitState init; | |
| 103 init.extensions = "GL_ANGLE_instanced_arrays"; | |
| 104 init.gl_version = "opengl es 2.0"; | |
| 105 init.has_alpha = true; | |
| 106 init.has_depth = true; | |
| 107 init.request_alpha = true; | |
| 108 init.request_depth = true; | |
| 109 init.bind_generates_resource = true; | |
| 110 InitDecoder(init); | |
| 111 SetupDefaultProgram(); | |
| 112 } | |
| 113 }; | |
| 114 | |
| 115 class GLES2DecoderRGBBackbufferTest : public GLES2DecoderWithShaderTest { | |
| 116 public: | |
| 117 GLES2DecoderRGBBackbufferTest() { } | |
| 118 | |
| 119 virtual void SetUp() { | |
| 120 // Test codepath with workaround clear_alpha_in_readpixels because | |
| 121 // ReadPixelsEmulator emulates the incorrect driver behavior. | |
| 122 CommandLine command_line(0, NULL); | |
| 123 command_line.AppendSwitchASCII( | |
| 124 switches::kGpuDriverBugWorkarounds, | |
| 125 base::IntToString(gpu::CLEAR_ALPHA_IN_READPIXELS)); | |
| 126 InitState init; | |
| 127 init.gl_version = "3.0"; | |
| 128 init.bind_generates_resource = true; | |
| 129 InitDecoderWithCommandLine(init, &command_line); | |
| 130 SetupDefaultProgram(); | |
| 131 } | |
| 132 }; | |
| 133 | |
| 134 class GLES2DecoderManualInitTest : public GLES2DecoderWithShaderTest { | |
| 135 public: | |
| 136 GLES2DecoderManualInitTest() { } | |
| 137 | |
| 138 // Override default setup so nothing gets setup. | |
| 139 virtual void SetUp() { | |
| 140 } | |
| 141 }; | |
| 142 | |
| 143 class GLES2DecoderCompressedFormatsTest : public GLES2DecoderManualInitTest { | |
| 144 public: | |
| 145 GLES2DecoderCompressedFormatsTest() { } | |
| 146 | |
| 147 static bool ValueInArray(GLint value, GLint* array, GLint count) { | |
| 148 for (GLint ii = 0; ii < count; ++ii) { | |
| 149 if (array[ii] == value) { | |
| 150 return true; | |
| 151 } | |
| 152 } | |
| 153 return false; | |
| 154 } | |
| 155 | |
| 156 void CheckFormats(const char* extension, const GLenum* formats, int count) { | |
| 157 InitState init; | |
| 158 init.extensions = extension; | |
| 159 init.gl_version = "3.0"; | |
| 160 init.bind_generates_resource = true; | |
| 161 InitDecoder(init); | |
| 162 | |
| 163 EXPECT_CALL(*gl_, GetError()) | |
| 164 .WillOnce(Return(GL_NO_ERROR)) | |
| 165 .WillOnce(Return(GL_NO_ERROR)) | |
| 166 .WillOnce(Return(GL_NO_ERROR)) | |
| 167 .WillOnce(Return(GL_NO_ERROR)) | |
| 168 .RetiresOnSaturation(); | |
| 169 | |
| 170 typedef GetIntegerv::Result Result; | |
| 171 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 172 GetIntegerv cmd; | |
| 173 result->size = 0; | |
| 174 EXPECT_CALL(*gl_, GetIntegerv(_, _)) | |
| 175 .Times(0) | |
| 176 .RetiresOnSaturation(); | |
| 177 cmd.Init( | |
| 178 GL_NUM_COMPRESSED_TEXTURE_FORMATS, | |
| 179 shared_memory_id_, shared_memory_offset_); | |
| 180 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 181 EXPECT_EQ(1, result->GetNumResults()); | |
| 182 GLint num_formats = result->GetData()[0]; | |
| 183 EXPECT_EQ(count, num_formats); | |
| 184 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 185 | |
| 186 result->size = 0; | |
| 187 cmd.Init( | |
| 188 GL_COMPRESSED_TEXTURE_FORMATS, | |
| 189 shared_memory_id_, shared_memory_offset_); | |
| 190 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 191 EXPECT_EQ(num_formats, result->GetNumResults()); | |
| 192 | |
| 193 for (int i = 0; i < count; ++i) { | |
| 194 EXPECT_TRUE(ValueInArray( | |
| 195 formats[i], | |
| 196 result->GetData(), result->GetNumResults())); | |
| 197 } | |
| 198 | |
| 199 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 200 } | |
| 201 }; | |
| 202 | |
| 203 class GLES2DecoderRestoreStateTest : public GLES2DecoderManualInitTest { | |
| 204 public: | |
| 205 GLES2DecoderRestoreStateTest() { } | |
| 206 | |
| 207 protected: | |
| 208 void AddExpectationsForActiveTexture(GLenum unit); | |
| 209 void AddExpectationsForBindTexture(GLenum target, GLuint id); | |
| 210 void InitializeContextState( | |
| 211 ContextState* state, uint32 non_default_unit, uint32 active_unit); | |
| 212 }; | |
| 213 | |
| 214 void GLES2DecoderRestoreStateTest::AddExpectationsForActiveTexture( | |
| 215 GLenum unit) { | |
| 216 EXPECT_CALL(*gl_, ActiveTexture(unit)) | |
| 217 .Times(1) | |
| 218 .RetiresOnSaturation(); | |
| 219 } | |
| 220 | |
| 221 void GLES2DecoderRestoreStateTest::AddExpectationsForBindTexture(GLenum target, | |
| 222 GLuint id) { | |
| 223 EXPECT_CALL(*gl_, BindTexture(target, id)) | |
| 224 .Times(1) | |
| 225 .RetiresOnSaturation(); | |
| 226 } | |
| 227 | |
| 228 void GLES2DecoderRestoreStateTest::InitializeContextState( | |
| 229 ContextState* state, uint32 non_default_unit, uint32 active_unit) { | |
| 230 state->texture_units.resize(group().max_texture_units()); | |
| 231 for (uint32 tt = 0; tt < state->texture_units.size(); ++tt) { | |
| 232 TextureRef* ref_cube_map = | |
| 233 group().texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_CUBE_MAP); | |
| 234 state->texture_units[tt].bound_texture_cube_map = ref_cube_map; | |
| 235 TextureRef* ref_2d = | |
| 236 (tt == non_default_unit) | |
| 237 ? group().texture_manager()->GetTexture(client_texture_id_) | |
| 238 : group().texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_2D); | |
| 239 state->texture_units[tt].bound_texture_2d = ref_2d; | |
| 240 } | |
| 241 state->active_texture_unit = active_unit; | |
| 242 } | |
| 243 | |
| 244 TEST_F(GLES2DecoderWithShaderTest, DrawArraysNoAttributesSucceeds) { | |
| 245 SetupTexture(); | |
| 246 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); | |
| 247 SetupExpectationsForApplyingDefaultDirtyState(); | |
| 248 | |
| 249 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | |
| 250 .Times(1) | |
| 251 .RetiresOnSaturation(); | |
| 252 DrawArrays cmd; | |
| 253 cmd.Init(GL_TRIANGLES, 0, kNumVertices); | |
| 254 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 255 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 256 } | |
| 257 | |
| 258 // Tests when the math overflows (0x40000000 * sizeof GLfloat) | |
| 259 TEST_F(GLES2DecoderWithShaderTest, DrawArraysSimulatedAttrib0OverflowFails) { | |
| 260 const GLsizei kLargeCount = 0x40000000; | |
| 261 SetupTexture(); | |
| 262 EXPECT_CALL(*gl_, DrawArrays(_, _, _)) | |
| 263 .Times(0) | |
| 264 .RetiresOnSaturation(); | |
| 265 DrawArrays cmd; | |
| 266 cmd.Init(GL_TRIANGLES, 0, kLargeCount); | |
| 267 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 268 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); | |
| 269 EXPECT_FALSE(GetDecoder()->WasContextLost()); | |
| 270 } | |
| 271 | |
| 272 // Tests when the math overflows (0x7FFFFFFF + 1 = 0x8000000 verts) | |
| 273 TEST_F(GLES2DecoderWithShaderTest, DrawArraysSimulatedAttrib0PosToNegFails) { | |
| 274 const GLsizei kLargeCount = 0x7FFFFFFF; | |
| 275 SetupTexture(); | |
| 276 EXPECT_CALL(*gl_, DrawArrays(_, _, _)) | |
| 277 .Times(0) | |
| 278 .RetiresOnSaturation(); | |
| 279 DrawArrays cmd; | |
| 280 cmd.Init(GL_TRIANGLES, 0, kLargeCount); | |
| 281 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 282 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); | |
| 283 EXPECT_FALSE(GetDecoder()->WasContextLost()); | |
| 284 } | |
| 285 | |
| 286 // Tests when the driver returns an error | |
| 287 TEST_F(GLES2DecoderWithShaderTest, DrawArraysSimulatedAttrib0OOMFails) { | |
| 288 const GLsizei kFakeLargeCount = 0x1234; | |
| 289 SetupTexture(); | |
| 290 AddExpectationsForSimulatedAttrib0WithError( | |
| 291 kFakeLargeCount, 0, GL_OUT_OF_MEMORY); | |
| 292 EXPECT_CALL(*gl_, DrawArrays(_, _, _)) | |
| 293 .Times(0) | |
| 294 .RetiresOnSaturation(); | |
| 295 DrawArrays cmd; | |
| 296 cmd.Init(GL_TRIANGLES, 0, kFakeLargeCount); | |
| 297 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 298 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); | |
| 299 EXPECT_FALSE(GetDecoder()->WasContextLost()); | |
| 300 } | |
| 301 | |
| 302 // Test that we lose context. | |
| 303 TEST_F(GLES2DecoderManualInitTest, LoseContextWhenOOM) { | |
| 304 InitState init; | |
| 305 init.gl_version = "3.0"; | |
| 306 init.has_alpha = true; | |
| 307 init.has_depth = true; | |
| 308 init.request_alpha = true; | |
| 309 init.request_depth = true; | |
| 310 init.bind_generates_resource = true; | |
| 311 init.lose_context_when_out_of_memory = true; | |
| 312 InitDecoder(init); | |
| 313 SetupDefaultProgram(); | |
| 314 | |
| 315 const GLsizei kFakeLargeCount = 0x1234; | |
| 316 SetupTexture(); | |
| 317 AddExpectationsForSimulatedAttrib0WithError( | |
| 318 kFakeLargeCount, 0, GL_OUT_OF_MEMORY); | |
| 319 EXPECT_CALL(*gl_, DrawArrays(_, _, _)).Times(0).RetiresOnSaturation(); | |
| 320 // Other contexts in the group should be lost also. | |
| 321 EXPECT_CALL(*mock_decoder_, LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB)) | |
| 322 .Times(1) | |
| 323 .RetiresOnSaturation(); | |
| 324 DrawArrays cmd; | |
| 325 cmd.Init(GL_TRIANGLES, 0, kFakeLargeCount); | |
| 326 // This context should be lost. | |
| 327 EXPECT_EQ(error::kLostContext, ExecuteCmd(cmd)); | |
| 328 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); | |
| 329 EXPECT_TRUE(decoder_->WasContextLost()); | |
| 330 } | |
| 331 | |
| 332 TEST_F(GLES2DecoderWithShaderTest, DrawArraysBadTextureUsesBlack) { | |
| 333 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 334 // This is an NPOT texture. As the default filtering requires mips | |
| 335 // this should trigger replacing with black textures before rendering. | |
| 336 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 337 kSharedMemoryId, kSharedMemoryOffset); | |
| 338 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); | |
| 339 { | |
| 340 InSequence sequence; | |
| 341 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)) | |
| 342 .Times(1) | |
| 343 .RetiresOnSaturation(); | |
| 344 EXPECT_CALL(*gl_, BindTexture( | |
| 345 GL_TEXTURE_2D, TestHelper::kServiceBlackTexture2dId)) | |
| 346 .Times(1) | |
| 347 .RetiresOnSaturation(); | |
| 348 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | |
| 349 .Times(1) | |
| 350 .RetiresOnSaturation(); | |
| 351 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)) | |
| 352 .Times(1) | |
| 353 .RetiresOnSaturation(); | |
| 354 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId)) | |
| 355 .Times(1) | |
| 356 .RetiresOnSaturation(); | |
| 357 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)) | |
| 358 .Times(1) | |
| 359 .RetiresOnSaturation(); | |
| 360 } | |
| 361 SetupExpectationsForApplyingDefaultDirtyState(); | |
| 362 DrawArrays cmd; | |
| 363 cmd.Init(GL_TRIANGLES, 0, kNumVertices); | |
| 364 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 365 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 366 } | |
| 367 | |
| 368 TEST_F(GLES2DecoderWithShaderTest, DrawArraysMissingAttributesFails) { | |
| 369 DoEnableVertexAttribArray(1); | |
| 370 | |
| 371 EXPECT_CALL(*gl_, DrawArrays(_, _, _)) | |
| 372 .Times(0); | |
| 373 DrawArrays cmd; | |
| 374 cmd.Init(GL_TRIANGLES, 0, kNumVertices); | |
| 375 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 376 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 377 } | |
| 378 | |
| 379 TEST_F(GLES2DecoderWithShaderTest, | |
| 380 DrawArraysMissingAttributesZeroCountSucceeds) { | |
| 381 DoEnableVertexAttribArray(1); | |
| 382 | |
| 383 EXPECT_CALL(*gl_, DrawArrays(_, _, _)) | |
| 384 .Times(0); | |
| 385 DrawArrays cmd; | |
| 386 cmd.Init(GL_TRIANGLES, 0, 0); | |
| 387 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 388 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 389 } | |
| 390 | |
| 391 TEST_F(GLES2DecoderWithShaderTest, DrawArraysValidAttributesSucceeds) { | |
| 392 SetupTexture(); | |
| 393 SetupVertexBuffer(); | |
| 394 DoEnableVertexAttribArray(1); | |
| 395 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); | |
| 396 AddExpectationsForSimulatedAttrib0(kNumVertices, kServiceBufferId); | |
| 397 SetupExpectationsForApplyingDefaultDirtyState(); | |
| 398 | |
| 399 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | |
| 400 .Times(1) | |
| 401 .RetiresOnSaturation(); | |
| 402 DrawArrays cmd; | |
| 403 cmd.Init(GL_TRIANGLES, 0, kNumVertices); | |
| 404 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 405 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 406 } | |
| 407 | |
| 408 // Same as DrawArraysValidAttributesSucceeds, but with workaround | |
| 409 // |init_vertex_attributes|. | |
| 410 TEST_F(GLES2DecoderManualInitTest, InitVertexAttributes) { | |
| 411 CommandLine command_line(0, NULL); | 60 CommandLine command_line(0, NULL); |
| 412 command_line.AppendSwitchASCII( | 61 command_line.AppendSwitchASCII( |
| 413 switches::kGpuDriverBugWorkarounds, | 62 switches::kGpuDriverBugWorkarounds, |
| 414 base::IntToString(gpu::INIT_VERTEX_ATTRIBUTES)); | 63 base::IntToString(gpu::CLEAR_ALPHA_IN_READPIXELS)); |
| 415 InitState init; | 64 InitState init; |
| 416 init.gl_version = "3.0"; | 65 init.gl_version = "3.0"; |
| 417 init.has_alpha = true; | |
| 418 init.has_depth = true; | |
| 419 init.request_alpha = true; | |
| 420 init.request_depth = true; | |
| 421 init.bind_generates_resource = true; | 66 init.bind_generates_resource = true; |
| 422 InitDecoderWithCommandLine(init, &command_line); | 67 InitDecoderWithCommandLine(init, &command_line); |
| 423 SetupDefaultProgram(); | 68 SetupDefaultProgram(); |
| 424 SetupTexture(); | 69 } |
| 425 SetupVertexBuffer(); | 70 |
| 426 DoEnableVertexAttribArray(1); | 71 // Override default setup so nothing gets setup. |
| 427 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); | 72 void GLES2DecoderManualInitTest::SetUp() { |
| 428 AddExpectationsForSimulatedAttrib0(kNumVertices, kServiceBufferId); | |
| 429 SetupExpectationsForApplyingDefaultDirtyState(); | |
| 430 | |
| 431 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | |
| 432 .Times(1) | |
| 433 .RetiresOnSaturation(); | |
| 434 DrawArrays cmd; | |
| 435 cmd.Init(GL_TRIANGLES, 0, kNumVertices); | |
| 436 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 437 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 438 } | |
| 439 | |
| 440 TEST_F(GLES2DecoderWithShaderTest, DrawArraysDeletedBufferFails) { | |
| 441 SetupVertexBuffer(); | |
| 442 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); | |
| 443 DeleteVertexBuffer(); | |
| 444 | |
| 445 EXPECT_CALL(*gl_, DrawArrays(_, _, _)) | |
| 446 .Times(0); | |
| 447 DrawArrays cmd; | |
| 448 cmd.Init(GL_TRIANGLES, 0, kNumVertices); | |
| 449 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 450 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 451 } | |
| 452 | |
| 453 TEST_F(GLES2DecoderWithShaderTest, DrawArraysDeletedProgramSucceeds) { | |
| 454 SetupTexture(); | |
| 455 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); | |
| 456 SetupExpectationsForApplyingDefaultDirtyState(); | |
| 457 DoDeleteProgram(client_program_id_, kServiceProgramId); | |
| 458 | |
| 459 EXPECT_CALL(*gl_, DrawArrays(_, _, _)) | |
| 460 .Times(1) | |
| 461 .RetiresOnSaturation(); | |
| 462 EXPECT_CALL(*gl_, DeleteProgram(kServiceProgramId)) | |
| 463 .Times(1); | |
| 464 DrawArrays cmd; | |
| 465 cmd.Init(GL_TRIANGLES, 0, kNumVertices); | |
| 466 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 467 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 468 } | |
| 469 | |
| 470 TEST_F(GLES2DecoderWithShaderTest, DrawArraysWithInvalidModeFails) { | |
| 471 SetupVertexBuffer(); | |
| 472 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); | |
| 473 | |
| 474 EXPECT_CALL(*gl_, DrawArrays(_, _, _)) | |
| 475 .Times(0); | |
| 476 DrawArrays cmd; | |
| 477 cmd.Init(GL_QUADS, 0, 1); | |
| 478 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 479 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | |
| 480 cmd.Init(GL_POLYGON, 0, 1); | |
| 481 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 482 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | |
| 483 } | |
| 484 | |
| 485 TEST_F(GLES2DecoderWithShaderTest, DrawArraysInvalidCountFails) { | |
| 486 SetupVertexBuffer(); | |
| 487 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); | |
| 488 | |
| 489 // Try start > 0 | |
| 490 EXPECT_CALL(*gl_, DrawArrays(_, _, _)).Times(0); | |
| 491 DrawArrays cmd; | |
| 492 cmd.Init(GL_TRIANGLES, 1, kNumVertices); | |
| 493 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 494 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 495 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 496 | |
| 497 // Try with count > size | |
| 498 cmd.Init(GL_TRIANGLES, 0, kNumVertices + 1); | |
| 499 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 500 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 501 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 502 | |
| 503 // Try with attrib offset > 0 | |
| 504 cmd.Init(GL_TRIANGLES, 0, kNumVertices); | |
| 505 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 4); | |
| 506 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 507 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 508 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 509 | |
| 510 // Try with size > 2 (ie, vec3 instead of vec2) | |
| 511 DoVertexAttribPointer(1, 3, GL_FLOAT, 0, 0); | |
| 512 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 513 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 514 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 515 | |
| 516 // Try with stride > 8 (vec2 + vec2 byte) | |
| 517 DoVertexAttribPointer(1, 2, GL_FLOAT, sizeof(GLfloat) * 3, 0); | |
| 518 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 519 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 520 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 521 } | |
| 522 | |
| 523 TEST_F(GLES2DecoderWithShaderTest, DrawArraysInstancedANGLEFails) { | |
| 524 SetupTexture(); | |
| 525 SetupVertexBuffer(); | |
| 526 DoEnableVertexAttribArray(1); | |
| 527 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); | |
| 528 | |
| 529 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(_, _, _, _)) | |
| 530 .Times(0) | |
| 531 .RetiresOnSaturation(); | |
| 532 DrawArraysInstancedANGLE cmd; | |
| 533 cmd.Init(GL_TRIANGLES, 0, kNumVertices, 1); | |
| 534 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 535 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 536 } | |
| 537 | |
| 538 TEST_F(GLES2DecoderGeometryInstancingTest, | |
| 539 DrawArraysInstancedANGLENoAttributesFails) { | |
| 540 SetupTexture(); | |
| 541 | |
| 542 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(_, _, _, _)) | |
| 543 .Times(0) | |
| 544 .RetiresOnSaturation(); | |
| 545 DrawArraysInstancedANGLE cmd; | |
| 546 cmd.Init(GL_TRIANGLES, 0, kNumVertices, 1); | |
| 547 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 548 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 549 } | |
| 550 | |
| 551 TEST_F(GLES2DecoderGeometryInstancingTest, | |
| 552 DrawArraysInstancedANGLESimulatedAttrib0) { | |
| 553 SetupTexture(); | |
| 554 SetupVertexBuffer(); | |
| 555 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); | |
| 556 | |
| 557 AddExpectationsForSimulatedAttrib0(kNumVertices, kServiceBufferId); | |
| 558 SetupExpectationsForApplyingDefaultDirtyState(); | |
| 559 | |
| 560 DoVertexAttribDivisorANGLE(0, 1); | |
| 561 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(GL_TRIANGLES, 0, kNumVertices, 3)) | |
| 562 .Times(1) | |
| 563 .RetiresOnSaturation(); | |
| 564 EXPECT_CALL(*gl_, VertexAttribDivisorANGLE(0, 0)) | |
| 565 .Times(1) | |
| 566 .RetiresOnSaturation(); | |
| 567 EXPECT_CALL(*gl_, VertexAttribDivisorANGLE(0, 1)) | |
| 568 .Times(1) | |
| 569 .RetiresOnSaturation(); | |
| 570 DrawArraysInstancedANGLE cmd; | |
| 571 cmd.Init(GL_TRIANGLES, 0, kNumVertices, 3); | |
| 572 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 573 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 574 } | |
| 575 | |
| 576 TEST_F(GLES2DecoderGeometryInstancingTest, | |
| 577 DrawArraysInstancedANGLEMissingAttributesFails) { | |
| 578 DoEnableVertexAttribArray(1); | |
| 579 | |
| 580 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(_, _, _, _)) | |
| 581 .Times(0); | |
| 582 DrawArraysInstancedANGLE cmd; | |
| 583 cmd.Init(GL_TRIANGLES, 0, kNumVertices, 1); | |
| 584 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 585 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 586 } | |
| 587 | |
| 588 TEST_F(GLES2DecoderGeometryInstancingTest, | |
| 589 DrawArraysInstancedANGLEMissingAttributesZeroCountSucceeds) { | |
| 590 DoEnableVertexAttribArray(1); | |
| 591 | |
| 592 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(_, _, _, _)) | |
| 593 .Times(0); | |
| 594 DrawArraysInstancedANGLE cmd; | |
| 595 cmd.Init(GL_TRIANGLES, 0, 0, 1); | |
| 596 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 597 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 598 } | |
| 599 | |
| 600 TEST_F(GLES2DecoderGeometryInstancingTest, | |
| 601 DrawArraysInstancedANGLEValidAttributesSucceeds) { | |
| 602 SetupTexture(); | |
| 603 SetupVertexBuffer(); | |
| 604 DoEnableVertexAttribArray(1); | |
| 605 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); | |
| 606 AddExpectationsForSimulatedAttrib0(kNumVertices, kServiceBufferId); | |
| 607 SetupExpectationsForApplyingDefaultDirtyState(); | |
| 608 | |
| 609 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(GL_TRIANGLES, 0, kNumVertices, 1)) | |
| 610 .Times(1) | |
| 611 .RetiresOnSaturation(); | |
| 612 DrawArraysInstancedANGLE cmd; | |
| 613 cmd.Init(GL_TRIANGLES, 0, kNumVertices, 1); | |
| 614 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 615 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 616 } | |
| 617 | |
| 618 TEST_F(GLES2DecoderGeometryInstancingTest, | |
| 619 DrawArraysInstancedANGLEWithInvalidModeFails) { | |
| 620 SetupVertexBuffer(); | |
| 621 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); | |
| 622 | |
| 623 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(_, _, _, _)) | |
| 624 .Times(0); | |
| 625 DrawArraysInstancedANGLE cmd; | |
| 626 cmd.Init(GL_QUADS, 0, 1, 1); | |
| 627 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 628 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | |
| 629 cmd.Init(GL_POLYGON, 0, 1, 1); | |
| 630 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 631 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | |
| 632 } | |
| 633 | |
| 634 TEST_F(GLES2DecoderGeometryInstancingTest, | |
| 635 DrawArraysInstancedANGLEInvalidPrimcountFails) { | |
| 636 SetupVertexBuffer(); | |
| 637 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); | |
| 638 | |
| 639 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(_, _, _, _)) | |
| 640 .Times(0); | |
| 641 DrawArraysInstancedANGLE cmd; | |
| 642 cmd.Init(GL_TRIANGLES, 0, 1, -1); | |
| 643 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 644 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 645 } | |
| 646 | |
| 647 // Per-instance data is twice as large, but number of instances is half | |
| 648 TEST_F(GLES2DecoderGeometryInstancingTest, | |
| 649 DrawArraysInstancedANGLELargeInstanceSucceeds) { | |
| 650 SetupTexture(); | |
| 651 SetupVertexBuffer(); | |
| 652 SetupExpectationsForApplyingDefaultDirtyState(); | |
| 653 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); | |
| 654 | |
| 655 DoEnableVertexAttribArray(0); | |
| 656 DoVertexAttribPointer(0, 4, GL_FLOAT, 0, 0); | |
| 657 DoVertexAttribDivisorANGLE(0, 1); | |
| 658 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(GL_TRIANGLES, 0, kNumVertices, | |
| 659 kNumVertices / 2)) | |
| 660 .Times(1) | |
| 661 .RetiresOnSaturation(); | |
| 662 DrawArraysInstancedANGLE cmd; | |
| 663 cmd.Init(GL_TRIANGLES, 0, kNumVertices, kNumVertices / 2); | |
| 664 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 665 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 666 } | |
| 667 | |
| 668 // Per-instance data is twice as large, but divisor is twice | |
| 669 TEST_F(GLES2DecoderGeometryInstancingTest, | |
| 670 DrawArraysInstancedANGLELargeDivisorSucceeds) { | |
| 671 SetupTexture(); | |
| 672 SetupVertexBuffer(); | |
| 673 SetupExpectationsForApplyingDefaultDirtyState(); | |
| 674 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); | |
| 675 | |
| 676 DoEnableVertexAttribArray(0); | |
| 677 DoVertexAttribPointer(0, 4, GL_FLOAT, 0, 0); | |
| 678 DoVertexAttribDivisorANGLE(0, 2); | |
| 679 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(GL_TRIANGLES, 0, kNumVertices, | |
| 680 kNumVertices)) | |
| 681 .Times(1) | |
| 682 .RetiresOnSaturation(); | |
| 683 DrawArraysInstancedANGLE cmd; | |
| 684 cmd.Init(GL_TRIANGLES, 0, kNumVertices, kNumVertices); | |
| 685 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 686 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 687 } | |
| 688 | |
| 689 TEST_F(GLES2DecoderGeometryInstancingTest, DrawArraysInstancedANGLELargeFails) { | |
| 690 SetupTexture(); | |
| 691 SetupVertexBuffer(); | |
| 692 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); | |
| 693 | |
| 694 DoEnableVertexAttribArray(0); | |
| 695 DoVertexAttribPointer(0, 2, GL_FLOAT, 0, 0); | |
| 696 DoVertexAttribDivisorANGLE(0, 1); | |
| 697 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(_, _, _, _)) | |
| 698 .Times(0) | |
| 699 .RetiresOnSaturation(); | |
| 700 DrawArraysInstancedANGLE cmd; | |
| 701 cmd.Init(GL_TRIANGLES, 0, kNumVertices, kNumVertices + 1); | |
| 702 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 703 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 704 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 705 | |
| 706 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(_, _, _, _)) | |
| 707 .Times(0) | |
| 708 .RetiresOnSaturation(); | |
| 709 cmd.Init(GL_TRIANGLES, 0, kNumVertices + 1, kNumVertices); | |
| 710 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 711 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 712 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 713 } | |
| 714 | |
| 715 // Per-index data is twice as large, but number of indices is half | |
| 716 TEST_F(GLES2DecoderGeometryInstancingTest, | |
| 717 DrawArraysInstancedANGLELargeIndexSucceeds) { | |
| 718 SetupTexture(); | |
| 719 SetupVertexBuffer(); | |
| 720 SetupExpectationsForApplyingDefaultDirtyState(); | |
| 721 DoVertexAttribPointer(1, 4, GL_FLOAT, 0, 0); | |
| 722 | |
| 723 DoEnableVertexAttribArray(0); | |
| 724 DoVertexAttribPointer(0, 2, GL_FLOAT, 0, 0); | |
| 725 DoVertexAttribDivisorANGLE(0, 1); | |
| 726 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(GL_TRIANGLES, 0, kNumVertices / 2, | |
| 727 kNumVertices)) | |
| 728 .Times(1) | |
| 729 .RetiresOnSaturation(); | |
| 730 DrawArraysInstancedANGLE cmd; | |
| 731 cmd.Init(GL_TRIANGLES, 0, kNumVertices / 2, kNumVertices); | |
| 732 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 733 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 734 } | |
| 735 | |
| 736 TEST_F(GLES2DecoderGeometryInstancingTest, | |
| 737 DrawArraysInstancedANGLENoDivisor0Fails) { | |
| 738 SetupTexture(); | |
| 739 SetupVertexBuffer(); | |
| 740 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); | |
| 741 | |
| 742 DoEnableVertexAttribArray(0); | |
| 743 DoVertexAttribPointer(0, 2, GL_FLOAT, 0, 0); | |
| 744 DoVertexAttribDivisorANGLE(0, 1); | |
| 745 DoVertexAttribDivisorANGLE(1, 1); | |
| 746 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(_, _, _, _)) | |
| 747 .Times(0) | |
| 748 .RetiresOnSaturation(); | |
| 749 DrawArraysInstancedANGLE cmd; | |
| 750 cmd.Init(GL_TRIANGLES, 0, kNumVertices, 1); | |
| 751 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 752 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 753 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 754 } | |
| 755 | |
| 756 TEST_F(GLES2DecoderWithShaderTest, DrawElementsNoAttributesSucceeds) { | |
| 757 SetupTexture(); | |
| 758 SetupIndexBuffer(); | |
| 759 AddExpectationsForSimulatedAttrib0(kMaxValidIndex + 1, 0); | |
| 760 SetupExpectationsForApplyingDefaultDirtyState(); | |
| 761 EXPECT_CALL(*gl_, DrawElements(GL_TRIANGLES, kValidIndexRangeCount, | |
| 762 GL_UNSIGNED_SHORT, | |
| 763 BufferOffset(kValidIndexRangeStart * 2))) | |
| 764 .Times(1) | |
| 765 .RetiresOnSaturation(); | |
| 766 DrawElements cmd; | |
| 767 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, | |
| 768 kValidIndexRangeStart * 2); | |
| 769 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 770 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 771 } | |
| 772 | |
| 773 TEST_F(GLES2DecoderWithShaderTest, DrawElementsMissingAttributesFails) { | |
| 774 SetupIndexBuffer(); | |
| 775 DoEnableVertexAttribArray(1); | |
| 776 | |
| 777 EXPECT_CALL(*gl_, DrawElements(_, _, _, _)) | |
| 778 .Times(0); | |
| 779 DrawElements cmd; | |
| 780 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, | |
| 781 kValidIndexRangeStart * 2); | |
| 782 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 783 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 784 } | |
| 785 | |
| 786 TEST_F(GLES2DecoderWithShaderTest, | |
| 787 DrawElementsMissingAttributesZeroCountSucceeds) { | |
| 788 SetupIndexBuffer(); | |
| 789 DoEnableVertexAttribArray(1); | |
| 790 | |
| 791 EXPECT_CALL(*gl_, DrawElements(_, _, _, _)) | |
| 792 .Times(0); | |
| 793 DrawElements cmd; | |
| 794 cmd.Init(GL_TRIANGLES, 0, GL_UNSIGNED_SHORT, | |
| 795 kValidIndexRangeStart * 2); | |
| 796 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 797 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 798 } | |
| 799 | |
| 800 TEST_F(GLES2DecoderWithShaderTest, DrawElementsExtraAttributesFails) { | |
| 801 SetupIndexBuffer(); | |
| 802 DoEnableVertexAttribArray(6); | |
| 803 | |
| 804 EXPECT_CALL(*gl_, DrawElements(_, _, _, _)) | |
| 805 .Times(0); | |
| 806 DrawElements cmd; | |
| 807 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, | |
| 808 kValidIndexRangeStart * 2); | |
| 809 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 810 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 811 } | |
| 812 | |
| 813 TEST_F(GLES2DecoderWithShaderTest, DrawElementsValidAttributesSucceeds) { | |
| 814 SetupTexture(); | |
| 815 SetupVertexBuffer(); | |
| 816 SetupIndexBuffer(); | |
| 817 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); | |
| 818 AddExpectationsForSimulatedAttrib0(kMaxValidIndex + 1, kServiceBufferId); | |
| 819 SetupExpectationsForApplyingDefaultDirtyState(); | |
| 820 | |
| 821 EXPECT_CALL(*gl_, DrawElements(GL_TRIANGLES, kValidIndexRangeCount, | |
| 822 GL_UNSIGNED_SHORT, | |
| 823 BufferOffset(kValidIndexRangeStart * 2))) | |
| 824 .Times(1) | |
| 825 .RetiresOnSaturation(); | |
| 826 DrawElements cmd; | |
| 827 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, | |
| 828 kValidIndexRangeStart * 2); | |
| 829 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 830 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 831 } | |
| 832 | |
| 833 TEST_F(GLES2DecoderWithShaderTest, DrawElementsDeletedBufferFails) { | |
| 834 SetupVertexBuffer(); | |
| 835 SetupIndexBuffer(); | |
| 836 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); | |
| 837 DeleteIndexBuffer(); | |
| 838 | |
| 839 EXPECT_CALL(*gl_, DrawElements(_, _, _, _)) | |
| 840 .Times(0); | |
| 841 DrawElements cmd; | |
| 842 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, | |
| 843 kValidIndexRangeStart * 2); | |
| 844 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 845 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 846 } | |
| 847 | |
| 848 TEST_F(GLES2DecoderWithShaderTest, DrawElementsDeletedProgramSucceeds) { | |
| 849 SetupTexture(); | |
| 850 SetupIndexBuffer(); | |
| 851 AddExpectationsForSimulatedAttrib0(kMaxValidIndex + 1, 0); | |
| 852 SetupExpectationsForApplyingDefaultDirtyState(); | |
| 853 DoDeleteProgram(client_program_id_, kServiceProgramId); | |
| 854 | |
| 855 EXPECT_CALL(*gl_, DrawElements(_, _, _, _)) | |
| 856 .Times(1); | |
| 857 EXPECT_CALL(*gl_, DeleteProgram(kServiceProgramId)) | |
| 858 .Times(1); | |
| 859 DrawElements cmd; | |
| 860 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, | |
| 861 kValidIndexRangeStart * 2); | |
| 862 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 863 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 864 } | |
| 865 | |
| 866 TEST_F(GLES2DecoderWithShaderTest, DrawElementsWithInvalidModeFails) { | |
| 867 SetupVertexBuffer(); | |
| 868 SetupIndexBuffer(); | |
| 869 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); | |
| 870 | |
| 871 EXPECT_CALL(*gl_, DrawElements(_, _, _, _)) | |
| 872 .Times(0); | |
| 873 DrawElements cmd; | |
| 874 cmd.Init(GL_QUADS, kValidIndexRangeCount, GL_UNSIGNED_SHORT, | |
| 875 kValidIndexRangeStart * 2); | |
| 876 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 877 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | |
| 878 cmd.Init(GL_POLYGON, kValidIndexRangeCount, GL_UNSIGNED_SHORT, | |
| 879 kValidIndexRangeStart); | |
| 880 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 881 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | |
| 882 } | |
| 883 | |
| 884 TEST_F(GLES2DecoderWithShaderTest, DrawElementsInvalidCountFails) { | |
| 885 SetupVertexBuffer(); | |
| 886 SetupIndexBuffer(); | |
| 887 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); | |
| 888 | |
| 889 // Try start > 0 | |
| 890 EXPECT_CALL(*gl_, DrawElements(_, _, _, _)).Times(0); | |
| 891 DrawElements cmd; | |
| 892 cmd.Init(GL_TRIANGLES, kNumIndices, GL_UNSIGNED_SHORT, 2); | |
| 893 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 894 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 895 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 896 | |
| 897 // Try with count > size | |
| 898 cmd.Init(GL_TRIANGLES, kNumIndices + 1, GL_UNSIGNED_SHORT, 0); | |
| 899 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 900 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 901 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 902 } | |
| 903 | |
| 904 TEST_F(GLES2DecoderWithShaderTest, DrawElementsOutOfRangeIndicesFails) { | |
| 905 SetupVertexBuffer(); | |
| 906 SetupIndexBuffer(); | |
| 907 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); | |
| 908 | |
| 909 EXPECT_CALL(*gl_, DrawElements(_, _, _, _)).Times(0); | |
| 910 DrawElements cmd; | |
| 911 cmd.Init(GL_TRIANGLES, kInvalidIndexRangeCount, GL_UNSIGNED_SHORT, | |
| 912 kInvalidIndexRangeStart * 2); | |
| 913 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 914 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 915 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 916 } | |
| 917 | |
| 918 TEST_F(GLES2DecoderWithShaderTest, DrawElementsOddOffsetForUint16Fails) { | |
| 919 SetupVertexBuffer(); | |
| 920 SetupIndexBuffer(); | |
| 921 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); | |
| 922 | |
| 923 EXPECT_CALL(*gl_, DrawElements(_, _, _, _)).Times(0); | |
| 924 DrawElements cmd; | |
| 925 cmd.Init(GL_TRIANGLES, kInvalidIndexRangeCount, GL_UNSIGNED_SHORT, 1); | |
| 926 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 927 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 928 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 929 } | |
| 930 | |
| 931 TEST_F(GLES2DecoderWithShaderTest, DrawElementsInstancedANGLEFails) { | |
| 932 SetupTexture(); | |
| 933 SetupVertexBuffer(); | |
| 934 SetupIndexBuffer(); | |
| 935 DoEnableVertexAttribArray(1); | |
| 936 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); | |
| 937 | |
| 938 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE(_, _, _, _, _)) | |
| 939 .Times(0) | |
| 940 .RetiresOnSaturation(); | |
| 941 DrawElementsInstancedANGLE cmd; | |
| 942 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, | |
| 943 kValidIndexRangeStart * 2, 1); | |
| 944 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 945 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 946 } | |
| 947 | |
| 948 TEST_F(GLES2DecoderGeometryInstancingTest, | |
| 949 DrawElementsInstancedANGLENoAttributesFails) { | |
| 950 SetupTexture(); | |
| 951 SetupIndexBuffer(); | |
| 952 | |
| 953 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE(_, _, _, _, _)) | |
| 954 .Times(0) | |
| 955 .RetiresOnSaturation(); | |
| 956 DrawElementsInstancedANGLE cmd; | |
| 957 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, | |
| 958 kValidIndexRangeStart * 2, 1); | |
| 959 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 960 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 961 } | |
| 962 | |
| 963 TEST_F(GLES2DecoderGeometryInstancingTest, | |
| 964 DrawElementsInstancedANGLESimulatedAttrib0) { | |
| 965 SetupTexture(); | |
| 966 SetupVertexBuffer(); | |
| 967 SetupIndexBuffer(); | |
| 968 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); | |
| 969 | |
| 970 AddExpectationsForSimulatedAttrib0(kMaxValidIndex + 1, kServiceBufferId); | |
| 971 SetupExpectationsForApplyingDefaultDirtyState(); | |
| 972 | |
| 973 DoVertexAttribDivisorANGLE(0, 1); | |
| 974 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE( | |
| 975 GL_TRIANGLES, | |
| 976 kValidIndexRangeCount, | |
| 977 GL_UNSIGNED_SHORT, | |
| 978 BufferOffset(kValidIndexRangeStart * 2), | |
| 979 3)) | |
| 980 .Times(1) | |
| 981 .RetiresOnSaturation(); | |
| 982 EXPECT_CALL(*gl_, VertexAttribDivisorANGLE(0, 0)) | |
| 983 .Times(1) | |
| 984 .RetiresOnSaturation(); | |
| 985 EXPECT_CALL(*gl_, VertexAttribDivisorANGLE(0, 1)) | |
| 986 .Times(1) | |
| 987 .RetiresOnSaturation(); | |
| 988 DrawElementsInstancedANGLE cmd; | |
| 989 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, | |
| 990 kValidIndexRangeStart * 2, 3); | |
| 991 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 992 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 993 } | |
| 994 | |
| 995 TEST_F(GLES2DecoderGeometryInstancingTest, | |
| 996 DrawElementsInstancedANGLEMissingAttributesFails) { | |
| 997 SetupIndexBuffer(); | |
| 998 DoEnableVertexAttribArray(1); | |
| 999 | |
| 1000 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE(_, _, _, _, _)) | |
| 1001 .Times(0); | |
| 1002 DrawElementsInstancedANGLE cmd; | |
| 1003 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, | |
| 1004 kValidIndexRangeStart * 2, 1); | |
| 1005 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1006 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 1007 } | |
| 1008 | |
| 1009 TEST_F(GLES2DecoderGeometryInstancingTest, | |
| 1010 DrawElementsInstancedANGLEMissingAttributesZeroCountSucceeds) { | |
| 1011 SetupIndexBuffer(); | |
| 1012 DoEnableVertexAttribArray(1); | |
| 1013 | |
| 1014 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE(_, _, _, _, _)) | |
| 1015 .Times(0); | |
| 1016 DrawElementsInstancedANGLE cmd; | |
| 1017 cmd.Init(GL_TRIANGLES, 0, GL_UNSIGNED_SHORT, | |
| 1018 kValidIndexRangeStart * 2, 1); | |
| 1019 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1020 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 1021 } | |
| 1022 | |
| 1023 TEST_F(GLES2DecoderGeometryInstancingTest, | |
| 1024 DrawElementsInstancedANGLEValidAttributesSucceeds) { | |
| 1025 SetupIndexBuffer(); | |
| 1026 SetupTexture(); | |
| 1027 SetupVertexBuffer(); | |
| 1028 DoEnableVertexAttribArray(1); | |
| 1029 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); | |
| 1030 AddExpectationsForSimulatedAttrib0(kMaxValidIndex + 1, kServiceBufferId); | |
| 1031 SetupExpectationsForApplyingDefaultDirtyState(); | |
| 1032 | |
| 1033 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE( | |
| 1034 GL_TRIANGLES, | |
| 1035 kValidIndexRangeCount, | |
| 1036 GL_UNSIGNED_SHORT, | |
| 1037 BufferOffset(kValidIndexRangeStart * 2), | |
| 1038 1)) | |
| 1039 .Times(1) | |
| 1040 .RetiresOnSaturation(); | |
| 1041 DrawElementsInstancedANGLE cmd; | |
| 1042 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, | |
| 1043 kValidIndexRangeStart * 2, 1); | |
| 1044 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1045 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 1046 } | |
| 1047 | |
| 1048 TEST_F(GLES2DecoderGeometryInstancingTest, | |
| 1049 DrawElementsInstancedANGLEWithInvalidModeFails) { | |
| 1050 SetupIndexBuffer(); | |
| 1051 SetupVertexBuffer(); | |
| 1052 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); | |
| 1053 | |
| 1054 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE(_, _, _, _, _)) | |
| 1055 .Times(0); | |
| 1056 DrawElementsInstancedANGLE cmd; | |
| 1057 cmd.Init(GL_QUADS, kValidIndexRangeCount, GL_UNSIGNED_SHORT, | |
| 1058 kValidIndexRangeStart * 2, 1); | |
| 1059 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1060 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | |
| 1061 cmd.Init(GL_INVALID_ENUM, kValidIndexRangeCount, GL_UNSIGNED_SHORT, | |
| 1062 kValidIndexRangeStart * 2, 1); | |
| 1063 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1064 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | |
| 1065 } | |
| 1066 | |
| 1067 // Per-instance data is twice as large, but number of instances is half | |
| 1068 TEST_F(GLES2DecoderGeometryInstancingTest, | |
| 1069 DrawElementsInstancedANGLELargeInstanceSucceeds) { | |
| 1070 SetupTexture(); | |
| 1071 SetupIndexBuffer(); | |
| 1072 SetupVertexBuffer(); | |
| 1073 SetupExpectationsForApplyingDefaultDirtyState(); | |
| 1074 //Add offset so we're sure we're accessing data near the end of the buffer. | |
| 1075 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, | |
| 1076 (kNumVertices - kMaxValidIndex - 1) * 2 * | |
| 1077 sizeof(GLfloat)); | |
| 1078 | |
| 1079 DoEnableVertexAttribArray(0); | |
| 1080 DoVertexAttribPointer(0, 4, GL_FLOAT, 0, 0); | |
| 1081 DoVertexAttribDivisorANGLE(0, 1); | |
| 1082 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE( | |
| 1083 GL_TRIANGLES, | |
| 1084 kValidIndexRangeCount, | |
| 1085 GL_UNSIGNED_SHORT, | |
| 1086 BufferOffset(kValidIndexRangeStart * 2), | |
| 1087 kNumVertices / 2)) | |
| 1088 .Times(1) | |
| 1089 .RetiresOnSaturation(); | |
| 1090 DrawElementsInstancedANGLE cmd; | |
| 1091 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, | |
| 1092 kValidIndexRangeStart * 2, kNumVertices / 2); | |
| 1093 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1094 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 1095 } | |
| 1096 | |
| 1097 // Per-instance data is twice as large, but divisor is twice | |
| 1098 TEST_F(GLES2DecoderGeometryInstancingTest, | |
| 1099 DrawElementsInstancedANGLELargeDivisorSucceeds) { | |
| 1100 SetupTexture(); | |
| 1101 SetupIndexBuffer(); | |
| 1102 SetupVertexBuffer(); | |
| 1103 SetupExpectationsForApplyingDefaultDirtyState(); | |
| 1104 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); | |
| 1105 | |
| 1106 DoEnableVertexAttribArray(0); | |
| 1107 DoVertexAttribPointer(0, 4, GL_FLOAT, 0, 0); | |
| 1108 DoVertexAttribDivisorANGLE(0, 2); | |
| 1109 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE( | |
| 1110 GL_TRIANGLES, | |
| 1111 kValidIndexRangeCount, | |
| 1112 GL_UNSIGNED_SHORT, | |
| 1113 BufferOffset(kValidIndexRangeStart * 2), | |
| 1114 kNumVertices)) | |
| 1115 .Times(1) | |
| 1116 .RetiresOnSaturation(); | |
| 1117 DrawElementsInstancedANGLE cmd; | |
| 1118 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, | |
| 1119 kValidIndexRangeStart * 2, kNumVertices); | |
| 1120 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1121 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 1122 } | |
| 1123 | |
| 1124 TEST_F(GLES2DecoderGeometryInstancingTest, | |
| 1125 DrawElementsInstancedANGLELargeFails) { | |
| 1126 SetupTexture(); | |
| 1127 SetupIndexBuffer(); | |
| 1128 SetupVertexBuffer(); | |
| 1129 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); | |
| 1130 | |
| 1131 DoEnableVertexAttribArray(0); | |
| 1132 DoVertexAttribPointer(0, 2, GL_FLOAT, 0, 0); | |
| 1133 DoVertexAttribDivisorANGLE(0, 1); | |
| 1134 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE(_, _, _, _, _)) | |
| 1135 .Times(0) | |
| 1136 .RetiresOnSaturation(); | |
| 1137 DrawElementsInstancedANGLE cmd; | |
| 1138 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, | |
| 1139 kValidIndexRangeStart * 2, kNumVertices + 1); | |
| 1140 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1141 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 1142 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 1143 | |
| 1144 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE(_, _, _, _, _)) | |
| 1145 .Times(0) | |
| 1146 .RetiresOnSaturation(); | |
| 1147 cmd.Init(GL_TRIANGLES, kInvalidIndexRangeCount, GL_UNSIGNED_SHORT, | |
| 1148 kInvalidIndexRangeStart * 2, kNumVertices); | |
| 1149 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1150 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 1151 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 1152 } | |
| 1153 | |
| 1154 TEST_F(GLES2DecoderGeometryInstancingTest, | |
| 1155 DrawElementsInstancedANGLEInvalidPrimcountFails) { | |
| 1156 SetupTexture(); | |
| 1157 SetupIndexBuffer(); | |
| 1158 SetupVertexBuffer(); | |
| 1159 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); | |
| 1160 | |
| 1161 DoEnableVertexAttribArray(0); | |
| 1162 DoVertexAttribPointer(0, 2, GL_FLOAT, 0, 0); | |
| 1163 DoVertexAttribDivisorANGLE(0, 1); | |
| 1164 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE(_, _, _, _, _)) | |
| 1165 .Times(0) | |
| 1166 .RetiresOnSaturation(); | |
| 1167 DrawElementsInstancedANGLE cmd; | |
| 1168 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, | |
| 1169 kValidIndexRangeStart * 2, -1); | |
| 1170 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1171 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 1172 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 1173 } | |
| 1174 | |
| 1175 // Per-index data is twice as large, but values of indices are smaller | |
| 1176 TEST_F(GLES2DecoderGeometryInstancingTest, | |
| 1177 DrawElementsInstancedANGLELargeIndexSucceeds) { | |
| 1178 SetupTexture(); | |
| 1179 SetupIndexBuffer(); | |
| 1180 SetupVertexBuffer(); | |
| 1181 SetupExpectationsForApplyingDefaultDirtyState(); | |
| 1182 DoVertexAttribPointer(1, 4, GL_FLOAT, 0, 0); | |
| 1183 | |
| 1184 DoEnableVertexAttribArray(0); | |
| 1185 DoVertexAttribPointer(0, 2, GL_FLOAT, 0, 0); | |
| 1186 DoVertexAttribDivisorANGLE(0, 1); | |
| 1187 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE( | |
| 1188 GL_TRIANGLES, | |
| 1189 kValidIndexRangeCount, | |
| 1190 GL_UNSIGNED_SHORT, | |
| 1191 BufferOffset(kValidIndexRangeStart * 2), | |
| 1192 kNumVertices)) | |
| 1193 .Times(1) | |
| 1194 .RetiresOnSaturation(); | |
| 1195 DrawElementsInstancedANGLE cmd; | |
| 1196 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, | |
| 1197 kValidIndexRangeStart * 2, kNumVertices); | |
| 1198 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1199 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 1200 } | |
| 1201 | |
| 1202 TEST_F(GLES2DecoderGeometryInstancingTest, | |
| 1203 DrawElementsInstancedANGLENoDivisor0Fails) { | |
| 1204 SetupTexture(); | |
| 1205 SetupIndexBuffer(); | |
| 1206 SetupVertexBuffer(); | |
| 1207 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); | |
| 1208 | |
| 1209 DoEnableVertexAttribArray(0); | |
| 1210 DoVertexAttribPointer(0, 2, GL_FLOAT, 0, 0); | |
| 1211 DoVertexAttribDivisorANGLE(0, 1); | |
| 1212 DoVertexAttribDivisorANGLE(1, 1); | |
| 1213 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE(_, _, _, _, _)) | |
| 1214 .Times(0) | |
| 1215 .RetiresOnSaturation(); | |
| 1216 DrawElementsInstancedANGLE cmd; | |
| 1217 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, | |
| 1218 kValidIndexRangeStart * 2, kNumVertices); | |
| 1219 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1220 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 1221 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 1222 } | |
| 1223 | |
| 1224 TEST_F(GLES2DecoderWithShaderTest, GetVertexAttribPointervSucceeds) { | |
| 1225 const float dummy = 0; | |
| 1226 const GLuint kOffsetToTestFor = sizeof(dummy) * 4; | |
| 1227 const GLuint kIndexToTest = 1; | |
| 1228 GetVertexAttribPointerv::Result* result = | |
| 1229 static_cast<GetVertexAttribPointerv::Result*>(shared_memory_address_); | |
| 1230 result->size = 0; | |
| 1231 const GLuint* result_value = result->GetData(); | |
| 1232 // Test that initial value is 0. | |
| 1233 GetVertexAttribPointerv cmd; | |
| 1234 cmd.Init(kIndexToTest, GL_VERTEX_ATTRIB_ARRAY_POINTER, | |
| 1235 shared_memory_id_, shared_memory_offset_); | |
| 1236 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1237 EXPECT_EQ(sizeof(*result_value), result->size); | |
| 1238 EXPECT_EQ(0u, *result_value); | |
| 1239 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 1240 | |
| 1241 // Set the value and see that we get it. | |
| 1242 SetupVertexBuffer(); | |
| 1243 DoVertexAttribPointer(kIndexToTest, 2, GL_FLOAT, 0, kOffsetToTestFor); | |
| 1244 result->size = 0; | |
| 1245 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1246 EXPECT_EQ(sizeof(*result_value), result->size); | |
| 1247 EXPECT_EQ(kOffsetToTestFor, *result_value); | |
| 1248 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 1249 } | |
| 1250 | |
| 1251 TEST_F(GLES2DecoderWithShaderTest, GetVertexAttribPointervBadArgsFails) { | |
| 1252 const GLuint kIndexToTest = 1; | |
| 1253 GetVertexAttribPointerv::Result* result = | |
| 1254 static_cast<GetVertexAttribPointerv::Result*>(shared_memory_address_); | |
| 1255 result->size = 0; | |
| 1256 const GLuint* result_value = result->GetData(); | |
| 1257 // Test pname invalid fails. | |
| 1258 GetVertexAttribPointerv cmd; | |
| 1259 cmd.Init(kIndexToTest, GL_VERTEX_ATTRIB_ARRAY_POINTER + 1, | |
| 1260 shared_memory_id_, shared_memory_offset_); | |
| 1261 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1262 EXPECT_EQ(0u, result->size); | |
| 1263 EXPECT_EQ(kInitialResult, *result_value); | |
| 1264 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | |
| 1265 | |
| 1266 // Test index out of range fails. | |
| 1267 result->size = 0; | |
| 1268 cmd.Init(kNumVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_POINTER, | |
| 1269 shared_memory_id_, shared_memory_offset_); | |
| 1270 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1271 EXPECT_EQ(0u, result->size); | |
| 1272 EXPECT_EQ(kInitialResult, *result_value); | |
| 1273 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 1274 | |
| 1275 // Test memory id bad fails. | |
| 1276 cmd.Init(kIndexToTest, GL_VERTEX_ATTRIB_ARRAY_POINTER, | |
| 1277 kInvalidSharedMemoryId, shared_memory_offset_); | |
| 1278 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 1279 | |
| 1280 // Test memory offset bad fails. | |
| 1281 cmd.Init(kIndexToTest, GL_VERTEX_ATTRIB_ARRAY_POINTER, | |
| 1282 shared_memory_id_, kInvalidSharedMemoryOffset); | |
| 1283 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 1284 } | |
| 1285 | |
| 1286 TEST_F(GLES2DecoderWithShaderTest, GetUniformivSucceeds) { | |
| 1287 GetUniformiv::Result* result = | |
| 1288 static_cast<GetUniformiv::Result*>(shared_memory_address_); | |
| 1289 result->size = 0; | |
| 1290 GetUniformiv cmd; | |
| 1291 cmd.Init(client_program_id_, | |
| 1292 kUniform2FakeLocation, | |
| 1293 kSharedMemoryId, kSharedMemoryOffset); | |
| 1294 EXPECT_CALL(*gl_, GetUniformiv(kServiceProgramId, kUniform2RealLocation, _)) | |
| 1295 .Times(1); | |
| 1296 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1297 EXPECT_EQ(GLES2Util::GetGLDataTypeSizeForUniforms(kUniform2Type), | |
| 1298 result->size); | |
| 1299 } | |
| 1300 | |
| 1301 TEST_F(GLES2DecoderWithShaderTest, GetUniformivArrayElementSucceeds) { | |
| 1302 GetUniformiv::Result* result = | |
| 1303 static_cast<GetUniformiv::Result*>(shared_memory_address_); | |
| 1304 result->size = 0; | |
| 1305 GetUniformiv cmd; | |
| 1306 cmd.Init(client_program_id_, | |
| 1307 kUniform2ElementFakeLocation, | |
| 1308 kSharedMemoryId, kSharedMemoryOffset); | |
| 1309 EXPECT_CALL(*gl_, | |
| 1310 GetUniformiv(kServiceProgramId, kUniform2ElementRealLocation, _)) | |
| 1311 .Times(1); | |
| 1312 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1313 EXPECT_EQ(GLES2Util::GetGLDataTypeSizeForUniforms(kUniform2Type), | |
| 1314 result->size); | |
| 1315 } | |
| 1316 | |
| 1317 TEST_F(GLES2DecoderWithShaderTest, GetUniformivBadProgramFails) { | |
| 1318 GetUniformiv::Result* result = | |
| 1319 static_cast<GetUniformiv::Result*>(shared_memory_address_); | |
| 1320 result->size = 0; | |
| 1321 GetUniformiv cmd; | |
| 1322 // non-existant program | |
| 1323 cmd.Init(kInvalidClientId, | |
| 1324 kUniform2FakeLocation, | |
| 1325 kSharedMemoryId, kSharedMemoryOffset); | |
| 1326 EXPECT_CALL(*gl_, GetUniformiv(_, _, _)) | |
| 1327 .Times(0); | |
| 1328 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1329 EXPECT_EQ(0U, result->size); | |
| 1330 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 1331 // Valid id that is not a program. The GL spec requires a different error for | |
| 1332 // this case. | |
| 1333 #if GLES2_TEST_SHADER_VS_PROGRAM_IDS | |
| 1334 result->size = kInitialResult; | |
| 1335 cmd.Init(client_shader_id_, | |
| 1336 kUniform2FakeLocation, | |
| 1337 kSharedMemoryId, kSharedMemoryOffset); | |
| 1338 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1339 EXPECT_EQ(0U, result->size); | |
| 1340 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 1341 #endif // GLES2_TEST_SHADER_VS_PROGRAM_IDS | |
| 1342 // Unlinked program | |
| 1343 EXPECT_CALL(*gl_, CreateProgram()) | |
| 1344 .Times(1) | |
| 1345 .WillOnce(Return(kNewServiceId)) | |
| 1346 .RetiresOnSaturation(); | |
| 1347 CreateProgram cmd2; | |
| 1348 cmd2.Init(kNewClientId); | |
| 1349 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 1350 result->size = kInitialResult; | |
| 1351 cmd.Init(kNewClientId, | |
| 1352 kUniform2FakeLocation, | |
| 1353 kSharedMemoryId, kSharedMemoryOffset); | |
| 1354 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1355 EXPECT_EQ(0U, result->size); | |
| 1356 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 1357 } | |
| 1358 | |
| 1359 TEST_F(GLES2DecoderWithShaderTest, GetUniformivBadLocationFails) { | |
| 1360 GetUniformiv::Result* result = | |
| 1361 static_cast<GetUniformiv::Result*>(shared_memory_address_); | |
| 1362 result->size = 0; | |
| 1363 GetUniformiv cmd; | |
| 1364 // invalid location | |
| 1365 cmd.Init(client_program_id_, kInvalidUniformLocation, | |
| 1366 kSharedMemoryId, kSharedMemoryOffset); | |
| 1367 EXPECT_CALL(*gl_, GetUniformiv(_, _, _)) | |
| 1368 .Times(0); | |
| 1369 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1370 EXPECT_EQ(0U, result->size); | |
| 1371 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 1372 } | |
| 1373 | |
| 1374 TEST_F(GLES2DecoderWithShaderTest, GetUniformivBadSharedMemoryFails) { | |
| 1375 GetUniformiv cmd; | |
| 1376 cmd.Init(client_program_id_, | |
| 1377 kUniform2FakeLocation, | |
| 1378 kInvalidSharedMemoryId, kSharedMemoryOffset); | |
| 1379 EXPECT_CALL(*gl_, GetUniformiv(_, _, _)) | |
| 1380 .Times(0); | |
| 1381 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 1382 cmd.Init(client_program_id_, kUniform2FakeLocation, | |
| 1383 kSharedMemoryId, kInvalidSharedMemoryOffset); | |
| 1384 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 1385 }; | |
| 1386 | |
| 1387 TEST_F(GLES2DecoderWithShaderTest, GetUniformfvSucceeds) { | |
| 1388 GetUniformfv::Result* result = | |
| 1389 static_cast<GetUniformfv::Result*>(shared_memory_address_); | |
| 1390 result->size = 0; | |
| 1391 GetUniformfv cmd; | |
| 1392 cmd.Init(client_program_id_, | |
| 1393 kUniform2FakeLocation, | |
| 1394 kSharedMemoryId, kSharedMemoryOffset); | |
| 1395 EXPECT_CALL(*gl_, GetUniformfv(kServiceProgramId, kUniform2RealLocation, _)) | |
| 1396 .Times(1); | |
| 1397 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1398 EXPECT_EQ(GLES2Util::GetGLDataTypeSizeForUniforms(kUniform2Type), | |
| 1399 result->size); | |
| 1400 } | |
| 1401 | |
| 1402 TEST_F(GLES2DecoderWithShaderTest, GetUniformfvArrayElementSucceeds) { | |
| 1403 GetUniformfv::Result* result = | |
| 1404 static_cast<GetUniformfv::Result*>(shared_memory_address_); | |
| 1405 result->size = 0; | |
| 1406 GetUniformfv cmd; | |
| 1407 cmd.Init(client_program_id_, | |
| 1408 kUniform2ElementFakeLocation, | |
| 1409 kSharedMemoryId, kSharedMemoryOffset); | |
| 1410 EXPECT_CALL(*gl_, | |
| 1411 GetUniformfv(kServiceProgramId, kUniform2ElementRealLocation, _)) | |
| 1412 .Times(1); | |
| 1413 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1414 EXPECT_EQ(GLES2Util::GetGLDataTypeSizeForUniforms(kUniform2Type), | |
| 1415 result->size); | |
| 1416 } | |
| 1417 | |
| 1418 TEST_F(GLES2DecoderWithShaderTest, GetUniformfvBadProgramFails) { | |
| 1419 GetUniformfv::Result* result = | |
| 1420 static_cast<GetUniformfv::Result*>(shared_memory_address_); | |
| 1421 result->size = 0; | |
| 1422 GetUniformfv cmd; | |
| 1423 // non-existant program | |
| 1424 cmd.Init(kInvalidClientId, | |
| 1425 kUniform2FakeLocation, | |
| 1426 kSharedMemoryId, kSharedMemoryOffset); | |
| 1427 EXPECT_CALL(*gl_, GetUniformfv(_, _, _)) | |
| 1428 .Times(0); | |
| 1429 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1430 EXPECT_EQ(0U, result->size); | |
| 1431 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 1432 // Valid id that is not a program. The GL spec requires a different error for | |
| 1433 // this case. | |
| 1434 #if GLES2_TEST_SHADER_VS_PROGRAM_IDS | |
| 1435 result->size = kInitialResult; | |
| 1436 cmd.Init(client_shader_id_, | |
| 1437 kUniform2FakeLocation, | |
| 1438 kSharedMemoryId, kSharedMemoryOffset); | |
| 1439 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1440 EXPECT_EQ(0U, result->size); | |
| 1441 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 1442 #endif // GLES2_TEST_SHADER_VS_PROGRAM_IDS | |
| 1443 // Unlinked program | |
| 1444 EXPECT_CALL(*gl_, CreateProgram()) | |
| 1445 .Times(1) | |
| 1446 .WillOnce(Return(kNewServiceId)) | |
| 1447 .RetiresOnSaturation(); | |
| 1448 CreateProgram cmd2; | |
| 1449 cmd2.Init(kNewClientId); | |
| 1450 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 1451 result->size = kInitialResult; | |
| 1452 cmd.Init(kNewClientId, | |
| 1453 kUniform2FakeLocation, | |
| 1454 kSharedMemoryId, kSharedMemoryOffset); | |
| 1455 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1456 EXPECT_EQ(0U, result->size); | |
| 1457 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 1458 } | |
| 1459 | |
| 1460 TEST_F(GLES2DecoderWithShaderTest, GetUniformfvBadLocationFails) { | |
| 1461 GetUniformfv::Result* result = | |
| 1462 static_cast<GetUniformfv::Result*>(shared_memory_address_); | |
| 1463 result->size = 0; | |
| 1464 GetUniformfv cmd; | |
| 1465 // invalid location | |
| 1466 cmd.Init(client_program_id_, kInvalidUniformLocation, | |
| 1467 kSharedMemoryId, kSharedMemoryOffset); | |
| 1468 EXPECT_CALL(*gl_, GetUniformfv(_, _, _)) | |
| 1469 .Times(0); | |
| 1470 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1471 EXPECT_EQ(0U, result->size); | |
| 1472 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 1473 } | |
| 1474 | |
| 1475 TEST_F(GLES2DecoderWithShaderTest, GetUniformfvBadSharedMemoryFails) { | |
| 1476 GetUniformfv cmd; | |
| 1477 cmd.Init(client_program_id_, | |
| 1478 kUniform2FakeLocation, | |
| 1479 kInvalidSharedMemoryId, kSharedMemoryOffset); | |
| 1480 EXPECT_CALL(*gl_, GetUniformfv(_, _, _)) | |
| 1481 .Times(0); | |
| 1482 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 1483 cmd.Init(client_program_id_, kUniform2FakeLocation, | |
| 1484 kSharedMemoryId, kInvalidSharedMemoryOffset); | |
| 1485 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 1486 }; | |
| 1487 | |
| 1488 TEST_F(GLES2DecoderWithShaderTest, GetAttachedShadersSucceeds) { | |
| 1489 GetAttachedShaders cmd; | |
| 1490 typedef GetAttachedShaders::Result Result; | |
| 1491 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 1492 result->size = 0; | |
| 1493 EXPECT_CALL(*gl_, GetAttachedShaders(kServiceProgramId, 1, _, _)) | |
| 1494 .WillOnce(DoAll(SetArgumentPointee<2>(1), | |
| 1495 SetArgumentPointee<3>(kServiceShaderId))); | |
| 1496 cmd.Init(client_program_id_, shared_memory_id_, shared_memory_offset_, | |
| 1497 Result::ComputeSize(1)); | |
| 1498 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1499 EXPECT_EQ(1, result->GetNumResults()); | |
| 1500 EXPECT_EQ(client_shader_id_, result->GetData()[0]); | |
| 1501 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 1502 } | |
| 1503 | |
| 1504 TEST_F(GLES2DecoderWithShaderTest, GetAttachedShadersResultNotInitFail) { | |
| 1505 GetAttachedShaders cmd; | |
| 1506 typedef GetAttachedShaders::Result Result; | |
| 1507 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 1508 result->size = 1; | |
| 1509 EXPECT_CALL(*gl_, GetAttachedShaders(_, _, _, _)) | |
| 1510 .Times(0); | |
| 1511 cmd.Init(client_program_id_, shared_memory_id_, shared_memory_offset_, | |
| 1512 Result::ComputeSize(1)); | |
| 1513 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 1514 } | |
| 1515 | |
| 1516 TEST_F(GLES2DecoderWithShaderTest, GetAttachedShadersBadProgramFails) { | |
| 1517 GetAttachedShaders cmd; | |
| 1518 typedef GetAttachedShaders::Result Result; | |
| 1519 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 1520 result->size = 0; | |
| 1521 EXPECT_CALL(*gl_, GetAttachedShaders(_, _, _, _)) | |
| 1522 .Times(0); | |
| 1523 cmd.Init(kInvalidClientId, shared_memory_id_, shared_memory_offset_, | |
| 1524 Result::ComputeSize(1)); | |
| 1525 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1526 EXPECT_EQ(0U, result->size); | |
| 1527 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 1528 } | |
| 1529 | |
| 1530 TEST_F(GLES2DecoderWithShaderTest, GetAttachedShadersBadSharedMemoryFails) { | |
| 1531 GetAttachedShaders cmd; | |
| 1532 typedef GetAttachedShaders::Result Result; | |
| 1533 cmd.Init(client_program_id_, kInvalidSharedMemoryId, shared_memory_offset_, | |
| 1534 Result::ComputeSize(1)); | |
| 1535 EXPECT_CALL(*gl_, GetAttachedShaders(_, _, _, _)) | |
| 1536 .Times(0); | |
| 1537 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 1538 cmd.Init(client_program_id_, shared_memory_id_, kInvalidSharedMemoryOffset, | |
| 1539 Result::ComputeSize(1)); | |
| 1540 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 1541 } | |
| 1542 | |
| 1543 TEST_F(GLES2DecoderWithShaderTest, GetShaderPrecisionFormatSucceeds) { | |
| 1544 ScopedGLImplementationSetter gl_impl(::gfx::kGLImplementationEGLGLES2); | |
| 1545 GetShaderPrecisionFormat cmd; | |
| 1546 typedef GetShaderPrecisionFormat::Result Result; | |
| 1547 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 1548 result->success = 0; | |
| 1549 const GLint range[2] = { 62, 62 }; | |
| 1550 const GLint precision = 16; | |
| 1551 EXPECT_CALL(*gl_,GetShaderPrecisionFormat(_, _, _, _)) | |
| 1552 .WillOnce(DoAll(SetArrayArgument<2>(range,range+2), | |
| 1553 SetArgumentPointee<3>(precision))) | |
| 1554 .RetiresOnSaturation(); | |
| 1555 cmd.Init(GL_VERTEX_SHADER, GL_HIGH_FLOAT, | |
| 1556 shared_memory_id_, shared_memory_offset_); | |
| 1557 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1558 EXPECT_NE(0, result->success); | |
| 1559 EXPECT_EQ(range[0], result->min_range); | |
| 1560 EXPECT_EQ(range[1], result->max_range); | |
| 1561 EXPECT_EQ(precision, result->precision); | |
| 1562 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 1563 } | |
| 1564 | |
| 1565 TEST_F(GLES2DecoderWithShaderTest, GetShaderPrecisionFormatResultNotInitFails) { | |
| 1566 GetShaderPrecisionFormat cmd; | |
| 1567 typedef GetShaderPrecisionFormat::Result Result; | |
| 1568 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 1569 result->success = 1; | |
| 1570 // NOTE: GL might not be called. There is no Desktop OpenGL equivalent | |
| 1571 cmd.Init(GL_VERTEX_SHADER, GL_HIGH_FLOAT, | |
| 1572 shared_memory_id_, shared_memory_offset_); | |
| 1573 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 1574 } | |
| 1575 | |
| 1576 TEST_F(GLES2DecoderWithShaderTest, GetShaderPrecisionFormatBadArgsFails) { | |
| 1577 typedef GetShaderPrecisionFormat::Result Result; | |
| 1578 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 1579 result->success = 0; | |
| 1580 GetShaderPrecisionFormat cmd; | |
| 1581 cmd.Init(GL_TEXTURE_2D, GL_HIGH_FLOAT, | |
| 1582 shared_memory_id_, shared_memory_offset_); | |
| 1583 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1584 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | |
| 1585 result->success = 0; | |
| 1586 cmd.Init(GL_VERTEX_SHADER, GL_TEXTURE_2D, | |
| 1587 shared_memory_id_, shared_memory_offset_); | |
| 1588 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1589 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | |
| 1590 } | |
| 1591 | |
| 1592 TEST_F(GLES2DecoderWithShaderTest, | |
| 1593 GetShaderPrecisionFormatBadSharedMemoryFails) { | |
| 1594 GetShaderPrecisionFormat cmd; | |
| 1595 cmd.Init(GL_VERTEX_SHADER, GL_HIGH_FLOAT, | |
| 1596 kInvalidSharedMemoryId, shared_memory_offset_); | |
| 1597 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 1598 cmd.Init(GL_VERTEX_SHADER, GL_TEXTURE_2D, | |
| 1599 shared_memory_id_, kInvalidSharedMemoryOffset); | |
| 1600 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 1601 } | |
| 1602 | |
| 1603 TEST_F(GLES2DecoderWithShaderTest, GetActiveUniformSucceeds) { | |
| 1604 const GLuint kUniformIndex = 1; | |
| 1605 const uint32 kBucketId = 123; | |
| 1606 GetActiveUniform cmd; | |
| 1607 typedef GetActiveUniform::Result Result; | |
| 1608 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 1609 result->success = 0; | |
| 1610 cmd.Init(client_program_id_, kUniformIndex, kBucketId, | |
| 1611 shared_memory_id_, shared_memory_offset_); | |
| 1612 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1613 EXPECT_NE(0, result->success); | |
| 1614 EXPECT_EQ(kUniform2Size, result->size); | |
| 1615 EXPECT_EQ(kUniform2Type, result->type); | |
| 1616 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 1617 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId); | |
| 1618 ASSERT_TRUE(bucket != NULL); | |
| 1619 EXPECT_EQ(0, memcmp(bucket->GetData(0, bucket->size()), kUniform2Name, | |
| 1620 bucket->size())); | |
| 1621 } | |
| 1622 | |
| 1623 TEST_F(GLES2DecoderWithShaderTest, GetActiveUniformResultNotInitFails) { | |
| 1624 const GLuint kUniformIndex = 1; | |
| 1625 const uint32 kBucketId = 123; | |
| 1626 GetActiveUniform cmd; | |
| 1627 typedef GetActiveUniform::Result Result; | |
| 1628 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 1629 result->success = 1; | |
| 1630 cmd.Init(client_program_id_, kUniformIndex, kBucketId, | |
| 1631 shared_memory_id_, shared_memory_offset_); | |
| 1632 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 1633 } | |
| 1634 | |
| 1635 TEST_F(GLES2DecoderWithShaderTest, GetActiveUniformBadProgramFails) { | |
| 1636 const GLuint kUniformIndex = 1; | |
| 1637 const uint32 kBucketId = 123; | |
| 1638 GetActiveUniform cmd; | |
| 1639 typedef GetActiveUniform::Result Result; | |
| 1640 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 1641 result->success = 0; | |
| 1642 cmd.Init(kInvalidClientId, kUniformIndex, kBucketId, | |
| 1643 shared_memory_id_, shared_memory_offset_); | |
| 1644 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1645 EXPECT_EQ(0, result->success); | |
| 1646 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 1647 #if GLES2_TEST_SHADER_VS_PROGRAM_IDS | |
| 1648 result->success = 0; | |
| 1649 cmd.Init(client_shader_id_, kUniformIndex, kBucketId, | |
| 1650 shared_memory_id_, shared_memory_offset_); | |
| 1651 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1652 EXPECT_EQ(0, result->success); | |
| 1653 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 1654 #endif // GLES2_TEST_SHADER_VS_PROGRAM_IDS | |
| 1655 } | |
| 1656 | |
| 1657 TEST_F(GLES2DecoderWithShaderTest, GetActiveUniformBadIndexFails) { | |
| 1658 const uint32 kBucketId = 123; | |
| 1659 GetActiveUniform cmd; | |
| 1660 typedef GetActiveUniform::Result Result; | |
| 1661 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 1662 result->success = 0; | |
| 1663 cmd.Init(client_program_id_, kBadUniformIndex, kBucketId, | |
| 1664 shared_memory_id_, shared_memory_offset_); | |
| 1665 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1666 EXPECT_EQ(0, result->success); | |
| 1667 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 1668 } | |
| 1669 | |
| 1670 TEST_F(GLES2DecoderWithShaderTest, GetActiveUniformBadSharedMemoryFails) { | |
| 1671 const GLuint kUniformIndex = 1; | |
| 1672 const uint32 kBucketId = 123; | |
| 1673 GetActiveUniform cmd; | |
| 1674 cmd.Init(client_program_id_, kUniformIndex, kBucketId, | |
| 1675 kInvalidSharedMemoryId, shared_memory_offset_); | |
| 1676 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 1677 cmd.Init(client_program_id_, kUniformIndex, kBucketId, | |
| 1678 shared_memory_id_, kInvalidSharedMemoryOffset); | |
| 1679 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 1680 } | |
| 1681 | |
| 1682 TEST_F(GLES2DecoderWithShaderTest, GetActiveAttribSucceeds) { | |
| 1683 const GLuint kAttribIndex = 1; | |
| 1684 const uint32 kBucketId = 123; | |
| 1685 GetActiveAttrib cmd; | |
| 1686 typedef GetActiveAttrib::Result Result; | |
| 1687 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 1688 result->success = 0; | |
| 1689 cmd.Init(client_program_id_, kAttribIndex, kBucketId, | |
| 1690 shared_memory_id_, shared_memory_offset_); | |
| 1691 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1692 EXPECT_NE(0, result->success); | |
| 1693 EXPECT_EQ(kAttrib2Size, result->size); | |
| 1694 EXPECT_EQ(kAttrib2Type, result->type); | |
| 1695 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 1696 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId); | |
| 1697 ASSERT_TRUE(bucket != NULL); | |
| 1698 EXPECT_EQ(0, memcmp(bucket->GetData(0, bucket->size()), kAttrib2Name, | |
| 1699 bucket->size())); | |
| 1700 } | |
| 1701 | |
| 1702 TEST_F(GLES2DecoderWithShaderTest, GetActiveAttribResultNotInitFails) { | |
| 1703 const GLuint kAttribIndex = 1; | |
| 1704 const uint32 kBucketId = 123; | |
| 1705 GetActiveAttrib cmd; | |
| 1706 typedef GetActiveAttrib::Result Result; | |
| 1707 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 1708 result->success = 1; | |
| 1709 cmd.Init(client_program_id_, kAttribIndex, kBucketId, | |
| 1710 shared_memory_id_, shared_memory_offset_); | |
| 1711 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 1712 } | |
| 1713 | |
| 1714 TEST_F(GLES2DecoderWithShaderTest, GetActiveAttribBadProgramFails) { | |
| 1715 const GLuint kAttribIndex = 1; | |
| 1716 const uint32 kBucketId = 123; | |
| 1717 GetActiveAttrib cmd; | |
| 1718 typedef GetActiveAttrib::Result Result; | |
| 1719 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 1720 result->success = 0; | |
| 1721 cmd.Init(kInvalidClientId, kAttribIndex, kBucketId, | |
| 1722 shared_memory_id_, shared_memory_offset_); | |
| 1723 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1724 EXPECT_EQ(0, result->success); | |
| 1725 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 1726 #if GLES2_TEST_SHADER_VS_PROGRAM_IDS | |
| 1727 result->success = 0; | |
| 1728 cmd.Init(client_shader_id_, kAttribIndex, kBucketId, | |
| 1729 shared_memory_id_, shared_memory_offset_); | |
| 1730 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1731 EXPECT_EQ(0, result->success); | |
| 1732 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 1733 #endif // GLES2_TEST_SHADER_VS_PROGRAM_IDS | |
| 1734 } | |
| 1735 | |
| 1736 TEST_F(GLES2DecoderWithShaderTest, GetActiveAttribBadIndexFails) { | |
| 1737 const uint32 kBucketId = 123; | |
| 1738 GetActiveAttrib cmd; | |
| 1739 typedef GetActiveAttrib::Result Result; | |
| 1740 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 1741 result->success = 0; | |
| 1742 cmd.Init(client_program_id_, kBadAttribIndex, kBucketId, | |
| 1743 shared_memory_id_, shared_memory_offset_); | |
| 1744 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1745 EXPECT_EQ(0, result->success); | |
| 1746 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 1747 } | |
| 1748 | |
| 1749 TEST_F(GLES2DecoderWithShaderTest, GetActiveAttribBadSharedMemoryFails) { | |
| 1750 const GLuint kAttribIndex = 1; | |
| 1751 const uint32 kBucketId = 123; | |
| 1752 GetActiveAttrib cmd; | |
| 1753 cmd.Init(client_program_id_, kAttribIndex, kBucketId, | |
| 1754 kInvalidSharedMemoryId, shared_memory_offset_); | |
| 1755 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 1756 cmd.Init(client_program_id_, kAttribIndex, kBucketId, | |
| 1757 shared_memory_id_, kInvalidSharedMemoryOffset); | |
| 1758 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 1759 } | |
| 1760 | |
| 1761 TEST_F(GLES2DecoderWithShaderTest, GetShaderInfoLogValidArgs) { | |
| 1762 const char* kInfo = "hello"; | |
| 1763 const uint32 kBucketId = 123; | |
| 1764 CompileShader compile_cmd; | |
| 1765 GetShaderInfoLog cmd; | |
| 1766 EXPECT_CALL(*gl_, ShaderSource(kServiceShaderId, 1, _, _)); | |
| 1767 EXPECT_CALL(*gl_, CompileShader(kServiceShaderId)); | |
| 1768 EXPECT_CALL(*gl_, GetShaderiv(kServiceShaderId, GL_COMPILE_STATUS, _)) | |
| 1769 .WillOnce(SetArgumentPointee<2>(GL_FALSE)) | |
| 1770 .RetiresOnSaturation(); | |
| 1771 EXPECT_CALL(*gl_, GetShaderiv(kServiceShaderId, GL_INFO_LOG_LENGTH, _)) | |
| 1772 .WillOnce(SetArgumentPointee<2>(strlen(kInfo) + 1)) | |
| 1773 .RetiresOnSaturation(); | |
| 1774 EXPECT_CALL( | |
| 1775 *gl_, GetShaderInfoLog(kServiceShaderId, strlen(kInfo) + 1, _, _)) | |
| 1776 .WillOnce(DoAll(SetArgumentPointee<2>(strlen(kInfo)), | |
| 1777 SetArrayArgument<3>(kInfo, kInfo + strlen(kInfo) + 1))); | |
| 1778 compile_cmd.Init(client_shader_id_); | |
| 1779 cmd.Init(client_shader_id_, kBucketId); | |
| 1780 EXPECT_EQ(error::kNoError, ExecuteCmd(compile_cmd)); | |
| 1781 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1782 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId); | |
| 1783 ASSERT_TRUE(bucket != NULL); | |
| 1784 EXPECT_EQ(strlen(kInfo) + 1, bucket->size()); | |
| 1785 EXPECT_EQ(0, memcmp(bucket->GetData(0, bucket->size()), kInfo, | |
| 1786 bucket->size())); | |
| 1787 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 1788 } | |
| 1789 | |
| 1790 TEST_F(GLES2DecoderWithShaderTest, GetShaderInfoLogInvalidArgs) { | |
| 1791 const uint32 kBucketId = 123; | |
| 1792 GetShaderInfoLog cmd; | |
| 1793 cmd.Init(kInvalidClientId, kBucketId); | |
| 1794 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1795 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 1796 } | 73 } |
| 1797 | 74 |
| 1798 TEST_F(GLES2DecoderTest, GetIntegervCached) { | 75 TEST_F(GLES2DecoderTest, GetIntegervCached) { |
| 1799 struct TestInfo { | 76 struct TestInfo { |
| 1800 GLenum pname; | 77 GLenum pname; |
| 1801 GLint expected; | 78 GLint expected; |
| 1802 }; | 79 }; |
| 1803 TestInfo tests[] = { | 80 TestInfo tests[] = { |
| 1804 { GL_MAX_TEXTURE_SIZE, TestHelper::kMaxTextureSize, }, | 81 { |
| 1805 { GL_MAX_CUBE_MAP_TEXTURE_SIZE, TestHelper::kMaxCubeMapTextureSize, }, | 82 GL_MAX_TEXTURE_SIZE, TestHelper::kMaxTextureSize, |
| 1806 { GL_MAX_RENDERBUFFER_SIZE, TestHelper::kMaxRenderbufferSize, }, | 83 }, |
| 84 { |
| 85 GL_MAX_CUBE_MAP_TEXTURE_SIZE, TestHelper::kMaxCubeMapTextureSize, |
| 86 }, |
| 87 { |
| 88 GL_MAX_RENDERBUFFER_SIZE, TestHelper::kMaxRenderbufferSize, |
| 89 }, |
| 1807 }; | 90 }; |
| 1808 typedef GetIntegerv::Result Result; | 91 typedef GetIntegerv::Result Result; |
| 1809 for (size_t ii = 0; ii < sizeof(tests) / sizeof(tests[0]); ++ii) { | 92 for (size_t ii = 0; ii < sizeof(tests) / sizeof(tests[0]); ++ii) { |
| 1810 const TestInfo& test = tests[ii]; | 93 const TestInfo& test = tests[ii]; |
| 1811 Result* result = static_cast<Result*>(shared_memory_address_); | 94 Result* result = static_cast<Result*>(shared_memory_address_); |
| 1812 EXPECT_CALL(*gl_, GetError()) | 95 EXPECT_CALL(*gl_, GetError()) |
| 1813 .WillOnce(Return(GL_NO_ERROR)) | 96 .WillOnce(Return(GL_NO_ERROR)) |
| 1814 .WillOnce(Return(GL_NO_ERROR)) | 97 .WillOnce(Return(GL_NO_ERROR)) |
| 1815 .RetiresOnSaturation(); | 98 .RetiresOnSaturation(); |
| 1816 EXPECT_CALL(*gl_, GetIntegerv(test.pname, _)) | 99 EXPECT_CALL(*gl_, GetIntegerv(test.pname, _)).Times(0); |
| 1817 .Times(0); | |
| 1818 result->size = 0; | 100 result->size = 0; |
| 1819 GetIntegerv cmd2; | 101 GetIntegerv cmd2; |
| 1820 cmd2.Init(test.pname, shared_memory_id_, shared_memory_offset_); | 102 cmd2.Init(test.pname, shared_memory_id_, shared_memory_offset_); |
| 1821 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | 103 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |
| 1822 EXPECT_EQ( | 104 EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned(test.pname), |
| 1823 decoder_->GetGLES2Util()->GLGetNumValuesReturned(test.pname), | 105 result->GetNumResults()); |
| 1824 result->GetNumResults()); | |
| 1825 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 106 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1826 EXPECT_EQ(test.expected, result->GetData()[0]); | 107 EXPECT_EQ(test.expected, result->GetData()[0]); |
| 1827 } | 108 } |
| 1828 } | 109 } |
| 1829 | 110 |
| 1830 TEST_F(GLES2DecoderTest, CompileShaderValidArgs) { | |
| 1831 EXPECT_CALL(*gl_, ShaderSource(kServiceShaderId, 1, _, _)); | |
| 1832 EXPECT_CALL(*gl_, CompileShader(kServiceShaderId)); | |
| 1833 EXPECT_CALL(*gl_, GetShaderiv(kServiceShaderId, GL_COMPILE_STATUS, _)) | |
| 1834 .WillOnce(SetArgumentPointee<2>(GL_TRUE)) | |
| 1835 .RetiresOnSaturation(); | |
| 1836 CompileShader cmd; | |
| 1837 cmd.Init(client_shader_id_); | |
| 1838 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1839 } | |
| 1840 | |
| 1841 TEST_F(GLES2DecoderTest, CompileShaderInvalidArgs) { | |
| 1842 CompileShader cmd; | |
| 1843 cmd.Init(kInvalidClientId); | |
| 1844 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1845 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 1846 #if GLES2_TEST_SHADER_VS_PROGRAM_IDS | |
| 1847 cmd.Init(client_program_id_); | |
| 1848 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1849 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 1850 #endif // GLES2_TEST_SHADER_VS_PROGRAM_IDS | |
| 1851 } | |
| 1852 | |
| 1853 TEST_F(GLES2DecoderTest, ShaderSourceAndGetShaderSourceValidArgs) { | |
| 1854 const uint32 kBucketId = 123; | |
| 1855 const char kSource[] = "hello"; | |
| 1856 const uint32 kSourceSize = sizeof(kSource) - 1; | |
| 1857 memcpy(shared_memory_address_, kSource, kSourceSize); | |
| 1858 ShaderSource cmd; | |
| 1859 cmd.Init(client_shader_id_, | |
| 1860 kSharedMemoryId, kSharedMemoryOffset, kSourceSize); | |
| 1861 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1862 memset(shared_memory_address_, 0, kSourceSize); | |
| 1863 GetShaderSource get_cmd; | |
| 1864 get_cmd.Init(client_shader_id_, kBucketId); | |
| 1865 EXPECT_EQ(error::kNoError, ExecuteCmd(get_cmd)); | |
| 1866 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId); | |
| 1867 ASSERT_TRUE(bucket != NULL); | |
| 1868 EXPECT_EQ(kSourceSize + 1, bucket->size()); | |
| 1869 EXPECT_EQ(0, memcmp(bucket->GetData(0, bucket->size()), kSource, | |
| 1870 bucket->size())); | |
| 1871 } | |
| 1872 | |
| 1873 TEST_F(GLES2DecoderTest, ShaderSourceInvalidArgs) { | |
| 1874 const char kSource[] = "hello"; | |
| 1875 const uint32 kSourceSize = sizeof(kSource) - 1; | |
| 1876 memcpy(shared_memory_address_, kSource, kSourceSize); | |
| 1877 ShaderSource cmd; | |
| 1878 cmd.Init(kInvalidClientId, | |
| 1879 kSharedMemoryId, kSharedMemoryOffset, kSourceSize); | |
| 1880 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1881 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 1882 #if GLES2_TEST_SHADER_VS_PROGRAM_IDS | |
| 1883 cmd.Init(client_program_id_, | |
| 1884 kSharedMemoryId, kSharedMemoryOffset, kSourceSize); | |
| 1885 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1886 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 1887 #endif // GLES2_TEST_SHADER_VS_PROGRAM_IDS | |
| 1888 cmd.Init(client_shader_id_, | |
| 1889 kInvalidSharedMemoryId, kSharedMemoryOffset, kSourceSize); | |
| 1890 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 1891 cmd.Init(client_shader_id_, | |
| 1892 kSharedMemoryId, kInvalidSharedMemoryOffset, kSourceSize); | |
| 1893 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 1894 cmd.Init(client_shader_id_, | |
| 1895 kSharedMemoryId, kSharedMemoryOffset, kSharedBufferSize); | |
| 1896 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 1897 } | |
| 1898 | |
| 1899 TEST_F(GLES2DecoderTest, ShaderSourceBucketAndGetShaderSourceValidArgs) { | |
| 1900 const uint32 kInBucketId = 123; | |
| 1901 const uint32 kOutBucketId = 125; | |
| 1902 const char kSource[] = "hello"; | |
| 1903 const uint32 kSourceSize = sizeof(kSource) - 1; | |
| 1904 SetBucketAsCString(kInBucketId, kSource); | |
| 1905 ShaderSourceBucket cmd; | |
| 1906 cmd.Init(client_shader_id_, kInBucketId); | |
| 1907 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1908 ClearSharedMemory(); | |
| 1909 GetShaderSource get_cmd; | |
| 1910 get_cmd.Init(client_shader_id_, kOutBucketId); | |
| 1911 EXPECT_EQ(error::kNoError, ExecuteCmd(get_cmd)); | |
| 1912 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kOutBucketId); | |
| 1913 ASSERT_TRUE(bucket != NULL); | |
| 1914 EXPECT_EQ(kSourceSize + 1, bucket->size()); | |
| 1915 EXPECT_EQ(0, memcmp(bucket->GetData(0, bucket->size()), kSource, | |
| 1916 bucket->size())); | |
| 1917 } | |
| 1918 | |
| 1919 TEST_F(GLES2DecoderTest, ShaderSourceBucketInvalidArgs) { | |
| 1920 const uint32 kBucketId = 123; | |
| 1921 const char kSource[] = "hello"; | |
| 1922 const uint32 kSourceSize = sizeof(kSource) - 1; | |
| 1923 memcpy(shared_memory_address_, kSource, kSourceSize); | |
| 1924 ShaderSourceBucket cmd; | |
| 1925 // Test no bucket. | |
| 1926 cmd.Init(client_texture_id_, kBucketId); | |
| 1927 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 1928 // Test invalid client. | |
| 1929 SetBucketAsCString(kBucketId, kSource); | |
| 1930 cmd.Init(kInvalidClientId, kBucketId); | |
| 1931 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1932 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 1933 } | |
| 1934 | |
| 1935 TEST_F(GLES2DecoderTest, ShaderSourceStripComments) { | |
| 1936 const uint32 kInBucketId = 123; | |
| 1937 const char kSource[] = "hello/*te\ast*/world//a\ab"; | |
| 1938 SetBucketAsCString(kInBucketId, kSource); | |
| 1939 ShaderSourceBucket cmd; | |
| 1940 cmd.Init(client_shader_id_, kInBucketId); | |
| 1941 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1942 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 1943 } | |
| 1944 | |
| 1945 TEST_F(GLES2DecoderTest, GenerateMipmapWrongFormatsFails) { | |
| 1946 EXPECT_CALL(*gl_, GenerateMipmapEXT(_)) | |
| 1947 .Times(0); | |
| 1948 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 1949 DoTexImage2D( | |
| 1950 GL_TEXTURE_2D, 0, GL_RGBA, 16, 17, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 1951 0, 0); | |
| 1952 GenerateMipmap cmd; | |
| 1953 cmd.Init(GL_TEXTURE_2D); | |
| 1954 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1955 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 1956 } | |
| 1957 | |
| 1958 TEST_F(GLES2DecoderTest, GenerateMipmapHandlesOutOfMemory) { | |
| 1959 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 1960 TextureManager* manager = group().texture_manager(); | |
| 1961 TextureRef* texture_ref = manager->GetTexture(client_texture_id_); | |
| 1962 ASSERT_TRUE(texture_ref != NULL); | |
| 1963 Texture* texture = texture_ref->texture(); | |
| 1964 GLint width = 0; | |
| 1965 GLint height = 0; | |
| 1966 EXPECT_FALSE(texture->GetLevelSize(GL_TEXTURE_2D, 2, &width, &height)); | |
| 1967 DoTexImage2D( | |
| 1968 GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 1969 kSharedMemoryId, kSharedMemoryOffset); | |
| 1970 EXPECT_CALL(*gl_, GenerateMipmapEXT(GL_TEXTURE_2D)) | |
| 1971 .Times(1); | |
| 1972 EXPECT_CALL(*gl_, GetError()) | |
| 1973 .WillOnce(Return(GL_NO_ERROR)) | |
| 1974 .WillOnce(Return(GL_OUT_OF_MEMORY)) | |
| 1975 .RetiresOnSaturation(); | |
| 1976 GenerateMipmap cmd; | |
| 1977 cmd.Init(GL_TEXTURE_2D); | |
| 1978 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 1979 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); | |
| 1980 EXPECT_FALSE(texture->GetLevelSize(GL_TEXTURE_2D, 2, &width, &height)); | |
| 1981 } | |
| 1982 | |
| 1983 TEST_F(GLES2DecoderTest, GenerateMipmapClearsUnclearedTexture) { | |
| 1984 EXPECT_CALL(*gl_, GenerateMipmapEXT(_)) | |
| 1985 .Times(0); | |
| 1986 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 1987 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 1988 0, 0); | |
| 1989 SetupClearTextureExpectations( | |
| 1990 kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D, | |
| 1991 0, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2); | |
| 1992 EXPECT_CALL(*gl_, GenerateMipmapEXT(GL_TEXTURE_2D)); | |
| 1993 EXPECT_CALL(*gl_, GetError()) | |
| 1994 .WillOnce(Return(GL_NO_ERROR)) | |
| 1995 .WillOnce(Return(GL_NO_ERROR)) | |
| 1996 .RetiresOnSaturation(); | |
| 1997 GenerateMipmap cmd; | |
| 1998 cmd.Init(GL_TEXTURE_2D); | |
| 1999 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2000 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 2001 } | |
| 2002 | |
| 2003 // Same as GenerateMipmapClearsUnclearedTexture, but with workaround | |
| 2004 // |set_texture_filters_before_generating_mipmap|. | |
| 2005 TEST_F(GLES2DecoderManualInitTest, SetTextureFiltersBeforeGenerateMipmap) { | |
| 2006 CommandLine command_line(0, NULL); | |
| 2007 command_line.AppendSwitchASCII( | |
| 2008 switches::kGpuDriverBugWorkarounds, | |
| 2009 base::IntToString(gpu::SET_TEXTURE_FILTER_BEFORE_GENERATING_MIPMAP)); | |
| 2010 InitState init; | |
| 2011 init.gl_version = "3.0"; | |
| 2012 init.bind_generates_resource = true; | |
| 2013 InitDecoderWithCommandLine(init, &command_line); | |
| 2014 | |
| 2015 EXPECT_CALL(*gl_, GenerateMipmapEXT(_)) | |
| 2016 .Times(0); | |
| 2017 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 2018 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 2019 0, 0); | |
| 2020 SetupClearTextureExpectations( | |
| 2021 kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D, | |
| 2022 0, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2); | |
| 2023 EXPECT_CALL(*gl_, TexParameteri( | |
| 2024 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST)) | |
| 2025 .Times(1) | |
| 2026 .RetiresOnSaturation(); | |
| 2027 EXPECT_CALL(*gl_, GenerateMipmapEXT(GL_TEXTURE_2D)); | |
| 2028 EXPECT_CALL(*gl_, TexParameteri( | |
| 2029 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR)) | |
| 2030 .Times(1) | |
| 2031 .RetiresOnSaturation(); | |
| 2032 EXPECT_CALL(*gl_, GetError()) | |
| 2033 .WillOnce(Return(GL_NO_ERROR)) | |
| 2034 .WillOnce(Return(GL_NO_ERROR)) | |
| 2035 .RetiresOnSaturation(); | |
| 2036 GenerateMipmap cmd; | |
| 2037 cmd.Init(GL_TEXTURE_2D); | |
| 2038 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2039 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 2040 } | |
| 2041 | |
| 2042 TEST_F(GLES2DecoderWithShaderTest, Uniform1iValidArgs) { | |
| 2043 EXPECT_CALL(*gl_, Uniform1i(kUniform1RealLocation, 2)); | |
| 2044 Uniform1i cmd; | |
| 2045 cmd.Init(kUniform1FakeLocation, 2); | |
| 2046 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2047 } | |
| 2048 | |
| 2049 TEST_F(GLES2DecoderWithShaderTest, Uniform1ivValidArgs) { | |
| 2050 EXPECT_CALL( | |
| 2051 *gl_, Uniform1iv(kUniform1RealLocation, 1, | |
| 2052 reinterpret_cast<const GLint*>(shared_memory_address_))); | |
| 2053 Uniform1iv cmd; | |
| 2054 cmd.Init(kUniform1FakeLocation, | |
| 2055 1, shared_memory_id_, shared_memory_offset_); | |
| 2056 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2057 } | |
| 2058 | |
| 2059 TEST_F(GLES2DecoderWithShaderTest, Uniform1ivInvalidArgs2_0) { | |
| 2060 EXPECT_CALL(*gl_, Uniform1iv(_, _, _)).Times(0); | |
| 2061 Uniform1iv cmd; | |
| 2062 cmd.Init(kUniform1FakeLocation, | |
| 2063 1, kInvalidSharedMemoryId, 0); | |
| 2064 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); | |
| 2065 } | |
| 2066 | |
| 2067 TEST_F(GLES2DecoderWithShaderTest, Uniform1ivInvalidArgs2_1) { | |
| 2068 EXPECT_CALL(*gl_, Uniform1iv(_, _, _)).Times(0); | |
| 2069 Uniform1iv cmd; | |
| 2070 cmd.Init(kUniform1FakeLocation, | |
| 2071 1, shared_memory_id_, kInvalidSharedMemoryOffset); | |
| 2072 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); | |
| 2073 } | |
| 2074 | |
| 2075 TEST_F(GLES2DecoderWithShaderTest, Uniform1ivImmediateValidArgs) { | |
| 2076 Uniform1ivImmediate& cmd = *GetImmediateAs<Uniform1ivImmediate>(); | |
| 2077 EXPECT_CALL( | |
| 2078 *gl_, | |
| 2079 Uniform1iv(kUniform1RealLocation, 1, | |
| 2080 reinterpret_cast<GLint*>(ImmediateDataAddress(&cmd)))); | |
| 2081 GLint temp[1 * 2] = { 0, }; | |
| 2082 cmd.Init(kUniform1FakeLocation, 1, | |
| 2083 &temp[0]); | |
| 2084 EXPECT_EQ(error::kNoError, | |
| 2085 ExecuteImmediateCmd(cmd, sizeof(temp))); | |
| 2086 } | |
| 2087 | |
| 2088 TEST_F(GLES2DecoderWithShaderTest, Uniform1ivInvalidValidArgs) { | |
| 2089 EXPECT_CALL(*gl_, Uniform1iv(_, _, _)).Times(0); | |
| 2090 Uniform1iv cmd; | |
| 2091 cmd.Init(kUniform1FakeLocation, | |
| 2092 2, shared_memory_id_, shared_memory_offset_); | |
| 2093 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2094 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 2095 } | |
| 2096 | |
| 2097 TEST_F(GLES2DecoderWithShaderTest, Uniform1ivZeroCount) { | |
| 2098 EXPECT_CALL(*gl_, Uniform1iv(_, _, _)).Times(0); | |
| 2099 Uniform1iv cmd; | |
| 2100 cmd.Init(kUniform1FakeLocation, | |
| 2101 0, shared_memory_id_, shared_memory_offset_); | |
| 2102 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2103 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 2104 } | |
| 2105 | |
| 2106 TEST_F(GLES2DecoderWithShaderTest, Uniform1iSamplerIsLmited) { | |
| 2107 EXPECT_CALL(*gl_, Uniform1i(_, _)).Times(0); | |
| 2108 Uniform1i cmd; | |
| 2109 cmd.Init( | |
| 2110 kUniform1FakeLocation, | |
| 2111 kNumTextureUnits); | |
| 2112 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2113 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 2114 } | |
| 2115 | |
| 2116 TEST_F(GLES2DecoderWithShaderTest, Uniform1ivSamplerIsLimited) { | |
| 2117 EXPECT_CALL(*gl_, Uniform1iv(_, _, _)).Times(0); | |
| 2118 Uniform1ivImmediate& cmd = *GetImmediateAs<Uniform1ivImmediate>(); | |
| 2119 GLint temp[] = { kNumTextureUnits }; | |
| 2120 cmd.Init(kUniform1FakeLocation, 1, | |
| 2121 &temp[0]); | |
| 2122 EXPECT_EQ(error::kNoError, | |
| 2123 ExecuteImmediateCmd(cmd, sizeof(temp))); | |
| 2124 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 2125 } | |
| 2126 | |
| 2127 TEST_F(GLES2DecoderWithShaderTest, BindBufferToDifferentTargetFails) { | |
| 2128 // Bind the buffer to GL_ARRAY_BUFFER | |
| 2129 DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId); | |
| 2130 // Attempt to rebind to GL_ELEMENT_ARRAY_BUFFER | |
| 2131 // NOTE: Real GLES2 does not have this restriction but WebGL and we do. | |
| 2132 // This can be restriction can be removed at runtime. | |
| 2133 EXPECT_CALL(*gl_, BindBuffer(_, _)) | |
| 2134 .Times(0); | |
| 2135 BindBuffer cmd; | |
| 2136 cmd.Init(GL_ELEMENT_ARRAY_BUFFER, client_buffer_id_); | |
| 2137 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2138 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 2139 } | |
| 2140 | |
| 2141 TEST_F(GLES2DecoderTest, ActiveTextureValidArgs) { | |
| 2142 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1)); | |
| 2143 SpecializedSetup<ActiveTexture, 0>(true); | |
| 2144 ActiveTexture cmd; | |
| 2145 cmd.Init(GL_TEXTURE1); | |
| 2146 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2147 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 2148 } | |
| 2149 | |
| 2150 TEST_F(GLES2DecoderTest, ActiveTextureInvalidArgs) { | |
| 2151 EXPECT_CALL(*gl_, ActiveTexture(_)).Times(0); | |
| 2152 SpecializedSetup<ActiveTexture, 0>(false); | |
| 2153 ActiveTexture cmd; | |
| 2154 cmd.Init(GL_TEXTURE0 - 1); | |
| 2155 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2156 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | |
| 2157 cmd.Init(kNumTextureUnits); | |
| 2158 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2159 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | |
| 2160 } | |
| 2161 | |
| 2162 TEST_F(GLES2DecoderTest, CheckFramebufferStatusWithNoBoundTarget) { | |
| 2163 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(_)) | |
| 2164 .Times(0); | |
| 2165 CheckFramebufferStatus::Result* result = | |
| 2166 static_cast<CheckFramebufferStatus::Result*>(shared_memory_address_); | |
| 2167 *result = 0; | |
| 2168 CheckFramebufferStatus cmd; | |
| 2169 cmd.Init(GL_FRAMEBUFFER, shared_memory_id_, shared_memory_offset_); | |
| 2170 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2171 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), *result); | |
| 2172 } | |
| 2173 | |
| 2174 TEST_F(GLES2DecoderWithShaderTest, BindAndDeleteFramebuffer) { | |
| 2175 SetupTexture(); | |
| 2176 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); | |
| 2177 SetupExpectationsForApplyingDefaultDirtyState(); | |
| 2178 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, | |
| 2179 kServiceFramebufferId); | |
| 2180 DoDeleteFramebuffer( | |
| 2181 client_framebuffer_id_, kServiceFramebufferId, | |
| 2182 true, GL_FRAMEBUFFER, 0, | |
| 2183 true, GL_FRAMEBUFFER, 0); | |
| 2184 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | |
| 2185 .Times(1) | |
| 2186 .RetiresOnSaturation(); | |
| 2187 DrawArrays cmd; | |
| 2188 cmd.Init(GL_TRIANGLES, 0, kNumVertices); | |
| 2189 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2190 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 2191 } | |
| 2192 | |
| 2193 TEST_F(GLES2DecoderTest, FramebufferRenderbufferWithNoBoundTarget) { | |
| 2194 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT(_, _, _, _)) | |
| 2195 .Times(0); | |
| 2196 FramebufferRenderbuffer cmd; | |
| 2197 cmd.Init( | |
| 2198 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, | |
| 2199 client_renderbuffer_id_); | |
| 2200 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2201 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 2202 } | |
| 2203 | |
| 2204 TEST_F(GLES2DecoderTest, FramebufferTexture2DWithNoBoundTarget) { | |
| 2205 EXPECT_CALL(*gl_, FramebufferTexture2DEXT(_, _, _, _, _)) | |
| 2206 .Times(0); | |
| 2207 FramebufferTexture2D cmd; | |
| 2208 cmd.Init( | |
| 2209 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, client_texture_id_, | |
| 2210 0); | |
| 2211 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2212 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 2213 } | |
| 2214 | |
| 2215 TEST_F(GLES2DecoderTest, GetFramebufferAttachmentParameterivWithNoBoundTarget) { | |
| 2216 EXPECT_CALL(*gl_, GetError()) | |
| 2217 .WillOnce(Return(GL_NO_ERROR)) | |
| 2218 .WillOnce(Return(GL_NO_ERROR)) | |
| 2219 .RetiresOnSaturation(); | |
| 2220 EXPECT_CALL(*gl_, GetFramebufferAttachmentParameterivEXT(_, _, _, _)) | |
| 2221 .Times(0); | |
| 2222 GetFramebufferAttachmentParameteriv cmd; | |
| 2223 cmd.Init( | |
| 2224 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, | |
| 2225 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, shared_memory_id_, | |
| 2226 shared_memory_offset_); | |
| 2227 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2228 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 2229 } | |
| 2230 | |
| 2231 TEST_F(GLES2DecoderTest, GetFramebufferAttachmentParameterivWithRenderbuffer) { | |
| 2232 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, | |
| 2233 kServiceFramebufferId); | |
| 2234 EXPECT_CALL(*gl_, GetError()) | |
| 2235 .WillOnce(Return(GL_NO_ERROR)) | |
| 2236 .RetiresOnSaturation(); | |
| 2237 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT( | |
| 2238 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, | |
| 2239 kServiceRenderbufferId)) | |
| 2240 .Times(1) | |
| 2241 .RetiresOnSaturation(); | |
| 2242 EXPECT_CALL(*gl_, GetError()) | |
| 2243 .WillOnce(Return(GL_NO_ERROR)) | |
| 2244 .RetiresOnSaturation(); | |
| 2245 EXPECT_CALL(*gl_, GetError()) | |
| 2246 .WillOnce(Return(GL_NO_ERROR)) | |
| 2247 .WillOnce(Return(GL_NO_ERROR)) | |
| 2248 .RetiresOnSaturation(); | |
| 2249 GetFramebufferAttachmentParameteriv::Result* result = | |
| 2250 static_cast<GetFramebufferAttachmentParameteriv::Result*>( | |
| 2251 shared_memory_address_); | |
| 2252 result->size = 0; | |
| 2253 const GLint* result_value = result->GetData(); | |
| 2254 FramebufferRenderbuffer fbrb_cmd; | |
| 2255 GetFramebufferAttachmentParameteriv cmd; | |
| 2256 fbrb_cmd.Init( | |
| 2257 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, | |
| 2258 client_renderbuffer_id_); | |
| 2259 cmd.Init( | |
| 2260 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, | |
| 2261 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, shared_memory_id_, | |
| 2262 shared_memory_offset_); | |
| 2263 EXPECT_EQ(error::kNoError, ExecuteCmd(fbrb_cmd)); | |
| 2264 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2265 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 2266 EXPECT_EQ(static_cast<GLuint>(*result_value), client_renderbuffer_id_); | |
| 2267 } | |
| 2268 | |
| 2269 TEST_F(GLES2DecoderTest, GetFramebufferAttachmentParameterivWithTexture) { | |
| 2270 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, | |
| 2271 kServiceFramebufferId); | |
| 2272 EXPECT_CALL(*gl_, GetError()) | |
| 2273 .WillOnce(Return(GL_NO_ERROR)) | |
| 2274 .RetiresOnSaturation(); | |
| 2275 EXPECT_CALL(*gl_, FramebufferTexture2DEXT( | |
| 2276 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, | |
| 2277 kServiceTextureId, 0)) | |
| 2278 .Times(1) | |
| 2279 .RetiresOnSaturation(); | |
| 2280 EXPECT_CALL(*gl_, GetError()) | |
| 2281 .WillOnce(Return(GL_NO_ERROR)) | |
| 2282 .RetiresOnSaturation(); | |
| 2283 EXPECT_CALL(*gl_, GetError()) | |
| 2284 .WillOnce(Return(GL_NO_ERROR)) | |
| 2285 .WillOnce(Return(GL_NO_ERROR)) | |
| 2286 .RetiresOnSaturation(); | |
| 2287 GetFramebufferAttachmentParameteriv::Result* result = | |
| 2288 static_cast<GetFramebufferAttachmentParameteriv::Result*>( | |
| 2289 shared_memory_address_); | |
| 2290 result->SetNumResults(0); | |
| 2291 const GLint* result_value = result->GetData(); | |
| 2292 FramebufferTexture2D fbtex_cmd; | |
| 2293 GetFramebufferAttachmentParameteriv cmd; | |
| 2294 fbtex_cmd.Init( | |
| 2295 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, client_texture_id_, | |
| 2296 0); | |
| 2297 cmd.Init( | |
| 2298 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, | |
| 2299 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, shared_memory_id_, | |
| 2300 shared_memory_offset_); | |
| 2301 EXPECT_EQ(error::kNoError, ExecuteCmd(fbtex_cmd)); | |
| 2302 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2303 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 2304 EXPECT_EQ(static_cast<GLuint>(*result_value), client_texture_id_); | |
| 2305 } | |
| 2306 | |
| 2307 TEST_F(GLES2DecoderTest, GetRenderbufferParameterivWithNoBoundTarget) { | |
| 2308 EXPECT_CALL(*gl_, GetError()) | |
| 2309 .WillOnce(Return(GL_NO_ERROR)) | |
| 2310 .WillOnce(Return(GL_NO_ERROR)) | |
| 2311 .RetiresOnSaturation(); | |
| 2312 EXPECT_CALL(*gl_, GetRenderbufferParameterivEXT(_, _, _)) | |
| 2313 .Times(0); | |
| 2314 GetRenderbufferParameteriv cmd; | |
| 2315 cmd.Init( | |
| 2316 GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, shared_memory_id_, | |
| 2317 shared_memory_offset_); | |
| 2318 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2319 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 2320 } | |
| 2321 | |
| 2322 TEST_F(GLES2DecoderTest, RenderbufferStorageWithNoBoundTarget) { | |
| 2323 EXPECT_CALL(*gl_, RenderbufferStorageEXT(_, _, _, _)) | |
| 2324 .Times(0); | |
| 2325 RenderbufferStorage cmd; | |
| 2326 cmd.Init(GL_RENDERBUFFER, GL_RGBA4, 3, 4); | |
| 2327 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2328 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 2329 } | |
| 2330 | |
| 2331 namespace { | |
| 2332 | |
| 2333 // A class to emulate glReadPixels | |
| 2334 class ReadPixelsEmulator { | |
| 2335 public: | |
| 2336 // pack_alignment is the alignment you want ReadPixels to use | |
| 2337 // when copying. The actual data passed in pixels should be contiguous. | |
| 2338 ReadPixelsEmulator(GLsizei width, GLsizei height, GLint bytes_per_pixel, | |
| 2339 const void* src_pixels, const void* expected_pixels, | |
| 2340 GLint pack_alignment) | |
| 2341 : width_(width), | |
| 2342 height_(height), | |
| 2343 pack_alignment_(pack_alignment), | |
| 2344 bytes_per_pixel_(bytes_per_pixel), | |
| 2345 src_pixels_(reinterpret_cast<const int8*>(src_pixels)), | |
| 2346 expected_pixels_(reinterpret_cast<const int8*>(expected_pixels)) { | |
| 2347 } | |
| 2348 | |
| 2349 void ReadPixels( | |
| 2350 GLint x, GLint y, GLsizei width, GLsizei height, | |
| 2351 GLenum format, GLenum type, void* pixels) const { | |
| 2352 DCHECK_GE(x, 0); | |
| 2353 DCHECK_GE(y, 0); | |
| 2354 DCHECK_LE(x + width, width_); | |
| 2355 DCHECK_LE(y + height, height_); | |
| 2356 for (GLint yy = 0; yy < height; ++yy) { | |
| 2357 const int8* src = GetPixelAddress(src_pixels_, x, y + yy); | |
| 2358 const void* dst = ComputePackAlignmentAddress(0, yy, width, pixels); | |
| 2359 memcpy(const_cast<void*>(dst), src, width * bytes_per_pixel_); | |
| 2360 } | |
| 2361 } | |
| 2362 | |
| 2363 bool CompareRowSegment( | |
| 2364 GLint x, GLint y, GLsizei width, const void* data) const { | |
| 2365 DCHECK(x + width <= width_ || width == 0); | |
| 2366 return memcmp(data, GetPixelAddress(expected_pixels_, x, y), | |
| 2367 width * bytes_per_pixel_) == 0; | |
| 2368 } | |
| 2369 | |
| 2370 // Helper to compute address of pixel in pack aligned data. | |
| 2371 const void* ComputePackAlignmentAddress( | |
| 2372 GLint x, GLint y, GLsizei width, const void* address) const { | |
| 2373 GLint unpadded_row_size = ComputeImageDataSize(width, 1); | |
| 2374 GLint two_rows_size = ComputeImageDataSize(width, 2); | |
| 2375 GLsizei padded_row_size = two_rows_size - unpadded_row_size; | |
| 2376 GLint offset = y * padded_row_size + x * bytes_per_pixel_; | |
| 2377 return static_cast<const int8*>(address) + offset; | |
| 2378 } | |
| 2379 | |
| 2380 GLint ComputeImageDataSize(GLint width, GLint height) const { | |
| 2381 GLint row_size = width * bytes_per_pixel_; | |
| 2382 if (height > 1) { | |
| 2383 GLint temp = row_size + pack_alignment_ - 1; | |
| 2384 GLint padded_row_size = (temp / pack_alignment_) * pack_alignment_; | |
| 2385 GLint size_of_all_but_last_row = (height - 1) * padded_row_size; | |
| 2386 return size_of_all_but_last_row + row_size; | |
| 2387 } else { | |
| 2388 return height * row_size; | |
| 2389 } | |
| 2390 } | |
| 2391 | |
| 2392 private: | |
| 2393 const int8* GetPixelAddress(const int8* base, GLint x, GLint y) const { | |
| 2394 return base + (width_ * y + x) * bytes_per_pixel_; | |
| 2395 } | |
| 2396 | |
| 2397 GLsizei width_; | |
| 2398 GLsizei height_; | |
| 2399 GLint pack_alignment_; | |
| 2400 GLint bytes_per_pixel_; | |
| 2401 const int8* src_pixels_; | |
| 2402 const int8* expected_pixels_; | |
| 2403 }; | |
| 2404 | |
| 2405 } // anonymous namespace | |
| 2406 | |
| 2407 void GLES2DecoderTest::CheckReadPixelsOutOfRange( | |
| 2408 GLint in_read_x, GLint in_read_y, | |
| 2409 GLsizei in_read_width, GLsizei in_read_height, | |
| 2410 bool init) { | |
| 2411 const GLsizei kWidth = 5; | |
| 2412 const GLsizei kHeight = 3; | |
| 2413 const GLint kBytesPerPixel = 3; | |
| 2414 const GLint kPackAlignment = 4; | |
| 2415 const GLenum kFormat = GL_RGB; | |
| 2416 static const int8 kSrcPixels[kWidth * kHeight * kBytesPerPixel] = { | |
| 2417 12, 13, 14, 18, 19, 18, 19, 12, 13, 14, 18, 19, 18, 19, 13, | |
| 2418 29, 28, 23, 22, 21, 22, 21, 29, 28, 23, 22, 21, 22, 21, 28, | |
| 2419 31, 34, 39, 37, 32, 37, 32, 31, 34, 39, 37, 32, 37, 32, 34, | |
| 2420 }; | |
| 2421 | |
| 2422 ClearSharedMemory(); | |
| 2423 | |
| 2424 // We need to setup an FBO so we can know the max size that ReadPixels will | |
| 2425 // access | |
| 2426 if (init) { | |
| 2427 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 2428 DoTexImage2D( | |
| 2429 GL_TEXTURE_2D, 0, kFormat, kWidth, kHeight, 0, | |
| 2430 kFormat, GL_UNSIGNED_BYTE, kSharedMemoryId, | |
| 2431 kSharedMemoryOffset); | |
| 2432 DoBindFramebuffer( | |
| 2433 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); | |
| 2434 DoFramebufferTexture2D( | |
| 2435 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, | |
| 2436 client_texture_id_, kServiceTextureId, 0, GL_NO_ERROR); | |
| 2437 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) | |
| 2438 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) | |
| 2439 .RetiresOnSaturation(); | |
| 2440 } | |
| 2441 | |
| 2442 ReadPixelsEmulator emu( | |
| 2443 kWidth, kHeight, kBytesPerPixel, kSrcPixels, kSrcPixels, kPackAlignment); | |
| 2444 typedef ReadPixels::Result Result; | |
| 2445 Result* result = GetSharedMemoryAs<Result*>(); | |
| 2446 uint32 result_shm_id = kSharedMemoryId; | |
| 2447 uint32 result_shm_offset = kSharedMemoryOffset; | |
| 2448 uint32 pixels_shm_id = kSharedMemoryId; | |
| 2449 uint32 pixels_shm_offset = kSharedMemoryOffset + sizeof(*result); | |
| 2450 void* dest = &result[1]; | |
| 2451 EXPECT_CALL(*gl_, GetError()) | |
| 2452 .WillOnce(Return(GL_NO_ERROR)) | |
| 2453 .WillOnce(Return(GL_NO_ERROR)) | |
| 2454 .RetiresOnSaturation(); | |
| 2455 // ReadPixels will be called for valid size only even though the command | |
| 2456 // is requesting a larger size. | |
| 2457 GLint read_x = std::max(0, in_read_x); | |
| 2458 GLint read_y = std::max(0, in_read_y); | |
| 2459 GLint read_end_x = std::max(0, std::min(kWidth, in_read_x + in_read_width)); | |
| 2460 GLint read_end_y = std::max(0, std::min(kHeight, in_read_y + in_read_height)); | |
| 2461 GLint read_width = read_end_x - read_x; | |
| 2462 GLint read_height = read_end_y - read_y; | |
| 2463 if (read_width > 0 && read_height > 0) { | |
| 2464 for (GLint yy = read_y; yy < read_end_y; ++yy) { | |
| 2465 EXPECT_CALL( | |
| 2466 *gl_, ReadPixels(read_x, yy, read_width, 1, | |
| 2467 kFormat, GL_UNSIGNED_BYTE, _)) | |
| 2468 .WillOnce(Invoke(&emu, &ReadPixelsEmulator::ReadPixels)) | |
| 2469 .RetiresOnSaturation(); | |
| 2470 } | |
| 2471 } | |
| 2472 ReadPixels cmd; | |
| 2473 cmd.Init(in_read_x, in_read_y, in_read_width, in_read_height, | |
| 2474 kFormat, GL_UNSIGNED_BYTE, | |
| 2475 pixels_shm_id, pixels_shm_offset, | |
| 2476 result_shm_id, result_shm_offset, | |
| 2477 false); | |
| 2478 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2479 | |
| 2480 GLint unpadded_row_size = emu.ComputeImageDataSize(in_read_width, 1); | |
| 2481 scoped_ptr<int8[]> zero(new int8[unpadded_row_size]); | |
| 2482 scoped_ptr<int8[]> pack(new int8[kPackAlignment]); | |
| 2483 memset(zero.get(), 0, unpadded_row_size); | |
| 2484 memset(pack.get(), kInitialMemoryValue, kPackAlignment); | |
| 2485 for (GLint yy = 0; yy < in_read_height; ++yy) { | |
| 2486 const int8* row = static_cast<const int8*>( | |
| 2487 emu.ComputePackAlignmentAddress(0, yy, in_read_width, dest)); | |
| 2488 GLint y = in_read_y + yy; | |
| 2489 if (y < 0 || y >= kHeight) { | |
| 2490 EXPECT_EQ(0, memcmp(zero.get(), row, unpadded_row_size)); | |
| 2491 } else { | |
| 2492 // check off left. | |
| 2493 GLint num_left_pixels = std::max(-in_read_x, 0); | |
| 2494 GLint num_left_bytes = num_left_pixels * kBytesPerPixel; | |
| 2495 EXPECT_EQ(0, memcmp(zero.get(), row, num_left_bytes)); | |
| 2496 | |
| 2497 // check off right. | |
| 2498 GLint num_right_pixels = std::max(in_read_x + in_read_width - kWidth, 0); | |
| 2499 GLint num_right_bytes = num_right_pixels * kBytesPerPixel; | |
| 2500 EXPECT_EQ(0, memcmp(zero.get(), | |
| 2501 row + unpadded_row_size - num_right_bytes, | |
| 2502 num_right_bytes)); | |
| 2503 | |
| 2504 // check middle. | |
| 2505 GLint x = std::max(in_read_x, 0); | |
| 2506 GLint num_middle_pixels = | |
| 2507 std::max(in_read_width - num_left_pixels - num_right_pixels, 0); | |
| 2508 EXPECT_TRUE(emu.CompareRowSegment( | |
| 2509 x, y, num_middle_pixels, row + num_left_bytes)); | |
| 2510 } | |
| 2511 | |
| 2512 // check padding | |
| 2513 if (yy != in_read_height - 1) { | |
| 2514 GLint num_padding_bytes = | |
| 2515 (kPackAlignment - 1) - (unpadded_row_size % kPackAlignment); | |
| 2516 EXPECT_EQ(0, | |
| 2517 memcmp(pack.get(), row + unpadded_row_size, num_padding_bytes)); | |
| 2518 } | |
| 2519 } | |
| 2520 } | |
| 2521 | |
| 2522 TEST_F(GLES2DecoderTest, ReadPixels) { | |
| 2523 const GLsizei kWidth = 5; | |
| 2524 const GLsizei kHeight = 3; | |
| 2525 const GLint kBytesPerPixel = 3; | |
| 2526 const GLint kPackAlignment = 4; | |
| 2527 static const int8 kSrcPixels[kWidth * kHeight * kBytesPerPixel] = { | |
| 2528 12, 13, 14, 18, 19, 18, 19, 12, 13, 14, 18, 19, 18, 19, 13, | |
| 2529 29, 28, 23, 22, 21, 22, 21, 29, 28, 23, 22, 21, 22, 21, 28, | |
| 2530 31, 34, 39, 37, 32, 37, 32, 31, 34, 39, 37, 32, 37, 32, 34, | |
| 2531 }; | |
| 2532 | |
| 2533 surface_->SetSize(gfx::Size(INT_MAX, INT_MAX)); | |
| 2534 | |
| 2535 ReadPixelsEmulator emu( | |
| 2536 kWidth, kHeight, kBytesPerPixel, kSrcPixels, kSrcPixels, kPackAlignment); | |
| 2537 typedef ReadPixels::Result Result; | |
| 2538 Result* result = GetSharedMemoryAs<Result*>(); | |
| 2539 uint32 result_shm_id = kSharedMemoryId; | |
| 2540 uint32 result_shm_offset = kSharedMemoryOffset; | |
| 2541 uint32 pixels_shm_id = kSharedMemoryId; | |
| 2542 uint32 pixels_shm_offset = kSharedMemoryOffset + sizeof(*result); | |
| 2543 void* dest = &result[1]; | |
| 2544 EXPECT_CALL(*gl_, GetError()) | |
| 2545 .WillOnce(Return(GL_NO_ERROR)) | |
| 2546 .WillOnce(Return(GL_NO_ERROR)) | |
| 2547 .RetiresOnSaturation(); | |
| 2548 EXPECT_CALL( | |
| 2549 *gl_, ReadPixels(0, 0, kWidth, kHeight, GL_RGB, GL_UNSIGNED_BYTE, _)) | |
| 2550 .WillOnce(Invoke(&emu, &ReadPixelsEmulator::ReadPixels)); | |
| 2551 ReadPixels cmd; | |
| 2552 cmd.Init(0, 0, kWidth, kHeight, GL_RGB, GL_UNSIGNED_BYTE, | |
| 2553 pixels_shm_id, pixels_shm_offset, | |
| 2554 result_shm_id, result_shm_offset, | |
| 2555 false); | |
| 2556 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2557 for (GLint yy = 0; yy < kHeight; ++yy) { | |
| 2558 EXPECT_TRUE(emu.CompareRowSegment( | |
| 2559 0, yy, kWidth, | |
| 2560 emu.ComputePackAlignmentAddress(0, yy, kWidth, dest))); | |
| 2561 } | |
| 2562 } | |
| 2563 | |
| 2564 TEST_F(GLES2DecoderRGBBackbufferTest, ReadPixelsNoAlphaBackbuffer) { | |
| 2565 const GLsizei kWidth = 3; | |
| 2566 const GLsizei kHeight = 3; | |
| 2567 const GLint kBytesPerPixel = 4; | |
| 2568 const GLint kPackAlignment = 4; | |
| 2569 static const uint8 kExpectedPixels[kWidth * kHeight * kBytesPerPixel] = { | |
| 2570 12, 13, 14, 255, 19, 18, 19, 255, 13, 14, 18, 255, | |
| 2571 29, 28, 23, 255, 21, 22, 21, 255, 28, 23, 22, 255, | |
| 2572 31, 34, 39, 255, 32, 37, 32, 255, 34, 39, 37, 255, | |
| 2573 }; | |
| 2574 static const uint8 kSrcPixels[kWidth * kHeight * kBytesPerPixel] = { | |
| 2575 12, 13, 14, 18, 19, 18, 19, 12, 13, 14, 18, 19, | |
| 2576 29, 28, 23, 22, 21, 22, 21, 29, 28, 23, 22, 21, | |
| 2577 31, 34, 39, 37, 32, 37, 32, 31, 34, 39, 37, 32, | |
| 2578 }; | |
| 2579 | |
| 2580 surface_->SetSize(gfx::Size(INT_MAX, INT_MAX)); | |
| 2581 | |
| 2582 ReadPixelsEmulator emu( | |
| 2583 kWidth, kHeight, kBytesPerPixel, kSrcPixels, kExpectedPixels, | |
| 2584 kPackAlignment); | |
| 2585 typedef ReadPixels::Result Result; | |
| 2586 Result* result = GetSharedMemoryAs<Result*>(); | |
| 2587 uint32 result_shm_id = kSharedMemoryId; | |
| 2588 uint32 result_shm_offset = kSharedMemoryOffset; | |
| 2589 uint32 pixels_shm_id = kSharedMemoryId; | |
| 2590 uint32 pixels_shm_offset = kSharedMemoryOffset + sizeof(*result); | |
| 2591 void* dest = &result[1]; | |
| 2592 EXPECT_CALL(*gl_, GetError()) | |
| 2593 .WillOnce(Return(GL_NO_ERROR)) | |
| 2594 .WillOnce(Return(GL_NO_ERROR)) | |
| 2595 .RetiresOnSaturation(); | |
| 2596 EXPECT_CALL( | |
| 2597 *gl_, ReadPixels(0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, _)) | |
| 2598 .WillOnce(Invoke(&emu, &ReadPixelsEmulator::ReadPixels)); | |
| 2599 ReadPixels cmd; | |
| 2600 cmd.Init(0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 2601 pixels_shm_id, pixels_shm_offset, | |
| 2602 result_shm_id, result_shm_offset, | |
| 2603 false); | |
| 2604 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2605 for (GLint yy = 0; yy < kHeight; ++yy) { | |
| 2606 EXPECT_TRUE(emu.CompareRowSegment( | |
| 2607 0, yy, kWidth, | |
| 2608 emu.ComputePackAlignmentAddress(0, yy, kWidth, dest))); | |
| 2609 } | |
| 2610 } | |
| 2611 | |
| 2612 TEST_F(GLES2DecoderTest, ReadPixelsOutOfRange) { | |
| 2613 static GLint tests[][4] = { | |
| 2614 { -2, -1, 9, 5, }, // out of range on all sides | |
| 2615 { 2, 1, 9, 5, }, // out of range on right, bottom | |
| 2616 { -7, -4, 9, 5, }, // out of range on left, top | |
| 2617 { 0, -5, 9, 5, }, // completely off top | |
| 2618 { 0, 3, 9, 5, }, // completely off bottom | |
| 2619 { -9, 0, 9, 5, }, // completely off left | |
| 2620 { 5, 0, 9, 5, }, // completely off right | |
| 2621 }; | |
| 2622 | |
| 2623 for (size_t tt = 0; tt < arraysize(tests); ++tt) { | |
| 2624 CheckReadPixelsOutOfRange( | |
| 2625 tests[tt][0], tests[tt][1], tests[tt][2], tests[tt][3], tt == 0); | |
| 2626 } | |
| 2627 } | |
| 2628 | |
| 2629 TEST_F(GLES2DecoderTest, ReadPixelsInvalidArgs) { | |
| 2630 typedef ReadPixels::Result Result; | |
| 2631 Result* result = GetSharedMemoryAs<Result*>(); | |
| 2632 uint32 result_shm_id = kSharedMemoryId; | |
| 2633 uint32 result_shm_offset = kSharedMemoryOffset; | |
| 2634 uint32 pixels_shm_id = kSharedMemoryId; | |
| 2635 uint32 pixels_shm_offset = kSharedMemoryOffset + sizeof(*result); | |
| 2636 EXPECT_CALL(*gl_, ReadPixels(_, _, _, _, _, _, _)).Times(0); | |
| 2637 ReadPixels cmd; | |
| 2638 cmd.Init(0, 0, -1, 1, GL_RGB, GL_UNSIGNED_BYTE, | |
| 2639 pixels_shm_id, pixels_shm_offset, | |
| 2640 result_shm_id, result_shm_offset, | |
| 2641 false); | |
| 2642 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2643 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 2644 cmd.Init(0, 0, 1, -1, GL_RGB, GL_UNSIGNED_BYTE, | |
| 2645 pixels_shm_id, pixels_shm_offset, | |
| 2646 result_shm_id, result_shm_offset, | |
| 2647 false); | |
| 2648 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2649 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 2650 cmd.Init(0, 0, 1, 1, GL_RGB, GL_INT, | |
| 2651 pixels_shm_id, pixels_shm_offset, | |
| 2652 result_shm_id, result_shm_offset, | |
| 2653 false); | |
| 2654 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2655 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | |
| 2656 cmd.Init(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, | |
| 2657 kInvalidSharedMemoryId, pixels_shm_offset, | |
| 2658 result_shm_id, result_shm_offset, | |
| 2659 false); | |
| 2660 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 2661 cmd.Init(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, | |
| 2662 pixels_shm_id, kInvalidSharedMemoryOffset, | |
| 2663 result_shm_id, result_shm_offset, | |
| 2664 false); | |
| 2665 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 2666 cmd.Init(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, | |
| 2667 pixels_shm_id, pixels_shm_offset, | |
| 2668 kInvalidSharedMemoryId, result_shm_offset, | |
| 2669 false); | |
| 2670 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 2671 cmd.Init(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, | |
| 2672 pixels_shm_id, pixels_shm_offset, | |
| 2673 result_shm_id, kInvalidSharedMemoryOffset, | |
| 2674 false); | |
| 2675 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 2676 } | |
| 2677 | |
| 2678 TEST_F(GLES2DecoderManualInitTest, ReadPixelsAsyncError) { | |
| 2679 InitState init; | |
| 2680 init.extensions = "GL_ARB_sync"; | |
| 2681 init.gl_version = "opengl es 3.0"; | |
| 2682 init.has_alpha = true; | |
| 2683 init.request_alpha = true; | |
| 2684 init.bind_generates_resource = true; | |
| 2685 InitDecoder(init); | |
| 2686 | |
| 2687 typedef ReadPixels::Result Result; | |
| 2688 Result* result = GetSharedMemoryAs<Result*>(); | |
| 2689 | |
| 2690 const GLsizei kWidth = 4; | |
| 2691 const GLsizei kHeight = 4; | |
| 2692 uint32 result_shm_id = kSharedMemoryId; | |
| 2693 uint32 result_shm_offset = kSharedMemoryOffset; | |
| 2694 uint32 pixels_shm_id = kSharedMemoryId; | |
| 2695 uint32 pixels_shm_offset = kSharedMemoryOffset + sizeof(*result); | |
| 2696 | |
| 2697 EXPECT_CALL(*gl_, GetError()) | |
| 2698 // first error check must pass to get to the test | |
| 2699 .WillOnce(Return(GL_NO_ERROR)) | |
| 2700 // second check is after BufferData, simulate fail here | |
| 2701 .WillOnce(Return(GL_INVALID_OPERATION)) | |
| 2702 // third error check is fall-through call to sync ReadPixels | |
| 2703 .WillOnce(Return(GL_NO_ERROR)) | |
| 2704 .RetiresOnSaturation(); | |
| 2705 | |
| 2706 EXPECT_CALL(*gl_, ReadPixels(0, 0, kWidth, kHeight, GL_RGB, | |
| 2707 GL_UNSIGNED_BYTE, _)).Times(1); | |
| 2708 EXPECT_CALL(*gl_, GenBuffersARB(1, _)).Times(1); | |
| 2709 EXPECT_CALL(*gl_, BindBuffer(GL_PIXEL_PACK_BUFFER_ARB, _)).Times(2); | |
| 2710 EXPECT_CALL(*gl_, BufferData(GL_PIXEL_PACK_BUFFER_ARB, _, NULL, | |
| 2711 GL_STREAM_READ)).Times(1); | |
| 2712 | |
| 2713 ReadPixels cmd; | |
| 2714 cmd.Init(0, 0, kWidth, kHeight, GL_RGB, GL_UNSIGNED_BYTE, | |
| 2715 pixels_shm_id, pixels_shm_offset, | |
| 2716 result_shm_id, result_shm_offset, | |
| 2717 true); | |
| 2718 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2719 } | |
| 2720 | |
| 2721 TEST_F(GLES2DecoderTest, BindAttribLocation) { | |
| 2722 const GLint kLocation = 2; | |
| 2723 const char* kName = "testing"; | |
| 2724 const uint32 kNameSize = strlen(kName); | |
| 2725 EXPECT_CALL( | |
| 2726 *gl_, BindAttribLocation(kServiceProgramId, kLocation, StrEq(kName))) | |
| 2727 .Times(1); | |
| 2728 memcpy(shared_memory_address_, kName, kNameSize); | |
| 2729 BindAttribLocation cmd; | |
| 2730 cmd.Init(client_program_id_, kLocation, kSharedMemoryId, kSharedMemoryOffset, | |
| 2731 kNameSize); | |
| 2732 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2733 } | |
| 2734 | |
| 2735 TEST_F(GLES2DecoderTest, BindAttribLocationInvalidArgs) { | |
| 2736 const GLint kLocation = 2; | |
| 2737 const char* kName = "testing"; | |
| 2738 const char* kBadName = "test\aing"; | |
| 2739 const uint32 kNameSize = strlen(kName); | |
| 2740 const uint32 kBadNameSize = strlen(kBadName); | |
| 2741 EXPECT_CALL(*gl_, BindAttribLocation(_, _, _)).Times(0); | |
| 2742 memcpy(shared_memory_address_, kName, kNameSize); | |
| 2743 BindAttribLocation cmd; | |
| 2744 cmd.Init(kInvalidClientId, kLocation, | |
| 2745 kSharedMemoryId, kSharedMemoryOffset, kNameSize); | |
| 2746 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2747 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 2748 cmd.Init(client_program_id_, kLocation, | |
| 2749 kInvalidSharedMemoryId, kSharedMemoryOffset, kNameSize); | |
| 2750 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 2751 cmd.Init(client_program_id_, kLocation, | |
| 2752 kSharedMemoryId, kInvalidSharedMemoryOffset, kNameSize); | |
| 2753 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 2754 cmd.Init(client_program_id_, kLocation, | |
| 2755 kSharedMemoryId, kSharedMemoryOffset, kSharedBufferSize); | |
| 2756 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 2757 memcpy(shared_memory_address_, kBadName, kBadNameSize); | |
| 2758 cmd.Init(client_program_id_, kLocation, | |
| 2759 kSharedMemoryId, kSharedMemoryOffset, kBadNameSize); | |
| 2760 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2761 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 2762 } | |
| 2763 | |
| 2764 TEST_F(GLES2DecoderTest, BindAttribLocationBucket) { | |
| 2765 const uint32 kBucketId = 123; | |
| 2766 const GLint kLocation = 2; | |
| 2767 const char* kName = "testing"; | |
| 2768 EXPECT_CALL( | |
| 2769 *gl_, BindAttribLocation(kServiceProgramId, kLocation, StrEq(kName))) | |
| 2770 .Times(1); | |
| 2771 SetBucketAsCString(kBucketId, kName); | |
| 2772 BindAttribLocationBucket cmd; | |
| 2773 cmd.Init(client_program_id_, kLocation, kBucketId); | |
| 2774 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2775 } | |
| 2776 | |
| 2777 TEST_F(GLES2DecoderTest, BindAttribLocationBucketInvalidArgs) { | |
| 2778 const uint32 kBucketId = 123; | |
| 2779 const GLint kLocation = 2; | |
| 2780 const char* kName = "testing"; | |
| 2781 EXPECT_CALL(*gl_, BindAttribLocation(_, _, _)).Times(0); | |
| 2782 BindAttribLocationBucket cmd; | |
| 2783 // check bucket does not exist. | |
| 2784 cmd.Init(client_program_id_, kLocation, kBucketId); | |
| 2785 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 2786 // check bucket is empty. | |
| 2787 SetBucketAsCString(kBucketId, NULL); | |
| 2788 cmd.Init(client_program_id_, kLocation, kBucketId); | |
| 2789 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 2790 // Check bad program id | |
| 2791 SetBucketAsCString(kBucketId, kName); | |
| 2792 cmd.Init(kInvalidClientId, kLocation, kBucketId); | |
| 2793 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2794 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 2795 } | |
| 2796 | |
| 2797 TEST_F(GLES2DecoderWithShaderTest, GetAttribLocation) { | |
| 2798 const uint32 kNameSize = strlen(kAttrib2Name); | |
| 2799 const char* kNonExistentName = "foobar"; | |
| 2800 const uint32 kNonExistentNameSize = strlen(kNonExistentName); | |
| 2801 typedef GetAttribLocation::Result Result; | |
| 2802 Result* result = GetSharedMemoryAs<Result*>(); | |
| 2803 *result = -1; | |
| 2804 char* name = GetSharedMemoryAsWithOffset<char*>(sizeof(*result)); | |
| 2805 const uint32 kNameOffset = kSharedMemoryOffset + sizeof(*result); | |
| 2806 memcpy(name, kAttrib2Name, kNameSize); | |
| 2807 GetAttribLocation cmd; | |
| 2808 cmd.Init(client_program_id_, | |
| 2809 kSharedMemoryId, kNameOffset, | |
| 2810 kSharedMemoryId, kSharedMemoryOffset, | |
| 2811 kNameSize); | |
| 2812 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2813 EXPECT_EQ(kAttrib2Location, *result); | |
| 2814 *result = -1; | |
| 2815 memcpy(name, kNonExistentName, kNonExistentNameSize); | |
| 2816 cmd.Init(client_program_id_, | |
| 2817 kSharedMemoryId, kNameOffset, | |
| 2818 kSharedMemoryId, kSharedMemoryOffset, | |
| 2819 kNonExistentNameSize); | |
| 2820 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2821 EXPECT_EQ(-1, *result); | |
| 2822 } | |
| 2823 | |
| 2824 TEST_F(GLES2DecoderWithShaderTest, GetAttribLocationInvalidArgs) { | |
| 2825 const uint32 kNameSize = strlen(kAttrib2Name); | |
| 2826 const char* kBadName = "foo\abar"; | |
| 2827 const uint32 kBadNameSize = strlen(kBadName); | |
| 2828 typedef GetAttribLocation::Result Result; | |
| 2829 Result* result = GetSharedMemoryAs<Result*>(); | |
| 2830 *result = -1; | |
| 2831 char* name = GetSharedMemoryAsWithOffset<char*>(sizeof(*result)); | |
| 2832 const uint32 kNameOffset = kSharedMemoryOffset + sizeof(*result); | |
| 2833 memcpy(name, kAttrib2Name, kNameSize); | |
| 2834 GetAttribLocation cmd; | |
| 2835 cmd.Init(kInvalidClientId, | |
| 2836 kSharedMemoryId, kNameOffset, | |
| 2837 kSharedMemoryId, kSharedMemoryOffset, | |
| 2838 kNameSize); | |
| 2839 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2840 EXPECT_EQ(-1, *result); | |
| 2841 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 2842 *result = -1; | |
| 2843 cmd.Init(client_program_id_, | |
| 2844 kInvalidSharedMemoryId, kNameOffset, | |
| 2845 kSharedMemoryId, kSharedMemoryOffset, | |
| 2846 kNameSize); | |
| 2847 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 2848 EXPECT_EQ(-1, *result); | |
| 2849 cmd.Init(client_program_id_, | |
| 2850 kSharedMemoryId, kInvalidSharedMemoryOffset, | |
| 2851 kSharedMemoryId, kSharedMemoryOffset, | |
| 2852 kNameSize); | |
| 2853 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 2854 EXPECT_EQ(-1, *result); | |
| 2855 cmd.Init(client_program_id_, | |
| 2856 kSharedMemoryId, kNameOffset, | |
| 2857 kInvalidSharedMemoryId, kSharedMemoryOffset, | |
| 2858 kNameSize); | |
| 2859 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 2860 EXPECT_EQ(-1, *result); | |
| 2861 cmd.Init(client_program_id_, | |
| 2862 kSharedMemoryId, kNameOffset, | |
| 2863 kSharedMemoryId, kInvalidSharedMemoryOffset, | |
| 2864 kNameSize); | |
| 2865 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 2866 EXPECT_EQ(-1, *result); | |
| 2867 cmd.Init(client_program_id_, | |
| 2868 kSharedMemoryId, kNameOffset, | |
| 2869 kSharedMemoryId, kSharedMemoryOffset, | |
| 2870 kSharedBufferSize); | |
| 2871 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 2872 EXPECT_EQ(-1, *result); | |
| 2873 memcpy(name, kBadName, kBadNameSize); | |
| 2874 cmd.Init(client_program_id_, | |
| 2875 kSharedMemoryId, kNameOffset, | |
| 2876 kSharedMemoryId, kSharedMemoryOffset, | |
| 2877 kBadNameSize); | |
| 2878 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2879 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 2880 } | |
| 2881 | |
| 2882 TEST_F(GLES2DecoderWithShaderTest, GetAttribLocationBucket) { | |
| 2883 const uint32 kBucketId = 123; | |
| 2884 const char* kNonExistentName = "foobar"; | |
| 2885 typedef GetAttribLocationBucket::Result Result; | |
| 2886 Result* result = GetSharedMemoryAs<Result*>(); | |
| 2887 SetBucketAsCString(kBucketId, kAttrib2Name); | |
| 2888 *result = -1; | |
| 2889 GetAttribLocationBucket cmd; | |
| 2890 cmd.Init(client_program_id_, kBucketId, | |
| 2891 kSharedMemoryId, kSharedMemoryOffset); | |
| 2892 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2893 EXPECT_EQ(kAttrib2Location, *result); | |
| 2894 SetBucketAsCString(kBucketId, kNonExistentName); | |
| 2895 *result = -1; | |
| 2896 cmd.Init(client_program_id_, kBucketId, | |
| 2897 kSharedMemoryId, kSharedMemoryOffset); | |
| 2898 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2899 EXPECT_EQ(-1, *result); | |
| 2900 } | |
| 2901 | |
| 2902 TEST_F(GLES2DecoderWithShaderTest, GetAttribLocationBucketInvalidArgs) { | |
| 2903 const uint32 kBucketId = 123; | |
| 2904 typedef GetAttribLocationBucket::Result Result; | |
| 2905 Result* result = GetSharedMemoryAs<Result*>(); | |
| 2906 *result = -1; | |
| 2907 GetAttribLocationBucket cmd; | |
| 2908 // Check no bucket | |
| 2909 cmd.Init(client_program_id_, kBucketId, | |
| 2910 kSharedMemoryId, kSharedMemoryOffset); | |
| 2911 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 2912 EXPECT_EQ(-1, *result); | |
| 2913 // Check bad program id. | |
| 2914 SetBucketAsCString(kBucketId, kAttrib2Name); | |
| 2915 cmd.Init(kInvalidClientId, kBucketId, | |
| 2916 kSharedMemoryId, kSharedMemoryOffset); | |
| 2917 *result = -1; | |
| 2918 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2919 EXPECT_EQ(-1, *result); | |
| 2920 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 2921 // Check bad memory | |
| 2922 cmd.Init(client_program_id_, kBucketId, | |
| 2923 kInvalidSharedMemoryId, kSharedMemoryOffset); | |
| 2924 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 2925 cmd.Init(client_program_id_, kBucketId, | |
| 2926 kSharedMemoryId, kInvalidSharedMemoryOffset); | |
| 2927 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 2928 } | |
| 2929 | |
| 2930 TEST_F(GLES2DecoderWithShaderTest, GetUniformLocation) { | |
| 2931 const uint32 kNameSize = strlen(kUniform2Name); | |
| 2932 const char* kNonExistentName = "foobar"; | |
| 2933 const uint32 kNonExistentNameSize = strlen(kNonExistentName); | |
| 2934 typedef GetUniformLocation::Result Result; | |
| 2935 Result* result = GetSharedMemoryAs<Result*>(); | |
| 2936 *result = -1; | |
| 2937 char* name = GetSharedMemoryAsWithOffset<char*>(sizeof(*result)); | |
| 2938 const uint32 kNameOffset = kSharedMemoryOffset + sizeof(*result); | |
| 2939 memcpy(name, kUniform2Name, kNameSize); | |
| 2940 GetUniformLocation cmd; | |
| 2941 cmd.Init(client_program_id_, | |
| 2942 kSharedMemoryId, kNameOffset, | |
| 2943 kSharedMemoryId, kSharedMemoryOffset, | |
| 2944 kNameSize); | |
| 2945 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2946 EXPECT_EQ(kUniform2FakeLocation, *result); | |
| 2947 memcpy(name, kNonExistentName, kNonExistentNameSize); | |
| 2948 *result = -1; | |
| 2949 cmd.Init(client_program_id_, | |
| 2950 kSharedMemoryId, kNameOffset, | |
| 2951 kSharedMemoryId, kSharedMemoryOffset, | |
| 2952 kNonExistentNameSize); | |
| 2953 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2954 EXPECT_EQ(-1, *result); | |
| 2955 } | |
| 2956 | |
| 2957 TEST_F(GLES2DecoderWithShaderTest, GetUniformLocationInvalidArgs) { | |
| 2958 const uint32 kNameSize = strlen(kUniform2Name); | |
| 2959 const char* kBadName = "foo\abar"; | |
| 2960 const uint32 kBadNameSize = strlen(kBadName); | |
| 2961 typedef GetUniformLocation::Result Result; | |
| 2962 Result* result = GetSharedMemoryAs<Result*>(); | |
| 2963 *result = -1; | |
| 2964 char* name = GetSharedMemoryAsWithOffset<char*>(sizeof(*result)); | |
| 2965 const uint32 kNameOffset = kSharedMemoryOffset + sizeof(*result); | |
| 2966 memcpy(name, kUniform2Name, kNameSize); | |
| 2967 GetUniformLocation cmd; | |
| 2968 cmd.Init(kInvalidClientId, | |
| 2969 kSharedMemoryId, kNameOffset, | |
| 2970 kSharedMemoryId, kSharedMemoryOffset, | |
| 2971 kNameSize); | |
| 2972 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 2973 EXPECT_EQ(-1, *result); | |
| 2974 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 2975 *result = -1; | |
| 2976 cmd.Init(client_program_id_, | |
| 2977 kInvalidSharedMemoryId, kNameOffset, | |
| 2978 kSharedMemoryId, kSharedMemoryOffset, | |
| 2979 kNameSize); | |
| 2980 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 2981 EXPECT_EQ(-1, *result); | |
| 2982 cmd.Init(client_program_id_, | |
| 2983 kSharedMemoryId, kInvalidSharedMemoryOffset, | |
| 2984 kSharedMemoryId, kSharedMemoryOffset, | |
| 2985 kNameSize); | |
| 2986 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 2987 EXPECT_EQ(-1, *result); | |
| 2988 cmd.Init(client_program_id_, | |
| 2989 kSharedMemoryId, kNameOffset, | |
| 2990 kInvalidSharedMemoryId, kSharedMemoryOffset, | |
| 2991 kNameSize); | |
| 2992 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 2993 EXPECT_EQ(-1, *result); | |
| 2994 cmd.Init(client_program_id_, | |
| 2995 kSharedMemoryId, kNameOffset, | |
| 2996 kSharedMemoryId, kInvalidSharedMemoryOffset, | |
| 2997 kNameSize); | |
| 2998 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 2999 EXPECT_EQ(-1, *result); | |
| 3000 cmd.Init(client_program_id_, | |
| 3001 kSharedMemoryId, kNameOffset, | |
| 3002 kSharedMemoryId, kSharedMemoryOffset, | |
| 3003 kSharedBufferSize); | |
| 3004 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 3005 EXPECT_EQ(-1, *result); | |
| 3006 memcpy(name, kBadName, kBadNameSize); | |
| 3007 cmd.Init(client_program_id_, | |
| 3008 kSharedMemoryId, kNameOffset, | |
| 3009 kSharedMemoryId, kSharedMemoryOffset, | |
| 3010 kBadNameSize); | |
| 3011 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3012 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 3013 } | |
| 3014 | |
| 3015 TEST_F(GLES2DecoderWithShaderTest, GetUniformLocationBucket) { | |
| 3016 const uint32 kBucketId = 123; | |
| 3017 const char* kNonExistentName = "foobar"; | |
| 3018 typedef GetUniformLocationBucket::Result Result; | |
| 3019 Result* result = GetSharedMemoryAs<Result*>(); | |
| 3020 SetBucketAsCString(kBucketId, kUniform2Name); | |
| 3021 *result = -1; | |
| 3022 GetUniformLocationBucket cmd; | |
| 3023 cmd.Init(client_program_id_, kBucketId, | |
| 3024 kSharedMemoryId, kSharedMemoryOffset); | |
| 3025 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3026 EXPECT_EQ(kUniform2FakeLocation, *result); | |
| 3027 SetBucketAsCString(kBucketId, kNonExistentName); | |
| 3028 *result = -1; | |
| 3029 cmd.Init(client_program_id_, kBucketId, | |
| 3030 kSharedMemoryId, kSharedMemoryOffset); | |
| 3031 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3032 EXPECT_EQ(-1, *result); | |
| 3033 } | |
| 3034 | |
| 3035 TEST_F(GLES2DecoderWithShaderTest, GetUniformLocationBucketInvalidArgs) { | |
| 3036 const uint32 kBucketId = 123; | |
| 3037 typedef GetUniformLocationBucket::Result Result; | |
| 3038 Result* result = GetSharedMemoryAs<Result*>(); | |
| 3039 *result = -1; | |
| 3040 GetUniformLocationBucket cmd; | |
| 3041 // Check no bucket | |
| 3042 cmd.Init(client_program_id_, kBucketId, | |
| 3043 kSharedMemoryId, kSharedMemoryOffset); | |
| 3044 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 3045 EXPECT_EQ(-1, *result); | |
| 3046 // Check bad program id. | |
| 3047 SetBucketAsCString(kBucketId, kUniform2Name); | |
| 3048 cmd.Init(kInvalidClientId, kBucketId, | |
| 3049 kSharedMemoryId, kSharedMemoryOffset); | |
| 3050 *result = -1; | |
| 3051 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3052 EXPECT_EQ(-1, *result); | |
| 3053 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 3054 // Check bad memory | |
| 3055 cmd.Init(client_program_id_, kBucketId, | |
| 3056 kInvalidSharedMemoryId, kSharedMemoryOffset); | |
| 3057 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 3058 cmd.Init(client_program_id_, kBucketId, | |
| 3059 kSharedMemoryId, kInvalidSharedMemoryOffset); | |
| 3060 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 3061 } | |
| 3062 | |
| 3063 TEST_F(GLES2DecoderWithShaderTest, GetMaxValueInBufferCHROMIUM) { | 111 TEST_F(GLES2DecoderWithShaderTest, GetMaxValueInBufferCHROMIUM) { |
| 3064 SetupIndexBuffer(); | 112 SetupIndexBuffer(); |
| 3065 GetMaxValueInBufferCHROMIUM::Result* result = | 113 GetMaxValueInBufferCHROMIUM::Result* result = |
| 3066 static_cast<GetMaxValueInBufferCHROMIUM::Result*>(shared_memory_address_); | 114 static_cast<GetMaxValueInBufferCHROMIUM::Result*>(shared_memory_address_); |
| 3067 *result = 0; | 115 *result = 0; |
| 3068 | 116 |
| 3069 GetMaxValueInBufferCHROMIUM cmd; | 117 GetMaxValueInBufferCHROMIUM cmd; |
| 3070 cmd.Init(client_element_buffer_id_, kValidIndexRangeCount, GL_UNSIGNED_SHORT, | 118 cmd.Init(client_element_buffer_id_, |
| 3071 kValidIndexRangeStart * 2, kSharedMemoryId, kSharedMemoryOffset); | 119 kValidIndexRangeCount, |
| 3072 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3073 EXPECT_EQ(7u, *result); | |
| 3074 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 3075 cmd.Init(client_element_buffer_id_, kValidIndexRangeCount + 1, | |
| 3076 GL_UNSIGNED_SHORT, | |
| 3077 kValidIndexRangeStart * 2, kSharedMemoryId, kSharedMemoryOffset); | |
| 3078 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3079 EXPECT_EQ(100u, *result); | |
| 3080 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 3081 | |
| 3082 cmd.Init(kInvalidClientId, kValidIndexRangeCount, | |
| 3083 GL_UNSIGNED_SHORT, | |
| 3084 kValidIndexRangeStart * 2, kSharedMemoryId, kSharedMemoryOffset); | |
| 3085 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3086 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 3087 cmd.Init(client_element_buffer_id_, kOutOfRangeIndexRangeEnd, | |
| 3088 GL_UNSIGNED_SHORT, | |
| 3089 kValidIndexRangeStart * 2, kSharedMemoryId, kSharedMemoryOffset); | |
| 3090 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3091 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 3092 cmd.Init(client_element_buffer_id_, kValidIndexRangeCount + 1, | |
| 3093 GL_UNSIGNED_SHORT, | |
| 3094 kOutOfRangeIndexRangeEnd * 2, kSharedMemoryId, kSharedMemoryOffset); | |
| 3095 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3096 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 3097 cmd.Init(client_element_buffer_id_, kValidIndexRangeCount + 1, | |
| 3098 GL_UNSIGNED_SHORT, | |
| 3099 kValidIndexRangeStart * 2, kSharedMemoryId, kSharedMemoryOffset); | |
| 3100 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3101 cmd.Init(client_buffer_id_, kValidIndexRangeCount + 1, | |
| 3102 GL_UNSIGNED_SHORT, | |
| 3103 kValidIndexRangeStart * 2, kSharedMemoryId, kSharedMemoryOffset); | |
| 3104 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3105 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 3106 cmd.Init(client_element_buffer_id_, kValidIndexRangeCount + 1, | |
| 3107 GL_UNSIGNED_SHORT, | 120 GL_UNSIGNED_SHORT, |
| 3108 kValidIndexRangeStart * 2, | 121 kValidIndexRangeStart * 2, |
| 3109 kInvalidSharedMemoryId, kSharedMemoryOffset); | 122 kSharedMemoryId, |
| 3110 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | 123 kSharedMemoryOffset); |
| 3111 cmd.Init(client_element_buffer_id_, kValidIndexRangeCount + 1, | 124 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 125 EXPECT_EQ(7u, *result); |
| 126 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 127 cmd.Init(client_element_buffer_id_, |
| 128 kValidIndexRangeCount + 1, |
| 3112 GL_UNSIGNED_SHORT, | 129 GL_UNSIGNED_SHORT, |
| 3113 kValidIndexRangeStart * 2, | 130 kValidIndexRangeStart * 2, |
| 3114 kSharedMemoryId, kInvalidSharedMemoryOffset); | 131 kSharedMemoryId, |
| 132 kSharedMemoryOffset); |
| 133 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 134 EXPECT_EQ(100u, *result); |
| 135 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 136 |
| 137 cmd.Init(kInvalidClientId, |
| 138 kValidIndexRangeCount, |
| 139 GL_UNSIGNED_SHORT, |
| 140 kValidIndexRangeStart * 2, |
| 141 kSharedMemoryId, |
| 142 kSharedMemoryOffset); |
| 143 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 144 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 145 cmd.Init(client_element_buffer_id_, |
| 146 kOutOfRangeIndexRangeEnd, |
| 147 GL_UNSIGNED_SHORT, |
| 148 kValidIndexRangeStart * 2, |
| 149 kSharedMemoryId, |
| 150 kSharedMemoryOffset); |
| 151 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 152 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 153 cmd.Init(client_element_buffer_id_, |
| 154 kValidIndexRangeCount + 1, |
| 155 GL_UNSIGNED_SHORT, |
| 156 kOutOfRangeIndexRangeEnd * 2, |
| 157 kSharedMemoryId, |
| 158 kSharedMemoryOffset); |
| 159 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 160 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 161 cmd.Init(client_element_buffer_id_, |
| 162 kValidIndexRangeCount + 1, |
| 163 GL_UNSIGNED_SHORT, |
| 164 kValidIndexRangeStart * 2, |
| 165 kSharedMemoryId, |
| 166 kSharedMemoryOffset); |
| 167 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 168 cmd.Init(client_buffer_id_, |
| 169 kValidIndexRangeCount + 1, |
| 170 GL_UNSIGNED_SHORT, |
| 171 kValidIndexRangeStart * 2, |
| 172 kSharedMemoryId, |
| 173 kSharedMemoryOffset); |
| 174 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 175 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 176 cmd.Init(client_element_buffer_id_, |
| 177 kValidIndexRangeCount + 1, |
| 178 GL_UNSIGNED_SHORT, |
| 179 kValidIndexRangeStart * 2, |
| 180 kInvalidSharedMemoryId, |
| 181 kSharedMemoryOffset); |
| 182 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
| 183 cmd.Init(client_element_buffer_id_, |
| 184 kValidIndexRangeCount + 1, |
| 185 GL_UNSIGNED_SHORT, |
| 186 kValidIndexRangeStart * 2, |
| 187 kSharedMemoryId, |
| 188 kInvalidSharedMemoryOffset); |
| 3115 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | 189 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
| 3116 } | 190 } |
| 3117 | 191 |
| 3118 TEST_F(GLES2DecoderTest, SharedIds) { | 192 TEST_F(GLES2DecoderTest, SharedIds) { |
| 3119 GenSharedIdsCHROMIUM gen_cmd; | 193 GenSharedIdsCHROMIUM gen_cmd; |
| 3120 RegisterSharedIdsCHROMIUM reg_cmd; | 194 RegisterSharedIdsCHROMIUM reg_cmd; |
| 3121 DeleteSharedIdsCHROMIUM del_cmd; | 195 DeleteSharedIdsCHROMIUM del_cmd; |
| 3122 | 196 |
| 3123 const GLuint kNamespaceId = id_namespaces::kTextures; | 197 const GLuint kNamespaceId = id_namespaces::kTextures; |
| 3124 const GLuint kExpectedId1 = 1; | 198 const GLuint kExpectedId1 = 1; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3225 const GLuint kNamespaceId = id_namespaces::kTextures; | 299 const GLuint kNamespaceId = id_namespaces::kTextures; |
| 3226 DeleteSharedIdsCHROMIUM cmd; | 300 DeleteSharedIdsCHROMIUM cmd; |
| 3227 cmd.Init(kNamespaceId, -1, kSharedMemoryId, kSharedMemoryOffset); | 301 cmd.Init(kNamespaceId, -1, kSharedMemoryId, kSharedMemoryOffset); |
| 3228 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | 302 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
| 3229 cmd.Init(kNamespaceId, 1, kInvalidSharedMemoryId, kSharedMemoryOffset); | 303 cmd.Init(kNamespaceId, 1, kInvalidSharedMemoryId, kSharedMemoryOffset); |
| 3230 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | 304 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
| 3231 cmd.Init(kNamespaceId, 1, kSharedMemoryId, kInvalidSharedMemoryOffset); | 305 cmd.Init(kNamespaceId, 1, kSharedMemoryId, kInvalidSharedMemoryOffset); |
| 3232 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | 306 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
| 3233 } | 307 } |
| 3234 | 308 |
| 3235 TEST_F(GLES2DecoderTest, TexSubImage2DValidArgs) { | |
| 3236 const int kWidth = 16; | |
| 3237 const int kHeight = 8; | |
| 3238 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 3239 DoTexImage2D( | |
| 3240 GL_TEXTURE_2D, 1, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 3241 kSharedMemoryId, kSharedMemoryOffset); | |
| 3242 EXPECT_CALL(*gl_, TexSubImage2D( | |
| 3243 GL_TEXTURE_2D, 1, 1, 0, kWidth - 1, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 3244 shared_memory_address_)) | |
| 3245 .Times(1) | |
| 3246 .RetiresOnSaturation(); | |
| 3247 TexSubImage2D cmd; | |
| 3248 cmd.Init( | |
| 3249 GL_TEXTURE_2D, 1, 1, 0, kWidth - 1, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 3250 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); | |
| 3251 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3252 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 3253 } | |
| 3254 | |
| 3255 TEST_F(GLES2DecoderTest, TexSubImage2DBadArgs) { | |
| 3256 const int kWidth = 16; | |
| 3257 const int kHeight = 8; | |
| 3258 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 3259 DoTexImage2D( | |
| 3260 GL_TEXTURE_2D, 1, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 3261 0, 0); | |
| 3262 TexSubImage2D cmd; | |
| 3263 cmd.Init(GL_TEXTURE0, 1, 0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 3264 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); | |
| 3265 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3266 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | |
| 3267 cmd.Init(GL_TEXTURE_2D, 1, 0, 0, kWidth, kHeight, GL_TRUE, GL_UNSIGNED_BYTE, | |
| 3268 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); | |
| 3269 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3270 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | |
| 3271 cmd.Init(GL_TEXTURE_2D, 1, 0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_INT, | |
| 3272 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); | |
| 3273 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3274 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | |
| 3275 cmd.Init(GL_TEXTURE_2D, 1, -1, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 3276 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); | |
| 3277 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3278 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 3279 cmd.Init(GL_TEXTURE_2D, 1, 1, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 3280 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); | |
| 3281 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3282 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 3283 cmd.Init(GL_TEXTURE_2D, 1, 0, -1, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 3284 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); | |
| 3285 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3286 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 3287 cmd.Init(GL_TEXTURE_2D, 1, 0, 1, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 3288 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); | |
| 3289 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3290 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 3291 cmd.Init(GL_TEXTURE_2D, 1, 0, 0, kWidth + 1, kHeight, GL_RGBA, | |
| 3292 GL_UNSIGNED_BYTE, kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); | |
| 3293 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3294 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 3295 cmd.Init(GL_TEXTURE_2D, 1, 0, 0, kWidth, kHeight + 1, GL_RGBA, | |
| 3296 GL_UNSIGNED_BYTE, kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); | |
| 3297 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3298 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 3299 cmd.Init(GL_TEXTURE_2D, 1, 0, 0, kWidth, kHeight, GL_RGB, GL_UNSIGNED_BYTE, | |
| 3300 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); | |
| 3301 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3302 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 3303 cmd.Init(GL_TEXTURE_2D, 1, 0, 0, kWidth, kHeight, GL_RGBA, | |
| 3304 GL_UNSIGNED_SHORT_4_4_4_4, kSharedMemoryId, kSharedMemoryOffset, | |
| 3305 GL_FALSE); | |
| 3306 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3307 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 3308 cmd.Init(GL_TEXTURE_2D, 1, 0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 3309 kInvalidSharedMemoryId, kSharedMemoryOffset, GL_FALSE); | |
| 3310 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 3311 cmd.Init(GL_TEXTURE_2D, 1, 0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 3312 kSharedMemoryId, kInvalidSharedMemoryOffset, GL_FALSE); | |
| 3313 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 3314 } | |
| 3315 | |
| 3316 TEST_F(GLES2DecoderTest, CopyTexSubImage2DValidArgs) { | |
| 3317 const int kWidth = 16; | |
| 3318 const int kHeight = 8; | |
| 3319 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 3320 DoTexImage2D( | |
| 3321 GL_TEXTURE_2D, 1, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 3322 kSharedMemoryId, kSharedMemoryOffset); | |
| 3323 EXPECT_CALL(*gl_, CopyTexSubImage2D( | |
| 3324 GL_TEXTURE_2D, 1, 0, 0, 0, 0, kWidth, kHeight)) | |
| 3325 .Times(1) | |
| 3326 .RetiresOnSaturation(); | |
| 3327 CopyTexSubImage2D cmd; | |
| 3328 cmd.Init(GL_TEXTURE_2D, 1, 0, 0, 0, 0, kWidth, kHeight); | |
| 3329 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3330 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 3331 } | |
| 3332 | |
| 3333 TEST_F(GLES2DecoderTest, CopyTexSubImage2DBadArgs) { | |
| 3334 const int kWidth = 16; | |
| 3335 const int kHeight = 8; | |
| 3336 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 3337 DoTexImage2D( | |
| 3338 GL_TEXTURE_2D, 1, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 3339 0, 0); | |
| 3340 CopyTexSubImage2D cmd; | |
| 3341 cmd.Init(GL_TEXTURE0, 1, 0, 0, 0, 0, kWidth, kHeight); | |
| 3342 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3343 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | |
| 3344 cmd.Init(GL_TEXTURE_2D, 1, -1, 0, 0, 0, kWidth, kHeight); | |
| 3345 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3346 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 3347 cmd.Init(GL_TEXTURE_2D, 1, 1, 0, 0, 0, kWidth, kHeight); | |
| 3348 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3349 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 3350 cmd.Init(GL_TEXTURE_2D, 1, 0, -1, 0, 0, kWidth, kHeight); | |
| 3351 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3352 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 3353 cmd.Init(GL_TEXTURE_2D, 1, 0, 1, 0, 0, kWidth, kHeight); | |
| 3354 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3355 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 3356 cmd.Init(GL_TEXTURE_2D, 1, 0, 0, 0, 0, kWidth + 1, kHeight); | |
| 3357 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3358 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 3359 cmd.Init(GL_TEXTURE_2D, 1, 0, 0, 0, 0, kWidth, kHeight + 1); | |
| 3360 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3361 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 3362 } | |
| 3363 | |
| 3364 // Check that if a renderbuffer is attached and GL returns | |
| 3365 // GL_FRAMEBUFFER_COMPLETE that the buffer is cleared and state is restored. | |
| 3366 TEST_F(GLES2DecoderTest, FramebufferRenderbufferClearColor) { | |
| 3367 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, | |
| 3368 kServiceFramebufferId); | |
| 3369 ClearColor color_cmd; | |
| 3370 ColorMask color_mask_cmd; | |
| 3371 Enable enable_cmd; | |
| 3372 FramebufferRenderbuffer cmd; | |
| 3373 color_cmd.Init(0.1f, 0.2f, 0.3f, 0.4f); | |
| 3374 color_mask_cmd.Init(0, 1, 0, 1); | |
| 3375 enable_cmd.Init(GL_SCISSOR_TEST); | |
| 3376 cmd.Init( | |
| 3377 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, | |
| 3378 client_renderbuffer_id_); | |
| 3379 InSequence sequence; | |
| 3380 EXPECT_CALL(*gl_, ClearColor(0.1f, 0.2f, 0.3f, 0.4f)) | |
| 3381 .Times(1) | |
| 3382 .RetiresOnSaturation(); | |
| 3383 EXPECT_CALL(*gl_, GetError()) | |
| 3384 .WillOnce(Return(GL_NO_ERROR)) | |
| 3385 .RetiresOnSaturation(); | |
| 3386 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT( | |
| 3387 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, | |
| 3388 kServiceRenderbufferId)) | |
| 3389 .Times(1) | |
| 3390 .RetiresOnSaturation(); | |
| 3391 EXPECT_CALL(*gl_, GetError()) | |
| 3392 .WillOnce(Return(GL_NO_ERROR)) | |
| 3393 .RetiresOnSaturation(); | |
| 3394 EXPECT_EQ(error::kNoError, ExecuteCmd(color_cmd)); | |
| 3395 EXPECT_EQ(error::kNoError, ExecuteCmd(color_mask_cmd)); | |
| 3396 EXPECT_EQ(error::kNoError, ExecuteCmd(enable_cmd)); | |
| 3397 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3398 } | |
| 3399 | |
| 3400 TEST_F(GLES2DecoderTest, FramebufferRenderbufferClearDepth) { | |
| 3401 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, | |
| 3402 kServiceFramebufferId); | |
| 3403 ClearDepthf depth_cmd; | |
| 3404 DepthMask depth_mask_cmd; | |
| 3405 FramebufferRenderbuffer cmd; | |
| 3406 depth_cmd.Init(0.5f); | |
| 3407 depth_mask_cmd.Init(false); | |
| 3408 cmd.Init( | |
| 3409 GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, | |
| 3410 client_renderbuffer_id_); | |
| 3411 InSequence sequence; | |
| 3412 EXPECT_CALL(*gl_, ClearDepth(0.5f)) | |
| 3413 .Times(1) | |
| 3414 .RetiresOnSaturation(); | |
| 3415 EXPECT_CALL(*gl_, GetError()) | |
| 3416 .WillOnce(Return(GL_NO_ERROR)) | |
| 3417 .RetiresOnSaturation(); | |
| 3418 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT( | |
| 3419 GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, | |
| 3420 kServiceRenderbufferId)) | |
| 3421 .Times(1) | |
| 3422 .RetiresOnSaturation(); | |
| 3423 EXPECT_CALL(*gl_, GetError()) | |
| 3424 .WillOnce(Return(GL_NO_ERROR)) | |
| 3425 .RetiresOnSaturation(); | |
| 3426 EXPECT_EQ(error::kNoError, ExecuteCmd(depth_cmd)); | |
| 3427 EXPECT_EQ(error::kNoError, ExecuteCmd(depth_mask_cmd)); | |
| 3428 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3429 } | |
| 3430 | |
| 3431 TEST_F(GLES2DecoderTest, FramebufferRenderbufferClearStencil) { | |
| 3432 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, | |
| 3433 kServiceFramebufferId); | |
| 3434 ClearStencil stencil_cmd; | |
| 3435 StencilMaskSeparate stencil_mask_separate_cmd; | |
| 3436 FramebufferRenderbuffer cmd; | |
| 3437 stencil_cmd.Init(123); | |
| 3438 stencil_mask_separate_cmd.Init(GL_BACK, 0x1234u); | |
| 3439 cmd.Init( | |
| 3440 GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, | |
| 3441 client_renderbuffer_id_); | |
| 3442 InSequence sequence; | |
| 3443 EXPECT_CALL(*gl_, ClearStencil(123)) | |
| 3444 .Times(1) | |
| 3445 .RetiresOnSaturation(); | |
| 3446 EXPECT_CALL(*gl_, GetError()) | |
| 3447 .WillOnce(Return(GL_NO_ERROR)) | |
| 3448 .RetiresOnSaturation(); | |
| 3449 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT( | |
| 3450 GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, | |
| 3451 kServiceRenderbufferId)) | |
| 3452 .Times(1) | |
| 3453 .RetiresOnSaturation(); | |
| 3454 EXPECT_CALL(*gl_, GetError()) | |
| 3455 .WillOnce(Return(GL_NO_ERROR)) | |
| 3456 .RetiresOnSaturation(); | |
| 3457 EXPECT_EQ(error::kNoError, ExecuteCmd(stencil_cmd)); | |
| 3458 EXPECT_EQ(error::kNoError, ExecuteCmd(stencil_mask_separate_cmd)); | |
| 3459 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3460 } | |
| 3461 | |
| 3462 TEST_F(GLES2DecoderTest, IsBuffer) { | 309 TEST_F(GLES2DecoderTest, IsBuffer) { |
| 3463 EXPECT_FALSE(DoIsBuffer(client_buffer_id_)); | 310 EXPECT_FALSE(DoIsBuffer(client_buffer_id_)); |
| 3464 DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId); | 311 DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId); |
| 3465 EXPECT_TRUE(DoIsBuffer(client_buffer_id_)); | 312 EXPECT_TRUE(DoIsBuffer(client_buffer_id_)); |
| 3466 DoDeleteBuffer(client_buffer_id_, kServiceBufferId); | 313 DoDeleteBuffer(client_buffer_id_, kServiceBufferId); |
| 3467 EXPECT_FALSE(DoIsBuffer(client_buffer_id_)); | 314 EXPECT_FALSE(DoIsBuffer(client_buffer_id_)); |
| 3468 } | 315 } |
| 3469 | 316 |
| 3470 TEST_F(GLES2DecoderTest, IsFramebuffer) { | 317 TEST_F(GLES2DecoderTest, IsFramebuffer) { |
| 3471 EXPECT_FALSE(DoIsFramebuffer(client_framebuffer_id_)); | 318 EXPECT_FALSE(DoIsFramebuffer(client_framebuffer_id_)); |
| 3472 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, | 319 DoBindFramebuffer( |
| 3473 kServiceFramebufferId); | 320 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
| 3474 EXPECT_TRUE(DoIsFramebuffer(client_framebuffer_id_)); | 321 EXPECT_TRUE(DoIsFramebuffer(client_framebuffer_id_)); |
| 3475 DoDeleteFramebuffer( | 322 DoDeleteFramebuffer(client_framebuffer_id_, |
| 3476 client_framebuffer_id_, kServiceFramebufferId, | 323 kServiceFramebufferId, |
| 3477 true, GL_FRAMEBUFFER, 0, | 324 true, |
| 3478 true, GL_FRAMEBUFFER, 0); | 325 GL_FRAMEBUFFER, |
| 326 0, |
| 327 true, |
| 328 GL_FRAMEBUFFER, |
| 329 0); |
| 3479 EXPECT_FALSE(DoIsFramebuffer(client_framebuffer_id_)); | 330 EXPECT_FALSE(DoIsFramebuffer(client_framebuffer_id_)); |
| 3480 } | 331 } |
| 3481 | 332 |
| 3482 TEST_F(GLES2DecoderTest, IsProgram) { | 333 TEST_F(GLES2DecoderTest, IsProgram) { |
| 3483 // IsProgram is true as soon as the program is created. | 334 // IsProgram is true as soon as the program is created. |
| 3484 EXPECT_TRUE(DoIsProgram(client_program_id_)); | 335 EXPECT_TRUE(DoIsProgram(client_program_id_)); |
| 3485 EXPECT_CALL(*gl_, DeleteProgram(kServiceProgramId)) | 336 EXPECT_CALL(*gl_, DeleteProgram(kServiceProgramId)) |
| 3486 .Times(1) | 337 .Times(1) |
| 3487 .RetiresOnSaturation(); | 338 .RetiresOnSaturation(); |
| 3488 DoDeleteProgram(client_program_id_, kServiceProgramId); | 339 DoDeleteProgram(client_program_id_, kServiceProgramId); |
| 3489 EXPECT_FALSE(DoIsProgram(client_program_id_)); | 340 EXPECT_FALSE(DoIsProgram(client_program_id_)); |
| 3490 | |
| 3491 } | 341 } |
| 3492 | 342 |
| 3493 TEST_F(GLES2DecoderTest, IsRenderbuffer) { | 343 TEST_F(GLES2DecoderTest, IsRenderbuffer) { |
| 3494 EXPECT_FALSE(DoIsRenderbuffer(client_renderbuffer_id_)); | 344 EXPECT_FALSE(DoIsRenderbuffer(client_renderbuffer_id_)); |
| 3495 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_, | 345 DoBindRenderbuffer( |
| 3496 kServiceRenderbufferId); | 346 GL_RENDERBUFFER, client_renderbuffer_id_, kServiceRenderbufferId); |
| 3497 EXPECT_TRUE(DoIsRenderbuffer(client_renderbuffer_id_)); | 347 EXPECT_TRUE(DoIsRenderbuffer(client_renderbuffer_id_)); |
| 3498 DoDeleteRenderbuffer(client_renderbuffer_id_, kServiceRenderbufferId); | 348 DoDeleteRenderbuffer(client_renderbuffer_id_, kServiceRenderbufferId); |
| 3499 EXPECT_FALSE(DoIsRenderbuffer(client_renderbuffer_id_)); | 349 EXPECT_FALSE(DoIsRenderbuffer(client_renderbuffer_id_)); |
| 3500 } | 350 } |
| 3501 | 351 |
| 3502 TEST_F(GLES2DecoderTest, IsShader) { | 352 TEST_F(GLES2DecoderTest, IsShader) { |
| 3503 // IsShader is true as soon as the program is created. | 353 // IsShader is true as soon as the program is created. |
| 3504 EXPECT_TRUE(DoIsShader(client_shader_id_)); | 354 EXPECT_TRUE(DoIsShader(client_shader_id_)); |
| 3505 DoDeleteShader(client_shader_id_, kServiceShaderId); | 355 DoDeleteShader(client_shader_id_, kServiceShaderId); |
| 3506 EXPECT_FALSE(DoIsShader(client_shader_id_)); | 356 EXPECT_FALSE(DoIsShader(client_shader_id_)); |
| 3507 } | 357 } |
| 3508 | 358 |
| 3509 TEST_F(GLES2DecoderTest, IsTexture) { | 359 TEST_F(GLES2DecoderTest, IsTexture) { |
| 3510 EXPECT_FALSE(DoIsTexture(client_texture_id_)); | 360 EXPECT_FALSE(DoIsTexture(client_texture_id_)); |
| 3511 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 361 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 3512 EXPECT_TRUE(DoIsTexture(client_texture_id_)); | 362 EXPECT_TRUE(DoIsTexture(client_texture_id_)); |
| 3513 DoDeleteTexture(client_texture_id_, kServiceTextureId); | 363 DoDeleteTexture(client_texture_id_, kServiceTextureId); |
| 3514 EXPECT_FALSE(DoIsTexture(client_texture_id_)); | 364 EXPECT_FALSE(DoIsTexture(client_texture_id_)); |
| 3515 } | 365 } |
| 3516 | 366 |
| 3517 #if 0 // Turn this test on once we allow GL_DEPTH_STENCIL_ATTACHMENT | |
| 3518 TEST_F(GLES2DecoderTest, FramebufferRenderbufferClearDepthStencil) { | |
| 3519 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, | |
| 3520 kServiceFramebufferId); | |
| 3521 ClearDepthf depth_cmd; | |
| 3522 ClearStencil stencil_cmd; | |
| 3523 FramebufferRenderbuffer cmd; | |
| 3524 depth_cmd.Init(0.5f); | |
| 3525 stencil_cmd.Init(123); | |
| 3526 cmd.Init( | |
| 3527 GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, | |
| 3528 client_renderbuffer_id_); | |
| 3529 InSequence sequence; | |
| 3530 EXPECT_CALL(*gl_, ClearDepth(0.5f)) | |
| 3531 .Times(1) | |
| 3532 .RetiresOnSaturation(); | |
| 3533 EXPECT_CALL(*gl_, ClearStencil(123)) | |
| 3534 .Times(1) | |
| 3535 .RetiresOnSaturation(); | |
| 3536 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT( | |
| 3537 GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, | |
| 3538 kServiceRenderbufferId)) | |
| 3539 .Times(1) | |
| 3540 .RetiresOnSaturation(); | |
| 3541 EXPECT_EQ(error::kNoError, ExecuteCmd(depth_cmd)); | |
| 3542 EXPECT_EQ(error::kNoError, ExecuteCmd(stencil_cmd)); | |
| 3543 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3544 } | |
| 3545 #endif | |
| 3546 | |
| 3547 TEST_F(GLES2DecoderWithShaderTest, VertexAttribPointer) { | |
| 3548 SetupVertexBuffer(); | |
| 3549 static const GLenum types[] = { | |
| 3550 GL_BYTE, | |
| 3551 GL_UNSIGNED_BYTE, | |
| 3552 GL_SHORT, | |
| 3553 GL_UNSIGNED_SHORT, | |
| 3554 GL_FLOAT, | |
| 3555 GL_FIXED, | |
| 3556 GL_INT, | |
| 3557 GL_UNSIGNED_INT, | |
| 3558 }; | |
| 3559 static const GLsizei sizes[] = { | |
| 3560 1, | |
| 3561 1, | |
| 3562 2, | |
| 3563 2, | |
| 3564 4, | |
| 3565 4, | |
| 3566 4, | |
| 3567 4, | |
| 3568 }; | |
| 3569 static const GLuint indices[] = { | |
| 3570 0, | |
| 3571 1, | |
| 3572 kNumVertexAttribs - 1, | |
| 3573 kNumVertexAttribs, | |
| 3574 }; | |
| 3575 static const GLsizei offset_mult[] = { | |
| 3576 0, | |
| 3577 0, | |
| 3578 1, | |
| 3579 1, | |
| 3580 2, | |
| 3581 1000, | |
| 3582 }; | |
| 3583 static const GLsizei offset_offset[] = { | |
| 3584 0, | |
| 3585 1, | |
| 3586 0, | |
| 3587 1, | |
| 3588 0, | |
| 3589 0, | |
| 3590 }; | |
| 3591 static const GLsizei stride_mult[] = { | |
| 3592 -1, | |
| 3593 0, | |
| 3594 0, | |
| 3595 1, | |
| 3596 1, | |
| 3597 2, | |
| 3598 1000, | |
| 3599 }; | |
| 3600 static const GLsizei stride_offset[] = { | |
| 3601 0, | |
| 3602 0, | |
| 3603 1, | |
| 3604 0, | |
| 3605 1, | |
| 3606 0, | |
| 3607 0, | |
| 3608 }; | |
| 3609 for (size_t tt = 0; tt < arraysize(types); ++tt) { | |
| 3610 GLenum type = types[tt]; | |
| 3611 GLsizei num_bytes = sizes[tt]; | |
| 3612 for (size_t ii = 0; ii < arraysize(indices); ++ii) { | |
| 3613 GLuint index = indices[ii]; | |
| 3614 for (GLint size = 0; size < 5; ++size) { | |
| 3615 for (size_t oo = 0; oo < arraysize(offset_mult); ++oo) { | |
| 3616 GLuint offset = num_bytes * offset_mult[oo] + offset_offset[oo]; | |
| 3617 for (size_t ss = 0; ss < arraysize(stride_mult); ++ss) { | |
| 3618 GLsizei stride = num_bytes * stride_mult[ss] + stride_offset[ss]; | |
| 3619 for (int normalize = 0; normalize < 2; ++normalize) { | |
| 3620 bool index_good = index < static_cast<GLuint>(kNumVertexAttribs); | |
| 3621 bool size_good = (size > 0 && size < 5); | |
| 3622 bool offset_good = (offset % num_bytes == 0); | |
| 3623 bool stride_good = (stride % num_bytes == 0) && stride >= 0 && | |
| 3624 stride <= 255; | |
| 3625 bool type_good = (type != GL_INT && type != GL_UNSIGNED_INT && | |
| 3626 type != GL_FIXED); | |
| 3627 bool good = size_good && offset_good && stride_good && | |
| 3628 type_good && index_good; | |
| 3629 bool call = good && (type != GL_FIXED); | |
| 3630 if (call) { | |
| 3631 EXPECT_CALL(*gl_, VertexAttribPointer( | |
| 3632 index, size, type, normalize, stride, | |
| 3633 BufferOffset(offset))); | |
| 3634 } | |
| 3635 VertexAttribPointer cmd; | |
| 3636 cmd.Init(index, size, type, normalize, stride, offset); | |
| 3637 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3638 if (good) { | |
| 3639 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 3640 } else if (size_good && | |
| 3641 offset_good && | |
| 3642 stride_good && | |
| 3643 type_good && | |
| 3644 !index_good) { | |
| 3645 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 3646 } else if (size_good && | |
| 3647 offset_good && | |
| 3648 stride_good && | |
| 3649 !type_good && | |
| 3650 index_good) { | |
| 3651 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | |
| 3652 } else if (size_good && | |
| 3653 offset_good && | |
| 3654 !stride_good && | |
| 3655 type_good && | |
| 3656 index_good) { | |
| 3657 if (stride < 0 || stride > 255) { | |
| 3658 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 3659 } else { | |
| 3660 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 3661 } | |
| 3662 } else if (size_good && | |
| 3663 !offset_good && | |
| 3664 stride_good && | |
| 3665 type_good && | |
| 3666 index_good) { | |
| 3667 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 3668 } else if (!size_good && | |
| 3669 offset_good && | |
| 3670 stride_good && | |
| 3671 type_good && | |
| 3672 index_good) { | |
| 3673 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 3674 } else { | |
| 3675 EXPECT_NE(GL_NO_ERROR, GetGLError()); | |
| 3676 } | |
| 3677 } | |
| 3678 } | |
| 3679 } | |
| 3680 } | |
| 3681 } | |
| 3682 } | |
| 3683 } | |
| 3684 | |
| 3685 // Test that with an RGB backbuffer if we set the color mask to 1,1,1,1 it is | |
| 3686 // set to 1,1,1,0 at Draw time but is 1,1,1,1 at query time. | |
| 3687 TEST_F(GLES2DecoderRGBBackbufferTest, RGBBackbufferColorMask) { | |
| 3688 ColorMask cmd; | |
| 3689 cmd.Init(true, true, true, true); | |
| 3690 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3691 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 3692 | |
| 3693 SetupTexture(); | |
| 3694 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); | |
| 3695 SetupExpectationsForApplyingDirtyState( | |
| 3696 true, // Framebuffer is RGB | |
| 3697 false, // Framebuffer has depth | |
| 3698 false, // Framebuffer has stencil | |
| 3699 0x1110, // color bits | |
| 3700 false, // depth mask | |
| 3701 false, // depth enabled | |
| 3702 0, // front stencil mask | |
| 3703 0, // back stencil mask | |
| 3704 false, // stencil enabled | |
| 3705 false, // cull_face_enabled | |
| 3706 false, // scissor_test_enabled | |
| 3707 false); // blend_enabled | |
| 3708 | |
| 3709 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | |
| 3710 .Times(1) | |
| 3711 .RetiresOnSaturation(); | |
| 3712 DrawArrays draw_cmd; | |
| 3713 draw_cmd.Init(GL_TRIANGLES, 0, kNumVertices); | |
| 3714 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd)); | |
| 3715 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 3716 | |
| 3717 EXPECT_CALL(*gl_, GetError()) | |
| 3718 .WillOnce(Return(GL_NO_ERROR)) | |
| 3719 .WillOnce(Return(GL_NO_ERROR)) | |
| 3720 .RetiresOnSaturation(); | |
| 3721 typedef GetIntegerv::Result Result; | |
| 3722 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 3723 EXPECT_CALL(*gl_, GetIntegerv(GL_COLOR_WRITEMASK, result->GetData())) | |
| 3724 .Times(0); | |
| 3725 result->size = 0; | |
| 3726 GetIntegerv cmd2; | |
| 3727 cmd2.Init(GL_COLOR_WRITEMASK, shared_memory_id_, shared_memory_offset_); | |
| 3728 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 3729 EXPECT_EQ( | |
| 3730 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_COLOR_WRITEMASK), | |
| 3731 result->GetNumResults()); | |
| 3732 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 3733 EXPECT_EQ(1, result->GetData()[0]); | |
| 3734 EXPECT_EQ(1, result->GetData()[1]); | |
| 3735 EXPECT_EQ(1, result->GetData()[2]); | |
| 3736 EXPECT_EQ(1, result->GetData()[3]); | |
| 3737 } | |
| 3738 | |
| 3739 // Test that with no depth if we set DepthMask true that it's set to false at | |
| 3740 // draw time but querying it returns true. | |
| 3741 TEST_F(GLES2DecoderRGBBackbufferTest, RGBBackbufferDepthMask) { | |
| 3742 EXPECT_CALL(*gl_, DepthMask(true)) | |
| 3743 .Times(0) | |
| 3744 .RetiresOnSaturation(); | |
| 3745 DepthMask cmd; | |
| 3746 cmd.Init(true); | |
| 3747 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3748 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 3749 | |
| 3750 SetupTexture(); | |
| 3751 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); | |
| 3752 SetupExpectationsForApplyingDirtyState( | |
| 3753 true, // Framebuffer is RGB | |
| 3754 false, // Framebuffer has depth | |
| 3755 false, // Framebuffer has stencil | |
| 3756 0x1110, // color bits | |
| 3757 false, // depth mask | |
| 3758 false, // depth enabled | |
| 3759 0, // front stencil mask | |
| 3760 0, // back stencil mask | |
| 3761 false, // stencil enabled | |
| 3762 false, // cull_face_enabled | |
| 3763 false, // scissor_test_enabled | |
| 3764 false); // blend_enabled | |
| 3765 | |
| 3766 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | |
| 3767 .Times(1) | |
| 3768 .RetiresOnSaturation(); | |
| 3769 DrawArrays draw_cmd; | |
| 3770 draw_cmd.Init(GL_TRIANGLES, 0, kNumVertices); | |
| 3771 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd)); | |
| 3772 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 3773 | |
| 3774 EXPECT_CALL(*gl_, GetError()) | |
| 3775 .WillOnce(Return(GL_NO_ERROR)) | |
| 3776 .WillOnce(Return(GL_NO_ERROR)) | |
| 3777 .RetiresOnSaturation(); | |
| 3778 typedef GetIntegerv::Result Result; | |
| 3779 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 3780 EXPECT_CALL(*gl_, GetIntegerv(GL_DEPTH_WRITEMASK, result->GetData())) | |
| 3781 .Times(0); | |
| 3782 result->size = 0; | |
| 3783 GetIntegerv cmd2; | |
| 3784 cmd2.Init(GL_DEPTH_WRITEMASK, shared_memory_id_, shared_memory_offset_); | |
| 3785 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 3786 EXPECT_EQ( | |
| 3787 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_WRITEMASK), | |
| 3788 result->GetNumResults()); | |
| 3789 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 3790 EXPECT_EQ(1, result->GetData()[0]); | |
| 3791 } | |
| 3792 | |
| 3793 // Test that with no stencil if we set the stencil mask it's still set to 0 at | |
| 3794 // draw time but gets our value if we query. | |
| 3795 TEST_F(GLES2DecoderRGBBackbufferTest, RGBBackbufferStencilMask) { | |
| 3796 const GLint kMask = 123; | |
| 3797 EXPECT_CALL(*gl_, StencilMask(kMask)) | |
| 3798 .Times(0) | |
| 3799 .RetiresOnSaturation(); | |
| 3800 StencilMask cmd; | |
| 3801 cmd.Init(kMask); | |
| 3802 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3803 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 3804 | |
| 3805 SetupTexture(); | |
| 3806 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); | |
| 3807 SetupExpectationsForApplyingDirtyState( | |
| 3808 true, // Framebuffer is RGB | |
| 3809 false, // Framebuffer has depth | |
| 3810 false, // Framebuffer has stencil | |
| 3811 0x1110, // color bits | |
| 3812 false, // depth mask | |
| 3813 false, // depth enabled | |
| 3814 0, // front stencil mask | |
| 3815 0, // back stencil mask | |
| 3816 false, // stencil enabled | |
| 3817 false, // cull_face_enabled | |
| 3818 false, // scissor_test_enabled | |
| 3819 false); // blend_enabled | |
| 3820 | |
| 3821 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | |
| 3822 .Times(1) | |
| 3823 .RetiresOnSaturation(); | |
| 3824 DrawArrays draw_cmd; | |
| 3825 draw_cmd.Init(GL_TRIANGLES, 0, kNumVertices); | |
| 3826 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd)); | |
| 3827 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 3828 | |
| 3829 EXPECT_CALL(*gl_, GetError()) | |
| 3830 .WillOnce(Return(GL_NO_ERROR)) | |
| 3831 .WillOnce(Return(GL_NO_ERROR)) | |
| 3832 .RetiresOnSaturation(); | |
| 3833 typedef GetIntegerv::Result Result; | |
| 3834 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 3835 EXPECT_CALL(*gl_, GetIntegerv(GL_STENCIL_WRITEMASK, result->GetData())) | |
| 3836 .Times(0); | |
| 3837 result->size = 0; | |
| 3838 GetIntegerv cmd2; | |
| 3839 cmd2.Init(GL_STENCIL_WRITEMASK, shared_memory_id_, shared_memory_offset_); | |
| 3840 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 3841 EXPECT_EQ( | |
| 3842 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_WRITEMASK), | |
| 3843 result->GetNumResults()); | |
| 3844 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 3845 EXPECT_EQ(kMask, result->GetData()[0]); | |
| 3846 } | |
| 3847 | |
| 3848 // Test that if an FBO is bound we get the correct masks. | |
| 3849 TEST_F(GLES2DecoderRGBBackbufferTest, RGBBackbufferColorMaskFBO) { | |
| 3850 ColorMask cmd; | |
| 3851 cmd.Init(true, true, true, true); | |
| 3852 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3853 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 3854 | |
| 3855 SetupTexture(); | |
| 3856 SetupVertexBuffer(); | |
| 3857 DoEnableVertexAttribArray(0); | |
| 3858 DoVertexAttribPointer(0, 2, GL_FLOAT, 0, 0); | |
| 3859 DoEnableVertexAttribArray(1); | |
| 3860 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); | |
| 3861 DoEnableVertexAttribArray(2); | |
| 3862 DoVertexAttribPointer(2, 2, GL_FLOAT, 0, 0); | |
| 3863 SetupExpectationsForApplyingDirtyState( | |
| 3864 true, // Framebuffer is RGB | |
| 3865 false, // Framebuffer has depth | |
| 3866 false, // Framebuffer has stencil | |
| 3867 0x1110, // color bits | |
| 3868 false, // depth mask | |
| 3869 false, // depth enabled | |
| 3870 0, // front stencil mask | |
| 3871 0, // back stencil mask | |
| 3872 false, // stencil enabled | |
| 3873 false, // cull_face_enabled | |
| 3874 false, // scissor_test_enabled | |
| 3875 false); // blend_enabled | |
| 3876 | |
| 3877 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | |
| 3878 .Times(1) | |
| 3879 .RetiresOnSaturation(); | |
| 3880 DrawArrays draw_cmd; | |
| 3881 draw_cmd.Init(GL_TRIANGLES, 0, kNumVertices); | |
| 3882 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd)); | |
| 3883 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 3884 | |
| 3885 // Check that no extra calls are made on the next draw. | |
| 3886 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | |
| 3887 .Times(1) | |
| 3888 .RetiresOnSaturation(); | |
| 3889 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd)); | |
| 3890 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 3891 | |
| 3892 // Setup Frame buffer. | |
| 3893 // needs to be 1x1 or else it's not renderable. | |
| 3894 const GLsizei kWidth = 1; | |
| 3895 const GLsizei kHeight = 1; | |
| 3896 const GLenum kFormat = GL_RGB; | |
| 3897 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 3898 // Pass some data so the texture will be marked as cleared. | |
| 3899 DoTexImage2D( | |
| 3900 GL_TEXTURE_2D, 0, kFormat, kWidth, kHeight, 0, | |
| 3901 kFormat, GL_UNSIGNED_BYTE, kSharedMemoryId, kSharedMemoryOffset); | |
| 3902 DoBindFramebuffer( | |
| 3903 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); | |
| 3904 DoFramebufferTexture2D( | |
| 3905 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, | |
| 3906 client_texture_id_, kServiceTextureId, 0, GL_NO_ERROR); | |
| 3907 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) | |
| 3908 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) | |
| 3909 .RetiresOnSaturation(); | |
| 3910 | |
| 3911 // This time state needs to be set. | |
| 3912 SetupExpectationsForApplyingDirtyState( | |
| 3913 false, // Framebuffer is RGB | |
| 3914 false, // Framebuffer has depth | |
| 3915 false, // Framebuffer has stencil | |
| 3916 0x1110, // color bits | |
| 3917 false, // depth mask | |
| 3918 false, // depth enabled | |
| 3919 0, // front stencil mask | |
| 3920 0, // back stencil mask | |
| 3921 false, // stencil enabled | |
| 3922 false, // cull_face_enabled | |
| 3923 false, // scissor_test_enabled | |
| 3924 false); // blend_enabled | |
| 3925 | |
| 3926 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | |
| 3927 .Times(1) | |
| 3928 .RetiresOnSaturation(); | |
| 3929 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd)); | |
| 3930 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 3931 | |
| 3932 // Check that no extra calls are made on the next draw. | |
| 3933 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | |
| 3934 .Times(1) | |
| 3935 .RetiresOnSaturation(); | |
| 3936 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd)); | |
| 3937 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 3938 | |
| 3939 // Unbind | |
| 3940 DoBindFramebuffer(GL_FRAMEBUFFER, 0, 0); | |
| 3941 | |
| 3942 SetupExpectationsForApplyingDirtyState( | |
| 3943 true, // Framebuffer is RGB | |
| 3944 false, // Framebuffer has depth | |
| 3945 false, // Framebuffer has stencil | |
| 3946 0x1110, // color bits | |
| 3947 false, // depth mask | |
| 3948 false, // depth enabled | |
| 3949 0, // front stencil mask | |
| 3950 0, // back stencil mask | |
| 3951 false, // stencil enabled | |
| 3952 false, // cull_face_enabled | |
| 3953 false, // scissor_test_enabled | |
| 3954 false); // blend_enabled | |
| 3955 | |
| 3956 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | |
| 3957 .Times(1) | |
| 3958 .RetiresOnSaturation(); | |
| 3959 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd)); | |
| 3960 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 3961 } | |
| 3962 | |
| 3963 TEST_F(GLES2DecoderManualInitTest, ActualAlphaMatchesRequestedAlpha) { | |
| 3964 InitState init; | |
| 3965 init.gl_version = "3.0"; | |
| 3966 init.has_alpha = true; | |
| 3967 init.request_alpha = true; | |
| 3968 init.bind_generates_resource = true; | |
| 3969 InitDecoder(init); | |
| 3970 | |
| 3971 EXPECT_CALL(*gl_, GetError()) | |
| 3972 .WillOnce(Return(GL_NO_ERROR)) | |
| 3973 .WillOnce(Return(GL_NO_ERROR)) | |
| 3974 .RetiresOnSaturation(); | |
| 3975 typedef GetIntegerv::Result Result; | |
| 3976 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 3977 EXPECT_CALL(*gl_, GetIntegerv(GL_ALPHA_BITS, _)) | |
| 3978 .WillOnce(SetArgumentPointee<1>(8)) | |
| 3979 .RetiresOnSaturation(); | |
| 3980 result->size = 0; | |
| 3981 GetIntegerv cmd2; | |
| 3982 cmd2.Init(GL_ALPHA_BITS, shared_memory_id_, shared_memory_offset_); | |
| 3983 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 3984 EXPECT_EQ( | |
| 3985 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_ALPHA_BITS), | |
| 3986 result->GetNumResults()); | |
| 3987 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 3988 EXPECT_EQ(8, result->GetData()[0]); | |
| 3989 } | |
| 3990 | |
| 3991 TEST_F(GLES2DecoderManualInitTest, ActualAlphaDoesNotMatchRequestedAlpha) { | |
| 3992 InitState init; | |
| 3993 init.gl_version = "3.0"; | |
| 3994 init.has_alpha = true; | |
| 3995 init.bind_generates_resource = true; | |
| 3996 InitDecoder(init); | |
| 3997 | |
| 3998 EXPECT_CALL(*gl_, GetError()) | |
| 3999 .WillOnce(Return(GL_NO_ERROR)) | |
| 4000 .WillOnce(Return(GL_NO_ERROR)) | |
| 4001 .RetiresOnSaturation(); | |
| 4002 typedef GetIntegerv::Result Result; | |
| 4003 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 4004 EXPECT_CALL(*gl_, GetIntegerv(GL_ALPHA_BITS, _)) | |
| 4005 .WillOnce(SetArgumentPointee<1>(8)) | |
| 4006 .RetiresOnSaturation(); | |
| 4007 result->size = 0; | |
| 4008 GetIntegerv cmd2; | |
| 4009 cmd2.Init(GL_ALPHA_BITS, shared_memory_id_, shared_memory_offset_); | |
| 4010 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 4011 EXPECT_EQ( | |
| 4012 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_ALPHA_BITS), | |
| 4013 result->GetNumResults()); | |
| 4014 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 4015 EXPECT_EQ(0, result->GetData()[0]); | |
| 4016 } | |
| 4017 | |
| 4018 TEST_F(GLES2DecoderManualInitTest, ActualDepthMatchesRequestedDepth) { | |
| 4019 InitState init; | |
| 4020 init.gl_version = "3.0"; | |
| 4021 init.has_depth = true; | |
| 4022 init.request_depth = true; | |
| 4023 init.bind_generates_resource = true; | |
| 4024 InitDecoder(init); | |
| 4025 | |
| 4026 EXPECT_CALL(*gl_, GetError()) | |
| 4027 .WillOnce(Return(GL_NO_ERROR)) | |
| 4028 .WillOnce(Return(GL_NO_ERROR)) | |
| 4029 .RetiresOnSaturation(); | |
| 4030 typedef GetIntegerv::Result Result; | |
| 4031 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 4032 EXPECT_CALL(*gl_, GetIntegerv(GL_DEPTH_BITS, _)) | |
| 4033 .WillOnce(SetArgumentPointee<1>(24)) | |
| 4034 .RetiresOnSaturation(); | |
| 4035 result->size = 0; | |
| 4036 GetIntegerv cmd2; | |
| 4037 cmd2.Init(GL_DEPTH_BITS, shared_memory_id_, shared_memory_offset_); | |
| 4038 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 4039 EXPECT_EQ( | |
| 4040 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_BITS), | |
| 4041 result->GetNumResults()); | |
| 4042 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 4043 EXPECT_EQ(24, result->GetData()[0]); | |
| 4044 } | |
| 4045 | |
| 4046 TEST_F(GLES2DecoderManualInitTest, ActualDepthDoesNotMatchRequestedDepth) { | |
| 4047 InitState init; | |
| 4048 init.gl_version = "3.0"; | |
| 4049 init.has_depth = true; | |
| 4050 init.bind_generates_resource = true; | |
| 4051 InitDecoder(init); | |
| 4052 | |
| 4053 EXPECT_CALL(*gl_, GetError()) | |
| 4054 .WillOnce(Return(GL_NO_ERROR)) | |
| 4055 .WillOnce(Return(GL_NO_ERROR)) | |
| 4056 .RetiresOnSaturation(); | |
| 4057 typedef GetIntegerv::Result Result; | |
| 4058 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 4059 EXPECT_CALL(*gl_, GetIntegerv(GL_DEPTH_BITS, _)) | |
| 4060 .WillOnce(SetArgumentPointee<1>(24)) | |
| 4061 .RetiresOnSaturation(); | |
| 4062 result->size = 0; | |
| 4063 GetIntegerv cmd2; | |
| 4064 cmd2.Init(GL_DEPTH_BITS, shared_memory_id_, shared_memory_offset_); | |
| 4065 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 4066 EXPECT_EQ( | |
| 4067 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_BITS), | |
| 4068 result->GetNumResults()); | |
| 4069 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 4070 EXPECT_EQ(0, result->GetData()[0]); | |
| 4071 } | |
| 4072 | |
| 4073 TEST_F(GLES2DecoderManualInitTest, ActualStencilMatchesRequestedStencil) { | |
| 4074 InitState init; | |
| 4075 init.gl_version = "3.0"; | |
| 4076 init.has_stencil = true; | |
| 4077 init.request_stencil = true; | |
| 4078 init.bind_generates_resource = true; | |
| 4079 InitDecoder(init); | |
| 4080 | |
| 4081 EXPECT_CALL(*gl_, GetError()) | |
| 4082 .WillOnce(Return(GL_NO_ERROR)) | |
| 4083 .WillOnce(Return(GL_NO_ERROR)) | |
| 4084 .RetiresOnSaturation(); | |
| 4085 typedef GetIntegerv::Result Result; | |
| 4086 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 4087 EXPECT_CALL(*gl_, GetIntegerv(GL_STENCIL_BITS, _)) | |
| 4088 .WillOnce(SetArgumentPointee<1>(8)) | |
| 4089 .RetiresOnSaturation(); | |
| 4090 result->size = 0; | |
| 4091 GetIntegerv cmd2; | |
| 4092 cmd2.Init(GL_STENCIL_BITS, shared_memory_id_, shared_memory_offset_); | |
| 4093 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 4094 EXPECT_EQ( | |
| 4095 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_BITS), | |
| 4096 result->GetNumResults()); | |
| 4097 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 4098 EXPECT_EQ(8, result->GetData()[0]); | |
| 4099 } | |
| 4100 | |
| 4101 TEST_F(GLES2DecoderManualInitTest, ActualStencilDoesNotMatchRequestedStencil) { | |
| 4102 InitState init; | |
| 4103 init.gl_version = "3.0"; | |
| 4104 init.has_stencil = true; | |
| 4105 init.bind_generates_resource = true; | |
| 4106 InitDecoder(init); | |
| 4107 | |
| 4108 EXPECT_CALL(*gl_, GetError()) | |
| 4109 .WillOnce(Return(GL_NO_ERROR)) | |
| 4110 .WillOnce(Return(GL_NO_ERROR)) | |
| 4111 .RetiresOnSaturation(); | |
| 4112 typedef GetIntegerv::Result Result; | |
| 4113 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 4114 EXPECT_CALL(*gl_, GetIntegerv(GL_STENCIL_BITS, _)) | |
| 4115 .WillOnce(SetArgumentPointee<1>(8)) | |
| 4116 .RetiresOnSaturation(); | |
| 4117 result->size = 0; | |
| 4118 GetIntegerv cmd2; | |
| 4119 cmd2.Init(GL_STENCIL_BITS, shared_memory_id_, shared_memory_offset_); | |
| 4120 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 4121 EXPECT_EQ( | |
| 4122 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_BITS), | |
| 4123 result->GetNumResults()); | |
| 4124 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 4125 EXPECT_EQ(0, result->GetData()[0]); | |
| 4126 } | |
| 4127 | |
| 4128 TEST_F(GLES2DecoderManualInitTest, DepthEnableWithDepth) { | |
| 4129 InitState init; | |
| 4130 init.gl_version = "3.0"; | |
| 4131 init.has_depth = true; | |
| 4132 init.request_depth = true; | |
| 4133 init.bind_generates_resource = true; | |
| 4134 InitDecoder(init); | |
| 4135 | |
| 4136 Enable cmd; | |
| 4137 cmd.Init(GL_DEPTH_TEST); | |
| 4138 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 4139 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 4140 | |
| 4141 SetupDefaultProgram(); | |
| 4142 SetupTexture(); | |
| 4143 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); | |
| 4144 SetupExpectationsForApplyingDirtyState( | |
| 4145 true, // Framebuffer is RGB | |
| 4146 true, // Framebuffer has depth | |
| 4147 false, // Framebuffer has stencil | |
| 4148 0x1110, // color bits | |
| 4149 true, // depth mask | |
| 4150 true, // depth enabled | |
| 4151 0, // front stencil mask | |
| 4152 0, // back stencil mask | |
| 4153 false, // stencil enabled | |
| 4154 false, // cull_face_enabled | |
| 4155 false, // scissor_test_enabled | |
| 4156 false); // blend_enabled | |
| 4157 | |
| 4158 | |
| 4159 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | |
| 4160 .Times(1) | |
| 4161 .RetiresOnSaturation(); | |
| 4162 DrawArrays draw_cmd; | |
| 4163 draw_cmd.Init(GL_TRIANGLES, 0, kNumVertices); | |
| 4164 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd)); | |
| 4165 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 4166 | |
| 4167 EXPECT_CALL(*gl_, GetError()) | |
| 4168 .WillOnce(Return(GL_NO_ERROR)) | |
| 4169 .WillOnce(Return(GL_NO_ERROR)) | |
| 4170 .RetiresOnSaturation(); | |
| 4171 typedef GetIntegerv::Result Result; | |
| 4172 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 4173 EXPECT_CALL(*gl_, GetIntegerv(GL_DEPTH_TEST, _)) | |
| 4174 .Times(0) | |
| 4175 .RetiresOnSaturation(); | |
| 4176 result->size = 0; | |
| 4177 GetIntegerv cmd2; | |
| 4178 cmd2.Init(GL_DEPTH_TEST, shared_memory_id_, shared_memory_offset_); | |
| 4179 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 4180 EXPECT_EQ( | |
| 4181 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_TEST), | |
| 4182 result->GetNumResults()); | |
| 4183 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 4184 EXPECT_EQ(1, result->GetData()[0]); | |
| 4185 } | |
| 4186 | |
| 4187 TEST_F(GLES2DecoderManualInitTest, DepthEnableWithoutRequestedDepth) { | |
| 4188 InitState init; | |
| 4189 init.gl_version = "3.0"; | |
| 4190 init.has_depth = true; | |
| 4191 init.bind_generates_resource = true; | |
| 4192 InitDecoder(init); | |
| 4193 | |
| 4194 Enable cmd; | |
| 4195 cmd.Init(GL_DEPTH_TEST); | |
| 4196 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 4197 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 4198 | |
| 4199 SetupDefaultProgram(); | |
| 4200 SetupTexture(); | |
| 4201 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); | |
| 4202 SetupExpectationsForApplyingDirtyState( | |
| 4203 true, // Framebuffer is RGB | |
| 4204 false, // Framebuffer has depth | |
| 4205 false, // Framebuffer has stencil | |
| 4206 0x1110, // color bits | |
| 4207 false, // depth mask | |
| 4208 false, // depth enabled | |
| 4209 0, // front stencil mask | |
| 4210 0, // back stencil mask | |
| 4211 false, // stencil enabled | |
| 4212 false, // cull_face_enabled | |
| 4213 false, // scissor_test_enabled | |
| 4214 false); // blend_enabled | |
| 4215 | |
| 4216 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | |
| 4217 .Times(1) | |
| 4218 .RetiresOnSaturation(); | |
| 4219 DrawArrays draw_cmd; | |
| 4220 draw_cmd.Init(GL_TRIANGLES, 0, kNumVertices); | |
| 4221 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd)); | |
| 4222 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 4223 | |
| 4224 EXPECT_CALL(*gl_, GetError()) | |
| 4225 .WillOnce(Return(GL_NO_ERROR)) | |
| 4226 .WillOnce(Return(GL_NO_ERROR)) | |
| 4227 .RetiresOnSaturation(); | |
| 4228 typedef GetIntegerv::Result Result; | |
| 4229 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 4230 EXPECT_CALL(*gl_, GetIntegerv(GL_DEPTH_TEST, _)) | |
| 4231 .Times(0) | |
| 4232 .RetiresOnSaturation(); | |
| 4233 result->size = 0; | |
| 4234 GetIntegerv cmd2; | |
| 4235 cmd2.Init(GL_DEPTH_TEST, shared_memory_id_, shared_memory_offset_); | |
| 4236 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 4237 EXPECT_EQ( | |
| 4238 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_TEST), | |
| 4239 result->GetNumResults()); | |
| 4240 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 4241 EXPECT_EQ(1, result->GetData()[0]); | |
| 4242 } | |
| 4243 | |
| 4244 TEST_F(GLES2DecoderManualInitTest, StencilEnableWithStencil) { | |
| 4245 InitState init; | |
| 4246 init.gl_version = "3.0"; | |
| 4247 init.has_stencil = true; | |
| 4248 init.request_stencil = true; | |
| 4249 init.bind_generates_resource = true; | |
| 4250 InitDecoder(init); | |
| 4251 | |
| 4252 Enable cmd; | |
| 4253 cmd.Init(GL_STENCIL_TEST); | |
| 4254 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 4255 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 4256 | |
| 4257 SetupDefaultProgram(); | |
| 4258 SetupTexture(); | |
| 4259 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); | |
| 4260 SetupExpectationsForApplyingDirtyState( | |
| 4261 true, // Framebuffer is RGB | |
| 4262 false, // Framebuffer has depth | |
| 4263 true, // Framebuffer has stencil | |
| 4264 0x1110, // color bits | |
| 4265 false, // depth mask | |
| 4266 false, // depth enabled | |
| 4267 -1, // front stencil mask | |
| 4268 -1, // back stencil mask | |
| 4269 true, // stencil enabled | |
| 4270 false, // cull_face_enabled | |
| 4271 false, // scissor_test_enabled | |
| 4272 false); // blend_enabled | |
| 4273 | |
| 4274 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | |
| 4275 .Times(1) | |
| 4276 .RetiresOnSaturation(); | |
| 4277 DrawArrays draw_cmd; | |
| 4278 draw_cmd.Init(GL_TRIANGLES, 0, kNumVertices); | |
| 4279 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd)); | |
| 4280 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 4281 | |
| 4282 EXPECT_CALL(*gl_, GetError()) | |
| 4283 .WillOnce(Return(GL_NO_ERROR)) | |
| 4284 .WillOnce(Return(GL_NO_ERROR)) | |
| 4285 .RetiresOnSaturation(); | |
| 4286 typedef GetIntegerv::Result Result; | |
| 4287 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 4288 EXPECT_CALL(*gl_, GetIntegerv(GL_STENCIL_TEST, _)) | |
| 4289 .Times(0) | |
| 4290 .RetiresOnSaturation(); | |
| 4291 result->size = 0; | |
| 4292 GetIntegerv cmd2; | |
| 4293 cmd2.Init(GL_STENCIL_TEST, shared_memory_id_, shared_memory_offset_); | |
| 4294 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 4295 EXPECT_EQ( | |
| 4296 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_TEST), | |
| 4297 result->GetNumResults()); | |
| 4298 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 4299 EXPECT_EQ(1, result->GetData()[0]); | |
| 4300 } | |
| 4301 | |
| 4302 TEST_F(GLES2DecoderManualInitTest, StencilEnableWithoutRequestedStencil) { | |
| 4303 InitState init; | |
| 4304 init.gl_version = "3.0"; | |
| 4305 init.has_stencil = true; | |
| 4306 init.bind_generates_resource = true; | |
| 4307 InitDecoder(init); | |
| 4308 | |
| 4309 Enable cmd; | |
| 4310 cmd.Init(GL_STENCIL_TEST); | |
| 4311 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 4312 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 4313 | |
| 4314 SetupDefaultProgram(); | |
| 4315 SetupTexture(); | |
| 4316 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); | |
| 4317 SetupExpectationsForApplyingDirtyState( | |
| 4318 true, // Framebuffer is RGB | |
| 4319 false, // Framebuffer has depth | |
| 4320 false, // Framebuffer has stencil | |
| 4321 0x1110, // color bits | |
| 4322 false, // depth mask | |
| 4323 false, // depth enabled | |
| 4324 0, // front stencil mask | |
| 4325 0, // back stencil mask | |
| 4326 false, // stencil enabled | |
| 4327 false, // cull_face_enabled | |
| 4328 false, // scissor_test_enabled | |
| 4329 false); // blend_enabled | |
| 4330 | |
| 4331 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | |
| 4332 .Times(1) | |
| 4333 .RetiresOnSaturation(); | |
| 4334 DrawArrays draw_cmd; | |
| 4335 draw_cmd.Init(GL_TRIANGLES, 0, kNumVertices); | |
| 4336 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd)); | |
| 4337 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 4338 | |
| 4339 EXPECT_CALL(*gl_, GetError()) | |
| 4340 .WillOnce(Return(GL_NO_ERROR)) | |
| 4341 .WillOnce(Return(GL_NO_ERROR)) | |
| 4342 .RetiresOnSaturation(); | |
| 4343 typedef GetIntegerv::Result Result; | |
| 4344 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 4345 EXPECT_CALL(*gl_, GetIntegerv(GL_STENCIL_TEST, _)) | |
| 4346 .Times(0) | |
| 4347 .RetiresOnSaturation(); | |
| 4348 result->size = 0; | |
| 4349 GetIntegerv cmd2; | |
| 4350 cmd2.Init(GL_STENCIL_TEST, shared_memory_id_, shared_memory_offset_); | |
| 4351 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 4352 EXPECT_EQ( | |
| 4353 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_TEST), | |
| 4354 result->GetNumResults()); | |
| 4355 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 4356 EXPECT_EQ(1, result->GetData()[0]); | |
| 4357 } | |
| 4358 | |
| 4359 TEST_F(GLES2DecoderManualInitTest, PackedDepthStencilReportsCorrectValues) { | |
| 4360 InitState init; | |
| 4361 init.extensions = "GL_OES_packed_depth_stencil"; | |
| 4362 init.gl_version = "opengl es 2.0"; | |
| 4363 init.has_depth = true; | |
| 4364 init.has_stencil = true; | |
| 4365 init.request_depth = true; | |
| 4366 init.request_stencil = true; | |
| 4367 init.bind_generates_resource = true; | |
| 4368 InitDecoder(init); | |
| 4369 | |
| 4370 EXPECT_CALL(*gl_, GetError()) | |
| 4371 .WillOnce(Return(GL_NO_ERROR)) | |
| 4372 .WillOnce(Return(GL_NO_ERROR)) | |
| 4373 .WillOnce(Return(GL_NO_ERROR)) | |
| 4374 .WillOnce(Return(GL_NO_ERROR)) | |
| 4375 .RetiresOnSaturation(); | |
| 4376 typedef GetIntegerv::Result Result; | |
| 4377 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 4378 result->size = 0; | |
| 4379 GetIntegerv cmd2; | |
| 4380 cmd2.Init(GL_STENCIL_BITS, shared_memory_id_, shared_memory_offset_); | |
| 4381 EXPECT_CALL(*gl_, GetIntegerv(GL_STENCIL_BITS, _)) | |
| 4382 .WillOnce(SetArgumentPointee<1>(8)) | |
| 4383 .RetiresOnSaturation(); | |
| 4384 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 4385 EXPECT_EQ( | |
| 4386 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_BITS), | |
| 4387 result->GetNumResults()); | |
| 4388 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 4389 EXPECT_EQ(8, result->GetData()[0]); | |
| 4390 result->size = 0; | |
| 4391 cmd2.Init(GL_DEPTH_BITS, shared_memory_id_, shared_memory_offset_); | |
| 4392 EXPECT_CALL(*gl_, GetIntegerv(GL_DEPTH_BITS, _)) | |
| 4393 .WillOnce(SetArgumentPointee<1>(24)) | |
| 4394 .RetiresOnSaturation(); | |
| 4395 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 4396 EXPECT_EQ( | |
| 4397 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_BITS), | |
| 4398 result->GetNumResults()); | |
| 4399 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 4400 EXPECT_EQ(24, result->GetData()[0]); | |
| 4401 } | |
| 4402 | |
| 4403 TEST_F(GLES2DecoderManualInitTest, PackedDepthStencilNoRequestedStencil) { | |
| 4404 InitState init; | |
| 4405 init.extensions = "GL_OES_packed_depth_stencil"; | |
| 4406 init.gl_version = "opengl es 2.0"; | |
| 4407 init.has_depth = true; | |
| 4408 init.has_stencil = true; | |
| 4409 init.request_depth = true; | |
| 4410 init.bind_generates_resource = true; | |
| 4411 InitDecoder(init); | |
| 4412 | |
| 4413 EXPECT_CALL(*gl_, GetError()) | |
| 4414 .WillOnce(Return(GL_NO_ERROR)) | |
| 4415 .WillOnce(Return(GL_NO_ERROR)) | |
| 4416 .WillOnce(Return(GL_NO_ERROR)) | |
| 4417 .WillOnce(Return(GL_NO_ERROR)) | |
| 4418 .RetiresOnSaturation(); | |
| 4419 typedef GetIntegerv::Result Result; | |
| 4420 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 4421 result->size = 0; | |
| 4422 GetIntegerv cmd2; | |
| 4423 cmd2.Init(GL_STENCIL_BITS, shared_memory_id_, shared_memory_offset_); | |
| 4424 EXPECT_CALL(*gl_, GetIntegerv(GL_STENCIL_BITS, _)) | |
| 4425 .WillOnce(SetArgumentPointee<1>(8)) | |
| 4426 .RetiresOnSaturation(); | |
| 4427 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 4428 EXPECT_EQ( | |
| 4429 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_BITS), | |
| 4430 result->GetNumResults()); | |
| 4431 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 4432 EXPECT_EQ(0, result->GetData()[0]); | |
| 4433 result->size = 0; | |
| 4434 cmd2.Init(GL_DEPTH_BITS, shared_memory_id_, shared_memory_offset_); | |
| 4435 EXPECT_CALL(*gl_, GetIntegerv(GL_DEPTH_BITS, _)) | |
| 4436 .WillOnce(SetArgumentPointee<1>(24)) | |
| 4437 .RetiresOnSaturation(); | |
| 4438 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 4439 EXPECT_EQ( | |
| 4440 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_BITS), | |
| 4441 result->GetNumResults()); | |
| 4442 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 4443 EXPECT_EQ(24, result->GetData()[0]); | |
| 4444 } | |
| 4445 | |
| 4446 TEST_F(GLES2DecoderManualInitTest, PackedDepthStencilRenderbufferDepth) { | |
| 4447 InitState init; | |
| 4448 init.extensions = "GL_OES_packed_depth_stencil"; | |
| 4449 init.gl_version = "opengl es 2.0"; | |
| 4450 init.bind_generates_resource = true; | |
| 4451 InitDecoder(init); | |
| 4452 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_, | |
| 4453 kServiceRenderbufferId); | |
| 4454 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, | |
| 4455 kServiceFramebufferId); | |
| 4456 | |
| 4457 EXPECT_CALL(*gl_, GetError()) | |
| 4458 .WillOnce(Return(GL_NO_ERROR)) // for RenderbufferStoage | |
| 4459 .WillOnce(Return(GL_NO_ERROR)) | |
| 4460 .WillOnce(Return(GL_NO_ERROR)) // for FramebufferRenderbuffer | |
| 4461 .WillOnce(Return(GL_NO_ERROR)) | |
| 4462 .WillOnce(Return(GL_NO_ERROR)) // for GetIntegerv | |
| 4463 .WillOnce(Return(GL_NO_ERROR)) | |
| 4464 .WillOnce(Return(GL_NO_ERROR)) // for GetIntegerv | |
| 4465 .WillOnce(Return(GL_NO_ERROR)) | |
| 4466 .RetiresOnSaturation(); | |
| 4467 | |
| 4468 EXPECT_CALL(*gl_, RenderbufferStorageEXT( | |
| 4469 GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 100, 50)) | |
| 4470 .Times(1) | |
| 4471 .RetiresOnSaturation(); | |
| 4472 RenderbufferStorage cmd; | |
| 4473 cmd.Init(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 100, 50); | |
| 4474 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 4475 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT( | |
| 4476 GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, | |
| 4477 kServiceRenderbufferId)) | |
| 4478 .Times(1) | |
| 4479 .RetiresOnSaturation(); | |
| 4480 FramebufferRenderbuffer fbrb_cmd; | |
| 4481 fbrb_cmd.Init( | |
| 4482 GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, | |
| 4483 client_renderbuffer_id_); | |
| 4484 EXPECT_EQ(error::kNoError, ExecuteCmd(fbrb_cmd)); | |
| 4485 | |
| 4486 typedef GetIntegerv::Result Result; | |
| 4487 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 4488 result->size = 0; | |
| 4489 GetIntegerv cmd2; | |
| 4490 cmd2.Init(GL_STENCIL_BITS, shared_memory_id_, shared_memory_offset_); | |
| 4491 EXPECT_CALL(*gl_, GetIntegerv(GL_STENCIL_BITS, _)) | |
| 4492 .WillOnce(SetArgumentPointee<1>(8)) | |
| 4493 .RetiresOnSaturation(); | |
| 4494 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 4495 EXPECT_EQ( | |
| 4496 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_BITS), | |
| 4497 result->GetNumResults()); | |
| 4498 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 4499 EXPECT_EQ(0, result->GetData()[0]); | |
| 4500 result->size = 0; | |
| 4501 cmd2.Init(GL_DEPTH_BITS, shared_memory_id_, shared_memory_offset_); | |
| 4502 EXPECT_CALL(*gl_, GetIntegerv(GL_DEPTH_BITS, _)) | |
| 4503 .WillOnce(SetArgumentPointee<1>(24)) | |
| 4504 .RetiresOnSaturation(); | |
| 4505 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 4506 EXPECT_EQ( | |
| 4507 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_BITS), | |
| 4508 result->GetNumResults()); | |
| 4509 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 4510 EXPECT_EQ(24, result->GetData()[0]); | |
| 4511 } | |
| 4512 | |
| 4513 TEST_F(GLES2DecoderManualInitTest, PackedDepthStencilRenderbufferStencil) { | |
| 4514 InitState init; | |
| 4515 init.extensions = "GL_OES_packed_depth_stencil"; | |
| 4516 init.gl_version = "opengl es 2.0"; | |
| 4517 init.bind_generates_resource = true; | |
| 4518 InitDecoder(init); | |
| 4519 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_, | |
| 4520 kServiceRenderbufferId); | |
| 4521 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, | |
| 4522 kServiceFramebufferId); | |
| 4523 | |
| 4524 EXPECT_CALL(*gl_, GetError()) | |
| 4525 .WillOnce(Return(GL_NO_ERROR)) // for RenderbufferStoage | |
| 4526 .WillOnce(Return(GL_NO_ERROR)) | |
| 4527 .WillOnce(Return(GL_NO_ERROR)) // for FramebufferRenderbuffer | |
| 4528 .WillOnce(Return(GL_NO_ERROR)) | |
| 4529 .WillOnce(Return(GL_NO_ERROR)) // for GetIntegerv | |
| 4530 .WillOnce(Return(GL_NO_ERROR)) | |
| 4531 .WillOnce(Return(GL_NO_ERROR)) // for GetIntegerv | |
| 4532 .WillOnce(Return(GL_NO_ERROR)) | |
| 4533 .RetiresOnSaturation(); | |
| 4534 | |
| 4535 EXPECT_CALL(*gl_, RenderbufferStorageEXT( | |
| 4536 GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 100, 50)) | |
| 4537 .Times(1) | |
| 4538 .RetiresOnSaturation(); | |
| 4539 RenderbufferStorage cmd; | |
| 4540 cmd.Init(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 100, 50); | |
| 4541 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 4542 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT( | |
| 4543 GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, | |
| 4544 kServiceRenderbufferId)) | |
| 4545 .Times(1) | |
| 4546 .RetiresOnSaturation(); | |
| 4547 FramebufferRenderbuffer fbrb_cmd; | |
| 4548 fbrb_cmd.Init( | |
| 4549 GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, | |
| 4550 client_renderbuffer_id_); | |
| 4551 EXPECT_EQ(error::kNoError, ExecuteCmd(fbrb_cmd)); | |
| 4552 | |
| 4553 typedef GetIntegerv::Result Result; | |
| 4554 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 4555 result->size = 0; | |
| 4556 GetIntegerv cmd2; | |
| 4557 cmd2.Init(GL_STENCIL_BITS, shared_memory_id_, shared_memory_offset_); | |
| 4558 EXPECT_CALL(*gl_, GetIntegerv(GL_STENCIL_BITS, _)) | |
| 4559 .WillOnce(SetArgumentPointee<1>(8)) | |
| 4560 .RetiresOnSaturation(); | |
| 4561 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 4562 EXPECT_EQ( | |
| 4563 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_BITS), | |
| 4564 result->GetNumResults()); | |
| 4565 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 4566 EXPECT_EQ(8, result->GetData()[0]); | |
| 4567 result->size = 0; | |
| 4568 cmd2.Init(GL_DEPTH_BITS, shared_memory_id_, shared_memory_offset_); | |
| 4569 EXPECT_CALL(*gl_, GetIntegerv(GL_DEPTH_BITS, _)) | |
| 4570 .WillOnce(SetArgumentPointee<1>(24)) | |
| 4571 .RetiresOnSaturation(); | |
| 4572 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 4573 EXPECT_EQ( | |
| 4574 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_BITS), | |
| 4575 result->GetNumResults()); | |
| 4576 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 4577 EXPECT_EQ(0, result->GetData()[0]); | |
| 4578 } | |
| 4579 | |
| 4580 TEST_F(GLES2DecoderTest, GetMultipleIntegervCHROMIUMValidArgs) { | 367 TEST_F(GLES2DecoderTest, GetMultipleIntegervCHROMIUMValidArgs) { |
| 4581 const GLsizei kCount = 3; | 368 const GLsizei kCount = 3; |
| 4582 GLenum* pnames = GetSharedMemoryAs<GLenum*>(); | 369 GLenum* pnames = GetSharedMemoryAs<GLenum*>(); |
| 4583 pnames[0] = GL_DEPTH_WRITEMASK; | 370 pnames[0] = GL_DEPTH_WRITEMASK; |
| 4584 pnames[1] = GL_COLOR_WRITEMASK; | 371 pnames[1] = GL_COLOR_WRITEMASK; |
| 4585 pnames[2] = GL_STENCIL_WRITEMASK; | 372 pnames[2] = GL_STENCIL_WRITEMASK; |
| 4586 GLint* results = | 373 GLint* results = |
| 4587 GetSharedMemoryAsWithOffset<GLint*>(sizeof(*pnames) * kCount); | 374 GetSharedMemoryAsWithOffset<GLint*>(sizeof(*pnames) * kCount); |
| 4588 | 375 |
| 4589 GLsizei num_results = 0; | 376 GLsizei num_results = 0; |
| 4590 for (GLsizei ii = 0; ii < kCount; ++ii) { | 377 for (GLsizei ii = 0; ii < kCount; ++ii) { |
| 4591 num_results += decoder_->GetGLES2Util()->GLGetNumValuesReturned(pnames[ii]); | 378 num_results += decoder_->GetGLES2Util()->GLGetNumValuesReturned(pnames[ii]); |
| 4592 } | 379 } |
| 4593 const GLsizei result_size = num_results * sizeof(*results); | 380 const GLsizei result_size = num_results * sizeof(*results); |
| 4594 memset(results, 0, result_size); | 381 memset(results, 0, result_size); |
| 4595 | 382 |
| 4596 const GLint kSentinel = 0x12345678; | 383 const GLint kSentinel = 0x12345678; |
| 4597 results[num_results] = kSentinel; | 384 results[num_results] = kSentinel; |
| 4598 | 385 |
| 4599 GetMultipleIntegervCHROMIUM cmd; | 386 GetMultipleIntegervCHROMIUM cmd; |
| 4600 cmd.Init( | 387 cmd.Init(kSharedMemoryId, |
| 4601 kSharedMemoryId, kSharedMemoryOffset, kCount, | 388 kSharedMemoryOffset, |
| 4602 kSharedMemoryId, kSharedMemoryOffset + sizeof(*pnames) * kCount, | 389 kCount, |
| 4603 result_size); | 390 kSharedMemoryId, |
| 4604 | 391 kSharedMemoryOffset + sizeof(*pnames) * kCount, |
| 4605 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 392 result_size); |
| 4606 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 393 |
| 4607 EXPECT_EQ(1, results[0]); // Depth writemask | 394 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4608 EXPECT_EQ(1, results[1]); // color writemask red | 395 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 4609 EXPECT_EQ(1, results[2]); // color writemask green | 396 EXPECT_EQ(1, results[0]); // Depth writemask |
| 4610 EXPECT_EQ(1, results[3]); // color writemask blue | 397 EXPECT_EQ(1, results[1]); // color writemask red |
| 4611 EXPECT_EQ(1, results[4]); // color writemask alpha | 398 EXPECT_EQ(1, results[2]); // color writemask green |
| 4612 EXPECT_EQ(-1, results[5]); // stencil writemask alpha | 399 EXPECT_EQ(1, results[3]); // color writemask blue |
| 400 EXPECT_EQ(1, results[4]); // color writemask alpha |
| 401 EXPECT_EQ(-1, results[5]); // stencil writemask alpha |
| 4613 EXPECT_EQ(kSentinel, results[num_results]); // End of results | 402 EXPECT_EQ(kSentinel, results[num_results]); // End of results |
| 4614 } | 403 } |
| 4615 | 404 |
| 4616 TEST_F(GLES2DecoderTest, GetMultipleIntegervCHROMIUMInvalidArgs) { | 405 TEST_F(GLES2DecoderTest, GetMultipleIntegervCHROMIUMInvalidArgs) { |
| 4617 const GLsizei kCount = 3; | 406 const GLsizei kCount = 3; |
| 4618 // Offset the pnames because GLGetError will use the first uint32. | 407 // Offset the pnames because GLGetError will use the first uint32. |
| 4619 const uint32 kPnameOffset = sizeof(uint32); | 408 const uint32 kPnameOffset = sizeof(uint32); |
| 4620 const uint32 kResultsOffset = kPnameOffset + sizeof(GLint) * kCount; | 409 const uint32 kResultsOffset = kPnameOffset + sizeof(GLint) * kCount; |
| 4621 GLenum* pnames = GetSharedMemoryAsWithOffset<GLenum*>(kPnameOffset); | 410 GLenum* pnames = GetSharedMemoryAsWithOffset<GLenum*>(kPnameOffset); |
| 4622 pnames[0] = GL_DEPTH_WRITEMASK; | 411 pnames[0] = GL_DEPTH_WRITEMASK; |
| 4623 pnames[1] = GL_COLOR_WRITEMASK; | 412 pnames[1] = GL_COLOR_WRITEMASK; |
| 4624 pnames[2] = GL_STENCIL_WRITEMASK; | 413 pnames[2] = GL_STENCIL_WRITEMASK; |
| 4625 GLint* results = GetSharedMemoryAsWithOffset<GLint*>(kResultsOffset); | 414 GLint* results = GetSharedMemoryAsWithOffset<GLint*>(kResultsOffset); |
| 4626 | 415 |
| 4627 GLsizei num_results = 0; | 416 GLsizei num_results = 0; |
| 4628 for (GLsizei ii = 0; ii < kCount; ++ii) { | 417 for (GLsizei ii = 0; ii < kCount; ++ii) { |
| 4629 num_results += decoder_->GetGLES2Util()->GLGetNumValuesReturned(pnames[ii]); | 418 num_results += decoder_->GetGLES2Util()->GLGetNumValuesReturned(pnames[ii]); |
| 4630 } | 419 } |
| 4631 const GLsizei result_size = num_results * sizeof(*results); | 420 const GLsizei result_size = num_results * sizeof(*results); |
| 4632 memset(results, 0, result_size); | 421 memset(results, 0, result_size); |
| 4633 | 422 |
| 4634 const GLint kSentinel = 0x12345678; | 423 const GLint kSentinel = 0x12345678; |
| 4635 results[num_results] = kSentinel; | 424 results[num_results] = kSentinel; |
| 4636 | 425 |
| 4637 GetMultipleIntegervCHROMIUM cmd; | 426 GetMultipleIntegervCHROMIUM cmd; |
| 4638 // Check bad pnames pointer. | 427 // Check bad pnames pointer. |
| 4639 cmd.Init( | 428 cmd.Init(kInvalidSharedMemoryId, |
| 4640 kInvalidSharedMemoryId, kSharedMemoryOffset + kPnameOffset, kCount, | 429 kSharedMemoryOffset + kPnameOffset, |
| 4641 kSharedMemoryId, kSharedMemoryOffset + kResultsOffset, | 430 kCount, |
| 4642 result_size); | 431 kSharedMemoryId, |
| 432 kSharedMemoryOffset + kResultsOffset, |
| 433 result_size); |
| 4643 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); | 434 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); |
| 4644 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 435 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 4645 // Check bad pnames pointer. | 436 // Check bad pnames pointer. |
| 4646 cmd.Init( | 437 cmd.Init(kSharedMemoryId, |
| 4647 kSharedMemoryId, kInvalidSharedMemoryOffset, kCount, | 438 kInvalidSharedMemoryOffset, |
| 4648 kSharedMemoryId, kSharedMemoryOffset + kResultsOffset, | 439 kCount, |
| 4649 result_size); | 440 kSharedMemoryId, |
| 441 kSharedMemoryOffset + kResultsOffset, |
| 442 result_size); |
| 4650 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); | 443 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); |
| 4651 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 444 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 4652 // Check bad count. | 445 // Check bad count. |
| 4653 cmd.Init( | 446 cmd.Init(kSharedMemoryId, |
| 4654 kSharedMemoryId, kSharedMemoryOffset + kPnameOffset, -1, | 447 kSharedMemoryOffset + kPnameOffset, |
| 4655 kSharedMemoryId, kSharedMemoryOffset + kResultsOffset, | 448 -1, |
| 4656 result_size); | 449 kSharedMemoryId, |
| 450 kSharedMemoryOffset + kResultsOffset, |
| 451 result_size); |
| 4657 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); | 452 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); |
| 4658 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 453 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 4659 // Check bad results pointer. | 454 // Check bad results pointer. |
| 4660 cmd.Init( | 455 cmd.Init(kSharedMemoryId, |
| 4661 kSharedMemoryId, kSharedMemoryOffset + kPnameOffset, kCount, | 456 kSharedMemoryOffset + kPnameOffset, |
| 4662 kInvalidSharedMemoryId, kSharedMemoryOffset + kResultsOffset, | 457 kCount, |
| 4663 result_size); | 458 kInvalidSharedMemoryId, |
| 459 kSharedMemoryOffset + kResultsOffset, |
| 460 result_size); |
| 4664 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); | 461 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); |
| 4665 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 462 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 4666 // Check bad results pointer. | 463 // Check bad results pointer. |
| 4667 cmd.Init( | 464 cmd.Init(kSharedMemoryId, |
| 4668 kSharedMemoryId, kSharedMemoryOffset + kPnameOffset, kCount, | 465 kSharedMemoryOffset + kPnameOffset, |
| 4669 kSharedMemoryId, kInvalidSharedMemoryOffset, | 466 kCount, |
| 4670 result_size); | 467 kSharedMemoryId, |
| 468 kInvalidSharedMemoryOffset, |
| 469 result_size); |
| 4671 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); | 470 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); |
| 4672 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 471 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 4673 // Check bad size. | 472 // Check bad size. |
| 4674 cmd.Init( | 473 cmd.Init(kSharedMemoryId, |
| 4675 kSharedMemoryId, kSharedMemoryOffset + kPnameOffset, kCount, | 474 kSharedMemoryOffset + kPnameOffset, |
| 4676 kSharedMemoryId, kSharedMemoryOffset + kResultsOffset, | 475 kCount, |
| 4677 result_size + 1); | 476 kSharedMemoryId, |
| 477 kSharedMemoryOffset + kResultsOffset, |
| 478 result_size + 1); |
| 4678 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 479 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4679 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | 480 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 4680 // Check bad size. | 481 // Check bad size. |
| 4681 cmd.Init( | 482 cmd.Init(kSharedMemoryId, |
| 4682 kSharedMemoryId, kSharedMemoryOffset + kPnameOffset, kCount, | 483 kSharedMemoryOffset + kPnameOffset, |
| 4683 kSharedMemoryId, kSharedMemoryOffset + kResultsOffset, | 484 kCount, |
| 4684 result_size - 1); | 485 kSharedMemoryId, |
| 486 kSharedMemoryOffset + kResultsOffset, |
| 487 result_size - 1); |
| 4685 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 488 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4686 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | 489 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 4687 // Check bad enum. | 490 // Check bad enum. |
| 4688 cmd.Init( | 491 cmd.Init(kSharedMemoryId, |
| 4689 kSharedMemoryId, kSharedMemoryOffset + kPnameOffset, kCount, | 492 kSharedMemoryOffset + kPnameOffset, |
| 4690 kSharedMemoryId, kSharedMemoryOffset + kResultsOffset, | 493 kCount, |
| 4691 result_size); | 494 kSharedMemoryId, |
| 495 kSharedMemoryOffset + kResultsOffset, |
| 496 result_size); |
| 4692 GLenum temp = pnames[2]; | 497 GLenum temp = pnames[2]; |
| 4693 pnames[2] = GL_TRUE; | 498 pnames[2] = GL_TRUE; |
| 4694 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 499 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4695 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | 500 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 4696 pnames[2] = temp; | 501 pnames[2] = temp; |
| 4697 // Check results area has not been cleared by client. | 502 // Check results area has not been cleared by client. |
| 4698 results[1] = 1; | 503 results[1] = 1; |
| 4699 EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(cmd)); | 504 EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(cmd)); |
| 4700 // Check buffer is what we expect | 505 // Check buffer is what we expect |
| 4701 EXPECT_EQ(0, results[0]); | 506 EXPECT_EQ(0, results[0]); |
| 4702 EXPECT_EQ(1, results[1]); | 507 EXPECT_EQ(1, results[1]); |
| 4703 EXPECT_EQ(0, results[2]); | 508 EXPECT_EQ(0, results[2]); |
| 4704 EXPECT_EQ(0, results[3]); | 509 EXPECT_EQ(0, results[3]); |
| 4705 EXPECT_EQ(0, results[4]); | 510 EXPECT_EQ(0, results[4]); |
| 4706 EXPECT_EQ(0, results[5]); | 511 EXPECT_EQ(0, results[5]); |
| 4707 EXPECT_EQ(kSentinel, results[num_results]); // End of results | 512 EXPECT_EQ(kSentinel, results[num_results]); // End of results |
| 4708 } | 513 } |
| 4709 | 514 |
| 4710 TEST_F(GLES2DecoderTest, TexImage2DRedefinitionSucceeds) { | |
| 4711 const int kWidth = 16; | |
| 4712 const int kHeight = 8; | |
| 4713 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 4714 EXPECT_CALL(*gl_, GetError()) | |
| 4715 .WillRepeatedly(Return(GL_NO_ERROR)); | |
| 4716 for (int ii = 0; ii < 2; ++ii) { | |
| 4717 TexImage2D cmd; | |
| 4718 if (ii == 0) { | |
| 4719 EXPECT_CALL(*gl_, TexImage2D( | |
| 4720 GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, | |
| 4721 GL_UNSIGNED_BYTE, _)) | |
| 4722 .Times(1) | |
| 4723 .RetiresOnSaturation(); | |
| 4724 cmd.Init( | |
| 4725 GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, | |
| 4726 GL_UNSIGNED_BYTE, kSharedMemoryId, kSharedMemoryOffset); | |
| 4727 } else { | |
| 4728 SetupClearTextureExpectations( | |
| 4729 kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D, | |
| 4730 0, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, kWidth, kHeight); | |
| 4731 cmd.Init( | |
| 4732 GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, | |
| 4733 GL_UNSIGNED_BYTE, 0, 0); | |
| 4734 } | |
| 4735 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 4736 EXPECT_CALL(*gl_, TexSubImage2D( | |
| 4737 GL_TEXTURE_2D, 0, 0, 0, kWidth, kHeight - 1, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 4738 shared_memory_address_)) | |
| 4739 .Times(1) | |
| 4740 .RetiresOnSaturation(); | |
| 4741 // Consider this TexSubImage2D command part of the previous TexImage2D | |
| 4742 // (last GL_TRUE argument). It will be skipped if there are bugs in the | |
| 4743 // redefinition case. | |
| 4744 TexSubImage2D cmd2; | |
| 4745 cmd2.Init( | |
| 4746 GL_TEXTURE_2D, 0, 0, 0, kWidth, kHeight - 1, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 4747 kSharedMemoryId, kSharedMemoryOffset, GL_TRUE); | |
| 4748 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 4749 } | |
| 4750 } | |
| 4751 | |
| 4752 TEST_F(GLES2DecoderTest, TexImage2DGLError) { | |
| 4753 GLenum target = GL_TEXTURE_2D; | |
| 4754 GLint level = 0; | |
| 4755 GLenum internal_format = GL_RGBA; | |
| 4756 GLsizei width = 2; | |
| 4757 GLsizei height = 4; | |
| 4758 GLint border = 0; | |
| 4759 GLenum format = GL_RGBA; | |
| 4760 GLenum type = GL_UNSIGNED_BYTE; | |
| 4761 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 4762 TextureManager* manager = group().texture_manager(); | |
| 4763 TextureRef* texture_ref = manager->GetTexture(client_texture_id_); | |
| 4764 ASSERT_TRUE(texture_ref != NULL); | |
| 4765 Texture* texture = texture_ref->texture(); | |
| 4766 EXPECT_FALSE(texture->GetLevelSize(GL_TEXTURE_2D, level, &width, &height)); | |
| 4767 EXPECT_CALL(*gl_, GetError()) | |
| 4768 .WillOnce(Return(GL_NO_ERROR)) | |
| 4769 .WillOnce(Return(GL_OUT_OF_MEMORY)) | |
| 4770 .RetiresOnSaturation(); | |
| 4771 EXPECT_CALL(*gl_, TexImage2D(target, level, internal_format, | |
| 4772 width, height, border, format, type, _)) | |
| 4773 .Times(1) | |
| 4774 .RetiresOnSaturation(); | |
| 4775 TexImage2D cmd; | |
| 4776 cmd.Init(target, level, internal_format, width, height, border, format, | |
| 4777 type, kSharedMemoryId, kSharedMemoryOffset); | |
| 4778 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 4779 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); | |
| 4780 EXPECT_FALSE(texture->GetLevelSize(GL_TEXTURE_2D, level, &width, &height)); | |
| 4781 } | |
| 4782 | |
| 4783 TEST_F(GLES2DecoderTest, BufferDataGLError) { | |
| 4784 GLenum target = GL_ARRAY_BUFFER; | |
| 4785 GLsizeiptr size = 4; | |
| 4786 DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId); | |
| 4787 BufferManager* manager = group().buffer_manager(); | |
| 4788 Buffer* buffer = manager->GetBuffer(client_buffer_id_); | |
| 4789 ASSERT_TRUE(buffer != NULL); | |
| 4790 EXPECT_EQ(0, buffer->size()); | |
| 4791 EXPECT_CALL(*gl_, GetError()) | |
| 4792 .WillOnce(Return(GL_NO_ERROR)) | |
| 4793 .WillOnce(Return(GL_OUT_OF_MEMORY)) | |
| 4794 .RetiresOnSaturation(); | |
| 4795 EXPECT_CALL(*gl_, BufferData(target, size, _, GL_STREAM_DRAW)) | |
| 4796 .Times(1) | |
| 4797 .RetiresOnSaturation(); | |
| 4798 BufferData cmd; | |
| 4799 cmd.Init(target, size, 0, 0, GL_STREAM_DRAW); | |
| 4800 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 4801 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); | |
| 4802 EXPECT_EQ(0, buffer->size()); | |
| 4803 } | |
| 4804 | |
| 4805 TEST_F(GLES2DecoderTest, CopyTexImage2DGLError) { | |
| 4806 GLenum target = GL_TEXTURE_2D; | |
| 4807 GLint level = 0; | |
| 4808 GLenum internal_format = GL_RGBA; | |
| 4809 GLsizei width = 2; | |
| 4810 GLsizei height = 4; | |
| 4811 GLint border = 0; | |
| 4812 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 4813 TextureManager* manager = group().texture_manager(); | |
| 4814 TextureRef* texture_ref = manager->GetTexture(client_texture_id_); | |
| 4815 ASSERT_TRUE(texture_ref != NULL); | |
| 4816 Texture* texture = texture_ref->texture(); | |
| 4817 EXPECT_FALSE(texture->GetLevelSize(GL_TEXTURE_2D, level, &width, &height)); | |
| 4818 EXPECT_CALL(*gl_, GetError()) | |
| 4819 .WillOnce(Return(GL_NO_ERROR)) | |
| 4820 .WillOnce(Return(GL_OUT_OF_MEMORY)) | |
| 4821 .RetiresOnSaturation(); | |
| 4822 EXPECT_CALL(*gl_, CopyTexImage2D( | |
| 4823 target, level, internal_format, 0, 0, width, height, border)) | |
| 4824 .Times(1) | |
| 4825 .RetiresOnSaturation(); | |
| 4826 CopyTexImage2D cmd; | |
| 4827 cmd.Init(target, level, internal_format, 0, 0, width, height, border); | |
| 4828 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 4829 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); | |
| 4830 EXPECT_FALSE(texture->GetLevelSize(GL_TEXTURE_2D, level, &width, &height)); | |
| 4831 } | |
| 4832 | |
| 4833 TEST_F(GLES2DecoderTest, FramebufferRenderbufferGLError) { | |
| 4834 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, | |
| 4835 kServiceFramebufferId); | |
| 4836 EXPECT_CALL(*gl_, GetError()) | |
| 4837 .WillOnce(Return(GL_NO_ERROR)) | |
| 4838 .WillOnce(Return(GL_OUT_OF_MEMORY)) | |
| 4839 .RetiresOnSaturation(); | |
| 4840 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT( | |
| 4841 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, | |
| 4842 kServiceRenderbufferId)) | |
| 4843 .Times(1) | |
| 4844 .RetiresOnSaturation(); | |
| 4845 FramebufferRenderbuffer cmd; | |
| 4846 cmd.Init( | |
| 4847 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, | |
| 4848 client_renderbuffer_id_); | |
| 4849 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 4850 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); | |
| 4851 } | |
| 4852 | |
| 4853 TEST_F(GLES2DecoderTest, FramebufferTexture2DGLError) { | |
| 4854 const GLsizei kWidth = 5; | |
| 4855 const GLsizei kHeight = 3; | |
| 4856 const GLenum kFormat = GL_RGB; | |
| 4857 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 4858 DoTexImage2D(GL_TEXTURE_2D, 0, kFormat, kWidth, kHeight, 0, | |
| 4859 kFormat, GL_UNSIGNED_BYTE, 0, 0); | |
| 4860 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, | |
| 4861 kServiceFramebufferId); | |
| 4862 EXPECT_CALL(*gl_, GetError()) | |
| 4863 .WillOnce(Return(GL_NO_ERROR)) | |
| 4864 .WillOnce(Return(GL_OUT_OF_MEMORY)) | |
| 4865 .RetiresOnSaturation(); | |
| 4866 EXPECT_CALL(*gl_, FramebufferTexture2DEXT( | |
| 4867 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, | |
| 4868 kServiceTextureId, 0)) | |
| 4869 .Times(1) | |
| 4870 .RetiresOnSaturation(); | |
| 4871 FramebufferTexture2D fbtex_cmd; | |
| 4872 fbtex_cmd.Init( | |
| 4873 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, client_texture_id_, | |
| 4874 0); | |
| 4875 EXPECT_EQ(error::kNoError, ExecuteCmd(fbtex_cmd)); | |
| 4876 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); | |
| 4877 } | |
| 4878 | |
| 4879 TEST_F(GLES2DecoderTest, RenderbufferStorageGLError) { | |
| 4880 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_, | |
| 4881 kServiceRenderbufferId); | |
| 4882 EXPECT_CALL(*gl_, GetError()) | |
| 4883 .WillOnce(Return(GL_NO_ERROR)) | |
| 4884 .WillOnce(Return(GL_OUT_OF_MEMORY)) | |
| 4885 .RetiresOnSaturation(); | |
| 4886 EXPECT_CALL(*gl_, RenderbufferStorageEXT( | |
| 4887 GL_RENDERBUFFER, GL_RGBA, 100, 50)) | |
| 4888 .Times(1) | |
| 4889 .RetiresOnSaturation(); | |
| 4890 RenderbufferStorage cmd; | |
| 4891 cmd.Init(GL_RENDERBUFFER, GL_RGBA4, 100, 50); | |
| 4892 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 4893 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); | |
| 4894 } | |
| 4895 | |
| 4896 TEST_F(GLES2DecoderTest, RenderbufferStorageBadArgs) { | |
| 4897 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_, | |
| 4898 kServiceRenderbufferId); | |
| 4899 EXPECT_CALL(*gl_, RenderbufferStorageEXT(_, _, _, _)) | |
| 4900 .Times(0) | |
| 4901 .RetiresOnSaturation(); | |
| 4902 RenderbufferStorage cmd; | |
| 4903 cmd.Init(GL_RENDERBUFFER, GL_RGBA4, TestHelper::kMaxRenderbufferSize + 1, 1); | |
| 4904 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 4905 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 4906 cmd.Init(GL_RENDERBUFFER, GL_RGBA4, 1, TestHelper::kMaxRenderbufferSize + 1); | |
| 4907 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 4908 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 4909 } | |
| 4910 | |
| 4911 TEST_F(GLES2DecoderManualInitTest, | |
| 4912 RenderbufferStorageMultisampleCHROMIUMGLError) { | |
| 4913 InitState init; | |
| 4914 init.extensions = "GL_EXT_framebuffer_multisample"; | |
| 4915 init.gl_version = "2.1"; | |
| 4916 init.bind_generates_resource = true; | |
| 4917 InitDecoder(init); | |
| 4918 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_, | |
| 4919 kServiceRenderbufferId); | |
| 4920 EXPECT_CALL(*gl_, GetError()) | |
| 4921 .WillOnce(Return(GL_NO_ERROR)) | |
| 4922 .WillOnce(Return(GL_OUT_OF_MEMORY)) | |
| 4923 .RetiresOnSaturation(); | |
| 4924 EXPECT_CALL(*gl_, RenderbufferStorageMultisampleEXT( | |
| 4925 GL_RENDERBUFFER, 1, GL_RGBA, 100, 50)) | |
| 4926 .Times(1) | |
| 4927 .RetiresOnSaturation(); | |
| 4928 RenderbufferStorageMultisampleCHROMIUM cmd; | |
| 4929 cmd.Init(GL_RENDERBUFFER, 1, GL_RGBA4, 100, 50); | |
| 4930 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 4931 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); | |
| 4932 } | |
| 4933 | |
| 4934 TEST_F(GLES2DecoderManualInitTest, | |
| 4935 RenderbufferStorageMultisampleCHROMIUMBadArgs) { | |
| 4936 InitState init; | |
| 4937 init.extensions = "GL_EXT_framebuffer_multisample"; | |
| 4938 init.gl_version = "2.1"; | |
| 4939 init.bind_generates_resource = true; | |
| 4940 InitDecoder(init); | |
| 4941 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_, | |
| 4942 kServiceRenderbufferId); | |
| 4943 EXPECT_CALL(*gl_, RenderbufferStorageMultisampleEXT(_, _, _, _, _)) | |
| 4944 .Times(0) | |
| 4945 .RetiresOnSaturation(); | |
| 4946 RenderbufferStorageMultisampleCHROMIUM cmd; | |
| 4947 cmd.Init(GL_RENDERBUFFER, TestHelper::kMaxSamples + 1, | |
| 4948 GL_RGBA4, TestHelper::kMaxRenderbufferSize, 1); | |
| 4949 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 4950 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 4951 cmd.Init(GL_RENDERBUFFER, TestHelper::kMaxSamples, | |
| 4952 GL_RGBA4, TestHelper::kMaxRenderbufferSize + 1, 1); | |
| 4953 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 4954 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 4955 cmd.Init(GL_RENDERBUFFER, TestHelper::kMaxSamples, | |
| 4956 GL_RGBA4, 1, TestHelper::kMaxRenderbufferSize + 1); | |
| 4957 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 4958 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 4959 } | |
| 4960 | |
| 4961 TEST_F(GLES2DecoderManualInitTest, RenderbufferStorageMultisampleCHROMIUM) { | |
| 4962 InitState init; | |
| 4963 init.extensions = "GL_EXT_framebuffer_multisample"; | |
| 4964 init.gl_version = "2.1"; | |
| 4965 InitDecoder(init); | |
| 4966 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_, | |
| 4967 kServiceRenderbufferId); | |
| 4968 InSequence sequence; | |
| 4969 EXPECT_CALL(*gl_, GetError()) | |
| 4970 .WillOnce(Return(GL_NO_ERROR)) | |
| 4971 .RetiresOnSaturation(); | |
| 4972 EXPECT_CALL( | |
| 4973 *gl_, | |
| 4974 RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, | |
| 4975 TestHelper::kMaxSamples, | |
| 4976 GL_RGBA, | |
| 4977 TestHelper::kMaxRenderbufferSize, | |
| 4978 1)) | |
| 4979 .Times(1) | |
| 4980 .RetiresOnSaturation(); | |
| 4981 EXPECT_CALL(*gl_, GetError()) | |
| 4982 .WillOnce(Return(GL_NO_ERROR)) | |
| 4983 .RetiresOnSaturation(); | |
| 4984 RenderbufferStorageMultisampleCHROMIUM cmd; | |
| 4985 cmd.Init(GL_RENDERBUFFER, TestHelper::kMaxSamples, | |
| 4986 GL_RGBA4, TestHelper::kMaxRenderbufferSize, 1); | |
| 4987 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 4988 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 4989 } | |
| 4990 | |
| 4991 TEST_F(GLES2DecoderManualInitTest, | |
| 4992 RenderbufferStorageMultisampleEXTNotSupported) { | |
| 4993 InitState init; | |
| 4994 init.extensions = "GL_EXT_framebuffer_multisample"; | |
| 4995 init.gl_version = "2.1"; | |
| 4996 init.bind_generates_resource = true; | |
| 4997 InitDecoder(init); | |
| 4998 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_, | |
| 4999 kServiceRenderbufferId); | |
| 5000 InSequence sequence; | |
| 5001 // GL_EXT_framebuffer_multisample uses RenderbufferStorageMultisampleCHROMIUM. | |
| 5002 RenderbufferStorageMultisampleEXT cmd; | |
| 5003 cmd.Init(GL_RENDERBUFFER, TestHelper::kMaxSamples, | |
| 5004 GL_RGBA4, TestHelper::kMaxRenderbufferSize, 1); | |
| 5005 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 5006 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 5007 } | |
| 5008 | |
| 5009 class GLES2DecoderMultisampledRenderToTextureTest | |
| 5010 : public GLES2DecoderTestWithExtensionsOnGLES2 {}; | |
| 5011 | |
| 5012 TEST_P(GLES2DecoderMultisampledRenderToTextureTest, | |
| 5013 NotCompatibleWithRenderbufferStorageMultisampleCHROMIUM) { | |
| 5014 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_, | |
| 5015 kServiceRenderbufferId); | |
| 5016 RenderbufferStorageMultisampleCHROMIUM cmd; | |
| 5017 cmd.Init(GL_RENDERBUFFER, TestHelper::kMaxSamples, | |
| 5018 GL_RGBA4, TestHelper::kMaxRenderbufferSize, 1); | |
| 5019 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 5020 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 5021 } | |
| 5022 | |
| 5023 TEST_P(GLES2DecoderMultisampledRenderToTextureTest, | |
| 5024 RenderbufferStorageMultisampleEXT) { | |
| 5025 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_, | |
| 5026 kServiceRenderbufferId); | |
| 5027 InSequence sequence; | |
| 5028 EXPECT_CALL(*gl_, GetError()) | |
| 5029 .WillOnce(Return(GL_NO_ERROR)) | |
| 5030 .RetiresOnSaturation(); | |
| 5031 if (strstr(GetParam(), "GL_IMG_multisampled_render_to_texture")) { | |
| 5032 EXPECT_CALL( | |
| 5033 *gl_, | |
| 5034 RenderbufferStorageMultisampleIMG(GL_RENDERBUFFER, | |
| 5035 TestHelper::kMaxSamples, | |
| 5036 GL_RGBA, | |
| 5037 TestHelper::kMaxRenderbufferSize, | |
| 5038 1)) | |
| 5039 .Times(1) | |
| 5040 .RetiresOnSaturation(); | |
| 5041 } else { | |
| 5042 EXPECT_CALL( | |
| 5043 *gl_, | |
| 5044 RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, | |
| 5045 TestHelper::kMaxSamples, | |
| 5046 GL_RGBA, | |
| 5047 TestHelper::kMaxRenderbufferSize, | |
| 5048 1)) | |
| 5049 .Times(1) | |
| 5050 .RetiresOnSaturation(); | |
| 5051 } | |
| 5052 EXPECT_CALL(*gl_, GetError()) | |
| 5053 .WillOnce(Return(GL_NO_ERROR)) | |
| 5054 .RetiresOnSaturation(); | |
| 5055 RenderbufferStorageMultisampleEXT cmd; | |
| 5056 cmd.Init(GL_RENDERBUFFER, TestHelper::kMaxSamples, | |
| 5057 GL_RGBA4, TestHelper::kMaxRenderbufferSize, 1); | |
| 5058 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 5059 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5060 } | |
| 5061 | |
| 5062 INSTANTIATE_TEST_CASE_P( | |
| 5063 GLES2DecoderMultisampledRenderToTextureTests, | |
| 5064 GLES2DecoderMultisampledRenderToTextureTest, | |
| 5065 ::testing::Values("GL_EXT_multisampled_render_to_texture", | |
| 5066 "GL_IMG_multisampled_render_to_texture")); | |
| 5067 | |
| 5068 TEST_F(GLES2DecoderTest, ReadPixelsGLError) { | |
| 5069 GLenum kFormat = GL_RGBA; | |
| 5070 GLint x = 0; | |
| 5071 GLint y = 0; | |
| 5072 GLsizei width = 2; | |
| 5073 GLsizei height = 4; | |
| 5074 typedef ReadPixels::Result Result; | |
| 5075 Result* result = GetSharedMemoryAs<Result*>(); | |
| 5076 uint32 result_shm_id = kSharedMemoryId; | |
| 5077 uint32 result_shm_offset = kSharedMemoryOffset; | |
| 5078 uint32 pixels_shm_id = kSharedMemoryId; | |
| 5079 uint32 pixels_shm_offset = kSharedMemoryOffset + sizeof(*result); | |
| 5080 EXPECT_CALL(*gl_, GetError()) | |
| 5081 .WillOnce(Return(GL_NO_ERROR)) | |
| 5082 .WillOnce(Return(GL_OUT_OF_MEMORY)) | |
| 5083 .RetiresOnSaturation(); | |
| 5084 EXPECT_CALL( | |
| 5085 *gl_, ReadPixels(x, y, width, height, kFormat, GL_UNSIGNED_BYTE, _)) | |
| 5086 .Times(1) | |
| 5087 .RetiresOnSaturation(); | |
| 5088 ReadPixels cmd; | |
| 5089 cmd.Init(x, y, width, height, kFormat, GL_UNSIGNED_BYTE, | |
| 5090 pixels_shm_id, pixels_shm_offset, | |
| 5091 result_shm_id, result_shm_offset, | |
| 5092 false); | |
| 5093 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 5094 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); | |
| 5095 } | |
| 5096 | |
| 5097 TEST_F(GLES2DecoderCompressedFormatsTest, GetCompressedTextureFormatsS3TC) { | |
| 5098 const GLenum formats[] = { | |
| 5099 GL_COMPRESSED_RGB_S3TC_DXT1_EXT, | |
| 5100 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, | |
| 5101 GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, | |
| 5102 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT | |
| 5103 }; | |
| 5104 CheckFormats("GL_EXT_texture_compression_s3tc", formats, 4); | |
| 5105 } | |
| 5106 | |
| 5107 TEST_F(GLES2DecoderCompressedFormatsTest, GetCompressedTextureFormatsATC) { | |
| 5108 const GLenum formats[] = { | |
| 5109 GL_ATC_RGB_AMD, | |
| 5110 GL_ATC_RGBA_EXPLICIT_ALPHA_AMD, | |
| 5111 GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD | |
| 5112 }; | |
| 5113 CheckFormats("GL_AMD_compressed_ATC_texture", formats, 3); | |
| 5114 } | |
| 5115 | |
| 5116 TEST_F(GLES2DecoderCompressedFormatsTest, GetCompressedTextureFormatsPVRTC) { | |
| 5117 const GLenum formats[] = { | |
| 5118 GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG, | |
| 5119 GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG, | |
| 5120 GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, | |
| 5121 GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG | |
| 5122 }; | |
| 5123 CheckFormats("GL_IMG_texture_compression_pvrtc", formats, 4); | |
| 5124 } | |
| 5125 | |
| 5126 TEST_F(GLES2DecoderCompressedFormatsTest, GetCompressedTextureFormatsETC1) { | |
| 5127 const GLenum formats[] = { | |
| 5128 GL_ETC1_RGB8_OES | |
| 5129 }; | |
| 5130 CheckFormats("GL_OES_compressed_ETC1_RGB8_texture", formats, 1); | |
| 5131 } | |
| 5132 | |
| 5133 TEST_F(GLES2DecoderManualInitTest, GetNoCompressedTextureFormats) { | |
| 5134 InitState init; | |
| 5135 init.gl_version = "3.0"; | |
| 5136 init.bind_generates_resource = true; | |
| 5137 InitDecoder(init); | |
| 5138 | |
| 5139 EXPECT_CALL(*gl_, GetError()) | |
| 5140 .WillOnce(Return(GL_NO_ERROR)) | |
| 5141 .WillOnce(Return(GL_NO_ERROR)) | |
| 5142 .WillOnce(Return(GL_NO_ERROR)) | |
| 5143 .WillOnce(Return(GL_NO_ERROR)) | |
| 5144 .RetiresOnSaturation(); | |
| 5145 | |
| 5146 typedef GetIntegerv::Result Result; | |
| 5147 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 5148 GetIntegerv cmd; | |
| 5149 result->size = 0; | |
| 5150 EXPECT_CALL(*gl_, GetIntegerv(_, _)) | |
| 5151 .Times(0) | |
| 5152 .RetiresOnSaturation(); | |
| 5153 cmd.Init( | |
| 5154 GL_NUM_COMPRESSED_TEXTURE_FORMATS, | |
| 5155 shared_memory_id_, shared_memory_offset_); | |
| 5156 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 5157 EXPECT_EQ(1, result->GetNumResults()); | |
| 5158 GLint num_formats = result->GetData()[0]; | |
| 5159 EXPECT_EQ(0, num_formats); | |
| 5160 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5161 | |
| 5162 result->size = 0; | |
| 5163 cmd.Init( | |
| 5164 GL_COMPRESSED_TEXTURE_FORMATS, | |
| 5165 shared_memory_id_, shared_memory_offset_); | |
| 5166 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 5167 EXPECT_EQ(num_formats, result->GetNumResults()); | |
| 5168 | |
| 5169 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5170 } | |
| 5171 | |
| 5172 TEST_F(GLES2DecoderManualInitTest, CompressedTexImage2DBucketBadBucket) { | |
| 5173 InitState init; | |
| 5174 init.extensions = "GL_EXT_texture_compression_s3tc"; | |
| 5175 init.gl_version = "3.0"; | |
| 5176 init.bind_generates_resource = true; | |
| 5177 InitDecoder(init); | |
| 5178 | |
| 5179 const uint32 kBadBucketId = 123; | |
| 5180 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 5181 CompressedTexImage2DBucket cmd; | |
| 5182 cmd.Init( | |
| 5183 GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, 4, 4, 0, | |
| 5184 kBadBucketId); | |
| 5185 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 5186 CompressedTexSubImage2DBucket cmd2; | |
| 5187 cmd2.Init( | |
| 5188 GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, | |
| 5189 kBadBucketId); | |
| 5190 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 5191 } | |
| 5192 | |
| 5193 namespace { | |
| 5194 | |
| 5195 struct S3TCTestData { | |
| 5196 GLenum format; | |
| 5197 size_t block_size; | |
| 5198 }; | |
| 5199 | |
| 5200 } // anonymous namespace. | |
| 5201 | |
| 5202 TEST_F(GLES2DecoderManualInitTest, CompressedTexImage2DS3TC) { | |
| 5203 InitState init; | |
| 5204 init.extensions = "GL_EXT_texture_compression_s3tc"; | |
| 5205 init.gl_version = "3.0"; | |
| 5206 init.bind_generates_resource = true; | |
| 5207 InitDecoder(init); | |
| 5208 const uint32 kBucketId = 123; | |
| 5209 CommonDecoder::Bucket* bucket = decoder_->CreateBucket(kBucketId); | |
| 5210 ASSERT_TRUE(bucket != NULL); | |
| 5211 | |
| 5212 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 5213 | |
| 5214 static const S3TCTestData test_data[] = { | |
| 5215 { GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 8, }, | |
| 5216 { GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 8, }, | |
| 5217 { GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, 16, }, | |
| 5218 { GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, 16, }, | |
| 5219 }; | |
| 5220 | |
| 5221 for (size_t ii = 0; ii < arraysize(test_data); ++ii) { | |
| 5222 const S3TCTestData& test = test_data[ii]; | |
| 5223 CompressedTexImage2DBucket cmd; | |
| 5224 // test small width. | |
| 5225 DoCompressedTexImage2D( | |
| 5226 GL_TEXTURE_2D, 0, test.format, 2, 4, 0, test.block_size, | |
| 5227 kBucketId); | |
| 5228 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5229 | |
| 5230 // test bad width. | |
| 5231 cmd.Init( | |
| 5232 GL_TEXTURE_2D, 0, test.format, 5, 4, 0, | |
| 5233 kBucketId); | |
| 5234 bucket->SetSize(test.block_size * 2); | |
| 5235 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 5236 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 5237 | |
| 5238 // test small height. | |
| 5239 DoCompressedTexImage2D( | |
| 5240 GL_TEXTURE_2D, 0, test.format, 4, 2, 0, test.block_size, | |
| 5241 kBucketId); | |
| 5242 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5243 | |
| 5244 // test too bad height. | |
| 5245 cmd.Init( | |
| 5246 GL_TEXTURE_2D, 0, test.format, 4, 5, 0, | |
| 5247 kBucketId); | |
| 5248 bucket->SetSize(test.block_size * 2); | |
| 5249 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 5250 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 5251 | |
| 5252 // test small for level 0. | |
| 5253 DoCompressedTexImage2D( | |
| 5254 GL_TEXTURE_2D, 0, test.format, 1, 1, 0, test.block_size, | |
| 5255 kBucketId); | |
| 5256 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5257 | |
| 5258 // test small for level 0. | |
| 5259 DoCompressedTexImage2D( | |
| 5260 GL_TEXTURE_2D, 0, test.format, 2, 2, 0, test.block_size, | |
| 5261 kBucketId); | |
| 5262 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5263 | |
| 5264 // test size too large. | |
| 5265 cmd.Init( | |
| 5266 GL_TEXTURE_2D, 0, test.format, 4, 4, 0, | |
| 5267 kBucketId); | |
| 5268 bucket->SetSize(test.block_size * 2); | |
| 5269 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 5270 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 5271 | |
| 5272 // test size too small. | |
| 5273 cmd.Init( | |
| 5274 GL_TEXTURE_2D, 0, test.format, 4, 4, 0, | |
| 5275 kBucketId); | |
| 5276 bucket->SetSize(test.block_size / 2); | |
| 5277 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 5278 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 5279 | |
| 5280 // test with 3 mips. | |
| 5281 DoCompressedTexImage2D( | |
| 5282 GL_TEXTURE_2D, 0, test.format, 4, 4, 0, test.block_size, kBucketId); | |
| 5283 DoCompressedTexImage2D( | |
| 5284 GL_TEXTURE_2D, 1, test.format, 2, 2, 0, test.block_size, kBucketId); | |
| 5285 DoCompressedTexImage2D( | |
| 5286 GL_TEXTURE_2D, 2, test.format, 1, 1, 0, test.block_size, kBucketId); | |
| 5287 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5288 | |
| 5289 // Test a 16x16 | |
| 5290 DoCompressedTexImage2D( | |
| 5291 GL_TEXTURE_2D, 0, test.format, 16, 16, 0, test.block_size * 4 * 4, | |
| 5292 kBucketId); | |
| 5293 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5294 | |
| 5295 CompressedTexSubImage2DBucket sub_cmd; | |
| 5296 bucket->SetSize(test.block_size); | |
| 5297 // Test sub image bad xoffset | |
| 5298 sub_cmd.Init( | |
| 5299 GL_TEXTURE_2D, 0, 1, 0, 4, 4, test.format, kBucketId); | |
| 5300 EXPECT_EQ(error::kNoError, ExecuteCmd(sub_cmd)); | |
| 5301 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 5302 | |
| 5303 // Test sub image bad yoffset | |
| 5304 sub_cmd.Init( | |
| 5305 GL_TEXTURE_2D, 0, 0, 2, 4, 4, test.format, kBucketId); | |
| 5306 EXPECT_EQ(error::kNoError, ExecuteCmd(sub_cmd)); | |
| 5307 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 5308 | |
| 5309 // Test sub image bad width | |
| 5310 bucket->SetSize(test.block_size * 2); | |
| 5311 sub_cmd.Init( | |
| 5312 GL_TEXTURE_2D, 0, 0, 0, 5, 4, test.format, kBucketId); | |
| 5313 EXPECT_EQ(error::kNoError, ExecuteCmd(sub_cmd)); | |
| 5314 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 5315 | |
| 5316 // Test sub image bad height | |
| 5317 sub_cmd.Init( | |
| 5318 GL_TEXTURE_2D, 0, 0, 0, 4, 5, test.format, kBucketId); | |
| 5319 EXPECT_EQ(error::kNoError, ExecuteCmd(sub_cmd)); | |
| 5320 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 5321 | |
| 5322 // Test sub image bad size | |
| 5323 bucket->SetSize(test.block_size + 1); | |
| 5324 sub_cmd.Init( | |
| 5325 GL_TEXTURE_2D, 0, 0, 0, 4, 4, test.format, kBucketId); | |
| 5326 EXPECT_EQ(error::kNoError, ExecuteCmd(sub_cmd)); | |
| 5327 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 5328 | |
| 5329 for (GLint yoffset = 0; yoffset <= 8; yoffset += 4) { | |
| 5330 for (GLint xoffset = 0; xoffset <= 8; xoffset += 4) { | |
| 5331 for (GLsizei height = 4; height <= 8; height +=4 ) { | |
| 5332 for (GLsizei width = 4; width <= 8; width += 4) { | |
| 5333 GLsizei size = test.block_size * (width / 4) * (height / 4); | |
| 5334 bucket->SetSize(size); | |
| 5335 EXPECT_CALL(*gl_, CompressedTexSubImage2D( | |
| 5336 GL_TEXTURE_2D, 0, xoffset, yoffset, width, height, test.format, | |
| 5337 size, _)) | |
| 5338 .Times(1) | |
| 5339 .RetiresOnSaturation(); | |
| 5340 sub_cmd.Init( | |
| 5341 GL_TEXTURE_2D, 0, xoffset, yoffset, width, height, test.format, | |
| 5342 kBucketId); | |
| 5343 EXPECT_EQ(error::kNoError, ExecuteCmd(sub_cmd)); | |
| 5344 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5345 } | |
| 5346 } | |
| 5347 } | |
| 5348 } | |
| 5349 } | |
| 5350 } | |
| 5351 | |
| 5352 TEST_F(GLES2DecoderManualInitTest, CompressedTexImage2DETC1) { | |
| 5353 InitState init; | |
| 5354 init.extensions = "GL_OES_compressed_ETC1_RGB8_texture"; | |
| 5355 init.gl_version = "opengl es 2.0"; | |
| 5356 init.bind_generates_resource = true; | |
| 5357 InitDecoder(init); | |
| 5358 const uint32 kBucketId = 123; | |
| 5359 CommonDecoder::Bucket* bucket = decoder_->CreateBucket(kBucketId); | |
| 5360 ASSERT_TRUE(bucket != NULL); | |
| 5361 | |
| 5362 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 5363 | |
| 5364 const GLenum kFormat = GL_ETC1_RGB8_OES; | |
| 5365 const size_t kBlockSize = 8; | |
| 5366 | |
| 5367 CompressedTexImage2DBucket cmd; | |
| 5368 // test small width. | |
| 5369 DoCompressedTexImage2D(GL_TEXTURE_2D, 0, kFormat, 4, 8, 0, 16, kBucketId); | |
| 5370 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5371 | |
| 5372 // test small height. | |
| 5373 DoCompressedTexImage2D(GL_TEXTURE_2D, 0, kFormat, 8, 4, 0, 16, kBucketId); | |
| 5374 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5375 | |
| 5376 // test size too large. | |
| 5377 cmd.Init(GL_TEXTURE_2D, 0, kFormat, 4, 4, 0, kBucketId); | |
| 5378 bucket->SetSize(kBlockSize * 2); | |
| 5379 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 5380 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 5381 | |
| 5382 // test size too small. | |
| 5383 cmd.Init(GL_TEXTURE_2D, 0, kFormat, 4, 4, 0, kBucketId); | |
| 5384 bucket->SetSize(kBlockSize / 2); | |
| 5385 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 5386 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 5387 | |
| 5388 // Test a 16x16 | |
| 5389 DoCompressedTexImage2D( | |
| 5390 GL_TEXTURE_2D, 0, kFormat, 16, 16, 0, kBlockSize * 16, kBucketId); | |
| 5391 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5392 | |
| 5393 // Test CompressedTexSubImage not allowed | |
| 5394 CompressedTexSubImage2DBucket sub_cmd; | |
| 5395 bucket->SetSize(kBlockSize); | |
| 5396 sub_cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 4, 4, kFormat, kBucketId); | |
| 5397 EXPECT_EQ(error::kNoError, ExecuteCmd(sub_cmd)); | |
| 5398 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 5399 | |
| 5400 // Test TexSubImage not allowed for ETC1 compressed texture | |
| 5401 TextureRef* texture_ref = GetTexture(client_texture_id_); | |
| 5402 ASSERT_TRUE(texture_ref != NULL); | |
| 5403 Texture* texture = texture_ref->texture(); | |
| 5404 GLenum type, internal_format; | |
| 5405 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); | |
| 5406 EXPECT_EQ(kFormat, internal_format); | |
| 5407 TexSubImage2D texsub_cmd; | |
| 5408 texsub_cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 5409 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); | |
| 5410 EXPECT_EQ(error::kNoError, ExecuteCmd(texsub_cmd)); | |
| 5411 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 5412 | |
| 5413 // Test CopyTexSubImage not allowed for ETC1 compressed texture | |
| 5414 CopyTexSubImage2D copy_cmd; | |
| 5415 copy_cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 4, 4); | |
| 5416 EXPECT_EQ(error::kNoError, ExecuteCmd(copy_cmd)); | |
| 5417 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 5418 } | |
| 5419 | |
| 5420 TEST_F(GLES2DecoderWithShaderTest, GetProgramInfoCHROMIUMValidArgs) { | |
| 5421 const uint32 kBucketId = 123; | |
| 5422 GetProgramInfoCHROMIUM cmd; | |
| 5423 cmd.Init(client_program_id_, kBucketId); | |
| 5424 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 5425 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId); | |
| 5426 EXPECT_GT(bucket->size(), 0u); | |
| 5427 } | |
| 5428 | |
| 5429 TEST_F(GLES2DecoderWithShaderTest, GetProgramInfoCHROMIUMInvalidArgs) { | |
| 5430 const uint32 kBucketId = 123; | |
| 5431 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId); | |
| 5432 EXPECT_TRUE(bucket == NULL); | |
| 5433 GetProgramInfoCHROMIUM cmd; | |
| 5434 cmd.Init(kInvalidClientId, kBucketId); | |
| 5435 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 5436 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5437 bucket = decoder_->GetBucket(kBucketId); | |
| 5438 ASSERT_TRUE(bucket != NULL); | |
| 5439 EXPECT_EQ(sizeof(ProgramInfoHeader), bucket->size()); | |
| 5440 ProgramInfoHeader* info = bucket->GetDataAs<ProgramInfoHeader*>( | |
| 5441 0, sizeof(ProgramInfoHeader)); | |
| 5442 ASSERT_TRUE(info != 0); | |
| 5443 EXPECT_EQ(0u, info->link_status); | |
| 5444 EXPECT_EQ(0u, info->num_attribs); | |
| 5445 EXPECT_EQ(0u, info->num_uniforms); | |
| 5446 } | |
| 5447 | |
| 5448 TEST_F(GLES2DecoderManualInitTest, EGLImageExternalBindTexture) { | |
| 5449 InitState init; | |
| 5450 init.extensions = "GL_OES_EGL_image_external"; | |
| 5451 init.gl_version = "opengl es 2.0"; | |
| 5452 init.bind_generates_resource = true; | |
| 5453 InitDecoder(init); | |
| 5454 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_EXTERNAL_OES, kNewServiceId)); | |
| 5455 EXPECT_CALL(*gl_, GenTextures(1, _)) | |
| 5456 .WillOnce(SetArgumentPointee<1>(kNewServiceId)); | |
| 5457 BindTexture cmd; | |
| 5458 cmd.Init(GL_TEXTURE_EXTERNAL_OES, kNewClientId); | |
| 5459 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 5460 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5461 TextureRef* texture_ref = GetTexture(kNewClientId); | |
| 5462 EXPECT_TRUE(texture_ref != NULL); | |
| 5463 EXPECT_TRUE(texture_ref->texture()->target() == GL_TEXTURE_EXTERNAL_OES); | |
| 5464 } | |
| 5465 | |
| 5466 TEST_F(GLES2DecoderManualInitTest, EGLImageExternalGetBinding) { | |
| 5467 InitState init; | |
| 5468 init.extensions = "GL_OES_EGL_image_external"; | |
| 5469 init.gl_version = "opengl es 2.0"; | |
| 5470 init.bind_generates_resource = true; | |
| 5471 InitDecoder(init); | |
| 5472 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); | |
| 5473 | |
| 5474 EXPECT_CALL(*gl_, GetError()) | |
| 5475 .WillOnce(Return(GL_NO_ERROR)) | |
| 5476 .WillOnce(Return(GL_NO_ERROR)) | |
| 5477 .RetiresOnSaturation(); | |
| 5478 typedef GetIntegerv::Result Result; | |
| 5479 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 5480 EXPECT_CALL(*gl_, GetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES, | |
| 5481 result->GetData())) | |
| 5482 .Times(0); | |
| 5483 result->size = 0; | |
| 5484 GetIntegerv cmd; | |
| 5485 cmd.Init(GL_TEXTURE_BINDING_EXTERNAL_OES, | |
| 5486 shared_memory_id_, | |
| 5487 shared_memory_offset_); | |
| 5488 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 5489 EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned( | |
| 5490 GL_TEXTURE_BINDING_EXTERNAL_OES), result->GetNumResults()); | |
| 5491 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5492 EXPECT_EQ(client_texture_id_, (uint32)result->GetData()[0]); | |
| 5493 } | |
| 5494 | |
| 5495 TEST_F(GLES2DecoderManualInitTest, EGLImageExternalTextureDefaults) { | |
| 5496 InitState init; | |
| 5497 init.extensions = "GL_OES_EGL_image_external"; | |
| 5498 init.gl_version = "opengl es 2.0"; | |
| 5499 init.bind_generates_resource = true; | |
| 5500 InitDecoder(init); | |
| 5501 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); | |
| 5502 | |
| 5503 TextureRef* texture_ref = GetTexture(client_texture_id_); | |
| 5504 EXPECT_TRUE(texture_ref != NULL); | |
| 5505 Texture* texture = texture_ref->texture(); | |
| 5506 EXPECT_TRUE(texture->target() == GL_TEXTURE_EXTERNAL_OES); | |
| 5507 EXPECT_TRUE(texture->min_filter() == GL_LINEAR); | |
| 5508 EXPECT_TRUE(texture->wrap_s() == GL_CLAMP_TO_EDGE); | |
| 5509 EXPECT_TRUE(texture->wrap_t() == GL_CLAMP_TO_EDGE); | |
| 5510 } | |
| 5511 | |
| 5512 TEST_F(GLES2DecoderManualInitTest, EGLImageExternalTextureParam) { | |
| 5513 InitState init; | |
| 5514 init.extensions = "GL_OES_EGL_image_external"; | |
| 5515 init.gl_version = "opengl es 2.0"; | |
| 5516 init.bind_generates_resource = true; | |
| 5517 InitDecoder(init); | |
| 5518 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); | |
| 5519 | |
| 5520 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_EXTERNAL_OES, | |
| 5521 GL_TEXTURE_MIN_FILTER, | |
| 5522 GL_NEAREST)); | |
| 5523 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_EXTERNAL_OES, | |
| 5524 GL_TEXTURE_MIN_FILTER, | |
| 5525 GL_LINEAR)); | |
| 5526 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_EXTERNAL_OES, | |
| 5527 GL_TEXTURE_WRAP_S, | |
| 5528 GL_CLAMP_TO_EDGE)); | |
| 5529 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_EXTERNAL_OES, | |
| 5530 GL_TEXTURE_WRAP_T, | |
| 5531 GL_CLAMP_TO_EDGE)); | |
| 5532 TexParameteri cmd; | |
| 5533 cmd.Init(GL_TEXTURE_EXTERNAL_OES, | |
| 5534 GL_TEXTURE_MIN_FILTER, | |
| 5535 GL_NEAREST); | |
| 5536 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 5537 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5538 | |
| 5539 cmd.Init(GL_TEXTURE_EXTERNAL_OES, | |
| 5540 GL_TEXTURE_MIN_FILTER, | |
| 5541 GL_LINEAR); | |
| 5542 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 5543 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5544 | |
| 5545 cmd.Init(GL_TEXTURE_EXTERNAL_OES, | |
| 5546 GL_TEXTURE_WRAP_S, | |
| 5547 GL_CLAMP_TO_EDGE); | |
| 5548 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 5549 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5550 | |
| 5551 cmd.Init(GL_TEXTURE_EXTERNAL_OES, | |
| 5552 GL_TEXTURE_WRAP_T, | |
| 5553 GL_CLAMP_TO_EDGE); | |
| 5554 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 5555 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5556 | |
| 5557 TextureRef* texture_ref = GetTexture(client_texture_id_); | |
| 5558 EXPECT_TRUE(texture_ref != NULL); | |
| 5559 Texture* texture = texture_ref->texture(); | |
| 5560 EXPECT_TRUE(texture->target() == GL_TEXTURE_EXTERNAL_OES); | |
| 5561 EXPECT_TRUE(texture->min_filter() == GL_LINEAR); | |
| 5562 EXPECT_TRUE(texture->wrap_s() == GL_CLAMP_TO_EDGE); | |
| 5563 EXPECT_TRUE(texture->wrap_t() == GL_CLAMP_TO_EDGE); | |
| 5564 } | |
| 5565 | |
| 5566 TEST_F(GLES2DecoderManualInitTest, EGLImageExternalTextureParamInvalid) { | |
| 5567 InitState init; | |
| 5568 init.extensions = "GL_OES_EGL_image_external"; | |
| 5569 init.gl_version = "opengl es 2.0"; | |
| 5570 init.bind_generates_resource = true; | |
| 5571 InitDecoder(init); | |
| 5572 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); | |
| 5573 | |
| 5574 TexParameteri cmd; | |
| 5575 cmd.Init(GL_TEXTURE_EXTERNAL_OES, | |
| 5576 GL_TEXTURE_MIN_FILTER, | |
| 5577 GL_NEAREST_MIPMAP_NEAREST); | |
| 5578 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 5579 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | |
| 5580 | |
| 5581 cmd.Init(GL_TEXTURE_EXTERNAL_OES, | |
| 5582 GL_TEXTURE_WRAP_S, | |
| 5583 GL_REPEAT); | |
| 5584 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 5585 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | |
| 5586 | |
| 5587 cmd.Init(GL_TEXTURE_EXTERNAL_OES, | |
| 5588 GL_TEXTURE_WRAP_T, | |
| 5589 GL_REPEAT); | |
| 5590 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 5591 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | |
| 5592 | |
| 5593 TextureRef* texture_ref = GetTexture(client_texture_id_); | |
| 5594 EXPECT_TRUE(texture_ref != NULL); | |
| 5595 Texture* texture = texture_ref->texture(); | |
| 5596 EXPECT_TRUE(texture->target() == GL_TEXTURE_EXTERNAL_OES); | |
| 5597 EXPECT_TRUE(texture->min_filter() == GL_LINEAR); | |
| 5598 EXPECT_TRUE(texture->wrap_s() == GL_CLAMP_TO_EDGE); | |
| 5599 EXPECT_TRUE(texture->wrap_t() == GL_CLAMP_TO_EDGE); | |
| 5600 } | |
| 5601 | |
| 5602 TEST_F(GLES2DecoderManualInitTest, EGLImageExternalTexImage2DError) { | |
| 5603 InitState init; | |
| 5604 init.extensions = "GL_OES_EGL_image_external"; | |
| 5605 init.gl_version = "opengl es 2.0"; | |
| 5606 init.bind_generates_resource = true; | |
| 5607 InitDecoder(init); | |
| 5608 | |
| 5609 GLenum target = GL_TEXTURE_EXTERNAL_OES; | |
| 5610 GLint level = 0; | |
| 5611 GLenum internal_format = GL_RGBA; | |
| 5612 GLsizei width = 2; | |
| 5613 GLsizei height = 4; | |
| 5614 GLint border = 0; | |
| 5615 GLenum format = GL_RGBA; | |
| 5616 GLenum type = GL_UNSIGNED_BYTE; | |
| 5617 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); | |
| 5618 ASSERT_TRUE(GetTexture(client_texture_id_) != NULL); | |
| 5619 TexImage2D cmd; | |
| 5620 cmd.Init(target, level, internal_format, width, height, border, format, | |
| 5621 type, kSharedMemoryId, kSharedMemoryOffset); | |
| 5622 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 5623 | |
| 5624 // TexImage2D is not allowed with GL_TEXTURE_EXTERNAL_OES targets. | |
| 5625 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | |
| 5626 } | |
| 5627 | |
| 5628 TEST_F(GLES2DecoderManualInitTest, BindGeneratesResourceFalse) { | 515 TEST_F(GLES2DecoderManualInitTest, BindGeneratesResourceFalse) { |
| 5629 InitState init; | 516 InitState init; |
| 5630 init.gl_version = "3.0"; | 517 init.gl_version = "3.0"; |
| 5631 InitDecoder(init); | 518 InitDecoder(init); |
| 5632 | 519 |
| 5633 BindTexture cmd1; | 520 BindTexture cmd1; |
| 5634 cmd1.Init(GL_TEXTURE_2D, kInvalidClientId); | 521 cmd1.Init(GL_TEXTURE_2D, kInvalidClientId); |
| 5635 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); | 522 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); |
| 5636 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 523 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 5637 | 524 |
| 5638 BindBuffer cmd2; | 525 BindBuffer cmd2; |
| 5639 cmd2.Init(GL_ARRAY_BUFFER, kInvalidClientId); | 526 cmd2.Init(GL_ARRAY_BUFFER, kInvalidClientId); |
| 5640 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | 527 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |
| 5641 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 528 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 5642 | 529 |
| 5643 BindFramebuffer cmd3; | 530 BindFramebuffer cmd3; |
| 5644 cmd3.Init(GL_FRAMEBUFFER, kInvalidClientId); | 531 cmd3.Init(GL_FRAMEBUFFER, kInvalidClientId); |
| 5645 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd3)); | 532 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd3)); |
| 5646 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 533 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 5647 | 534 |
| 5648 BindRenderbuffer cmd4; | 535 BindRenderbuffer cmd4; |
| 5649 cmd4.Init(GL_RENDERBUFFER, kInvalidClientId); | 536 cmd4.Init(GL_RENDERBUFFER, kInvalidClientId); |
| 5650 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd4)); | 537 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd4)); |
| 5651 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 538 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 5652 } | 539 } |
| 5653 | 540 |
| 5654 TEST_F(GLES2DecoderManualInitTest, DefaultTextureZero) { | |
| 5655 InitState init; | |
| 5656 init.gl_version = "3.0"; | |
| 5657 InitDecoder(init); | |
| 5658 | |
| 5659 BindTexture cmd1; | |
| 5660 cmd1.Init(GL_TEXTURE_2D, 0); | |
| 5661 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0)); | |
| 5662 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); | |
| 5663 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5664 | |
| 5665 BindTexture cmd2; | |
| 5666 cmd2.Init(GL_TEXTURE_CUBE_MAP, 0); | |
| 5667 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_CUBE_MAP, 0)); | |
| 5668 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 5669 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5670 } | |
| 5671 | |
| 5672 TEST_F(GLES2DecoderManualInitTest, DefaultTextureBGR) { | |
| 5673 InitState init; | |
| 5674 init.gl_version = "3.0"; | |
| 5675 init.bind_generates_resource = true; | |
| 5676 InitDecoder(init); | |
| 5677 | |
| 5678 BindTexture cmd1; | |
| 5679 cmd1.Init(GL_TEXTURE_2D, 0); | |
| 5680 EXPECT_CALL( | |
| 5681 *gl_, BindTexture(GL_TEXTURE_2D, TestHelper::kServiceDefaultTexture2dId)); | |
| 5682 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); | |
| 5683 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5684 | |
| 5685 BindTexture cmd2; | |
| 5686 cmd2.Init(GL_TEXTURE_CUBE_MAP, 0); | |
| 5687 EXPECT_CALL(*gl_, | |
| 5688 BindTexture(GL_TEXTURE_CUBE_MAP, | |
| 5689 TestHelper::kServiceDefaultTextureCubemapId)); | |
| 5690 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 5691 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5692 } | |
| 5693 | |
| 5694 // Test that default texture 0 is immutable. | |
| 5695 TEST_F(GLES2DecoderManualInitTest, NoDefaultTexParameterf) { | |
| 5696 InitState init; | |
| 5697 init.gl_version = "3.0"; | |
| 5698 InitDecoder(init); | |
| 5699 | |
| 5700 { | |
| 5701 BindTexture cmd1; | |
| 5702 cmd1.Init(GL_TEXTURE_2D, 0); | |
| 5703 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0)); | |
| 5704 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); | |
| 5705 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5706 | |
| 5707 TexParameterf cmd2; | |
| 5708 cmd2.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | |
| 5709 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 5710 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 5711 } | |
| 5712 | |
| 5713 { | |
| 5714 BindTexture cmd1; | |
| 5715 cmd1.Init(GL_TEXTURE_CUBE_MAP, 0); | |
| 5716 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_CUBE_MAP, 0)); | |
| 5717 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); | |
| 5718 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5719 | |
| 5720 TexParameterf cmd2; | |
| 5721 cmd2.Init(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | |
| 5722 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 5723 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 5724 } | |
| 5725 } | |
| 5726 | |
| 5727 TEST_F(GLES2DecoderManualInitTest, NoDefaultTexParameteri) { | |
| 5728 InitState init; | |
| 5729 init.gl_version = "3.0"; | |
| 5730 InitDecoder(init); | |
| 5731 | |
| 5732 { | |
| 5733 BindTexture cmd1; | |
| 5734 cmd1.Init(GL_TEXTURE_2D, 0); | |
| 5735 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0)); | |
| 5736 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); | |
| 5737 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5738 | |
| 5739 TexParameteri cmd2; | |
| 5740 cmd2.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | |
| 5741 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 5742 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 5743 } | |
| 5744 | |
| 5745 { | |
| 5746 BindTexture cmd1; | |
| 5747 cmd1.Init(GL_TEXTURE_CUBE_MAP, 0); | |
| 5748 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_CUBE_MAP, 0)); | |
| 5749 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); | |
| 5750 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5751 | |
| 5752 TexParameteri cmd2; | |
| 5753 cmd2.Init(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | |
| 5754 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 5755 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 5756 } | |
| 5757 } | |
| 5758 | |
| 5759 TEST_F(GLES2DecoderManualInitTest, NoDefaultTexParameterfv) { | |
| 5760 InitState init; | |
| 5761 init.gl_version = "3.0"; | |
| 5762 InitDecoder(init); | |
| 5763 | |
| 5764 { | |
| 5765 BindTexture cmd1; | |
| 5766 cmd1.Init(GL_TEXTURE_2D, 0); | |
| 5767 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0)); | |
| 5768 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); | |
| 5769 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5770 | |
| 5771 TexParameterfv cmd2; | |
| 5772 cmd2.Init(GL_TEXTURE_2D, | |
| 5773 GL_TEXTURE_MAG_FILTER, | |
| 5774 shared_memory_id_, | |
| 5775 shared_memory_offset_); | |
| 5776 GetSharedMemoryAs<GLfloat*>()[0] = GL_NEAREST; | |
| 5777 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 5778 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 5779 } | |
| 5780 | |
| 5781 { | |
| 5782 BindTexture cmd1; | |
| 5783 cmd1.Init(GL_TEXTURE_CUBE_MAP, 0); | |
| 5784 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_CUBE_MAP, 0)); | |
| 5785 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); | |
| 5786 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5787 | |
| 5788 TexParameterfv cmd2; | |
| 5789 cmd2.Init(GL_TEXTURE_CUBE_MAP, | |
| 5790 GL_TEXTURE_MAG_FILTER, | |
| 5791 shared_memory_id_, | |
| 5792 shared_memory_offset_); | |
| 5793 GetSharedMemoryAs<GLfloat*>()[0] = GL_NEAREST; | |
| 5794 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 5795 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 5796 } | |
| 5797 } | |
| 5798 | |
| 5799 TEST_F(GLES2DecoderManualInitTest, NoDefaultTexParameteriv) { | |
| 5800 InitState init; | |
| 5801 init.gl_version = "3.0"; | |
| 5802 InitDecoder(init); | |
| 5803 | |
| 5804 { | |
| 5805 BindTexture cmd1; | |
| 5806 cmd1.Init(GL_TEXTURE_2D, 0); | |
| 5807 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0)); | |
| 5808 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); | |
| 5809 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5810 | |
| 5811 TexParameteriv cmd2; | |
| 5812 cmd2.Init(GL_TEXTURE_2D, | |
| 5813 GL_TEXTURE_MAG_FILTER, | |
| 5814 shared_memory_id_, | |
| 5815 shared_memory_offset_); | |
| 5816 GetSharedMemoryAs<GLint*>()[0] = GL_NEAREST; | |
| 5817 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 5818 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 5819 } | |
| 5820 | |
| 5821 { | |
| 5822 BindTexture cmd1; | |
| 5823 cmd1.Init(GL_TEXTURE_CUBE_MAP, 0); | |
| 5824 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_CUBE_MAP, 0)); | |
| 5825 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); | |
| 5826 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5827 | |
| 5828 TexParameteriv cmd2; | |
| 5829 cmd2.Init(GL_TEXTURE_CUBE_MAP, | |
| 5830 GL_TEXTURE_MAG_FILTER, | |
| 5831 shared_memory_id_, | |
| 5832 shared_memory_offset_); | |
| 5833 GetSharedMemoryAs<GLint*>()[0] = GL_NEAREST; | |
| 5834 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 5835 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 5836 } | |
| 5837 } | |
| 5838 | |
| 5839 TEST_F(GLES2DecoderManualInitTest, NoDefaultTexImage2D) { | |
| 5840 InitState init; | |
| 5841 init.gl_version = "3.0"; | |
| 5842 InitDecoder(init); | |
| 5843 | |
| 5844 BindTexture cmd1; | |
| 5845 cmd1.Init(GL_TEXTURE_2D, 0); | |
| 5846 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0)); | |
| 5847 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); | |
| 5848 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5849 | |
| 5850 TexImage2D cmd2; | |
| 5851 cmd2.Init(GL_TEXTURE_2D, | |
| 5852 0, | |
| 5853 GL_RGBA, | |
| 5854 2, | |
| 5855 2, | |
| 5856 0, | |
| 5857 GL_RGBA, | |
| 5858 GL_UNSIGNED_BYTE, | |
| 5859 kSharedMemoryId, | |
| 5860 kSharedMemoryOffset); | |
| 5861 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 5862 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 5863 } | |
| 5864 | |
| 5865 TEST_F(GLES2DecoderManualInitTest, NoDefaultTexSubImage2D) { | |
| 5866 InitState init; | |
| 5867 init.gl_version = "3.0"; | |
| 5868 InitDecoder(init); | |
| 5869 | |
| 5870 BindTexture cmd1; | |
| 5871 cmd1.Init(GL_TEXTURE_2D, 0); | |
| 5872 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0)); | |
| 5873 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); | |
| 5874 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5875 | |
| 5876 TexSubImage2D cmd2; | |
| 5877 cmd2.Init(GL_TEXTURE_2D, | |
| 5878 0, | |
| 5879 1, | |
| 5880 1, | |
| 5881 1, | |
| 5882 1, | |
| 5883 GL_RGBA, | |
| 5884 GL_UNSIGNED_BYTE, | |
| 5885 kSharedMemoryId, | |
| 5886 kSharedMemoryOffset, | |
| 5887 GL_FALSE); | |
| 5888 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
| 5889 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 5890 } | |
| 5891 | |
| 5892 TEST_F(GLES2DecoderManualInitTest, ARBTextureRectangleBindTexture) { | |
| 5893 InitState init; | |
| 5894 init.extensions = "GL_ARB_texture_rectangle"; | |
| 5895 init.gl_version = "3.0"; | |
| 5896 init.bind_generates_resource = true; | |
| 5897 InitDecoder(init); | |
| 5898 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_RECTANGLE_ARB, kNewServiceId)); | |
| 5899 EXPECT_CALL(*gl_, GenTextures(1, _)) | |
| 5900 .WillOnce(SetArgumentPointee<1>(kNewServiceId)); | |
| 5901 BindTexture cmd; | |
| 5902 cmd.Init(GL_TEXTURE_RECTANGLE_ARB, kNewClientId); | |
| 5903 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 5904 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5905 Texture* texture = GetTexture(kNewClientId)->texture(); | |
| 5906 EXPECT_TRUE(texture != NULL); | |
| 5907 EXPECT_TRUE(texture->target() == GL_TEXTURE_RECTANGLE_ARB); | |
| 5908 } | |
| 5909 | |
| 5910 TEST_F(GLES2DecoderManualInitTest, ARBTextureRectangleGetBinding) { | |
| 5911 InitState init; | |
| 5912 init.extensions = "GL_ARB_texture_rectangle"; | |
| 5913 init.gl_version = "3.0"; | |
| 5914 init.bind_generates_resource = true; | |
| 5915 InitDecoder(init); | |
| 5916 DoBindTexture( | |
| 5917 GL_TEXTURE_RECTANGLE_ARB, client_texture_id_, kServiceTextureId); | |
| 5918 | |
| 5919 EXPECT_CALL(*gl_, GetError()) | |
| 5920 .WillOnce(Return(GL_NO_ERROR)) | |
| 5921 .WillOnce(Return(GL_NO_ERROR)) | |
| 5922 .RetiresOnSaturation(); | |
| 5923 typedef GetIntegerv::Result Result; | |
| 5924 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 5925 EXPECT_CALL(*gl_, GetIntegerv(GL_TEXTURE_BINDING_RECTANGLE_ARB, | |
| 5926 result->GetData())) | |
| 5927 .Times(0); | |
| 5928 result->size = 0; | |
| 5929 GetIntegerv cmd; | |
| 5930 cmd.Init(GL_TEXTURE_BINDING_RECTANGLE_ARB, | |
| 5931 shared_memory_id_, | |
| 5932 shared_memory_offset_); | |
| 5933 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 5934 EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned( | |
| 5935 GL_TEXTURE_BINDING_RECTANGLE_ARB), result->GetNumResults()); | |
| 5936 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5937 EXPECT_EQ(client_texture_id_, (uint32)result->GetData()[0]); | |
| 5938 } | |
| 5939 | |
| 5940 TEST_F(GLES2DecoderManualInitTest, ARBTextureRectangleTextureDefaults) { | |
| 5941 InitState init; | |
| 5942 init.extensions = "GL_ARB_texture_rectangle"; | |
| 5943 init.gl_version = "3.0"; | |
| 5944 init.bind_generates_resource = true; | |
| 5945 InitDecoder(init); | |
| 5946 DoBindTexture( | |
| 5947 GL_TEXTURE_RECTANGLE_ARB, client_texture_id_, kServiceTextureId); | |
| 5948 | |
| 5949 Texture* texture = GetTexture(client_texture_id_)->texture(); | |
| 5950 EXPECT_TRUE(texture != NULL); | |
| 5951 EXPECT_TRUE(texture->target() == GL_TEXTURE_RECTANGLE_ARB); | |
| 5952 EXPECT_TRUE(texture->min_filter() == GL_LINEAR); | |
| 5953 EXPECT_TRUE(texture->wrap_s() == GL_CLAMP_TO_EDGE); | |
| 5954 EXPECT_TRUE(texture->wrap_t() == GL_CLAMP_TO_EDGE); | |
| 5955 } | |
| 5956 | |
| 5957 TEST_F(GLES2DecoderManualInitTest, ARBTextureRectangleTextureParam) { | |
| 5958 InitState init; | |
| 5959 init.extensions = "GL_ARB_texture_rectangle"; | |
| 5960 init.gl_version = "3.0"; | |
| 5961 init.bind_generates_resource = true; | |
| 5962 InitDecoder(init); | |
| 5963 | |
| 5964 DoBindTexture( | |
| 5965 GL_TEXTURE_RECTANGLE_ARB, client_texture_id_, kServiceTextureId); | |
| 5966 | |
| 5967 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_RECTANGLE_ARB, | |
| 5968 GL_TEXTURE_MIN_FILTER, | |
| 5969 GL_NEAREST)); | |
| 5970 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_RECTANGLE_ARB, | |
| 5971 GL_TEXTURE_MIN_FILTER, | |
| 5972 GL_LINEAR)); | |
| 5973 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_RECTANGLE_ARB, | |
| 5974 GL_TEXTURE_WRAP_S, | |
| 5975 GL_CLAMP_TO_EDGE)); | |
| 5976 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_RECTANGLE_ARB, | |
| 5977 GL_TEXTURE_WRAP_T, | |
| 5978 GL_CLAMP_TO_EDGE)); | |
| 5979 TexParameteri cmd; | |
| 5980 cmd.Init(GL_TEXTURE_RECTANGLE_ARB, | |
| 5981 GL_TEXTURE_MIN_FILTER, | |
| 5982 GL_NEAREST); | |
| 5983 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 5984 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5985 | |
| 5986 cmd.Init(GL_TEXTURE_RECTANGLE_ARB, | |
| 5987 GL_TEXTURE_MIN_FILTER, | |
| 5988 GL_LINEAR); | |
| 5989 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 5990 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5991 | |
| 5992 cmd.Init(GL_TEXTURE_RECTANGLE_ARB, | |
| 5993 GL_TEXTURE_WRAP_S, | |
| 5994 GL_CLAMP_TO_EDGE); | |
| 5995 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 5996 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5997 | |
| 5998 cmd.Init(GL_TEXTURE_RECTANGLE_ARB, | |
| 5999 GL_TEXTURE_WRAP_T, | |
| 6000 GL_CLAMP_TO_EDGE); | |
| 6001 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 6002 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 6003 | |
| 6004 Texture* texture = GetTexture(client_texture_id_)->texture(); | |
| 6005 EXPECT_TRUE(texture != NULL); | |
| 6006 EXPECT_TRUE(texture->target() == GL_TEXTURE_RECTANGLE_ARB); | |
| 6007 EXPECT_TRUE(texture->min_filter() == GL_LINEAR); | |
| 6008 EXPECT_TRUE(texture->wrap_s() == GL_CLAMP_TO_EDGE); | |
| 6009 EXPECT_TRUE(texture->wrap_t() == GL_CLAMP_TO_EDGE); | |
| 6010 } | |
| 6011 | |
| 6012 TEST_F(GLES2DecoderManualInitTest, ARBTextureRectangleTextureParamInvalid) { | |
| 6013 InitState init; | |
| 6014 init.extensions = "GL_ARB_texture_rectangle"; | |
| 6015 init.gl_version = "3.0"; | |
| 6016 init.bind_generates_resource = true; | |
| 6017 InitDecoder(init); | |
| 6018 | |
| 6019 DoBindTexture( | |
| 6020 GL_TEXTURE_RECTANGLE_ARB, client_texture_id_, kServiceTextureId); | |
| 6021 | |
| 6022 TexParameteri cmd; | |
| 6023 cmd.Init(GL_TEXTURE_RECTANGLE_ARB, | |
| 6024 GL_TEXTURE_MIN_FILTER, | |
| 6025 GL_NEAREST_MIPMAP_NEAREST); | |
| 6026 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 6027 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | |
| 6028 | |
| 6029 cmd.Init(GL_TEXTURE_RECTANGLE_ARB, | |
| 6030 GL_TEXTURE_WRAP_S, | |
| 6031 GL_REPEAT); | |
| 6032 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 6033 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | |
| 6034 | |
| 6035 cmd.Init(GL_TEXTURE_RECTANGLE_ARB, | |
| 6036 GL_TEXTURE_WRAP_T, | |
| 6037 GL_REPEAT); | |
| 6038 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 6039 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | |
| 6040 | |
| 6041 Texture* texture = GetTexture(client_texture_id_)->texture(); | |
| 6042 EXPECT_TRUE(texture != NULL); | |
| 6043 EXPECT_TRUE(texture->target() == GL_TEXTURE_RECTANGLE_ARB); | |
| 6044 EXPECT_TRUE(texture->min_filter() == GL_LINEAR); | |
| 6045 EXPECT_TRUE(texture->wrap_s() == GL_CLAMP_TO_EDGE); | |
| 6046 EXPECT_TRUE(texture->wrap_t() == GL_CLAMP_TO_EDGE); | |
| 6047 } | |
| 6048 | |
| 6049 TEST_F(GLES2DecoderManualInitTest, ARBTextureRectangleTexImage2DError) { | |
| 6050 InitState init; | |
| 6051 init.extensions = "GL_ARB_texture_rectangle"; | |
| 6052 init.gl_version = "3.0"; | |
| 6053 init.bind_generates_resource = true; | |
| 6054 InitDecoder(init); | |
| 6055 | |
| 6056 GLenum target = GL_TEXTURE_RECTANGLE_ARB; | |
| 6057 GLint level = 0; | |
| 6058 GLenum internal_format = GL_RGBA; | |
| 6059 GLsizei width = 2; | |
| 6060 GLsizei height = 4; | |
| 6061 GLint border = 0; | |
| 6062 GLenum format = GL_RGBA; | |
| 6063 GLenum type = GL_UNSIGNED_BYTE; | |
| 6064 DoBindTexture( | |
| 6065 GL_TEXTURE_RECTANGLE_ARB, client_texture_id_, kServiceTextureId); | |
| 6066 ASSERT_TRUE(GetTexture(client_texture_id_) != NULL); | |
| 6067 TexImage2D cmd; | |
| 6068 cmd.Init(target, level, internal_format, width, height, border, format, | |
| 6069 type, kSharedMemoryId, kSharedMemoryOffset); | |
| 6070 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 6071 | |
| 6072 // TexImage2D is not allowed with GL_TEXTURE_RECTANGLE_ARB targets. | |
| 6073 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | |
| 6074 } | |
| 6075 | |
| 6076 TEST_F(GLES2DecoderTest, EnableFeatureCHROMIUMBadBucket) { | 541 TEST_F(GLES2DecoderTest, EnableFeatureCHROMIUMBadBucket) { |
| 6077 const uint32 kBadBucketId = 123; | 542 const uint32 kBadBucketId = 123; |
| 6078 EnableFeatureCHROMIUM cmd; | 543 EnableFeatureCHROMIUM cmd; |
| 6079 cmd.Init(kBadBucketId, shared_memory_id_, shared_memory_offset_); | 544 cmd.Init(kBadBucketId, shared_memory_id_, shared_memory_offset_); |
| 6080 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | 545 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
| 6081 } | 546 } |
| 6082 | 547 |
| 6083 TEST_F(GLES2DecoderTest, RequestExtensionCHROMIUMBadBucket) { | 548 TEST_F(GLES2DecoderTest, RequestExtensionCHROMIUMBadBucket) { |
| 6084 const uint32 kBadBucketId = 123; | 549 const uint32 kBadBucketId = 123; |
| 6085 RequestExtensionCHROMIUM cmd; | 550 RequestExtensionCHROMIUM cmd; |
| 6086 cmd.Init(kBadBucketId); | 551 cmd.Init(kBadBucketId); |
| 6087 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | 552 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
| 6088 } | 553 } |
| 6089 | 554 |
| 6090 TEST_F(GLES2DecoderTest, TexSubImage2DClearsAfterTexImage2DNULL) { | |
| 6091 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 6092 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 6093 0, 0); | |
| 6094 SetupClearTextureExpectations( | |
| 6095 kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D, | |
| 6096 0, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2); | |
| 6097 EXPECT_CALL(*gl_, TexSubImage2D( | |
| 6098 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 6099 shared_memory_address_)) | |
| 6100 .Times(1) | |
| 6101 .RetiresOnSaturation(); | |
| 6102 TexSubImage2D cmd; | |
| 6103 cmd.Init( | |
| 6104 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 6105 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); | |
| 6106 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 6107 // Test if we call it again it does not clear. | |
| 6108 EXPECT_CALL(*gl_, TexSubImage2D( | |
| 6109 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 6110 shared_memory_address_)) | |
| 6111 .Times(1) | |
| 6112 .RetiresOnSaturation(); | |
| 6113 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 6114 } | |
| 6115 | |
| 6116 TEST_F(GLES2DecoderTest, TexSubImage2DDoesNotClearAfterTexImage2DNULLThenData) { | |
| 6117 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 6118 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 6119 0, 0); | |
| 6120 DoTexImage2D( | |
| 6121 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 6122 kSharedMemoryId, kSharedMemoryOffset); | |
| 6123 EXPECT_CALL(*gl_, TexSubImage2D( | |
| 6124 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 6125 shared_memory_address_)) | |
| 6126 .Times(1) | |
| 6127 .RetiresOnSaturation(); | |
| 6128 TexSubImage2D cmd; | |
| 6129 cmd.Init( | |
| 6130 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 6131 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); | |
| 6132 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 6133 // Test if we call it again it does not clear. | |
| 6134 EXPECT_CALL(*gl_, TexSubImage2D( | |
| 6135 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 6136 shared_memory_address_)) | |
| 6137 .Times(1) | |
| 6138 .RetiresOnSaturation(); | |
| 6139 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 6140 } | |
| 6141 | |
| 6142 TEST_F( | |
| 6143 GLES2DecoderManualInitTest, | |
| 6144 TexSubImage2DDoesNotClearAfterTexImage2DNULLThenDataWithTexImage2DIsFaster)
{ | |
| 6145 CommandLine command_line(0, NULL); | |
| 6146 command_line.AppendSwitchASCII( | |
| 6147 switches::kGpuDriverBugWorkarounds, | |
| 6148 base::IntToString(gpu::TEXSUBIMAGE2D_FASTER_THAN_TEXIMAGE2D)); | |
| 6149 InitState init; | |
| 6150 init.gl_version = "3.0"; | |
| 6151 init.bind_generates_resource = true; | |
| 6152 InitDecoderWithCommandLine(init, &command_line); | |
| 6153 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 6154 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 6155 0, 0); | |
| 6156 | |
| 6157 { | |
| 6158 // Uses texSubimage internally because the above workaround is active and | |
| 6159 // the update is for the full size of the texture. | |
| 6160 EXPECT_CALL(*gl_, | |
| 6161 TexSubImage2D( | |
| 6162 GL_TEXTURE_2D, 0, 0, 0, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, _)) | |
| 6163 .Times(1) | |
| 6164 .RetiresOnSaturation(); | |
| 6165 cmds::TexImage2D cmd; | |
| 6166 cmd.Init(GL_TEXTURE_2D, | |
| 6167 0, | |
| 6168 GL_RGBA, | |
| 6169 2, | |
| 6170 2, | |
| 6171 0, | |
| 6172 GL_RGBA, | |
| 6173 GL_UNSIGNED_BYTE, | |
| 6174 kSharedMemoryId, | |
| 6175 kSharedMemoryOffset); | |
| 6176 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 6177 } | |
| 6178 | |
| 6179 EXPECT_CALL(*gl_, TexSubImage2D( | |
| 6180 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 6181 shared_memory_address_)) | |
| 6182 .Times(1) | |
| 6183 .RetiresOnSaturation(); | |
| 6184 TexSubImage2D cmd; | |
| 6185 cmd.Init( | |
| 6186 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 6187 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); | |
| 6188 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 6189 // Test if we call it again it does not clear. | |
| 6190 EXPECT_CALL(*gl_, TexSubImage2D( | |
| 6191 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 6192 shared_memory_address_)) | |
| 6193 .Times(1) | |
| 6194 .RetiresOnSaturation(); | |
| 6195 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 6196 } | |
| 6197 | |
| 6198 TEST_F(GLES2DecoderTest, TexSubImage2DClearsAfterTexImage2DWithDataThenNULL) { | |
| 6199 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 6200 // Put in data (so it should be marked as cleared) | |
| 6201 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 6202 kSharedMemoryId, kSharedMemoryOffset); | |
| 6203 // Put in no data. | |
| 6204 TexImage2D tex_cmd; | |
| 6205 tex_cmd.Init( | |
| 6206 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); | |
| 6207 // It won't actually call TexImage2D, just mark it as uncleared. | |
| 6208 EXPECT_EQ(error::kNoError, ExecuteCmd(tex_cmd)); | |
| 6209 // Next call to TexSubImage2d should clear. | |
| 6210 SetupClearTextureExpectations( | |
| 6211 kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D, | |
| 6212 0, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2); | |
| 6213 EXPECT_CALL(*gl_, TexSubImage2D( | |
| 6214 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 6215 shared_memory_address_)) | |
| 6216 .Times(1) | |
| 6217 .RetiresOnSaturation(); | |
| 6218 TexSubImage2D cmd; | |
| 6219 cmd.Init( | |
| 6220 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 6221 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); | |
| 6222 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 6223 } | |
| 6224 | |
| 6225 TEST_F(GLES2DecoderWithShaderTest, DrawArraysClearsAfterTexImage2DNULL) { | |
| 6226 SetupAllNeededVertexBuffers(); | |
| 6227 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 6228 // Create an uncleared texture with 2 levels. | |
| 6229 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 6230 0, 0); | |
| 6231 DoTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 6232 0, 0); | |
| 6233 // Expect 2 levels will be cleared. | |
| 6234 SetupClearTextureExpectations( | |
| 6235 kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D, | |
| 6236 0, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2); | |
| 6237 SetupClearTextureExpectations( | |
| 6238 kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D, | |
| 6239 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 1, 1); | |
| 6240 SetupExpectationsForApplyingDefaultDirtyState(); | |
| 6241 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | |
| 6242 .Times(1) | |
| 6243 .RetiresOnSaturation(); | |
| 6244 DrawArrays cmd; | |
| 6245 cmd.Init(GL_TRIANGLES, 0, kNumVertices); | |
| 6246 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 6247 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 6248 | |
| 6249 // But not again | |
| 6250 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | |
| 6251 .Times(1) | |
| 6252 .RetiresOnSaturation(); | |
| 6253 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 6254 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 6255 } | |
| 6256 | |
| 6257 TEST_F(GLES2DecoderWithShaderTest, DrawElementsClearsAfterTexImage2DNULL) { | |
| 6258 SetupAllNeededVertexBuffers(); | |
| 6259 SetupIndexBuffer(); | |
| 6260 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 6261 // Create an uncleared texture with 2 levels. | |
| 6262 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 6263 0, 0); | |
| 6264 DoTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 6265 0, 0); | |
| 6266 // Expect 2 levels will be cleared. | |
| 6267 SetupClearTextureExpectations( | |
| 6268 kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D, | |
| 6269 0, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2); | |
| 6270 SetupClearTextureExpectations( | |
| 6271 kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D, | |
| 6272 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 1, 1); | |
| 6273 SetupExpectationsForApplyingDefaultDirtyState(); | |
| 6274 | |
| 6275 EXPECT_CALL(*gl_, DrawElements(GL_TRIANGLES, kValidIndexRangeCount, | |
| 6276 GL_UNSIGNED_SHORT, | |
| 6277 BufferOffset(kValidIndexRangeStart * 2))) | |
| 6278 .Times(1) | |
| 6279 .RetiresOnSaturation(); | |
| 6280 DrawElements cmd; | |
| 6281 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, | |
| 6282 kValidIndexRangeStart * 2); | |
| 6283 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 6284 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 6285 | |
| 6286 // But not again | |
| 6287 EXPECT_CALL(*gl_, DrawElements(GL_TRIANGLES, kValidIndexRangeCount, | |
| 6288 GL_UNSIGNED_SHORT, | |
| 6289 BufferOffset(kValidIndexRangeStart * 2))) | |
| 6290 .Times(1) | |
| 6291 .RetiresOnSaturation(); | |
| 6292 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 6293 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 6294 } | |
| 6295 | |
| 6296 TEST_F(GLES2DecoderWithShaderTest, DrawClearsAfterTexImage2DNULLInFBO) { | |
| 6297 const GLuint kFBOClientTextureId = 4100; | |
| 6298 const GLuint kFBOServiceTextureId = 4101; | |
| 6299 | |
| 6300 SetupAllNeededVertexBuffers(); | |
| 6301 // Register a texture id. | |
| 6302 EXPECT_CALL(*gl_, GenTextures(_, _)) | |
| 6303 .WillOnce(SetArgumentPointee<1>(kFBOServiceTextureId)) | |
| 6304 .RetiresOnSaturation(); | |
| 6305 GenHelper<GenTexturesImmediate>(kFBOClientTextureId); | |
| 6306 | |
| 6307 // Setup "render to" texture. | |
| 6308 DoBindTexture(GL_TEXTURE_2D, kFBOClientTextureId, kFBOServiceTextureId); | |
| 6309 DoTexImage2D( | |
| 6310 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); | |
| 6311 DoBindFramebuffer( | |
| 6312 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); | |
| 6313 DoFramebufferTexture2D( | |
| 6314 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, | |
| 6315 kFBOClientTextureId, kFBOServiceTextureId, 0, GL_NO_ERROR); | |
| 6316 | |
| 6317 // Setup "render from" texture. | |
| 6318 SetupTexture(); | |
| 6319 | |
| 6320 SetupExpectationsForFramebufferClearing( | |
| 6321 GL_FRAMEBUFFER, // target | |
| 6322 GL_COLOR_BUFFER_BIT, // clear bits | |
| 6323 0, 0, 0, 0, // color | |
| 6324 0, // stencil | |
| 6325 1.0f, // depth | |
| 6326 false); // scissor test | |
| 6327 | |
| 6328 SetupExpectationsForApplyingDirtyState( | |
| 6329 false, // Framebuffer is RGB | |
| 6330 false, // Framebuffer has depth | |
| 6331 false, // Framebuffer has stencil | |
| 6332 0x1111, // color bits | |
| 6333 false, // depth mask | |
| 6334 false, // depth enabled | |
| 6335 0, // front stencil mask | |
| 6336 0, // back stencil mask | |
| 6337 false, // stencil enabled | |
| 6338 false, // cull_face_enabled | |
| 6339 false, // scissor_test_enabled | |
| 6340 false); // blend_enabled | |
| 6341 | |
| 6342 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | |
| 6343 .Times(1) | |
| 6344 .RetiresOnSaturation(); | |
| 6345 DrawArrays cmd; | |
| 6346 cmd.Init(GL_TRIANGLES, 0, kNumVertices); | |
| 6347 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 6348 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 6349 | |
| 6350 // But not again. | |
| 6351 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | |
| 6352 .Times(1) | |
| 6353 .RetiresOnSaturation(); | |
| 6354 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 6355 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 6356 } | |
| 6357 | |
| 6358 TEST_F(GLES2DecoderWithShaderTest, DrawWitFBOThatCantClearDoesNotDraw) { | |
| 6359 const GLuint kFBOClientTextureId = 4100; | |
| 6360 const GLuint kFBOServiceTextureId = 4101; | |
| 6361 | |
| 6362 // Register a texture id. | |
| 6363 EXPECT_CALL(*gl_, GenTextures(_, _)) | |
| 6364 .WillOnce(SetArgumentPointee<1>(kFBOServiceTextureId)) | |
| 6365 .RetiresOnSaturation(); | |
| 6366 GenHelper<GenTexturesImmediate>(kFBOClientTextureId); | |
| 6367 | |
| 6368 // Setup "render to" texture. | |
| 6369 DoBindTexture(GL_TEXTURE_2D, kFBOClientTextureId, kFBOServiceTextureId); | |
| 6370 DoTexImage2D( | |
| 6371 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); | |
| 6372 DoBindFramebuffer( | |
| 6373 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); | |
| 6374 DoFramebufferTexture2D( | |
| 6375 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, | |
| 6376 kFBOClientTextureId, kFBOServiceTextureId, 0, GL_NO_ERROR); | |
| 6377 | |
| 6378 // Setup "render from" texture. | |
| 6379 SetupTexture(); | |
| 6380 | |
| 6381 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) | |
| 6382 .WillOnce(Return(GL_FRAMEBUFFER_UNSUPPORTED)) | |
| 6383 .RetiresOnSaturation(); | |
| 6384 EXPECT_CALL(*gl_, DrawArrays(_, _, _)) | |
| 6385 .Times(0) | |
| 6386 .RetiresOnSaturation(); | |
| 6387 DrawArrays cmd; | |
| 6388 cmd.Init(GL_TRIANGLES, 0, kNumVertices); | |
| 6389 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 6390 EXPECT_EQ(GL_INVALID_FRAMEBUFFER_OPERATION, GetGLError()); | |
| 6391 } | |
| 6392 | |
| 6393 TEST_F(GLES2DecoderTest, CopyTexImage2DMarksTextureAsCleared) { | |
| 6394 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 6395 | |
| 6396 TextureManager* manager = group().texture_manager(); | |
| 6397 TextureRef* texture_ref = manager->GetTexture(client_texture_id_); | |
| 6398 ASSERT_TRUE(texture_ref != NULL); | |
| 6399 Texture* texture = texture_ref->texture(); | |
| 6400 | |
| 6401 EXPECT_CALL(*gl_, GetError()) | |
| 6402 .WillOnce(Return(GL_NO_ERROR)) | |
| 6403 .RetiresOnSaturation(); | |
| 6404 EXPECT_CALL(*gl_, CopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 1, 1, 0)) | |
| 6405 .Times(1) | |
| 6406 .RetiresOnSaturation(); | |
| 6407 EXPECT_CALL(*gl_, GetError()) | |
| 6408 .WillOnce(Return(GL_NO_ERROR)) | |
| 6409 .RetiresOnSaturation(); | |
| 6410 CopyTexImage2D cmd; | |
| 6411 cmd.Init(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 1, 1, 0); | |
| 6412 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 6413 | |
| 6414 EXPECT_TRUE(texture->SafeToRenderFrom()); | |
| 6415 } | |
| 6416 | |
| 6417 TEST_F(GLES2DecoderTest, CopyTexSubImage2DClearsUnclearedTexture) { | |
| 6418 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 6419 DoTexImage2D( | |
| 6420 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); | |
| 6421 | |
| 6422 SetupClearTextureExpectations( | |
| 6423 kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D, | |
| 6424 0, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2); | |
| 6425 EXPECT_CALL(*gl_, CopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 1, 1)) | |
| 6426 .Times(1) | |
| 6427 .RetiresOnSaturation(); | |
| 6428 CopyTexSubImage2D cmd; | |
| 6429 cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 1, 1); | |
| 6430 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 6431 } | |
| 6432 | |
| 6433 TEST_F(GLES2DecoderManualInitTest, CompressedImage2DMarksTextureAsCleared) { | |
| 6434 InitState init; | |
| 6435 init.extensions = "GL_EXT_texture_compression_s3tc"; | |
| 6436 init.gl_version = "3.0"; | |
| 6437 init.bind_generates_resource = true; | |
| 6438 InitDecoder(init); | |
| 6439 | |
| 6440 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 6441 EXPECT_CALL(*gl_, GetError()) | |
| 6442 .WillOnce(Return(GL_NO_ERROR)) | |
| 6443 .RetiresOnSaturation(); | |
| 6444 EXPECT_CALL(*gl_, CompressedTexImage2D( | |
| 6445 GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 4, 4, 0, 8, _)) | |
| 6446 .Times(1) | |
| 6447 .RetiresOnSaturation(); | |
| 6448 EXPECT_CALL(*gl_, GetError()) | |
| 6449 .WillOnce(Return(GL_NO_ERROR)) | |
| 6450 .RetiresOnSaturation(); | |
| 6451 CompressedTexImage2D cmd; | |
| 6452 cmd.Init(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 4, 4, 0, | |
| 6453 8, kSharedMemoryId, kSharedMemoryOffset); | |
| 6454 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 6455 TextureManager* manager = group().texture_manager(); | |
| 6456 TextureRef* texture_ref = manager->GetTexture(client_texture_id_); | |
| 6457 EXPECT_TRUE(texture_ref->texture()->SafeToRenderFrom()); | |
| 6458 } | |
| 6459 | |
| 6460 TEST_F(GLES2DecoderWithShaderTest, UnClearedAttachmentsGetClearedOnClear) { | |
| 6461 const GLuint kFBOClientTextureId = 4100; | |
| 6462 const GLuint kFBOServiceTextureId = 4101; | |
| 6463 | |
| 6464 // Register a texture id. | |
| 6465 EXPECT_CALL(*gl_, GenTextures(_, _)) | |
| 6466 .WillOnce(SetArgumentPointee<1>(kFBOServiceTextureId)) | |
| 6467 .RetiresOnSaturation(); | |
| 6468 GenHelper<GenTexturesImmediate>(kFBOClientTextureId); | |
| 6469 | |
| 6470 // Setup "render to" texture. | |
| 6471 DoBindTexture(GL_TEXTURE_2D, kFBOClientTextureId, kFBOServiceTextureId); | |
| 6472 DoTexImage2D( | |
| 6473 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); | |
| 6474 DoBindFramebuffer( | |
| 6475 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); | |
| 6476 DoFramebufferTexture2D( | |
| 6477 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, | |
| 6478 kFBOClientTextureId, kFBOServiceTextureId, 0, GL_NO_ERROR); | |
| 6479 | |
| 6480 // Setup "render from" texture. | |
| 6481 SetupTexture(); | |
| 6482 | |
| 6483 SetupExpectationsForFramebufferClearing( | |
| 6484 GL_FRAMEBUFFER, // target | |
| 6485 GL_COLOR_BUFFER_BIT, // clear bits | |
| 6486 0, 0, 0, 0, // color | |
| 6487 0, // stencil | |
| 6488 1.0f, // depth | |
| 6489 false); // scissor test | |
| 6490 SetupExpectationsForApplyingDirtyState( | |
| 6491 false, // Framebuffer is RGB | |
| 6492 false, // Framebuffer has depth | |
| 6493 false, // Framebuffer has stencil | |
| 6494 0x1111, // color bits | |
| 6495 false, // depth mask | |
| 6496 false, // depth enabled | |
| 6497 0, // front stencil mask | |
| 6498 0, // back stencil mask | |
| 6499 false, // stencil enabled | |
| 6500 false, // cull_face_enabled | |
| 6501 false, // scissor_test_enabled | |
| 6502 false); // blend_enabled | |
| 6503 | |
| 6504 EXPECT_CALL(*gl_, Clear(GL_COLOR_BUFFER_BIT)) | |
| 6505 .Times(1) | |
| 6506 .RetiresOnSaturation(); | |
| 6507 | |
| 6508 Clear cmd; | |
| 6509 cmd.Init(GL_COLOR_BUFFER_BIT); | |
| 6510 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 6511 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 6512 } | |
| 6513 | |
| 6514 TEST_F(GLES2DecoderWithShaderTest, UnClearedAttachmentsGetClearedOnReadPixels) { | |
| 6515 const GLuint kFBOClientTextureId = 4100; | |
| 6516 const GLuint kFBOServiceTextureId = 4101; | |
| 6517 | |
| 6518 // Register a texture id. | |
| 6519 EXPECT_CALL(*gl_, GenTextures(_, _)) | |
| 6520 .WillOnce(SetArgumentPointee<1>(kFBOServiceTextureId)) | |
| 6521 .RetiresOnSaturation(); | |
| 6522 GenHelper<GenTexturesImmediate>(kFBOClientTextureId); | |
| 6523 | |
| 6524 // Setup "render to" texture. | |
| 6525 DoBindTexture(GL_TEXTURE_2D, kFBOClientTextureId, kFBOServiceTextureId); | |
| 6526 DoTexImage2D( | |
| 6527 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); | |
| 6528 DoBindFramebuffer( | |
| 6529 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); | |
| 6530 DoFramebufferTexture2D( | |
| 6531 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, | |
| 6532 kFBOClientTextureId, kFBOServiceTextureId, 0, GL_NO_ERROR); | |
| 6533 | |
| 6534 // Setup "render from" texture. | |
| 6535 SetupTexture(); | |
| 6536 | |
| 6537 SetupExpectationsForFramebufferClearing( | |
| 6538 GL_FRAMEBUFFER, // target | |
| 6539 GL_COLOR_BUFFER_BIT, // clear bits | |
| 6540 0, 0, 0, 0, // color | |
| 6541 0, // stencil | |
| 6542 1.0f, // depth | |
| 6543 false); // scissor test | |
| 6544 | |
| 6545 EXPECT_CALL(*gl_, GetError()) | |
| 6546 .WillOnce(Return(GL_NO_ERROR)) | |
| 6547 .WillOnce(Return(GL_NO_ERROR)) | |
| 6548 .RetiresOnSaturation(); | |
| 6549 EXPECT_CALL(*gl_, ReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, _)) | |
| 6550 .Times(1) | |
| 6551 .RetiresOnSaturation(); | |
| 6552 typedef ReadPixels::Result Result; | |
| 6553 Result* result = GetSharedMemoryAs<Result*>(); | |
| 6554 uint32 result_shm_id = kSharedMemoryId; | |
| 6555 uint32 result_shm_offset = kSharedMemoryOffset; | |
| 6556 uint32 pixels_shm_id = kSharedMemoryId; | |
| 6557 uint32 pixels_shm_offset = kSharedMemoryOffset + sizeof(*result); | |
| 6558 ReadPixels cmd; | |
| 6559 cmd.Init(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 6560 pixels_shm_id, pixels_shm_offset, | |
| 6561 result_shm_id, result_shm_offset, | |
| 6562 false); | |
| 6563 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 6564 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 6565 } | |
| 6566 | |
| 6567 TEST_F(GLES2DecoderManualInitTest, | |
| 6568 UnClearedAttachmentsGetClearedOnReadPixelsAndDrawBufferGetsRestored) { | |
| 6569 InitState init; | |
| 6570 init.extensions = "GL_EXT_framebuffer_multisample"; | |
| 6571 init.gl_version = "2.1"; | |
| 6572 init.bind_generates_resource = true; | |
| 6573 InitDecoder(init); | |
| 6574 const GLuint kFBOClientTextureId = 4100; | |
| 6575 const GLuint kFBOServiceTextureId = 4101; | |
| 6576 | |
| 6577 // Register a texture id. | |
| 6578 EXPECT_CALL(*gl_, GenTextures(_, _)) | |
| 6579 .WillOnce(SetArgumentPointee<1>(kFBOServiceTextureId)) | |
| 6580 .RetiresOnSaturation(); | |
| 6581 GenHelper<GenTexturesImmediate>(kFBOClientTextureId); | |
| 6582 | |
| 6583 // Setup "render from" texture. | |
| 6584 DoBindTexture(GL_TEXTURE_2D, kFBOClientTextureId, kFBOServiceTextureId); | |
| 6585 DoTexImage2D( | |
| 6586 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); | |
| 6587 DoBindFramebuffer( | |
| 6588 GL_READ_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); | |
| 6589 DoFramebufferTexture2D( | |
| 6590 GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, | |
| 6591 kFBOClientTextureId, kFBOServiceTextureId, 0, GL_NO_ERROR); | |
| 6592 | |
| 6593 SetupExpectationsForFramebufferClearingMulti( | |
| 6594 kServiceFramebufferId, // read framebuffer service id | |
| 6595 0, // backbuffer service id | |
| 6596 GL_READ_FRAMEBUFFER, // target | |
| 6597 GL_COLOR_BUFFER_BIT, // clear bits | |
| 6598 0, 0, 0, 0, // color | |
| 6599 0, // stencil | |
| 6600 1.0f, // depth | |
| 6601 false); // scissor test | |
| 6602 | |
| 6603 EXPECT_CALL(*gl_, GetError()) | |
| 6604 .WillOnce(Return(GL_NO_ERROR)) | |
| 6605 .WillOnce(Return(GL_NO_ERROR)) | |
| 6606 .RetiresOnSaturation(); | |
| 6607 EXPECT_CALL(*gl_, ReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, _)) | |
| 6608 .Times(1) | |
| 6609 .RetiresOnSaturation(); | |
| 6610 typedef ReadPixels::Result Result; | |
| 6611 uint32 result_shm_id = kSharedMemoryId; | |
| 6612 uint32 result_shm_offset = kSharedMemoryOffset; | |
| 6613 uint32 pixels_shm_id = kSharedMemoryId; | |
| 6614 uint32 pixels_shm_offset = kSharedMemoryOffset + sizeof(Result); | |
| 6615 ReadPixels cmd; | |
| 6616 cmd.Init(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 6617 pixels_shm_id, pixels_shm_offset, | |
| 6618 result_shm_id, result_shm_offset, | |
| 6619 false); | |
| 6620 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 6621 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 6622 } | |
| 6623 | |
| 6624 TEST_F(GLES2DecoderWithShaderTest, DrawClearsAfterRenderbufferStorageInFBO) { | |
| 6625 SetupTexture(); | |
| 6626 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_, | |
| 6627 kServiceRenderbufferId); | |
| 6628 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, | |
| 6629 kServiceFramebufferId); | |
| 6630 DoRenderbufferStorage( | |
| 6631 GL_RENDERBUFFER, GL_RGBA4, GL_RGBA, 100, 50, GL_NO_ERROR); | |
| 6632 DoFramebufferRenderbuffer( | |
| 6633 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, | |
| 6634 client_renderbuffer_id_, kServiceRenderbufferId, GL_NO_ERROR); | |
| 6635 | |
| 6636 SetupExpectationsForFramebufferClearing( | |
| 6637 GL_FRAMEBUFFER, // target | |
| 6638 GL_COLOR_BUFFER_BIT, // clear bits | |
| 6639 0, 0, 0, 0, // color | |
| 6640 0, // stencil | |
| 6641 1.0f, // depth | |
| 6642 false); // scissor test | |
| 6643 | |
| 6644 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); | |
| 6645 SetupExpectationsForApplyingDirtyState( | |
| 6646 false, // Framebuffer is RGB | |
| 6647 false, // Framebuffer has depth | |
| 6648 false, // Framebuffer has stencil | |
| 6649 0x1111, // color bits | |
| 6650 false, // depth mask | |
| 6651 false, // depth enabled | |
| 6652 0, // front stencil mask | |
| 6653 0, // back stencil mask | |
| 6654 false, // stencil enabled | |
| 6655 false, // cull_face_enabled | |
| 6656 false, // scissor_test_enabled | |
| 6657 false); // blend_enabled | |
| 6658 | |
| 6659 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | |
| 6660 .Times(1) | |
| 6661 .RetiresOnSaturation(); | |
| 6662 DrawArrays cmd; | |
| 6663 cmd.Init(GL_TRIANGLES, 0, kNumVertices); | |
| 6664 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 6665 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 6666 } | |
| 6667 | |
| 6668 TEST_F(GLES2DecoderTest, DrawArraysClearsAfterTexImage2DNULLCubemap) { | |
| 6669 static const GLenum faces[] = { | |
| 6670 GL_TEXTURE_CUBE_MAP_POSITIVE_X, | |
| 6671 GL_TEXTURE_CUBE_MAP_NEGATIVE_X, | |
| 6672 GL_TEXTURE_CUBE_MAP_POSITIVE_Y, | |
| 6673 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, | |
| 6674 GL_TEXTURE_CUBE_MAP_POSITIVE_Z, | |
| 6675 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, | |
| 6676 }; | |
| 6677 SetupCubemapProgram(); | |
| 6678 DoBindTexture(GL_TEXTURE_CUBE_MAP, client_texture_id_, kServiceTextureId); | |
| 6679 // Fill out all the faces for 2 levels, leave 2 uncleared. | |
| 6680 for (int ii = 0; ii < 6; ++ii) { | |
| 6681 GLenum face = faces[ii]; | |
| 6682 int32 shm_id = | |
| 6683 (face == GL_TEXTURE_CUBE_MAP_NEGATIVE_Y) ? 0 : kSharedMemoryId; | |
| 6684 uint32 shm_offset = | |
| 6685 (face == GL_TEXTURE_CUBE_MAP_NEGATIVE_Y) ? 0 : kSharedMemoryOffset; | |
| 6686 DoTexImage2D(face, 0, GL_RGBA, 2, 2, 0, GL_RGBA, | |
| 6687 GL_UNSIGNED_BYTE, shm_id, shm_offset); | |
| 6688 DoTexImage2D(face, 1, GL_RGBA, 1, 1, 0, GL_RGBA, | |
| 6689 GL_UNSIGNED_BYTE, shm_id, shm_offset); | |
| 6690 } | |
| 6691 // Expect 2 levels will be cleared. | |
| 6692 SetupClearTextureExpectations( | |
| 6693 kServiceTextureId, kServiceTextureId, GL_TEXTURE_CUBE_MAP, | |
| 6694 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 6695 2, 2); | |
| 6696 SetupClearTextureExpectations( | |
| 6697 kServiceTextureId, kServiceTextureId, GL_TEXTURE_CUBE_MAP, | |
| 6698 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 6699 1, 1); | |
| 6700 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); | |
| 6701 SetupExpectationsForApplyingDefaultDirtyState(); | |
| 6702 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | |
| 6703 .Times(1) | |
| 6704 .RetiresOnSaturation(); | |
| 6705 DrawArrays cmd; | |
| 6706 cmd.Init(GL_TRIANGLES, 0, kNumVertices); | |
| 6707 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 6708 } | |
| 6709 | |
| 6710 TEST_F(GLES2DecoderTest, TextureUsageAngleExtNotEnabledByDefault) { | |
| 6711 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 6712 | |
| 6713 TexParameteri cmd; | |
| 6714 cmd.Init(GL_TEXTURE_2D, | |
| 6715 GL_TEXTURE_USAGE_ANGLE, | |
| 6716 GL_FRAMEBUFFER_ATTACHMENT_ANGLE); | |
| 6717 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 6718 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | |
| 6719 } | |
| 6720 | |
| 6721 TEST_F(GLES2DecoderWithShaderTest, | |
| 6722 DrawClearsAfterRenderbuffersWithMultipleAttachments) { | |
| 6723 const GLuint kFBOClientTextureId = 4100; | |
| 6724 const GLuint kFBOServiceTextureId = 4101; | |
| 6725 | |
| 6726 // Register a texture id. | |
| 6727 EXPECT_CALL(*gl_, GenTextures(_, _)) | |
| 6728 .WillOnce(SetArgumentPointee<1>(kFBOServiceTextureId)) | |
| 6729 .RetiresOnSaturation(); | |
| 6730 GenHelper<GenTexturesImmediate>(kFBOClientTextureId); | |
| 6731 | |
| 6732 // Setup "render to" texture. | |
| 6733 DoBindTexture(GL_TEXTURE_2D, kFBOClientTextureId, kFBOServiceTextureId); | |
| 6734 DoTexImage2D( | |
| 6735 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); | |
| 6736 DoBindFramebuffer( | |
| 6737 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); | |
| 6738 DoFramebufferTexture2D( | |
| 6739 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, | |
| 6740 kFBOClientTextureId, kFBOServiceTextureId, 0, GL_NO_ERROR); | |
| 6741 | |
| 6742 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_, | |
| 6743 kServiceRenderbufferId); | |
| 6744 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, | |
| 6745 kServiceFramebufferId); | |
| 6746 DoRenderbufferStorage( | |
| 6747 GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, | |
| 6748 1, 1, GL_NO_ERROR); | |
| 6749 DoFramebufferRenderbuffer( | |
| 6750 GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, | |
| 6751 client_renderbuffer_id_, kServiceRenderbufferId, GL_NO_ERROR); | |
| 6752 | |
| 6753 SetupTexture(); | |
| 6754 SetupExpectationsForFramebufferClearing( | |
| 6755 GL_FRAMEBUFFER, // target | |
| 6756 GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, // clear bits | |
| 6757 0, 0, 0, 0, // color | |
| 6758 0, // stencil | |
| 6759 1.0f, // depth | |
| 6760 false); // scissor test | |
| 6761 | |
| 6762 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); | |
| 6763 SetupExpectationsForApplyingDirtyState( | |
| 6764 false, // Framebuffer is RGB | |
| 6765 true, // Framebuffer has depth | |
| 6766 false, // Framebuffer has stencil | |
| 6767 0x1111, // color bits | |
| 6768 true, // depth mask | |
| 6769 false, // depth enabled | |
| 6770 0, // front stencil mask | |
| 6771 0, // back stencil mask | |
| 6772 false, // stencil enabled | |
| 6773 false, // cull_face_enabled | |
| 6774 false, // scissor_test_enabled | |
| 6775 false); // blend_enabled | |
| 6776 | |
| 6777 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | |
| 6778 .Times(1) | |
| 6779 .RetiresOnSaturation(); | |
| 6780 DrawArrays cmd; | |
| 6781 cmd.Init(GL_TRIANGLES, 0, kNumVertices); | |
| 6782 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 6783 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 6784 } | |
| 6785 | |
| 6786 TEST_F(GLES2DecoderWithShaderTest, CopyTexImageWithInCompleteFBOFails) { | |
| 6787 GLenum target = GL_TEXTURE_2D; | |
| 6788 GLint level = 0; | |
| 6789 GLenum internal_format = GL_RGBA; | |
| 6790 GLsizei width = 2; | |
| 6791 GLsizei height = 4; | |
| 6792 GLint border = 0; | |
| 6793 SetupTexture(); | |
| 6794 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_, | |
| 6795 kServiceRenderbufferId); | |
| 6796 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, | |
| 6797 kServiceFramebufferId); | |
| 6798 DoRenderbufferStorage( | |
| 6799 GL_RENDERBUFFER, GL_RGBA4, GL_RGBA, 0, 0, GL_NO_ERROR); | |
| 6800 DoFramebufferRenderbuffer( | |
| 6801 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, | |
| 6802 client_renderbuffer_id_, kServiceRenderbufferId, GL_NO_ERROR); | |
| 6803 | |
| 6804 EXPECT_CALL(*gl_, CopyTexImage2D(_, _, _, _, _, _, _, _)) | |
| 6805 .Times(0) | |
| 6806 .RetiresOnSaturation(); | |
| 6807 CopyTexImage2D cmd; | |
| 6808 cmd.Init(target, level, internal_format, 0, 0, width, height, border); | |
| 6809 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 6810 EXPECT_EQ(GL_INVALID_FRAMEBUFFER_OPERATION, GetGLError()); | |
| 6811 } | |
| 6812 | |
| 6813 void GLES2DecoderWithShaderTest::CheckRenderbufferChangesMarkFBOAsNotComplete( | |
| 6814 bool bound_fbo) { | |
| 6815 FramebufferManager* framebuffer_manager = group().framebuffer_manager(); | |
| 6816 SetupTexture(); | |
| 6817 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_, | |
| 6818 kServiceRenderbufferId); | |
| 6819 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, | |
| 6820 kServiceFramebufferId); | |
| 6821 DoRenderbufferStorage( | |
| 6822 GL_RENDERBUFFER, GL_RGBA4, GL_RGBA, 1, 1, GL_NO_ERROR); | |
| 6823 DoFramebufferRenderbuffer( | |
| 6824 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, | |
| 6825 client_renderbuffer_id_, kServiceRenderbufferId, GL_NO_ERROR); | |
| 6826 | |
| 6827 | |
| 6828 if (!bound_fbo) { | |
| 6829 DoBindFramebuffer(GL_FRAMEBUFFER, 0, 0); | |
| 6830 } | |
| 6831 | |
| 6832 Framebuffer* framebuffer = | |
| 6833 framebuffer_manager->GetFramebuffer(client_framebuffer_id_); | |
| 6834 ASSERT_TRUE(framebuffer != NULL); | |
| 6835 framebuffer_manager->MarkAsComplete(framebuffer); | |
| 6836 EXPECT_TRUE(framebuffer_manager->IsComplete(framebuffer)); | |
| 6837 | |
| 6838 // Test that renderbufferStorage marks fbo as not complete. | |
| 6839 DoRenderbufferStorage( | |
| 6840 GL_RENDERBUFFER, GL_RGBA4, GL_RGBA, 1, 1, GL_NO_ERROR); | |
| 6841 EXPECT_FALSE(framebuffer_manager->IsComplete(framebuffer)); | |
| 6842 framebuffer_manager->MarkAsComplete(framebuffer); | |
| 6843 EXPECT_TRUE(framebuffer_manager->IsComplete(framebuffer)); | |
| 6844 | |
| 6845 // Test deleting renderbuffer marks fbo as not complete. | |
| 6846 DoDeleteRenderbuffer(client_renderbuffer_id_, kServiceRenderbufferId); | |
| 6847 if (bound_fbo) { | |
| 6848 EXPECT_FALSE(framebuffer_manager->IsComplete(framebuffer)); | |
| 6849 } else { | |
| 6850 EXPECT_TRUE(framebuffer_manager->IsComplete(framebuffer)); | |
| 6851 } | |
| 6852 // Cleanup | |
| 6853 DoDeleteFramebuffer( | |
| 6854 client_framebuffer_id_, kServiceFramebufferId, | |
| 6855 bound_fbo, GL_FRAMEBUFFER, 0, | |
| 6856 bound_fbo, GL_FRAMEBUFFER, 0); | |
| 6857 } | |
| 6858 | |
| 6859 TEST_F(GLES2DecoderWithShaderTest, | |
| 6860 RenderbufferChangesMarkFBOAsNotCompleteBoundFBO) { | |
| 6861 CheckRenderbufferChangesMarkFBOAsNotComplete(true); | |
| 6862 } | |
| 6863 | |
| 6864 TEST_F(GLES2DecoderWithShaderTest, | |
| 6865 RenderbufferChangesMarkFBOAsNotCompleteUnboundFBO) { | |
| 6866 CheckRenderbufferChangesMarkFBOAsNotComplete(false); | |
| 6867 } | |
| 6868 | |
| 6869 void GLES2DecoderWithShaderTest::CheckTextureChangesMarkFBOAsNotComplete( | |
| 6870 bool bound_fbo) { | |
| 6871 FramebufferManager* framebuffer_manager = group().framebuffer_manager(); | |
| 6872 const GLuint kFBOClientTextureId = 4100; | |
| 6873 const GLuint kFBOServiceTextureId = 4101; | |
| 6874 | |
| 6875 // Register a texture id. | |
| 6876 EXPECT_CALL(*gl_, GenTextures(_, _)) | |
| 6877 .WillOnce(SetArgumentPointee<1>(kFBOServiceTextureId)) | |
| 6878 .RetiresOnSaturation(); | |
| 6879 GenHelper<GenTexturesImmediate>(kFBOClientTextureId); | |
| 6880 | |
| 6881 SetupTexture(); | |
| 6882 | |
| 6883 // Setup "render to" texture. | |
| 6884 DoBindTexture(GL_TEXTURE_2D, kFBOClientTextureId, kFBOServiceTextureId); | |
| 6885 DoTexImage2D( | |
| 6886 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); | |
| 6887 DoBindFramebuffer( | |
| 6888 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); | |
| 6889 DoFramebufferTexture2D( | |
| 6890 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, | |
| 6891 kFBOClientTextureId, kFBOServiceTextureId, 0, GL_NO_ERROR); | |
| 6892 | |
| 6893 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_, | |
| 6894 kServiceRenderbufferId); | |
| 6895 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, | |
| 6896 kServiceFramebufferId); | |
| 6897 DoRenderbufferStorage( | |
| 6898 GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, | |
| 6899 1, 1, GL_NO_ERROR); | |
| 6900 DoFramebufferRenderbuffer( | |
| 6901 GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, | |
| 6902 client_renderbuffer_id_, kServiceRenderbufferId, GL_NO_ERROR); | |
| 6903 | |
| 6904 if (!bound_fbo) { | |
| 6905 DoBindFramebuffer(GL_FRAMEBUFFER, 0, 0); | |
| 6906 } | |
| 6907 | |
| 6908 Framebuffer* framebuffer = | |
| 6909 framebuffer_manager->GetFramebuffer(client_framebuffer_id_); | |
| 6910 ASSERT_TRUE(framebuffer != NULL); | |
| 6911 framebuffer_manager->MarkAsComplete(framebuffer); | |
| 6912 EXPECT_TRUE(framebuffer_manager->IsComplete(framebuffer)); | |
| 6913 | |
| 6914 // Test TexImage2D marks fbo as not complete. | |
| 6915 DoTexImage2D( | |
| 6916 GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0, 0); | |
| 6917 EXPECT_FALSE(framebuffer_manager->IsComplete(framebuffer)); | |
| 6918 framebuffer_manager->MarkAsComplete(framebuffer); | |
| 6919 EXPECT_TRUE(framebuffer_manager->IsComplete(framebuffer)); | |
| 6920 | |
| 6921 // Test CopyImage2D marks fbo as not complete. | |
| 6922 EXPECT_CALL(*gl_, GetError()) | |
| 6923 .WillOnce(Return(GL_NO_ERROR)) | |
| 6924 .RetiresOnSaturation(); | |
| 6925 EXPECT_CALL(*gl_, CopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 1, 1, 0)) | |
| 6926 .Times(1) | |
| 6927 .RetiresOnSaturation(); | |
| 6928 EXPECT_CALL(*gl_, GetError()) | |
| 6929 .WillOnce(Return(GL_NO_ERROR)) | |
| 6930 .RetiresOnSaturation(); | |
| 6931 CopyTexImage2D cmd; | |
| 6932 cmd.Init(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 1, 1, 0); | |
| 6933 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 6934 EXPECT_FALSE(framebuffer_manager->IsComplete(framebuffer)); | |
| 6935 | |
| 6936 // Test deleting texture marks fbo as not complete. | |
| 6937 framebuffer_manager->MarkAsComplete(framebuffer); | |
| 6938 EXPECT_TRUE(framebuffer_manager->IsComplete(framebuffer)); | |
| 6939 DoDeleteTexture(kFBOClientTextureId, kFBOServiceTextureId); | |
| 6940 | |
| 6941 if (bound_fbo) { | |
| 6942 EXPECT_FALSE(framebuffer_manager->IsComplete(framebuffer)); | |
| 6943 } else { | |
| 6944 EXPECT_TRUE(framebuffer_manager->IsComplete(framebuffer)); | |
| 6945 } | |
| 6946 // Cleanup | |
| 6947 DoDeleteFramebuffer( | |
| 6948 client_framebuffer_id_, kServiceFramebufferId, | |
| 6949 bound_fbo, GL_FRAMEBUFFER, 0, | |
| 6950 bound_fbo, GL_FRAMEBUFFER, 0); | |
| 6951 } | |
| 6952 | |
| 6953 TEST_F(GLES2DecoderWithShaderTest, TextureChangesMarkFBOAsNotCompleteBoundFBO) { | |
| 6954 CheckTextureChangesMarkFBOAsNotComplete(true); | |
| 6955 } | |
| 6956 | |
| 6957 TEST_F(GLES2DecoderWithShaderTest, | |
| 6958 TextureChangesMarkFBOAsNotCompleteUnboundFBO) { | |
| 6959 CheckTextureChangesMarkFBOAsNotComplete(false); | |
| 6960 } | |
| 6961 | |
| 6962 TEST_F(GLES2DecoderWithShaderTest, | |
| 6963 DrawingWithFBOTwiceChecksForFBOCompleteOnce) { | |
| 6964 const GLuint kFBOClientTextureId = 4100; | |
| 6965 const GLuint kFBOServiceTextureId = 4101; | |
| 6966 | |
| 6967 SetupAllNeededVertexBuffers(); | |
| 6968 | |
| 6969 // Register a texture id. | |
| 6970 EXPECT_CALL(*gl_, GenTextures(_, _)) | |
| 6971 .WillOnce(SetArgumentPointee<1>(kFBOServiceTextureId)) | |
| 6972 .RetiresOnSaturation(); | |
| 6973 GenHelper<GenTexturesImmediate>(kFBOClientTextureId); | |
| 6974 | |
| 6975 // Setup "render to" texture that is cleared. | |
| 6976 DoBindTexture(GL_TEXTURE_2D, kFBOClientTextureId, kFBOServiceTextureId); | |
| 6977 DoTexImage2D( | |
| 6978 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 6979 kSharedMemoryId, kSharedMemoryOffset); | |
| 6980 DoBindFramebuffer( | |
| 6981 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); | |
| 6982 DoFramebufferTexture2D( | |
| 6983 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, | |
| 6984 kFBOClientTextureId, kFBOServiceTextureId, 0, GL_NO_ERROR); | |
| 6985 | |
| 6986 // Setup "render from" texture. | |
| 6987 SetupTexture(); | |
| 6988 | |
| 6989 // Make sure we check for framebuffer complete. | |
| 6990 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) | |
| 6991 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) | |
| 6992 .RetiresOnSaturation(); | |
| 6993 | |
| 6994 SetupExpectationsForApplyingDirtyState( | |
| 6995 false, // Framebuffer is RGB | |
| 6996 false, // Framebuffer has depth | |
| 6997 false, // Framebuffer has stencil | |
| 6998 0x1111, // color bits | |
| 6999 false, // depth mask | |
| 7000 false, // depth enabled | |
| 7001 0, // front stencil mask | |
| 7002 0, // back stencil mask | |
| 7003 false, // stencil enabled | |
| 7004 false, // cull_face_enabled | |
| 7005 false, // scissor_test_enabled | |
| 7006 false); // blend_enabled | |
| 7007 | |
| 7008 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | |
| 7009 .Times(1) | |
| 7010 .RetiresOnSaturation(); | |
| 7011 DrawArrays cmd; | |
| 7012 cmd.Init(GL_TRIANGLES, 0, kNumVertices); | |
| 7013 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 7014 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 7015 | |
| 7016 // But not again. | |
| 7017 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | |
| 7018 .Times(1) | |
| 7019 .RetiresOnSaturation(); | |
| 7020 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 7021 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 7022 } | |
| 7023 | |
| 7024 TEST_F(GLES2DecoderTest, BeginQueryEXTDisabled) { | 555 TEST_F(GLES2DecoderTest, BeginQueryEXTDisabled) { |
| 7025 // Test something fails if off. | 556 // Test something fails if off. |
| 7026 } | 557 } |
| 7027 | 558 |
| 7028 TEST_F(GLES2DecoderManualInitTest, BeginEndQueryEXT) { | 559 TEST_F(GLES2DecoderManualInitTest, BeginEndQueryEXT) { |
| 7029 InitState init; | 560 InitState init; |
| 7030 init.extensions = "GL_EXT_occlusion_query_boolean"; | 561 init.extensions = "GL_EXT_occlusion_query_boolean"; |
| 7031 init.gl_version = "opengl es 2.0"; | 562 init.gl_version = "opengl es 2.0"; |
| 7032 init.has_alpha = true; | 563 init.has_alpha = true; |
| 7033 init.request_alpha = true; | 564 init.request_alpha = true; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 7045 // Test id = 0 fails. | 576 // Test id = 0 fails. |
| 7046 begin_cmd.Init( | 577 begin_cmd.Init( |
| 7047 GL_ANY_SAMPLES_PASSED_EXT, 0, kSharedMemoryId, kSharedMemoryOffset); | 578 GL_ANY_SAMPLES_PASSED_EXT, 0, kSharedMemoryId, kSharedMemoryOffset); |
| 7048 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); | 579 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); |
| 7049 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 580 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 7050 | 581 |
| 7051 GenHelper<GenQueriesEXTImmediate>(kNewClientId); | 582 GenHelper<GenQueriesEXTImmediate>(kNewClientId); |
| 7052 | 583 |
| 7053 // Test valid parameters work. | 584 // Test valid parameters work. |
| 7054 EXPECT_CALL(*gl_, GenQueriesARB(1, _)) | 585 EXPECT_CALL(*gl_, GenQueriesARB(1, _)) |
| 7055 .WillOnce(SetArgumentPointee<1>(kNewServiceId)) | 586 .WillOnce(SetArgumentPointee<1>(kNewServiceId)) |
| 7056 .RetiresOnSaturation(); | 587 .RetiresOnSaturation(); |
| 7057 EXPECT_CALL(*gl_, BeginQueryARB(GL_ANY_SAMPLES_PASSED_EXT, kNewServiceId)) | 588 EXPECT_CALL(*gl_, BeginQueryARB(GL_ANY_SAMPLES_PASSED_EXT, kNewServiceId)) |
| 7058 .Times(1) | 589 .Times(1) |
| 7059 .RetiresOnSaturation(); | 590 .RetiresOnSaturation(); |
| 7060 | 591 |
| 7061 // Query object should not be created untill BeginQueriesEXT. | 592 // Query object should not be created untill BeginQueriesEXT. |
| 7062 QueryManager* query_manager = decoder_->GetQueryManager(); | 593 QueryManager* query_manager = decoder_->GetQueryManager(); |
| 7063 ASSERT_TRUE(query_manager != NULL); | 594 ASSERT_TRUE(query_manager != NULL); |
| 7064 QueryManager::Query* query = query_manager->GetQuery(kNewClientId); | 595 QueryManager::Query* query = query_manager->GetQuery(kNewClientId); |
| 7065 EXPECT_TRUE(query == NULL); | 596 EXPECT_TRUE(query == NULL); |
| 7066 | 597 |
| 7067 // BeginQueryEXT should fail if id is not generated from GenQueriesEXT. | 598 // BeginQueryEXT should fail if id is not generated from GenQueriesEXT. |
| 7068 begin_cmd.Init(GL_ANY_SAMPLES_PASSED_EXT, | 599 begin_cmd.Init(GL_ANY_SAMPLES_PASSED_EXT, |
| 7069 kInvalidClientId, | 600 kInvalidClientId, |
| 7070 kSharedMemoryId, | 601 kSharedMemoryId, |
| 7071 kSharedMemoryOffset); | 602 kSharedMemoryOffset); |
| 7072 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); | 603 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); |
| 7073 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 604 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 7074 | 605 |
| 7075 begin_cmd.Init( | 606 begin_cmd.Init(GL_ANY_SAMPLES_PASSED_EXT, |
| 7076 GL_ANY_SAMPLES_PASSED_EXT, kNewClientId, | 607 kNewClientId, |
| 7077 kSharedMemoryId, kSharedMemoryOffset); | 608 kSharedMemoryId, |
| 609 kSharedMemoryOffset); |
| 7078 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); | 610 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); |
| 7079 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 611 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 7080 | 612 |
| 7081 // After BeginQueriesEXT id name should have query object associated with it. | 613 // After BeginQueriesEXT id name should have query object associated with it. |
| 7082 query = query_manager->GetQuery(kNewClientId); | 614 query = query_manager->GetQuery(kNewClientId); |
| 7083 ASSERT_TRUE(query != NULL); | 615 ASSERT_TRUE(query != NULL); |
| 7084 EXPECT_FALSE(query->pending()); | 616 EXPECT_FALSE(query->pending()); |
| 7085 | 617 |
| 7086 // Test trying begin again fails | 618 // Test trying begin again fails |
| 7087 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); | 619 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); |
| 7088 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 620 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 7089 | 621 |
| 7090 // Test end fails with different target | 622 // Test end fails with different target |
| 7091 end_cmd.Init(GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT, 1); | 623 end_cmd.Init(GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT, 1); |
| 7092 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); | 624 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); |
| 7093 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 625 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 7094 | 626 |
| 7095 // Test end succeeds | 627 // Test end succeeds |
| 7096 EXPECT_CALL(*gl_, EndQueryARB(GL_ANY_SAMPLES_PASSED_EXT)) | 628 EXPECT_CALL(*gl_, EndQueryARB(GL_ANY_SAMPLES_PASSED_EXT)) |
| 7097 .Times(1) | 629 .Times(1) |
| 7098 .RetiresOnSaturation(); | 630 .RetiresOnSaturation(); |
| 7099 end_cmd.Init(GL_ANY_SAMPLES_PASSED_EXT, 1); | 631 end_cmd.Init(GL_ANY_SAMPLES_PASSED_EXT, 1); |
| 7100 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); | 632 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); |
| 7101 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 633 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 7102 EXPECT_TRUE(query->pending()); | 634 EXPECT_TRUE(query->pending()); |
| 7103 | 635 |
| 7104 EXPECT_CALL(*gl_, DeleteQueriesARB(1, _)) | 636 EXPECT_CALL(*gl_, DeleteQueriesARB(1, _)).Times(1).RetiresOnSaturation(); |
| 7105 .Times(1) | |
| 7106 .RetiresOnSaturation(); | |
| 7107 } | 637 } |
| 7108 | 638 |
| 7109 struct QueryType { | 639 struct QueryType { |
| 7110 GLenum type; | 640 GLenum type; |
| 7111 bool is_gl; | 641 bool is_gl; |
| 7112 }; | 642 }; |
| 7113 | 643 |
| 7114 const QueryType kQueryTypes[] = { | 644 const QueryType kQueryTypes[] = { |
| 7115 { GL_COMMANDS_ISSUED_CHROMIUM, false }, | 645 {GL_COMMANDS_ISSUED_CHROMIUM, false}, |
| 7116 { GL_LATENCY_QUERY_CHROMIUM, false }, | 646 {GL_LATENCY_QUERY_CHROMIUM, false}, |
| 7117 { GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM, false }, | 647 {GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM, false}, |
| 7118 { GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM, false }, | 648 {GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM, false}, |
| 7119 { GL_GET_ERROR_QUERY_CHROMIUM, false }, | 649 {GL_GET_ERROR_QUERY_CHROMIUM, false}, |
| 7120 { GL_COMMANDS_COMPLETED_CHROMIUM, false }, | 650 {GL_COMMANDS_COMPLETED_CHROMIUM, false}, |
| 7121 { GL_ANY_SAMPLES_PASSED_EXT, true }, | 651 {GL_ANY_SAMPLES_PASSED_EXT, true}, |
| 7122 }; | 652 }; |
| 7123 | 653 |
| 7124 static void CheckBeginEndQueryBadMemoryFails( | 654 static void CheckBeginEndQueryBadMemoryFails(GLES2DecoderTestBase* test, |
| 7125 GLES2DecoderTestBase* test, | 655 GLuint client_id, |
| 7126 GLuint client_id, | 656 GLuint service_id, |
| 7127 GLuint service_id, | 657 const QueryType& query_type, |
| 7128 const QueryType& query_type, | 658 int32 shm_id, |
| 7129 int32 shm_id, | 659 uint32 shm_offset) { |
| 7130 uint32 shm_offset) { | |
| 7131 // We need to reset the decoder on each iteration, because we lose the | 660 // We need to reset the decoder on each iteration, because we lose the |
| 7132 // context every time. | 661 // context every time. |
| 7133 GLES2DecoderTestBase::InitState init; | 662 GLES2DecoderTestBase::InitState init; |
| 7134 init.extensions = "GL_EXT_occlusion_query_boolean GL_ARB_sync"; | 663 init.extensions = "GL_EXT_occlusion_query_boolean GL_ARB_sync"; |
| 7135 init.gl_version = "opengl es 2.0"; | 664 init.gl_version = "opengl es 2.0"; |
| 7136 init.has_alpha = true; | 665 init.has_alpha = true; |
| 7137 init.request_alpha = true; | 666 init.request_alpha = true; |
| 7138 init.bind_generates_resource = true; | 667 init.bind_generates_resource = true; |
| 7139 test->InitDecoder(init); | 668 test->InitDecoder(init); |
| 7140 ::testing::StrictMock< ::gfx::MockGLInterface>* gl = test->GetGLMock(); | 669 ::testing::StrictMock< ::gfx::MockGLInterface>* gl = test->GetGLMock(); |
| 7141 | 670 |
| 7142 BeginQueryEXT begin_cmd; | 671 BeginQueryEXT begin_cmd; |
| 7143 | 672 |
| 7144 test->GenHelper<GenQueriesEXTImmediate>(client_id); | 673 test->GenHelper<GenQueriesEXTImmediate>(client_id); |
| 7145 | 674 |
| 7146 if (query_type.is_gl) { | 675 if (query_type.is_gl) { |
| 7147 EXPECT_CALL(*gl, GenQueriesARB(1, _)) | 676 EXPECT_CALL(*gl, GenQueriesARB(1, _)) |
| 7148 .WillOnce(SetArgumentPointee<1>(service_id)) | 677 .WillOnce(SetArgumentPointee<1>(service_id)) |
| 7149 .RetiresOnSaturation(); | 678 .RetiresOnSaturation(); |
| 7150 EXPECT_CALL(*gl, BeginQueryARB(query_type.type, service_id)) | 679 EXPECT_CALL(*gl, BeginQueryARB(query_type.type, service_id)) |
| 7151 .Times(1) | 680 .Times(1) |
| 7152 .RetiresOnSaturation(); | 681 .RetiresOnSaturation(); |
| 7153 } | 682 } |
| 7154 | 683 |
| 7155 // Test bad shared memory fails | 684 // Test bad shared memory fails |
| 7156 begin_cmd.Init(query_type.type, client_id, shm_id, shm_offset); | 685 begin_cmd.Init(query_type.type, client_id, shm_id, shm_offset); |
| 7157 error::Error error1 = test->ExecuteCmd(begin_cmd); | 686 error::Error error1 = test->ExecuteCmd(begin_cmd); |
| 7158 | 687 |
| 7159 if (query_type.is_gl) { | 688 if (query_type.is_gl) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 7172 EXPECT_CALL(*gl, FenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0)) | 701 EXPECT_CALL(*gl, FenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0)) |
| 7173 .WillOnce(Return(kGlSync)) | 702 .WillOnce(Return(kGlSync)) |
| 7174 .RetiresOnSaturation(); | 703 .RetiresOnSaturation(); |
| 7175 } | 704 } |
| 7176 | 705 |
| 7177 EndQueryEXT end_cmd; | 706 EndQueryEXT end_cmd; |
| 7178 end_cmd.Init(query_type.type, 1); | 707 end_cmd.Init(query_type.type, 1); |
| 7179 error::Error error2 = test->ExecuteCmd(end_cmd); | 708 error::Error error2 = test->ExecuteCmd(end_cmd); |
| 7180 | 709 |
| 7181 if (query_type.is_gl) { | 710 if (query_type.is_gl) { |
| 7182 EXPECT_CALL(*gl, | 711 EXPECT_CALL( |
| 7183 GetQueryObjectuivARB(service_id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) | 712 *gl, GetQueryObjectuivARB(service_id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) |
| 7184 .WillOnce(SetArgumentPointee<2>(1)) | 713 .WillOnce(SetArgumentPointee<2>(1)) |
| 7185 .RetiresOnSaturation(); | 714 .RetiresOnSaturation(); |
| 7186 EXPECT_CALL(*gl, | 715 EXPECT_CALL(*gl, GetQueryObjectuivARB(service_id, GL_QUERY_RESULT_EXT, _)) |
| 7187 GetQueryObjectuivARB(service_id, GL_QUERY_RESULT_EXT, _)) | |
| 7188 .WillOnce(SetArgumentPointee<2>(1)) | 716 .WillOnce(SetArgumentPointee<2>(1)) |
| 7189 .RetiresOnSaturation(); | 717 .RetiresOnSaturation(); |
| 7190 } | 718 } |
| 7191 if (query_type.type == GL_COMMANDS_COMPLETED_CHROMIUM) { | 719 if (query_type.type == GL_COMMANDS_COMPLETED_CHROMIUM) { |
| 7192 EXPECT_CALL(*gl, ClientWaitSync(kGlSync, _, _)) | 720 EXPECT_CALL(*gl, ClientWaitSync(kGlSync, _, _)) |
| 7193 .WillOnce(Return(GL_ALREADY_SIGNALED)) | 721 .WillOnce(Return(GL_ALREADY_SIGNALED)) |
| 7194 .RetiresOnSaturation(); | 722 .RetiresOnSaturation(); |
| 7195 } | 723 } |
| 7196 | 724 |
| 7197 QueryManager* query_manager = test->GetDecoder()->GetQueryManager(); | 725 QueryManager* query_manager = test->GetDecoder()->GetQueryManager(); |
| 7198 ASSERT_TRUE(query_manager != NULL); | 726 ASSERT_TRUE(query_manager != NULL); |
| 7199 bool process_success = query_manager->ProcessPendingQueries(); | 727 bool process_success = query_manager->ProcessPendingQueries(); |
| 7200 | 728 |
| 7201 EXPECT_TRUE(error1 != error::kNoError || | 729 EXPECT_TRUE(error1 != error::kNoError || error2 != error::kNoError || |
| 7202 error2 != error::kNoError || | |
| 7203 !process_success); | 730 !process_success); |
| 7204 | 731 |
| 7205 if (query_type.is_gl) { | 732 if (query_type.is_gl) { |
| 7206 EXPECT_CALL(*gl, DeleteQueriesARB(1, _)) | 733 EXPECT_CALL(*gl, DeleteQueriesARB(1, _)).Times(1).RetiresOnSaturation(); |
| 7207 .Times(1) | |
| 7208 .RetiresOnSaturation(); | |
| 7209 } | 734 } |
| 7210 if (query_type.type == GL_COMMANDS_COMPLETED_CHROMIUM) | 735 if (query_type.type == GL_COMMANDS_COMPLETED_CHROMIUM) |
| 7211 EXPECT_CALL(*gl, DeleteSync(kGlSync)).Times(1).RetiresOnSaturation(); | 736 EXPECT_CALL(*gl, DeleteSync(kGlSync)).Times(1).RetiresOnSaturation(); |
| 7212 test->ResetDecoder(); | 737 test->ResetDecoder(); |
| 7213 } | 738 } |
| 7214 | 739 |
| 7215 TEST_F(GLES2DecoderManualInitTest, BeginEndQueryEXTBadMemoryIdFails) { | 740 TEST_F(GLES2DecoderManualInitTest, BeginEndQueryEXTBadMemoryIdFails) { |
| 7216 for (size_t i = 0; i < arraysize(kQueryTypes); ++i) { | 741 for (size_t i = 0; i < arraysize(kQueryTypes); ++i) { |
| 7217 CheckBeginEndQueryBadMemoryFails( | 742 CheckBeginEndQueryBadMemoryFails(this, |
| 7218 this, kNewClientId, kNewServiceId, | 743 kNewClientId, |
| 7219 kQueryTypes[i], | 744 kNewServiceId, |
| 7220 kInvalidSharedMemoryId, kSharedMemoryOffset); | 745 kQueryTypes[i], |
| 746 kInvalidSharedMemoryId, |
| 747 kSharedMemoryOffset); |
| 7221 } | 748 } |
| 7222 } | 749 } |
| 7223 | 750 |
| 7224 TEST_F(GLES2DecoderManualInitTest, BeginEndQueryEXTBadMemoryOffsetFails) { | 751 TEST_F(GLES2DecoderManualInitTest, BeginEndQueryEXTBadMemoryOffsetFails) { |
| 7225 for (size_t i = 0; i < arraysize(kQueryTypes); ++i) { | 752 for (size_t i = 0; i < arraysize(kQueryTypes); ++i) { |
| 7226 // Out-of-bounds. | 753 // Out-of-bounds. |
| 7227 CheckBeginEndQueryBadMemoryFails( | 754 CheckBeginEndQueryBadMemoryFails(this, |
| 7228 this, kNewClientId, kNewServiceId, | 755 kNewClientId, |
| 7229 kQueryTypes[i], | 756 kNewServiceId, |
| 7230 kSharedMemoryId, kInvalidSharedMemoryOffset); | 757 kQueryTypes[i], |
| 758 kSharedMemoryId, |
| 759 kInvalidSharedMemoryOffset); |
| 7231 // Overflow. | 760 // Overflow. |
| 7232 CheckBeginEndQueryBadMemoryFails( | 761 CheckBeginEndQueryBadMemoryFails(this, |
| 7233 this, kNewClientId, kNewServiceId, | 762 kNewClientId, |
| 7234 kQueryTypes[i], | 763 kNewServiceId, |
| 7235 kSharedMemoryId, 0xfffffffcu); | 764 kQueryTypes[i], |
| 765 kSharedMemoryId, |
| 766 0xfffffffcu); |
| 7236 } | 767 } |
| 7237 } | 768 } |
| 7238 | 769 |
| 7239 TEST_F(GLES2DecoderTest, BeginEndQueryEXTCommandsIssuedCHROMIUM) { | 770 TEST_F(GLES2DecoderTest, BeginEndQueryEXTCommandsIssuedCHROMIUM) { |
| 7240 BeginQueryEXT begin_cmd; | 771 BeginQueryEXT begin_cmd; |
| 7241 | 772 |
| 7242 GenHelper<GenQueriesEXTImmediate>(kNewClientId); | 773 GenHelper<GenQueriesEXTImmediate>(kNewClientId); |
| 7243 | 774 |
| 7244 // Test valid parameters work. | 775 // Test valid parameters work. |
| 7245 begin_cmd.Init( | 776 begin_cmd.Init(GL_COMMANDS_ISSUED_CHROMIUM, |
| 7246 GL_COMMANDS_ISSUED_CHROMIUM, kNewClientId, | 777 kNewClientId, |
| 7247 kSharedMemoryId, kSharedMemoryOffset); | 778 kSharedMemoryId, |
| 779 kSharedMemoryOffset); |
| 7248 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); | 780 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); |
| 7249 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 781 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 7250 | 782 |
| 7251 QueryManager* query_manager = decoder_->GetQueryManager(); | 783 QueryManager* query_manager = decoder_->GetQueryManager(); |
| 7252 ASSERT_TRUE(query_manager != NULL); | 784 ASSERT_TRUE(query_manager != NULL); |
| 7253 QueryManager::Query* query = query_manager->GetQuery(kNewClientId); | 785 QueryManager::Query* query = query_manager->GetQuery(kNewClientId); |
| 7254 ASSERT_TRUE(query != NULL); | 786 ASSERT_TRUE(query != NULL); |
| 7255 EXPECT_FALSE(query->pending()); | 787 EXPECT_FALSE(query->pending()); |
| 7256 | 788 |
| 7257 // Test end succeeds | 789 // Test end succeeds |
| 7258 EndQueryEXT end_cmd; | 790 EndQueryEXT end_cmd; |
| 7259 end_cmd.Init(GL_COMMANDS_ISSUED_CHROMIUM, 1); | 791 end_cmd.Init(GL_COMMANDS_ISSUED_CHROMIUM, 1); |
| 7260 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); | 792 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); |
| 7261 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 793 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 7262 EXPECT_FALSE(query->pending()); | 794 EXPECT_FALSE(query->pending()); |
| 7263 } | 795 } |
| 7264 | 796 |
| 7265 TEST_F(GLES2DecoderTest, BeginEndQueryEXTGetErrorQueryCHROMIUM) { | 797 TEST_F(GLES2DecoderTest, BeginEndQueryEXTGetErrorQueryCHROMIUM) { |
| 7266 BeginQueryEXT begin_cmd; | 798 BeginQueryEXT begin_cmd; |
| 7267 | 799 |
| 7268 GenHelper<GenQueriesEXTImmediate>(kNewClientId); | 800 GenHelper<GenQueriesEXTImmediate>(kNewClientId); |
| 7269 | 801 |
| 7270 // Test valid parameters work. | 802 // Test valid parameters work. |
| 7271 begin_cmd.Init( | 803 begin_cmd.Init(GL_GET_ERROR_QUERY_CHROMIUM, |
| 7272 GL_GET_ERROR_QUERY_CHROMIUM, kNewClientId, | 804 kNewClientId, |
| 7273 kSharedMemoryId, kSharedMemoryOffset); | 805 kSharedMemoryId, |
| 806 kSharedMemoryOffset); |
| 7274 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); | 807 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); |
| 7275 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 808 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 7276 | 809 |
| 7277 QueryManager* query_manager = decoder_->GetQueryManager(); | 810 QueryManager* query_manager = decoder_->GetQueryManager(); |
| 7278 ASSERT_TRUE(query_manager != NULL); | 811 ASSERT_TRUE(query_manager != NULL); |
| 7279 QueryManager::Query* query = query_manager->GetQuery(kNewClientId); | 812 QueryManager::Query* query = query_manager->GetQuery(kNewClientId); |
| 7280 ASSERT_TRUE(query != NULL); | 813 ASSERT_TRUE(query != NULL); |
| 7281 EXPECT_FALSE(query->pending()); | 814 EXPECT_FALSE(query->pending()); |
| 7282 | 815 |
| 7283 // Test end succeeds | 816 // Test end succeeds |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7348 | 881 |
| 7349 EXPECT_TRUE(process_success); | 882 EXPECT_TRUE(process_success); |
| 7350 EXPECT_FALSE(query->pending()); | 883 EXPECT_FALSE(query->pending()); |
| 7351 QuerySync* sync = static_cast<QuerySync*>(shared_memory_address_); | 884 QuerySync* sync = static_cast<QuerySync*>(shared_memory_address_); |
| 7352 EXPECT_EQ(static_cast<GLenum>(0), static_cast<GLenum>(sync->result)); | 885 EXPECT_EQ(static_cast<GLenum>(0), static_cast<GLenum>(sync->result)); |
| 7353 | 886 |
| 7354 EXPECT_CALL(*gl_, DeleteSync(kGlSync)).Times(1).RetiresOnSaturation(); | 887 EXPECT_CALL(*gl_, DeleteSync(kGlSync)).Times(1).RetiresOnSaturation(); |
| 7355 ResetDecoder(); | 888 ResetDecoder(); |
| 7356 } | 889 } |
| 7357 | 890 |
| 7358 TEST_F(GLES2DecoderTest, ProduceAndConsumeTextureCHROMIUM) { | |
| 7359 Mailbox mailbox = Mailbox::Generate(); | |
| 7360 | |
| 7361 memcpy(shared_memory_address_, mailbox.name, sizeof(mailbox.name)); | |
| 7362 | |
| 7363 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 7364 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 7365 0, 0); | |
| 7366 DoTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 2, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 7367 0, 0); | |
| 7368 TextureRef* texture_ref = group().texture_manager()->GetTexture( | |
| 7369 client_texture_id_); | |
| 7370 ASSERT_TRUE(texture_ref != NULL); | |
| 7371 Texture* texture = texture_ref->texture(); | |
| 7372 EXPECT_EQ(kServiceTextureId, texture->service_id()); | |
| 7373 | |
| 7374 ProduceTextureCHROMIUM produce_cmd; | |
| 7375 produce_cmd.Init(GL_TEXTURE_2D, kSharedMemoryId, kSharedMemoryOffset); | |
| 7376 EXPECT_EQ(error::kNoError, ExecuteCmd(produce_cmd)); | |
| 7377 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 7378 | |
| 7379 // Texture didn't change. | |
| 7380 GLsizei width; | |
| 7381 GLsizei height; | |
| 7382 GLenum type; | |
| 7383 GLenum internal_format; | |
| 7384 | |
| 7385 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); | |
| 7386 EXPECT_EQ(3, width); | |
| 7387 EXPECT_EQ(1, height); | |
| 7388 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); | |
| 7389 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); | |
| 7390 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); | |
| 7391 | |
| 7392 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 1, &width, &height)); | |
| 7393 EXPECT_EQ(2, width); | |
| 7394 EXPECT_EQ(4, height); | |
| 7395 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 1, &type, &internal_format)); | |
| 7396 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); | |
| 7397 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); | |
| 7398 | |
| 7399 // Service ID has not changed. | |
| 7400 EXPECT_EQ(kServiceTextureId, texture->service_id()); | |
| 7401 | |
| 7402 // Create new texture for consume. | |
| 7403 EXPECT_CALL(*gl_, GenTextures(_, _)) | |
| 7404 .WillOnce(SetArgumentPointee<1>(kNewServiceId)) | |
| 7405 .RetiresOnSaturation(); | |
| 7406 DoBindTexture(GL_TEXTURE_2D, kNewClientId, kNewServiceId); | |
| 7407 | |
| 7408 // Assigns and binds original service size texture ID. | |
| 7409 EXPECT_CALL(*gl_, DeleteTextures(1, _)) | |
| 7410 .Times(1) | |
| 7411 .RetiresOnSaturation(); | |
| 7412 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId)) | |
| 7413 .Times(1) | |
| 7414 .RetiresOnSaturation(); | |
| 7415 | |
| 7416 memcpy(shared_memory_address_, mailbox.name, sizeof(mailbox.name)); | |
| 7417 ConsumeTextureCHROMIUM consume_cmd; | |
| 7418 consume_cmd.Init(GL_TEXTURE_2D, kSharedMemoryId, kSharedMemoryOffset); | |
| 7419 EXPECT_EQ(error::kNoError, ExecuteCmd(consume_cmd)); | |
| 7420 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 7421 | |
| 7422 // Texture is redefined. | |
| 7423 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); | |
| 7424 EXPECT_EQ(3, width); | |
| 7425 EXPECT_EQ(1, height); | |
| 7426 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); | |
| 7427 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); | |
| 7428 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); | |
| 7429 | |
| 7430 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 1, &width, &height)); | |
| 7431 EXPECT_EQ(2, width); | |
| 7432 EXPECT_EQ(4, height); | |
| 7433 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 1, &type, &internal_format)); | |
| 7434 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); | |
| 7435 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); | |
| 7436 | |
| 7437 // Service ID is restored. | |
| 7438 EXPECT_EQ(kServiceTextureId, texture->service_id()); | |
| 7439 } | |
| 7440 | |
| 7441 | |
| 7442 TEST_F(GLES2DecoderTest, CanChangeSurface) { | |
| 7443 scoped_refptr<GLSurfaceMock> other_surface(new GLSurfaceMock); | |
| 7444 EXPECT_CALL(*other_surface.get(), GetBackingFrameBufferObject()). | |
| 7445 WillOnce(Return(7)); | |
| 7446 EXPECT_CALL(*gl_, BindFramebufferEXT(GL_FRAMEBUFFER_EXT, 7)); | |
| 7447 | |
| 7448 decoder_->SetSurface(other_surface); | |
| 7449 } | |
| 7450 | |
| 7451 TEST_F(GLES2DecoderTest, IsEnabledReturnsCachedValue) { | 891 TEST_F(GLES2DecoderTest, IsEnabledReturnsCachedValue) { |
| 7452 // NOTE: There are no expectations because no GL functions should be | 892 // NOTE: There are no expectations because no GL functions should be |
| 7453 // called for DEPTH_TEST or STENCIL_TEST | 893 // called for DEPTH_TEST or STENCIL_TEST |
| 7454 static const GLenum kStates[] = { | 894 static const GLenum kStates[] = { |
| 7455 GL_DEPTH_TEST, | 895 GL_DEPTH_TEST, GL_STENCIL_TEST, |
| 7456 GL_STENCIL_TEST, | |
| 7457 }; | 896 }; |
| 7458 for (size_t ii = 0; ii < arraysize(kStates); ++ii) { | 897 for (size_t ii = 0; ii < arraysize(kStates); ++ii) { |
| 7459 Enable enable_cmd; | 898 Enable enable_cmd; |
| 7460 GLenum state = kStates[ii]; | 899 GLenum state = kStates[ii]; |
| 7461 enable_cmd.Init(state); | 900 enable_cmd.Init(state); |
| 7462 EXPECT_EQ(error::kNoError, ExecuteCmd(enable_cmd)); | 901 EXPECT_EQ(error::kNoError, ExecuteCmd(enable_cmd)); |
| 7463 IsEnabled::Result* result = | 902 IsEnabled::Result* result = |
| 7464 static_cast<IsEnabled::Result*>(shared_memory_address_); | 903 static_cast<IsEnabled::Result*>(shared_memory_address_); |
| 7465 IsEnabled is_enabled_cmd; | 904 IsEnabled is_enabled_cmd; |
| 7466 is_enabled_cmd.Init(state, shared_memory_id_, shared_memory_offset_); | 905 is_enabled_cmd.Init(state, shared_memory_id_, shared_memory_offset_); |
| 7467 EXPECT_EQ(error::kNoError, ExecuteCmd(is_enabled_cmd)); | 906 EXPECT_EQ(error::kNoError, ExecuteCmd(is_enabled_cmd)); |
| 7468 EXPECT_NE(0u, *result); | 907 EXPECT_NE(0u, *result); |
| 7469 Disable disable_cmd; | 908 Disable disable_cmd; |
| 7470 disable_cmd.Init(state); | 909 disable_cmd.Init(state); |
| 7471 EXPECT_EQ(error::kNoError, ExecuteCmd(disable_cmd)); | 910 EXPECT_EQ(error::kNoError, ExecuteCmd(disable_cmd)); |
| 7472 EXPECT_EQ(error::kNoError, ExecuteCmd(is_enabled_cmd)); | 911 EXPECT_EQ(error::kNoError, ExecuteCmd(is_enabled_cmd)); |
| 7473 EXPECT_EQ(0u, *result); | 912 EXPECT_EQ(0u, *result); |
| 7474 } | 913 } |
| 7475 } | 914 } |
| 7476 | 915 |
| 7477 TEST_F(GLES2DecoderManualInitTest, DepthTextureBadArgs) { | |
| 7478 InitState init; | |
| 7479 init.extensions = "GL_ANGLE_depth_texture"; | |
| 7480 init.gl_version = "opengl es 2.0"; | |
| 7481 init.has_depth = true; | |
| 7482 init.has_stencil = true; | |
| 7483 init.request_depth = true; | |
| 7484 init.request_stencil = true; | |
| 7485 init.bind_generates_resource = true; | |
| 7486 InitDecoder(init); | |
| 7487 | |
| 7488 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 7489 // Check trying to upload data fails. | |
| 7490 TexImage2D tex_cmd; | |
| 7491 tex_cmd.Init( | |
| 7492 GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, | |
| 7493 1, 1, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, | |
| 7494 kSharedMemoryId, kSharedMemoryOffset); | |
| 7495 EXPECT_EQ(error::kNoError, ExecuteCmd(tex_cmd)); | |
| 7496 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 7497 // Try level > 0. | |
| 7498 tex_cmd.Init( | |
| 7499 GL_TEXTURE_2D, 1, GL_DEPTH_COMPONENT, | |
| 7500 1, 1, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 0, 0); | |
| 7501 EXPECT_EQ(error::kNoError, ExecuteCmd(tex_cmd)); | |
| 7502 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 7503 // Make a 1 pixel depth texture. | |
| 7504 DoTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, | |
| 7505 1, 1, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 0, 0); | |
| 7506 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 7507 | |
| 7508 // Check that trying to update it fails. | |
| 7509 TexSubImage2D tex_sub_cmd; | |
| 7510 tex_sub_cmd.Init( | |
| 7511 GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, | |
| 7512 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); | |
| 7513 EXPECT_EQ(error::kNoError, ExecuteCmd(tex_sub_cmd)); | |
| 7514 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 7515 | |
| 7516 // Check that trying to CopyTexImage2D fails | |
| 7517 CopyTexImage2D copy_tex_cmd; | |
| 7518 copy_tex_cmd.Init(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 0, 0, 1, 1, 0); | |
| 7519 EXPECT_EQ(error::kNoError, ExecuteCmd(copy_tex_cmd)); | |
| 7520 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 7521 | |
| 7522 // Check that trying to CopyTexSubImage2D fails | |
| 7523 CopyTexSubImage2D copy_sub_cmd; | |
| 7524 copy_sub_cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 1, 1); | |
| 7525 EXPECT_EQ(error::kNoError, ExecuteCmd(copy_sub_cmd)); | |
| 7526 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 7527 } | |
| 7528 | |
| 7529 TEST_F(GLES2DecoderManualInitTest, GenerateMipmapDepthTexture) { | |
| 7530 InitState init; | |
| 7531 init.extensions = "GL_ANGLE_depth_texture"; | |
| 7532 init.gl_version = "opengl es 2.0"; | |
| 7533 init.has_depth = true; | |
| 7534 init.has_stencil = true; | |
| 7535 init.request_depth = true; | |
| 7536 init.request_stencil = true; | |
| 7537 init.bind_generates_resource = true; | |
| 7538 InitDecoder(init); | |
| 7539 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 7540 DoTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, | |
| 7541 2, 2, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, | |
| 7542 0, 0); | |
| 7543 GenerateMipmap cmd; | |
| 7544 cmd.Init(GL_TEXTURE_2D); | |
| 7545 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 7546 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 7547 } | |
| 7548 | |
| 7549 TEST_F(GLES2DecoderManualInitTest, DrawClearsDepthTexture) { | |
| 7550 InitState init; | |
| 7551 init.extensions = "GL_ANGLE_depth_texture"; | |
| 7552 init.gl_version = "opengl es 2.0"; | |
| 7553 init.has_alpha = true; | |
| 7554 init.has_depth = true; | |
| 7555 init.request_alpha = true; | |
| 7556 init.request_depth = true; | |
| 7557 init.bind_generates_resource = true; | |
| 7558 InitDecoder(init); | |
| 7559 | |
| 7560 SetupDefaultProgram(); | |
| 7561 SetupAllNeededVertexBuffers(); | |
| 7562 const GLenum attachment = GL_DEPTH_ATTACHMENT; | |
| 7563 const GLenum target = GL_TEXTURE_2D; | |
| 7564 const GLint level = 0; | |
| 7565 DoBindTexture(target, client_texture_id_, kServiceTextureId); | |
| 7566 | |
| 7567 // Create a depth texture. | |
| 7568 DoTexImage2D(target, level, GL_DEPTH_COMPONENT, 1, 1, 0, | |
| 7569 GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 0, 0); | |
| 7570 | |
| 7571 EXPECT_CALL(*gl_, GenFramebuffersEXT(1, _)) | |
| 7572 .Times(1) | |
| 7573 .RetiresOnSaturation(); | |
| 7574 EXPECT_CALL(*gl_, BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, _)) | |
| 7575 .Times(1) | |
| 7576 .RetiresOnSaturation(); | |
| 7577 | |
| 7578 EXPECT_CALL(*gl_, FramebufferTexture2DEXT( | |
| 7579 GL_DRAW_FRAMEBUFFER_EXT, attachment, target, kServiceTextureId, level)) | |
| 7580 .Times(1) | |
| 7581 .RetiresOnSaturation(); | |
| 7582 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER_EXT)) | |
| 7583 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) | |
| 7584 .RetiresOnSaturation(); | |
| 7585 | |
| 7586 EXPECT_CALL(*gl_, ClearStencil(0)) | |
| 7587 .Times(1) | |
| 7588 .RetiresOnSaturation(); | |
| 7589 EXPECT_CALL(*gl_, StencilMask(-1)) | |
| 7590 .Times(1) | |
| 7591 .RetiresOnSaturation(); | |
| 7592 EXPECT_CALL(*gl_, ClearDepth(1.0f)) | |
| 7593 .Times(1) | |
| 7594 .RetiresOnSaturation(); | |
| 7595 EXPECT_CALL(*gl_, DepthMask(true)) | |
| 7596 .Times(1) | |
| 7597 .RetiresOnSaturation(); | |
| 7598 EXPECT_CALL(*gl_, Disable(GL_SCISSOR_TEST)) | |
| 7599 .Times(1) | |
| 7600 .RetiresOnSaturation(); | |
| 7601 | |
| 7602 EXPECT_CALL(*gl_, Clear(GL_DEPTH_BUFFER_BIT)) | |
| 7603 .Times(1) | |
| 7604 .RetiresOnSaturation(); | |
| 7605 | |
| 7606 SetupExpectationsForRestoreClearState( | |
| 7607 0.0f, 0.0f, 0.0f, 0.0f, 0, 1.0f, false); | |
| 7608 | |
| 7609 EXPECT_CALL(*gl_, DeleteFramebuffersEXT(1, _)) | |
| 7610 .Times(1) | |
| 7611 .RetiresOnSaturation(); | |
| 7612 EXPECT_CALL(*gl_, BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0)) | |
| 7613 .Times(1) | |
| 7614 .RetiresOnSaturation(); | |
| 7615 | |
| 7616 SetupExpectationsForApplyingDefaultDirtyState(); | |
| 7617 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | |
| 7618 .Times(1) | |
| 7619 .RetiresOnSaturation(); | |
| 7620 DrawArrays cmd; | |
| 7621 cmd.Init(GL_TRIANGLES, 0, kNumVertices); | |
| 7622 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 7623 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 7624 } | |
| 7625 | |
| 7626 TEST_F(GLES2DecoderWithShaderTest, BindUniformLocationCHROMIUM) { | |
| 7627 const GLint kLocation = 2; | |
| 7628 const char* kName = "testing"; | |
| 7629 const uint32 kNameSize = strlen(kName); | |
| 7630 const char* kBadName1 = "gl_testing"; | |
| 7631 const uint32 kBadName1Size = strlen(kBadName1); | |
| 7632 const char* kBadName2 = "testing[1]"; | |
| 7633 const uint32 kBadName2Size = strlen(kBadName2); | |
| 7634 memcpy(shared_memory_address_, kName, kNameSize); | |
| 7635 BindUniformLocationCHROMIUM cmd; | |
| 7636 cmd.Init(client_program_id_, kLocation, kSharedMemoryId, kSharedMemoryOffset, | |
| 7637 kNameSize); | |
| 7638 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 7639 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 7640 // check negative location | |
| 7641 memcpy(shared_memory_address_, kName, kNameSize); | |
| 7642 cmd.Init(client_program_id_, -1, kSharedMemoryId, kSharedMemoryOffset, | |
| 7643 kNameSize); | |
| 7644 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 7645 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 7646 // check highest location | |
| 7647 memcpy(shared_memory_address_, kName, kNameSize); | |
| 7648 GLint kMaxLocation = | |
| 7649 (kMaxFragmentUniformVectors + kMaxVertexUniformVectors) * 4 - 1; | |
| 7650 cmd.Init(client_program_id_, kMaxLocation, kSharedMemoryId, | |
| 7651 kSharedMemoryOffset, kNameSize); | |
| 7652 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 7653 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 7654 // check too high location | |
| 7655 memcpy(shared_memory_address_, kName, kNameSize); | |
| 7656 cmd.Init(client_program_id_, kMaxLocation + 1, kSharedMemoryId, | |
| 7657 kSharedMemoryOffset, kNameSize); | |
| 7658 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 7659 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 7660 // check bad name "gl_..." | |
| 7661 memcpy(shared_memory_address_, kBadName1, kBadName1Size); | |
| 7662 cmd.Init(client_program_id_, kLocation, kSharedMemoryId, kSharedMemoryOffset, | |
| 7663 kBadName1Size); | |
| 7664 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 7665 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 7666 // check bad name "name[1]" non zero | |
| 7667 memcpy(shared_memory_address_, kBadName2, kBadName2Size); | |
| 7668 cmd.Init(client_program_id_, kLocation, kSharedMemoryId, kSharedMemoryOffset, | |
| 7669 kBadName2Size); | |
| 7670 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 7671 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 7672 } | |
| 7673 | |
| 7674 class GLES2DecoderVertexArraysOESTest : public GLES2DecoderWithShaderTest { | |
| 7675 public: | |
| 7676 GLES2DecoderVertexArraysOESTest() { } | |
| 7677 | |
| 7678 bool vertex_array_deleted_manually_; | |
| 7679 | |
| 7680 virtual void SetUp() { | |
| 7681 InitState init; | |
| 7682 init.extensions = "GL_OES_vertex_array_object"; | |
| 7683 init.gl_version = "opengl es 2.0"; | |
| 7684 init.bind_generates_resource = true; | |
| 7685 InitDecoder(init); | |
| 7686 SetupDefaultProgram(); | |
| 7687 | |
| 7688 AddExpectationsForGenVertexArraysOES(); | |
| 7689 GenHelper<GenVertexArraysOESImmediate>(client_vertexarray_id_); | |
| 7690 | |
| 7691 vertex_array_deleted_manually_ = false; | |
| 7692 } | |
| 7693 | |
| 7694 virtual void TearDown() { | |
| 7695 // This should only be set if the test handled deletion of the vertex array | |
| 7696 // itself. Necessary because vertex_array_objects are not sharable, and thus | |
| 7697 // not managed in the ContextGroup, meaning they will be destroyed during | |
| 7698 // test tear down | |
| 7699 if (!vertex_array_deleted_manually_) { | |
| 7700 AddExpectationsForDeleteVertexArraysOES(); | |
| 7701 } | |
| 7702 | |
| 7703 GLES2DecoderWithShaderTest::TearDown(); | |
| 7704 } | |
| 7705 | |
| 7706 void GenVertexArraysOESValidArgs() { | |
| 7707 AddExpectationsForGenVertexArraysOES(); | |
| 7708 GetSharedMemoryAs<GLuint*>()[0] = kNewClientId; | |
| 7709 GenVertexArraysOES cmd; | |
| 7710 cmd.Init(1, shared_memory_id_, shared_memory_offset_); | |
| 7711 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 7712 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 7713 EXPECT_TRUE(GetVertexArrayInfo(kNewClientId) != NULL); | |
| 7714 AddExpectationsForDeleteVertexArraysOES(); | |
| 7715 } | |
| 7716 | |
| 7717 void GenVertexArraysOESInvalidArgs() { | |
| 7718 EXPECT_CALL(*gl_, GenVertexArraysOES(_, _)).Times(0); | |
| 7719 GetSharedMemoryAs<GLuint*>()[0] = client_vertexarray_id_; | |
| 7720 GenVertexArraysOES cmd; | |
| 7721 cmd.Init(1, shared_memory_id_, shared_memory_offset_); | |
| 7722 EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(cmd)); | |
| 7723 } | |
| 7724 | |
| 7725 void GenVertexArraysOESImmediateValidArgs() { | |
| 7726 AddExpectationsForGenVertexArraysOES(); | |
| 7727 GenVertexArraysOESImmediate* cmd = | |
| 7728 GetImmediateAs<GenVertexArraysOESImmediate>(); | |
| 7729 GLuint temp = kNewClientId; | |
| 7730 cmd->Init(1, &temp); | |
| 7731 EXPECT_EQ(error::kNoError, | |
| 7732 ExecuteImmediateCmd(*cmd, sizeof(temp))); | |
| 7733 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 7734 EXPECT_TRUE(GetVertexArrayInfo(kNewClientId) != NULL); | |
| 7735 AddExpectationsForDeleteVertexArraysOES(); | |
| 7736 } | |
| 7737 | |
| 7738 void GenVertexArraysOESImmediateInvalidArgs() { | |
| 7739 EXPECT_CALL(*gl_, GenVertexArraysOES(_, _)).Times(0); | |
| 7740 GenVertexArraysOESImmediate* cmd = | |
| 7741 GetImmediateAs<GenVertexArraysOESImmediate>(); | |
| 7742 cmd->Init(1, &client_vertexarray_id_); | |
| 7743 EXPECT_EQ(error::kInvalidArguments, | |
| 7744 ExecuteImmediateCmd(*cmd, sizeof(&client_vertexarray_id_))); | |
| 7745 } | |
| 7746 | |
| 7747 void DeleteVertexArraysOESValidArgs() { | |
| 7748 AddExpectationsForDeleteVertexArraysOES(); | |
| 7749 GetSharedMemoryAs<GLuint*>()[0] = client_vertexarray_id_; | |
| 7750 DeleteVertexArraysOES cmd; | |
| 7751 cmd.Init(1, shared_memory_id_, shared_memory_offset_); | |
| 7752 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 7753 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 7754 EXPECT_TRUE( | |
| 7755 GetVertexArrayInfo(client_vertexarray_id_) == NULL); | |
| 7756 vertex_array_deleted_manually_ = true; | |
| 7757 } | |
| 7758 | |
| 7759 void DeleteVertexArraysOESInvalidArgs() { | |
| 7760 GetSharedMemoryAs<GLuint*>()[0] = kInvalidClientId; | |
| 7761 DeleteVertexArraysOES cmd; | |
| 7762 cmd.Init(1, shared_memory_id_, shared_memory_offset_); | |
| 7763 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 7764 } | |
| 7765 | |
| 7766 void DeleteVertexArraysOESImmediateValidArgs() { | |
| 7767 AddExpectationsForDeleteVertexArraysOES(); | |
| 7768 DeleteVertexArraysOESImmediate& cmd = | |
| 7769 *GetImmediateAs<DeleteVertexArraysOESImmediate>(); | |
| 7770 cmd.Init(1, &client_vertexarray_id_); | |
| 7771 EXPECT_EQ(error::kNoError, | |
| 7772 ExecuteImmediateCmd(cmd, sizeof(client_vertexarray_id_))); | |
| 7773 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 7774 EXPECT_TRUE( | |
| 7775 GetVertexArrayInfo(client_vertexarray_id_) == NULL); | |
| 7776 vertex_array_deleted_manually_ = true; | |
| 7777 } | |
| 7778 | |
| 7779 void DeleteVertexArraysOESImmediateInvalidArgs() { | |
| 7780 DeleteVertexArraysOESImmediate& cmd = | |
| 7781 *GetImmediateAs<DeleteVertexArraysOESImmediate>(); | |
| 7782 GLuint temp = kInvalidClientId; | |
| 7783 cmd.Init(1, &temp); | |
| 7784 EXPECT_EQ(error::kNoError, | |
| 7785 ExecuteImmediateCmd(cmd, sizeof(temp))); | |
| 7786 } | |
| 7787 | |
| 7788 void DeleteBoundVertexArraysOESImmediateValidArgs() { | |
| 7789 BindVertexArrayOESValidArgs(); | |
| 7790 | |
| 7791 AddExpectationsForDeleteBoundVertexArraysOES(); | |
| 7792 DeleteVertexArraysOESImmediate& cmd = | |
| 7793 *GetImmediateAs<DeleteVertexArraysOESImmediate>(); | |
| 7794 cmd.Init(1, &client_vertexarray_id_); | |
| 7795 EXPECT_EQ(error::kNoError, | |
| 7796 ExecuteImmediateCmd(cmd, sizeof(client_vertexarray_id_))); | |
| 7797 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 7798 EXPECT_TRUE(GetVertexArrayInfo(client_vertexarray_id_) == NULL); | |
| 7799 vertex_array_deleted_manually_ = true; | |
| 7800 } | |
| 7801 | |
| 7802 void IsVertexArrayOESValidArgs() { | |
| 7803 IsVertexArrayOES cmd; | |
| 7804 cmd.Init(client_vertexarray_id_, shared_memory_id_, shared_memory_offset_); | |
| 7805 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 7806 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 7807 } | |
| 7808 | |
| 7809 void IsVertexArrayOESInvalidArgsBadSharedMemoryId() { | |
| 7810 IsVertexArrayOES cmd; | |
| 7811 cmd.Init( | |
| 7812 client_vertexarray_id_, kInvalidSharedMemoryId, shared_memory_offset_); | |
| 7813 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); | |
| 7814 cmd.Init( | |
| 7815 client_vertexarray_id_, shared_memory_id_, kInvalidSharedMemoryOffset); | |
| 7816 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); | |
| 7817 } | |
| 7818 | |
| 7819 void BindVertexArrayOESValidArgs() { | |
| 7820 AddExpectationsForBindVertexArrayOES(); | |
| 7821 BindVertexArrayOES cmd; | |
| 7822 cmd.Init(client_vertexarray_id_); | |
| 7823 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 7824 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 7825 } | |
| 7826 | |
| 7827 void BindVertexArrayOESValidArgsNewId() { | |
| 7828 BindVertexArrayOES cmd; | |
| 7829 cmd.Init(kNewClientId); | |
| 7830 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 7831 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 7832 } | |
| 7833 }; | |
| 7834 | |
| 7835 class GLES2DecoderEmulatedVertexArraysOESTest | |
| 7836 : public GLES2DecoderVertexArraysOESTest { | |
| 7837 public: | |
| 7838 GLES2DecoderEmulatedVertexArraysOESTest() { } | |
| 7839 | |
| 7840 virtual void SetUp() { | |
| 7841 InitState init; | |
| 7842 init.gl_version = "3.0"; | |
| 7843 init.bind_generates_resource = true; | |
| 7844 InitDecoder(init); | |
| 7845 SetupDefaultProgram(); | |
| 7846 | |
| 7847 AddExpectationsForGenVertexArraysOES(); | |
| 7848 GenHelper<GenVertexArraysOESImmediate>(client_vertexarray_id_); | |
| 7849 | |
| 7850 vertex_array_deleted_manually_ = false; | |
| 7851 } | |
| 7852 }; | |
| 7853 | |
| 7854 // Test vertex array objects with native support | |
| 7855 TEST_F(GLES2DecoderVertexArraysOESTest, GenVertexArraysOESValidArgs) { | |
| 7856 GenVertexArraysOESValidArgs(); | |
| 7857 } | |
| 7858 TEST_F(GLES2DecoderEmulatedVertexArraysOESTest, GenVertexArraysOESValidArgs) { | |
| 7859 GenVertexArraysOESValidArgs(); | |
| 7860 } | |
| 7861 | |
| 7862 TEST_F(GLES2DecoderVertexArraysOESTest, GenVertexArraysOESInvalidArgs) { | |
| 7863 GenVertexArraysOESInvalidArgs(); | |
| 7864 } | |
| 7865 TEST_F(GLES2DecoderEmulatedVertexArraysOESTest, ) { | |
| 7866 GenVertexArraysOESInvalidArgs(); | |
| 7867 } | |
| 7868 | |
| 7869 TEST_F(GLES2DecoderVertexArraysOESTest, GenVertexArraysOESImmediateValidArgs) { | |
| 7870 GenVertexArraysOESImmediateValidArgs(); | |
| 7871 } | |
| 7872 TEST_F(GLES2DecoderEmulatedVertexArraysOESTest, | |
| 7873 GenVertexArraysOESImmediateValidArgs) { | |
| 7874 GenVertexArraysOESImmediateValidArgs(); | |
| 7875 } | |
| 7876 | |
| 7877 TEST_F(GLES2DecoderVertexArraysOESTest, | |
| 7878 GenVertexArraysOESImmediateInvalidArgs) { | |
| 7879 GenVertexArraysOESImmediateInvalidArgs(); | |
| 7880 } | |
| 7881 TEST_F(GLES2DecoderEmulatedVertexArraysOESTest, | |
| 7882 GenVertexArraysOESImmediateInvalidArgs) { | |
| 7883 GenVertexArraysOESImmediateInvalidArgs(); | |
| 7884 } | |
| 7885 | |
| 7886 TEST_F(GLES2DecoderVertexArraysOESTest, DeleteVertexArraysOESValidArgs) { | |
| 7887 DeleteVertexArraysOESValidArgs(); | |
| 7888 } | |
| 7889 TEST_F(GLES2DecoderEmulatedVertexArraysOESTest, | |
| 7890 DeleteVertexArraysOESValidArgs) { | |
| 7891 DeleteVertexArraysOESValidArgs(); | |
| 7892 } | |
| 7893 | |
| 7894 TEST_F(GLES2DecoderVertexArraysOESTest, DeleteVertexArraysOESInvalidArgs) { | |
| 7895 DeleteVertexArraysOESInvalidArgs(); | |
| 7896 } | |
| 7897 TEST_F(GLES2DecoderEmulatedVertexArraysOESTest, | |
| 7898 DeleteVertexArraysOESInvalidArgs) { | |
| 7899 DeleteVertexArraysOESInvalidArgs(); | |
| 7900 } | |
| 7901 | |
| 7902 TEST_F(GLES2DecoderVertexArraysOESTest, | |
| 7903 DeleteVertexArraysOESImmediateValidArgs) { | |
| 7904 DeleteVertexArraysOESImmediateValidArgs(); | |
| 7905 } | |
| 7906 TEST_F(GLES2DecoderEmulatedVertexArraysOESTest, | |
| 7907 DeleteVertexArraysOESImmediateValidArgs) { | |
| 7908 DeleteVertexArraysOESImmediateValidArgs(); | |
| 7909 } | |
| 7910 | |
| 7911 TEST_F(GLES2DecoderVertexArraysOESTest, | |
| 7912 DeleteVertexArraysOESImmediateInvalidArgs) { | |
| 7913 DeleteVertexArraysOESImmediateInvalidArgs(); | |
| 7914 } | |
| 7915 TEST_F(GLES2DecoderEmulatedVertexArraysOESTest, | |
| 7916 DeleteVertexArraysOESImmediateInvalidArgs) { | |
| 7917 DeleteVertexArraysOESImmediateInvalidArgs(); | |
| 7918 } | |
| 7919 | |
| 7920 TEST_F(GLES2DecoderVertexArraysOESTest, | |
| 7921 DeleteBoundVertexArraysOESImmediateValidArgs) { | |
| 7922 DeleteBoundVertexArraysOESImmediateValidArgs(); | |
| 7923 } | |
| 7924 TEST_F(GLES2DecoderEmulatedVertexArraysOESTest, | |
| 7925 DeleteBoundVertexArraysOESImmediateValidArgs) { | |
| 7926 DeleteBoundVertexArraysOESImmediateValidArgs(); | |
| 7927 } | |
| 7928 | |
| 7929 TEST_F(GLES2DecoderVertexArraysOESTest, IsVertexArrayOESValidArgs) { | |
| 7930 IsVertexArrayOESValidArgs(); | |
| 7931 } | |
| 7932 TEST_F(GLES2DecoderEmulatedVertexArraysOESTest, IsVertexArrayOESValidArgs) { | |
| 7933 IsVertexArrayOESValidArgs(); | |
| 7934 } | |
| 7935 | |
| 7936 TEST_F(GLES2DecoderVertexArraysOESTest, | |
| 7937 IsVertexArrayOESInvalidArgsBadSharedMemoryId) { | |
| 7938 IsVertexArrayOESInvalidArgsBadSharedMemoryId(); | |
| 7939 } | |
| 7940 TEST_F(GLES2DecoderEmulatedVertexArraysOESTest, | |
| 7941 IsVertexArrayOESInvalidArgsBadSharedMemoryId) { | |
| 7942 IsVertexArrayOESInvalidArgsBadSharedMemoryId(); | |
| 7943 } | |
| 7944 | |
| 7945 TEST_F(GLES2DecoderVertexArraysOESTest, BindVertexArrayOESValidArgs) { | |
| 7946 BindVertexArrayOESValidArgs(); | |
| 7947 } | |
| 7948 TEST_F(GLES2DecoderEmulatedVertexArraysOESTest, BindVertexArrayOESValidArgs) { | |
| 7949 BindVertexArrayOESValidArgs(); | |
| 7950 } | |
| 7951 | |
| 7952 TEST_F(GLES2DecoderVertexArraysOESTest, BindVertexArrayOESValidArgsNewId) { | |
| 7953 BindVertexArrayOESValidArgsNewId(); | |
| 7954 } | |
| 7955 TEST_F(GLES2DecoderEmulatedVertexArraysOESTest, | |
| 7956 BindVertexArrayOESValidArgsNewId) { | |
| 7957 BindVertexArrayOESValidArgsNewId(); | |
| 7958 } | |
| 7959 | |
| 7960 TEST_F(GLES2DecoderTest, BindTexImage2DCHROMIUM) { | |
| 7961 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 7962 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 7963 0, 0); | |
| 7964 TextureRef* texture_ref = group().texture_manager()->GetTexture( | |
| 7965 client_texture_id_); | |
| 7966 ASSERT_TRUE(texture_ref != NULL); | |
| 7967 Texture* texture = texture_ref->texture(); | |
| 7968 EXPECT_EQ(kServiceTextureId, texture->service_id()); | |
| 7969 | |
| 7970 group().image_manager()->AddImage(gfx::GLImage::CreateGLImage(0).get(), 1); | |
| 7971 EXPECT_FALSE(group().image_manager()->LookupImage(1) == NULL); | |
| 7972 | |
| 7973 GLsizei width; | |
| 7974 GLsizei height; | |
| 7975 GLenum type; | |
| 7976 GLenum internal_format; | |
| 7977 | |
| 7978 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); | |
| 7979 EXPECT_EQ(3, width); | |
| 7980 EXPECT_EQ(1, height); | |
| 7981 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); | |
| 7982 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); | |
| 7983 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); | |
| 7984 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); | |
| 7985 | |
| 7986 // Bind image to texture. | |
| 7987 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. | |
| 7988 EXPECT_CALL(*gl_, GetError()) | |
| 7989 .WillOnce(Return(GL_NO_ERROR)) | |
| 7990 .WillOnce(Return(GL_NO_ERROR)) | |
| 7991 .RetiresOnSaturation(); | |
| 7992 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd; | |
| 7993 bind_tex_image_2d_cmd.Init(GL_TEXTURE_2D, 1); | |
| 7994 EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd)); | |
| 7995 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); | |
| 7996 // Image should now be set. | |
| 7997 EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); | |
| 7998 | |
| 7999 // Define new texture image. | |
| 8000 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 8001 0, 0); | |
| 8002 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); | |
| 8003 // Image should no longer be set. | |
| 8004 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); | |
| 8005 } | |
| 8006 | |
| 8007 TEST_F(GLES2DecoderTest, BindTexImage2DCHROMIUMCubeMapNotAllowed) { | |
| 8008 group().image_manager()->AddImage(gfx::GLImage::CreateGLImage(0).get(), 1); | |
| 8009 DoBindTexture(GL_TEXTURE_CUBE_MAP, client_texture_id_, kServiceTextureId); | |
| 8010 | |
| 8011 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd; | |
| 8012 bind_tex_image_2d_cmd.Init(GL_TEXTURE_CUBE_MAP, 1); | |
| 8013 EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd)); | |
| 8014 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | |
| 8015 } | |
| 8016 | |
| 8017 TEST_F(GLES2DecoderTest, OrphanGLImageWithTexImage2D) { | |
| 8018 group().image_manager()->AddImage(gfx::GLImage::CreateGLImage(0).get(), 1); | |
| 8019 DoBindTexture(GL_TEXTURE_CUBE_MAP, client_texture_id_, kServiceTextureId); | |
| 8020 | |
| 8021 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd; | |
| 8022 bind_tex_image_2d_cmd.Init(GL_TEXTURE_CUBE_MAP, 1); | |
| 8023 EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd)); | |
| 8024 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | |
| 8025 | |
| 8026 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 8027 0, 0); | |
| 8028 TextureRef* texture_ref = group().texture_manager()->GetTexture( | |
| 8029 client_texture_id_); | |
| 8030 ASSERT_TRUE(texture_ref != NULL); | |
| 8031 Texture* texture = texture_ref->texture(); | |
| 8032 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); | |
| 8033 } | |
| 8034 | |
| 8035 TEST_F(GLES2DecoderTest, ReleaseTexImage2DCHROMIUM) { | |
| 8036 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 8037 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 8038 0, 0); | |
| 8039 TextureRef* texture_ref = group().texture_manager()->GetTexture( | |
| 8040 client_texture_id_); | |
| 8041 ASSERT_TRUE(texture_ref != NULL); | |
| 8042 Texture* texture = texture_ref->texture(); | |
| 8043 EXPECT_EQ(kServiceTextureId, texture->service_id()); | |
| 8044 | |
| 8045 group().image_manager()->AddImage(gfx::GLImage::CreateGLImage(0).get(), 1); | |
| 8046 EXPECT_FALSE(group().image_manager()->LookupImage(1) == NULL); | |
| 8047 | |
| 8048 GLsizei width; | |
| 8049 GLsizei height; | |
| 8050 GLenum type; | |
| 8051 GLenum internal_format; | |
| 8052 | |
| 8053 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); | |
| 8054 EXPECT_EQ(3, width); | |
| 8055 EXPECT_EQ(1, height); | |
| 8056 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); | |
| 8057 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); | |
| 8058 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); | |
| 8059 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); | |
| 8060 | |
| 8061 // Bind image to texture. | |
| 8062 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. | |
| 8063 EXPECT_CALL(*gl_, GetError()) | |
| 8064 .WillOnce(Return(GL_NO_ERROR)) | |
| 8065 .WillOnce(Return(GL_NO_ERROR)) | |
| 8066 .RetiresOnSaturation(); | |
| 8067 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd; | |
| 8068 bind_tex_image_2d_cmd.Init(GL_TEXTURE_2D, 1); | |
| 8069 EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd)); | |
| 8070 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); | |
| 8071 // Image should now be set. | |
| 8072 EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); | |
| 8073 | |
| 8074 // Release image from texture. | |
| 8075 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. | |
| 8076 EXPECT_CALL(*gl_, GetError()) | |
| 8077 .WillOnce(Return(GL_NO_ERROR)) | |
| 8078 .WillOnce(Return(GL_NO_ERROR)) | |
| 8079 .RetiresOnSaturation(); | |
| 8080 ReleaseTexImage2DCHROMIUM release_tex_image_2d_cmd; | |
| 8081 release_tex_image_2d_cmd.Init(GL_TEXTURE_2D, 1); | |
| 8082 EXPECT_EQ(error::kNoError, ExecuteCmd(release_tex_image_2d_cmd)); | |
| 8083 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); | |
| 8084 // Image should no longer be set. | |
| 8085 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); | |
| 8086 } | |
| 8087 | |
| 8088 class MockGLImage : public gfx::GLImage { | |
| 8089 public: | |
| 8090 MockGLImage() {} | |
| 8091 | |
| 8092 // Overridden from gfx::GLImage: | |
| 8093 MOCK_METHOD0(Destroy, void()); | |
| 8094 MOCK_METHOD0(GetSize, gfx::Size()); | |
| 8095 MOCK_METHOD1(BindTexImage, bool(unsigned)); | |
| 8096 MOCK_METHOD1(ReleaseTexImage, void(unsigned)); | |
| 8097 MOCK_METHOD0(WillUseTexImage, void()); | |
| 8098 MOCK_METHOD0(DidUseTexImage, void()); | |
| 8099 MOCK_METHOD0(WillModifyTexImage, void()); | |
| 8100 MOCK_METHOD0(DidModifyTexImage, void()); | |
| 8101 | |
| 8102 protected: | |
| 8103 virtual ~MockGLImage() {} | |
| 8104 }; | |
| 8105 | |
| 8106 TEST_F(GLES2DecoderWithShaderTest, UseTexImage) { | |
| 8107 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 8108 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 8109 kSharedMemoryId, kSharedMemoryOffset); | |
| 8110 | |
| 8111 TextureRef* texture_ref = group().texture_manager()->GetTexture( | |
| 8112 client_texture_id_); | |
| 8113 ASSERT_TRUE(texture_ref != NULL); | |
| 8114 Texture* texture = texture_ref->texture(); | |
| 8115 EXPECT_EQ(kServiceTextureId, texture->service_id()); | |
| 8116 | |
| 8117 const int32 kImageId = 1; | |
| 8118 scoped_refptr<MockGLImage> image(new MockGLImage); | |
| 8119 group().image_manager()->AddImage(image.get(), kImageId); | |
| 8120 | |
| 8121 // Bind image to texture. | |
| 8122 EXPECT_CALL(*image, BindTexImage(GL_TEXTURE_2D)) | |
| 8123 .Times(1) | |
| 8124 .WillOnce(Return(true)) | |
| 8125 .RetiresOnSaturation(); | |
| 8126 EXPECT_CALL(*image, GetSize()) | |
| 8127 .Times(1) | |
| 8128 .WillOnce(Return(gfx::Size(1, 1))) | |
| 8129 .RetiresOnSaturation(); | |
| 8130 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. | |
| 8131 EXPECT_CALL(*gl_, GetError()) | |
| 8132 .WillOnce(Return(GL_NO_ERROR)) | |
| 8133 .WillOnce(Return(GL_NO_ERROR)) | |
| 8134 .RetiresOnSaturation(); | |
| 8135 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd; | |
| 8136 bind_tex_image_2d_cmd.Init(GL_TEXTURE_2D, kImageId); | |
| 8137 EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd)); | |
| 8138 | |
| 8139 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); | |
| 8140 SetupExpectationsForApplyingDefaultDirtyState(); | |
| 8141 | |
| 8142 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. | |
| 8143 EXPECT_CALL(*gl_, GetError()) | |
| 8144 .WillOnce(Return(GL_NO_ERROR)) | |
| 8145 .WillOnce(Return(GL_NO_ERROR)) | |
| 8146 .WillOnce(Return(GL_NO_ERROR)) | |
| 8147 .WillOnce(Return(GL_NO_ERROR)) | |
| 8148 .RetiresOnSaturation(); | |
| 8149 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)) | |
| 8150 .Times(3) | |
| 8151 .RetiresOnSaturation(); | |
| 8152 EXPECT_CALL(*image, WillUseTexImage()) | |
| 8153 .Times(1) | |
| 8154 .RetiresOnSaturation(); | |
| 8155 EXPECT_CALL(*image, DidUseTexImage()) | |
| 8156 .Times(1) | |
| 8157 .RetiresOnSaturation(); | |
| 8158 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | |
| 8159 .Times(1) | |
| 8160 .RetiresOnSaturation(); | |
| 8161 DrawArrays cmd; | |
| 8162 cmd.Init(GL_TRIANGLES, 0, kNumVertices); | |
| 8163 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 8164 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 8165 | |
| 8166 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, | |
| 8167 kServiceFramebufferId); | |
| 8168 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. | |
| 8169 EXPECT_CALL(*gl_, GetError()) | |
| 8170 .WillOnce(Return(GL_NO_ERROR)) | |
| 8171 .WillOnce(Return(GL_NO_ERROR)) | |
| 8172 .RetiresOnSaturation(); | |
| 8173 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)) | |
| 8174 .Times(1) | |
| 8175 .RetiresOnSaturation(); | |
| 8176 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId)) | |
| 8177 .Times(2) | |
| 8178 .RetiresOnSaturation(); | |
| 8179 // Image will be 'in use' as long as bound to a framebuffer. | |
| 8180 EXPECT_CALL(*image, WillUseTexImage()) | |
| 8181 .Times(1) | |
| 8182 .RetiresOnSaturation(); | |
| 8183 EXPECT_CALL(*gl_, FramebufferTexture2DEXT( | |
| 8184 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, | |
| 8185 kServiceTextureId, 0)) | |
| 8186 .Times(1) | |
| 8187 .RetiresOnSaturation(); | |
| 8188 EXPECT_CALL(*gl_, GetError()) | |
| 8189 .WillOnce(Return(GL_NO_ERROR)) | |
| 8190 .WillOnce(Return(GL_NO_ERROR)) | |
| 8191 .RetiresOnSaturation(); | |
| 8192 FramebufferTexture2D fbtex_cmd; | |
| 8193 fbtex_cmd.Init( | |
| 8194 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, client_texture_id_, | |
| 8195 0); | |
| 8196 EXPECT_EQ(error::kNoError, ExecuteCmd(fbtex_cmd)); | |
| 8197 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 8198 | |
| 8199 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. | |
| 8200 EXPECT_CALL(*gl_, GetError()) | |
| 8201 .WillOnce(Return(GL_NO_ERROR)) | |
| 8202 .WillOnce(Return(GL_NO_ERROR)) | |
| 8203 .RetiresOnSaturation(); | |
| 8204 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT( | |
| 8205 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, | |
| 8206 kServiceRenderbufferId)) | |
| 8207 .Times(1) | |
| 8208 .RetiresOnSaturation(); | |
| 8209 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)) | |
| 8210 .Times(1) | |
| 8211 .RetiresOnSaturation(); | |
| 8212 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId)) | |
| 8213 .Times(2) | |
| 8214 .RetiresOnSaturation(); | |
| 8215 // Image should no longer be 'in use' after being unbound from framebuffer. | |
| 8216 EXPECT_CALL(*image, DidUseTexImage()) | |
| 8217 .Times(1) | |
| 8218 .RetiresOnSaturation(); | |
| 8219 EXPECT_CALL(*gl_, GetError()) | |
| 8220 .WillOnce(Return(GL_NO_ERROR)) | |
| 8221 .WillOnce(Return(GL_NO_ERROR)) | |
| 8222 .RetiresOnSaturation(); | |
| 8223 FramebufferRenderbuffer fbrb_cmd; | |
| 8224 fbrb_cmd.Init( | |
| 8225 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, | |
| 8226 client_renderbuffer_id_); | |
| 8227 EXPECT_EQ(error::kNoError, ExecuteCmd(fbrb_cmd)); | |
| 8228 } | |
| 8229 | |
| 8230 TEST_F(GLES2DecoderManualInitTest, DrawWithGLImageExternal) { | |
| 8231 InitState init; | |
| 8232 init.extensions = "GL_OES_EGL_image_external"; | |
| 8233 init.gl_version = "opengl es 2.0"; | |
| 8234 init.has_alpha = true; | |
| 8235 init.has_depth = true; | |
| 8236 init.request_alpha = true; | |
| 8237 init.request_depth = true; | |
| 8238 init.bind_generates_resource = true; | |
| 8239 InitDecoder(init); | |
| 8240 | |
| 8241 TextureRef* texture_ref = GetTexture(client_texture_id_); | |
| 8242 scoped_refptr<MockGLImage> image(new MockGLImage); | |
| 8243 group().texture_manager()->SetTarget(texture_ref, GL_TEXTURE_EXTERNAL_OES); | |
| 8244 group().texture_manager()->SetLevelInfo(texture_ref, | |
| 8245 GL_TEXTURE_EXTERNAL_OES, | |
| 8246 0, | |
| 8247 GL_RGBA, | |
| 8248 0, | |
| 8249 0, | |
| 8250 1, | |
| 8251 0, | |
| 8252 GL_RGBA, | |
| 8253 GL_UNSIGNED_BYTE, | |
| 8254 true); | |
| 8255 group().texture_manager()->SetLevelImage( | |
| 8256 texture_ref, GL_TEXTURE_EXTERNAL_OES, 0, image); | |
| 8257 | |
| 8258 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); | |
| 8259 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 8260 | |
| 8261 SetupSamplerExternalProgram(); | |
| 8262 SetupIndexBuffer(); | |
| 8263 AddExpectationsForSimulatedAttrib0(kMaxValidIndex + 1, 0); | |
| 8264 SetupExpectationsForApplyingDefaultDirtyState(); | |
| 8265 EXPECT_TRUE(group().texture_manager()->CanRender(texture_ref)); | |
| 8266 | |
| 8267 InSequence s; | |
| 8268 EXPECT_CALL(*gl_, GetError()) | |
| 8269 .WillOnce(Return(GL_NO_ERROR)) | |
| 8270 .RetiresOnSaturation(); | |
| 8271 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)) | |
| 8272 .Times(1) | |
| 8273 .RetiresOnSaturation(); | |
| 8274 EXPECT_CALL(*image, WillUseTexImage()) | |
| 8275 .Times(1) | |
| 8276 .RetiresOnSaturation(); | |
| 8277 EXPECT_CALL(*gl_, GetError()) | |
| 8278 .WillOnce(Return(GL_NO_ERROR)) | |
| 8279 .RetiresOnSaturation(); | |
| 8280 EXPECT_CALL(*gl_, DrawElements(_, _, _, _)) | |
| 8281 .Times(1); | |
| 8282 EXPECT_CALL(*gl_, GetError()) | |
| 8283 .WillOnce(Return(GL_NO_ERROR)) | |
| 8284 .RetiresOnSaturation(); | |
| 8285 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)) | |
| 8286 .Times(1) | |
| 8287 .RetiresOnSaturation(); | |
| 8288 EXPECT_CALL(*image, DidUseTexImage()) | |
| 8289 .Times(1) | |
| 8290 .RetiresOnSaturation(); | |
| 8291 EXPECT_CALL(*gl_, GetError()) | |
| 8292 .WillOnce(Return(GL_NO_ERROR)) | |
| 8293 .RetiresOnSaturation(); | |
| 8294 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)) | |
| 8295 .Times(1) | |
| 8296 .RetiresOnSaturation(); | |
| 8297 DrawElements cmd; | |
| 8298 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, | |
| 8299 kValidIndexRangeStart * 2); | |
| 8300 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 8301 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 8302 } | |
| 8303 | |
| 8304 TEST_F(GLES2DecoderManualInitTest, GpuMemoryManagerCHROMIUM) { | 916 TEST_F(GLES2DecoderManualInitTest, GpuMemoryManagerCHROMIUM) { |
| 8305 InitState init; | 917 InitState init; |
| 8306 init.extensions = "GL_ARB_texture_rectangle"; | 918 init.extensions = "GL_ARB_texture_rectangle"; |
| 8307 init.gl_version = "3.0"; | 919 init.gl_version = "3.0"; |
| 8308 init.bind_generates_resource = true; | 920 init.bind_generates_resource = true; |
| 8309 InitDecoder(init); | 921 InitDecoder(init); |
| 8310 | 922 |
| 8311 Texture* texture = GetTexture(client_texture_id_)->texture(); | 923 Texture* texture = GetTexture(client_texture_id_)->texture(); |
| 8312 EXPECT_TRUE(texture != NULL); | 924 EXPECT_TRUE(texture != NULL); |
| 8313 EXPECT_TRUE(texture->pool() == GL_TEXTURE_POOL_UNMANAGED_CHROMIUM); | 925 EXPECT_TRUE(texture->pool() == GL_TEXTURE_POOL_UNMANAGED_CHROMIUM); |
| 8314 | 926 |
| 8315 DoBindTexture( | 927 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 8316 GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 8317 | 928 |
| 8318 TexParameteri cmd; | 929 TexParameteri cmd; |
| 8319 cmd.Init(GL_TEXTURE_2D, | 930 cmd.Init(GL_TEXTURE_2D, |
| 8320 GL_TEXTURE_POOL_CHROMIUM, | 931 GL_TEXTURE_POOL_CHROMIUM, |
| 8321 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM); | 932 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM); |
| 8322 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 933 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 8323 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 934 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 8324 | 935 |
| 8325 cmd.Init(GL_TEXTURE_2D, | 936 cmd.Init(GL_TEXTURE_2D, |
| 8326 GL_TEXTURE_POOL_CHROMIUM, | 937 GL_TEXTURE_POOL_CHROMIUM, |
| 8327 GL_TEXTURE_POOL_MANAGED_CHROMIUM); | 938 GL_TEXTURE_POOL_MANAGED_CHROMIUM); |
| 8328 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 939 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 8329 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 940 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 8330 | 941 |
| 8331 EXPECT_TRUE(texture->pool() == GL_TEXTURE_POOL_MANAGED_CHROMIUM); | 942 EXPECT_TRUE(texture->pool() == GL_TEXTURE_POOL_MANAGED_CHROMIUM); |
| 8332 | 943 |
| 8333 cmd.Init(GL_TEXTURE_2D, | 944 cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_POOL_CHROMIUM, GL_NONE); |
| 8334 GL_TEXTURE_POOL_CHROMIUM, | |
| 8335 GL_NONE); | |
| 8336 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 945 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 8337 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); | 946 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 8338 } | 947 } |
| 8339 | 948 |
| 8340 TEST_F(GLES2DecoderManualInitTest, AsyncPixelTransfers) { | |
| 8341 InitState init; | |
| 8342 init.extensions = "GL_CHROMIUM_async_pixel_transfers"; | |
| 8343 init.gl_version = "3.0"; | |
| 8344 init.bind_generates_resource = true; | |
| 8345 InitDecoder(init); | |
| 8346 | |
| 8347 // Set up the texture. | |
| 8348 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 8349 TextureRef* texture_ref = GetTexture(client_texture_id_); | |
| 8350 Texture* texture = texture_ref->texture(); | |
| 8351 | |
| 8352 // Set a mock Async delegate | |
| 8353 StrictMock<gpu::MockAsyncPixelTransferManager>* manager = | |
| 8354 new StrictMock<gpu::MockAsyncPixelTransferManager>; | |
| 8355 manager->Initialize(group().texture_manager()); | |
| 8356 decoder_->SetAsyncPixelTransferManagerForTest(manager); | |
| 8357 StrictMock<gpu::MockAsyncPixelTransferDelegate>* delegate = NULL; | |
| 8358 | |
| 8359 // Tex(Sub)Image2D upload commands. | |
| 8360 AsyncTexImage2DCHROMIUM teximage_cmd; | |
| 8361 teximage_cmd.Init(GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0, GL_RGBA, | |
| 8362 GL_UNSIGNED_BYTE, kSharedMemoryId, kSharedMemoryOffset, | |
| 8363 0, 0, 0); | |
| 8364 AsyncTexSubImage2DCHROMIUM texsubimage_cmd; | |
| 8365 texsubimage_cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 8, 8, GL_RGBA, | |
| 8366 GL_UNSIGNED_BYTE, kSharedMemoryId, kSharedMemoryOffset, | |
| 8367 0, 0, 0); | |
| 8368 WaitAsyncTexImage2DCHROMIUM wait_cmd; | |
| 8369 wait_cmd.Init(GL_TEXTURE_2D); | |
| 8370 WaitAllAsyncTexImage2DCHROMIUM wait_all_cmd; | |
| 8371 wait_all_cmd.Init(); | |
| 8372 | |
| 8373 // No transfer state exists initially. | |
| 8374 EXPECT_FALSE( | |
| 8375 decoder_->GetAsyncPixelTransferManager()->GetPixelTransferDelegate( | |
| 8376 texture_ref)); | |
| 8377 | |
| 8378 base::Closure bind_callback; | |
| 8379 | |
| 8380 // AsyncTexImage2D | |
| 8381 { | |
| 8382 // Create transfer state since it doesn't exist. | |
| 8383 EXPECT_EQ(texture_ref->num_observers(), 0); | |
| 8384 EXPECT_CALL(*manager, CreatePixelTransferDelegateImpl(texture_ref, _)) | |
| 8385 .WillOnce(Return( | |
| 8386 delegate = new StrictMock<gpu::MockAsyncPixelTransferDelegate>)) | |
| 8387 .RetiresOnSaturation(); | |
| 8388 EXPECT_CALL(*delegate, AsyncTexImage2D(_, _, _)) | |
| 8389 .WillOnce(SaveArg<2>(&bind_callback)) | |
| 8390 .RetiresOnSaturation(); | |
| 8391 // Command succeeds. | |
| 8392 EXPECT_EQ(error::kNoError, ExecuteCmd(teximage_cmd)); | |
| 8393 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 8394 EXPECT_EQ( | |
| 8395 delegate, | |
| 8396 decoder_->GetAsyncPixelTransferManager()->GetPixelTransferDelegate( | |
| 8397 texture_ref)); | |
| 8398 EXPECT_TRUE(texture->IsImmutable()); | |
| 8399 // The texture is safe but the level has not been defined yet. | |
| 8400 EXPECT_TRUE(texture->SafeToRenderFrom()); | |
| 8401 GLsizei width, height; | |
| 8402 EXPECT_FALSE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); | |
| 8403 EXPECT_EQ(texture_ref->num_observers(), 1); | |
| 8404 } | |
| 8405 { | |
| 8406 // Async redefinitions are not allowed! | |
| 8407 // Command fails. | |
| 8408 EXPECT_EQ(error::kNoError, ExecuteCmd(teximage_cmd)); | |
| 8409 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 8410 EXPECT_EQ( | |
| 8411 delegate, | |
| 8412 decoder_->GetAsyncPixelTransferManager()->GetPixelTransferDelegate( | |
| 8413 texture_ref)); | |
| 8414 EXPECT_TRUE(texture->IsImmutable()); | |
| 8415 EXPECT_TRUE(texture->SafeToRenderFrom()); | |
| 8416 } | |
| 8417 | |
| 8418 // Binding/defining of the async transfer | |
| 8419 { | |
| 8420 // TODO(epenner): We should check that the manager gets the | |
| 8421 // BindCompletedAsyncTransfers() call, which is required to | |
| 8422 // guarantee the delegate calls the bind callback. | |
| 8423 | |
| 8424 // Simulate the bind callback from the delegate. | |
| 8425 bind_callback.Run(); | |
| 8426 | |
| 8427 // After the bind callback is run, the texture is safe, | |
| 8428 // and has the right size etc. | |
| 8429 EXPECT_TRUE(texture->SafeToRenderFrom()); | |
| 8430 GLsizei width, height; | |
| 8431 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); | |
| 8432 EXPECT_EQ(width, 8); | |
| 8433 EXPECT_EQ(height, 8); | |
| 8434 } | |
| 8435 | |
| 8436 // AsyncTexSubImage2D | |
| 8437 EXPECT_CALL(*delegate, Destroy()).RetiresOnSaturation(); | |
| 8438 decoder_->GetAsyncPixelTransferManager() | |
| 8439 ->ClearPixelTransferDelegateForTest(texture_ref); | |
| 8440 EXPECT_EQ(texture_ref->num_observers(), 0); | |
| 8441 texture->SetImmutable(false); | |
| 8442 { | |
| 8443 // Create transfer state since it doesn't exist. | |
| 8444 EXPECT_CALL(*manager, CreatePixelTransferDelegateImpl(texture_ref, _)) | |
| 8445 .WillOnce(Return( | |
| 8446 delegate = new StrictMock<gpu::MockAsyncPixelTransferDelegate>)) | |
| 8447 .RetiresOnSaturation(); | |
| 8448 EXPECT_CALL(*delegate, AsyncTexSubImage2D(_, _)) | |
| 8449 .RetiresOnSaturation(); | |
| 8450 // Command succeeds. | |
| 8451 EXPECT_EQ(error::kNoError, ExecuteCmd(texsubimage_cmd)); | |
| 8452 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 8453 EXPECT_EQ( | |
| 8454 delegate, | |
| 8455 decoder_->GetAsyncPixelTransferManager()->GetPixelTransferDelegate( | |
| 8456 texture_ref)); | |
| 8457 EXPECT_TRUE(texture->IsImmutable()); | |
| 8458 EXPECT_TRUE(texture->SafeToRenderFrom()); | |
| 8459 } | |
| 8460 { | |
| 8461 // No transfer is in progress. | |
| 8462 EXPECT_CALL(*delegate, TransferIsInProgress()) | |
| 8463 .WillOnce(Return(false)) // texSubImage validation | |
| 8464 .WillOnce(Return(false)) // async validation | |
| 8465 .RetiresOnSaturation(); | |
| 8466 EXPECT_CALL(*delegate, AsyncTexSubImage2D(_, _)) | |
| 8467 .RetiresOnSaturation(); | |
| 8468 // Command succeeds. | |
| 8469 EXPECT_EQ(error::kNoError, ExecuteCmd(texsubimage_cmd)); | |
| 8470 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 8471 EXPECT_EQ( | |
| 8472 delegate, | |
| 8473 decoder_->GetAsyncPixelTransferManager()->GetPixelTransferDelegate( | |
| 8474 texture_ref)); | |
| 8475 EXPECT_TRUE(texture->IsImmutable()); | |
| 8476 EXPECT_TRUE(texture->SafeToRenderFrom()); | |
| 8477 } | |
| 8478 { | |
| 8479 // A transfer is still in progress! | |
| 8480 EXPECT_CALL(*delegate, TransferIsInProgress()) | |
| 8481 .WillOnce(Return(true)) | |
| 8482 .RetiresOnSaturation(); | |
| 8483 // No async call, command fails. | |
| 8484 EXPECT_EQ(error::kNoError, ExecuteCmd(texsubimage_cmd)); | |
| 8485 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 8486 EXPECT_EQ( | |
| 8487 delegate, | |
| 8488 decoder_->GetAsyncPixelTransferManager()->GetPixelTransferDelegate( | |
| 8489 texture_ref)); | |
| 8490 EXPECT_TRUE(texture->IsImmutable()); | |
| 8491 EXPECT_TRUE(texture->SafeToRenderFrom()); | |
| 8492 } | |
| 8493 | |
| 8494 // Delete delegate on DeleteTexture. | |
| 8495 { | |
| 8496 EXPECT_EQ(texture_ref->num_observers(), 1); | |
| 8497 EXPECT_CALL(*delegate, Destroy()).RetiresOnSaturation(); | |
| 8498 DoDeleteTexture(client_texture_id_, kServiceTextureId); | |
| 8499 EXPECT_FALSE( | |
| 8500 decoder_->GetAsyncPixelTransferManager()->GetPixelTransferDelegate( | |
| 8501 texture_ref)); | |
| 8502 texture = NULL; | |
| 8503 texture_ref = NULL; | |
| 8504 delegate = NULL; | |
| 8505 } | |
| 8506 | |
| 8507 // WaitAsyncTexImage2D | |
| 8508 { | |
| 8509 // Get a fresh texture since the existing texture cannot be respecified | |
| 8510 // asynchronously and AsyncTexSubImage2D does not involve binding. | |
| 8511 EXPECT_CALL(*gl_, GenTextures(1, _)) | |
| 8512 .WillOnce(SetArgumentPointee<1>(kServiceTextureId)); | |
| 8513 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 8514 texture_ref = GetTexture(client_texture_id_); | |
| 8515 texture = texture_ref->texture(); | |
| 8516 texture->SetImmutable(false); | |
| 8517 // Create transfer state since it doesn't exist. | |
| 8518 EXPECT_CALL(*manager, CreatePixelTransferDelegateImpl(texture_ref, _)) | |
| 8519 .WillOnce(Return( | |
| 8520 delegate = new StrictMock<gpu::MockAsyncPixelTransferDelegate>)) | |
| 8521 .RetiresOnSaturation(); | |
| 8522 EXPECT_CALL(*delegate, AsyncTexImage2D(_, _, _)) | |
| 8523 .RetiresOnSaturation(); | |
| 8524 // Start async transfer. | |
| 8525 EXPECT_EQ(error::kNoError, ExecuteCmd(teximage_cmd)); | |
| 8526 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 8527 EXPECT_EQ( | |
| 8528 delegate, | |
| 8529 decoder_->GetAsyncPixelTransferManager()->GetPixelTransferDelegate( | |
| 8530 texture_ref)); | |
| 8531 | |
| 8532 EXPECT_TRUE(texture->IsImmutable()); | |
| 8533 // Wait for completion. | |
| 8534 EXPECT_CALL(*delegate, WaitForTransferCompletion()); | |
| 8535 EXPECT_CALL(*manager, BindCompletedAsyncTransfers()); | |
| 8536 EXPECT_EQ(error::kNoError, ExecuteCmd(wait_cmd)); | |
| 8537 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 8538 } | |
| 8539 | |
| 8540 // WaitAllAsyncTexImage2D | |
| 8541 EXPECT_CALL(*delegate, Destroy()).RetiresOnSaturation(); | |
| 8542 DoDeleteTexture(client_texture_id_, kServiceTextureId); | |
| 8543 EXPECT_FALSE( | |
| 8544 decoder_->GetAsyncPixelTransferManager()->GetPixelTransferDelegate( | |
| 8545 texture_ref)); | |
| 8546 texture = NULL; | |
| 8547 texture_ref = NULL; | |
| 8548 delegate = NULL; | |
| 8549 { | |
| 8550 // Get a fresh texture since the existing texture cannot be respecified | |
| 8551 // asynchronously and AsyncTexSubImage2D does not involve binding. | |
| 8552 EXPECT_CALL(*gl_, GenTextures(1, _)) | |
| 8553 .WillOnce(SetArgumentPointee<1>(kServiceTextureId)); | |
| 8554 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 8555 texture_ref = GetTexture(client_texture_id_); | |
| 8556 texture = texture_ref->texture(); | |
| 8557 texture->SetImmutable(false); | |
| 8558 // Create transfer state since it doesn't exist. | |
| 8559 EXPECT_CALL(*manager, CreatePixelTransferDelegateImpl(texture_ref, _)) | |
| 8560 .WillOnce(Return( | |
| 8561 delegate = new StrictMock<gpu::MockAsyncPixelTransferDelegate>)) | |
| 8562 .RetiresOnSaturation(); | |
| 8563 EXPECT_CALL(*delegate, AsyncTexImage2D(_, _, _)) | |
| 8564 .RetiresOnSaturation(); | |
| 8565 // Start async transfer. | |
| 8566 EXPECT_EQ(error::kNoError, ExecuteCmd(teximage_cmd)); | |
| 8567 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 8568 EXPECT_EQ( | |
| 8569 delegate, | |
| 8570 decoder_->GetAsyncPixelTransferManager()->GetPixelTransferDelegate( | |
| 8571 texture_ref)); | |
| 8572 | |
| 8573 EXPECT_TRUE(texture->IsImmutable()); | |
| 8574 // Wait for completion of all uploads. | |
| 8575 EXPECT_CALL(*manager, WaitAllAsyncTexImage2D()).RetiresOnSaturation(); | |
| 8576 EXPECT_CALL(*manager, BindCompletedAsyncTransfers()); | |
| 8577 EXPECT_EQ(error::kNoError, ExecuteCmd(wait_all_cmd)); | |
| 8578 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 8579 } | |
| 8580 | |
| 8581 // Remove PixelTransferManager before the decoder destroys. | |
| 8582 EXPECT_CALL(*delegate, Destroy()).RetiresOnSaturation(); | |
| 8583 decoder_->ResetAsyncPixelTransferManagerForTest(); | |
| 8584 manager = NULL; | |
| 8585 } | |
| 8586 | |
| 8587 TEST_F(GLES2DecoderManualInitTest, AsyncPixelTransferManager) { | |
| 8588 InitState init; | |
| 8589 init.extensions = "GL_CHROMIUM_async_pixel_transfers"; | |
| 8590 init.gl_version = "3.0"; | |
| 8591 init.bind_generates_resource = true; | |
| 8592 InitDecoder(init); | |
| 8593 | |
| 8594 // Set up the texture. | |
| 8595 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 8596 TextureRef* texture_ref = GetTexture(client_texture_id_); | |
| 8597 | |
| 8598 // Set a mock Async delegate. | |
| 8599 StrictMock<gpu::MockAsyncPixelTransferManager>* manager = | |
| 8600 new StrictMock<gpu::MockAsyncPixelTransferManager>; | |
| 8601 manager->Initialize(group().texture_manager()); | |
| 8602 decoder_->SetAsyncPixelTransferManagerForTest(manager); | |
| 8603 StrictMock<gpu::MockAsyncPixelTransferDelegate>* delegate = NULL; | |
| 8604 | |
| 8605 AsyncTexImage2DCHROMIUM teximage_cmd; | |
| 8606 teximage_cmd.Init(GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0, GL_RGBA, | |
| 8607 GL_UNSIGNED_BYTE, kSharedMemoryId, kSharedMemoryOffset, | |
| 8608 0, 0, 0); | |
| 8609 | |
| 8610 // No transfer delegate exists initially. | |
| 8611 EXPECT_FALSE( | |
| 8612 decoder_->GetAsyncPixelTransferManager()->GetPixelTransferDelegate( | |
| 8613 texture_ref)); | |
| 8614 | |
| 8615 // Create delegate on AsyncTexImage2D. | |
| 8616 { | |
| 8617 EXPECT_CALL(*manager, CreatePixelTransferDelegateImpl(texture_ref, _)) | |
| 8618 .WillOnce(Return( | |
| 8619 delegate = new StrictMock<gpu::MockAsyncPixelTransferDelegate>)) | |
| 8620 .RetiresOnSaturation(); | |
| 8621 EXPECT_CALL(*delegate, AsyncTexImage2D(_, _, _)).RetiresOnSaturation(); | |
| 8622 | |
| 8623 // Command succeeds. | |
| 8624 EXPECT_EQ(error::kNoError, ExecuteCmd(teximage_cmd)); | |
| 8625 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 8626 } | |
| 8627 | |
| 8628 // Delegate is cached. | |
| 8629 EXPECT_EQ(delegate, | |
| 8630 decoder_->GetAsyncPixelTransferManager()->GetPixelTransferDelegate( | |
| 8631 texture_ref)); | |
| 8632 | |
| 8633 // Delete delegate on manager teardown. | |
| 8634 { | |
| 8635 EXPECT_EQ(texture_ref->num_observers(), 1); | |
| 8636 EXPECT_CALL(*delegate, Destroy()).RetiresOnSaturation(); | |
| 8637 decoder_->ResetAsyncPixelTransferManagerForTest(); | |
| 8638 manager = NULL; | |
| 8639 | |
| 8640 // Texture ref still valid. | |
| 8641 EXPECT_EQ(texture_ref, GetTexture(client_texture_id_)); | |
| 8642 EXPECT_EQ(texture_ref->num_observers(), 0); | |
| 8643 } | |
| 8644 } | |
| 8645 | |
| 8646 namespace { | 949 namespace { |
| 8647 | 950 |
| 8648 class SizeOnlyMemoryTracker : public MemoryTracker { | 951 class SizeOnlyMemoryTracker : public MemoryTracker { |
| 8649 public: | 952 public: |
| 8650 SizeOnlyMemoryTracker() { | 953 SizeOnlyMemoryTracker() { |
| 8651 // These are the default textures. 1 for TEXTURE_2D and 6 faces for | 954 // These are the default textures. 1 for TEXTURE_2D and 6 faces for |
| 8652 // TEXTURE_CUBE_MAP. | 955 // TEXTURE_CUBE_MAP. |
| 8653 const size_t kInitialUnmanagedPoolSize = 7 * 4; | 956 const size_t kInitialUnmanagedPoolSize = 7 * 4; |
| 8654 const size_t kInitialManagedPoolSize = 0; | 957 const size_t kInitialManagedPoolSize = 0; |
| 8655 pool_infos_[MemoryTracker::kUnmanaged].initial_size = | 958 pool_infos_[MemoryTracker::kUnmanaged].initial_size = |
| 8656 kInitialUnmanagedPoolSize; | 959 kInitialUnmanagedPoolSize; |
| 8657 pool_infos_[MemoryTracker::kManaged].initial_size = | 960 pool_infos_[MemoryTracker::kManaged].initial_size = kInitialManagedPoolSize; |
| 8658 kInitialManagedPoolSize; | |
| 8659 } | 961 } |
| 8660 | 962 |
| 8661 // Ensure a certain amount of GPU memory is free. Returns true on success. | 963 // Ensure a certain amount of GPU memory is free. Returns true on success. |
| 8662 MOCK_METHOD1(EnsureGPUMemoryAvailable, bool(size_t size_needed)); | 964 MOCK_METHOD1(EnsureGPUMemoryAvailable, bool(size_t size_needed)); |
| 8663 | 965 |
| 8664 virtual void TrackMemoryAllocatedChange( | 966 virtual void TrackMemoryAllocatedChange(size_t old_size, |
| 8665 size_t old_size, size_t new_size, Pool pool) { | 967 size_t new_size, |
| 968 Pool pool) { |
| 8666 PoolInfo& info = pool_infos_[pool]; | 969 PoolInfo& info = pool_infos_[pool]; |
| 8667 info.size += new_size - old_size; | 970 info.size += new_size - old_size; |
| 8668 } | 971 } |
| 8669 | 972 |
| 8670 size_t GetPoolSize(Pool pool) { | 973 size_t GetPoolSize(Pool pool) { |
| 8671 const PoolInfo& info = pool_infos_[pool]; | 974 const PoolInfo& info = pool_infos_[pool]; |
| 8672 return info.size - info.initial_size; | 975 return info.size - info.initial_size; |
| 8673 } | 976 } |
| 8674 | 977 |
| 8675 private: | 978 private: |
| 8676 virtual ~SizeOnlyMemoryTracker() { | 979 virtual ~SizeOnlyMemoryTracker() {} |
| 8677 } | |
| 8678 struct PoolInfo { | 980 struct PoolInfo { |
| 8679 PoolInfo() | 981 PoolInfo() : initial_size(0), size(0) {} |
| 8680 : initial_size(0), | |
| 8681 size(0) { | |
| 8682 } | |
| 8683 size_t initial_size; | 982 size_t initial_size; |
| 8684 size_t size; | 983 size_t size; |
| 8685 }; | 984 }; |
| 8686 std::map<Pool, PoolInfo> pool_infos_; | 985 std::map<Pool, PoolInfo> pool_infos_; |
| 8687 }; | 986 }; |
| 8688 | 987 |
| 8689 } // anonymous namespace. | 988 } // anonymous namespace. |
| 8690 | 989 |
| 8691 TEST_F(GLES2DecoderManualInitTest, MemoryTrackerInitialSize) { | 990 TEST_F(GLES2DecoderManualInitTest, MemoryTrackerInitialSize) { |
| 8692 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = | 991 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = |
| (...skipping 11 matching lines...) Expand all Loading... |
| 8704 TEST_F(GLES2DecoderManualInitTest, MemoryTrackerTexImage2D) { | 1003 TEST_F(GLES2DecoderManualInitTest, MemoryTrackerTexImage2D) { |
| 8705 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = | 1004 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = |
| 8706 new SizeOnlyMemoryTracker(); | 1005 new SizeOnlyMemoryTracker(); |
| 8707 set_memory_tracker(memory_tracker.get()); | 1006 set_memory_tracker(memory_tracker.get()); |
| 8708 InitState init; | 1007 InitState init; |
| 8709 init.gl_version = "3.0"; | 1008 init.gl_version = "3.0"; |
| 8710 init.bind_generates_resource = true; | 1009 init.bind_generates_resource = true; |
| 8711 InitDecoder(init); | 1010 InitDecoder(init); |
| 8712 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 1011 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 8713 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) | 1012 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) |
| 8714 .WillOnce(Return(true)).RetiresOnSaturation(); | 1013 .WillOnce(Return(true)) |
| 8715 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 8, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 1014 .RetiresOnSaturation(); |
| 8716 kSharedMemoryId, kSharedMemoryOffset); | 1015 DoTexImage2D(GL_TEXTURE_2D, |
| 1016 0, |
| 1017 GL_RGBA, |
| 1018 8, |
| 1019 4, |
| 1020 0, |
| 1021 GL_RGBA, |
| 1022 GL_UNSIGNED_BYTE, |
| 1023 kSharedMemoryId, |
| 1024 kSharedMemoryOffset); |
| 8717 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); | 1025 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); |
| 8718 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(64)) | 1026 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(64)) |
| 8719 .WillOnce(Return(true)).RetiresOnSaturation(); | 1027 .WillOnce(Return(true)) |
| 8720 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 1028 .RetiresOnSaturation(); |
| 8721 kSharedMemoryId, kSharedMemoryOffset); | 1029 DoTexImage2D(GL_TEXTURE_2D, |
| 1030 0, |
| 1031 GL_RGBA, |
| 1032 4, |
| 1033 4, |
| 1034 0, |
| 1035 GL_RGBA, |
| 1036 GL_UNSIGNED_BYTE, |
| 1037 kSharedMemoryId, |
| 1038 kSharedMemoryOffset); |
| 8722 EXPECT_EQ(64u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); | 1039 EXPECT_EQ(64u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); |
| 8723 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 1040 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 8724 // Check we get out of memory and no call to glTexImage2D if Ensure fails. | 1041 // Check we get out of memory and no call to glTexImage2D if Ensure fails. |
| 8725 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(64)) | 1042 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(64)) |
| 8726 .WillOnce(Return(false)).RetiresOnSaturation(); | 1043 .WillOnce(Return(false)) |
| 1044 .RetiresOnSaturation(); |
| 8727 TexImage2D cmd; | 1045 TexImage2D cmd; |
| 8728 cmd.Init(GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 1046 cmd.Init(GL_TEXTURE_2D, |
| 8729 kSharedMemoryId, kSharedMemoryOffset); | 1047 0, |
| 1048 GL_RGBA, |
| 1049 4, |
| 1050 4, |
| 1051 0, |
| 1052 GL_RGBA, |
| 1053 GL_UNSIGNED_BYTE, |
| 1054 kSharedMemoryId, |
| 1055 kSharedMemoryOffset); |
| 8730 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 1056 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 8731 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); | 1057 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); |
| 8732 EXPECT_EQ(64u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); | 1058 EXPECT_EQ(64u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); |
| 8733 } | 1059 } |
| 8734 | 1060 |
| 8735 TEST_F(GLES2DecoderManualInitTest, MemoryTrackerTexStorage2DEXT) { | 1061 TEST_F(GLES2DecoderManualInitTest, MemoryTrackerTexStorage2DEXT) { |
| 8736 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = | 1062 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = |
| 8737 new SizeOnlyMemoryTracker(); | 1063 new SizeOnlyMemoryTracker(); |
| 8738 set_memory_tracker(memory_tracker.get()); | 1064 set_memory_tracker(memory_tracker.get()); |
| 8739 InitState init; | 1065 InitState init; |
| 8740 init.gl_version = "3.0"; | 1066 init.gl_version = "3.0"; |
| 8741 init.bind_generates_resource = true; | 1067 init.bind_generates_resource = true; |
| 8742 InitDecoder(init); | 1068 InitDecoder(init); |
| 8743 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 1069 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 8744 // Check we get out of memory and no call to glTexStorage2DEXT | 1070 // Check we get out of memory and no call to glTexStorage2DEXT |
| 8745 // if Ensure fails. | 1071 // if Ensure fails. |
| 8746 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) | 1072 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) |
| 8747 .WillOnce(Return(false)).RetiresOnSaturation(); | 1073 .WillOnce(Return(false)) |
| 1074 .RetiresOnSaturation(); |
| 8748 TexStorage2DEXT cmd; | 1075 TexStorage2DEXT cmd; |
| 8749 cmd.Init(GL_TEXTURE_2D, 1, GL_RGBA8, 8, 4); | 1076 cmd.Init(GL_TEXTURE_2D, 1, GL_RGBA8, 8, 4); |
| 8750 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 1077 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 8751 EXPECT_EQ(0u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); | 1078 EXPECT_EQ(0u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); |
| 8752 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); | 1079 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); |
| 8753 } | 1080 } |
| 8754 | 1081 |
| 8755 TEST_F(GLES2DecoderManualInitTest, MemoryTrackerCopyTexImage2D) { | 1082 TEST_F(GLES2DecoderManualInitTest, MemoryTrackerCopyTexImage2D) { |
| 8756 GLenum target = GL_TEXTURE_2D; | 1083 GLenum target = GL_TEXTURE_2D; |
| 8757 GLint level = 0; | 1084 GLint level = 0; |
| 8758 GLenum internal_format = GL_RGBA; | 1085 GLenum internal_format = GL_RGBA; |
| 8759 GLsizei width = 4; | 1086 GLsizei width = 4; |
| 8760 GLsizei height = 8; | 1087 GLsizei height = 8; |
| 8761 GLint border = 0; | 1088 GLint border = 0; |
| 8762 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = | 1089 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = |
| 8763 new SizeOnlyMemoryTracker(); | 1090 new SizeOnlyMemoryTracker(); |
| 8764 set_memory_tracker(memory_tracker.get()); | 1091 set_memory_tracker(memory_tracker.get()); |
| 8765 InitState init; | 1092 InitState init; |
| 8766 init.gl_version = "3.0"; | 1093 init.gl_version = "3.0"; |
| 8767 init.has_alpha = true; | 1094 init.has_alpha = true; |
| 8768 init.request_alpha = true; | 1095 init.request_alpha = true; |
| 8769 init.bind_generates_resource = true; | 1096 init.bind_generates_resource = true; |
| 8770 InitDecoder(init); | 1097 InitDecoder(init); |
| 8771 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 1098 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 8772 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) | 1099 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) |
| 8773 .WillOnce(Return(true)).RetiresOnSaturation(); | 1100 .WillOnce(Return(true)) |
| 1101 .RetiresOnSaturation(); |
| 8774 EXPECT_CALL(*gl_, GetError()) | 1102 EXPECT_CALL(*gl_, GetError()) |
| 8775 .WillOnce(Return(GL_NO_ERROR)) | 1103 .WillOnce(Return(GL_NO_ERROR)) |
| 8776 .WillOnce(Return(GL_NO_ERROR)) | 1104 .WillOnce(Return(GL_NO_ERROR)) |
| 8777 .RetiresOnSaturation(); | 1105 .RetiresOnSaturation(); |
| 8778 EXPECT_CALL(*gl_, CopyTexImage2D( | 1106 EXPECT_CALL(*gl_, |
| 8779 target, level, internal_format, 0, 0, width, height, border)) | 1107 CopyTexImage2D( |
| 1108 target, level, internal_format, 0, 0, width, height, border)) |
| 8780 .Times(1) | 1109 .Times(1) |
| 8781 .RetiresOnSaturation(); | 1110 .RetiresOnSaturation(); |
| 8782 CopyTexImage2D cmd; | 1111 CopyTexImage2D cmd; |
| 8783 cmd.Init(target, level, internal_format, 0, 0, width, height, border); | 1112 cmd.Init(target, level, internal_format, 0, 0, width, height, border); |
| 8784 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 1113 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 8785 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); | 1114 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); |
| 8786 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 1115 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 8787 // Check we get out of memory and no call to glCopyTexImage2D if Ensure fails. | 1116 // Check we get out of memory and no call to glCopyTexImage2D if Ensure fails. |
| 8788 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) | 1117 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) |
| 8789 .WillOnce(Return(false)).RetiresOnSaturation(); | 1118 .WillOnce(Return(false)) |
| 1119 .RetiresOnSaturation(); |
| 8790 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 1120 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 8791 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); | 1121 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); |
| 8792 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); | 1122 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); |
| 8793 } | 1123 } |
| 8794 | 1124 |
| 8795 TEST_F(GLES2DecoderManualInitTest, MemoryTrackerRenderbufferStorage) { | 1125 TEST_F(GLES2DecoderManualInitTest, MemoryTrackerRenderbufferStorage) { |
| 8796 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = | 1126 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = |
| 8797 new SizeOnlyMemoryTracker(); | 1127 new SizeOnlyMemoryTracker(); |
| 8798 set_memory_tracker(memory_tracker.get()); | 1128 set_memory_tracker(memory_tracker.get()); |
| 8799 InitState init; | 1129 InitState init; |
| 8800 init.gl_version = "3.0"; | 1130 init.gl_version = "3.0"; |
| 8801 init.bind_generates_resource = true; | 1131 init.bind_generates_resource = true; |
| 8802 InitDecoder(init); | 1132 InitDecoder(init); |
| 8803 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_, | 1133 DoBindRenderbuffer( |
| 8804 kServiceRenderbufferId); | 1134 GL_RENDERBUFFER, client_renderbuffer_id_, kServiceRenderbufferId); |
| 8805 EXPECT_CALL(*gl_, GetError()) | 1135 EXPECT_CALL(*gl_, GetError()) |
| 8806 .WillOnce(Return(GL_NO_ERROR)) | 1136 .WillOnce(Return(GL_NO_ERROR)) |
| 8807 .WillOnce(Return(GL_NO_ERROR)) | 1137 .WillOnce(Return(GL_NO_ERROR)) |
| 8808 .RetiresOnSaturation(); | 1138 .RetiresOnSaturation(); |
| 8809 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) | 1139 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) |
| 8810 .WillOnce(Return(true)).RetiresOnSaturation(); | 1140 .WillOnce(Return(true)) |
| 8811 EXPECT_CALL(*gl_, RenderbufferStorageEXT( | 1141 .RetiresOnSaturation(); |
| 8812 GL_RENDERBUFFER, GL_RGBA, 8, 4)) | 1142 EXPECT_CALL(*gl_, RenderbufferStorageEXT(GL_RENDERBUFFER, GL_RGBA, 8, 4)) |
| 8813 .Times(1) | 1143 .Times(1) |
| 8814 .RetiresOnSaturation(); | 1144 .RetiresOnSaturation(); |
| 8815 RenderbufferStorage cmd; | 1145 RenderbufferStorage cmd; |
| 8816 cmd.Init(GL_RENDERBUFFER, GL_RGBA4, 8, 4); | 1146 cmd.Init(GL_RENDERBUFFER, GL_RGBA4, 8, 4); |
| 8817 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 1147 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 8818 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 1148 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 8819 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); | 1149 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); |
| 8820 // Check we get out of memory and no call to glRenderbufferStorage if Ensure | 1150 // Check we get out of memory and no call to glRenderbufferStorage if Ensure |
| 8821 // fails. | 1151 // fails. |
| 8822 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) | 1152 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) |
| 8823 .WillOnce(Return(false)).RetiresOnSaturation(); | 1153 .WillOnce(Return(false)) |
| 1154 .RetiresOnSaturation(); |
| 8824 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 1155 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 8825 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); | 1156 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); |
| 8826 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); | 1157 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); |
| 8827 } | 1158 } |
| 8828 | 1159 |
| 8829 TEST_F(GLES2DecoderManualInitTest, MemoryTrackerBufferData) { | 1160 TEST_F(GLES2DecoderManualInitTest, MemoryTrackerBufferData) { |
| 8830 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = | 1161 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = |
| 8831 new SizeOnlyMemoryTracker(); | 1162 new SizeOnlyMemoryTracker(); |
| 8832 set_memory_tracker(memory_tracker.get()); | 1163 set_memory_tracker(memory_tracker.get()); |
| 8833 InitState init; | 1164 InitState init; |
| 8834 init.gl_version = "3.0"; | 1165 init.gl_version = "3.0"; |
| 8835 init.bind_generates_resource = true; | 1166 init.bind_generates_resource = true; |
| 8836 InitDecoder(init); | 1167 InitDecoder(init); |
| 8837 DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, | 1168 DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId); |
| 8838 kServiceBufferId); | |
| 8839 EXPECT_CALL(*gl_, GetError()) | 1169 EXPECT_CALL(*gl_, GetError()) |
| 8840 .WillOnce(Return(GL_NO_ERROR)) | 1170 .WillOnce(Return(GL_NO_ERROR)) |
| 8841 .WillOnce(Return(GL_NO_ERROR)) | 1171 .WillOnce(Return(GL_NO_ERROR)) |
| 8842 .RetiresOnSaturation(); | 1172 .RetiresOnSaturation(); |
| 8843 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) | 1173 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) |
| 8844 .WillOnce(Return(true)).RetiresOnSaturation(); | 1174 .WillOnce(Return(true)) |
| 1175 .RetiresOnSaturation(); |
| 8845 EXPECT_CALL(*gl_, BufferData(GL_ARRAY_BUFFER, 128, _, GL_STREAM_DRAW)) | 1176 EXPECT_CALL(*gl_, BufferData(GL_ARRAY_BUFFER, 128, _, GL_STREAM_DRAW)) |
| 8846 .Times(1) | 1177 .Times(1) |
| 8847 .RetiresOnSaturation(); | 1178 .RetiresOnSaturation(); |
| 8848 BufferData cmd; | 1179 BufferData cmd; |
| 8849 cmd.Init(GL_ARRAY_BUFFER, 128, 0, 0, GL_STREAM_DRAW); | 1180 cmd.Init(GL_ARRAY_BUFFER, 128, 0, 0, GL_STREAM_DRAW); |
| 8850 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 1181 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 8851 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 1182 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 8852 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kManaged)); | 1183 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kManaged)); |
| 8853 // Check we get out of memory and no call to glBufferData if Ensure | 1184 // Check we get out of memory and no call to glBufferData if Ensure |
| 8854 // fails. | 1185 // fails. |
| 8855 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) | 1186 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) |
| 8856 .WillOnce(Return(false)).RetiresOnSaturation(); | 1187 .WillOnce(Return(false)) |
| 1188 .RetiresOnSaturation(); |
| 8857 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 1189 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 8858 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); | 1190 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); |
| 8859 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kManaged)); | 1191 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kManaged)); |
| 8860 } | 1192 } |
| 8861 | 1193 |
| 8862 TEST_F(GLES2DecoderTest, DrawBuffersEXTImmediateSuccceeds) { | |
| 8863 const GLsizei count = 1; | |
| 8864 const GLenum bufs[] = { GL_COLOR_ATTACHMENT0 }; | |
| 8865 DrawBuffersEXTImmediate& cmd = | |
| 8866 *GetImmediateAs<DrawBuffersEXTImmediate>(); | |
| 8867 cmd.Init(count, bufs); | |
| 8868 | |
| 8869 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, | |
| 8870 kServiceFramebufferId); | |
| 8871 EXPECT_CALL(*gl_, DrawBuffersARB(count, _)) | |
| 8872 .Times(1) | |
| 8873 .RetiresOnSaturation(); | |
| 8874 EXPECT_EQ(error::kNoError, | |
| 8875 ExecuteImmediateCmd(cmd, sizeof(bufs))); | |
| 8876 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 8877 } | |
| 8878 | |
| 8879 TEST_F(GLES2DecoderTest, DrawBuffersEXTImmediateFails) { | |
| 8880 const GLsizei count = 1; | |
| 8881 const GLenum bufs[] = { GL_COLOR_ATTACHMENT1_EXT }; | |
| 8882 DrawBuffersEXTImmediate& cmd = | |
| 8883 *GetImmediateAs<DrawBuffersEXTImmediate>(); | |
| 8884 cmd.Init(count, bufs); | |
| 8885 | |
| 8886 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, | |
| 8887 kServiceFramebufferId); | |
| 8888 EXPECT_EQ(error::kNoError, | |
| 8889 ExecuteImmediateCmd(cmd, sizeof(bufs))); | |
| 8890 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 8891 } | |
| 8892 | |
| 8893 TEST_F(GLES2DecoderTest, DrawBuffersEXTImmediateBackbuffer) { | |
| 8894 const GLsizei count = 1; | |
| 8895 const GLenum bufs[] = { GL_BACK }; | |
| 8896 DrawBuffersEXTImmediate& cmd = | |
| 8897 *GetImmediateAs<DrawBuffersEXTImmediate>(); | |
| 8898 cmd.Init(count, bufs); | |
| 8899 | |
| 8900 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, | |
| 8901 kServiceFramebufferId); | |
| 8902 EXPECT_EQ(error::kNoError, | |
| 8903 ExecuteImmediateCmd(cmd, sizeof(bufs))); | |
| 8904 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 8905 | |
| 8906 DoBindFramebuffer(GL_FRAMEBUFFER, 0, 0); // unbind | |
| 8907 | |
| 8908 EXPECT_CALL(*gl_, DrawBuffersARB(count, _)) | |
| 8909 .Times(1) | |
| 8910 .RetiresOnSaturation(); | |
| 8911 | |
| 8912 EXPECT_EQ(error::kNoError, | |
| 8913 ExecuteImmediateCmd(cmd, sizeof(bufs))); | |
| 8914 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 8915 } | |
| 8916 | |
| 8917 TEST_F(GLES2DecoderManualInitTest, InvalidateFramebufferBinding) { | |
| 8918 InitState init; | |
| 8919 init.gl_version = "opengl es 3.0"; | |
| 8920 InitDecoder(init); | |
| 8921 | |
| 8922 // EXPECT_EQ can't be used to compare function pointers | |
| 8923 EXPECT_TRUE( | |
| 8924 gfx::MockGLInterface::GetGLProcAddress("glInvalidateFramebuffer") == | |
| 8925 gfx::g_driver_gl.fn.glDiscardFramebufferEXTFn); | |
| 8926 EXPECT_TRUE( | |
| 8927 gfx::MockGLInterface::GetGLProcAddress("glInvalidateFramebuffer") != | |
| 8928 gfx::MockGLInterface::GetGLProcAddress("glDiscardFramebufferEXT")); | |
| 8929 } | |
| 8930 | |
| 8931 TEST_F(GLES2DecoderManualInitTest, DiscardFramebufferEXT) { | |
| 8932 InitState init; | |
| 8933 init.extensions = "GL_EXT_discard_framebuffer"; | |
| 8934 init.gl_version = "opengl es 2.0"; | |
| 8935 InitDecoder(init); | |
| 8936 | |
| 8937 // EXPECT_EQ can't be used to compare function pointers | |
| 8938 EXPECT_TRUE( | |
| 8939 gfx::MockGLInterface::GetGLProcAddress("glDiscardFramebufferEXT") == | |
| 8940 gfx::g_driver_gl.fn.glDiscardFramebufferEXTFn); | |
| 8941 | |
| 8942 const GLenum target = GL_FRAMEBUFFER; | |
| 8943 const GLsizei count = 1; | |
| 8944 const GLenum attachments[] = { GL_COLOR_ATTACHMENT0 }; | |
| 8945 | |
| 8946 SetupTexture(); | |
| 8947 DoBindFramebuffer( | |
| 8948 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); | |
| 8949 DoFramebufferTexture2D(GL_FRAMEBUFFER, | |
| 8950 GL_COLOR_ATTACHMENT0, | |
| 8951 GL_TEXTURE_2D, | |
| 8952 client_texture_id_, | |
| 8953 kServiceTextureId, | |
| 8954 0, | |
| 8955 GL_NO_ERROR); | |
| 8956 FramebufferManager* framebuffer_manager = group().framebuffer_manager(); | |
| 8957 Framebuffer* framebuffer = | |
| 8958 framebuffer_manager->GetFramebuffer(client_framebuffer_id_); | |
| 8959 EXPECT_TRUE(framebuffer->IsCleared()); | |
| 8960 | |
| 8961 EXPECT_CALL(*gl_, DiscardFramebufferEXT(target, count, _)) | |
| 8962 .Times(1) | |
| 8963 .RetiresOnSaturation(); | |
| 8964 DiscardFramebufferEXTImmediate& cmd = | |
| 8965 *GetImmediateAs<DiscardFramebufferEXTImmediate>(); | |
| 8966 cmd.Init(target, count, attachments); | |
| 8967 | |
| 8968 EXPECT_EQ(error::kNoError, | |
| 8969 ExecuteImmediateCmd(cmd, sizeof(attachments))); | |
| 8970 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 8971 EXPECT_FALSE(framebuffer->IsCleared()); | |
| 8972 } | |
| 8973 | |
| 8974 TEST_F(GLES2DecoderTest, DiscardFramebufferEXTUnsupported) { | |
| 8975 const GLenum target = GL_FRAMEBUFFER; | |
| 8976 const GLsizei count = 1; | |
| 8977 const GLenum attachments[] = { GL_COLOR_EXT }; | |
| 8978 DiscardFramebufferEXTImmediate& cmd = | |
| 8979 *GetImmediateAs<DiscardFramebufferEXTImmediate>(); | |
| 8980 cmd.Init(target, count, attachments); | |
| 8981 | |
| 8982 // Should not result into a call into GL. | |
| 8983 EXPECT_EQ(error::kNoError, | |
| 8984 ExecuteImmediateCmd(cmd, sizeof(attachments))); | |
| 8985 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
| 8986 } | |
| 8987 | |
| 8988 TEST_F(GLES2DecoderRestoreStateTest, NullPreviousStateBGR) { | |
| 8989 InitState init; | |
| 8990 init.gl_version = "3.0"; | |
| 8991 init.bind_generates_resource = true; | |
| 8992 InitDecoder(init); | |
| 8993 SetupTexture(); | |
| 8994 | |
| 8995 InSequence sequence; | |
| 8996 // Expect to restore texture bindings for unit GL_TEXTURE0. | |
| 8997 AddExpectationsForActiveTexture(GL_TEXTURE0); | |
| 8998 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); | |
| 8999 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, | |
| 9000 TestHelper::kServiceDefaultTextureCubemapId); | |
| 9001 | |
| 9002 // Expect to restore texture bindings for remaining units. | |
| 9003 for (uint32 i = 1; i < group().max_texture_units() ; ++i) { | |
| 9004 AddExpectationsForActiveTexture(GL_TEXTURE0 + i); | |
| 9005 AddExpectationsForBindTexture(GL_TEXTURE_2D, | |
| 9006 TestHelper::kServiceDefaultTexture2dId); | |
| 9007 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, | |
| 9008 TestHelper::kServiceDefaultTextureCubemapId); | |
| 9009 } | |
| 9010 | |
| 9011 // Expect to restore the active texture unit to GL_TEXTURE0. | |
| 9012 AddExpectationsForActiveTexture(GL_TEXTURE0); | |
| 9013 | |
| 9014 GetDecoder()->RestoreAllTextureUnitBindings(NULL); | |
| 9015 } | |
| 9016 | |
| 9017 TEST_F(GLES2DecoderRestoreStateTest, NullPreviousState) { | |
| 9018 InitState init; | |
| 9019 init.gl_version = "3.0"; | |
| 9020 InitDecoder(init); | |
| 9021 SetupTexture(); | |
| 9022 | |
| 9023 InSequence sequence; | |
| 9024 // Expect to restore texture bindings for unit GL_TEXTURE0. | |
| 9025 AddExpectationsForActiveTexture(GL_TEXTURE0); | |
| 9026 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); | |
| 9027 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, 0); | |
| 9028 | |
| 9029 // Expect to restore texture bindings for remaining units. | |
| 9030 for (uint32 i = 1; i < group().max_texture_units(); ++i) { | |
| 9031 AddExpectationsForActiveTexture(GL_TEXTURE0 + i); | |
| 9032 AddExpectationsForBindTexture(GL_TEXTURE_2D, 0); | |
| 9033 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, 0); | |
| 9034 } | |
| 9035 | |
| 9036 // Expect to restore the active texture unit to GL_TEXTURE0. | |
| 9037 AddExpectationsForActiveTexture(GL_TEXTURE0); | |
| 9038 | |
| 9039 GetDecoder()->RestoreAllTextureUnitBindings(NULL); | |
| 9040 } | |
| 9041 | |
| 9042 TEST_F(GLES2DecoderRestoreStateTest, WithPreviousStateBGR) { | |
| 9043 InitState init; | |
| 9044 init.gl_version = "3.0"; | |
| 9045 init.bind_generates_resource = true; | |
| 9046 InitDecoder(init); | |
| 9047 SetupTexture(); | |
| 9048 | |
| 9049 // Construct a previous ContextState with all texture bindings | |
| 9050 // set to default textures. | |
| 9051 ContextState prev_state(NULL, NULL, NULL); | |
| 9052 InitializeContextState(&prev_state, std::numeric_limits<uint32>::max(), 0); | |
| 9053 | |
| 9054 InSequence sequence; | |
| 9055 // Expect to restore only GL_TEXTURE_2D binding for GL_TEXTURE0 unit, | |
| 9056 // since the rest of the bindings haven't changed between the current | |
| 9057 // state and the |prev_state|. | |
| 9058 AddExpectationsForActiveTexture(GL_TEXTURE0); | |
| 9059 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); | |
| 9060 | |
| 9061 // Expect to restore active texture unit to GL_TEXTURE0. | |
| 9062 AddExpectationsForActiveTexture(GL_TEXTURE0); | |
| 9063 | |
| 9064 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); | |
| 9065 } | |
| 9066 | |
| 9067 TEST_F(GLES2DecoderRestoreStateTest, WithPreviousState) { | |
| 9068 InitState init; | |
| 9069 init.gl_version = "3.0"; | |
| 9070 InitDecoder(init); | |
| 9071 SetupTexture(); | |
| 9072 | |
| 9073 // Construct a previous ContextState with all texture bindings | |
| 9074 // set to default textures. | |
| 9075 ContextState prev_state(NULL, NULL, NULL); | |
| 9076 InitializeContextState(&prev_state, std::numeric_limits<uint32>::max(), 0); | |
| 9077 | |
| 9078 InSequence sequence; | |
| 9079 // Expect to restore only GL_TEXTURE_2D binding for GL_TEXTURE0 unit, | |
| 9080 // since the rest of the bindings haven't changed between the current | |
| 9081 // state and the |prev_state|. | |
| 9082 AddExpectationsForActiveTexture(GL_TEXTURE0); | |
| 9083 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); | |
| 9084 | |
| 9085 // Expect to restore active texture unit to GL_TEXTURE0. | |
| 9086 AddExpectationsForActiveTexture(GL_TEXTURE0); | |
| 9087 | |
| 9088 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); | |
| 9089 } | |
| 9090 | |
| 9091 TEST_F(GLES2DecoderRestoreStateTest, ActiveUnit1) { | |
| 9092 InitState init; | |
| 9093 init.gl_version = "3.0"; | |
| 9094 InitDecoder(init); | |
| 9095 | |
| 9096 // Bind a non-default texture to GL_TEXTURE1 unit. | |
| 9097 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1)); | |
| 9098 ActiveTexture cmd; | |
| 9099 cmd.Init(GL_TEXTURE1); | |
| 9100 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 9101 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 9102 SetupTexture(); | |
| 9103 | |
| 9104 // Construct a previous ContextState with all texture bindings | |
| 9105 // set to default textures. | |
| 9106 ContextState prev_state(NULL, NULL, NULL); | |
| 9107 InitializeContextState(&prev_state, std::numeric_limits<uint32>::max(), 0); | |
| 9108 | |
| 9109 InSequence sequence; | |
| 9110 // Expect to restore only GL_TEXTURE_2D binding for GL_TEXTURE1 unit, | |
| 9111 // since the rest of the bindings haven't changed between the current | |
| 9112 // state and the |prev_state|. | |
| 9113 AddExpectationsForActiveTexture(GL_TEXTURE1); | |
| 9114 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); | |
| 9115 | |
| 9116 // Expect to restore active texture unit to GL_TEXTURE1. | |
| 9117 AddExpectationsForActiveTexture(GL_TEXTURE1); | |
| 9118 | |
| 9119 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); | |
| 9120 } | |
| 9121 | |
| 9122 TEST_F(GLES2DecoderRestoreStateTest, NonDefaultUnit0BGR) { | |
| 9123 InitState init; | |
| 9124 init.gl_version = "3.0"; | |
| 9125 init.bind_generates_resource = true; | |
| 9126 InitDecoder(init); | |
| 9127 | |
| 9128 // Bind a non-default texture to GL_TEXTURE1 unit. | |
| 9129 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1)); | |
| 9130 SpecializedSetup<ActiveTexture, 0>(true); | |
| 9131 ActiveTexture cmd; | |
| 9132 cmd.Init(GL_TEXTURE1); | |
| 9133 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 9134 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 9135 SetupTexture(); | |
| 9136 | |
| 9137 // Construct a previous ContextState with GL_TEXTURE_2D target in | |
| 9138 // GL_TEXTURE0 unit bound to a non-default texture and the rest | |
| 9139 // set to default textures. | |
| 9140 ContextState prev_state(NULL, NULL, NULL); | |
| 9141 InitializeContextState(&prev_state, 0, kServiceTextureId); | |
| 9142 | |
| 9143 InSequence sequence; | |
| 9144 // Expect to restore GL_TEXTURE_2D binding for GL_TEXTURE0 unit to | |
| 9145 // a default texture. | |
| 9146 AddExpectationsForActiveTexture(GL_TEXTURE0); | |
| 9147 AddExpectationsForBindTexture(GL_TEXTURE_2D, | |
| 9148 TestHelper::kServiceDefaultTexture2dId); | |
| 9149 | |
| 9150 // Expect to restore GL_TEXTURE_2D binding for GL_TEXTURE1 unit to | |
| 9151 // non-default. | |
| 9152 AddExpectationsForActiveTexture(GL_TEXTURE1); | |
| 9153 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); | |
| 9154 | |
| 9155 // Expect to restore active texture unit to GL_TEXTURE1. | |
| 9156 AddExpectationsForActiveTexture(GL_TEXTURE1); | |
| 9157 | |
| 9158 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); | |
| 9159 } | |
| 9160 | |
| 9161 TEST_F(GLES2DecoderRestoreStateTest, NonDefaultUnit1BGR) { | |
| 9162 InitState init; | |
| 9163 init.gl_version = "3.0"; | |
| 9164 init.bind_generates_resource = true; | |
| 9165 InitDecoder(init); | |
| 9166 | |
| 9167 // Bind a non-default texture to GL_TEXTURE0 unit. | |
| 9168 SetupTexture(); | |
| 9169 | |
| 9170 // Construct a previous ContextState with GL_TEXTURE_2D target in | |
| 9171 // GL_TEXTURE1 unit bound to a non-default texture and the rest | |
| 9172 // set to default textures. | |
| 9173 ContextState prev_state(NULL, NULL, NULL); | |
| 9174 InitializeContextState(&prev_state, 1, kServiceTextureId); | |
| 9175 | |
| 9176 InSequence sequence; | |
| 9177 // Expect to restore GL_TEXTURE_2D binding to the non-default texture | |
| 9178 // for GL_TEXTURE0 unit. | |
| 9179 AddExpectationsForActiveTexture(GL_TEXTURE0); | |
| 9180 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); | |
| 9181 | |
| 9182 // Expect to restore GL_TEXTURE_2D binding to the default texture | |
| 9183 // for GL_TEXTURE1 unit. | |
| 9184 AddExpectationsForActiveTexture(GL_TEXTURE1); | |
| 9185 AddExpectationsForBindTexture(GL_TEXTURE_2D, | |
| 9186 TestHelper::kServiceDefaultTexture2dId); | |
| 9187 | |
| 9188 // Expect to restore active texture unit to GL_TEXTURE0. | |
| 9189 AddExpectationsForActiveTexture(GL_TEXTURE0); | |
| 9190 | |
| 9191 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); | |
| 9192 } | |
| 9193 | |
| 9194 TEST_F(GLES2DecoderRestoreStateTest, DefaultUnit0) { | |
| 9195 InitState init; | |
| 9196 init.gl_version = "3.0"; | |
| 9197 InitDecoder(init); | |
| 9198 | |
| 9199 // Bind a non-default texture to GL_TEXTURE1 unit. | |
| 9200 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1)); | |
| 9201 SpecializedSetup<ActiveTexture, 0>(true); | |
| 9202 ActiveTexture cmd; | |
| 9203 cmd.Init(GL_TEXTURE1); | |
| 9204 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 9205 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 9206 SetupTexture(); | |
| 9207 | |
| 9208 // Construct a previous ContextState with GL_TEXTURE_2D target in | |
| 9209 // GL_TEXTURE0 unit bound to a non-default texture and the rest | |
| 9210 // set to default textures. | |
| 9211 ContextState prev_state(NULL, NULL, NULL); | |
| 9212 InitializeContextState(&prev_state, 0, kServiceTextureId); | |
| 9213 | |
| 9214 InSequence sequence; | |
| 9215 // Expect to restore GL_TEXTURE_2D binding for GL_TEXTURE0 unit to | |
| 9216 // the 0 texture. | |
| 9217 AddExpectationsForActiveTexture(GL_TEXTURE0); | |
| 9218 AddExpectationsForBindTexture(GL_TEXTURE_2D, 0); | |
| 9219 | |
| 9220 // Expect to restore GL_TEXTURE_2D binding for GL_TEXTURE1 unit to | |
| 9221 // non-default. | |
| 9222 AddExpectationsForActiveTexture(GL_TEXTURE1); | |
| 9223 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); | |
| 9224 | |
| 9225 // Expect to restore active texture unit to GL_TEXTURE1. | |
| 9226 AddExpectationsForActiveTexture(GL_TEXTURE1); | |
| 9227 | |
| 9228 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); | |
| 9229 } | |
| 9230 | |
| 9231 TEST_F(GLES2DecoderRestoreStateTest, DefaultUnit1) { | |
| 9232 InitState init; | |
| 9233 init.gl_version = "3.0"; | |
| 9234 InitDecoder(init); | |
| 9235 | |
| 9236 // Bind a non-default texture to GL_TEXTURE0 unit. | |
| 9237 SetupTexture(); | |
| 9238 | |
| 9239 // Construct a previous ContextState with GL_TEXTURE_2D target in | |
| 9240 // GL_TEXTURE1 unit bound to a non-default texture and the rest | |
| 9241 // set to default textures. | |
| 9242 ContextState prev_state(NULL, NULL, NULL); | |
| 9243 InitializeContextState(&prev_state, 1, kServiceTextureId); | |
| 9244 | |
| 9245 InSequence sequence; | |
| 9246 // Expect to restore GL_TEXTURE_2D binding to the non-default texture | |
| 9247 // for GL_TEXTURE0 unit. | |
| 9248 AddExpectationsForActiveTexture(GL_TEXTURE0); | |
| 9249 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); | |
| 9250 | |
| 9251 // Expect to restore GL_TEXTURE_2D binding to the 0 texture | |
| 9252 // for GL_TEXTURE1 unit. | |
| 9253 AddExpectationsForActiveTexture(GL_TEXTURE1); | |
| 9254 AddExpectationsForBindTexture(GL_TEXTURE_2D, 0); | |
| 9255 | |
| 9256 // Expect to restore active texture unit to GL_TEXTURE0. | |
| 9257 AddExpectationsForActiveTexture(GL_TEXTURE0); | |
| 9258 | |
| 9259 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); | |
| 9260 } | |
| 9261 | |
| 9262 // TODO(vmiura): Tests for VAO restore. | |
| 9263 | |
| 9264 // TODO(vmiura): Tests for ContextState::RestoreAttribute(). | |
| 9265 | |
| 9266 // TODO(vmiura): Tests for ContextState::RestoreBufferBindings(). | |
| 9267 | |
| 9268 // TODO(vmiura): Tests for ContextState::RestoreProgramBindings(). | |
| 9269 | |
| 9270 // TODO(vmiura): Tests for RestoreRenderbufferBindings(). | |
| 9271 | |
| 9272 // TODO(vmiura): Tests for RestoreProgramBindings(). | |
| 9273 | |
| 9274 // TODO(vmiura): Tests for RestoreGlobalState(). | |
| 9275 | |
| 9276 TEST_F(GLES2DecoderManualInitTest, ClearUniformsBeforeFirstProgramUse) { | |
| 9277 CommandLine command_line(0, NULL); | |
| 9278 command_line.AppendSwitchASCII( | |
| 9279 switches::kGpuDriverBugWorkarounds, | |
| 9280 base::IntToString(gpu::CLEAR_UNIFORMS_BEFORE_FIRST_PROGRAM_USE)); | |
| 9281 InitState init; | |
| 9282 init.gl_version = "3.0"; | |
| 9283 init.has_alpha = true; | |
| 9284 init.request_alpha = true; | |
| 9285 init.bind_generates_resource = true; | |
| 9286 InitDecoderWithCommandLine(init, &command_line); | |
| 9287 { | |
| 9288 static AttribInfo attribs[] = { | |
| 9289 { kAttrib1Name, kAttrib1Size, kAttrib1Type, kAttrib1Location, }, | |
| 9290 { kAttrib2Name, kAttrib2Size, kAttrib2Type, kAttrib2Location, }, | |
| 9291 { kAttrib3Name, kAttrib3Size, kAttrib3Type, kAttrib3Location, }, | |
| 9292 }; | |
| 9293 static UniformInfo uniforms[] = { | |
| 9294 { kUniform1Name, kUniform1Size, kUniform1Type, | |
| 9295 kUniform1FakeLocation, kUniform1RealLocation, | |
| 9296 kUniform1DesiredLocation }, | |
| 9297 { kUniform2Name, kUniform2Size, kUniform2Type, | |
| 9298 kUniform2FakeLocation, kUniform2RealLocation, | |
| 9299 kUniform2DesiredLocation }, | |
| 9300 { kUniform3Name, kUniform3Size, kUniform3Type, | |
| 9301 kUniform3FakeLocation, kUniform3RealLocation, | |
| 9302 kUniform3DesiredLocation }, | |
| 9303 }; | |
| 9304 SetupShader(attribs, arraysize(attribs), uniforms, arraysize(uniforms), | |
| 9305 client_program_id_, kServiceProgramId, | |
| 9306 client_vertex_shader_id_, kServiceVertexShaderId, | |
| 9307 client_fragment_shader_id_, kServiceFragmentShaderId); | |
| 9308 TestHelper::SetupExpectationsForClearingUniforms( | |
| 9309 gl_.get(), uniforms, arraysize(uniforms)); | |
| 9310 } | |
| 9311 | |
| 9312 { | |
| 9313 EXPECT_CALL(*gl_, UseProgram(kServiceProgramId)) | |
| 9314 .Times(1) | |
| 9315 .RetiresOnSaturation(); | |
| 9316 cmds::UseProgram cmd; | |
| 9317 cmd.Init(client_program_id_); | |
| 9318 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 9319 } | |
| 9320 } | |
| 9321 | |
| 9322 TEST_F(GLES2DecoderManualInitTest, TexImage2DFloatOnGLES2) { | |
| 9323 InitState init; | |
| 9324 init.extensions = "GL_OES_texture_float"; | |
| 9325 init.gl_version = "opengl es 2.0"; | |
| 9326 InitDecoder(init); | |
| 9327 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 9328 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 17, 0, GL_RGBA, GL_FLOAT, 0, 0); | |
| 9329 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 16, 17, 0, GL_RGB, GL_FLOAT, 0, 0); | |
| 9330 DoTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 16, 17, 0, GL_LUMINANCE, | |
| 9331 GL_FLOAT, 0, 0); | |
| 9332 DoTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 16, 17, 0, GL_ALPHA, GL_FLOAT, | |
| 9333 0, 0); | |
| 9334 DoTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, 16, 17, 0, | |
| 9335 GL_LUMINANCE_ALPHA, GL_FLOAT, 0, 0); | |
| 9336 } | |
| 9337 | |
| 9338 TEST_F(GLES2DecoderManualInitTest, TexImage2DFloatOnGLES3) { | |
| 9339 InitState init; | |
| 9340 init.extensions = "GL_OES_texture_float GL_EXT_color_buffer_float"; | |
| 9341 init.gl_version = "opengl es 3.0"; | |
| 9342 InitDecoder(init); | |
| 9343 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 9344 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 17, 0, GL_RGBA, GL_FLOAT, 0, 0); | |
| 9345 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 16, 17, 0, GL_RGB, GL_FLOAT, 0, 0); | |
| 9346 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, 16, 17, 0, GL_RGBA, GL_FLOAT, 0, | |
| 9347 0); | |
| 9348 DoTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 16, 17, 0, GL_LUMINANCE, | |
| 9349 GL_FLOAT, 0, 0); | |
| 9350 DoTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 16, 17, 0, GL_ALPHA, GL_FLOAT, | |
| 9351 0, 0); | |
| 9352 DoTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, 16, 17, 0, | |
| 9353 GL_LUMINANCE_ALPHA, GL_FLOAT, 0, 0); | |
| 9354 } | |
| 9355 | |
| 9356 TEST_F(GLES2DecoderManualInitTest, TexSubImage2DFloatOnGLES3) { | |
| 9357 InitState init; | |
| 9358 init.extensions = "GL_OES_texture_float GL_EXT_color_buffer_float"; | |
| 9359 init.gl_version = "opengl es 3.0"; | |
| 9360 InitDecoder(init); | |
| 9361 const int kWidth = 8; | |
| 9362 const int kHeight = 4; | |
| 9363 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 9364 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, kWidth, kHeight, 0, GL_RGBA, | |
| 9365 GL_FLOAT, 0, 0); | |
| 9366 EXPECT_CALL(*gl_, TexImage2D( | |
| 9367 GL_TEXTURE_2D, 0, GL_RGBA32F, kWidth, kHeight, 0, GL_RGBA, GL_FLOAT, | |
| 9368 shared_memory_address_)) | |
| 9369 .Times(1) | |
| 9370 .RetiresOnSaturation(); | |
| 9371 TexSubImage2D cmd; | |
| 9372 cmd.Init( | |
| 9373 GL_TEXTURE_2D, 0, 0, 0, kWidth, kHeight, GL_RGBA, GL_FLOAT, | |
| 9374 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); | |
| 9375 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 9376 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 9377 } | |
| 9378 | |
| 9379 TEST_F(GLES2DecoderManualInitTest, TexSubImage2DFloatDoesClearOnGLES3) { | |
| 9380 InitState init; | |
| 9381 init.extensions = "GL_OES_texture_float GL_EXT_color_buffer_float"; | |
| 9382 init.gl_version = "opengl es 3.0"; | |
| 9383 InitDecoder(init); | |
| 9384 const int kWidth = 8; | |
| 9385 const int kHeight = 4; | |
| 9386 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 9387 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, kWidth, kHeight, 0, GL_RGBA, | |
| 9388 GL_FLOAT, 0, 0); | |
| 9389 SetupClearTextureExpectations( | |
| 9390 kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D, | |
| 9391 0, GL_RGBA32F, GL_RGBA, GL_FLOAT, kWidth, kHeight); | |
| 9392 EXPECT_CALL(*gl_, TexSubImage2D( | |
| 9393 GL_TEXTURE_2D, 0, 1, 0, kWidth - 1, kHeight, GL_RGBA, GL_FLOAT, | |
| 9394 shared_memory_address_)) | |
| 9395 .Times(1) | |
| 9396 .RetiresOnSaturation(); | |
| 9397 TexSubImage2D cmd; | |
| 9398 cmd.Init( | |
| 9399 GL_TEXTURE_2D, 0, 1, 0, kWidth - 1, kHeight, GL_RGBA, GL_FLOAT, | |
| 9400 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); | |
| 9401 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 9402 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 9403 } | |
| 9404 | |
| 9405 TEST_F(GLES2DecoderManualInitTest, TexImage2DFloatConvertsFormatDesktop) { | |
| 9406 InitState init; | |
| 9407 init.extensions = "GL_ARB_texture_float"; | |
| 9408 init.gl_version = "2.1"; | |
| 9409 InitDecoder(init); | |
| 9410 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 9411 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, 16, 17, 0, GL_RGBA, GL_FLOAT, 0, | |
| 9412 0); | |
| 9413 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, 16, 17, 0, GL_RGB, GL_FLOAT, 0, 0); | |
| 9414 DoTexImage2DConvertInternalFormat(GL_TEXTURE_2D, 0, GL_RGBA, 16, 17, 0, | |
| 9415 GL_RGBA, GL_FLOAT, 0, 0, GL_RGBA32F_ARB); | |
| 9416 DoTexImage2DConvertInternalFormat(GL_TEXTURE_2D, 0, GL_RGB, 16, 17, 0, | |
| 9417 GL_RGB, GL_FLOAT, 0, 0, GL_RGB32F_ARB); | |
| 9418 DoTexImage2DConvertInternalFormat(GL_TEXTURE_2D, 0, GL_LUMINANCE, 16, 17, 0, | |
| 9419 GL_LUMINANCE, GL_FLOAT, 0, 0, | |
| 9420 GL_LUMINANCE32F_ARB); | |
| 9421 DoTexImage2DConvertInternalFormat(GL_TEXTURE_2D, 0, GL_ALPHA, 16, 17, 0, | |
| 9422 GL_ALPHA, GL_FLOAT, 0, 0, GL_ALPHA32F_ARB); | |
| 9423 DoTexImage2DConvertInternalFormat(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, 16, | |
| 9424 17, 0, GL_LUMINANCE_ALPHA, GL_FLOAT, 0, 0, | |
| 9425 GL_LUMINANCE_ALPHA32F_ARB); | |
| 9426 } | |
| 9427 | |
| 9428 TEST_F(GLES2DecoderManualInitTest, ReadFormatExtension) { | |
| 9429 InitState init; | |
| 9430 init.extensions = "GL_OES_read_format"; | |
| 9431 init.gl_version = "2.1"; | |
| 9432 init.bind_generates_resource = true; | |
| 9433 InitDecoder(init); | |
| 9434 | |
| 9435 EXPECT_CALL(*gl_, GetError()) | |
| 9436 .WillOnce(Return(GL_NO_ERROR)) | |
| 9437 .WillOnce(Return(GL_NO_ERROR)) | |
| 9438 .WillOnce(Return(GL_NO_ERROR)) | |
| 9439 .WillOnce(Return(GL_NO_ERROR)) | |
| 9440 .RetiresOnSaturation(); | |
| 9441 EXPECT_CALL(*gl_, GetError()) | |
| 9442 .Times(6) | |
| 9443 .RetiresOnSaturation(); | |
| 9444 | |
| 9445 typedef GetIntegerv::Result Result; | |
| 9446 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 9447 GetIntegerv cmd; | |
| 9448 const GLuint kFBOClientTextureId = 4100; | |
| 9449 const GLuint kFBOServiceTextureId = 4101; | |
| 9450 | |
| 9451 // Register a texture id. | |
| 9452 EXPECT_CALL(*gl_, GenTextures(_, _)) | |
| 9453 .WillOnce(SetArgumentPointee<1>(kFBOServiceTextureId)) | |
| 9454 .RetiresOnSaturation(); | |
| 9455 GenHelper<GenTexturesImmediate>(kFBOClientTextureId); | |
| 9456 | |
| 9457 // Setup "render to" texture. | |
| 9458 DoBindTexture(GL_TEXTURE_2D, kFBOClientTextureId, kFBOServiceTextureId); | |
| 9459 DoTexImage2D( | |
| 9460 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); | |
| 9461 DoBindFramebuffer( | |
| 9462 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); | |
| 9463 DoFramebufferTexture2D( | |
| 9464 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, | |
| 9465 kFBOClientTextureId, kFBOServiceTextureId, 0, GL_NO_ERROR); | |
| 9466 | |
| 9467 result->size = 0; | |
| 9468 EXPECT_CALL(*gl_, GetIntegerv(_, _)) | |
| 9469 .Times(1) | |
| 9470 .RetiresOnSaturation(); | |
| 9471 cmd.Init( | |
| 9472 GL_IMPLEMENTATION_COLOR_READ_FORMAT, | |
| 9473 shared_memory_id_, shared_memory_offset_); | |
| 9474 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 9475 EXPECT_EQ(1, result->GetNumResults()); | |
| 9476 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 9477 | |
| 9478 result->size = 0; | |
| 9479 EXPECT_CALL(*gl_, GetIntegerv(_, _)) | |
| 9480 .Times(1) | |
| 9481 .RetiresOnSaturation(); | |
| 9482 cmd.Init( | |
| 9483 GL_IMPLEMENTATION_COLOR_READ_TYPE, | |
| 9484 shared_memory_id_, shared_memory_offset_); | |
| 9485 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 9486 EXPECT_EQ(1, result->GetNumResults()); | |
| 9487 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 9488 } | |
| 9489 | |
| 9490 TEST_F(GLES2DecoderManualInitTest, NoReadFormatExtension) { | |
| 9491 InitState init; | |
| 9492 init.gl_version = "2.1"; | |
| 9493 init.bind_generates_resource = true; | |
| 9494 InitDecoder(init); | |
| 9495 | |
| 9496 EXPECT_CALL(*gl_, GetError()) | |
| 9497 .WillOnce(Return(GL_NO_ERROR)) | |
| 9498 .WillOnce(Return(GL_NO_ERROR)) | |
| 9499 .WillOnce(Return(GL_NO_ERROR)) | |
| 9500 .WillOnce(Return(GL_NO_ERROR)) | |
| 9501 .RetiresOnSaturation(); | |
| 9502 | |
| 9503 typedef GetIntegerv::Result Result; | |
| 9504 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 9505 GetIntegerv cmd; | |
| 9506 const GLuint kFBOClientTextureId = 4100; | |
| 9507 const GLuint kFBOServiceTextureId = 4101; | |
| 9508 | |
| 9509 // Register a texture id. | |
| 9510 EXPECT_CALL(*gl_, GenTextures(_, _)) | |
| 9511 .WillOnce(SetArgumentPointee<1>(kFBOServiceTextureId)) | |
| 9512 .RetiresOnSaturation(); | |
| 9513 GenHelper<GenTexturesImmediate>(kFBOClientTextureId); | |
| 9514 | |
| 9515 // Setup "render to" texture. | |
| 9516 DoBindTexture(GL_TEXTURE_2D, kFBOClientTextureId, kFBOServiceTextureId); | |
| 9517 DoTexImage2D( | |
| 9518 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); | |
| 9519 DoBindFramebuffer( | |
| 9520 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); | |
| 9521 DoFramebufferTexture2D( | |
| 9522 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, | |
| 9523 kFBOClientTextureId, kFBOServiceTextureId, 0, GL_NO_ERROR); | |
| 9524 | |
| 9525 result->size = 0; | |
| 9526 EXPECT_CALL(*gl_, GetIntegerv(_, _)) | |
| 9527 .Times(0) | |
| 9528 .RetiresOnSaturation(); | |
| 9529 cmd.Init( | |
| 9530 GL_IMPLEMENTATION_COLOR_READ_FORMAT, | |
| 9531 shared_memory_id_, shared_memory_offset_); | |
| 9532 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 9533 EXPECT_EQ(1, result->GetNumResults()); | |
| 9534 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 9535 | |
| 9536 result->size = 0; | |
| 9537 EXPECT_CALL(*gl_, GetIntegerv(_, _)) | |
| 9538 .Times(0) | |
| 9539 .RetiresOnSaturation(); | |
| 9540 cmd.Init( | |
| 9541 GL_IMPLEMENTATION_COLOR_READ_TYPE, | |
| 9542 shared_memory_id_, shared_memory_offset_); | |
| 9543 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 9544 EXPECT_EQ(1, result->GetNumResults()); | |
| 9545 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 9546 } | |
| 9547 | |
| 9548 // TODO(gman): Complete this test. | |
| 9549 // TEST_F(GLES2DecoderTest, CompressedTexImage2DGLError) { | |
| 9550 // } | |
| 9551 | |
| 9552 // TODO(gman): BufferData | |
| 9553 | |
| 9554 // TODO(gman): BufferDataImmediate | |
| 9555 | |
| 9556 // TODO(gman): BufferSubData | |
| 9557 | |
| 9558 // TODO(gman): BufferSubDataImmediate | |
| 9559 | |
| 9560 // TODO(gman): CompressedTexImage2D | |
| 9561 | |
| 9562 // TODO(gman): CompressedTexImage2DImmediate | |
| 9563 | |
| 9564 // TODO(gman): CompressedTexSubImage2DImmediate | |
| 9565 | |
| 9566 // TODO(gman): DeleteProgram | |
| 9567 | |
| 9568 // TODO(gman): DeleteShader | |
| 9569 | |
| 9570 // TODO(gman): PixelStorei | |
| 9571 | |
| 9572 // TODO(gman): TexImage2D | |
| 9573 | |
| 9574 // TODO(gman): TexImage2DImmediate | |
| 9575 | |
| 9576 // TODO(gman): TexSubImage2DImmediate | |
| 9577 | |
| 9578 // TODO(gman): UseProgram | |
| 9579 | |
| 9580 // TODO(gman): SwapBuffers | |
| 9581 | |
| 9582 } // namespace gles2 | 1194 } // namespace gles2 |
| 9583 } // namespace gpu | 1195 } // namespace gpu |
| OLD | NEW |