OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
6 | 6 |
7 #include "base/atomicops.h" | 7 #include "base/atomicops.h" |
8 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 8 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
9 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 9 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
10 #include "gpu/command_buffer/common/gl_mock.h" | 10 #include "gpu/command_buffer/common/gl_mock.h" |
(...skipping 4270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4281 ASSERT_TRUE(bucket != NULL); | 4281 ASSERT_TRUE(bucket != NULL); |
4282 EXPECT_EQ(sizeof(ProgramInfoHeader), bucket->size()); | 4282 EXPECT_EQ(sizeof(ProgramInfoHeader), bucket->size()); |
4283 ProgramInfoHeader* info = bucket->GetDataAs<ProgramInfoHeader*>( | 4283 ProgramInfoHeader* info = bucket->GetDataAs<ProgramInfoHeader*>( |
4284 0, sizeof(ProgramInfoHeader)); | 4284 0, sizeof(ProgramInfoHeader)); |
4285 ASSERT_TRUE(info != 0); | 4285 ASSERT_TRUE(info != 0); |
4286 EXPECT_EQ(0u, info->link_status); | 4286 EXPECT_EQ(0u, info->link_status); |
4287 EXPECT_EQ(0u, info->num_attribs); | 4287 EXPECT_EQ(0u, info->num_attribs); |
4288 EXPECT_EQ(0u, info->num_uniforms); | 4288 EXPECT_EQ(0u, info->num_uniforms); |
4289 } | 4289 } |
4290 | 4290 |
| 4291 TEST_F(GLES2DecoderManualInitTest, EGLImageExternalBindTexture) { |
| 4292 InitDecoder( |
| 4293 "GL_OES_EGL_image_external", // extensions |
| 4294 false, // has alpha |
| 4295 false, // has depth |
| 4296 false, // has stencil |
| 4297 false, // request alpha |
| 4298 false, // request depth |
| 4299 false); // request stencil |
| 4300 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_EXTERNAL_OES, kNewServiceId)); |
| 4301 EXPECT_CALL(*gl_, GenTextures(1, _)) |
| 4302 .WillOnce(SetArgumentPointee<1>(kNewServiceId)); |
| 4303 BindTexture cmd; |
| 4304 cmd.Init(GL_TEXTURE_EXTERNAL_OES, kNewClientId); |
| 4305 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4306 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 4307 TextureManager::TextureInfo* info = GetTextureInfo(kNewClientId); |
| 4308 EXPECT_TRUE(info != NULL); |
| 4309 EXPECT_TRUE(info->target() == GL_TEXTURE_EXTERNAL_OES); |
| 4310 } |
| 4311 |
| 4312 TEST_F(GLES2DecoderManualInitTest, EGLImageExternalGetBinding) { |
| 4313 InitDecoder( |
| 4314 "GL_OES_EGL_image_external", // extensions |
| 4315 false, // has alpha |
| 4316 false, // has depth |
| 4317 false, // has stencil |
| 4318 false, // request alpha |
| 4319 false, // request depth |
| 4320 false); // request stencil |
| 4321 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); |
| 4322 |
| 4323 EXPECT_CALL(*gl_, GetError()) |
| 4324 .WillOnce(Return(GL_NO_ERROR)) |
| 4325 .WillOnce(Return(GL_NO_ERROR)) |
| 4326 .RetiresOnSaturation(); |
| 4327 typedef GetIntegerv::Result Result; |
| 4328 Result* result = static_cast<Result*>(shared_memory_address_); |
| 4329 EXPECT_CALL(*gl_, GetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES, |
| 4330 result->GetData())) |
| 4331 .Times(0); |
| 4332 result->size = 0; |
| 4333 GetIntegerv cmd; |
| 4334 cmd.Init(GL_TEXTURE_BINDING_EXTERNAL_OES, |
| 4335 shared_memory_id_, |
| 4336 shared_memory_offset_); |
| 4337 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4338 EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned( |
| 4339 GL_TEXTURE_BINDING_EXTERNAL_OES), result->GetNumResults()); |
| 4340 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 4341 EXPECT_EQ(client_texture_id_, (uint32)result->GetData()[0]); |
| 4342 } |
| 4343 |
| 4344 TEST_F(GLES2DecoderManualInitTest, EGLImageExternalTextureDefaults) { |
| 4345 InitDecoder( |
| 4346 "GL_OES_EGL_image_external", // extensions |
| 4347 false, // has alpha |
| 4348 false, // has depth |
| 4349 false, // has stencil |
| 4350 false, // request alpha |
| 4351 false, // request depth |
| 4352 false); // request stencil |
| 4353 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); |
| 4354 |
| 4355 TextureManager::TextureInfo* info = GetTextureInfo(client_texture_id_); |
| 4356 EXPECT_TRUE(info != NULL); |
| 4357 EXPECT_TRUE(info->target() == GL_TEXTURE_EXTERNAL_OES); |
| 4358 EXPECT_TRUE(info->min_filter() == GL_LINEAR); |
| 4359 EXPECT_TRUE(info->wrap_s() == GL_CLAMP_TO_EDGE); |
| 4360 EXPECT_TRUE(info->wrap_t() == GL_CLAMP_TO_EDGE); |
| 4361 } |
| 4362 |
| 4363 TEST_F(GLES2DecoderManualInitTest, EGLImageExternalTextureParam) { |
| 4364 InitDecoder( |
| 4365 "GL_OES_EGL_image_external", // extensions |
| 4366 false, // has alpha |
| 4367 false, // has depth |
| 4368 false, // has stencil |
| 4369 false, // request alpha |
| 4370 false, // request depth |
| 4371 false); // request stencil |
| 4372 |
| 4373 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); |
| 4374 |
| 4375 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_EXTERNAL_OES, |
| 4376 GL_TEXTURE_MIN_FILTER, |
| 4377 GL_NEAREST)); |
| 4378 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_EXTERNAL_OES, |
| 4379 GL_TEXTURE_MIN_FILTER, |
| 4380 GL_LINEAR)); |
| 4381 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_EXTERNAL_OES, |
| 4382 GL_TEXTURE_WRAP_S, |
| 4383 GL_CLAMP_TO_EDGE)); |
| 4384 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_EXTERNAL_OES, |
| 4385 GL_TEXTURE_WRAP_T, |
| 4386 GL_CLAMP_TO_EDGE)); |
| 4387 TexParameteri cmd; |
| 4388 cmd.Init(GL_TEXTURE_EXTERNAL_OES, |
| 4389 GL_TEXTURE_MIN_FILTER, |
| 4390 GL_NEAREST); |
| 4391 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4392 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 4393 |
| 4394 cmd.Init(GL_TEXTURE_EXTERNAL_OES, |
| 4395 GL_TEXTURE_MIN_FILTER, |
| 4396 GL_LINEAR); |
| 4397 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4398 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 4399 |
| 4400 cmd.Init(GL_TEXTURE_EXTERNAL_OES, |
| 4401 GL_TEXTURE_WRAP_S, |
| 4402 GL_CLAMP_TO_EDGE); |
| 4403 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4404 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 4405 |
| 4406 cmd.Init(GL_TEXTURE_EXTERNAL_OES, |
| 4407 GL_TEXTURE_WRAP_T, |
| 4408 GL_CLAMP_TO_EDGE); |
| 4409 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4410 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 4411 |
| 4412 TextureManager::TextureInfo* info = GetTextureInfo(client_texture_id_); |
| 4413 EXPECT_TRUE(info != NULL); |
| 4414 EXPECT_TRUE(info->target() == GL_TEXTURE_EXTERNAL_OES); |
| 4415 EXPECT_TRUE(info->min_filter() == GL_LINEAR); |
| 4416 EXPECT_TRUE(info->wrap_s() == GL_CLAMP_TO_EDGE); |
| 4417 EXPECT_TRUE(info->wrap_t() == GL_CLAMP_TO_EDGE); |
| 4418 } |
| 4419 |
| 4420 TEST_F(GLES2DecoderManualInitTest, EGLImageExternalTextureParamInvalid) { |
| 4421 InitDecoder( |
| 4422 "GL_OES_EGL_image_external", // extensions |
| 4423 false, // has alpha |
| 4424 false, // has depth |
| 4425 false, // has stencil |
| 4426 false, // request alpha |
| 4427 false, // request depth |
| 4428 false); // request stencil |
| 4429 |
| 4430 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); |
| 4431 |
| 4432 TexParameteri cmd; |
| 4433 cmd.Init(GL_TEXTURE_EXTERNAL_OES, |
| 4434 GL_TEXTURE_MIN_FILTER, |
| 4435 GL_NEAREST_MIPMAP_NEAREST); |
| 4436 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4437 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 4438 |
| 4439 cmd.Init(GL_TEXTURE_EXTERNAL_OES, |
| 4440 GL_TEXTURE_WRAP_S, |
| 4441 GL_REPEAT); |
| 4442 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4443 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 4444 |
| 4445 cmd.Init(GL_TEXTURE_EXTERNAL_OES, |
| 4446 GL_TEXTURE_WRAP_T, |
| 4447 GL_REPEAT); |
| 4448 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4449 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 4450 |
| 4451 TextureManager::TextureInfo* info = GetTextureInfo(client_texture_id_); |
| 4452 EXPECT_TRUE(info != NULL); |
| 4453 EXPECT_TRUE(info->target() == GL_TEXTURE_EXTERNAL_OES); |
| 4454 EXPECT_TRUE(info->min_filter() == GL_LINEAR); |
| 4455 EXPECT_TRUE(info->wrap_s() == GL_CLAMP_TO_EDGE); |
| 4456 EXPECT_TRUE(info->wrap_t() == GL_CLAMP_TO_EDGE); |
| 4457 } |
| 4458 |
| 4459 TEST_F(GLES2DecoderManualInitTest, EGLImageExternalTexImage2DError) { |
| 4460 InitDecoder( |
| 4461 "GL_OES_EGL_image_external", // extensions |
| 4462 false, // has alpha |
| 4463 false, // has depth |
| 4464 false, // has stencil |
| 4465 false, // request alpha |
| 4466 false, // request depth |
| 4467 false); // request stencil |
| 4468 |
| 4469 GLenum target = GL_TEXTURE_EXTERNAL_OES; |
| 4470 GLint level = 0; |
| 4471 GLenum internal_format = GL_RGBA; |
| 4472 GLsizei width = 2; |
| 4473 GLsizei height = 4; |
| 4474 GLint border = 0; |
| 4475 GLenum format = GL_RGBA; |
| 4476 GLenum type = GL_UNSIGNED_BYTE; |
| 4477 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); |
| 4478 ASSERT_TRUE(GetTextureInfo(client_texture_id_) != NULL); |
| 4479 TexImage2D cmd; |
| 4480 cmd.Init(target, level, internal_format, width, height, border, format, |
| 4481 type, kSharedMemoryId, kSharedMemoryOffset); |
| 4482 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4483 |
| 4484 // TexImage2D is not allowed with GL_TEXTURE_EXTERNAL_OES targets. |
| 4485 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 4486 } |
| 4487 |
4291 // TODO(gman): Complete this test. | 4488 // TODO(gman): Complete this test. |
4292 // TEST_F(GLES2DecoderTest, CompressedTexImage2DGLError) { | 4489 // TEST_F(GLES2DecoderTest, CompressedTexImage2DGLError) { |
4293 // } | 4490 // } |
4294 | 4491 |
4295 // TODO(gman): BufferData | 4492 // TODO(gman): BufferData |
4296 | 4493 |
4297 // TODO(gman): BufferDataImmediate | 4494 // TODO(gman): BufferDataImmediate |
4298 | 4495 |
4299 // TODO(gman): BufferSubData | 4496 // TODO(gman): BufferSubData |
4300 | 4497 |
(...skipping 16 matching lines...) Expand all Loading... |
4317 // TODO(gman): TexImage2DImmediate | 4514 // TODO(gman): TexImage2DImmediate |
4318 | 4515 |
4319 // TODO(gman): TexSubImage2DImmediate | 4516 // TODO(gman): TexSubImage2DImmediate |
4320 | 4517 |
4321 // TODO(gman): UseProgram | 4518 // TODO(gman): UseProgram |
4322 | 4519 |
4323 // TODO(gman): SwapBuffers | 4520 // TODO(gman): SwapBuffers |
4324 | 4521 |
4325 } // namespace gles2 | 4522 } // namespace gles2 |
4326 } // namespace gpu | 4523 } // namespace gpu |
OLD | NEW |