OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 6 |
| 7 #include "base/command_line.h" |
| 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
| 10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 11 #include "gpu/command_buffer/common/id_allocator.h" |
| 12 #include "gpu/command_buffer/service/async_pixel_transfer_delegate_mock.h" |
| 13 #include "gpu/command_buffer/service/async_pixel_transfer_manager.h" |
| 14 #include "gpu/command_buffer/service/async_pixel_transfer_manager_mock.h" |
| 15 #include "gpu/command_buffer/service/cmd_buffer_engine.h" |
| 16 #include "gpu/command_buffer/service/context_group.h" |
| 17 #include "gpu/command_buffer/service/context_state.h" |
| 18 #include "gpu/command_buffer/service/gl_surface_mock.h" |
| 19 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.h" |
| 20 |
| 21 #include "gpu/command_buffer/service/gpu_switches.h" |
| 22 #include "gpu/command_buffer/service/image_manager.h" |
| 23 #include "gpu/command_buffer/service/mailbox_manager.h" |
| 24 #include "gpu/command_buffer/service/mocks.h" |
| 25 #include "gpu/command_buffer/service/program_manager.h" |
| 26 #include "gpu/command_buffer/service/test_helper.h" |
| 27 #include "testing/gtest/include/gtest/gtest.h" |
| 28 #include "ui/gl/gl_implementation.h" |
| 29 #include "ui/gl/gl_mock.h" |
| 30 #include "ui/gl/gl_surface_stub.h" |
| 31 |
| 32 #if !defined(GL_DEPTH24_STENCIL8) |
| 33 #define GL_DEPTH24_STENCIL8 0x88F0 |
| 34 #endif |
| 35 |
| 36 using ::gfx::MockGLInterface; |
| 37 using ::testing::_; |
| 38 using ::testing::DoAll; |
| 39 using ::testing::InSequence; |
| 40 using ::testing::Invoke; |
| 41 using ::testing::MatcherCast; |
| 42 using ::testing::Mock; |
| 43 using ::testing::Pointee; |
| 44 using ::testing::Return; |
| 45 using ::testing::SaveArg; |
| 46 using ::testing::SetArrayArgument; |
| 47 using ::testing::SetArgumentPointee; |
| 48 using ::testing::SetArgPointee; |
| 49 using ::testing::StrEq; |
| 50 using ::testing::StrictMock; |
| 51 |
| 52 namespace gpu { |
| 53 namespace gles2 { |
| 54 |
| 55 using namespace cmds; |
| 56 |
| 57 TEST_F(GLES2DecoderTest, GenerateMipmapWrongFormatsFails) { |
| 58 EXPECT_CALL(*gl_, GenerateMipmapEXT(_)).Times(0); |
| 59 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 60 DoTexImage2D( |
| 61 GL_TEXTURE_2D, 0, GL_RGBA, 16, 17, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
| 62 GenerateMipmap cmd; |
| 63 cmd.Init(GL_TEXTURE_2D); |
| 64 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 65 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 66 } |
| 67 |
| 68 TEST_F(GLES2DecoderTest, GenerateMipmapHandlesOutOfMemory) { |
| 69 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 70 TextureManager* manager = group().texture_manager(); |
| 71 TextureRef* texture_ref = manager->GetTexture(client_texture_id_); |
| 72 ASSERT_TRUE(texture_ref != NULL); |
| 73 Texture* texture = texture_ref->texture(); |
| 74 GLint width = 0; |
| 75 GLint height = 0; |
| 76 EXPECT_FALSE(texture->GetLevelSize(GL_TEXTURE_2D, 2, &width, &height)); |
| 77 DoTexImage2D(GL_TEXTURE_2D, |
| 78 0, |
| 79 GL_RGBA, |
| 80 16, |
| 81 16, |
| 82 0, |
| 83 GL_RGBA, |
| 84 GL_UNSIGNED_BYTE, |
| 85 kSharedMemoryId, |
| 86 kSharedMemoryOffset); |
| 87 EXPECT_CALL(*gl_, GenerateMipmapEXT(GL_TEXTURE_2D)).Times(1); |
| 88 EXPECT_CALL(*gl_, GetError()) |
| 89 .WillOnce(Return(GL_NO_ERROR)) |
| 90 .WillOnce(Return(GL_OUT_OF_MEMORY)) |
| 91 .RetiresOnSaturation(); |
| 92 GenerateMipmap cmd; |
| 93 cmd.Init(GL_TEXTURE_2D); |
| 94 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 95 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); |
| 96 EXPECT_FALSE(texture->GetLevelSize(GL_TEXTURE_2D, 2, &width, &height)); |
| 97 } |
| 98 |
| 99 TEST_F(GLES2DecoderTest, GenerateMipmapClearsUnclearedTexture) { |
| 100 EXPECT_CALL(*gl_, GenerateMipmapEXT(_)).Times(0); |
| 101 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 102 DoTexImage2D( |
| 103 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
| 104 SetupClearTextureExpectations(kServiceTextureId, |
| 105 kServiceTextureId, |
| 106 GL_TEXTURE_2D, |
| 107 GL_TEXTURE_2D, |
| 108 0, |
| 109 GL_RGBA, |
| 110 GL_RGBA, |
| 111 GL_UNSIGNED_BYTE, |
| 112 2, |
| 113 2); |
| 114 EXPECT_CALL(*gl_, GenerateMipmapEXT(GL_TEXTURE_2D)); |
| 115 EXPECT_CALL(*gl_, GetError()) |
| 116 .WillOnce(Return(GL_NO_ERROR)) |
| 117 .WillOnce(Return(GL_NO_ERROR)) |
| 118 .RetiresOnSaturation(); |
| 119 GenerateMipmap cmd; |
| 120 cmd.Init(GL_TEXTURE_2D); |
| 121 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 122 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 123 } |
| 124 |
| 125 // Same as GenerateMipmapClearsUnclearedTexture, but with workaround |
| 126 // |set_texture_filters_before_generating_mipmap|. |
| 127 TEST_F(GLES2DecoderManualInitTest, SetTextureFiltersBeforeGenerateMipmap) { |
| 128 CommandLine command_line(0, NULL); |
| 129 command_line.AppendSwitchASCII( |
| 130 switches::kGpuDriverBugWorkarounds, |
| 131 base::IntToString(gpu::SET_TEXTURE_FILTER_BEFORE_GENERATING_MIPMAP)); |
| 132 InitState init; |
| 133 init.gl_version = "3.0"; |
| 134 init.bind_generates_resource = true; |
| 135 InitDecoderWithCommandLine(init, &command_line); |
| 136 |
| 137 EXPECT_CALL(*gl_, GenerateMipmapEXT(_)).Times(0); |
| 138 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 139 DoTexImage2D( |
| 140 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
| 141 SetupClearTextureExpectations(kServiceTextureId, |
| 142 kServiceTextureId, |
| 143 GL_TEXTURE_2D, |
| 144 GL_TEXTURE_2D, |
| 145 0, |
| 146 GL_RGBA, |
| 147 GL_RGBA, |
| 148 GL_UNSIGNED_BYTE, |
| 149 2, |
| 150 2); |
| 151 EXPECT_CALL( |
| 152 *gl_, |
| 153 TexParameteri( |
| 154 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST)) |
| 155 .Times(1) |
| 156 .RetiresOnSaturation(); |
| 157 EXPECT_CALL(*gl_, GenerateMipmapEXT(GL_TEXTURE_2D)); |
| 158 EXPECT_CALL( |
| 159 *gl_, |
| 160 TexParameteri( |
| 161 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR)) |
| 162 .Times(1) |
| 163 .RetiresOnSaturation(); |
| 164 EXPECT_CALL(*gl_, GetError()) |
| 165 .WillOnce(Return(GL_NO_ERROR)) |
| 166 .WillOnce(Return(GL_NO_ERROR)) |
| 167 .RetiresOnSaturation(); |
| 168 GenerateMipmap cmd; |
| 169 cmd.Init(GL_TEXTURE_2D); |
| 170 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 171 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 172 } |
| 173 |
| 174 TEST_F(GLES2DecoderTest, ActiveTextureValidArgs) { |
| 175 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1)); |
| 176 SpecializedSetup<ActiveTexture, 0>(true); |
| 177 ActiveTexture cmd; |
| 178 cmd.Init(GL_TEXTURE1); |
| 179 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 180 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 181 } |
| 182 |
| 183 TEST_F(GLES2DecoderTest, ActiveTextureInvalidArgs) { |
| 184 EXPECT_CALL(*gl_, ActiveTexture(_)).Times(0); |
| 185 SpecializedSetup<ActiveTexture, 0>(false); |
| 186 ActiveTexture cmd; |
| 187 cmd.Init(GL_TEXTURE0 - 1); |
| 188 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 189 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 190 cmd.Init(kNumTextureUnits); |
| 191 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 192 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 193 } |
| 194 |
| 195 TEST_F(GLES2DecoderTest, TexSubImage2DValidArgs) { |
| 196 const int kWidth = 16; |
| 197 const int kHeight = 8; |
| 198 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 199 DoTexImage2D(GL_TEXTURE_2D, |
| 200 1, |
| 201 GL_RGBA, |
| 202 kWidth, |
| 203 kHeight, |
| 204 0, |
| 205 GL_RGBA, |
| 206 GL_UNSIGNED_BYTE, |
| 207 kSharedMemoryId, |
| 208 kSharedMemoryOffset); |
| 209 EXPECT_CALL(*gl_, |
| 210 TexSubImage2D(GL_TEXTURE_2D, |
| 211 1, |
| 212 1, |
| 213 0, |
| 214 kWidth - 1, |
| 215 kHeight, |
| 216 GL_RGBA, |
| 217 GL_UNSIGNED_BYTE, |
| 218 shared_memory_address_)) |
| 219 .Times(1) |
| 220 .RetiresOnSaturation(); |
| 221 TexSubImage2D cmd; |
| 222 cmd.Init(GL_TEXTURE_2D, |
| 223 1, |
| 224 1, |
| 225 0, |
| 226 kWidth - 1, |
| 227 kHeight, |
| 228 GL_RGBA, |
| 229 GL_UNSIGNED_BYTE, |
| 230 kSharedMemoryId, |
| 231 kSharedMemoryOffset, |
| 232 GL_FALSE); |
| 233 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 234 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 235 } |
| 236 |
| 237 TEST_F(GLES2DecoderTest, TexSubImage2DBadArgs) { |
| 238 const int kWidth = 16; |
| 239 const int kHeight = 8; |
| 240 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 241 DoTexImage2D(GL_TEXTURE_2D, |
| 242 1, |
| 243 GL_RGBA, |
| 244 kWidth, |
| 245 kHeight, |
| 246 0, |
| 247 GL_RGBA, |
| 248 GL_UNSIGNED_BYTE, |
| 249 0, |
| 250 0); |
| 251 TexSubImage2D cmd; |
| 252 cmd.Init(GL_TEXTURE0, |
| 253 1, |
| 254 0, |
| 255 0, |
| 256 kWidth, |
| 257 kHeight, |
| 258 GL_RGBA, |
| 259 GL_UNSIGNED_BYTE, |
| 260 kSharedMemoryId, |
| 261 kSharedMemoryOffset, |
| 262 GL_FALSE); |
| 263 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 264 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 265 cmd.Init(GL_TEXTURE_2D, |
| 266 1, |
| 267 0, |
| 268 0, |
| 269 kWidth, |
| 270 kHeight, |
| 271 GL_TRUE, |
| 272 GL_UNSIGNED_BYTE, |
| 273 kSharedMemoryId, |
| 274 kSharedMemoryOffset, |
| 275 GL_FALSE); |
| 276 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 277 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 278 cmd.Init(GL_TEXTURE_2D, |
| 279 1, |
| 280 0, |
| 281 0, |
| 282 kWidth, |
| 283 kHeight, |
| 284 GL_RGBA, |
| 285 GL_UNSIGNED_INT, |
| 286 kSharedMemoryId, |
| 287 kSharedMemoryOffset, |
| 288 GL_FALSE); |
| 289 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 290 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 291 cmd.Init(GL_TEXTURE_2D, |
| 292 1, |
| 293 -1, |
| 294 0, |
| 295 kWidth, |
| 296 kHeight, |
| 297 GL_RGBA, |
| 298 GL_UNSIGNED_BYTE, |
| 299 kSharedMemoryId, |
| 300 kSharedMemoryOffset, |
| 301 GL_FALSE); |
| 302 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 303 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 304 cmd.Init(GL_TEXTURE_2D, |
| 305 1, |
| 306 1, |
| 307 0, |
| 308 kWidth, |
| 309 kHeight, |
| 310 GL_RGBA, |
| 311 GL_UNSIGNED_BYTE, |
| 312 kSharedMemoryId, |
| 313 kSharedMemoryOffset, |
| 314 GL_FALSE); |
| 315 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 316 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 317 cmd.Init(GL_TEXTURE_2D, |
| 318 1, |
| 319 0, |
| 320 -1, |
| 321 kWidth, |
| 322 kHeight, |
| 323 GL_RGBA, |
| 324 GL_UNSIGNED_BYTE, |
| 325 kSharedMemoryId, |
| 326 kSharedMemoryOffset, |
| 327 GL_FALSE); |
| 328 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 329 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 330 cmd.Init(GL_TEXTURE_2D, |
| 331 1, |
| 332 0, |
| 333 1, |
| 334 kWidth, |
| 335 kHeight, |
| 336 GL_RGBA, |
| 337 GL_UNSIGNED_BYTE, |
| 338 kSharedMemoryId, |
| 339 kSharedMemoryOffset, |
| 340 GL_FALSE); |
| 341 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 342 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 343 cmd.Init(GL_TEXTURE_2D, |
| 344 1, |
| 345 0, |
| 346 0, |
| 347 kWidth + 1, |
| 348 kHeight, |
| 349 GL_RGBA, |
| 350 GL_UNSIGNED_BYTE, |
| 351 kSharedMemoryId, |
| 352 kSharedMemoryOffset, |
| 353 GL_FALSE); |
| 354 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 355 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 356 cmd.Init(GL_TEXTURE_2D, |
| 357 1, |
| 358 0, |
| 359 0, |
| 360 kWidth, |
| 361 kHeight + 1, |
| 362 GL_RGBA, |
| 363 GL_UNSIGNED_BYTE, |
| 364 kSharedMemoryId, |
| 365 kSharedMemoryOffset, |
| 366 GL_FALSE); |
| 367 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 368 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 369 cmd.Init(GL_TEXTURE_2D, |
| 370 1, |
| 371 0, |
| 372 0, |
| 373 kWidth, |
| 374 kHeight, |
| 375 GL_RGB, |
| 376 GL_UNSIGNED_BYTE, |
| 377 kSharedMemoryId, |
| 378 kSharedMemoryOffset, |
| 379 GL_FALSE); |
| 380 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 381 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 382 cmd.Init(GL_TEXTURE_2D, |
| 383 1, |
| 384 0, |
| 385 0, |
| 386 kWidth, |
| 387 kHeight, |
| 388 GL_RGBA, |
| 389 GL_UNSIGNED_SHORT_4_4_4_4, |
| 390 kSharedMemoryId, |
| 391 kSharedMemoryOffset, |
| 392 GL_FALSE); |
| 393 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 394 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 395 cmd.Init(GL_TEXTURE_2D, |
| 396 1, |
| 397 0, |
| 398 0, |
| 399 kWidth, |
| 400 kHeight, |
| 401 GL_RGBA, |
| 402 GL_UNSIGNED_BYTE, |
| 403 kInvalidSharedMemoryId, |
| 404 kSharedMemoryOffset, |
| 405 GL_FALSE); |
| 406 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
| 407 cmd.Init(GL_TEXTURE_2D, |
| 408 1, |
| 409 0, |
| 410 0, |
| 411 kWidth, |
| 412 kHeight, |
| 413 GL_RGBA, |
| 414 GL_UNSIGNED_BYTE, |
| 415 kSharedMemoryId, |
| 416 kInvalidSharedMemoryOffset, |
| 417 GL_FALSE); |
| 418 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
| 419 } |
| 420 |
| 421 TEST_F(GLES2DecoderTest, CopyTexSubImage2DValidArgs) { |
| 422 const int kWidth = 16; |
| 423 const int kHeight = 8; |
| 424 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 425 DoTexImage2D(GL_TEXTURE_2D, |
| 426 1, |
| 427 GL_RGBA, |
| 428 kWidth, |
| 429 kHeight, |
| 430 0, |
| 431 GL_RGBA, |
| 432 GL_UNSIGNED_BYTE, |
| 433 kSharedMemoryId, |
| 434 kSharedMemoryOffset); |
| 435 EXPECT_CALL(*gl_, |
| 436 CopyTexSubImage2D(GL_TEXTURE_2D, 1, 0, 0, 0, 0, kWidth, kHeight)) |
| 437 .Times(1) |
| 438 .RetiresOnSaturation(); |
| 439 CopyTexSubImage2D cmd; |
| 440 cmd.Init(GL_TEXTURE_2D, 1, 0, 0, 0, 0, kWidth, kHeight); |
| 441 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 442 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 443 } |
| 444 |
| 445 TEST_F(GLES2DecoderTest, CopyTexSubImage2DBadArgs) { |
| 446 const int kWidth = 16; |
| 447 const int kHeight = 8; |
| 448 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 449 DoTexImage2D(GL_TEXTURE_2D, |
| 450 1, |
| 451 GL_RGBA, |
| 452 kWidth, |
| 453 kHeight, |
| 454 0, |
| 455 GL_RGBA, |
| 456 GL_UNSIGNED_BYTE, |
| 457 0, |
| 458 0); |
| 459 CopyTexSubImage2D cmd; |
| 460 cmd.Init(GL_TEXTURE0, 1, 0, 0, 0, 0, kWidth, kHeight); |
| 461 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 462 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 463 cmd.Init(GL_TEXTURE_2D, 1, -1, 0, 0, 0, kWidth, kHeight); |
| 464 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 465 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 466 cmd.Init(GL_TEXTURE_2D, 1, 1, 0, 0, 0, kWidth, kHeight); |
| 467 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 468 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 469 cmd.Init(GL_TEXTURE_2D, 1, 0, -1, 0, 0, kWidth, kHeight); |
| 470 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 471 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 472 cmd.Init(GL_TEXTURE_2D, 1, 0, 1, 0, 0, kWidth, kHeight); |
| 473 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 474 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 475 cmd.Init(GL_TEXTURE_2D, 1, 0, 0, 0, 0, kWidth + 1, kHeight); |
| 476 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 477 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 478 cmd.Init(GL_TEXTURE_2D, 1, 0, 0, 0, 0, kWidth, kHeight + 1); |
| 479 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 480 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 481 } |
| 482 |
| 483 TEST_F(GLES2DecoderTest, TexImage2DRedefinitionSucceeds) { |
| 484 const int kWidth = 16; |
| 485 const int kHeight = 8; |
| 486 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 487 EXPECT_CALL(*gl_, GetError()).WillRepeatedly(Return(GL_NO_ERROR)); |
| 488 for (int ii = 0; ii < 2; ++ii) { |
| 489 TexImage2D cmd; |
| 490 if (ii == 0) { |
| 491 EXPECT_CALL(*gl_, |
| 492 TexImage2D(GL_TEXTURE_2D, |
| 493 0, |
| 494 GL_RGBA, |
| 495 kWidth, |
| 496 kHeight, |
| 497 0, |
| 498 GL_RGBA, |
| 499 GL_UNSIGNED_BYTE, |
| 500 _)) |
| 501 .Times(1) |
| 502 .RetiresOnSaturation(); |
| 503 cmd.Init(GL_TEXTURE_2D, |
| 504 0, |
| 505 GL_RGBA, |
| 506 kWidth, |
| 507 kHeight, |
| 508 0, |
| 509 GL_RGBA, |
| 510 GL_UNSIGNED_BYTE, |
| 511 kSharedMemoryId, |
| 512 kSharedMemoryOffset); |
| 513 } else { |
| 514 SetupClearTextureExpectations(kServiceTextureId, |
| 515 kServiceTextureId, |
| 516 GL_TEXTURE_2D, |
| 517 GL_TEXTURE_2D, |
| 518 0, |
| 519 GL_RGBA, |
| 520 GL_RGBA, |
| 521 GL_UNSIGNED_BYTE, |
| 522 kWidth, |
| 523 kHeight); |
| 524 cmd.Init(GL_TEXTURE_2D, |
| 525 0, |
| 526 GL_RGBA, |
| 527 kWidth, |
| 528 kHeight, |
| 529 0, |
| 530 GL_RGBA, |
| 531 GL_UNSIGNED_BYTE, |
| 532 0, |
| 533 0); |
| 534 } |
| 535 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 536 EXPECT_CALL(*gl_, |
| 537 TexSubImage2D(GL_TEXTURE_2D, |
| 538 0, |
| 539 0, |
| 540 0, |
| 541 kWidth, |
| 542 kHeight - 1, |
| 543 GL_RGBA, |
| 544 GL_UNSIGNED_BYTE, |
| 545 shared_memory_address_)) |
| 546 .Times(1) |
| 547 .RetiresOnSaturation(); |
| 548 // Consider this TexSubImage2D command part of the previous TexImage2D |
| 549 // (last GL_TRUE argument). It will be skipped if there are bugs in the |
| 550 // redefinition case. |
| 551 TexSubImage2D cmd2; |
| 552 cmd2.Init(GL_TEXTURE_2D, |
| 553 0, |
| 554 0, |
| 555 0, |
| 556 kWidth, |
| 557 kHeight - 1, |
| 558 GL_RGBA, |
| 559 GL_UNSIGNED_BYTE, |
| 560 kSharedMemoryId, |
| 561 kSharedMemoryOffset, |
| 562 GL_TRUE); |
| 563 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |
| 564 } |
| 565 } |
| 566 |
| 567 TEST_F(GLES2DecoderTest, TexImage2DGLError) { |
| 568 GLenum target = GL_TEXTURE_2D; |
| 569 GLint level = 0; |
| 570 GLenum internal_format = GL_RGBA; |
| 571 GLsizei width = 2; |
| 572 GLsizei height = 4; |
| 573 GLint border = 0; |
| 574 GLenum format = GL_RGBA; |
| 575 GLenum type = GL_UNSIGNED_BYTE; |
| 576 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 577 TextureManager* manager = group().texture_manager(); |
| 578 TextureRef* texture_ref = manager->GetTexture(client_texture_id_); |
| 579 ASSERT_TRUE(texture_ref != NULL); |
| 580 Texture* texture = texture_ref->texture(); |
| 581 EXPECT_FALSE(texture->GetLevelSize(GL_TEXTURE_2D, level, &width, &height)); |
| 582 EXPECT_CALL(*gl_, GetError()) |
| 583 .WillOnce(Return(GL_NO_ERROR)) |
| 584 .WillOnce(Return(GL_OUT_OF_MEMORY)) |
| 585 .RetiresOnSaturation(); |
| 586 EXPECT_CALL(*gl_, |
| 587 TexImage2D(target, |
| 588 level, |
| 589 internal_format, |
| 590 width, |
| 591 height, |
| 592 border, |
| 593 format, |
| 594 type, |
| 595 _)) |
| 596 .Times(1) |
| 597 .RetiresOnSaturation(); |
| 598 TexImage2D cmd; |
| 599 cmd.Init(target, |
| 600 level, |
| 601 internal_format, |
| 602 width, |
| 603 height, |
| 604 border, |
| 605 format, |
| 606 type, |
| 607 kSharedMemoryId, |
| 608 kSharedMemoryOffset); |
| 609 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 610 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); |
| 611 EXPECT_FALSE(texture->GetLevelSize(GL_TEXTURE_2D, level, &width, &height)); |
| 612 } |
| 613 |
| 614 TEST_F(GLES2DecoderTest, CopyTexImage2DGLError) { |
| 615 GLenum target = GL_TEXTURE_2D; |
| 616 GLint level = 0; |
| 617 GLenum internal_format = GL_RGBA; |
| 618 GLsizei width = 2; |
| 619 GLsizei height = 4; |
| 620 GLint border = 0; |
| 621 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 622 TextureManager* manager = group().texture_manager(); |
| 623 TextureRef* texture_ref = manager->GetTexture(client_texture_id_); |
| 624 ASSERT_TRUE(texture_ref != NULL); |
| 625 Texture* texture = texture_ref->texture(); |
| 626 EXPECT_FALSE(texture->GetLevelSize(GL_TEXTURE_2D, level, &width, &height)); |
| 627 EXPECT_CALL(*gl_, GetError()) |
| 628 .WillOnce(Return(GL_NO_ERROR)) |
| 629 .WillOnce(Return(GL_OUT_OF_MEMORY)) |
| 630 .RetiresOnSaturation(); |
| 631 EXPECT_CALL(*gl_, |
| 632 CopyTexImage2D( |
| 633 target, level, internal_format, 0, 0, width, height, border)) |
| 634 .Times(1) |
| 635 .RetiresOnSaturation(); |
| 636 CopyTexImage2D cmd; |
| 637 cmd.Init(target, level, internal_format, 0, 0, width, height, border); |
| 638 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 639 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); |
| 640 EXPECT_FALSE(texture->GetLevelSize(GL_TEXTURE_2D, level, &width, &height)); |
| 641 } |
| 642 |
| 643 TEST_F(GLES2DecoderManualInitTest, CompressedTexImage2DBucketBadBucket) { |
| 644 InitState init; |
| 645 init.extensions = "GL_EXT_texture_compression_s3tc"; |
| 646 init.gl_version = "3.0"; |
| 647 init.bind_generates_resource = true; |
| 648 InitDecoder(init); |
| 649 |
| 650 const uint32 kBadBucketId = 123; |
| 651 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 652 CompressedTexImage2DBucket cmd; |
| 653 cmd.Init(GL_TEXTURE_2D, |
| 654 0, |
| 655 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, |
| 656 4, |
| 657 4, |
| 658 0, |
| 659 kBadBucketId); |
| 660 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
| 661 CompressedTexSubImage2DBucket cmd2; |
| 662 cmd2.Init(GL_TEXTURE_2D, |
| 663 0, |
| 664 0, |
| 665 0, |
| 666 4, |
| 667 4, |
| 668 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, |
| 669 kBadBucketId); |
| 670 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
| 671 } |
| 672 |
| 673 namespace { |
| 674 |
| 675 struct S3TCTestData { |
| 676 GLenum format; |
| 677 size_t block_size; |
| 678 }; |
| 679 |
| 680 } // anonymous namespace. |
| 681 |
| 682 TEST_F(GLES2DecoderManualInitTest, CompressedTexImage2DS3TC) { |
| 683 InitState init; |
| 684 init.extensions = "GL_EXT_texture_compression_s3tc"; |
| 685 init.gl_version = "3.0"; |
| 686 init.bind_generates_resource = true; |
| 687 InitDecoder(init); |
| 688 const uint32 kBucketId = 123; |
| 689 CommonDecoder::Bucket* bucket = decoder_->CreateBucket(kBucketId); |
| 690 ASSERT_TRUE(bucket != NULL); |
| 691 |
| 692 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 693 |
| 694 static const S3TCTestData test_data[] = { |
| 695 { |
| 696 GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 8, |
| 697 }, |
| 698 { |
| 699 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 8, |
| 700 }, |
| 701 { |
| 702 GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, 16, |
| 703 }, |
| 704 { |
| 705 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, 16, |
| 706 }, |
| 707 }; |
| 708 |
| 709 for (size_t ii = 0; ii < arraysize(test_data); ++ii) { |
| 710 const S3TCTestData& test = test_data[ii]; |
| 711 CompressedTexImage2DBucket cmd; |
| 712 // test small width. |
| 713 DoCompressedTexImage2D( |
| 714 GL_TEXTURE_2D, 0, test.format, 2, 4, 0, test.block_size, kBucketId); |
| 715 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 716 |
| 717 // test bad width. |
| 718 cmd.Init(GL_TEXTURE_2D, 0, test.format, 5, 4, 0, kBucketId); |
| 719 bucket->SetSize(test.block_size * 2); |
| 720 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 721 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 722 |
| 723 // test small height. |
| 724 DoCompressedTexImage2D( |
| 725 GL_TEXTURE_2D, 0, test.format, 4, 2, 0, test.block_size, kBucketId); |
| 726 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 727 |
| 728 // test too bad height. |
| 729 cmd.Init(GL_TEXTURE_2D, 0, test.format, 4, 5, 0, kBucketId); |
| 730 bucket->SetSize(test.block_size * 2); |
| 731 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 732 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 733 |
| 734 // test small for level 0. |
| 735 DoCompressedTexImage2D( |
| 736 GL_TEXTURE_2D, 0, test.format, 1, 1, 0, test.block_size, kBucketId); |
| 737 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 738 |
| 739 // test small for level 0. |
| 740 DoCompressedTexImage2D( |
| 741 GL_TEXTURE_2D, 0, test.format, 2, 2, 0, test.block_size, kBucketId); |
| 742 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 743 |
| 744 // test size too large. |
| 745 cmd.Init(GL_TEXTURE_2D, 0, test.format, 4, 4, 0, kBucketId); |
| 746 bucket->SetSize(test.block_size * 2); |
| 747 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 748 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 749 |
| 750 // test size too small. |
| 751 cmd.Init(GL_TEXTURE_2D, 0, test.format, 4, 4, 0, kBucketId); |
| 752 bucket->SetSize(test.block_size / 2); |
| 753 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 754 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 755 |
| 756 // test with 3 mips. |
| 757 DoCompressedTexImage2D( |
| 758 GL_TEXTURE_2D, 0, test.format, 4, 4, 0, test.block_size, kBucketId); |
| 759 DoCompressedTexImage2D( |
| 760 GL_TEXTURE_2D, 1, test.format, 2, 2, 0, test.block_size, kBucketId); |
| 761 DoCompressedTexImage2D( |
| 762 GL_TEXTURE_2D, 2, test.format, 1, 1, 0, test.block_size, kBucketId); |
| 763 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 764 |
| 765 // Test a 16x16 |
| 766 DoCompressedTexImage2D(GL_TEXTURE_2D, |
| 767 0, |
| 768 test.format, |
| 769 16, |
| 770 16, |
| 771 0, |
| 772 test.block_size * 4 * 4, |
| 773 kBucketId); |
| 774 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 775 |
| 776 CompressedTexSubImage2DBucket sub_cmd; |
| 777 bucket->SetSize(test.block_size); |
| 778 // Test sub image bad xoffset |
| 779 sub_cmd.Init(GL_TEXTURE_2D, 0, 1, 0, 4, 4, test.format, kBucketId); |
| 780 EXPECT_EQ(error::kNoError, ExecuteCmd(sub_cmd)); |
| 781 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 782 |
| 783 // Test sub image bad yoffset |
| 784 sub_cmd.Init(GL_TEXTURE_2D, 0, 0, 2, 4, 4, test.format, kBucketId); |
| 785 EXPECT_EQ(error::kNoError, ExecuteCmd(sub_cmd)); |
| 786 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 787 |
| 788 // Test sub image bad width |
| 789 bucket->SetSize(test.block_size * 2); |
| 790 sub_cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 5, 4, test.format, kBucketId); |
| 791 EXPECT_EQ(error::kNoError, ExecuteCmd(sub_cmd)); |
| 792 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 793 |
| 794 // Test sub image bad height |
| 795 sub_cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 4, 5, test.format, kBucketId); |
| 796 EXPECT_EQ(error::kNoError, ExecuteCmd(sub_cmd)); |
| 797 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 798 |
| 799 // Test sub image bad size |
| 800 bucket->SetSize(test.block_size + 1); |
| 801 sub_cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 4, 4, test.format, kBucketId); |
| 802 EXPECT_EQ(error::kNoError, ExecuteCmd(sub_cmd)); |
| 803 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 804 |
| 805 for (GLint yoffset = 0; yoffset <= 8; yoffset += 4) { |
| 806 for (GLint xoffset = 0; xoffset <= 8; xoffset += 4) { |
| 807 for (GLsizei height = 4; height <= 8; height += 4) { |
| 808 for (GLsizei width = 4; width <= 8; width += 4) { |
| 809 GLsizei size = test.block_size * (width / 4) * (height / 4); |
| 810 bucket->SetSize(size); |
| 811 EXPECT_CALL(*gl_, |
| 812 CompressedTexSubImage2D(GL_TEXTURE_2D, |
| 813 0, |
| 814 xoffset, |
| 815 yoffset, |
| 816 width, |
| 817 height, |
| 818 test.format, |
| 819 size, |
| 820 _)) |
| 821 .Times(1) |
| 822 .RetiresOnSaturation(); |
| 823 sub_cmd.Init(GL_TEXTURE_2D, |
| 824 0, |
| 825 xoffset, |
| 826 yoffset, |
| 827 width, |
| 828 height, |
| 829 test.format, |
| 830 kBucketId); |
| 831 EXPECT_EQ(error::kNoError, ExecuteCmd(sub_cmd)); |
| 832 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 833 } |
| 834 } |
| 835 } |
| 836 } |
| 837 } |
| 838 } |
| 839 |
| 840 TEST_F(GLES2DecoderManualInitTest, CompressedTexImage2DETC1) { |
| 841 InitState init; |
| 842 init.extensions = "GL_OES_compressed_ETC1_RGB8_texture"; |
| 843 init.gl_version = "opengl es 2.0"; |
| 844 init.bind_generates_resource = true; |
| 845 InitDecoder(init); |
| 846 const uint32 kBucketId = 123; |
| 847 CommonDecoder::Bucket* bucket = decoder_->CreateBucket(kBucketId); |
| 848 ASSERT_TRUE(bucket != NULL); |
| 849 |
| 850 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 851 |
| 852 const GLenum kFormat = GL_ETC1_RGB8_OES; |
| 853 const size_t kBlockSize = 8; |
| 854 |
| 855 CompressedTexImage2DBucket cmd; |
| 856 // test small width. |
| 857 DoCompressedTexImage2D(GL_TEXTURE_2D, 0, kFormat, 4, 8, 0, 16, kBucketId); |
| 858 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 859 |
| 860 // test small height. |
| 861 DoCompressedTexImage2D(GL_TEXTURE_2D, 0, kFormat, 8, 4, 0, 16, kBucketId); |
| 862 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 863 |
| 864 // test size too large. |
| 865 cmd.Init(GL_TEXTURE_2D, 0, kFormat, 4, 4, 0, kBucketId); |
| 866 bucket->SetSize(kBlockSize * 2); |
| 867 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 868 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 869 |
| 870 // test size too small. |
| 871 cmd.Init(GL_TEXTURE_2D, 0, kFormat, 4, 4, 0, kBucketId); |
| 872 bucket->SetSize(kBlockSize / 2); |
| 873 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 874 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 875 |
| 876 // Test a 16x16 |
| 877 DoCompressedTexImage2D( |
| 878 GL_TEXTURE_2D, 0, kFormat, 16, 16, 0, kBlockSize * 16, kBucketId); |
| 879 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 880 |
| 881 // Test CompressedTexSubImage not allowed |
| 882 CompressedTexSubImage2DBucket sub_cmd; |
| 883 bucket->SetSize(kBlockSize); |
| 884 sub_cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 4, 4, kFormat, kBucketId); |
| 885 EXPECT_EQ(error::kNoError, ExecuteCmd(sub_cmd)); |
| 886 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 887 |
| 888 // Test TexSubImage not allowed for ETC1 compressed texture |
| 889 TextureRef* texture_ref = GetTexture(client_texture_id_); |
| 890 ASSERT_TRUE(texture_ref != NULL); |
| 891 Texture* texture = texture_ref->texture(); |
| 892 GLenum type, internal_format; |
| 893 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); |
| 894 EXPECT_EQ(kFormat, internal_format); |
| 895 TexSubImage2D texsub_cmd; |
| 896 texsub_cmd.Init(GL_TEXTURE_2D, |
| 897 0, |
| 898 0, |
| 899 0, |
| 900 4, |
| 901 4, |
| 902 GL_RGBA, |
| 903 GL_UNSIGNED_BYTE, |
| 904 kSharedMemoryId, |
| 905 kSharedMemoryOffset, |
| 906 GL_FALSE); |
| 907 EXPECT_EQ(error::kNoError, ExecuteCmd(texsub_cmd)); |
| 908 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 909 |
| 910 // Test CopyTexSubImage not allowed for ETC1 compressed texture |
| 911 CopyTexSubImage2D copy_cmd; |
| 912 copy_cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 4, 4); |
| 913 EXPECT_EQ(error::kNoError, ExecuteCmd(copy_cmd)); |
| 914 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 915 } |
| 916 |
| 917 TEST_F(GLES2DecoderManualInitTest, EGLImageExternalBindTexture) { |
| 918 InitState init; |
| 919 init.extensions = "GL_OES_EGL_image_external"; |
| 920 init.gl_version = "opengl es 2.0"; |
| 921 init.bind_generates_resource = true; |
| 922 InitDecoder(init); |
| 923 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_EXTERNAL_OES, kNewServiceId)); |
| 924 EXPECT_CALL(*gl_, GenTextures(1, _)) |
| 925 .WillOnce(SetArgumentPointee<1>(kNewServiceId)); |
| 926 BindTexture cmd; |
| 927 cmd.Init(GL_TEXTURE_EXTERNAL_OES, kNewClientId); |
| 928 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 929 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 930 TextureRef* texture_ref = GetTexture(kNewClientId); |
| 931 EXPECT_TRUE(texture_ref != NULL); |
| 932 EXPECT_TRUE(texture_ref->texture()->target() == GL_TEXTURE_EXTERNAL_OES); |
| 933 } |
| 934 |
| 935 TEST_F(GLES2DecoderManualInitTest, EGLImageExternalGetBinding) { |
| 936 InitState init; |
| 937 init.extensions = "GL_OES_EGL_image_external"; |
| 938 init.gl_version = "opengl es 2.0"; |
| 939 init.bind_generates_resource = true; |
| 940 InitDecoder(init); |
| 941 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); |
| 942 |
| 943 EXPECT_CALL(*gl_, GetError()) |
| 944 .WillOnce(Return(GL_NO_ERROR)) |
| 945 .WillOnce(Return(GL_NO_ERROR)) |
| 946 .RetiresOnSaturation(); |
| 947 typedef GetIntegerv::Result Result; |
| 948 Result* result = static_cast<Result*>(shared_memory_address_); |
| 949 EXPECT_CALL(*gl_, |
| 950 GetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES, result->GetData())) |
| 951 .Times(0); |
| 952 result->size = 0; |
| 953 GetIntegerv cmd; |
| 954 cmd.Init(GL_TEXTURE_BINDING_EXTERNAL_OES, |
| 955 shared_memory_id_, |
| 956 shared_memory_offset_); |
| 957 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 958 EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned( |
| 959 GL_TEXTURE_BINDING_EXTERNAL_OES), |
| 960 result->GetNumResults()); |
| 961 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 962 EXPECT_EQ(client_texture_id_, (uint32)result->GetData()[0]); |
| 963 } |
| 964 |
| 965 TEST_F(GLES2DecoderManualInitTest, EGLImageExternalTextureDefaults) { |
| 966 InitState init; |
| 967 init.extensions = "GL_OES_EGL_image_external"; |
| 968 init.gl_version = "opengl es 2.0"; |
| 969 init.bind_generates_resource = true; |
| 970 InitDecoder(init); |
| 971 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); |
| 972 |
| 973 TextureRef* texture_ref = GetTexture(client_texture_id_); |
| 974 EXPECT_TRUE(texture_ref != NULL); |
| 975 Texture* texture = texture_ref->texture(); |
| 976 EXPECT_TRUE(texture->target() == GL_TEXTURE_EXTERNAL_OES); |
| 977 EXPECT_TRUE(texture->min_filter() == GL_LINEAR); |
| 978 EXPECT_TRUE(texture->wrap_s() == GL_CLAMP_TO_EDGE); |
| 979 EXPECT_TRUE(texture->wrap_t() == GL_CLAMP_TO_EDGE); |
| 980 } |
| 981 |
| 982 TEST_F(GLES2DecoderManualInitTest, EGLImageExternalTextureParam) { |
| 983 InitState init; |
| 984 init.extensions = "GL_OES_EGL_image_external"; |
| 985 init.gl_version = "opengl es 2.0"; |
| 986 init.bind_generates_resource = true; |
| 987 InitDecoder(init); |
| 988 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); |
| 989 |
| 990 EXPECT_CALL(*gl_, |
| 991 TexParameteri( |
| 992 GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_NEAREST)); |
| 993 EXPECT_CALL( |
| 994 *gl_, |
| 995 TexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); |
| 996 EXPECT_CALL( |
| 997 *gl_, |
| 998 TexParameteri( |
| 999 GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); |
| 1000 EXPECT_CALL( |
| 1001 *gl_, |
| 1002 TexParameteri( |
| 1003 GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); |
| 1004 TexParameteri cmd; |
| 1005 cmd.Init(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 1006 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1007 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1008 |
| 1009 cmd.Init(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 1010 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1011 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1012 |
| 1013 cmd.Init(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 1014 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1015 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1016 |
| 1017 cmd.Init(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 1018 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1019 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1020 |
| 1021 TextureRef* texture_ref = GetTexture(client_texture_id_); |
| 1022 EXPECT_TRUE(texture_ref != NULL); |
| 1023 Texture* texture = texture_ref->texture(); |
| 1024 EXPECT_TRUE(texture->target() == GL_TEXTURE_EXTERNAL_OES); |
| 1025 EXPECT_TRUE(texture->min_filter() == GL_LINEAR); |
| 1026 EXPECT_TRUE(texture->wrap_s() == GL_CLAMP_TO_EDGE); |
| 1027 EXPECT_TRUE(texture->wrap_t() == GL_CLAMP_TO_EDGE); |
| 1028 } |
| 1029 |
| 1030 TEST_F(GLES2DecoderManualInitTest, EGLImageExternalTextureParamInvalid) { |
| 1031 InitState init; |
| 1032 init.extensions = "GL_OES_EGL_image_external"; |
| 1033 init.gl_version = "opengl es 2.0"; |
| 1034 init.bind_generates_resource = true; |
| 1035 InitDecoder(init); |
| 1036 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); |
| 1037 |
| 1038 TexParameteri cmd; |
| 1039 cmd.Init(GL_TEXTURE_EXTERNAL_OES, |
| 1040 GL_TEXTURE_MIN_FILTER, |
| 1041 GL_NEAREST_MIPMAP_NEAREST); |
| 1042 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1043 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 1044 |
| 1045 cmd.Init(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_REPEAT); |
| 1046 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1047 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 1048 |
| 1049 cmd.Init(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_REPEAT); |
| 1050 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1051 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 1052 |
| 1053 TextureRef* texture_ref = GetTexture(client_texture_id_); |
| 1054 EXPECT_TRUE(texture_ref != NULL); |
| 1055 Texture* texture = texture_ref->texture(); |
| 1056 EXPECT_TRUE(texture->target() == GL_TEXTURE_EXTERNAL_OES); |
| 1057 EXPECT_TRUE(texture->min_filter() == GL_LINEAR); |
| 1058 EXPECT_TRUE(texture->wrap_s() == GL_CLAMP_TO_EDGE); |
| 1059 EXPECT_TRUE(texture->wrap_t() == GL_CLAMP_TO_EDGE); |
| 1060 } |
| 1061 |
| 1062 TEST_F(GLES2DecoderManualInitTest, EGLImageExternalTexImage2DError) { |
| 1063 InitState init; |
| 1064 init.extensions = "GL_OES_EGL_image_external"; |
| 1065 init.gl_version = "opengl es 2.0"; |
| 1066 init.bind_generates_resource = true; |
| 1067 InitDecoder(init); |
| 1068 |
| 1069 GLenum target = GL_TEXTURE_EXTERNAL_OES; |
| 1070 GLint level = 0; |
| 1071 GLenum internal_format = GL_RGBA; |
| 1072 GLsizei width = 2; |
| 1073 GLsizei height = 4; |
| 1074 GLint border = 0; |
| 1075 GLenum format = GL_RGBA; |
| 1076 GLenum type = GL_UNSIGNED_BYTE; |
| 1077 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); |
| 1078 ASSERT_TRUE(GetTexture(client_texture_id_) != NULL); |
| 1079 TexImage2D cmd; |
| 1080 cmd.Init(target, |
| 1081 level, |
| 1082 internal_format, |
| 1083 width, |
| 1084 height, |
| 1085 border, |
| 1086 format, |
| 1087 type, |
| 1088 kSharedMemoryId, |
| 1089 kSharedMemoryOffset); |
| 1090 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1091 |
| 1092 // TexImage2D is not allowed with GL_TEXTURE_EXTERNAL_OES targets. |
| 1093 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 1094 } |
| 1095 |
| 1096 TEST_F(GLES2DecoderManualInitTest, DefaultTextureZero) { |
| 1097 InitState init; |
| 1098 init.gl_version = "3.0"; |
| 1099 InitDecoder(init); |
| 1100 |
| 1101 BindTexture cmd1; |
| 1102 cmd1.Init(GL_TEXTURE_2D, 0); |
| 1103 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0)); |
| 1104 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); |
| 1105 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1106 |
| 1107 BindTexture cmd2; |
| 1108 cmd2.Init(GL_TEXTURE_CUBE_MAP, 0); |
| 1109 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_CUBE_MAP, 0)); |
| 1110 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |
| 1111 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1112 } |
| 1113 |
| 1114 TEST_F(GLES2DecoderManualInitTest, DefaultTextureBGR) { |
| 1115 InitState init; |
| 1116 init.gl_version = "3.0"; |
| 1117 init.bind_generates_resource = true; |
| 1118 InitDecoder(init); |
| 1119 |
| 1120 BindTexture cmd1; |
| 1121 cmd1.Init(GL_TEXTURE_2D, 0); |
| 1122 EXPECT_CALL( |
| 1123 *gl_, BindTexture(GL_TEXTURE_2D, TestHelper::kServiceDefaultTexture2dId)); |
| 1124 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); |
| 1125 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1126 |
| 1127 BindTexture cmd2; |
| 1128 cmd2.Init(GL_TEXTURE_CUBE_MAP, 0); |
| 1129 EXPECT_CALL(*gl_, |
| 1130 BindTexture(GL_TEXTURE_CUBE_MAP, |
| 1131 TestHelper::kServiceDefaultTextureCubemapId)); |
| 1132 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |
| 1133 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1134 } |
| 1135 |
| 1136 // Test that default texture 0 is immutable. |
| 1137 TEST_F(GLES2DecoderManualInitTest, NoDefaultTexParameterf) { |
| 1138 InitState init; |
| 1139 init.gl_version = "3.0"; |
| 1140 InitDecoder(init); |
| 1141 |
| 1142 { |
| 1143 BindTexture cmd1; |
| 1144 cmd1.Init(GL_TEXTURE_2D, 0); |
| 1145 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0)); |
| 1146 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); |
| 1147 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1148 |
| 1149 TexParameterf cmd2; |
| 1150 cmd2.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 1151 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |
| 1152 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 1153 } |
| 1154 |
| 1155 { |
| 1156 BindTexture cmd1; |
| 1157 cmd1.Init(GL_TEXTURE_CUBE_MAP, 0); |
| 1158 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_CUBE_MAP, 0)); |
| 1159 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); |
| 1160 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1161 |
| 1162 TexParameterf cmd2; |
| 1163 cmd2.Init(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 1164 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |
| 1165 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 1166 } |
| 1167 } |
| 1168 |
| 1169 TEST_F(GLES2DecoderManualInitTest, NoDefaultTexParameteri) { |
| 1170 InitState init; |
| 1171 init.gl_version = "3.0"; |
| 1172 InitDecoder(init); |
| 1173 |
| 1174 { |
| 1175 BindTexture cmd1; |
| 1176 cmd1.Init(GL_TEXTURE_2D, 0); |
| 1177 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0)); |
| 1178 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); |
| 1179 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1180 |
| 1181 TexParameteri cmd2; |
| 1182 cmd2.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 1183 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |
| 1184 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 1185 } |
| 1186 |
| 1187 { |
| 1188 BindTexture cmd1; |
| 1189 cmd1.Init(GL_TEXTURE_CUBE_MAP, 0); |
| 1190 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_CUBE_MAP, 0)); |
| 1191 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); |
| 1192 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1193 |
| 1194 TexParameteri cmd2; |
| 1195 cmd2.Init(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 1196 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |
| 1197 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 1198 } |
| 1199 } |
| 1200 |
| 1201 TEST_F(GLES2DecoderManualInitTest, NoDefaultTexParameterfv) { |
| 1202 InitState init; |
| 1203 init.gl_version = "3.0"; |
| 1204 InitDecoder(init); |
| 1205 |
| 1206 { |
| 1207 BindTexture cmd1; |
| 1208 cmd1.Init(GL_TEXTURE_2D, 0); |
| 1209 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0)); |
| 1210 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); |
| 1211 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1212 |
| 1213 TexParameterfv cmd2; |
| 1214 cmd2.Init(GL_TEXTURE_2D, |
| 1215 GL_TEXTURE_MAG_FILTER, |
| 1216 shared_memory_id_, |
| 1217 shared_memory_offset_); |
| 1218 GetSharedMemoryAs<GLfloat*>()[0] = GL_NEAREST; |
| 1219 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |
| 1220 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 1221 } |
| 1222 |
| 1223 { |
| 1224 BindTexture cmd1; |
| 1225 cmd1.Init(GL_TEXTURE_CUBE_MAP, 0); |
| 1226 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_CUBE_MAP, 0)); |
| 1227 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); |
| 1228 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1229 |
| 1230 TexParameterfv cmd2; |
| 1231 cmd2.Init(GL_TEXTURE_CUBE_MAP, |
| 1232 GL_TEXTURE_MAG_FILTER, |
| 1233 shared_memory_id_, |
| 1234 shared_memory_offset_); |
| 1235 GetSharedMemoryAs<GLfloat*>()[0] = GL_NEAREST; |
| 1236 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |
| 1237 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 1238 } |
| 1239 } |
| 1240 |
| 1241 TEST_F(GLES2DecoderManualInitTest, NoDefaultTexParameteriv) { |
| 1242 InitState init; |
| 1243 init.gl_version = "3.0"; |
| 1244 InitDecoder(init); |
| 1245 |
| 1246 { |
| 1247 BindTexture cmd1; |
| 1248 cmd1.Init(GL_TEXTURE_2D, 0); |
| 1249 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0)); |
| 1250 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); |
| 1251 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1252 |
| 1253 TexParameteriv cmd2; |
| 1254 cmd2.Init(GL_TEXTURE_2D, |
| 1255 GL_TEXTURE_MAG_FILTER, |
| 1256 shared_memory_id_, |
| 1257 shared_memory_offset_); |
| 1258 GetSharedMemoryAs<GLint*>()[0] = GL_NEAREST; |
| 1259 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |
| 1260 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 1261 } |
| 1262 |
| 1263 { |
| 1264 BindTexture cmd1; |
| 1265 cmd1.Init(GL_TEXTURE_CUBE_MAP, 0); |
| 1266 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_CUBE_MAP, 0)); |
| 1267 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); |
| 1268 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1269 |
| 1270 TexParameteriv cmd2; |
| 1271 cmd2.Init(GL_TEXTURE_CUBE_MAP, |
| 1272 GL_TEXTURE_MAG_FILTER, |
| 1273 shared_memory_id_, |
| 1274 shared_memory_offset_); |
| 1275 GetSharedMemoryAs<GLint*>()[0] = GL_NEAREST; |
| 1276 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |
| 1277 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 1278 } |
| 1279 } |
| 1280 |
| 1281 TEST_F(GLES2DecoderManualInitTest, NoDefaultTexImage2D) { |
| 1282 InitState init; |
| 1283 init.gl_version = "3.0"; |
| 1284 InitDecoder(init); |
| 1285 |
| 1286 BindTexture cmd1; |
| 1287 cmd1.Init(GL_TEXTURE_2D, 0); |
| 1288 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0)); |
| 1289 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); |
| 1290 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1291 |
| 1292 TexImage2D cmd2; |
| 1293 cmd2.Init(GL_TEXTURE_2D, |
| 1294 0, |
| 1295 GL_RGBA, |
| 1296 2, |
| 1297 2, |
| 1298 0, |
| 1299 GL_RGBA, |
| 1300 GL_UNSIGNED_BYTE, |
| 1301 kSharedMemoryId, |
| 1302 kSharedMemoryOffset); |
| 1303 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |
| 1304 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 1305 } |
| 1306 |
| 1307 TEST_F(GLES2DecoderManualInitTest, NoDefaultTexSubImage2D) { |
| 1308 InitState init; |
| 1309 init.gl_version = "3.0"; |
| 1310 InitDecoder(init); |
| 1311 |
| 1312 BindTexture cmd1; |
| 1313 cmd1.Init(GL_TEXTURE_2D, 0); |
| 1314 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0)); |
| 1315 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); |
| 1316 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1317 |
| 1318 TexSubImage2D cmd2; |
| 1319 cmd2.Init(GL_TEXTURE_2D, |
| 1320 0, |
| 1321 1, |
| 1322 1, |
| 1323 1, |
| 1324 1, |
| 1325 GL_RGBA, |
| 1326 GL_UNSIGNED_BYTE, |
| 1327 kSharedMemoryId, |
| 1328 kSharedMemoryOffset, |
| 1329 GL_FALSE); |
| 1330 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |
| 1331 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 1332 } |
| 1333 |
| 1334 TEST_F(GLES2DecoderManualInitTest, ARBTextureRectangleBindTexture) { |
| 1335 InitState init; |
| 1336 init.extensions = "GL_ARB_texture_rectangle"; |
| 1337 init.gl_version = "3.0"; |
| 1338 init.bind_generates_resource = true; |
| 1339 InitDecoder(init); |
| 1340 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_RECTANGLE_ARB, kNewServiceId)); |
| 1341 EXPECT_CALL(*gl_, GenTextures(1, _)) |
| 1342 .WillOnce(SetArgumentPointee<1>(kNewServiceId)); |
| 1343 BindTexture cmd; |
| 1344 cmd.Init(GL_TEXTURE_RECTANGLE_ARB, kNewClientId); |
| 1345 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1346 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1347 Texture* texture = GetTexture(kNewClientId)->texture(); |
| 1348 EXPECT_TRUE(texture != NULL); |
| 1349 EXPECT_TRUE(texture->target() == GL_TEXTURE_RECTANGLE_ARB); |
| 1350 } |
| 1351 |
| 1352 TEST_F(GLES2DecoderManualInitTest, ARBTextureRectangleGetBinding) { |
| 1353 InitState init; |
| 1354 init.extensions = "GL_ARB_texture_rectangle"; |
| 1355 init.gl_version = "3.0"; |
| 1356 init.bind_generates_resource = true; |
| 1357 InitDecoder(init); |
| 1358 DoBindTexture( |
| 1359 GL_TEXTURE_RECTANGLE_ARB, client_texture_id_, kServiceTextureId); |
| 1360 |
| 1361 EXPECT_CALL(*gl_, GetError()) |
| 1362 .WillOnce(Return(GL_NO_ERROR)) |
| 1363 .WillOnce(Return(GL_NO_ERROR)) |
| 1364 .RetiresOnSaturation(); |
| 1365 typedef GetIntegerv::Result Result; |
| 1366 Result* result = static_cast<Result*>(shared_memory_address_); |
| 1367 EXPECT_CALL(*gl_, |
| 1368 GetIntegerv(GL_TEXTURE_BINDING_RECTANGLE_ARB, result->GetData())) |
| 1369 .Times(0); |
| 1370 result->size = 0; |
| 1371 GetIntegerv cmd; |
| 1372 cmd.Init(GL_TEXTURE_BINDING_RECTANGLE_ARB, |
| 1373 shared_memory_id_, |
| 1374 shared_memory_offset_); |
| 1375 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1376 EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned( |
| 1377 GL_TEXTURE_BINDING_RECTANGLE_ARB), |
| 1378 result->GetNumResults()); |
| 1379 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1380 EXPECT_EQ(client_texture_id_, (uint32)result->GetData()[0]); |
| 1381 } |
| 1382 |
| 1383 TEST_F(GLES2DecoderManualInitTest, ARBTextureRectangleTextureDefaults) { |
| 1384 InitState init; |
| 1385 init.extensions = "GL_ARB_texture_rectangle"; |
| 1386 init.gl_version = "3.0"; |
| 1387 init.bind_generates_resource = true; |
| 1388 InitDecoder(init); |
| 1389 DoBindTexture( |
| 1390 GL_TEXTURE_RECTANGLE_ARB, client_texture_id_, kServiceTextureId); |
| 1391 |
| 1392 Texture* texture = GetTexture(client_texture_id_)->texture(); |
| 1393 EXPECT_TRUE(texture != NULL); |
| 1394 EXPECT_TRUE(texture->target() == GL_TEXTURE_RECTANGLE_ARB); |
| 1395 EXPECT_TRUE(texture->min_filter() == GL_LINEAR); |
| 1396 EXPECT_TRUE(texture->wrap_s() == GL_CLAMP_TO_EDGE); |
| 1397 EXPECT_TRUE(texture->wrap_t() == GL_CLAMP_TO_EDGE); |
| 1398 } |
| 1399 |
| 1400 TEST_F(GLES2DecoderManualInitTest, ARBTextureRectangleTextureParam) { |
| 1401 InitState init; |
| 1402 init.extensions = "GL_ARB_texture_rectangle"; |
| 1403 init.gl_version = "3.0"; |
| 1404 init.bind_generates_resource = true; |
| 1405 InitDecoder(init); |
| 1406 |
| 1407 DoBindTexture( |
| 1408 GL_TEXTURE_RECTANGLE_ARB, client_texture_id_, kServiceTextureId); |
| 1409 |
| 1410 EXPECT_CALL(*gl_, |
| 1411 TexParameteri( |
| 1412 GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST)); |
| 1413 EXPECT_CALL(*gl_, |
| 1414 TexParameteri( |
| 1415 GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); |
| 1416 EXPECT_CALL( |
| 1417 *gl_, |
| 1418 TexParameteri( |
| 1419 GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); |
| 1420 EXPECT_CALL( |
| 1421 *gl_, |
| 1422 TexParameteri( |
| 1423 GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); |
| 1424 TexParameteri cmd; |
| 1425 cmd.Init(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 1426 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1427 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1428 |
| 1429 cmd.Init(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 1430 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1431 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1432 |
| 1433 cmd.Init(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 1434 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1435 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1436 |
| 1437 cmd.Init(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 1438 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1439 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1440 |
| 1441 Texture* texture = GetTexture(client_texture_id_)->texture(); |
| 1442 EXPECT_TRUE(texture != NULL); |
| 1443 EXPECT_TRUE(texture->target() == GL_TEXTURE_RECTANGLE_ARB); |
| 1444 EXPECT_TRUE(texture->min_filter() == GL_LINEAR); |
| 1445 EXPECT_TRUE(texture->wrap_s() == GL_CLAMP_TO_EDGE); |
| 1446 EXPECT_TRUE(texture->wrap_t() == GL_CLAMP_TO_EDGE); |
| 1447 } |
| 1448 |
| 1449 TEST_F(GLES2DecoderManualInitTest, ARBTextureRectangleTextureParamInvalid) { |
| 1450 InitState init; |
| 1451 init.extensions = "GL_ARB_texture_rectangle"; |
| 1452 init.gl_version = "3.0"; |
| 1453 init.bind_generates_resource = true; |
| 1454 InitDecoder(init); |
| 1455 |
| 1456 DoBindTexture( |
| 1457 GL_TEXTURE_RECTANGLE_ARB, client_texture_id_, kServiceTextureId); |
| 1458 |
| 1459 TexParameteri cmd; |
| 1460 cmd.Init(GL_TEXTURE_RECTANGLE_ARB, |
| 1461 GL_TEXTURE_MIN_FILTER, |
| 1462 GL_NEAREST_MIPMAP_NEAREST); |
| 1463 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1464 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 1465 |
| 1466 cmd.Init(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_REPEAT); |
| 1467 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1468 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 1469 |
| 1470 cmd.Init(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_REPEAT); |
| 1471 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1472 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 1473 |
| 1474 Texture* texture = GetTexture(client_texture_id_)->texture(); |
| 1475 EXPECT_TRUE(texture != NULL); |
| 1476 EXPECT_TRUE(texture->target() == GL_TEXTURE_RECTANGLE_ARB); |
| 1477 EXPECT_TRUE(texture->min_filter() == GL_LINEAR); |
| 1478 EXPECT_TRUE(texture->wrap_s() == GL_CLAMP_TO_EDGE); |
| 1479 EXPECT_TRUE(texture->wrap_t() == GL_CLAMP_TO_EDGE); |
| 1480 } |
| 1481 |
| 1482 TEST_F(GLES2DecoderManualInitTest, ARBTextureRectangleTexImage2DError) { |
| 1483 InitState init; |
| 1484 init.extensions = "GL_ARB_texture_rectangle"; |
| 1485 init.gl_version = "3.0"; |
| 1486 init.bind_generates_resource = true; |
| 1487 InitDecoder(init); |
| 1488 |
| 1489 GLenum target = GL_TEXTURE_RECTANGLE_ARB; |
| 1490 GLint level = 0; |
| 1491 GLenum internal_format = GL_RGBA; |
| 1492 GLsizei width = 2; |
| 1493 GLsizei height = 4; |
| 1494 GLint border = 0; |
| 1495 GLenum format = GL_RGBA; |
| 1496 GLenum type = GL_UNSIGNED_BYTE; |
| 1497 DoBindTexture( |
| 1498 GL_TEXTURE_RECTANGLE_ARB, client_texture_id_, kServiceTextureId); |
| 1499 ASSERT_TRUE(GetTexture(client_texture_id_) != NULL); |
| 1500 TexImage2D cmd; |
| 1501 cmd.Init(target, |
| 1502 level, |
| 1503 internal_format, |
| 1504 width, |
| 1505 height, |
| 1506 border, |
| 1507 format, |
| 1508 type, |
| 1509 kSharedMemoryId, |
| 1510 kSharedMemoryOffset); |
| 1511 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1512 |
| 1513 // TexImage2D is not allowed with GL_TEXTURE_RECTANGLE_ARB targets. |
| 1514 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 1515 } |
| 1516 |
| 1517 TEST_F(GLES2DecoderManualInitTest, TexSubImage2DClearsAfterTexImage2DNULL) { |
| 1518 InitState init; |
| 1519 init.gl_version = "opengl es 2.0"; |
| 1520 init.has_alpha = true; |
| 1521 init.has_depth = true; |
| 1522 init.request_alpha = true; |
| 1523 init.request_depth = true; |
| 1524 InitDecoder(init); |
| 1525 |
| 1526 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 1527 DoTexImage2D( |
| 1528 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
| 1529 SetupClearTextureExpectations(kServiceTextureId, |
| 1530 kServiceTextureId, |
| 1531 GL_TEXTURE_2D, |
| 1532 GL_TEXTURE_2D, |
| 1533 0, |
| 1534 GL_RGBA, |
| 1535 GL_RGBA, |
| 1536 GL_UNSIGNED_BYTE, |
| 1537 2, |
| 1538 2); |
| 1539 EXPECT_CALL(*gl_, |
| 1540 TexSubImage2D(GL_TEXTURE_2D, |
| 1541 0, |
| 1542 1, |
| 1543 1, |
| 1544 1, |
| 1545 1, |
| 1546 GL_RGBA, |
| 1547 GL_UNSIGNED_BYTE, |
| 1548 shared_memory_address_)) |
| 1549 .Times(1) |
| 1550 .RetiresOnSaturation(); |
| 1551 TexSubImage2D cmd; |
| 1552 cmd.Init(GL_TEXTURE_2D, |
| 1553 0, |
| 1554 1, |
| 1555 1, |
| 1556 1, |
| 1557 1, |
| 1558 GL_RGBA, |
| 1559 GL_UNSIGNED_BYTE, |
| 1560 kSharedMemoryId, |
| 1561 kSharedMemoryOffset, |
| 1562 GL_FALSE); |
| 1563 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1564 // Test if we call it again it does not clear. |
| 1565 EXPECT_CALL(*gl_, |
| 1566 TexSubImage2D(GL_TEXTURE_2D, |
| 1567 0, |
| 1568 1, |
| 1569 1, |
| 1570 1, |
| 1571 1, |
| 1572 GL_RGBA, |
| 1573 GL_UNSIGNED_BYTE, |
| 1574 shared_memory_address_)) |
| 1575 .Times(1) |
| 1576 .RetiresOnSaturation(); |
| 1577 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1578 } |
| 1579 |
| 1580 TEST_F(GLES2DecoderTest, TexSubImage2DDoesNotClearAfterTexImage2DNULLThenData) { |
| 1581 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 1582 DoTexImage2D( |
| 1583 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
| 1584 DoTexImage2D(GL_TEXTURE_2D, |
| 1585 0, |
| 1586 GL_RGBA, |
| 1587 2, |
| 1588 2, |
| 1589 0, |
| 1590 GL_RGBA, |
| 1591 GL_UNSIGNED_BYTE, |
| 1592 kSharedMemoryId, |
| 1593 kSharedMemoryOffset); |
| 1594 EXPECT_CALL(*gl_, |
| 1595 TexSubImage2D(GL_TEXTURE_2D, |
| 1596 0, |
| 1597 1, |
| 1598 1, |
| 1599 1, |
| 1600 1, |
| 1601 GL_RGBA, |
| 1602 GL_UNSIGNED_BYTE, |
| 1603 shared_memory_address_)) |
| 1604 .Times(1) |
| 1605 .RetiresOnSaturation(); |
| 1606 TexSubImage2D cmd; |
| 1607 cmd.Init(GL_TEXTURE_2D, |
| 1608 0, |
| 1609 1, |
| 1610 1, |
| 1611 1, |
| 1612 1, |
| 1613 GL_RGBA, |
| 1614 GL_UNSIGNED_BYTE, |
| 1615 kSharedMemoryId, |
| 1616 kSharedMemoryOffset, |
| 1617 GL_FALSE); |
| 1618 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1619 // Test if we call it again it does not clear. |
| 1620 EXPECT_CALL(*gl_, |
| 1621 TexSubImage2D(GL_TEXTURE_2D, |
| 1622 0, |
| 1623 1, |
| 1624 1, |
| 1625 1, |
| 1626 1, |
| 1627 GL_RGBA, |
| 1628 GL_UNSIGNED_BYTE, |
| 1629 shared_memory_address_)) |
| 1630 .Times(1) |
| 1631 .RetiresOnSaturation(); |
| 1632 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1633 } |
| 1634 |
| 1635 TEST_F( |
| 1636 GLES2DecoderManualInitTest, |
| 1637 TexSubImage2DDoesNotClearAfterTexImage2DNULLThenDataWithTexImage2DIsFaster)
{ |
| 1638 CommandLine command_line(0, NULL); |
| 1639 command_line.AppendSwitchASCII( |
| 1640 switches::kGpuDriverBugWorkarounds, |
| 1641 base::IntToString(gpu::TEXSUBIMAGE2D_FASTER_THAN_TEXIMAGE2D)); |
| 1642 InitState init; |
| 1643 init.gl_version = "3.0"; |
| 1644 init.bind_generates_resource = true; |
| 1645 InitDecoderWithCommandLine(init, &command_line); |
| 1646 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 1647 DoTexImage2D( |
| 1648 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
| 1649 |
| 1650 { |
| 1651 // Uses texSubimage internally because the above workaround is active and |
| 1652 // the update is for the full size of the texture. |
| 1653 EXPECT_CALL(*gl_, |
| 1654 TexSubImage2D( |
| 1655 GL_TEXTURE_2D, 0, 0, 0, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, _)) |
| 1656 .Times(1) |
| 1657 .RetiresOnSaturation(); |
| 1658 cmds::TexImage2D cmd; |
| 1659 cmd.Init(GL_TEXTURE_2D, |
| 1660 0, |
| 1661 GL_RGBA, |
| 1662 2, |
| 1663 2, |
| 1664 0, |
| 1665 GL_RGBA, |
| 1666 GL_UNSIGNED_BYTE, |
| 1667 kSharedMemoryId, |
| 1668 kSharedMemoryOffset); |
| 1669 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1670 } |
| 1671 |
| 1672 EXPECT_CALL(*gl_, |
| 1673 TexSubImage2D(GL_TEXTURE_2D, |
| 1674 0, |
| 1675 1, |
| 1676 1, |
| 1677 1, |
| 1678 1, |
| 1679 GL_RGBA, |
| 1680 GL_UNSIGNED_BYTE, |
| 1681 shared_memory_address_)) |
| 1682 .Times(1) |
| 1683 .RetiresOnSaturation(); |
| 1684 TexSubImage2D cmd; |
| 1685 cmd.Init(GL_TEXTURE_2D, |
| 1686 0, |
| 1687 1, |
| 1688 1, |
| 1689 1, |
| 1690 1, |
| 1691 GL_RGBA, |
| 1692 GL_UNSIGNED_BYTE, |
| 1693 kSharedMemoryId, |
| 1694 kSharedMemoryOffset, |
| 1695 GL_FALSE); |
| 1696 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1697 // Test if we call it again it does not clear. |
| 1698 EXPECT_CALL(*gl_, |
| 1699 TexSubImage2D(GL_TEXTURE_2D, |
| 1700 0, |
| 1701 1, |
| 1702 1, |
| 1703 1, |
| 1704 1, |
| 1705 GL_RGBA, |
| 1706 GL_UNSIGNED_BYTE, |
| 1707 shared_memory_address_)) |
| 1708 .Times(1) |
| 1709 .RetiresOnSaturation(); |
| 1710 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1711 } |
| 1712 |
| 1713 TEST_F(GLES2DecoderTest, TexSubImage2DClearsAfterTexImage2DWithDataThenNULL) { |
| 1714 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 1715 // Put in data (so it should be marked as cleared) |
| 1716 DoTexImage2D(GL_TEXTURE_2D, |
| 1717 0, |
| 1718 GL_RGBA, |
| 1719 2, |
| 1720 2, |
| 1721 0, |
| 1722 GL_RGBA, |
| 1723 GL_UNSIGNED_BYTE, |
| 1724 kSharedMemoryId, |
| 1725 kSharedMemoryOffset); |
| 1726 // Put in no data. |
| 1727 TexImage2D tex_cmd; |
| 1728 tex_cmd.Init( |
| 1729 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
| 1730 // It won't actually call TexImage2D, just mark it as uncleared. |
| 1731 EXPECT_EQ(error::kNoError, ExecuteCmd(tex_cmd)); |
| 1732 // Next call to TexSubImage2d should clear. |
| 1733 SetupClearTextureExpectations(kServiceTextureId, |
| 1734 kServiceTextureId, |
| 1735 GL_TEXTURE_2D, |
| 1736 GL_TEXTURE_2D, |
| 1737 0, |
| 1738 GL_RGBA, |
| 1739 GL_RGBA, |
| 1740 GL_UNSIGNED_BYTE, |
| 1741 2, |
| 1742 2); |
| 1743 EXPECT_CALL(*gl_, |
| 1744 TexSubImage2D(GL_TEXTURE_2D, |
| 1745 0, |
| 1746 1, |
| 1747 1, |
| 1748 1, |
| 1749 1, |
| 1750 GL_RGBA, |
| 1751 GL_UNSIGNED_BYTE, |
| 1752 shared_memory_address_)) |
| 1753 .Times(1) |
| 1754 .RetiresOnSaturation(); |
| 1755 TexSubImage2D cmd; |
| 1756 cmd.Init(GL_TEXTURE_2D, |
| 1757 0, |
| 1758 1, |
| 1759 1, |
| 1760 1, |
| 1761 1, |
| 1762 GL_RGBA, |
| 1763 GL_UNSIGNED_BYTE, |
| 1764 kSharedMemoryId, |
| 1765 kSharedMemoryOffset, |
| 1766 GL_FALSE); |
| 1767 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1768 } |
| 1769 |
| 1770 TEST_F(GLES2DecoderTest, CopyTexImage2DMarksTextureAsCleared) { |
| 1771 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 1772 |
| 1773 TextureManager* manager = group().texture_manager(); |
| 1774 TextureRef* texture_ref = manager->GetTexture(client_texture_id_); |
| 1775 ASSERT_TRUE(texture_ref != NULL); |
| 1776 Texture* texture = texture_ref->texture(); |
| 1777 |
| 1778 EXPECT_CALL(*gl_, GetError()) |
| 1779 .WillOnce(Return(GL_NO_ERROR)) |
| 1780 .RetiresOnSaturation(); |
| 1781 EXPECT_CALL(*gl_, CopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 1, 1, 0)) |
| 1782 .Times(1) |
| 1783 .RetiresOnSaturation(); |
| 1784 EXPECT_CALL(*gl_, GetError()) |
| 1785 .WillOnce(Return(GL_NO_ERROR)) |
| 1786 .RetiresOnSaturation(); |
| 1787 CopyTexImage2D cmd; |
| 1788 cmd.Init(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 1, 1, 0); |
| 1789 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1790 |
| 1791 EXPECT_TRUE(texture->SafeToRenderFrom()); |
| 1792 } |
| 1793 |
| 1794 TEST_F(GLES2DecoderTest, CopyTexSubImage2DClearsUnclearedTexture) { |
| 1795 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 1796 DoTexImage2D( |
| 1797 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
| 1798 |
| 1799 SetupClearTextureExpectations(kServiceTextureId, |
| 1800 kServiceTextureId, |
| 1801 GL_TEXTURE_2D, |
| 1802 GL_TEXTURE_2D, |
| 1803 0, |
| 1804 GL_RGBA, |
| 1805 GL_RGBA, |
| 1806 GL_UNSIGNED_BYTE, |
| 1807 2, |
| 1808 2); |
| 1809 EXPECT_CALL(*gl_, CopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 1, 1)) |
| 1810 .Times(1) |
| 1811 .RetiresOnSaturation(); |
| 1812 CopyTexSubImage2D cmd; |
| 1813 cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 1, 1); |
| 1814 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1815 } |
| 1816 |
| 1817 TEST_F(GLES2DecoderManualInitTest, CompressedImage2DMarksTextureAsCleared) { |
| 1818 InitState init; |
| 1819 init.extensions = "GL_EXT_texture_compression_s3tc"; |
| 1820 init.gl_version = "3.0"; |
| 1821 init.bind_generates_resource = true; |
| 1822 InitDecoder(init); |
| 1823 |
| 1824 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 1825 EXPECT_CALL(*gl_, GetError()) |
| 1826 .WillOnce(Return(GL_NO_ERROR)) |
| 1827 .RetiresOnSaturation(); |
| 1828 EXPECT_CALL( |
| 1829 *gl_, |
| 1830 CompressedTexImage2D( |
| 1831 GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 4, 4, 0, 8, _)) |
| 1832 .Times(1) |
| 1833 .RetiresOnSaturation(); |
| 1834 EXPECT_CALL(*gl_, GetError()) |
| 1835 .WillOnce(Return(GL_NO_ERROR)) |
| 1836 .RetiresOnSaturation(); |
| 1837 CompressedTexImage2D cmd; |
| 1838 cmd.Init(GL_TEXTURE_2D, |
| 1839 0, |
| 1840 GL_COMPRESSED_RGB_S3TC_DXT1_EXT, |
| 1841 4, |
| 1842 4, |
| 1843 0, |
| 1844 8, |
| 1845 kSharedMemoryId, |
| 1846 kSharedMemoryOffset); |
| 1847 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1848 TextureManager* manager = group().texture_manager(); |
| 1849 TextureRef* texture_ref = manager->GetTexture(client_texture_id_); |
| 1850 EXPECT_TRUE(texture_ref->texture()->SafeToRenderFrom()); |
| 1851 } |
| 1852 |
| 1853 TEST_F(GLES2DecoderTest, TextureUsageAngleExtNotEnabledByDefault) { |
| 1854 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 1855 |
| 1856 TexParameteri cmd; |
| 1857 cmd.Init( |
| 1858 GL_TEXTURE_2D, GL_TEXTURE_USAGE_ANGLE, GL_FRAMEBUFFER_ATTACHMENT_ANGLE); |
| 1859 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 1860 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 1861 } |
| 1862 |
| 1863 TEST_F(GLES2DecoderTest, ProduceAndConsumeTextureCHROMIUM) { |
| 1864 Mailbox mailbox = Mailbox::Generate(); |
| 1865 |
| 1866 memcpy(shared_memory_address_, mailbox.name, sizeof(mailbox.name)); |
| 1867 |
| 1868 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 1869 DoTexImage2D( |
| 1870 GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
| 1871 DoTexImage2D( |
| 1872 GL_TEXTURE_2D, 1, GL_RGBA, 2, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
| 1873 TextureRef* texture_ref = |
| 1874 group().texture_manager()->GetTexture(client_texture_id_); |
| 1875 ASSERT_TRUE(texture_ref != NULL); |
| 1876 Texture* texture = texture_ref->texture(); |
| 1877 EXPECT_EQ(kServiceTextureId, texture->service_id()); |
| 1878 |
| 1879 ProduceTextureCHROMIUM produce_cmd; |
| 1880 produce_cmd.Init(GL_TEXTURE_2D, kSharedMemoryId, kSharedMemoryOffset); |
| 1881 EXPECT_EQ(error::kNoError, ExecuteCmd(produce_cmd)); |
| 1882 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1883 |
| 1884 // Texture didn't change. |
| 1885 GLsizei width; |
| 1886 GLsizei height; |
| 1887 GLenum type; |
| 1888 GLenum internal_format; |
| 1889 |
| 1890 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); |
| 1891 EXPECT_EQ(3, width); |
| 1892 EXPECT_EQ(1, height); |
| 1893 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); |
| 1894 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); |
| 1895 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); |
| 1896 |
| 1897 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 1, &width, &height)); |
| 1898 EXPECT_EQ(2, width); |
| 1899 EXPECT_EQ(4, height); |
| 1900 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 1, &type, &internal_format)); |
| 1901 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); |
| 1902 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); |
| 1903 |
| 1904 // Service ID has not changed. |
| 1905 EXPECT_EQ(kServiceTextureId, texture->service_id()); |
| 1906 |
| 1907 // Create new texture for consume. |
| 1908 EXPECT_CALL(*gl_, GenTextures(_, _)) |
| 1909 .WillOnce(SetArgumentPointee<1>(kNewServiceId)) |
| 1910 .RetiresOnSaturation(); |
| 1911 DoBindTexture(GL_TEXTURE_2D, kNewClientId, kNewServiceId); |
| 1912 |
| 1913 // Assigns and binds original service size texture ID. |
| 1914 EXPECT_CALL(*gl_, DeleteTextures(1, _)).Times(1).RetiresOnSaturation(); |
| 1915 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId)) |
| 1916 .Times(1) |
| 1917 .RetiresOnSaturation(); |
| 1918 |
| 1919 memcpy(shared_memory_address_, mailbox.name, sizeof(mailbox.name)); |
| 1920 ConsumeTextureCHROMIUM consume_cmd; |
| 1921 consume_cmd.Init(GL_TEXTURE_2D, kSharedMemoryId, kSharedMemoryOffset); |
| 1922 EXPECT_EQ(error::kNoError, ExecuteCmd(consume_cmd)); |
| 1923 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1924 |
| 1925 // Texture is redefined. |
| 1926 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); |
| 1927 EXPECT_EQ(3, width); |
| 1928 EXPECT_EQ(1, height); |
| 1929 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); |
| 1930 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); |
| 1931 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); |
| 1932 |
| 1933 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 1, &width, &height)); |
| 1934 EXPECT_EQ(2, width); |
| 1935 EXPECT_EQ(4, height); |
| 1936 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 1, &type, &internal_format)); |
| 1937 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); |
| 1938 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); |
| 1939 |
| 1940 // Service ID is restored. |
| 1941 EXPECT_EQ(kServiceTextureId, texture->service_id()); |
| 1942 } |
| 1943 |
| 1944 TEST_F(GLES2DecoderManualInitTest, DepthTextureBadArgs) { |
| 1945 InitState init; |
| 1946 init.extensions = "GL_ANGLE_depth_texture"; |
| 1947 init.gl_version = "opengl es 2.0"; |
| 1948 init.has_depth = true; |
| 1949 init.has_stencil = true; |
| 1950 init.request_depth = true; |
| 1951 init.request_stencil = true; |
| 1952 init.bind_generates_resource = true; |
| 1953 InitDecoder(init); |
| 1954 |
| 1955 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 1956 // Check trying to upload data fails. |
| 1957 TexImage2D tex_cmd; |
| 1958 tex_cmd.Init(GL_TEXTURE_2D, |
| 1959 0, |
| 1960 GL_DEPTH_COMPONENT, |
| 1961 1, |
| 1962 1, |
| 1963 0, |
| 1964 GL_DEPTH_COMPONENT, |
| 1965 GL_UNSIGNED_INT, |
| 1966 kSharedMemoryId, |
| 1967 kSharedMemoryOffset); |
| 1968 EXPECT_EQ(error::kNoError, ExecuteCmd(tex_cmd)); |
| 1969 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 1970 // Try level > 0. |
| 1971 tex_cmd.Init(GL_TEXTURE_2D, |
| 1972 1, |
| 1973 GL_DEPTH_COMPONENT, |
| 1974 1, |
| 1975 1, |
| 1976 0, |
| 1977 GL_DEPTH_COMPONENT, |
| 1978 GL_UNSIGNED_INT, |
| 1979 0, |
| 1980 0); |
| 1981 EXPECT_EQ(error::kNoError, ExecuteCmd(tex_cmd)); |
| 1982 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 1983 // Make a 1 pixel depth texture. |
| 1984 DoTexImage2D(GL_TEXTURE_2D, |
| 1985 0, |
| 1986 GL_DEPTH_COMPONENT, |
| 1987 1, |
| 1988 1, |
| 1989 0, |
| 1990 GL_DEPTH_COMPONENT, |
| 1991 GL_UNSIGNED_INT, |
| 1992 0, |
| 1993 0); |
| 1994 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1995 |
| 1996 // Check that trying to update it fails. |
| 1997 TexSubImage2D tex_sub_cmd; |
| 1998 tex_sub_cmd.Init(GL_TEXTURE_2D, |
| 1999 0, |
| 2000 0, |
| 2001 0, |
| 2002 1, |
| 2003 1, |
| 2004 GL_DEPTH_COMPONENT, |
| 2005 GL_UNSIGNED_INT, |
| 2006 kSharedMemoryId, |
| 2007 kSharedMemoryOffset, |
| 2008 GL_FALSE); |
| 2009 EXPECT_EQ(error::kNoError, ExecuteCmd(tex_sub_cmd)); |
| 2010 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 2011 |
| 2012 // Check that trying to CopyTexImage2D fails |
| 2013 CopyTexImage2D copy_tex_cmd; |
| 2014 copy_tex_cmd.Init(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 0, 0, 1, 1, 0); |
| 2015 EXPECT_EQ(error::kNoError, ExecuteCmd(copy_tex_cmd)); |
| 2016 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 2017 |
| 2018 // Check that trying to CopyTexSubImage2D fails |
| 2019 CopyTexSubImage2D copy_sub_cmd; |
| 2020 copy_sub_cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 1, 1); |
| 2021 EXPECT_EQ(error::kNoError, ExecuteCmd(copy_sub_cmd)); |
| 2022 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 2023 } |
| 2024 |
| 2025 TEST_F(GLES2DecoderManualInitTest, GenerateMipmapDepthTexture) { |
| 2026 InitState init; |
| 2027 init.extensions = "GL_ANGLE_depth_texture"; |
| 2028 init.gl_version = "opengl es 2.0"; |
| 2029 init.has_depth = true; |
| 2030 init.has_stencil = true; |
| 2031 init.request_depth = true; |
| 2032 init.request_stencil = true; |
| 2033 init.bind_generates_resource = true; |
| 2034 InitDecoder(init); |
| 2035 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 2036 DoTexImage2D(GL_TEXTURE_2D, |
| 2037 0, |
| 2038 GL_DEPTH_COMPONENT, |
| 2039 2, |
| 2040 2, |
| 2041 0, |
| 2042 GL_DEPTH_COMPONENT, |
| 2043 GL_UNSIGNED_INT, |
| 2044 0, |
| 2045 0); |
| 2046 GenerateMipmap cmd; |
| 2047 cmd.Init(GL_TEXTURE_2D); |
| 2048 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 2049 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 2050 } |
| 2051 |
| 2052 TEST_F(GLES2DecoderTest, BindTexImage2DCHROMIUM) { |
| 2053 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 2054 DoTexImage2D( |
| 2055 GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
| 2056 TextureRef* texture_ref = |
| 2057 group().texture_manager()->GetTexture(client_texture_id_); |
| 2058 ASSERT_TRUE(texture_ref != NULL); |
| 2059 Texture* texture = texture_ref->texture(); |
| 2060 EXPECT_EQ(kServiceTextureId, texture->service_id()); |
| 2061 |
| 2062 group().image_manager()->AddImage(gfx::GLImage::CreateGLImage(0).get(), 1); |
| 2063 EXPECT_FALSE(group().image_manager()->LookupImage(1) == NULL); |
| 2064 |
| 2065 GLsizei width; |
| 2066 GLsizei height; |
| 2067 GLenum type; |
| 2068 GLenum internal_format; |
| 2069 |
| 2070 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); |
| 2071 EXPECT_EQ(3, width); |
| 2072 EXPECT_EQ(1, height); |
| 2073 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); |
| 2074 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); |
| 2075 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); |
| 2076 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); |
| 2077 |
| 2078 // Bind image to texture. |
| 2079 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. |
| 2080 EXPECT_CALL(*gl_, GetError()) |
| 2081 .WillOnce(Return(GL_NO_ERROR)) |
| 2082 .WillOnce(Return(GL_NO_ERROR)) |
| 2083 .RetiresOnSaturation(); |
| 2084 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd; |
| 2085 bind_tex_image_2d_cmd.Init(GL_TEXTURE_2D, 1); |
| 2086 EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd)); |
| 2087 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); |
| 2088 // Image should now be set. |
| 2089 EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); |
| 2090 |
| 2091 // Define new texture image. |
| 2092 DoTexImage2D( |
| 2093 GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
| 2094 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); |
| 2095 // Image should no longer be set. |
| 2096 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); |
| 2097 } |
| 2098 |
| 2099 TEST_F(GLES2DecoderTest, BindTexImage2DCHROMIUMCubeMapNotAllowed) { |
| 2100 group().image_manager()->AddImage(gfx::GLImage::CreateGLImage(0).get(), 1); |
| 2101 DoBindTexture(GL_TEXTURE_CUBE_MAP, client_texture_id_, kServiceTextureId); |
| 2102 |
| 2103 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd; |
| 2104 bind_tex_image_2d_cmd.Init(GL_TEXTURE_CUBE_MAP, 1); |
| 2105 EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd)); |
| 2106 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 2107 } |
| 2108 |
| 2109 TEST_F(GLES2DecoderTest, OrphanGLImageWithTexImage2D) { |
| 2110 group().image_manager()->AddImage(gfx::GLImage::CreateGLImage(0).get(), 1); |
| 2111 DoBindTexture(GL_TEXTURE_CUBE_MAP, client_texture_id_, kServiceTextureId); |
| 2112 |
| 2113 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd; |
| 2114 bind_tex_image_2d_cmd.Init(GL_TEXTURE_CUBE_MAP, 1); |
| 2115 EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd)); |
| 2116 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 2117 |
| 2118 DoTexImage2D( |
| 2119 GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
| 2120 TextureRef* texture_ref = |
| 2121 group().texture_manager()->GetTexture(client_texture_id_); |
| 2122 ASSERT_TRUE(texture_ref != NULL); |
| 2123 Texture* texture = texture_ref->texture(); |
| 2124 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); |
| 2125 } |
| 2126 |
| 2127 TEST_F(GLES2DecoderTest, ReleaseTexImage2DCHROMIUM) { |
| 2128 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 2129 DoTexImage2D( |
| 2130 GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
| 2131 TextureRef* texture_ref = |
| 2132 group().texture_manager()->GetTexture(client_texture_id_); |
| 2133 ASSERT_TRUE(texture_ref != NULL); |
| 2134 Texture* texture = texture_ref->texture(); |
| 2135 EXPECT_EQ(kServiceTextureId, texture->service_id()); |
| 2136 |
| 2137 group().image_manager()->AddImage(gfx::GLImage::CreateGLImage(0).get(), 1); |
| 2138 EXPECT_FALSE(group().image_manager()->LookupImage(1) == NULL); |
| 2139 |
| 2140 GLsizei width; |
| 2141 GLsizei height; |
| 2142 GLenum type; |
| 2143 GLenum internal_format; |
| 2144 |
| 2145 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); |
| 2146 EXPECT_EQ(3, width); |
| 2147 EXPECT_EQ(1, height); |
| 2148 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); |
| 2149 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); |
| 2150 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); |
| 2151 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); |
| 2152 |
| 2153 // Bind image to texture. |
| 2154 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. |
| 2155 EXPECT_CALL(*gl_, GetError()) |
| 2156 .WillOnce(Return(GL_NO_ERROR)) |
| 2157 .WillOnce(Return(GL_NO_ERROR)) |
| 2158 .RetiresOnSaturation(); |
| 2159 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd; |
| 2160 bind_tex_image_2d_cmd.Init(GL_TEXTURE_2D, 1); |
| 2161 EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd)); |
| 2162 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); |
| 2163 // Image should now be set. |
| 2164 EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); |
| 2165 |
| 2166 // Release image from texture. |
| 2167 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. |
| 2168 EXPECT_CALL(*gl_, GetError()) |
| 2169 .WillOnce(Return(GL_NO_ERROR)) |
| 2170 .WillOnce(Return(GL_NO_ERROR)) |
| 2171 .RetiresOnSaturation(); |
| 2172 ReleaseTexImage2DCHROMIUM release_tex_image_2d_cmd; |
| 2173 release_tex_image_2d_cmd.Init(GL_TEXTURE_2D, 1); |
| 2174 EXPECT_EQ(error::kNoError, ExecuteCmd(release_tex_image_2d_cmd)); |
| 2175 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); |
| 2176 // Image should no longer be set. |
| 2177 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); |
| 2178 } |
| 2179 |
| 2180 class MockGLImage : public gfx::GLImage { |
| 2181 public: |
| 2182 MockGLImage() {} |
| 2183 |
| 2184 // Overridden from gfx::GLImage: |
| 2185 MOCK_METHOD0(Destroy, void()); |
| 2186 MOCK_METHOD0(GetSize, gfx::Size()); |
| 2187 MOCK_METHOD1(BindTexImage, bool(unsigned)); |
| 2188 MOCK_METHOD1(ReleaseTexImage, void(unsigned)); |
| 2189 MOCK_METHOD0(WillUseTexImage, void()); |
| 2190 MOCK_METHOD0(DidUseTexImage, void()); |
| 2191 MOCK_METHOD0(WillModifyTexImage, void()); |
| 2192 MOCK_METHOD0(DidModifyTexImage, void()); |
| 2193 |
| 2194 protected: |
| 2195 virtual ~MockGLImage() {} |
| 2196 }; |
| 2197 |
| 2198 TEST_F(GLES2DecoderWithShaderTest, UseTexImage) { |
| 2199 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 2200 DoTexImage2D(GL_TEXTURE_2D, |
| 2201 0, |
| 2202 GL_RGBA, |
| 2203 1, |
| 2204 1, |
| 2205 0, |
| 2206 GL_RGBA, |
| 2207 GL_UNSIGNED_BYTE, |
| 2208 kSharedMemoryId, |
| 2209 kSharedMemoryOffset); |
| 2210 |
| 2211 TextureRef* texture_ref = |
| 2212 group().texture_manager()->GetTexture(client_texture_id_); |
| 2213 ASSERT_TRUE(texture_ref != NULL); |
| 2214 Texture* texture = texture_ref->texture(); |
| 2215 EXPECT_EQ(kServiceTextureId, texture->service_id()); |
| 2216 |
| 2217 const int32 kImageId = 1; |
| 2218 scoped_refptr<MockGLImage> image(new MockGLImage); |
| 2219 group().image_manager()->AddImage(image.get(), kImageId); |
| 2220 |
| 2221 // Bind image to texture. |
| 2222 EXPECT_CALL(*image, BindTexImage(GL_TEXTURE_2D)) |
| 2223 .Times(1) |
| 2224 .WillOnce(Return(true)) |
| 2225 .RetiresOnSaturation(); |
| 2226 EXPECT_CALL(*image, GetSize()) |
| 2227 .Times(1) |
| 2228 .WillOnce(Return(gfx::Size(1, 1))) |
| 2229 .RetiresOnSaturation(); |
| 2230 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. |
| 2231 EXPECT_CALL(*gl_, GetError()) |
| 2232 .WillOnce(Return(GL_NO_ERROR)) |
| 2233 .WillOnce(Return(GL_NO_ERROR)) |
| 2234 .RetiresOnSaturation(); |
| 2235 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd; |
| 2236 bind_tex_image_2d_cmd.Init(GL_TEXTURE_2D, kImageId); |
| 2237 EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd)); |
| 2238 |
| 2239 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); |
| 2240 SetupExpectationsForApplyingDefaultDirtyState(); |
| 2241 |
| 2242 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. |
| 2243 EXPECT_CALL(*gl_, GetError()) |
| 2244 .WillOnce(Return(GL_NO_ERROR)) |
| 2245 .WillOnce(Return(GL_NO_ERROR)) |
| 2246 .WillOnce(Return(GL_NO_ERROR)) |
| 2247 .WillOnce(Return(GL_NO_ERROR)) |
| 2248 .RetiresOnSaturation(); |
| 2249 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)).Times(3).RetiresOnSaturation(); |
| 2250 EXPECT_CALL(*image, WillUseTexImage()).Times(1).RetiresOnSaturation(); |
| 2251 EXPECT_CALL(*image, DidUseTexImage()).Times(1).RetiresOnSaturation(); |
| 2252 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) |
| 2253 .Times(1) |
| 2254 .RetiresOnSaturation(); |
| 2255 DrawArrays cmd; |
| 2256 cmd.Init(GL_TRIANGLES, 0, kNumVertices); |
| 2257 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 2258 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 2259 |
| 2260 DoBindFramebuffer( |
| 2261 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
| 2262 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. |
| 2263 EXPECT_CALL(*gl_, GetError()) |
| 2264 .WillOnce(Return(GL_NO_ERROR)) |
| 2265 .WillOnce(Return(GL_NO_ERROR)) |
| 2266 .RetiresOnSaturation(); |
| 2267 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)).Times(1).RetiresOnSaturation(); |
| 2268 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId)) |
| 2269 .Times(2) |
| 2270 .RetiresOnSaturation(); |
| 2271 // Image will be 'in use' as long as bound to a framebuffer. |
| 2272 EXPECT_CALL(*image, WillUseTexImage()).Times(1).RetiresOnSaturation(); |
| 2273 EXPECT_CALL(*gl_, |
| 2274 FramebufferTexture2DEXT(GL_FRAMEBUFFER, |
| 2275 GL_COLOR_ATTACHMENT0, |
| 2276 GL_TEXTURE_2D, |
| 2277 kServiceTextureId, |
| 2278 0)) |
| 2279 .Times(1) |
| 2280 .RetiresOnSaturation(); |
| 2281 EXPECT_CALL(*gl_, GetError()) |
| 2282 .WillOnce(Return(GL_NO_ERROR)) |
| 2283 .WillOnce(Return(GL_NO_ERROR)) |
| 2284 .RetiresOnSaturation(); |
| 2285 FramebufferTexture2D fbtex_cmd; |
| 2286 fbtex_cmd.Init(GL_FRAMEBUFFER, |
| 2287 GL_COLOR_ATTACHMENT0, |
| 2288 GL_TEXTURE_2D, |
| 2289 client_texture_id_, |
| 2290 0); |
| 2291 EXPECT_EQ(error::kNoError, ExecuteCmd(fbtex_cmd)); |
| 2292 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 2293 |
| 2294 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. |
| 2295 EXPECT_CALL(*gl_, GetError()) |
| 2296 .WillOnce(Return(GL_NO_ERROR)) |
| 2297 .WillOnce(Return(GL_NO_ERROR)) |
| 2298 .RetiresOnSaturation(); |
| 2299 EXPECT_CALL(*gl_, |
| 2300 FramebufferRenderbufferEXT(GL_FRAMEBUFFER, |
| 2301 GL_COLOR_ATTACHMENT0, |
| 2302 GL_RENDERBUFFER, |
| 2303 kServiceRenderbufferId)) |
| 2304 .Times(1) |
| 2305 .RetiresOnSaturation(); |
| 2306 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)).Times(1).RetiresOnSaturation(); |
| 2307 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId)) |
| 2308 .Times(2) |
| 2309 .RetiresOnSaturation(); |
| 2310 // Image should no longer be 'in use' after being unbound from framebuffer. |
| 2311 EXPECT_CALL(*image, DidUseTexImage()).Times(1).RetiresOnSaturation(); |
| 2312 EXPECT_CALL(*gl_, GetError()) |
| 2313 .WillOnce(Return(GL_NO_ERROR)) |
| 2314 .WillOnce(Return(GL_NO_ERROR)) |
| 2315 .RetiresOnSaturation(); |
| 2316 FramebufferRenderbuffer fbrb_cmd; |
| 2317 fbrb_cmd.Init(GL_FRAMEBUFFER, |
| 2318 GL_COLOR_ATTACHMENT0, |
| 2319 GL_RENDERBUFFER, |
| 2320 client_renderbuffer_id_); |
| 2321 EXPECT_EQ(error::kNoError, ExecuteCmd(fbrb_cmd)); |
| 2322 } |
| 2323 |
| 2324 TEST_F(GLES2DecoderManualInitTest, DrawWithGLImageExternal) { |
| 2325 InitState init; |
| 2326 init.extensions = "GL_OES_EGL_image_external"; |
| 2327 init.gl_version = "opengl es 2.0"; |
| 2328 init.has_alpha = true; |
| 2329 init.has_depth = true; |
| 2330 init.request_alpha = true; |
| 2331 init.request_depth = true; |
| 2332 init.bind_generates_resource = true; |
| 2333 InitDecoder(init); |
| 2334 |
| 2335 TextureRef* texture_ref = GetTexture(client_texture_id_); |
| 2336 scoped_refptr<MockGLImage> image(new MockGLImage); |
| 2337 group().texture_manager()->SetTarget(texture_ref, GL_TEXTURE_EXTERNAL_OES); |
| 2338 group().texture_manager()->SetLevelInfo(texture_ref, |
| 2339 GL_TEXTURE_EXTERNAL_OES, |
| 2340 0, |
| 2341 GL_RGBA, |
| 2342 0, |
| 2343 0, |
| 2344 1, |
| 2345 0, |
| 2346 GL_RGBA, |
| 2347 GL_UNSIGNED_BYTE, |
| 2348 true); |
| 2349 group().texture_manager()->SetLevelImage( |
| 2350 texture_ref, GL_TEXTURE_EXTERNAL_OES, 0, image); |
| 2351 |
| 2352 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); |
| 2353 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 2354 |
| 2355 SetupSamplerExternalProgram(); |
| 2356 SetupIndexBuffer(); |
| 2357 AddExpectationsForSimulatedAttrib0(kMaxValidIndex + 1, 0); |
| 2358 SetupExpectationsForApplyingDefaultDirtyState(); |
| 2359 EXPECT_TRUE(group().texture_manager()->CanRender(texture_ref)); |
| 2360 |
| 2361 InSequence s; |
| 2362 EXPECT_CALL(*gl_, GetError()) |
| 2363 .WillOnce(Return(GL_NO_ERROR)) |
| 2364 .RetiresOnSaturation(); |
| 2365 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)).Times(1).RetiresOnSaturation(); |
| 2366 EXPECT_CALL(*image, WillUseTexImage()).Times(1).RetiresOnSaturation(); |
| 2367 EXPECT_CALL(*gl_, GetError()) |
| 2368 .WillOnce(Return(GL_NO_ERROR)) |
| 2369 .RetiresOnSaturation(); |
| 2370 EXPECT_CALL(*gl_, DrawElements(_, _, _, _)).Times(1); |
| 2371 EXPECT_CALL(*gl_, GetError()) |
| 2372 .WillOnce(Return(GL_NO_ERROR)) |
| 2373 .RetiresOnSaturation(); |
| 2374 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)).Times(1).RetiresOnSaturation(); |
| 2375 EXPECT_CALL(*image, DidUseTexImage()).Times(1).RetiresOnSaturation(); |
| 2376 EXPECT_CALL(*gl_, GetError()) |
| 2377 .WillOnce(Return(GL_NO_ERROR)) |
| 2378 .RetiresOnSaturation(); |
| 2379 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)).Times(1).RetiresOnSaturation(); |
| 2380 DrawElements cmd; |
| 2381 cmd.Init(GL_TRIANGLES, |
| 2382 kValidIndexRangeCount, |
| 2383 GL_UNSIGNED_SHORT, |
| 2384 kValidIndexRangeStart * 2); |
| 2385 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 2386 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 2387 } |
| 2388 |
| 2389 TEST_F(GLES2DecoderManualInitTest, TexImage2DFloatOnGLES2) { |
| 2390 InitState init; |
| 2391 init.extensions = "GL_OES_texture_float"; |
| 2392 init.gl_version = "opengl es 2.0"; |
| 2393 InitDecoder(init); |
| 2394 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 2395 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 17, 0, GL_RGBA, GL_FLOAT, 0, 0); |
| 2396 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 16, 17, 0, GL_RGB, GL_FLOAT, 0, 0); |
| 2397 DoTexImage2D( |
| 2398 GL_TEXTURE_2D, 0, GL_LUMINANCE, 16, 17, 0, GL_LUMINANCE, GL_FLOAT, 0, 0); |
| 2399 DoTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 16, 17, 0, GL_ALPHA, GL_FLOAT, 0, 0); |
| 2400 DoTexImage2D(GL_TEXTURE_2D, |
| 2401 0, |
| 2402 GL_LUMINANCE_ALPHA, |
| 2403 16, |
| 2404 17, |
| 2405 0, |
| 2406 GL_LUMINANCE_ALPHA, |
| 2407 GL_FLOAT, |
| 2408 0, |
| 2409 0); |
| 2410 } |
| 2411 |
| 2412 TEST_F(GLES2DecoderManualInitTest, TexImage2DFloatOnGLES3) { |
| 2413 InitState init; |
| 2414 init.extensions = "GL_OES_texture_float GL_EXT_color_buffer_float"; |
| 2415 init.gl_version = "opengl es 3.0"; |
| 2416 InitDecoder(init); |
| 2417 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 2418 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 17, 0, GL_RGBA, GL_FLOAT, 0, 0); |
| 2419 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 16, 17, 0, GL_RGB, GL_FLOAT, 0, 0); |
| 2420 DoTexImage2D( |
| 2421 GL_TEXTURE_2D, 0, GL_RGBA32F, 16, 17, 0, GL_RGBA, GL_FLOAT, 0, 0); |
| 2422 DoTexImage2D( |
| 2423 GL_TEXTURE_2D, 0, GL_LUMINANCE, 16, 17, 0, GL_LUMINANCE, GL_FLOAT, 0, 0); |
| 2424 DoTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 16, 17, 0, GL_ALPHA, GL_FLOAT, 0, 0); |
| 2425 DoTexImage2D(GL_TEXTURE_2D, |
| 2426 0, |
| 2427 GL_LUMINANCE_ALPHA, |
| 2428 16, |
| 2429 17, |
| 2430 0, |
| 2431 GL_LUMINANCE_ALPHA, |
| 2432 GL_FLOAT, |
| 2433 0, |
| 2434 0); |
| 2435 } |
| 2436 |
| 2437 TEST_F(GLES2DecoderManualInitTest, TexSubImage2DFloatOnGLES3) { |
| 2438 InitState init; |
| 2439 init.extensions = "GL_OES_texture_float GL_EXT_color_buffer_float"; |
| 2440 init.gl_version = "opengl es 3.0"; |
| 2441 InitDecoder(init); |
| 2442 const int kWidth = 8; |
| 2443 const int kHeight = 4; |
| 2444 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 2445 DoTexImage2D(GL_TEXTURE_2D, |
| 2446 0, |
| 2447 GL_RGBA32F, |
| 2448 kWidth, |
| 2449 kHeight, |
| 2450 0, |
| 2451 GL_RGBA, |
| 2452 GL_FLOAT, |
| 2453 0, |
| 2454 0); |
| 2455 EXPECT_CALL(*gl_, |
| 2456 TexImage2D(GL_TEXTURE_2D, |
| 2457 0, |
| 2458 GL_RGBA32F, |
| 2459 kWidth, |
| 2460 kHeight, |
| 2461 0, |
| 2462 GL_RGBA, |
| 2463 GL_FLOAT, |
| 2464 shared_memory_address_)) |
| 2465 .Times(1) |
| 2466 .RetiresOnSaturation(); |
| 2467 TexSubImage2D cmd; |
| 2468 cmd.Init(GL_TEXTURE_2D, |
| 2469 0, |
| 2470 0, |
| 2471 0, |
| 2472 kWidth, |
| 2473 kHeight, |
| 2474 GL_RGBA, |
| 2475 GL_FLOAT, |
| 2476 kSharedMemoryId, |
| 2477 kSharedMemoryOffset, |
| 2478 GL_FALSE); |
| 2479 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 2480 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 2481 } |
| 2482 |
| 2483 TEST_F(GLES2DecoderManualInitTest, TexSubImage2DFloatDoesClearOnGLES3) { |
| 2484 InitState init; |
| 2485 init.extensions = "GL_OES_texture_float GL_EXT_color_buffer_float"; |
| 2486 init.gl_version = "opengl es 3.0"; |
| 2487 InitDecoder(init); |
| 2488 const int kWidth = 8; |
| 2489 const int kHeight = 4; |
| 2490 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 2491 DoTexImage2D(GL_TEXTURE_2D, |
| 2492 0, |
| 2493 GL_RGBA32F, |
| 2494 kWidth, |
| 2495 kHeight, |
| 2496 0, |
| 2497 GL_RGBA, |
| 2498 GL_FLOAT, |
| 2499 0, |
| 2500 0); |
| 2501 SetupClearTextureExpectations(kServiceTextureId, |
| 2502 kServiceTextureId, |
| 2503 GL_TEXTURE_2D, |
| 2504 GL_TEXTURE_2D, |
| 2505 0, |
| 2506 GL_RGBA32F, |
| 2507 GL_RGBA, |
| 2508 GL_FLOAT, |
| 2509 kWidth, |
| 2510 kHeight); |
| 2511 EXPECT_CALL(*gl_, |
| 2512 TexSubImage2D(GL_TEXTURE_2D, |
| 2513 0, |
| 2514 1, |
| 2515 0, |
| 2516 kWidth - 1, |
| 2517 kHeight, |
| 2518 GL_RGBA, |
| 2519 GL_FLOAT, |
| 2520 shared_memory_address_)) |
| 2521 .Times(1) |
| 2522 .RetiresOnSaturation(); |
| 2523 TexSubImage2D cmd; |
| 2524 cmd.Init(GL_TEXTURE_2D, |
| 2525 0, |
| 2526 1, |
| 2527 0, |
| 2528 kWidth - 1, |
| 2529 kHeight, |
| 2530 GL_RGBA, |
| 2531 GL_FLOAT, |
| 2532 kSharedMemoryId, |
| 2533 kSharedMemoryOffset, |
| 2534 GL_FALSE); |
| 2535 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 2536 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 2537 } |
| 2538 |
| 2539 TEST_F(GLES2DecoderManualInitTest, TexImage2DFloatConvertsFormatDesktop) { |
| 2540 InitState init; |
| 2541 init.extensions = "GL_ARB_texture_float"; |
| 2542 init.gl_version = "2.1"; |
| 2543 InitDecoder(init); |
| 2544 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 2545 DoTexImage2D( |
| 2546 GL_TEXTURE_2D, 0, GL_RGBA32F, 16, 17, 0, GL_RGBA, GL_FLOAT, 0, 0); |
| 2547 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, 16, 17, 0, GL_RGB, GL_FLOAT, 0, 0); |
| 2548 DoTexImage2DConvertInternalFormat(GL_TEXTURE_2D, |
| 2549 0, |
| 2550 GL_RGBA, |
| 2551 16, |
| 2552 17, |
| 2553 0, |
| 2554 GL_RGBA, |
| 2555 GL_FLOAT, |
| 2556 0, |
| 2557 0, |
| 2558 GL_RGBA32F_ARB); |
| 2559 DoTexImage2DConvertInternalFormat(GL_TEXTURE_2D, |
| 2560 0, |
| 2561 GL_RGB, |
| 2562 16, |
| 2563 17, |
| 2564 0, |
| 2565 GL_RGB, |
| 2566 GL_FLOAT, |
| 2567 0, |
| 2568 0, |
| 2569 GL_RGB32F_ARB); |
| 2570 DoTexImage2DConvertInternalFormat(GL_TEXTURE_2D, |
| 2571 0, |
| 2572 GL_LUMINANCE, |
| 2573 16, |
| 2574 17, |
| 2575 0, |
| 2576 GL_LUMINANCE, |
| 2577 GL_FLOAT, |
| 2578 0, |
| 2579 0, |
| 2580 GL_LUMINANCE32F_ARB); |
| 2581 DoTexImage2DConvertInternalFormat(GL_TEXTURE_2D, |
| 2582 0, |
| 2583 GL_ALPHA, |
| 2584 16, |
| 2585 17, |
| 2586 0, |
| 2587 GL_ALPHA, |
| 2588 GL_FLOAT, |
| 2589 0, |
| 2590 0, |
| 2591 GL_ALPHA32F_ARB); |
| 2592 DoTexImage2DConvertInternalFormat(GL_TEXTURE_2D, |
| 2593 0, |
| 2594 GL_LUMINANCE_ALPHA, |
| 2595 16, |
| 2596 17, |
| 2597 0, |
| 2598 GL_LUMINANCE_ALPHA, |
| 2599 GL_FLOAT, |
| 2600 0, |
| 2601 0, |
| 2602 GL_LUMINANCE_ALPHA32F_ARB); |
| 2603 } |
| 2604 |
| 2605 class GLES2DecoderCompressedFormatsTest : public GLES2DecoderManualInitTest { |
| 2606 public: |
| 2607 GLES2DecoderCompressedFormatsTest() {} |
| 2608 |
| 2609 static bool ValueInArray(GLint value, GLint* array, GLint count) { |
| 2610 for (GLint ii = 0; ii < count; ++ii) { |
| 2611 if (array[ii] == value) { |
| 2612 return true; |
| 2613 } |
| 2614 } |
| 2615 return false; |
| 2616 } |
| 2617 |
| 2618 void CheckFormats(const char* extension, const GLenum* formats, int count) { |
| 2619 InitState init; |
| 2620 init.extensions = extension; |
| 2621 init.gl_version = "3.0"; |
| 2622 init.bind_generates_resource = true; |
| 2623 InitDecoder(init); |
| 2624 |
| 2625 EXPECT_CALL(*gl_, GetError()) |
| 2626 .WillOnce(Return(GL_NO_ERROR)) |
| 2627 .WillOnce(Return(GL_NO_ERROR)) |
| 2628 .WillOnce(Return(GL_NO_ERROR)) |
| 2629 .WillOnce(Return(GL_NO_ERROR)) |
| 2630 .RetiresOnSaturation(); |
| 2631 |
| 2632 typedef GetIntegerv::Result Result; |
| 2633 Result* result = static_cast<Result*>(shared_memory_address_); |
| 2634 GetIntegerv cmd; |
| 2635 result->size = 0; |
| 2636 EXPECT_CALL(*gl_, GetIntegerv(_, _)).Times(0).RetiresOnSaturation(); |
| 2637 cmd.Init(GL_NUM_COMPRESSED_TEXTURE_FORMATS, |
| 2638 shared_memory_id_, |
| 2639 shared_memory_offset_); |
| 2640 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 2641 EXPECT_EQ(1, result->GetNumResults()); |
| 2642 GLint num_formats = result->GetData()[0]; |
| 2643 EXPECT_EQ(count, num_formats); |
| 2644 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 2645 |
| 2646 result->size = 0; |
| 2647 cmd.Init(GL_COMPRESSED_TEXTURE_FORMATS, |
| 2648 shared_memory_id_, |
| 2649 shared_memory_offset_); |
| 2650 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 2651 EXPECT_EQ(num_formats, result->GetNumResults()); |
| 2652 |
| 2653 for (int i = 0; i < count; ++i) { |
| 2654 EXPECT_TRUE( |
| 2655 ValueInArray(formats[i], result->GetData(), result->GetNumResults())); |
| 2656 } |
| 2657 |
| 2658 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 2659 } |
| 2660 }; |
| 2661 |
| 2662 TEST_F(GLES2DecoderCompressedFormatsTest, GetCompressedTextureFormatsS3TC) { |
| 2663 const GLenum formats[] = { |
| 2664 GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, |
| 2665 GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT}; |
| 2666 CheckFormats("GL_EXT_texture_compression_s3tc", formats, 4); |
| 2667 } |
| 2668 |
| 2669 TEST_F(GLES2DecoderCompressedFormatsTest, GetCompressedTextureFormatsATC) { |
| 2670 const GLenum formats[] = {GL_ATC_RGB_AMD, GL_ATC_RGBA_EXPLICIT_ALPHA_AMD, |
| 2671 GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD}; |
| 2672 CheckFormats("GL_AMD_compressed_ATC_texture", formats, 3); |
| 2673 } |
| 2674 |
| 2675 TEST_F(GLES2DecoderCompressedFormatsTest, GetCompressedTextureFormatsPVRTC) { |
| 2676 const GLenum formats[] = { |
| 2677 GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG, GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG, |
| 2678 GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}; |
| 2679 CheckFormats("GL_IMG_texture_compression_pvrtc", formats, 4); |
| 2680 } |
| 2681 |
| 2682 TEST_F(GLES2DecoderCompressedFormatsTest, GetCompressedTextureFormatsETC1) { |
| 2683 const GLenum formats[] = {GL_ETC1_RGB8_OES}; |
| 2684 CheckFormats("GL_OES_compressed_ETC1_RGB8_texture", formats, 1); |
| 2685 } |
| 2686 |
| 2687 TEST_F(GLES2DecoderManualInitTest, GetNoCompressedTextureFormats) { |
| 2688 InitState init; |
| 2689 init.gl_version = "3.0"; |
| 2690 init.bind_generates_resource = true; |
| 2691 InitDecoder(init); |
| 2692 |
| 2693 EXPECT_CALL(*gl_, GetError()) |
| 2694 .WillOnce(Return(GL_NO_ERROR)) |
| 2695 .WillOnce(Return(GL_NO_ERROR)) |
| 2696 .WillOnce(Return(GL_NO_ERROR)) |
| 2697 .WillOnce(Return(GL_NO_ERROR)) |
| 2698 .RetiresOnSaturation(); |
| 2699 |
| 2700 typedef GetIntegerv::Result Result; |
| 2701 Result* result = static_cast<Result*>(shared_memory_address_); |
| 2702 GetIntegerv cmd; |
| 2703 result->size = 0; |
| 2704 EXPECT_CALL(*gl_, GetIntegerv(_, _)).Times(0).RetiresOnSaturation(); |
| 2705 cmd.Init(GL_NUM_COMPRESSED_TEXTURE_FORMATS, |
| 2706 shared_memory_id_, |
| 2707 shared_memory_offset_); |
| 2708 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 2709 EXPECT_EQ(1, result->GetNumResults()); |
| 2710 GLint num_formats = result->GetData()[0]; |
| 2711 EXPECT_EQ(0, num_formats); |
| 2712 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 2713 |
| 2714 result->size = 0; |
| 2715 cmd.Init( |
| 2716 GL_COMPRESSED_TEXTURE_FORMATS, shared_memory_id_, shared_memory_offset_); |
| 2717 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 2718 EXPECT_EQ(num_formats, result->GetNumResults()); |
| 2719 |
| 2720 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 2721 } |
| 2722 |
| 2723 // TODO(gman): Complete this test. |
| 2724 // TEST_F(GLES2DecoderTest, CompressedTexImage2DGLError) { |
| 2725 // } |
| 2726 |
| 2727 // TODO(gman): CompressedTexImage2D |
| 2728 |
| 2729 // TODO(gman): CompressedTexImage2DImmediate |
| 2730 |
| 2731 // TODO(gman): CompressedTexSubImage2DImmediate |
| 2732 |
| 2733 // TODO(gman): TexImage2D |
| 2734 |
| 2735 // TODO(gman): TexImage2DImmediate |
| 2736 |
| 2737 // TODO(gman): TexSubImage2DImmediate |
| 2738 |
| 2739 } // namespace gles2 |
| 2740 } // namespace gpu |
OLD | NEW |